907 lines
27 KiB
ObjectPascal
907 lines
27 KiB
ObjectPascal
unit U_PKFKList;
|
||
|
||
interface
|
||
|
||
uses
|
||
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
|
||
Dialogs, StdCtrls, ExtCtrls, ComCtrls, ToolWin, cxStyles, cxCustomData,
|
||
cxGraphics, cxFilter, cxData, cxDataStorage, cxEdit, DB, cxDBData, ADODB,
|
||
cxGridCustomPopupMenu, cxGridPopupMenu, cxGridLevel, cxClasses,
|
||
cxControls, cxGridCustomView, cxGridCustomTableView, cxGridTableView,
|
||
cxGridDBTableView, cxGrid, DBClient, cxCalendar, cxButtonEdit, cxSplitter,
|
||
RM_Common, RM_Class, RM_e_Xls, RM_Dataset, RM_System, RM_GridReport,
|
||
cxTextEdit, cxPC, cxCheckBox, Menus;
|
||
|
||
|
||
type
|
||
TfrmPKFKList = class(TForm)
|
||
ToolBar1: TToolBar;
|
||
TBRafresh: TToolButton;
|
||
TBClose: TToolButton;
|
||
cxGridPopupMenu1: TcxGridPopupMenu;
|
||
ADOQueryCmd: TADOQuery;
|
||
ADOQueryMain: TADOQuery;
|
||
ADOQueryTemp: TADOQuery;
|
||
DataSource1: TDataSource;
|
||
TBExport: TToolButton;
|
||
Order_Main: TClientDataSet;
|
||
RM1: TRMGridReport;
|
||
RMDBMain: TRMDBDataSet;
|
||
RMXLSExport1: TRMXLSExport;
|
||
CDS_PRT: TClientDataSet;
|
||
ToolButton3: TToolButton;
|
||
Panel1: TPanel;
|
||
Label2: TLabel;
|
||
BegDate: TDateTimePicker;
|
||
EndDate: TDateTimePicker;
|
||
FactoryName: TEdit;
|
||
Label6: TLabel;
|
||
cxGrid1: TcxGrid;
|
||
Tv1: TcxGridDBTableView;
|
||
v1Column6: TcxGridDBColumn;
|
||
v1Column5: TcxGridDBColumn;
|
||
v1Column8: TcxGridDBColumn;
|
||
v1ShipDate: TcxGridDBColumn;
|
||
v1Column12: TcxGridDBColumn;
|
||
v1Column15: TcxGridDBColumn;
|
||
cxGrid1Level1: TcxGridLevel;
|
||
v1Column22: TcxGridDBColumn;
|
||
ToolButton1: TToolButton;
|
||
ToolButton4: TToolButton;
|
||
v1Column1: TcxGridDBColumn;
|
||
cxTabControl1: TcxTabControl;
|
||
ToolButton2: TToolButton;
|
||
v1Column16: TcxGridDBColumn;
|
||
v1Column17: TcxGridDBColumn;
|
||
Label3: TLabel;
|
||
PayMent: TEdit;
|
||
Label4: TLabel;
|
||
ComTaiTou: TEdit;
|
||
v1Column18: TcxGridDBColumn;
|
||
PopupMenu1: TPopupMenu;
|
||
N1: TMenuItem;
|
||
N2: TMenuItem;
|
||
ToolButton5: TToolButton;
|
||
v1Column19: TcxGridDBColumn;
|
||
v1Column20: TcxGridDBColumn;
|
||
v1Column23: TcxGridDBColumn;
|
||
v1Column3: TcxGridDBColumn;
|
||
ClientDataSet3: TClientDataSet;
|
||
Label5: TLabel;
|
||
v1Column4: TcxGridDBColumn;
|
||
v1Column2: TcxGridDBColumn;
|
||
v1Column7: TcxGridDBColumn;
|
||
v1Column9: TcxGridDBColumn;
|
||
v1Huilv: TcxGridDBColumn;
|
||
Label1: TLabel;
|
||
BZType: TComboBox;
|
||
Label7: TLabel;
|
||
JBPerson: TEdit;
|
||
Label8: TLabel;
|
||
PKName: TEdit;
|
||
procedure FormDestroy(Sender: TObject);
|
||
procedure FormClose(Sender: TObject; var Action: TCloseAction);
|
||
procedure TBCloseClick(Sender: TObject);
|
||
procedure TBExportClick(Sender: TObject);
|
||
procedure TBRafreshClick(Sender: TObject);
|
||
procedure FormShow(Sender: TObject);
|
||
procedure cxPageControl1Change(Sender: TObject);
|
||
procedure ToolButton3Click(Sender: TObject);
|
||
procedure FormCreate(Sender: TObject);
|
||
procedure cxTabControl1Change(Sender: TObject);
|
||
procedure FactoryNameChange(Sender: TObject);
|
||
procedure ToolButton1Click(Sender: TObject);
|
||
procedure ToolButton4Click(Sender: TObject);
|
||
procedure N1Click(Sender: TObject);
|
||
procedure N2Click(Sender: TObject);
|
||
procedure ToolButton2Click(Sender: TObject);
|
||
procedure ToolButton5Click(Sender: TObject);
|
||
procedure Tv1MouseDown(Sender: TObject; Button: TMouseButton;
|
||
Shift: TShiftState; X, Y: Integer);
|
||
|
||
private
|
||
FInt,PFInt:Integer;
|
||
canshu1,canshu2:string;
|
||
FNowDate:TDateTime;
|
||
procedure InitGrid();
|
||
procedure InitForm();
|
||
function DelData():Boolean;
|
||
function SaveFKData():Boolean;
|
||
function SaveFKQTData():Boolean;
|
||
function HXYFK(FKID:string):Boolean;
|
||
{ Private declarations }
|
||
public
|
||
{ Public declarations }
|
||
end;
|
||
|
||
var
|
||
frmPKFKList: TfrmPKFKList;
|
||
|
||
implementation
|
||
uses
|
||
U_DataLink,U_RTFun,U_PKInPut,U_ModuleNote, U_ZDYHelp;
|
||
|
||
{$R *.dfm}
|
||
|
||
procedure TfrmPKFKList.FormDestroy(Sender: TObject);
|
||
begin
|
||
frmPKFKList:=nil;
|
||
end;
|
||
|
||
procedure TfrmPKFKList.FormClose(Sender: TObject;
|
||
var Action: TCloseAction);
|
||
begin
|
||
Action:=caFree;
|
||
end;
|
||
|
||
procedure TfrmPKFKList.TBCloseClick(Sender: TObject);
|
||
begin
|
||
Close;
|
||
WriteCxGrid('<27>ʽ<EFBFBD><CABD><EFBFBD><EFBFBD>븶<EFBFBD><EBB8B6><EFBFBD>б<EFBFBD>',Tv1,'<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>');
|
||
|
||
end;
|
||
|
||
procedure TfrmPKFKList.InitGrid();
|
||
var
|
||
fsj:String;
|
||
begin
|
||
try
|
||
ADOQueryMain.DisableControls;
|
||
with ADOQueryMain do
|
||
begin
|
||
Filtered:=False;
|
||
Close;
|
||
sql.Clear;
|
||
sql.Add(' select A.*');
|
||
SQL.Add(' from YF_Money_PaiKuan A where 1=1 ');
|
||
if cxTabControl1.TabIndex=2 then
|
||
begin
|
||
sql.Add(' and A.PKDate>='''+Trim(FormatDateTime('yyyy-MM-dd',BegDate.Date))+'''');
|
||
sql.Add(' and A.PKDate<'''+Trim(FormatDateTime('yyyy-MM-dd',Enddate.Date+1))+'''');
|
||
end else
|
||
if cxTabControl1.TabIndex=1 then
|
||
begin
|
||
sql.Add(' and A.FKTime>='''+Trim(FormatDateTime('yyyy-MM-dd',BegDate.Date))+'''');
|
||
sql.Add(' and A.FKTime<'''+Trim(FormatDateTime('yyyy-MM-dd',Enddate.Date+1))+'''');
|
||
end;
|
||
|
||
sql.Add(' and isnull(ChkStatus,'''')=''<27><><EFBFBD><EFBFBD>ͨ<EFBFBD><CDA8>'' ');
|
||
if cxTabControl1.TabIndex=0 then
|
||
begin
|
||
sql.Add(' and isnull(FKID,'''')='''' ');
|
||
end else
|
||
if cxTabControl1.TabIndex=1 then
|
||
begin
|
||
sql.Add(' and isnull(FKID,'''')<>'''' ');
|
||
end;
|
||
Open;
|
||
end;
|
||
SCreateCDS20(ADOQueryMain,Order_Main);
|
||
SInitCDSData20(ADOQueryMain,Order_Main);
|
||
finally
|
||
ADOQueryMain.EnableControls;
|
||
end;
|
||
|
||
end;
|
||
|
||
procedure TfrmPKFKList.InitForm();
|
||
begin
|
||
FNowDate:=SGetServerDate(ADOQueryTemp);
|
||
EndDate.Date:=FNowDate+7;
|
||
BegDate.Date:=FNowDate-7;
|
||
ReadCxGrid('<27>ʽ<EFBFBD><CABD><EFBFBD><EFBFBD>븶<EFBFBD><EBB8B6><EFBFBD>б<EFBFBD>',Tv1,'<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>');
|
||
end;
|
||
|
||
function TfrmPKFKList.DelData():Boolean;
|
||
begin
|
||
try
|
||
Result:=false;
|
||
ADOQueryCmd.Connection.BeginTrans;
|
||
with Order_Main do
|
||
begin
|
||
First;
|
||
while Locate('SSel',True,[]) do
|
||
begin
|
||
with ADOQueryCmd do
|
||
begin
|
||
Close;
|
||
sql.Clear;
|
||
sql.Add('delete YF_Money_PaiKuan where PKId='''+Trim(Order_Main.fieldbyname('PKId').AsString)+'''');
|
||
ExecSQL;
|
||
end;
|
||
Order_Main.Delete;
|
||
end;
|
||
end;
|
||
|
||
ADOQueryCmd.Connection.CommitTrans;
|
||
Result:=True;
|
||
except
|
||
ADOQueryCmd.Connection.RollbackTrans;
|
||
Result:=False;
|
||
Application.MessageBox('<27><><EFBFBD><EFBFBD>ɾ<EFBFBD><C9BE><EFBFBD>쳣<EFBFBD><ECB3A3>','<27><>ʾ',0);
|
||
end;
|
||
end;
|
||
|
||
procedure TfrmPKFKList.TBExportClick(Sender: TObject);
|
||
begin
|
||
if Order_Main.IsEmpty then Exit;
|
||
TcxGridToExcel('<27>ʽ<EFBFBD><CABD><EFBFBD><EFBFBD>븶<EFBFBD><EBB8B6><EFBFBD>б<EFBFBD>',cxGrid1);
|
||
end;
|
||
|
||
procedure TfrmPKFKList.TBRafreshClick(Sender: TObject);
|
||
begin
|
||
InitGrid();
|
||
end;
|
||
|
||
procedure TfrmPKFKList.FormShow(Sender: TObject);
|
||
begin
|
||
InitForm();
|
||
end;
|
||
|
||
procedure TfrmPKFKList.cxPageControl1Change(Sender: TObject);
|
||
begin
|
||
InitGrid();
|
||
end;
|
||
|
||
procedure TfrmPKFKList.ToolButton3Click(Sender: TObject);
|
||
begin
|
||
try
|
||
frmModuleNote:=TfrmModuleNote.Create(Application);
|
||
with frmModuleNote do
|
||
begin
|
||
flag:='<27>ʽ<EFBFBD><CABD><EFBFBD><EFBFBD>븶<EFBFBD><EBB8B6>';
|
||
if ShowModal=1 then
|
||
begin
|
||
|
||
end;
|
||
end;
|
||
finally
|
||
frmModuleNote.Free;
|
||
end;
|
||
end;
|
||
|
||
procedure TfrmPKFKList.FormCreate(Sender: TObject);
|
||
begin
|
||
canshu1:=Trim(DParameters1);
|
||
canshu2:=Trim(DParameters2);
|
||
end;
|
||
procedure TfrmPKFKList.cxTabControl1Change(Sender: TObject);
|
||
begin
|
||
InitGrid();
|
||
end;
|
||
|
||
procedure TfrmPKFKList.FactoryNameChange(Sender: TObject);
|
||
begin
|
||
if ADOQueryMain.Active=False then Exit;
|
||
SDofilter(ADOQueryMain,SGetFilters(Panel1,1,2));
|
||
SCreateCDS20(ADOQueryMain,Order_Main);
|
||
SInitCDSData20(ADOQueryMain,Order_Main);
|
||
end;
|
||
|
||
procedure TfrmPKFKList.ToolButton1Click(Sender: TObject);
|
||
begin
|
||
if ADOQueryMain.Active=False then Exit;
|
||
SDofilter(ADOQueryMain,SGetFilters(Panel1,1,2));
|
||
SCreateCDS20(ADOQueryMain,Order_Main);
|
||
SInitCDSData20(ADOQueryMain,Order_Main);
|
||
end;
|
||
|
||
procedure TfrmPKFKList.ToolButton4Click(Sender: TObject);
|
||
var
|
||
fPrintFile:string;
|
||
begin
|
||
if Order_Main.IsEmpty then Exit;
|
||
if cxTabControl1.TabIndex<>2 then Exit;
|
||
if Order_Main.Locate('SSel',True,[])=False then
|
||
begin
|
||
Application.MessageBox('û<><C3BB>ѡ<EFBFBD><D1A1><EFBFBD><EFBFBD><EFBFBD><EFBFBD>!','<27><>ʾ',0);
|
||
Exit;
|
||
end;
|
||
fPrintFile:= ExtractFilePath(Application.ExeName) + 'Report\<5C>ʽ<EFBFBD><CABD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>.rmf' ;
|
||
with ADOQueryCmd do
|
||
begin
|
||
close;
|
||
sql.Clear;
|
||
sql.Add('delete TBSubID where DName='''+Trim(DName)+'''');
|
||
ExecSQL;
|
||
end;
|
||
Order_Main.DisableControls;
|
||
with Order_Main do
|
||
begin
|
||
First;
|
||
while not Eof do
|
||
begin
|
||
if Order_Main.FieldByName('SSel').AsBoolean=True then
|
||
begin
|
||
with ADOQueryCmd do
|
||
begin
|
||
Close;
|
||
sql.Clear;
|
||
sql.Add('insert into TBSubID');
|
||
sql.Add(' select '''+Trim(Order_Main.fieldbyname('PKID').AsString)+'''');
|
||
sql.Add(','''+Trim(DName)+'''');
|
||
ExecSQL;
|
||
end;
|
||
Edit;
|
||
FieldByName('PrtFlag').Value:=True;
|
||
Post;
|
||
end;
|
||
Next;
|
||
end;
|
||
end;
|
||
with ADOQueryCmd do
|
||
begin
|
||
Close;
|
||
sql.Clear;
|
||
sql.Add('Update YF_Money_PaiKuan Set PrtFlag=1,PrtTime=getdate(),Prter='''+Trim(DName)+'''');
|
||
sql.Add(' where PKID in(select SubId from TBSubID A where A.DName='''+Trim(DName)+''')');
|
||
ExecSQL;
|
||
end;
|
||
Order_Main.EnableControls;
|
||
with ADOQueryTemp do
|
||
begin
|
||
Close;
|
||
sql.Clear;
|
||
sql.Add(' select AA.*,');
|
||
sql.Add(' Case when isnull(FactoryNameOther,'''')<>'''' then RTrim(FactoryNameOther)+''/''+RTrim(FactoryName) ');
|
||
sql.Add(' else FactoryNameQC end as FactoryNameHZ');
|
||
sql.Add(' from (');
|
||
sql.Add(' select A.PKID,A.ComTaiTou,A.PKYongTu,A.PayMent,A.FactoryNameOther,A.FactoryName,isnull(A.PKMoney,0) PKMoney,A.ChkNote ');
|
||
sql.Add(' ,isnull(A.BQKKMoney,0) BQKKMoney,isnull(A.HZKKMoney,0) HZKKMoney,isnull(A.BQYFMoney,0) BQYFMoney,isnull(A.HZYFMoney,0) HZYFMoney');
|
||
sql.Add(',isnull(A.DDuiZhangMoney,0) DDuiZhangMoney,isnull(A.MaxHZYFMoney,0) MaxHZYFMoney,A.PKDate,A.Filler');
|
||
sql.Add(' ,FYear=Rtrim(Convert(varchar(4),A.PKDate,120))+''<27><>''');
|
||
sql.Add(' ,FactoryNameQC=(select KHName from ZH_KH_Info B where B.KHNameJC=A.FactoryName and B.Type=''GYS'' ) ');
|
||
sql.Add(' from YF_Money_PaiKuan A');
|
||
sql.Add(' where PKID in(select SubId from TBSubID where DName='''+Trim(DName)+'''))AA');
|
||
Open;
|
||
end;
|
||
SCreateCDS20(ADOQueryTemp,CDS_PRT);
|
||
SInitCDSData20(ADOQueryTemp,CDS_PRT);
|
||
if FileExists(fPrintFile) then
|
||
begin
|
||
//RMVariables['FMonth']:=Order_Main.fieldbyname('KQDate10').AsString;
|
||
RM1.ShowPrintDialog:=True;
|
||
RM1.LoadFromFile(fPrintFile);
|
||
RM1.ShowReport;
|
||
end else
|
||
begin
|
||
Application.MessageBox(PChar('û<><C3BB><EFBFBD><EFBFBD>'+ExtractFilePath(Application.ExeName)+'<27>ʽ<EFBFBD><CABD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>'),'<27><>ʾ',0);
|
||
end;
|
||
|
||
end;
|
||
procedure TfrmPKFKList.N1Click(Sender: TObject);
|
||
begin
|
||
SelOKNo(Order_Main,True);
|
||
end;
|
||
|
||
procedure TfrmPKFKList.N2Click(Sender: TObject);
|
||
begin
|
||
SelOKNo(Order_Main,False);
|
||
end;
|
||
|
||
procedure TfrmPKFKList.ToolButton2Click(Sender: TObject);
|
||
begin
|
||
if cxTabControl1.TabIndex<>0 then Exit;
|
||
if Order_Main.IsEmpty then Exit;
|
||
if Order_Main.Locate('SSel',True,[])=False then
|
||
begin
|
||
Application.MessageBox('û<><C3BB>ѡ<EFBFBD><D1A1><EFBFBD><EFBFBD><EFBFBD><EFBFBD>!','<27><>ʾ',0);
|
||
Exit;
|
||
end;
|
||
if Order_Main.Locate('SSel;FKMoney',VarArrayOf([True,null]),[loPartialKey])=True then
|
||
begin
|
||
Application.MessageBox('<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EEB2BB>Ϊ<EFBFBD><CEAA>!','<27><>ʾ',0);
|
||
Exit;
|
||
end;
|
||
if Order_Main.Locate('SSel;FKTime',VarArrayOf([True,null]),[loPartialKey])=True then
|
||
begin
|
||
Application.MessageBox('<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ڲ<EFBFBD><DAB2><EFBFBD>Ϊ<EFBFBD><CEAA>!','<27><>ʾ',0);
|
||
Exit;
|
||
end;
|
||
if Order_Main.Locate('SSel;ComTaiTou',VarArrayOf([True,null]),[loPartialKey])=True then
|
||
begin
|
||
Application.MessageBox('<27><><EFBFBD>λ<EEB5A5><CEBB><EFBFBD><EFBFBD>Ϊ<EFBFBD><CEAA>!','<27><>ʾ',0);
|
||
Exit;
|
||
end;
|
||
if Order_Main.Locate('SSel;BZType;HuiLv',VarArrayOf([True,'<27><><EFBFBD><EFBFBD>',null]),[loPartialKey])=True then
|
||
begin
|
||
Application.MessageBox('<27><><EFBFBD>ʲ<EFBFBD><CAB2><EFBFBD>Ϊ<EFBFBD><CEAA>!','<27><>ʾ',0);
|
||
Exit;
|
||
end;
|
||
Order_Main.DisableControls;
|
||
with Order_Main do
|
||
begin
|
||
First;
|
||
while not Eof do
|
||
begin
|
||
if FieldByName('SSel').AsBoolean=True then
|
||
begin
|
||
if FieldByName('FKMoney').Value=0 then
|
||
begin
|
||
Order_Main.EnableControls;
|
||
Application.MessageBox('<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EEB2BB>Ϊ<EFBFBD><CEAA>!','<27><>ʾ',0);
|
||
Exit;
|
||
end;
|
||
if FieldByName('FKMoney').Value>FieldByName('PKMoney').Value then
|
||
begin
|
||
Order_Main.EnableControls;
|
||
Application.MessageBox('<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ܴ<EFBFBD><DCB4><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>!','<27><>ʾ',0);
|
||
Exit;
|
||
end;
|
||
|
||
end;
|
||
Next;
|
||
end;
|
||
end;
|
||
Order_Main.EnableControls;
|
||
if Application.MessageBox('ȷ<><C8B7>Ҫ<EFBFBD><D2AA><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>','<27><>ʾ',32+4)<>IDYES then Exit;
|
||
try
|
||
ADOQueryCmd.Connection.BeginTrans;
|
||
Order_Main.DisableControls;
|
||
with Order_Main do
|
||
begin
|
||
First;
|
||
while Order_Main.Locate('SSel',True,[]) do
|
||
begin
|
||
if Trim(Order_Main.fieldbyname('HZType').AsString)='<27><><EFBFBD><EFBFBD>' then
|
||
begin
|
||
SaveFKData();
|
||
end else
|
||
begin
|
||
SaveFKQTData();
|
||
end;
|
||
Order_Main.Delete;
|
||
end;
|
||
end;
|
||
ADOQueryCmd.Connection.CommitTrans;
|
||
Order_Main.EnableControls;
|
||
except
|
||
Order_Main.EnableControls;
|
||
ADOQueryCmd.Connection.RollbackTrans;
|
||
Application.MessageBox('<27><><EFBFBD><EFBFBD><EFBFBD>쳣!','<27><>ʾ',0);
|
||
end;
|
||
end;
|
||
function TfrmPKFKList.SaveFKData():Boolean;
|
||
var
|
||
maxId,CRID:String;
|
||
begin
|
||
try
|
||
//ADOQueryCmd.Connection.BeginTrans;
|
||
with ADOQueryCmd do
|
||
begin
|
||
Close;
|
||
SQL.Clear;
|
||
sql.Add('select * from YF_Money_KC where FactoryNo='''+Trim(Order_Main.fieldbyname('FactoryNo').AsString)+'''');
|
||
Open;
|
||
end;
|
||
if ADOQueryCmd.IsEmpty=False then
|
||
begin
|
||
CRID:=ADOQueryCmd.fieldbyname('CRID').AsString;
|
||
end else
|
||
begin
|
||
with ADOQueryCmd do
|
||
begin
|
||
Close;
|
||
sql.Clear;
|
||
sql.Add('Update YF_Money_CRID set CRID=CRID+1');
|
||
sql.Add('select * from YF_Money_CRID ');
|
||
Open;
|
||
end;
|
||
CRID:=ADOQueryCmd.fieldbyname('CRID').AsString;
|
||
with ADOQueryCmd do
|
||
begin
|
||
Close;
|
||
SQL.Clear;
|
||
sql.Add('select * from YF_Money_KC where 1<>1');
|
||
Open;
|
||
end;
|
||
with ADOQueryCmd do
|
||
begin
|
||
Append;
|
||
FieldByName('CRID').Value:=StrToInt(CRID);
|
||
FieldByName('FactoryNo').Value:=Trim(Order_Main.fieldbyname('FactoryNo').AsString);
|
||
FieldByName('FactoryName').Value:=Trim(Order_Main.fieldbyname('FactoryName').AsString);
|
||
FieldByName('ZdyStr1').Value:='Ӧ<><D3A6><EFBFBD><EFBFBD>';
|
||
Post;
|
||
end;
|
||
end;
|
||
if GetLSNo(ADOQueryCmd,maxId,'SF','YF_Money_CR',4,1)=False then
|
||
begin
|
||
Result:=False;
|
||
Application.MessageBox('ȡ<><C8A1><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʧ<EFBFBD>ܣ<EFBFBD>','<27><>ʾ',0);
|
||
Exit;
|
||
end;
|
||
with ADOQueryCmd do
|
||
begin
|
||
Close;
|
||
SQL.Clear;
|
||
sql.Add('select * from YF_Money_CR where 1<>1');
|
||
Open;
|
||
end;
|
||
with ADOQueryCmd do
|
||
begin
|
||
Append;
|
||
FieldByName('YFID').Value:=Trim(maxId);
|
||
FieldByName('CRID').Value:=StrToInt(CRID);
|
||
FieldByName('Filler').Value:=Trim(DName);
|
||
FieldByName('CRType').Value:='<27><><EFBFBD><EFBFBD><EFBFBD>Ǽ<EFBFBD>';
|
||
FieldByName('CRFlag').Value:='Ӧ<><D3A6><EFBFBD><EFBFBD>';
|
||
FieldByName('QtyFlag').Value:=-1;
|
||
FieldByName('FactoryNo').Value:=Trim(Order_Main.fieldbyname('FactoryNo').AsString);
|
||
FieldByName('FactoryName').Value:=Trim(Order_Main.fieldbyname('FactoryName').AsString);
|
||
FieldByName('CRTime').Value:=Order_Main.fieldbyname('FKTime').Value;
|
||
FieldByName('Money').Value:=Order_Main.fieldbyname('FKMoney').Value;
|
||
FieldByName('BBMoney').Value:=Order_Main.fieldbyname('FKMoney').Value;
|
||
FieldByName('BZType').Value:='<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>';
|
||
FieldByName('HuiLv').Value:=1;
|
||
FieldByName('Note').Value:=Order_Main.fieldbyname('FKNote').Value;
|
||
Post;
|
||
end;
|
||
with ADOQueryCmd do
|
||
begin
|
||
Close;
|
||
sql.Clear;
|
||
sql.Add('UPdate YF_Money_KC Set KCMoney=(select isnull(Sum(Money*QtyFlag),0) from YF_Money_CR A where A.CRID=YF_Money_KC.CRID)');
|
||
sql.Add(',KCBBMoney=(select isnull(Sum(BBMoney*QtyFlag),0) from YF_Money_CR A where A.CRID=YF_Money_KC.CRID)');
|
||
sql.Add(' where CRID='+CRID);
|
||
ExecSQL;
|
||
end;
|
||
with ADOQueryCmd do
|
||
begin
|
||
Close;
|
||
sql.Clear;
|
||
sql.Add('Update YF_Money_PaiKuan Set FKPerson='''+Trim(DName)+'''');
|
||
sql.Add(',FKID='''+Trim(maxId)+'''');
|
||
sql.Add(',FKTime='''+Trim(FormatDateTime('yyyy-MM-dd',Order_Main.fieldbyname('FKTime').AsDateTime))+'''');
|
||
sql.Add(',FKMoney='+Trim(Order_Main.fieldbyname('FKMoney').AsString));
|
||
sql.Add(',FKNote='''+Trim(Order_Main.fieldbyname('FKNote').AsString)+'''');
|
||
sql.Add(' where PKID='''+Trim(Order_Main.fieldbyname('PKID').AsString)+'''');
|
||
ExecSQL;
|
||
end;
|
||
Result:=True;
|
||
{if HXYFK(maxId)=True then
|
||
begin
|
||
Result:=True;
|
||
end else
|
||
begin
|
||
Result:=False;
|
||
end; }
|
||
|
||
except
|
||
Result:=True;
|
||
ADOQueryCmd.Connection.RollbackTrans;
|
||
Application.MessageBox('<27><><EFBFBD>渶<EFBFBD><E6B8B6>ʧ<EFBFBD><CAA7>!','<27><>ʾ',0);
|
||
end;
|
||
end;
|
||
function TfrmPKFKList.SaveFKQTData():Boolean;
|
||
var
|
||
maxId:String;
|
||
begin
|
||
try
|
||
//ADOQueryCmd.Connection.BeginTrans;
|
||
if GetLSNo(ADOQueryCmd,maxId,'QF','YF_Money_CR',4,1)=False then
|
||
begin
|
||
Result:=False;
|
||
Application.MessageBox('ȡ<><C8A1><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʧ<EFBFBD>ܣ<EFBFBD>','<27><>ʾ',0);
|
||
Exit;
|
||
end;
|
||
with ADOQueryCmd do
|
||
begin
|
||
Close;
|
||
SQL.Clear;
|
||
sql.Add('select * from YF_Money_CR where 1<>1');
|
||
Open;
|
||
end;
|
||
with ADOQueryCmd do
|
||
begin
|
||
Append;
|
||
FieldByName('YFID').Value:=Trim(maxId);
|
||
FieldByName('Filler').Value:=Trim(DName);
|
||
FieldByName('CRType').Value:='<27><><EFBFBD><EFBFBD><EFBFBD>Ǽ<EFBFBD>';
|
||
FieldByName('CRFlag').Value:='Ӧ<><D3A6><EFBFBD><EFBFBD>';
|
||
FieldByName('QtyFlag').Value:=-1;
|
||
FieldByName('FactoryNo').Value:=Trim(Order_Main.fieldbyname('FactoryNo').AsString);
|
||
FieldByName('FactoryName').Value:=Trim(Order_Main.fieldbyname('FactoryName').AsString);
|
||
FieldByName('CRTime').Value:=Order_Main.fieldbyname('FKTime').Value;
|
||
FieldByName('Money').Value:=Order_Main.fieldbyname('FKMoney').Value;
|
||
FieldByName('BBMoney').Value:=Order_Main.fieldbyname('FKMoney').Value
|
||
*Order_Main.fieldbyname('HuiLv').Value;
|
||
FieldByName('Note').Value:=Order_Main.fieldbyname('FKNote').Value;
|
||
FieldByName('BZType').Value:=Order_Main.fieldbyname('BZType').Value;
|
||
FieldByName('HuiLv').Value:=Order_Main.fieldbyname('HuiLv').Value;
|
||
Post;
|
||
end;
|
||
with ADOQueryCmd do
|
||
begin
|
||
Close;
|
||
sql.Clear;
|
||
sql.Add('Update YF_Money_PaiKuan Set FKPerson='''+Trim(DName)+'''');
|
||
sql.Add(',FKID='''+Trim(maxId)+'''');
|
||
sql.Add(',FKTime='''+Trim(FormatDateTime('yyyy-MM-dd',Order_Main.fieldbyname('FKTime').AsDateTime))+'''');
|
||
sql.Add(',FKMoney='+Trim(Order_Main.fieldbyname('FKMoney').AsString));
|
||
sql.Add(',FKNote='''+Trim(Order_Main.fieldbyname('FKNote').AsString)+'''');
|
||
sql.Add(',HuiLv='+Trim(Order_Main.fieldbyname('HuiLv').AsString));
|
||
sql.Add(' where PKID='''+Trim(Order_Main.fieldbyname('PKID').AsString)+'''');
|
||
ExecSQL;
|
||
end;
|
||
Result:=True;
|
||
except
|
||
Result:=True;
|
||
ADOQueryCmd.Connection.RollbackTrans;
|
||
Application.MessageBox('<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʧ<EFBFBD><CAA7>!','<27><>ʾ',0);
|
||
end;
|
||
end;
|
||
function TfrmPKFKList.HXYFK(FKID:string):Boolean;
|
||
var
|
||
factoryname,FFKMoney,maxno,FXType:String;
|
||
begin
|
||
Result:=False;
|
||
with ADOQueryTemp do
|
||
begin
|
||
Close;
|
||
sql.Clear;
|
||
sql.Add('select FXType,');
|
||
sql.Add(' DHXMoney=Money-isnull((select isnull(Sum(HXMoney),0) from YF_Money_CR_HX B where B.FKID=A.YFID),0)');
|
||
sql.Add(' from YF_Money_CR A');
|
||
SQL.Add(' where YFID='''+Trim(FKID)+'''');
|
||
Open;
|
||
end;
|
||
FFKMoney:=ADOQueryTemp.fieldbyname('DHXMoney').AsString;
|
||
FXType:=Trim(ADOQueryTemp.fieldbyname('FXType').AsString);
|
||
if StrToFloat(FFKMoney)>0 then
|
||
begin
|
||
if Trim(FXType)='' then
|
||
begin
|
||
with ADOQueryTemp do
|
||
begin
|
||
Close;
|
||
sql.Clear;
|
||
sql.Add('select A.*,YingFuMoney=Money-YiFuMoney ');
|
||
sql.Add(' ,DZMoney=(select isnull(Money,0) from JYOrder_Main_MD_HZ HZ where HZ.MHID=A.MHID)');
|
||
sql.Add(' ,DZChaEMoney=(select isnull(ChaEMoney,0) from JYOrder_Main_MD_HZ HZ where HZ.MHID=A.MHID)');
|
||
sql.Add(' from YF_Money_CR A ');
|
||
sql.Add(' where FactoryName='''+Trim(Order_Main.fieldbyname('FactoryName').AsString)+'''');
|
||
//SQL.Add(' and CRID='+Trim(ClientDataSet2.fieldbyname('CRID').AsString));
|
||
sql.Add(' and CRType=''Ӧ<><D3A6><EFBFBD><EFBFBD><EFBFBD>Ǽ<EFBFBD>'' ');
|
||
sql.Add(' and (Money-YiFuMoney)<>0');
|
||
sql.Add(' and not exists(select * from JYOrder_Main_MD_HZ C where C.YFID=A.YFID and isnull(C.ItemName,'''')=''<27><><EFBFBD><EFBFBD>'')');
|
||
sql.Add(' order by CRTime,Money');
|
||
Open;
|
||
end;
|
||
end else
|
||
if Trim(FXType)='<27><><EFBFBD><EFBFBD>' then
|
||
begin
|
||
with ADOQueryTemp do
|
||
begin
|
||
Close;
|
||
sql.Clear;
|
||
sql.Add('select A.*,YingFuMoney=Money-YiFuMoney ');
|
||
sql.Add(' ,DZMoney=(select isnull(Money,0) from JYOrder_Main_MD_HZ HZ where HZ.MHID=A.MHID)');
|
||
sql.Add(' ,DZChaEMoney=(select isnull(ChaEMoney,0) from JYOrder_Main_MD_HZ HZ where HZ.MHID=A.MHID)');
|
||
sql.Add(' from YF_Money_CR A ');
|
||
sql.Add(' where isnull(A.MHID,'''')='''+Trim(Order_Main.fieldbyname('MHID').AsString)+'''');
|
||
sql.Add(' and CRType=''Ӧ<><D3A6><EFBFBD><EFBFBD><EFBFBD>Ǽ<EFBFBD>'' ');
|
||
sql.Add(' and (Money-YiFuMoney)<>0');
|
||
Open;
|
||
end;
|
||
end;
|
||
SCreateCDS20(ADOQueryTemp,ClientDataSet3);
|
||
SInitCDSData20(ADOQueryTemp,ClientDataSet3);
|
||
with ClientDataSet3 do
|
||
begin
|
||
First;
|
||
while not Eof do
|
||
begin
|
||
if ClientDataSet3.FieldByName('DZMoney').Value<0 then
|
||
begin
|
||
if ClientDataSet3.FieldByName('DZChaEMoney').Value<>0 then
|
||
begin
|
||
Next;
|
||
end;
|
||
end;
|
||
if ClientDataSet3.FieldByName('YingFuMoney').Value<=StrToFloat(FFKMoney) then //<2F><><EFBFBD><EFBFBD>Ӧ<EFBFBD><D3A6><EFBFBD><EFBFBD><EFBFBD><EFBFBD>С<EFBFBD>ڵ<EFBFBD><DAB5>ڸ<EFBFBD><DAB8><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||
begin
|
||
if StrToFloat(FFKMoney)>0 then
|
||
begin
|
||
if GetLSNo(ADOQueryCmd,maxno,'YH','YF_Money_CR_HX',4,1)=False then
|
||
begin
|
||
Result:=False;
|
||
ADOQueryCmd.Connection.RollbackTrans;
|
||
Application.MessageBox('ȡ<><C8A1><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ˮ<EFBFBD><CBAE>ʧ<EFBFBD><CAA7>!','<27><>ʾ',0);
|
||
Exit;
|
||
end;
|
||
with ADOQueryCmd do
|
||
begin
|
||
Close;
|
||
sql.Clear;
|
||
sql.Add('select * from YF_Money_CR_HX where 1<>1');
|
||
Open;
|
||
end;
|
||
with ADOQueryCmd do
|
||
begin
|
||
Append;
|
||
FieldByName('YHID').Value:=Trim(maxno);
|
||
FieldByName('YFID').Value:=Trim(ClientDataSet3.fieldbyname('YFID').AsString);
|
||
FieldByName('FKID').Value:=Trim(FKID);
|
||
FieldByName('HXMoney').Value:=ClientDataSet3.FieldByName('YingFuMoney').Value;
|
||
FieldByName('Filler').Value:=Trim(DName);
|
||
Post;
|
||
end;
|
||
|
||
with ADOQueryCmd do
|
||
begin
|
||
Close;
|
||
sql.Clear;
|
||
sql.Add('Update YF_Money_CR Set YiFuMoney=(select isnull(Sum(HXMoney),0) from YF_Money_CR_HX A where A.YFID=YF_Money_CR.YFID)');
|
||
sql.Add(' where YFID='''+Trim(ClientDataSet3.fieldbyname('YFID').AsString)+'''');
|
||
ExecSQL;
|
||
end;
|
||
FFKMoney:=FloatToStr(StrToFloat(FFKMoney)-ClientDataSet3.FieldByName('YingFuMoney').Value);
|
||
ClientDataSet3.Delete;
|
||
end else
|
||
begin
|
||
ClientDataSet3.Last;
|
||
end;
|
||
end else
|
||
//<2F><><EFBFBD><EFBFBD>Ӧ<EFBFBD><D3A6><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ڸ<EFBFBD><DAB8><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||
begin
|
||
if StrToFloat(FFKMoney)=0 then
|
||
begin
|
||
ClientDataSet3.Last;
|
||
end;
|
||
if GetLSNo(ADOQueryCmd,maxno,'YH','YF_Money_CR_HX',4,1)=False then
|
||
begin
|
||
Result:=False;
|
||
ADOQueryCmd.Connection.RollbackTrans;
|
||
Application.MessageBox('ȡ<><C8A1><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ˮ<EFBFBD><CBAE>ʧ<EFBFBD><CAA7>!','<27><>ʾ',0);
|
||
Exit;
|
||
end;
|
||
with ADOQueryCmd do
|
||
begin
|
||
Close;
|
||
sql.Clear;
|
||
sql.Add('select * from YF_Money_CR_HX where 1<>1');
|
||
Open;
|
||
end;
|
||
with ADOQueryCmd do
|
||
begin
|
||
Append;
|
||
FieldByName('YHID').Value:=Trim(maxno);
|
||
FieldByName('YFID').Value:=Trim(ClientDataSet3.fieldbyname('YFID').AsString);
|
||
FieldByName('FKID').Value:=Trim(FKID);
|
||
FieldByName('HXMoney').Value:=FFKMoney;
|
||
FieldByName('Filler').Value:=Trim(DName);
|
||
Post;
|
||
end;
|
||
with ADOQueryCmd do
|
||
begin
|
||
Close;
|
||
sql.Clear;
|
||
sql.Add('Update YF_Money_CR Set YiFuMoney=(select isnull(Sum(HXMoney),0) from YF_Money_CR_HX A where A.YFID=YF_Money_CR.YFID)');
|
||
sql.Add(' where YFID='''+Trim(ClientDataSet3.fieldbyname('YFID').AsString)+'''');
|
||
ExecSQL;
|
||
end;
|
||
FFKMoney:='0';
|
||
ClientDataSet3.Delete;
|
||
ClientDataSet3.Last;
|
||
end;
|
||
end;
|
||
end;
|
||
Result:=True;
|
||
end;
|
||
end;
|
||
procedure TfrmPKFKList.ToolButton5Click(Sender: TObject);
|
||
var
|
||
CRID:String;
|
||
begin
|
||
if cxTabControl1.TabIndex<>1 then Exit;
|
||
if Order_Main.IsEmpty then Exit;
|
||
if Order_Main.Locate('SSel',True,[])=False then
|
||
begin
|
||
Application.MessageBox('û<><C3BB>ѡ<EFBFBD><D1A1><EFBFBD><EFBFBD><EFBFBD><EFBFBD>!','<27><>ʾ',0);
|
||
Exit;
|
||
end;
|
||
{Order_Main.DisableControls;
|
||
with Order_Main do
|
||
begin
|
||
First;
|
||
while not Eof do
|
||
begin
|
||
if Order_Main.FieldByName('SSel').AsBoolean=True then
|
||
begin
|
||
with ADOQueryTemp do
|
||
begin
|
||
Close;
|
||
sql.Clear;
|
||
sql.Add('select * from YF_Money_PaiKuan ');
|
||
sql.Add(' where PKID='''+Trim(Order_Main.fieldbyname('PKID').AsString)+'''');
|
||
sql.Add(' and OKFlag=1 ');
|
||
Open;
|
||
end;
|
||
if ADOQueryTemp.IsEmpty=False then
|
||
begin
|
||
Order_Main.EnableControls;
|
||
Application.MessageBox('<27><>ȷ<EFBFBD>ϣ<EFBFBD><CFA3><EFBFBD><EFBFBD>ܳ<EFBFBD><DCB3><EFBFBD>!','<27><>ʾ',0);
|
||
Exit;
|
||
end;
|
||
end;
|
||
Next;
|
||
end;
|
||
end;
|
||
Order_Main.EnableControls;}
|
||
if Application.MessageBox('ȷ<><C8B7>Ҫִ<D2AA>г<EFBFBD><D0B3><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>','<27><>ʾ',32+4)<>IDYES then Exit;
|
||
try
|
||
ADOQueryCmd.Connection.BeginTrans;
|
||
Order_Main.DisableControls;
|
||
with Order_Main do
|
||
begin
|
||
First;
|
||
while Order_Main.Locate('SSel',True,[]) do
|
||
begin
|
||
with ADOQueryTemp do
|
||
begin
|
||
Close;
|
||
sql.Clear;
|
||
sql.Add('select * from YF_Money_CR where YFID='''+Trim(Order_Main.fieldbyname('FKID').AsString)+'''');
|
||
Open;
|
||
end;
|
||
CRID:=Trim(ADOQueryTemp.fieldbyname('CRID').AsString);
|
||
with ADOQueryCmd do
|
||
begin
|
||
Close;
|
||
sql.Clear;
|
||
sql.Add('Update YF_Money_PaiKuan Set FKTime=NUll,FKPerson=Null');
|
||
if Trim(Order_Main.fieldbyname('BZType').AsString)='<27><><EFBFBD><EFBFBD>' then
|
||
begin
|
||
sql.Add(',HuiLv=Null ');
|
||
end;
|
||
sql.Add(',FKNote=Null,FKID=Null,FKMoney=Null ');
|
||
sql.Add(' where PKID='''+Trim(Order_Main.fieldbyname('PKID').AsString)+'''');
|
||
ExecSQL;
|
||
end;
|
||
with ADOQueryCmd do
|
||
begin
|
||
Close;
|
||
SQL.Clear;
|
||
sql.Add('delete YF_Money_CR where YFID='''+Trim(Order_Main.fieldbyname('FKID').AsString)+'''');
|
||
ExecSQL;
|
||
end;
|
||
if Trim(CRID)<>'' then
|
||
begin
|
||
with ADOQueryCmd do
|
||
begin
|
||
Close;
|
||
SQL.Clear;
|
||
sql.Add('UPdate YF_Money_KC Set KCMoney=(select isnull(Sum(Money*QtyFlag),0) from YF_Money_CR A where A.CRID=YF_Money_KC.CRID)');
|
||
sql.Add(',KCBBMoney=(select isnull(Sum(BBMoney*QtyFlag),0) from YF_Money_CR A where A.CRID=YF_Money_KC.CRID)');
|
||
sql.Add(' where CRID='+CRID);
|
||
ExecSQL;
|
||
end;
|
||
end;
|
||
Order_Main.Delete;
|
||
end;
|
||
end;
|
||
ADOQueryCmd.Connection.CommitTrans;
|
||
Order_Main.EnableControls;
|
||
except
|
||
Order_Main.EnableControls;
|
||
ADOQueryCmd.Connection.RollbackTrans;
|
||
Application.MessageBox('<27><><EFBFBD><EFBFBD><EFBFBD>쳣!','<27><>ʾ',0);
|
||
end;
|
||
end;
|
||
|
||
procedure TfrmPKFKList.Tv1MouseDown(Sender: TObject; Button: TMouseButton;
|
||
Shift: TShiftState; X, Y: Integer);
|
||
begin
|
||
if Order_Main.IsEmpty then exit;
|
||
if Trim(Order_Main.fieldbyname('BZType').AsString)='<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>' then
|
||
begin
|
||
v1Huilv.Options.Editing:=False;
|
||
end else
|
||
begin
|
||
v1Huilv.Options.Editing:=True;
|
||
end;
|
||
end;
|
||
|
||
end.
|