749 lines
26 KiB
ObjectPascal
749 lines
26 KiB
ObjectPascal
unit U_PKInPut;
|
||
|
||
interface
|
||
|
||
uses
|
||
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
|
||
Dialogs, cxStyles, cxCustomData, cxGraphics, cxFilter, cxData,
|
||
cxDataStorage, cxEdit, DB, cxDBData, cxGridLevel, cxGridCustomTableView,
|
||
cxGridTableView, cxGridDBTableView, cxClasses, cxControls,
|
||
cxGridCustomView, cxGrid, cxMemo, cxRichEdit, ComCtrls, cxContainer,
|
||
cxTextEdit, cxMaskEdit, cxButtonEdit, StdCtrls, ToolWin, DBClient, ADODB,
|
||
ExtCtrls, BtnEdit, cxDropDownEdit, cxCalendar, cxGridCustomPopupMenu,
|
||
cxGridPopupMenu, cxSplitter;
|
||
|
||
type
|
||
TfrmPKInPut = class(TForm)
|
||
ToolBar1: TToolBar;
|
||
TBSave: TToolButton;
|
||
TBClose: TToolButton;
|
||
ADOTemp: TADOQuery;
|
||
ADOCmd: TADOQuery;
|
||
DataSource1: TDataSource;
|
||
Order_Sub: TClientDataSet;
|
||
DataSource2: TDataSource;
|
||
ADOZDY: TADOQuery;
|
||
CDS_ZDY: TClientDataSet;
|
||
ADOQuery1: TADOQuery;
|
||
cxGridPopupMenu1: TcxGridPopupMenu;
|
||
ToolButton3: TToolButton;
|
||
ToolButton4: TToolButton;
|
||
ClientDataSet1: TClientDataSet;
|
||
Panel1: TPanel;
|
||
Label1: TLabel;
|
||
PKDate: TDateTimePicker;
|
||
ToolButton1: TToolButton;
|
||
cxGrid1: TcxGrid;
|
||
Tv1: TcxGridDBTableView;
|
||
v1Column6: TcxGridDBColumn;
|
||
v1Column8: TcxGridDBColumn;
|
||
v1Column5: TcxGridDBColumn;
|
||
v1Column15: TcxGridDBColumn;
|
||
v1Column9: TcxGridDBColumn;
|
||
v1Column22: TcxGridDBColumn;
|
||
v1Column10: TcxGridDBColumn;
|
||
v1Column2: TcxGridDBColumn;
|
||
cxGrid1Level1: TcxGridLevel;
|
||
v1Column1: TcxGridDBColumn;
|
||
ClientDataSet2: TClientDataSet;
|
||
DataSource3: TDataSource;
|
||
cxGrid2: TcxGrid;
|
||
Tv2: TcxGridDBTableView;
|
||
VOrderNo: TcxGridDBColumn;
|
||
vPSName: TcxGridDBColumn;
|
||
VDate: TcxGridDBColumn;
|
||
VFTYName: TcxGridDBColumn;
|
||
VYFName: TcxGridDBColumn;
|
||
VPayMent: TcxGridDBColumn;
|
||
VPS: TcxGridDBColumn;
|
||
VQty: TcxGridDBColumn;
|
||
VQtyUnit: TcxGridDBColumn;
|
||
VPrice: TcxGridDBColumn;
|
||
VYB: TcxGridDBColumn;
|
||
v2Column1: TcxGridDBColumn;
|
||
v2Column2: TcxGridDBColumn;
|
||
VNote: TcxGridDBColumn;
|
||
cxGridLevel1: TcxGridLevel;
|
||
cxSplitter1: TcxSplitter;
|
||
Panel2: TPanel;
|
||
RadioGroup1: TRadioGroup;
|
||
cxGridPopupMenu2: TcxGridPopupMenu;
|
||
v1Column3: TcxGridDBColumn;
|
||
v1Column4: TcxGridDBColumn;
|
||
v1Column7: TcxGridDBColumn;
|
||
v1Column11: TcxGridDBColumn;
|
||
ToolButton2: TToolButton;
|
||
v1Column12: TcxGridDBColumn;
|
||
v1Column13: TcxGridDBColumn;
|
||
v2Column3: TcxGridDBColumn;
|
||
v1Column14: TcxGridDBColumn;
|
||
procedure TBCloseClick(Sender: TObject);
|
||
procedure FormShow(Sender: TObject);
|
||
procedure TBSaveClick(Sender: TObject);
|
||
procedure ToolButton3Click(Sender: TObject);
|
||
procedure ToolButton4Click(Sender: TObject);
|
||
procedure ToolButton1Click(Sender: TObject);
|
||
procedure Tv1CellClick(Sender: TcxCustomGridTableView;
|
||
ACellViewInfo: TcxGridTableDataCellViewInfo; AButton: TMouseButton;
|
||
AShift: TShiftState; var AHandled: Boolean);
|
||
procedure RadioGroup1Click(Sender: TObject);
|
||
procedure v1Column11PropertiesButtonClick(Sender: TObject;
|
||
AButtonIndex: Integer);
|
||
procedure v1Column7PropertiesButtonClick(Sender: TObject;
|
||
AButtonIndex: Integer);
|
||
procedure ToolButton2Click(Sender: TObject);
|
||
procedure v1Column13PropertiesButtonClick(Sender: TObject;
|
||
AButtonIndex: Integer);
|
||
procedure Tv1MouseDown(Sender: TObject; Button: TMouseButton;
|
||
Shift: TShiftState; X, Y: Integer);
|
||
private
|
||
FXS:Integer;
|
||
procedure InitData();
|
||
procedure ZDYHelp(FButn:TcxButtonEdit;LType:string);
|
||
function SaveData():Boolean;
|
||
procedure GetMaxConNO();
|
||
{ Private declarations }
|
||
public
|
||
PState,PCopyInt:Integer;
|
||
FMainId,FConNo,FConType,FYLType:String;
|
||
|
||
{ Public declarations }
|
||
end;
|
||
|
||
var
|
||
frmPKInPut: TfrmPKInPut;
|
||
|
||
implementation
|
||
uses
|
||
U_DataLink,U_ZDYHelp,U_RTFun,U_GYSList,U_ZDYHelpSel, U_ModuleNote;
|
||
|
||
{$R *.dfm}
|
||
|
||
procedure TfrmPKInPut.TBCloseClick(Sender: TObject);
|
||
begin
|
||
Close;
|
||
WriteCxGrid('<27>ſ<EFBFBD>¼<EFBFBD><C2BC>',Tv1,'<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>');
|
||
WriteCxGrid('Ӧ<><D3A6><EFBFBD>б<EFBFBD>1',Tv2,'<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>');
|
||
end;
|
||
|
||
procedure TfrmPKInPut.InitData();
|
||
var
|
||
fsj:String;
|
||
begin
|
||
with ADOQuery1 do
|
||
begin
|
||
Close;
|
||
SQL.Clear;
|
||
sql.Add(' select A.*,MDQingKuang=Cast('''' as varchar(50)) ');
|
||
SQL.Add(' from YF_Money_PaiKuan A ');
|
||
sql.Add(' where A.PKId='''+Trim(FMainId)+'''');
|
||
Open;
|
||
end;
|
||
SCreateCDS20(ADOQuery1,Order_Sub);
|
||
SInitCDSData20(ADOQuery1,Order_Sub);
|
||
if Order_Sub.IsEmpty then
|
||
begin
|
||
PKDate.DateTime:=Now;
|
||
fsj:=Trim(FormatDateTime('yyyy-MM-dd',PKDate.DateTime));
|
||
PKDate.DateTime:=StrToDate(fsj);
|
||
end else
|
||
begin
|
||
fsj:=Trim(FormatDateTime('yyyy-MM-dd',Order_Sub.fieldbyname('PKDate').AsDateTime));
|
||
PKDate.Date:=StrToDate(fsj);
|
||
end;
|
||
|
||
end;
|
||
|
||
procedure TfrmPKInPut.ZDYHelp(FButn:TcxButtonEdit;LType:string);
|
||
begin
|
||
end;
|
||
|
||
procedure TfrmPKInPut.FormShow(Sender: TObject);
|
||
begin
|
||
ReadCxGrid('<27>ſ<EFBFBD>¼<EFBFBD><C2BC>',Tv1,'<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>');
|
||
ReadCxGrid('Ӧ<><D3A6><EFBFBD>б<EFBFBD>1',Tv2,'<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>');
|
||
InitData();
|
||
end;
|
||
procedure TfrmPKInPut.GetMaxConNO();
|
||
begin
|
||
|
||
end;
|
||
function TfrmPKInPut.SaveData():Boolean;
|
||
var
|
||
maxno:String;
|
||
begin
|
||
try
|
||
Result:=False;
|
||
ADOCmd.Connection.BeginTrans;
|
||
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||
Order_Sub.DisableControls;
|
||
with Order_Sub do
|
||
begin
|
||
First;
|
||
while not Eof do
|
||
begin
|
||
if Trim(Order_Sub.fieldbyname('PKMoney').AsString)<>'' then
|
||
begin
|
||
if Trim(Order_Sub.fieldbyname('PKID').AsString)='' then
|
||
begin
|
||
if GetLSNo(ADOCmd,maxno,'PK','YF_Money_PaiKuan',4,1)=False then
|
||
begin
|
||
Order_Sub.EnableControls;
|
||
ADOCmd.Connection.RollbackTrans;
|
||
Application.MessageBox('ȡ<><C8A1><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ˮ<EFBFBD><CBAE>ʧ<EFBFBD><CAA7>!','<27><>ʾ',0);
|
||
Exit;
|
||
end;
|
||
end else
|
||
begin
|
||
maxno:=Trim(Order_Sub.fieldbyname('PKID').AsString);
|
||
end;
|
||
with ADOCmd do
|
||
begin
|
||
Close;
|
||
sql.Clear;
|
||
SQL.Add('select * from YF_Money_PaiKuan where PKID='''+Trim(Order_Sub.fieldbyname('PKID').AsString)+'''');
|
||
Open;
|
||
end;
|
||
with ADOCmd do
|
||
begin
|
||
if Trim(Order_Sub.fieldbyname('PKID').AsString)='' then
|
||
begin
|
||
Append;
|
||
end
|
||
else begin
|
||
Edit;
|
||
end;
|
||
FieldByName('PKID').Value:=Trim(maxno);
|
||
RTSetSaveDataCDS(ADOCmd,Tv1,Order_Sub,'YF_Money_PaiKuan',0) ;
|
||
FieldByName('PKDate').Value:=Trim(FormatDateTime('yyyy-MM-dd',PKDate.Date));
|
||
FieldByName('FactoryNo').Value:=Order_Sub.fieldbyname('FactoryNo').Value;
|
||
if PState=1 then
|
||
begin
|
||
FieldByName('Chker').Value:=Null;
|
||
FieldByName('ChkStatus').Value:=Null;
|
||
FieldByName('ChkNote').Value:=Null;
|
||
FieldByName('ChkTime').Value:=Null;
|
||
end;
|
||
|
||
if Trim(FMainId)='' then
|
||
begin
|
||
FieldByName('Filler').Value:=Trim(DName);
|
||
end else
|
||
begin
|
||
FieldByName('Editer').Value:=Trim(DName);
|
||
FieldByName('EditTime').Value:=SGetServerDateTime(ADOTemp);
|
||
end;
|
||
Post;
|
||
end;
|
||
with ADOTemp do
|
||
begin
|
||
Close;
|
||
sql.Clear;
|
||
sql.Add('select * from YF_Money_PaiKuan where ');
|
||
sql.Add(' FactoryName='''+Trim(Order_Sub.fieldbyname('FactoryName').AsString)+'''');
|
||
sql.Add(' and isnull(ComTaiTou,'''')='''+Trim(Order_Sub.fieldbyname('ComTaiTou').AsString)+'''');
|
||
sql.Add(' and isnull(FactoryNameOther,'''')='''+Trim(Order_Sub.fieldbyname('FactoryNameOther').AsString)+'''');
|
||
sql.Add(' and isnull(PayMent,'''')='''+Trim(Order_Sub.fieldbyname('PayMent').AsString)+'''');
|
||
sql.Add(' and PKDate='''+Trim(Order_Sub.fieldbyname('PKDate').AsString)+'''');
|
||
Open;
|
||
end;
|
||
if ADOTemp.RecordCount>1 then
|
||
begin
|
||
Result:=False;
|
||
ADOCmd.Connection.RollbackTrans;
|
||
Order_Sub.EnableControls;
|
||
Application.MessageBox(PChar('<27><>Ӧ<EFBFBD><D3A6>:'+
|
||
Trim(Order_Sub.fieldbyname('FactoryName').AsString)+
|
||
Trim(FormatDateTime('yyyy-MM-dd',PKDate.Date))+
|
||
'<27><><EFBFBD>ڵ<EFBFBD><DAB5>ſ<EFBFBD><C5BF><EFBFBD><EFBFBD>ݲ<EFBFBD><DDB2><EFBFBD><EFBFBD>ظ<EFBFBD>¼<EFBFBD><C2BC>!'),'<27><>ʾ',0);
|
||
Exit;
|
||
end;
|
||
Edit;
|
||
FieldByName('PKID').Value:=Trim(maxno);
|
||
end;
|
||
|
||
Next;
|
||
end;
|
||
end;
|
||
Order_Sub.EnableControls;
|
||
ADOCmd.Connection.CommitTrans;
|
||
Result:=True;
|
||
except
|
||
Result:=False;
|
||
ADOCmd.Connection.RollbackTrans;
|
||
Application.MessageBox('<27><><EFBFBD><EFBFBD>ʧ<EFBFBD>ܣ<EFBFBD>','<27><>ʾ',0);
|
||
end;
|
||
end;
|
||
|
||
procedure TfrmPKInPut.TBSaveClick(Sender: TObject);
|
||
var
|
||
FPPrice,PRTPrice,BCMoney,FPQty,ChaMoney:string;
|
||
begin
|
||
ToolBar1.SetFocus;
|
||
|
||
if Order_Sub.IsEmpty then
|
||
begin
|
||
Application.MessageBox('<27><>ϸ<EFBFBD><CFB8><EFBFBD><EFBFBD>Ϊ<EFBFBD>գ<EFBFBD>','<27><>ʾ',0);
|
||
exit;
|
||
end;
|
||
{if Order_Sub.Locate('PKMoney',null,[]) then
|
||
begin
|
||
Application.MessageBox('<27>ſ<EFBFBD><C5BF><EFBFBD><EFBFBD><EFBFBD><EEB2BB>Ϊ<EFBFBD><CEAA>!','<27><>ʾ',0);
|
||
Exit;
|
||
end;}
|
||
Order_Sub.DisableControls;
|
||
with Order_Sub do
|
||
begin
|
||
First;
|
||
while not Eof do
|
||
begin
|
||
if Trim(Order_Sub.fieldbyname('PKMoney').AsString)<>'' then
|
||
begin
|
||
{if Trim(Order_Sub.fieldbyname('ComTaiTou').AsString)='' then
|
||
begin
|
||
Order_Sub.EnableControls;
|
||
Application.MessageBox('<27><><EFBFBD>λ<EEB5A5><CEBB><EFBFBD><EFBFBD>Ϊ<EFBFBD><CEAA>!','<27><>ʾ',0);
|
||
Exit;
|
||
end;}
|
||
if Trim(Order_Sub.fieldbyname('PayMent').AsString)='' then
|
||
begin
|
||
Order_Sub.EnableControls;
|
||
Application.MessageBox('֧<><D6A7><EFBFBD><EFBFBD>ʽ<EFBFBD><CABD><EFBFBD><EFBFBD>Ϊ<EFBFBD><CEAA>!','<27><>ʾ',0);
|
||
Exit;
|
||
end;
|
||
if Trim(Order_Sub.fieldbyname('PSName').AsString)='' then
|
||
begin
|
||
Order_Sub.EnableControls;
|
||
Application.MessageBox('<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ʋ<EFBFBD><C6B2><EFBFBD>Ϊ<EFBFBD><CEAA>!','<27><>ʾ',0);
|
||
Exit;
|
||
end;
|
||
if Trim(Order_Sub.fieldbyname('PKYongTu').AsString)='' then
|
||
begin
|
||
Order_Sub.EnableControls;
|
||
Application.MessageBox('<27>ʽ<EFBFBD><CABD><EFBFBD>;<EFBFBD><CDBE><EFBFBD><EFBFBD>Ϊ<EFBFBD><CEAA>!','<27><>ʾ',0);
|
||
Exit;
|
||
end;
|
||
|
||
end;
|
||
Next;
|
||
end;
|
||
end;
|
||
Order_Sub.EnableControls;
|
||
if SaveData() then
|
||
begin
|
||
Application.MessageBox('<27><><EFBFBD><EFBFBD><EFBFBD>ɹ<EFBFBD><C9B9><EFBFBD>','<27><>ʾ',0);
|
||
ModalResult:=1;
|
||
end;
|
||
|
||
end;
|
||
|
||
procedure TfrmPKInPut.ToolButton3Click(Sender: TObject);
|
||
var
|
||
FKQDate:TDateTime;
|
||
FKQWorkDays,FStr:string;
|
||
begin
|
||
Fstr:='';
|
||
try
|
||
frmGYSList:=TfrmGYSList.Create(Application);
|
||
with frmGYSList do
|
||
begin
|
||
if ShowModal=1 then
|
||
begin
|
||
{with ADOTemp do
|
||
begin
|
||
close;
|
||
SQL.Clear;
|
||
sql.Add('select * from YF_Money_KC where FactoryName='''+Order_Main.fieldbyname('KHNameJC').AsString+'''');
|
||
Open;
|
||
end;
|
||
if ADOTemp.IsEmpty then
|
||
begin
|
||
Fstr:='99';
|
||
end else
|
||
if ADOTemp.FieldByName('KCMoney').Value>0 then
|
||
begin
|
||
FStr:='';
|
||
end else
|
||
begin
|
||
FStr:='99';
|
||
end;}
|
||
with ADOTemp do
|
||
begin
|
||
Close;
|
||
sql.Clear;
|
||
SQL.Add(' select AAA.*,MaxHZYFMoney=isnull(HZYFMoney,0)+isnull(DDuiZhangMoney,0) ');
|
||
sql.Add(' ,BQYFMoney=isnull(BQYFMoney10,0)+isnull(HZKKMoney,0)');
|
||
sql.Add(',Case when GYS.LockFlag=1 and isnull(GYS.LockDays,0)+isnull(AAA.MinMHDate,Getdate())<=getdate() then ''<27><>δ<EFBFBD><CEB4><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>뵥<EFBFBD><EBB5A5><EFBFBD><EFBFBD><EFBFBD>ſ<EFBFBD>'' ');
|
||
SQL.Add(' When isnull((select Top 1 PK.FactoryName from YF_Money_PaiKuan PK ');
|
||
SQL.Add(' where isnull(PK.FKMoney,0)=0 and PK.FactoryName='''+Trim(Order_Main.fieldbyname('KHNameJC').AsString)+'''');
|
||
sql.Add(' and isnull(PK.ChkStatus,'''')<>''<27><><EFBFBD>˲<EFBFBD>ͨ<EFBFBD><CDA8>'' and PK.PKDate>''2014-11-10''), '''')<>'''' then ''<27><>δ<EFBFBD><CEB4><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ſ<EFBFBD><C5BF><EFBFBD>¼<EFBFBD><C2BC><EFBFBD><EFBFBD><EFBFBD>ſ<EFBFBD>'' ');
|
||
SQL.Add(' else '''' end as MDQingKuang');
|
||
sql.Add(' from(');
|
||
sql.Add(' select AA.* ');
|
||
SQL.Add(',MinMHDate=(select min(MHDate) from JYOrder_Main_MD_HZ B ');
|
||
sql.Add(' where B.FactoryName=AA.FactoryName and isnull(B.DuiZhangStatus,'''')='''' )');
|
||
sql.Add(' ,HZYFMoney=(select Sum(Money-YiFuMoney) from YF_Money_CR B ');
|
||
sql.Add(' where B.FactoryName=AA.FactoryName and isnull(B.YiFuMoney,0)<>isnull(B.Money,0)');//and B.PSName=AA.PSName
|
||
sql.Add(' and B.CRType=''Ӧ<><D3A6><EFBFBD><EFBFBD><EFBFBD>Ǽ<EFBFBD>'' )');
|
||
sql.Add(' ,BQKKMoney=(select Sum(Money-YiFuMoney) from YF_Money_CR B ');
|
||
sql.Add(' where B.FactoryName=AA.FactoryName and isnull(B.YiFuMoney,0)<>isnull(B.Money,0)');//and B.PSName=AA.PSName
|
||
sql.Add(' and isnull(B.Money,0)<0 and B.CRTime<='''+Trim(FormatDateTime('yyyy-MM-dd',PKDate.DateTime))+'''');
|
||
sql.Add(' and B.CRType=''Ӧ<><D3A6><EFBFBD><EFBFBD><EFBFBD>Ǽ<EFBFBD>'' )');
|
||
sql.Add(' ,HZKKMoney=(select Sum(Money-YiFuMoney) from YF_Money_CR B ');
|
||
sql.Add(' where B.FactoryName=AA.FactoryName and isnull(B.YiFuMoney,0)<>isnull(B.Money,0)');//and B.PSName=AA.PSName
|
||
sql.Add(' and isnull(B.Money,0)<0 ');
|
||
sql.Add(' and B.CRType=''Ӧ<><D3A6><EFBFBD><EFBFBD><EFBFBD>Ǽ<EFBFBD>'' )');
|
||
sql.Add(' ,DDuiZhangMoney=(select Sum(Money) from JYOrder_Main_MD_HZ JMMH where JMMH.FactoryName=AA.FactoryName ');//and JMMH.PSName=AA.PSName
|
||
sql.Add(' and isnull(JMMH.Status,'''')<>'''' and isnull(JMMH.DuiZhangStatus,'''')='''')');
|
||
sql.Add(' from (');
|
||
sql.Add(' select FactoryName,BQYFMoney10=sum(Money-YiFuMoney) '); //PSName,FactoryNo,
|
||
sql.Add(' from YF_Money_CR A');
|
||
sql.Add(' where CRTime<='''+Trim(FormatDateTime('yyyy-MM-dd',PKDate.DateTime))+'''');
|
||
sql.Add(' and isnull(YiFuMoney,0)<>isnull(Money,0)');
|
||
sql.Add(' and isnull(Money,0)>0');
|
||
sql.Add(' and not exists(select * from YF_Money_PaiKuan PK where PK.FactoryName=A.FactoryName ');
|
||
sql.Add(' and PK.PKDate='''+Trim(FormatDateTime('yyyy-MM-dd',PKDate.DateTime))+''')');
|
||
sql.Add(' and FactoryName='''+Trim(Order_Main.fieldbyname('KHNameJC').AsString)+'''');
|
||
sql.Add(' and A.CRType=''Ӧ<><D3A6><EFBFBD><EFBFBD><EFBFBD>Ǽ<EFBFBD>'' ');
|
||
sql.Add(' Group by FactoryName)AA)AAA');//,PSName ,FactoryNo
|
||
sql.Add(' inner join ZH_KH_Info GYS on Rtrim(GYS.KHNameJC)=RTrim(AAA.FactoryName)');
|
||
//sql.Add(' where (GYS.LockFlag=0 or (GYS.LockFlag=1 and isnull(GYS.LockDays,0)+isnull(AAA.MinMHDate,Getdate())>getdate() ))');
|
||
Open;
|
||
end;
|
||
//if (ADOTemp.IsEmpty=False) or (FStr='99') then
|
||
begin
|
||
with Self.Order_Sub do
|
||
begin
|
||
Append;
|
||
// FieldByName('FactoryNo').Value:=Trim(Order_Main.fieldbyname('ZKID').AsString);
|
||
FieldByName('FactoryName').Value:=Trim(Order_Main.fieldbyname('KHNameJC').AsString);
|
||
FieldByName('PKDate').Value:=PKDate.Date;
|
||
// FieldByName('PSName').Value:=ADOTemp.fieldbyname('PSName').Value;
|
||
FieldByName('MDQingKuang').Value:=ADOTemp.fieldbyname('MDQingKuang').Value;
|
||
FieldByName('BQYFMoney').Value:=ADOTemp.fieldbyname('BQYFMoney').Value;
|
||
FieldByName('HZYFMoney').Value:=ADOTemp.fieldbyname('HZYFMoney').Value;
|
||
FieldByName('BQKKMoney').Value:=ADOTemp.fieldbyname('BQKKMoney').Value;
|
||
FieldByName('HZKKMoney').Value:=ADOTemp.fieldbyname('HZKKMoney').Value;
|
||
FieldByName('DDuiZhangMoney').Value:=ADOTemp.fieldbyname('DDuiZhangMoney').Value;
|
||
FieldByName('MaxHZYFMoney').Value:=ADOTemp.fieldbyname('MaxHZYFMoney').Value;
|
||
Post;
|
||
end;
|
||
end;
|
||
|
||
end;
|
||
end;
|
||
finally
|
||
frmGYSList.Free;
|
||
end;
|
||
|
||
end;
|
||
|
||
procedure TfrmPKInPut.ToolButton4Click(Sender: TObject);
|
||
begin
|
||
if Order_Sub.IsEmpty then Exit;
|
||
if Trim(Order_Sub.fieldbyname('PKId').AsString)<>'' then
|
||
begin
|
||
if Application.MessageBox('ȷ<><C8B7>Ҫɾ<D2AA><C9BE><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>','<27><>ʾ',32+4)<>IDYES then Exit;
|
||
with ADOCmd do
|
||
begin
|
||
Close;
|
||
sql.Clear;
|
||
sql.Add('delete YF_Money_PaiKuan where PKId='''+Trim(Order_Sub.fieldbyname('PKId').AsString)+'''');
|
||
ExecSQL;
|
||
end;
|
||
end;
|
||
Order_Sub.Delete;
|
||
end;
|
||
|
||
procedure TfrmPKInPut.ToolButton1Click(Sender: TObject);
|
||
var
|
||
FReal:Double;
|
||
begin
|
||
if Application.MessageBox('ȷ<><C8B7>Ҫִ<D2AA>д˲<D0B4><CBB2><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>','<27><>ʾ',32+4)<>IDYES then Exit;
|
||
with ADOTemp do
|
||
begin
|
||
Close;
|
||
sql.Clear;
|
||
sql.Add(' select AAA.*,MaxHZYFMoney=isnull(HZYFMoney,0)+isnull(DDuiZhangMoney,0) ');
|
||
sql.Add(' ,BQYFMoney=isnull(BQYFMoney10,0)+isnull(HZKKMoney,0)');
|
||
sql.Add(',Case when GYS.LockFlag=1 and isnull(GYS.LockDays,0)+isnull(AAA.MinMHDate,Getdate())<=getdate() then ''<27><>δ<EFBFBD><CEB4><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>뵥<EFBFBD><EBB5A5><EFBFBD><EFBFBD><EFBFBD>ſ<EFBFBD>'' ');
|
||
SQL.Add(' When isnull((select Top 1 PK.FactoryName from YF_Money_PaiKuan PK ');
|
||
SQL.Add(' where isnull(FKMoney,0)=0 and PK.FactoryName=AAA.FactoryName and PK.PKDate<='''+Trim(FormatDateTime('yyyy-MM-dd',PKDate.Date))+'''');
|
||
sql.Add(' and isnull(PK.ChkStatus,'''')<>''<27><><EFBFBD>˲<EFBFBD>ͨ<EFBFBD><CDA8>'' and PKDate>''2014-11-10''), '''')<>'''' then ''<27><>δ<EFBFBD><CEB4><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ſ<EFBFBD><C5BF><EFBFBD>¼<EFBFBD><C2BC><EFBFBD><EFBFBD><EFBFBD>ſ<EFBFBD>'' ');
|
||
sql.Add(' else '''' end as MDQingKuang');
|
||
sql.Add(' from(');
|
||
sql.Add(' select AA.* ');
|
||
SQL.Add(',MinMHDate=isnull((select min(MHDate) from JYOrder_Main_MD_HZ B ');
|
||
sql.Add(' where B.FactoryName=AA.FactoryName and isnull(B.DuiZhangStatus,'''')='''' ),getdate()+1)'); // and isnull(B.Status,'''')<>''''
|
||
sql.Add(' ,HZYFMoney=(select Sum(Money-YiFuMoney) from YF_Money_CR B ');
|
||
sql.Add(' where B.FactoryName=AA.FactoryName and isnull(B.YiFuMoney,0)<>isnull(B.Money,0)');//and B.PSName=AA.PSName
|
||
sql.Add(' and B.CRType=''Ӧ<><D3A6><EFBFBD><EFBFBD><EFBFBD>Ǽ<EFBFBD>'' )');
|
||
// sql.Add(' and not exists(select * from JYOrder_Main_MD_HZ C on )');
|
||
sql.Add(' ,BQKKMoney=(select Sum(Money-YiFuMoney) from YF_Money_CR B ');
|
||
sql.Add(' where B.FactoryName=AA.FactoryName and isnull(B.YiFuMoney,0)<>isnull(B.Money,0)');//and B.PSName=AA.PSName
|
||
sql.Add(' and isnull(B.Money,0)<0 and B.CRTime<='''+Trim(FormatDateTime('yyyy-MM-dd',PKDate.DateTime))+'''');
|
||
sql.Add(' and B.CRType=''Ӧ<><D3A6><EFBFBD><EFBFBD><EFBFBD>Ǽ<EFBFBD>'' )');
|
||
sql.Add(' ,HZKKMoney=(select Sum(Money-YiFuMoney) from YF_Money_CR B ');
|
||
sql.Add(' where B.FactoryName=AA.FactoryName and isnull(B.YiFuMoney,0)<>isnull(B.Money,0)');//and B.PSName=AA.PSName
|
||
sql.Add(' and isnull(B.Money,0)<0 ');
|
||
sql.Add(' and B.CRType=''Ӧ<><D3A6><EFBFBD><EFBFBD><EFBFBD>Ǽ<EFBFBD>'' )');
|
||
sql.Add(' ,DDuiZhangMoney=(select Sum(Money) from JYOrder_Main_MD_HZ JMMH where JMMH.FactoryName=AA.FactoryName ');//and JMMH.PSName=AA.PSName
|
||
sql.Add(' and isnull(JMMH.Status,'''')<>'''' and isnull(JMMH.DuiZhangStatus,'''')='''')');
|
||
sql.Add(' from (');
|
||
sql.Add(' select FactoryName,BQYFMoney10=sum(Money-YiFuMoney) ');//PSName,FactoryNo,
|
||
sql.Add(' from YF_Money_CR A');
|
||
sql.Add(' where CRTime<='''+Trim(FormatDateTime('yyyy-MM-dd',PKDate.DateTime))+'''');
|
||
sql.Add(' and isnull(YiFuMoney,0)<>isnull(Money,0)');
|
||
sql.Add(' and isnull(Money,0)>0');
|
||
sql.Add(' and A.CRType=''Ӧ<><D3A6><EFBFBD><EFBFBD><EFBFBD>Ǽ<EFBFBD>'' ');
|
||
sql.Add(' and not exists(select * from YF_Money_PaiKuan PK where PK.FactoryName=A.FactoryName ');
|
||
sql.Add(' and PK.PKDate='''+Trim(FormatDateTime('yyyy-MM-dd',PKDate.DateTime))+''')');
|
||
sql.Add(' Group by FactoryName)AA)AAA');//PSName ,FactoryNo
|
||
sql.Add(' inner join ZH_KH_Info GYS on Rtrim(GYS.KHNameJC)=RTrim(AAA.FactoryName)');
|
||
//sql.Add(' where (GYS.LockFlag=0 or (GYS.LockFlag=1 and isnull(GYS.LockDays,0)+isnull(AAA.MinMHDate,Getdate())>getdate() ))');
|
||
//sql.Add(' )AAA');
|
||
//ShowMessage(sql.Text);
|
||
Open;
|
||
end;
|
||
with ADOTemp do
|
||
begin
|
||
First;
|
||
while not Eof do
|
||
begin
|
||
with Order_Sub do
|
||
begin
|
||
Append;
|
||
//FieldByName('FactoryNo').Value:=ADOTemp.fieldbyname('FactoryNo').Value;
|
||
FieldByName('FactoryName').Value:=ADOTemp.fieldbyname('FactoryName').Value;
|
||
//FieldByName('PSName').Value:=ADOTemp.fieldbyname('PSName').Value;
|
||
FieldByName('MDQingKuang').Value:=ADOTemp.fieldbyname('MDQingKuang').Value;
|
||
FieldByName('BQYFMoney').Value:=ADOTemp.fieldbyname('BQYFMoney').Value;
|
||
FieldByName('HZYFMoney').Value:=ADOTemp.fieldbyname('HZYFMoney').Value;
|
||
FieldByName('BQKKMoney').Value:=ADOTemp.fieldbyname('BQKKMoney').Value;
|
||
FieldByName('HZKKMoney').Value:=ADOTemp.fieldbyname('HZKKMoney').Value;
|
||
FieldByName('PKDate').Value:=PKDate.Date;
|
||
FieldByName('DDuiZhangMoney').Value:=ADOTemp.fieldbyname('DDuiZhangMoney').Value;
|
||
FieldByName('MaxHZYFMoney').Value:=ADOTemp.fieldbyname('MaxHZYFMoney').Value;
|
||
Post;
|
||
end;
|
||
Next;
|
||
end;
|
||
end;
|
||
|
||
end;
|
||
|
||
procedure TfrmPKInPut.Tv1CellClick(Sender: TcxCustomGridTableView;
|
||
ACellViewInfo: TcxGridTableDataCellViewInfo; AButton: TMouseButton;
|
||
AShift: TShiftState; var AHandled: Boolean);
|
||
begin
|
||
{ if Trim(Order_Sub.fieldbyname('MDQingKuang').AsString)<>'' then
|
||
begin
|
||
Tv1.OptionsData.Editing:=False;
|
||
end else
|
||
begin
|
||
Tv1.OptionsData.Editing:=True;
|
||
end;
|
||
with ADOTemp do
|
||
begin
|
||
Close;
|
||
sql.Clear;
|
||
sql.Add('select A.*,OrderNo=(select OrderNo from JYOrder_Main where MainId=A.MainId) ');
|
||
SQL.Add(',FKDate=(select Top 1 CRTime from YF_Money_CR YR inner join YF_Money_CR_HX YH on YR.YFID=YH.FKID');
|
||
sql.Add(' where YH.YFID=A.YFID order by YR.CRTime )');
|
||
sql.Add(',YFYMoney=isnull(Money,0)-isnull(YiFuMoney,0)');
|
||
sql.Add(' from YF_Money_CR A where CRType=''Ӧ<><D3A6><EFBFBD><EFBFBD><EFBFBD>Ǽ<EFBFBD>''');
|
||
SQL.Add(' and FactoryName='''+Trim(Order_Sub.fieldbyname('FactoryName').AsString)+'''');
|
||
//SQL.Add(' and PSName='''+Trim(Order_Sub.fieldbyname('PSName').AsString)+'''');
|
||
if RadioGroup1.ItemIndex=0 then
|
||
begin
|
||
sql.Add(' and CRTime<='''+Trim(Order_Sub.fieldbyname('PKDate').AsString)+'''');
|
||
end else
|
||
if RadioGroup1.ItemIndex=1 then
|
||
begin
|
||
sql.Add(' and CRTime>'''+Trim(Order_Sub.fieldbyname('PKDate').AsString)+'''');
|
||
end;
|
||
Open;
|
||
end;
|
||
SCreateCDS20(ADOTemp,ClientDataSet2);
|
||
SInitCDSData20(ADOTemp,ClientDataSet2);
|
||
if Trim(Order_Sub.fieldbyname('PSName').AsString)='' then
|
||
begin
|
||
if ClientDataSet2.IsEmpty then Exit;
|
||
with Order_Sub do
|
||
begin
|
||
Edit;
|
||
FieldByName('PSName').Value:=Trim(ClientDataSet2.fieldbyname('PSName').AsString);
|
||
//Post;
|
||
end;
|
||
end; }
|
||
end;
|
||
|
||
procedure TfrmPKInPut.RadioGroup1Click(Sender: TObject);
|
||
begin
|
||
with ADOTemp do
|
||
begin
|
||
Close;
|
||
sql.Clear;
|
||
sql.Add('select A.*,OrderNo=(select OrderNo from JYOrder_Main where MainId=A.MainId) ');
|
||
SQL.Add(',FKDate=(select Top 1 CRTime from YF_Money_CR YR inner join YF_Money_CR_HX YH on YR.YFID=YH.FKID');
|
||
sql.Add(' where YH.YFID=A.YFID order by YR.CRTime )');
|
||
sql.Add(',YFYMoney=isnull(Money,0)-isnull(YiFuMoney,0)');
|
||
sql.Add(' from YF_Money_CR A where CRType=''Ӧ<><D3A6><EFBFBD><EFBFBD><EFBFBD>Ǽ<EFBFBD>''');
|
||
SQL.Add(' and FactoryName='''+Trim(Order_Sub.fieldbyname('FactoryName').AsString)+'''');
|
||
//SQL.Add(' and PSName='''+Trim(Order_Sub.fieldbyname('PSName').AsString)+'''');
|
||
if RadioGroup1.ItemIndex=0 then
|
||
begin
|
||
sql.Add(' and CRTime<='''+Trim(Order_Sub.fieldbyname('PKDate').AsString)+'''');
|
||
end else
|
||
if RadioGroup1.ItemIndex=1 then
|
||
begin
|
||
sql.Add(' and CRTime>'''+Trim(Order_Sub.fieldbyname('PKDate').AsString)+'''');
|
||
end;
|
||
Open;
|
||
end;
|
||
SCreateCDS20(ADOTemp,ClientDataSet2);
|
||
SInitCDSData20(ADOTemp,ClientDataSet2);
|
||
end;
|
||
|
||
procedure TfrmPKInPut.v1Column11PropertiesButtonClick(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.Order_Sub do
|
||
begin
|
||
Edit;
|
||
FieldByName('ComTaiTou').Value:=Trim(ClientDataSet1.fieldbyname('ZdyName').AsString);
|
||
end;
|
||
end;
|
||
end;
|
||
finally
|
||
frmZDYHelp.Free;
|
||
end;
|
||
end;
|
||
|
||
procedure TfrmPKInPut.v1Column7PropertiesButtonClick(Sender: TObject;
|
||
AButtonIndex: Integer);
|
||
begin
|
||
try
|
||
frmZDYHelp:=TfrmZDYHelp.Create(Application);
|
||
with frmZDYHelp do
|
||
begin
|
||
flag:='PKPayMent';
|
||
flagname:='<27><><EFBFBD>ʽ';
|
||
if ShowModal=1 then
|
||
begin
|
||
with Self.Order_Sub do
|
||
begin
|
||
Edit;
|
||
FieldByName('PayMent').Value:=Trim(ClientDataSet1.fieldbyname('ZdyName').AsString);
|
||
end;
|
||
end;
|
||
end;
|
||
finally
|
||
frmZDYHelp.Free;
|
||
end;
|
||
end;
|
||
|
||
procedure TfrmPKInPut.ToolButton2Click(Sender: TObject);
|
||
begin
|
||
try
|
||
frmModuleNote:=TfrmModuleNote.Create(Application);
|
||
with frmModuleNote do
|
||
begin
|
||
flag:='<27>ſ<EFBFBD>';
|
||
if ShowModal=1 then
|
||
begin
|
||
|
||
end;
|
||
end;
|
||
finally
|
||
frmModuleNote.Free;
|
||
end;
|
||
end;
|
||
|
||
procedure TfrmPKInPut.v1Column13PropertiesButtonClick(Sender: TObject;
|
||
AButtonIndex: Integer);
|
||
begin
|
||
try
|
||
frmZDYHelp:=TfrmZDYHelp.Create(Application);
|
||
with frmZDYHelp do
|
||
begin
|
||
flag:='PKYongTu';
|
||
flagname:='<27>ʽ<EFBFBD><CABD><EFBFBD>;';
|
||
if ShowModal=1 then
|
||
begin
|
||
with Self.Order_Sub do
|
||
begin
|
||
Edit;
|
||
FieldByName('PKYongTu').Value:=Trim(ClientDataSet1.fieldbyname('ZdyName').AsString);
|
||
end;
|
||
end;
|
||
end;
|
||
finally
|
||
frmZDYHelp.Free;
|
||
end;
|
||
end;
|
||
|
||
procedure TfrmPKInPut.Tv1MouseDown(Sender: TObject; Button: TMouseButton;
|
||
Shift: TShiftState; X, Y: Integer);
|
||
begin
|
||
if Trim(Order_Sub.fieldbyname('MDQingKuang').AsString)<>'' then
|
||
begin
|
||
Tv1.OptionsData.Editing:=False;
|
||
end else
|
||
begin
|
||
Tv1.OptionsData.Editing:=True;
|
||
end;
|
||
with ADOTemp do
|
||
begin
|
||
Close;
|
||
sql.Clear;
|
||
sql.Add('select A.*,OrderNo=(select OrderNo from JYOrder_Main where MainId=A.MainId) ');
|
||
SQL.Add(',FKDate=(select Top 1 CRTime from YF_Money_CR YR inner join YF_Money_CR_HX YH on YR.YFID=YH.FKID');
|
||
sql.Add(' where YH.YFID=A.YFID order by YR.CRTime )');
|
||
sql.Add(',YFYMoney=isnull(Money,0)-isnull(YiFuMoney,0)');
|
||
sql.Add(' from YF_Money_CR A where CRType=''Ӧ<><D3A6><EFBFBD><EFBFBD><EFBFBD>Ǽ<EFBFBD>''');
|
||
SQL.Add(' and FactoryName='''+Trim(Order_Sub.fieldbyname('FactoryName').AsString)+'''');
|
||
//SQL.Add(' and PSName='''+Trim(Order_Sub.fieldbyname('PSName').AsString)+'''');
|
||
if RadioGroup1.ItemIndex=0 then
|
||
begin
|
||
sql.Add(' and CRTime<='''+Trim(Order_Sub.fieldbyname('PKDate').AsString)+'''');
|
||
end else
|
||
if RadioGroup1.ItemIndex=1 then
|
||
begin
|
||
sql.Add(' and CRTime>'''+Trim(Order_Sub.fieldbyname('PKDate').AsString)+'''');
|
||
end;
|
||
Open;
|
||
end;
|
||
SCreateCDS20(ADOTemp,ClientDataSet2);
|
||
SInitCDSData20(ADOTemp,ClientDataSet2);
|
||
if Trim(Order_Sub.fieldbyname('PSName').AsString)='' then
|
||
begin
|
||
if ClientDataSet2.IsEmpty then Exit;
|
||
with Order_Sub do
|
||
begin
|
||
Edit;
|
||
FieldByName('PSName').Value:=Trim(ClientDataSet2.fieldbyname('PSName').AsString);
|
||
//Post;
|
||
end;
|
||
end;
|
||
end;
|
||
|
||
end.
|