D7wmguihua/坯布码单待检(PBMDDJ.dll)/U_SKCRCYZZ.pas
DESKTOP-E401PHE\Administrator b4b5840f18 1
2025-01-18 16:22:10 +08:00

543 lines
15 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_SKCRCYZZ;
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
TfrmSKCRCYZZ = class(TForm)
ToolBar1: TToolBar;
TBRafresh: TToolButton;
TBDel: TToolButton;
TBClose: TToolButton;
ADOQueryTemp: TADOQuery;
ADOQueryCmd: TADOQuery;
Panel1: TPanel;
ToolButton2: TToolButton;
Label1: TLabel;
YFName: TEdit;
ADOQueryMain: TADOQuery;
ToolButton1: TToolButton;
RM1: TRMGridReport;
RMDB_Main: TRMDBDataSet;
Label3: TLabel;
FactoryName: TEdit;
Label2: TLabel;
Label6: TLabel;
begdate: TDateTimePicker;
Enddate: TDateTimePicker;
cxGridPopupMenu2: TcxGridPopupMenu;
DS_HZ: TDataSource;
CDS_HZ: TClientDataSet;
ToolButton3: TToolButton;
Label4: TLabel;
OrderNo: TEdit;
ToolButton5: TToolButton;
Label8: TLabel;
HZFactoryName: TEdit;
cxGrid2: TcxGrid;
Tv2: TcxGridDBTableView;
VDate: TcxGridDBColumn;
VFTYName: TcxGridDBColumn;
VYFName: TcxGridDBColumn;
VPayMent: TcxGridDBColumn;
VYB: TcxGridDBColumn;
VNote: TcxGridDBColumn;
cxGridLevel1: TcxGridLevel;
v2Column1: TcxGridDBColumn;
v2Column2: TcxGridDBColumn;
v2Column3: TcxGridDBColumn;
v2Column4: TcxGridDBColumn;
v2Column5: TcxGridDBColumn;
Label9: TLabel;
ComTaiTou: TEdit;
v2Column8: TcxGridDBColumn;
v2Column9: TcxGridDBColumn;
v2Column10: TcxGridDBColumn;
v2Column11: TcxGridDBColumn;
v2Column13: TcxGridDBColumn;
procedure FormDestroy(Sender: TObject);
procedure FormClose(Sender: TObject; var Action: TCloseAction);
procedure TBCloseClick(Sender: TObject);
procedure TBDelClick(Sender: TObject);
procedure FormShow(Sender: TObject);
procedure TBRafreshClick(Sender: TObject);
procedure ToolButton2Click(Sender: TObject);
procedure FactoryNameChange(Sender: TObject);
procedure ToolButton3Click(Sender: TObject);
procedure cxGridDBColumn3PropertiesButtonClick(Sender: TObject;
AButtonIndex: Integer);
procedure ToolButton1Click(Sender: TObject);
procedure ToolButton5Click(Sender: TObject);
procedure FormCreate(Sender: TObject);
procedure VPayMentPropertiesButtonClick(Sender: TObject;
AButtonIndex: Integer);
procedure v2Column5PropertiesButtonClick(Sender: TObject;
AButtonIndex: Integer);
procedure v2Column9PropertiesEditValueChanged(Sender: TObject);
private
{ Private declarations }
canshu1:String;
procedure InitGrid();
public
{ Public declarations }
RKFlag,FCYID:String;
end;
var
frmSKCRCYZZ: TfrmSKCRCYZZ;
implementation
uses
U_DataLink,U_RTFun,U_ZDYHelp,U_ZHKHListNewCX;
{$R *.dfm}
procedure TfrmSKCRCYZZ.InitGrid();
begin
try
ADOQueryMain.DisableControls;
with ADOQueryMain do
begin
Filtered:=False;
Close;
SQL.Clear;
sql.Add(' select A.* ');
sql.Add(' from YF_Money_CR A');
sql.Add('where A.CRTime>=:begdate and A.CRTime<:Enddate and A.CRType=''<27>տ<EFBFBD><D5BF>Ǽ<EFBFBD>'' ');
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 TfrmSKCRCYZZ.FormDestroy(Sender: TObject);
begin
frmSKCRCYZZ:=nil;
end;
procedure TfrmSKCRCYZZ.FormClose(Sender: TObject; var Action: TCloseAction);
begin
Action:=caFree;
end;
procedure TfrmSKCRCYZZ.TBCloseClick(Sender: TObject);
begin
WriteCxGrid('<27>տ<EFBFBD><D5BF>Ǽ<EFBFBD>1',Tv2,'<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>');
Close;
end;
procedure TfrmSKCRCYZZ.TBDelClick(Sender: TObject);
var
FBBMoney,CRID:string;
begin
if CDS_HZ.IsEmpty then Exit;
if CDS_HZ.Locate('SSel',True,[])=False then
begin
Application.MessageBox(<><C3BB>ѡ<EFBFBD><D1A1><EFBFBD><EFBFBD><EFBFBD><EFBFBD>!','<27><>ʾ',0);
Exit;
end;
{CDS_HZ.DisableControls;
with CDS_HZ do
begin
First;
while not Eof do
begin
if FieldByName('SSel').AsBoolean=True then
begin
with ADOQueryTemp do
begin
Close;
sql.Clear;
sql.Add('select * from YF_Money_CR where YFID='''+Trim(CDS_HZ.fieldbyname('YFID').AsString)+'''');
sql.Add(' and isnull(Money,0)<>isnull(WFPMoney,0) ');
Open;
end;
if ADOQueryTemp.IsEmpty=False then
begin
Application.MessageBox('<27>տ<EFBFBD><D5BF>ѱ<EFBFBD><D1B1><EFBFBD><EFBFBD><EFBFBD><E4B2BB>ɾ<EFBFBD><C9BE><EFBFBD><EFBFBD><EFBFBD><EFBFBD>!','<27><>ʾ',0);
Exit;
end;
end;
end;
end;
CDS_HZ.EnableControls;}
try
ADOQueryCmd.Connection.BeginTrans;
CDS_HZ.DisableControls;
with CDS_HZ do
begin
First;
while Locate('SSel',True,[]) do
begin
if Trim(CDS_HZ.fieldbyname('YFID').AsString)<>'' then
begin
with ADOQueryTemp do
begin
Close;
sql.Clear;
sql.Add('select * from YF_Money_CR where YFID='''+Trim(CDS_HZ.fieldbyname('YFID').AsString)+'''');
sql.Add(' and isnull(Money,0)<>isnull(WFPMoney,0) ');
Open;
end;
if ADOQueryTemp.IsEmpty=False then
begin
ADOQueryCmd.Connection.RollbackTrans;
CDS_HZ.EnableControls;
Application.MessageBox('<27>տ<EFBFBD><D5BF>ѱ<EFBFBD><D1B1><EFBFBD><EFBFBD><EFBFBD><E4B2BB>ɾ<EFBFBD><C9BE><EFBFBD><EFBFBD><EFBFBD><EFBFBD>!','<27><>ʾ',0);
Exit;
end;
with ADOQueryCmd do
begin
Close;
SQL.Clear;
sql.Add('delete YF_Money_CR where YFID='''+Trim(CDS_HZ.fieldbyname('YFID').AsString)+'''');
ExecSQL;
end;
end;
CDS_HZ.Delete;
end;
end;
CDS_HZ.EnableControls;
ADOQueryCmd.Connection.CommitTrans;
except
CDS_HZ.EnableControls;
ADOQueryCmd.Connection.RollbackTrans;
Application.MessageBox(<><C9BE><EFBFBD><EFBFBD><ECB3A3>','<27><>ʾ',0);
end;
end;
procedure TfrmSKCRCYZZ.FormShow(Sender: TObject);
begin
ReadCxGrid('<27>տ<EFBFBD><D5BF>Ǽ<EFBFBD>1',Tv2,'<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>');
Enddate.DateTime:=SGetServerDate(ADOQueryTemp);
begdate.DateTime:=SGetServerDateMBeg(ADOQueryTemp);
InitGrid();
end;
procedure TfrmSKCRCYZZ.TBRafreshClick(Sender: TObject);
begin
InitGrid();
end;
procedure TfrmSKCRCYZZ.ToolButton2Click(Sender: TObject);
begin
if ADOQueryMain.Active then
begin
SDofilter(ADOQueryMain,SGetFilters(Panel1,1,2));
SCreateCDS20(ADOQueryMain,CDS_HZ);
SInitCDSData20(ADOQueryMain,CDS_HZ);
end;
end;
procedure TfrmSKCRCYZZ.FactoryNameChange(Sender: TObject);
begin
ToolButton2.Click;
end;
procedure TfrmSKCRCYZZ.ToolButton3Click(Sender: TObject);
begin
try
frmZHKHListNewCX:=TfrmZHKHListNewCX.Create(Application);
with frmZHKHListNewCX do
begin
DParameters1:='<27><>Ȩ<EFBFBD><C8A8>';
if ShowModal=1 then
begin
with Self.CDS_HZ do
begin
Append;
FieldByName('FactoryNo').Value:=Trim(Order_Main.fieldbyname('ZKID').AsString);
FieldByName('FactoryName').Value:=Trim(Order_Main.fieldbyname('KHName').AsString);
FieldByName('CRTime').Value:=SGetServerDate(ADOQueryTemp);
Post;
end;
//Self.SaveData();
end;
end;
finally
frmZHKHListNewCX.Free;
end;
end;
procedure TfrmSKCRCYZZ.cxGridDBColumn3PropertiesButtonClick(Sender: TObject;
AButtonIndex: Integer);
begin
try
frmZDYHelp:=TfrmZDYHelp.Create(Application);
with frmZDYHelp do
begin
flag:='SKYFName';
flagname:='<27><>Ŀ<EFBFBD><C4BF>ժҪ';
if ShowModal=1 then
begin
with Self.CDS_HZ do
begin
Edit;
FieldByName('YFCode').Value:=Trim(ClientDataSet1.fieldbyname('ZdyNo').AsString);
FieldByName('YFName').Value:=Trim(ClientDataSet1.fieldbyname('ZdyName').AsString);
end;
end;
end;
finally
frmZDYHelp.Free;
end;
end;
procedure TfrmSKCRCYZZ.ToolButton1Click(Sender: TObject);
begin
if ADOQueryMain.IsEmpty then Exit;
TcxGridToExcel('<27>տ<EFBFBD><D5BF>б<EFBFBD>',cxGrid2);
end;
procedure TfrmSKCRCYZZ.ToolButton5Click(Sender: TObject);
var
maxId,FYFID:String;
begin
if CDS_HZ.IsEmpty then exit;
if CDS_HZ.Locate('SSel',True,[])=False then
begin
Application.MessageBox(<><C3BB>ѡ<EFBFBD><D1A1><EFBFBD><EFBFBD><EFBFBD><EFBFBD>!','<27><>ʾ',0);
Exit;
end;
if CDS_HZ.Locate('SSel;Money',VarArrayOf([True,Null]),[loPartialKey])=True then
begin
Application.MessageBox('<27>ͻ<EFBFBD>ʵ<EFBFBD><CAB5><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EEB2BB>Ϊ<EFBFBD><CEAA>!','<27><>ʾ',0);
Exit;
end;
if CDS_HZ.Locate('SSel;BZType',VarArrayOf([True,Null]),[loPartialKey])=True then
begin
Application.MessageBox('<27><><EFBFBD>ֲ<EFBFBD><D6B2><EFBFBD>Ϊ<EFBFBD><CEAA>!','<27><>ʾ',0);
Exit;
end;
if CDS_HZ.Locate('SSel;ComTaiTou',VarArrayOf([True,Null]),[loPartialKey])=True then
begin
Application.MessageBox('<27><>˾̧ͷ<CCA7><CDB7><EFBFBD><EFBFBD>Ϊ<EFBFBD><CEAA>!','<27><>ʾ',0);
Exit;
end;
if CDS_HZ.Locate('SSel;CRTime',VarArrayOf([True,Null]),[loPartialKey])=True then
begin
Application.MessageBox('<27><><EFBFBD>ڲ<EFBFBD><DAB2><EFBFBD>Ϊ<EFBFBD><CEAA>!','<27><>ʾ',0);
Exit;
end;
if Application.MessageBox(<><C8B7>Ҫ<EFBFBD><D2AA><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>','<27><>ʾ',32+4)<>IDYES then Exit;
ToolBar1.SetFocus;
try
ADOQueryCmd.Connection.BeginTrans;
CDS_HZ.DisableControls;
with CDS_HZ do
begin
First;
while Locate('SSel',True,[]) do
begin
with ADOQueryTemp do
begin
Close;
SQL.Clear;
sql.Add('select * from YF_Money_CR where YFID='''+Trim(CDS_HZ.fieldbyname('YFID').AsString)+'''');
Open;
end;
FYFID:=Trim(ADOQueryTemp.fieldbyname('YFID').AsString);
if Trim(FYFID)='' then
begin
if GetLSNo(ADOQueryCmd,maxId,'SK','YF_Money_CR',4,1)=False then
begin
CDS_HZ.EnableControls;
ADOQueryCmd.Connection.RollbackTrans;
Application.MessageBox(<>տ<EFBFBD><D5BF><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʧ<EFBFBD>ܣ<EFBFBD>','<27><>ʾ',0);
Exit;
end;
end else
begin
maxId:=Trim(FYFID);
end;
with ADOQueryCmd do
begin
Close;
SQL.Clear;
sql.Add('select * from YF_Money_CR where YFID='''+Trim(maxId)+'''');
Open;
end;
with ADOQueryCmd do
begin
if Trim(FYFID)='' then
begin
Append;
FieldByName('Filler').Value:=Trim(DName);
end else
begin
Edit;
FieldByName('Editer').Value:=Trim(DName);
end;
FieldByName('YFID').Value:=Trim(maxId);
RTSetSaveDataCDS(ADOQueryCmd,Tv2,CDS_HZ,'YF_Money_CR',3);
FieldByName('YFType').Value:='<27>ֹ<EFBFBD>¼<EFBFBD><C2BC>';
FieldByName('CRType').Value:='<27>տ<EFBFBD><D5BF>Ǽ<EFBFBD>';
FieldByName('CRFlag').Value:=<><D3A6><EFBFBD><EFBFBD>';
FieldByName('QtyFlag').Value:=-1;
FieldByName('FactoryNo').Value:=Trim(CDS_HZ.fieldbyname('FactoryNo').AsString);
Post;
end;
with CDS_HZ do
begin
Edit;
FieldByName('YFId').Value:=Trim(maxId);
FieldByName('SSel').Value:=False;
end;
with ADOQueryCmd do
begin
Close;
sql.Clear;
sql.Add('Update YF_Money_CR Set WFPMoney=isnull(Money,0)-isnull(FPDJMoney,0)-isnull(FPYKMoney,0)');
sql.Add('-isnull(FPQKMoney,0)-isnull(FPYJMoney,0)-isnull(FPKKMoney,0)');
sql.Add('where YFID='''+Trim(CDS_HZ.fieldbyname('YFID').AsString)+'''');
ExecSQL;
end;
end;
end;
CDS_HZ.EnableControls;
ADOQueryCmd.Connection.CommitTrans;
Application.MessageBox('<27><><EFBFBD><EFBFBD><EFBFBD>ɹ<EFBFBD>!','<27><>ʾ',0);
except
CDS_HZ.EnableControls;
ADOQueryCmd.Connection.RollbackTrans;
Application.MessageBox('<27><><EFBFBD><EFBFBD><EFBFBD>쳣!','<27><>ʾ',0);
end;
end;
procedure TfrmSKCRCYZZ.FormCreate(Sender: TObject);
begin
canshu1:=Trim(DParameters1);
end;
procedure TfrmSKCRCYZZ.VPayMentPropertiesButtonClick(Sender: TObject;
AButtonIndex: Integer);
begin
try
frmZDYHelp:=TfrmZDYHelp.Create(Application);
with frmZDYHelp do
begin
flag:='SKPayment';
flagname:=<><D6A7><EFBFBD><EFBFBD>ʽ';
if ShowModal=1 then
begin
with Self.CDS_HZ do
begin
Edit;
FieldByName('PayMent').Value:=Trim(frmZDYHelp.ClientDataSet1.fieldbyname('ZdyName').AsString);
end;
end;
end;
finally
frmZDYHelp.Free;
end;
end;
procedure TfrmSKCRCYZZ.v2Column5PropertiesButtonClick(Sender: TObject;
AButtonIndex: Integer);
begin
try
frmZDYHelp:=TfrmZDYHelp.Create(Application);
with frmZDYHelp do
begin
flag:='GSTT';
flagname:='<27><>˾̧ͷ';
V1ZdyStr1.Visible:=True;
V1ZdyStr2.Visible:=True;
V1ZdyStr3.Visible:=True;
V1ZdyStr4.Visible:=True;
V1ZdyStr1.Caption:='<27><><EFBFBD><EFBFBD>';
V1ZdyStr2.Caption:='<27>绰';
V1ZdyStr3.Caption:='<27><><EFBFBD><EFBFBD>';
V1ZdyStr4.Caption:='<27><>ַ';
frmZDYHelp.Align:=alClient;
if ShowModal=1 then
begin
with Self.CDS_HZ do
begin
Edit;
FieldByName('ComTaiTou').Value:=Trim(ClientDataSet1.fieldbyname('ZdyName').AsString);
end;
end;
end;
finally
frmZDYHelp.Free;
end;
end;
procedure TfrmSKCRCYZZ.v2Column9PropertiesEditValueChanged(
Sender: TObject);
var
mvalue,FName,RZMoney,BankFee,Money:string;
begin
FName:=Tv2.Controller.FocusedColumn.DataBinding.FilterFieldName;
mvalue:=TcxTextEdit(Sender).EditingText;
if Trim(mvalue)='' then
begin
mvalue:='0';
end;
with CDS_HZ do
begin
Edit;
FieldByName(FName).Value:=mvalue;
Post;
end;
if Trim(CDS_HZ.fieldbyname('RZMoney').AsString)='' then RZMoney:='0'
else RZMoney:=CDS_HZ.fieldbyname('RZMoney').AsString;
if Trim(CDS_HZ.fieldbyname('BankFee').AsString)='' then BankFee:='0'
else BankFee:=CDS_HZ.fieldbyname('BankFee').AsString;
if Trim(CDS_HZ.fieldbyname('Money').AsString)='' then Money:='0'
else Money:=CDS_HZ.fieldbyname('Money').AsString;
if FName<>'Money' then
begin
with CDS_HZ do
begin
Edit;
FieldByName('Money').Value:=StrToFloat(RZMoney)+StrToFloat(BankFee);
Post;
end;
end else
begin
if RZMoney<>'0' then
begin
with CDS_HZ do
begin
Edit;
FieldByName('BankFee').Value:=StrToFloat(Money)-StrToFloat(RZMoney);
Post;
end;
Exit;
end;
if BankFee<>'0' then
begin
with CDS_HZ do
begin
Edit;
FieldByName('RZMoney').Value:=StrToFloat(Money)-StrToFloat(BankFee);
Post;
end;
end;
end;
end;
end.