D7wmguihua/应收应付/U_YSHZMXOLJ.pas
DESKTOP-E401PHE\Administrator b4b5840f18 1
2025-01-18 16:22:10 +08:00

427 lines
11 KiB
ObjectPascal
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

unit U_YSHZMXOLJ;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, cxGraphics, cxCustomData, cxStyles, cxTL, cxMaskEdit, DB, ADODB,
cxInplaceContainer, cxDBTL, cxControls, cxTLData, ComCtrls, ToolWin,
StdCtrls, cxFilter, cxData, cxDataStorage, cxEdit, cxDBData, DBClient,
cxGridCustomTableView, cxGridTableView, cxGridDBTableView, ExtCtrls,
cxSplitter, cxGridLevel, cxClasses, cxGridCustomView, cxGrid,
cxGridCustomPopupMenu, cxGridPopupMenu, RM_Dataset, RM_System, RM_Common,
RM_Class, RM_GridReport, IdBaseComponent, IdComponent, IdTCPConnection,
IdTCPClient, IdFTP,ShellAPI,IniFiles, cxCheckBox, cxCalendar,
cxButtonEdit, cxTextEdit, cxDropDownEdit;
type
TfrmYSHZMXOLJ = class(TForm)
ToolBar1: TToolBar;
TBRafresh: TToolButton;
TBClose: TToolButton;
ADOQueryTemp: TADOQuery;
ADOQueryCmd: TADOQuery;
Panel1: TPanel;
ToolButton2: TToolButton;
Label1: TLabel;
CustomerNoName: TEdit;
ADOQueryMain: TADOQuery;
ToolButton1: TToolButton;
RM1: TRMGridReport;
RMDB_Main: TRMDBDataSet;
Label3: TLabel;
OrderNo: TEdit;
cxGrid2: TcxGrid;
Tv2: TcxGridDBTableView;
cxGridDBColumn1: TcxGridDBColumn;
cxGridDBColumn3: TcxGridDBColumn;
cxGridDBColumn5: TcxGridDBColumn;
cxGridLevel1: TcxGridLevel;
Label2: TLabel;
Label6: TLabel;
begdate: TDateTimePicker;
Enddate: TDateTimePicker;
cxGridPopupMenu2: TcxGridPopupMenu;
DS_HZ: TDataSource;
CDS_HZ: TClientDataSet;
v2Column1: TcxGridDBColumn;
VHL: TcxGridDBColumn;
VBZ: TcxGridDBColumn;
VYB: TcxGridDBColumn;
VBB: TcxGridDBColumn;
VOrderNo: TcxGridDBColumn;
v2PS: TcxGridDBColumn;
v2Column2: TcxGridDBColumn;
v2Column3: TcxGridDBColumn;
v2Column4: TcxGridDBColumn;
v2Column5: TcxGridDBColumn;
Label4: TLabel;
Label5: TLabel;
PRTCodeName: TEdit;
SCNO: TEdit;
Label7: TLabel;
Label8: TLabel;
PRTColor: TEdit;
PRTSpec: TEdit;
procedure FormDestroy(Sender: TObject);
procedure FormClose(Sender: TObject; var Action: TCloseAction);
procedure TBCloseClick(Sender: TObject);
procedure FormShow(Sender: TObject);
procedure TBRafreshClick(Sender: TObject);
procedure ToolButton2Click(Sender: TObject);
procedure P_OrderNo_YSK(Sender: TObject);
procedure cxGridDBColumn8PropertiesEditValueChanged(Sender: TObject);
procedure cxGridDBColumn5PropertiesEditValueChanged(Sender: TObject);
procedure cxGridDBColumn1PropertiesEditValueChanged(Sender: TObject);
procedure ToolButton1Click(Sender: TObject);
procedure v2Column2PropertiesEditValueChanged(Sender: TObject);
procedure v2Column5PropertiesEditValueChanged(Sender: TObject);
procedure OrderNoChange(Sender: TObject);
procedure CustomerNoNameChange(Sender: TObject);
procedure SCNOChange(Sender: TObject);
private
{ Private declarations }
procedure InitGrid();
public
{ Public declarations }
RKFlag,FCYID:String;
end;
var
frmYSHZMXOLJ: TfrmYSHZMXOLJ;
implementation
uses
U_DataLink,U_Fun,U_ZDYHelp, U_ProductOrderNewList;
{$R *.dfm}
procedure TfrmYSHZMXOLJ.InitGrid();
begin
try
ADOQueryMain.DisableControls;
with ADOQueryMain do
begin
Filtered:=False;
Close;
SQL.Clear;
sql.Add(' exec P_OrderNo_YSK :begdate,:enddate');
Parameters.ParamByName('begdate').Value:=Trim(FormatDateTime('yyyy-MM-dd',begdate.DateTime));
Parameters.ParamByName('Enddate').Value:=Trim(FormatDateTime('yyyy-MM-dd',Enddate.DateTime+1));
Open;
end;
SCreateCDS20(ADOQueryMain,CDS_HZ);
SInitCDSData20(ADOQueryMain,CDS_HZ);
finally
ADOQueryMain.EnableControls;
end;
end;
procedure TfrmYSHZMXOLJ.FormDestroy(Sender: TObject);
begin
frmYSHZMXOLJ:=nil;
end;
procedure TfrmYSHZMXOLJ.FormClose(Sender: TObject; var Action: TCloseAction);
begin
Action:=caFree;
end;
procedure TfrmYSHZMXOLJ.TBCloseClick(Sender: TObject);
begin
WriteCxGrid(<><D3A6><EFBFBD>˿<EFBFBD><CBBF><EFBFBD>ϸ',Tv2,'<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>');
Close;
end;
procedure TfrmYSHZMXOLJ.FormShow(Sender: TObject);
begin
ReadCxGrid(<><D3A6><EFBFBD>˿<EFBFBD><CBBF><EFBFBD>ϸ',Tv2,'<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>');
Enddate.DateTime:=SGetServerDate(ADOQueryTemp);
begdate.DateTime:=Enddate.DateTime-50;
InitGrid();
end;
procedure TfrmYSHZMXOLJ.TBRafreshClick(Sender: TObject);
begin
begdate.SetFocus;
InitGrid();
end;
procedure TfrmYSHZMXOLJ.ToolButton2Click(Sender: TObject);
var
fsj:string;
begin
if ADOQueryMain.Active=False then Exit;
if Trim(SGetFilters(Panel1,1,2))='' then
begin
if Trim(CustomerNoName.Text)<>'' then
begin
fsj:=' CustomerNoName like '''+'%'+Trim(CustomerNoName.Text)+'%'+''''
+' or KHZJM like '''+'%'+Trim(CustomerNoName.Text)+'%'+'''';
end;
end else
begin
if Trim(CustomerNoName.Text)<>'' then
begin
fsj:=SGetFilters(Panel1,1,2)+' and (CustomerNoName like '''+'%'+Trim(CustomerNoName.Text)+'%'+''''
+' or KHZJM like '''+'%'+Trim(CustomerNoName.Text)+'%'+''')';
end;
end;
SDofilter(ADOQueryMain,fsj);
SCreateCDS20(ADOQueryMain,CDS_HZ);
SInitCDSData20(ADOQueryMain,CDS_HZ);
end;
procedure TfrmYSHZMXOLJ.P_OrderNo_YSK(Sender: TObject);
begin
ToolButton2.Click;
end;
procedure TfrmYSHZMXOLJ.cxGridDBColumn8PropertiesEditValueChanged(
Sender: TObject);
var
mvalue,FFieldName:String;
begin
mvalue:=TcxTextEdit(Sender).EditingText;
FFieldName:=Trim(Tv2.Controller.FocusedColumn.DataBinding.FilterFieldName);
with CDS_HZ do
begin
Edit;
FieldByName(FFieldName).Value:=Trim(mvalue);
Post;
end;
with ADOQueryCmd do
begin
Close;
sql.Clear;
sql.Add('UPdate YCL_SG_HZ ');
if Trim(mvalue)<>'' then
begin
sql.Add(' Set '+FFieldName+'='''+Trim(mvalue)+'''');
end else
begin
sql.Add(' Set '+FFieldName+'=NULL');
end;
SQL.Add(',Editer='''+Trim(DName)+'''');
SQL.Add(',Edittime=getdate() ');
SQL.Add(' where SubId='''+Trim(CDS_HZ.fieldbyname('SubId').AsString)+'''');
ExecSQL;
end;
end;
procedure TfrmYSHZMXOLJ.cxGridDBColumn5PropertiesEditValueChanged(
Sender: TObject);
var
mvalue,FQty,FPrice,FMoney,FHuiLv,FBBMoney,FKCBB,FFieldName:String;
begin
{if Trim(CDS_HZ.fieldbyname('YFType').AsString)<>'' then
begin
Application.MessageBox('<27>Զ<EFBFBD><D4B6><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ݲ<EFBFBD><DDB2>ܸ<EFBFBD><DCB8><EFBFBD>!','<27><>ʾ',0);
Exit;
end; }
mvalue:=TcxTextEdit(Sender).EditingText;
if Trim(mvalue)='' then
begin
mvalue:='0';
end;
FFieldName:=Trim(Tv2.Controller.FocusedColumn.DataBinding.FilterFieldName);
with CDS_HZ do
begin
Edit;
FieldByName(FFieldName).Value:=Trim(mvalue);
if Trim(DParameters2)='<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>' then
begin
FieldByName('HuiLv').Value:=1;
end;
Post;
end;
with ADOQueryTemp do
begin
Close;
sql.Clear;
sql.Add('select isnull(BBMoney,0) BBMoney from YF_Money_CR where YFID='''+cds_hz.fieldbyname('YFID').AsString+'''');
Open;
end;
FKCBB:=ADOQueryTemp.fieldbyname('BBMoney').AsString;
FQty:=Trim(CDS_HZ.fieldbyname('Qty').AsString);
if Trim(FQty)='' then FQty:='0';
FPrice:=Trim(CDS_HZ.fieldbyname('Price').AsString);
if Trim(FPrice)='' then FPrice:='0';
FQty:=Trim(CDS_HZ.fieldbyname('Qty').AsString);
if Trim(FQty)='' then FQty:='0';
FMoney:=Trim(CDS_HZ.fieldbyname('Money').AsString);
if Trim(FMoney)='' then FMoney:='0';
FHuiLv:=Trim(CDS_HZ.fieldbyname('HuiLv').AsString);
if Trim(FHuiLv)='' then FHuiLv:='0';
{FBBMoney:=Trim(CDS_HZ.fieldbyname('BBMoney').AsString);
if Trim(FBBMoney)='' then FBBMoney:='0'; }
if Trim(FFieldName)<>'Money' then
begin
if Trim(FFieldName)<>'HuiLv' then
begin
FBBMoney:=FloatToStr(StrToFloat(FQty)*StrToFloat(FPrice)*StrToFloat(FHuiLv));
FMoney:=FloatToStr(StrToFloat(FQty)*StrToFloat(FPrice));
end else
begin
FBBMoney:=FloatToStr(StrToFloat(FMoney)*StrToFloat(FHuiLv));
end;
end else
begin
FBBMoney:=FloatToStr(StrToFloat(FMoney)*StrToFloat(FHuiLv));
end;
with CDS_HZ do
begin
Edit;
FieldByName('Money').Value:=StrToFloat(FMoney);
FieldByName('BBMoney').Value:=StrToFloat(FBBMoney);
Post;
end;
with ADOQueryCmd do
begin
Close;
sql.Clear;
sql.Add('UPdate YF_Money_CR ');
sql.Add(' Set '+FFieldName+'='+Trim(mvalue));
if Trim(FFieldName)<>'Money' then
begin
sql.Add(',Money='+FMoney);
end;
sql.Add(',BBMoney='+FBBMoney);
SQL.Add(',Editer='''+Trim(DName)+'''');
SQL.Add(',Edittime=getdate() ');
SQL.Add(' where YFId='''+Trim(CDS_HZ.fieldbyname('YFId').AsString)+'''');
SQL.Add('Update YF_Money_KC Set KCBBMoney=KCBBMoney-'+FKCBB+'+'+FBBMoney);
sql.Add(' where CRID='''+Trim(CDS_HZ.fieldbyname('CRID').AsString)+'''');
ExecSQL;
end;
end;
procedure TfrmYSHZMXOLJ.cxGridDBColumn1PropertiesEditValueChanged(
Sender: TObject);
var
mvalue,FFieldName:String;
begin
mvalue:=TcxTextEdit(Sender).EditingText;
FFieldName:=Trim(Tv2.Controller.FocusedColumn.DataBinding.FilterFieldName);
with CDS_HZ do
begin
Edit;
FieldByName(FFieldName).Value:=Trim(mvalue);
Post;
end;
with ADOQueryCmd do
begin
Close;
sql.Clear;
sql.Add('UPdate JYOrder_Main ');
if Trim(mvalue)<>'' then
begin
sql.Add(' Set '+FFieldName+'='''+Trim(mvalue)+'''');
end else
begin
sql.Add(' Set '+FFieldName+'=NULL');
end;
SQL.Add(' where MainId='''+Trim(CDS_HZ.fieldbyname('MainId').AsString)+'''');
ExecSQL;
end;
end;
procedure TfrmYSHZMXOLJ.ToolButton1Click(Sender: TObject);
begin
if ADOQueryMain.IsEmpty then Exit;
SelExportData(Tv2,ADOQueryMain,<><D3A6><EFBFBD>˿<EFBFBD><CBBF>б<EFBFBD>');
end;
procedure TfrmYSHZMXOLJ.v2Column2PropertiesEditValueChanged(Sender: TObject);
var
mvalue,FFieldName:String;
begin
mvalue:=TcxTextEdit(Sender).EditingText;
FFieldName:=Trim(Tv2.Controller.FocusedColumn.DataBinding.FilterFieldName);
with CDS_HZ do
begin
Edit;
FieldByName(FFieldName).Value:=Trim(mvalue);
Post;
end;
with ADOQueryCmd do
begin
Close;
sql.Clear;
sql.Add('UPdate JYOrder_Sub ');
if Trim(mvalue)<>'' then
begin
sql.Add(' Set '+FFieldName+'='''+Trim(mvalue)+'''');
end else
begin
sql.Add(' Set '+FFieldName+'=NULL');
end;
SQL.Add(' where SubId='''+Trim(CDS_HZ.fieldbyname('SubId').AsString)+'''');
ExecSQL;
end;
end;
procedure TfrmYSHZMXOLJ.v2Column5PropertiesEditValueChanged(Sender: TObject);
var
mvalue,FFieldName:String;
begin
mvalue:=TcxComboBox(Sender).EditingText;
FFieldName:=Trim(Tv2.Controller.FocusedColumn.DataBinding.FilterFieldName);
with CDS_HZ do
begin
Edit;
FieldByName(FFieldName).Value:=Trim(mvalue);
Post;
end;
with ADOQueryCmd do
begin
Close;
sql.Clear;
sql.Add('UPdate JYOrder_Main ');
if Trim(mvalue)<>'' then
begin
sql.Add(' Set '+FFieldName+'='''+Trim(mvalue)+'''');
end else
begin
sql.Add(' Set '+FFieldName+'=NULL');
end;
SQL.Add(' where MainId='''+Trim(CDS_HZ.fieldbyname('MainId').AsString)+'''');
ExecSQL;
end;
end;
procedure TfrmYSHZMXOLJ.OrderNoChange(Sender: TObject);
begin
if Length(Trim(OrderNo.Text))<3 then Exit;
ToolButton2.Click;
end;
procedure TfrmYSHZMXOLJ.CustomerNoNameChange(Sender: TObject);
begin
ToolButton2.Click;
end;
procedure TfrmYSHZMXOLJ.SCNOChange(Sender: TObject);
begin
ToolButton2.Click;
end;
end.