355 lines
9.8 KiB
ObjectPascal
355 lines
9.8 KiB
ObjectPascal
|
|
unit U_YWLDJSList;
|
|||
|
|
|
|||
|
|
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, cxPC, cxDropDownEdit, BtnEdit, Menus, Buttons;
|
|||
|
|
|
|||
|
|
type
|
|||
|
|
TfrmYWLDJSList = class(TForm)
|
|||
|
|
ToolBar1: TToolBar;
|
|||
|
|
TBRafresh: TToolButton;
|
|||
|
|
TBDel: TToolButton;
|
|||
|
|
TBClose: TToolButton;
|
|||
|
|
ADOQueryTemp: TADOQuery;
|
|||
|
|
ADOQueryCmd: TADOQuery;
|
|||
|
|
Panel1: TPanel;
|
|||
|
|
TBFind: TToolButton;
|
|||
|
|
ADOQueryMain: TADOQuery;
|
|||
|
|
TBExport: TToolButton;
|
|||
|
|
RM1: TRMGridReport;
|
|||
|
|
RMDB_Main: TRMDBDataSet;
|
|||
|
|
cxGrid2: TcxGrid;
|
|||
|
|
Tv2: TcxGridDBTableView;
|
|||
|
|
cxGridLevel1: TcxGridLevel;
|
|||
|
|
cxGridPopupMenu2: TcxGridPopupMenu;
|
|||
|
|
DS_HZ: TDataSource;
|
|||
|
|
CDS_HZ: TClientDataSet;
|
|||
|
|
TBAdd: TToolButton;
|
|||
|
|
v2Column1: TcxGridDBColumn;
|
|||
|
|
TBEdit: TToolButton;
|
|||
|
|
v2Column10: TcxGridDBColumn;
|
|||
|
|
v2Column11: TcxGridDBColumn;
|
|||
|
|
v2Column12: TcxGridDBColumn;
|
|||
|
|
Label8: TLabel;
|
|||
|
|
FactoryNo: TEdit;
|
|||
|
|
v2Column3: TcxGridDBColumn;
|
|||
|
|
v2Column2: TcxGridDBColumn;
|
|||
|
|
v2Column5: TcxGridDBColumn;
|
|||
|
|
Label2: TLabel;
|
|||
|
|
begdate: TDateTimePicker;
|
|||
|
|
Enddate: TDateTimePicker;
|
|||
|
|
Label3: TLabel;
|
|||
|
|
ConNo: TEdit;
|
|||
|
|
v2Column6: TcxGridDBColumn;
|
|||
|
|
v2Column8: TcxGridDBColumn;
|
|||
|
|
v2Column15: TcxGridDBColumn;
|
|||
|
|
v2Column16: TcxGridDBColumn;
|
|||
|
|
v2Column4: TcxGridDBColumn;
|
|||
|
|
v2Column7: 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 TBFindClick(Sender: TObject);
|
|||
|
|
procedure FactoryName10Change(Sender: TObject);
|
|||
|
|
procedure TBExportClick(Sender: TObject);
|
|||
|
|
procedure cxTabControl1Change(Sender: TObject);
|
|||
|
|
procedure TBAddClick(Sender: TObject);
|
|||
|
|
procedure TBEditClick(Sender: TObject);
|
|||
|
|
procedure Tv2CellDblClick(Sender: TcxCustomGridTableView;
|
|||
|
|
ACellViewInfo: TcxGridTableDataCellViewInfo; AButton: TMouseButton;
|
|||
|
|
AShift: TShiftState; var AHandled: Boolean);
|
|||
|
|
procedure FKTypeChange(Sender: TObject);
|
|||
|
|
private
|
|||
|
|
{ Private declarations }
|
|||
|
|
canshu1:string;
|
|||
|
|
procedure InitGrid();
|
|||
|
|
|
|||
|
|
public
|
|||
|
|
{ Public declarations }
|
|||
|
|
|
|||
|
|
end;
|
|||
|
|
|
|||
|
|
//var
|
|||
|
|
//frmBankMoneyKHList: TfrmBankMoneyKHList;
|
|||
|
|
|
|||
|
|
implementation
|
|||
|
|
uses
|
|||
|
|
U_DataLink,U_Fun,U_ZDYHelp,U_RTFun,U_BankMoneyKHInPut,U_FjList;
|
|||
|
|
|
|||
|
|
{$R *.dfm}
|
|||
|
|
|
|||
|
|
|
|||
|
|
|
|||
|
|
procedure TfrmYWLDJSList.InitGrid();
|
|||
|
|
var
|
|||
|
|
fsj:string;
|
|||
|
|
begin
|
|||
|
|
fsj:=SGetWhereFinds(Panel1,1,2);
|
|||
|
|
try
|
|||
|
|
ADOQueryMain.DisableControls;
|
|||
|
|
with ADOQueryMain do
|
|||
|
|
begin
|
|||
|
|
Filtered:=False;
|
|||
|
|
Close;
|
|||
|
|
SQL.Clear;
|
|||
|
|
sql.Add('SELECT AA.* FROM(');
|
|||
|
|
sql.Add(' select CRTime,A.Note,A.YFID,A.JSMoney,A.FKType ');
|
|||
|
|
sql.Add(',A.FactoryNo,A.CRType,A.CRFlag,A.YFName,A.ConNo,A.ChkStatusP');
|
|||
|
|
sql.Add(',FactoryName=(select KHNameJC from KH_Main KM where KM.KHNO=A.FactoryNo and Valid=''Y'' )');
|
|||
|
|
sql.Add(',SDQty=(select Count(*) from TP_File TF where TF.WBID=A.YFID and TF.TFType=''<27>ͻ<EFBFBD><CDBB><EFBFBD><EFBFBD>ù<EFBFBD><C3B9><EFBFBD>'' )');
|
|||
|
|
sql.Add(',Case when isnull(A.BZType,'''')=''<27><>'' then JSMoney else Null end as MoneyRMB ');
|
|||
|
|
sql.Add(',Case when isnull(A.BZType,'''')=''$'' then JSMoney else Null end as MoneyMJ ');
|
|||
|
|
sql.Add(' from YS_Money_CR A');
|
|||
|
|
sql.Add(' left join KH_Sub_Bank B on A.BKNO=B.BKNO');
|
|||
|
|
sql.Add(' left join KH_Main C on B.KHMainId=C.KHMainId');
|
|||
|
|
sql.Add(' where 1=1 ');
|
|||
|
|
// if CheckBox1.Checked then
|
|||
|
|
// begin
|
|||
|
|
sql.Add('and A.CRTime>='''+FormatDateTime('yyyy-MM-dd',begdate.DateTime)+''' ');
|
|||
|
|
sql.Add(' and CRTime<'''+FormatDateTime('yyyy-MM-dd',Enddate.DateTime+1)+''' ');
|
|||
|
|
//end else
|
|||
|
|
// begin
|
|||
|
|
//sql.Add('where A.CRTime>=''2000-01-01'' ');
|
|||
|
|
//sql.Add(' and CRTime<''2500-01-01'' ');
|
|||
|
|
//end;
|
|||
|
|
if Trim(canshu1)='' then
|
|||
|
|
begin
|
|||
|
|
sql.Add(' and A.Filler='''+Trim(DName)+'''');
|
|||
|
|
end;
|
|||
|
|
sql.Add(' and A.CRType=''<27>ͻ<EFBFBD><CDBB><EFBFBD><EFBFBD>ù<EFBFBD><C3B9><EFBFBD>'')AA where 1=1 ');
|
|||
|
|
SQL.Add(fsj);
|
|||
|
|
Open;
|
|||
|
|
end;
|
|||
|
|
SCreateCDS20(ADOQueryMain,CDS_HZ);
|
|||
|
|
SInitCDSData20(ADOQueryMain,CDS_HZ);
|
|||
|
|
finally
|
|||
|
|
ADOQueryMain.EnableControls;
|
|||
|
|
TBFind.Click;
|
|||
|
|
end;
|
|||
|
|
end;
|
|||
|
|
|
|||
|
|
|
|||
|
|
procedure TfrmYWLDJSList.FormDestroy(Sender: TObject);
|
|||
|
|
begin
|
|||
|
|
//frmYWLDJSList:=nil;
|
|||
|
|
end;
|
|||
|
|
|
|||
|
|
procedure TfrmYWLDJSList.FormClose(Sender: TObject; var Action: TCloseAction);
|
|||
|
|
begin
|
|||
|
|
Action:=caFree;
|
|||
|
|
end;
|
|||
|
|
|
|||
|
|
procedure TfrmYWLDJSList.TBCloseClick(Sender: TObject);
|
|||
|
|
begin
|
|||
|
|
WriteCxGrid(Copy(Self.Caption,1,Length(Self.Caption)-1),Tv2,'<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>');
|
|||
|
|
Close;
|
|||
|
|
end;
|
|||
|
|
procedure TfrmYWLDJSList.TBDelClick(Sender: TObject);
|
|||
|
|
begin
|
|||
|
|
if CDS_HZ.IsEmpty then Exit;
|
|||
|
|
if Trim(DCode)<>'ADMIN' then
|
|||
|
|
begin
|
|||
|
|
with ADOQueryTemp do
|
|||
|
|
begin
|
|||
|
|
Close;
|
|||
|
|
sql.Clear;
|
|||
|
|
sql.Add('select AA=Cast(GETDATE()-Filltime as Int) from YS_Money_CR where YFID='''+Self.CDS_HZ.fieldbyname('YFID').AsString+'''');
|
|||
|
|
Open;
|
|||
|
|
end;
|
|||
|
|
if ADOQueryTemp.FieldByName('AA').AsInteger>0 then
|
|||
|
|
begin
|
|||
|
|
Application.MessageBox('<27><><EFBFBD><EFBFBD>24Сʱ<D0A1><CAB1><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ɾ<EFBFBD><C9BE><EFBFBD><EFBFBD><EFBFBD><EFBFBD>!','<27><>ʾ',0);
|
|||
|
|
Exit;
|
|||
|
|
end;
|
|||
|
|
end;
|
|||
|
|
with ADOQueryTemp do
|
|||
|
|
begin
|
|||
|
|
Close;
|
|||
|
|
sql.Clear;
|
|||
|
|
sql.Add('select * from YS_Money_CR where YFID='''+Self.CDS_HZ.fieldbyname('YFID').AsString+'''');
|
|||
|
|
Open;
|
|||
|
|
end;
|
|||
|
|
if Trim(ADOQueryTemp.FieldByName('ChkStatusP').AsString)='<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>' then
|
|||
|
|
begin
|
|||
|
|
Application.MessageBox('<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ˣ<EFBFBD><CBA3><EFBFBD><EFBFBD>ܲ<EFBFBD><DCB2><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>!','<27><>ʾ',0);
|
|||
|
|
Exit;
|
|||
|
|
end;
|
|||
|
|
if Application.MessageBox('ȷ<><C8B7>Ҫɾ<D2AA><C9BE><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>','<27><>ʾ',32+4)<>IDYES then Exit;
|
|||
|
|
try
|
|||
|
|
ADOQueryCmd.Connection.BeginTrans;
|
|||
|
|
with ADOQueryCmd do
|
|||
|
|
begin
|
|||
|
|
close;
|
|||
|
|
sql.Clear;
|
|||
|
|
sql.Add(' insert into YS_Money_CR_DelLog ');
|
|||
|
|
sql.Add(' select * from YS_Money_CR where YFID='''+Trim(CDS_HZ.fieldbyname('YFID').AsString)+'''');
|
|||
|
|
sql.Add(' Update YS_Money_CR_DelLog Set DelTime=getdate(),DelPerson='''+Trim(DName)+'''');
|
|||
|
|
sql.Add(' where YFID='''+Trim(CDS_HZ.fieldbyname('YFID').AsString)+'''');
|
|||
|
|
sql.Add(' delete YS_Money_CR where YFID='''+Trim(CDS_HZ.fieldbyname('YFID').AsString)+'''');
|
|||
|
|
execsql;
|
|||
|
|
end;
|
|||
|
|
ADOQueryCmd.Connection.CommitTrans;
|
|||
|
|
CDS_HZ.Delete;
|
|||
|
|
except
|
|||
|
|
ADOQueryCmd.Connection.RollbackTrans;
|
|||
|
|
Application.MessageBox('ɾ<><C9BE>ʧ<EFBFBD><CAA7>!','<27><>ʾ',0);
|
|||
|
|
end;
|
|||
|
|
end;
|
|||
|
|
|
|||
|
|
procedure TfrmYWLDJSList.FormShow(Sender: TObject);
|
|||
|
|
begin
|
|||
|
|
if Pos('<27><><EFBFBD><EFBFBD>',Trim(Self.Caption))>0 then
|
|||
|
|
begin
|
|||
|
|
canshu1:='<27><><EFBFBD><EFBFBD>';
|
|||
|
|
end else
|
|||
|
|
begin
|
|||
|
|
canshu1:='';
|
|||
|
|
end;
|
|||
|
|
Enddate.DateTime:=SGetServerDate(ADOQueryTemp);
|
|||
|
|
begdate.DateTime:=StrToDate(FormatDateTime('yyyy',Enddate.Date)+'-01-01');
|
|||
|
|
ReadCxGrid(Copy(Self.Caption,1,Length(Self.Caption)-1),Tv2,'<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>');
|
|||
|
|
InitGrid();
|
|||
|
|
end;
|
|||
|
|
|
|||
|
|
procedure TfrmYWLDJSList.TBRafreshClick(Sender: TObject);
|
|||
|
|
begin
|
|||
|
|
ToolBar1.SetFocus;
|
|||
|
|
InitGrid();
|
|||
|
|
|
|||
|
|
end;
|
|||
|
|
|
|||
|
|
procedure TfrmYWLDJSList.TBFindClick(Sender: TObject);
|
|||
|
|
begin
|
|||
|
|
if ADOQueryMain.Active=False then Exit;
|
|||
|
|
SDofilter(ADOQueryMain,SGetFilters(Panel1,1,2));
|
|||
|
|
SCreateCDS20(ADOQueryMain,CDS_HZ);
|
|||
|
|
SInitCDSData20(ADOQueryMain,CDS_HZ);
|
|||
|
|
end;
|
|||
|
|
|
|||
|
|
procedure TfrmYWLDJSList.FactoryName10Change(Sender: TObject);
|
|||
|
|
begin
|
|||
|
|
TBFind.Click;
|
|||
|
|
end;
|
|||
|
|
|
|||
|
|
|
|||
|
|
|
|||
|
|
procedure TfrmYWLDJSList.TBExportClick(Sender: TObject);
|
|||
|
|
begin
|
|||
|
|
if ADOQueryMain.IsEmpty then Exit;
|
|||
|
|
SelExportData(Tv2,ADOQueryMain,'<27>ͻ<EFBFBD><CDBB><EFBFBD><EFBFBD><EFBFBD><EFBFBD>б<EFBFBD>');
|
|||
|
|
end;
|
|||
|
|
|
|||
|
|
procedure TfrmYWLDJSList.cxTabControl1Change(Sender: TObject);
|
|||
|
|
begin
|
|||
|
|
InitGrid();
|
|||
|
|
end;
|
|||
|
|
|
|||
|
|
procedure TfrmYWLDJSList.TBAddClick(Sender: TObject);
|
|||
|
|
begin
|
|||
|
|
try
|
|||
|
|
frmBankMoneyKHInPut:=TfrmBankMoneyKHInPut.Create(Application);
|
|||
|
|
with frmBankMoneyKHInPut do
|
|||
|
|
begin
|
|||
|
|
FMainId:='';
|
|||
|
|
if ShowModal=1 then
|
|||
|
|
begin
|
|||
|
|
InitGrid();
|
|||
|
|
end;
|
|||
|
|
end;
|
|||
|
|
finally
|
|||
|
|
frmBankMoneyKHInPut.Free;
|
|||
|
|
end;
|
|||
|
|
end;
|
|||
|
|
|
|||
|
|
procedure TfrmYWLDJSList.TBEditClick(Sender: TObject);
|
|||
|
|
begin
|
|||
|
|
if Trim(DCode)<>'ADMIN' then
|
|||
|
|
begin
|
|||
|
|
with ADOQueryTemp do
|
|||
|
|
begin
|
|||
|
|
Close;
|
|||
|
|
sql.Clear;
|
|||
|
|
sql.Add('select AA=Cast(GETDATE()-Filltime as Int) from YS_Money_CR where YFID='''+Self.CDS_HZ.fieldbyname('YFID').AsString+'''');
|
|||
|
|
Open;
|
|||
|
|
end;
|
|||
|
|
if ADOQueryTemp.FieldByName('AA').AsInteger>0 then
|
|||
|
|
begin
|
|||
|
|
Application.MessageBox('<27><><EFBFBD><EFBFBD>24Сʱ<D0A1><CAB1><EFBFBD><EFBFBD><EFBFBD>ܸ<EFBFBD><DCB8><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>!','<27><>ʾ',0);
|
|||
|
|
Exit;
|
|||
|
|
end;
|
|||
|
|
end;
|
|||
|
|
with ADOQueryTemp do
|
|||
|
|
begin
|
|||
|
|
Close;
|
|||
|
|
sql.Clear;
|
|||
|
|
sql.Add('select * from YS_Money_CR where YFID='''+Self.CDS_HZ.fieldbyname('YFID').AsString+'''');
|
|||
|
|
Open;
|
|||
|
|
end;
|
|||
|
|
if Trim(ADOQueryTemp.FieldByName('ChkStatusP').AsString)='<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>' then
|
|||
|
|
begin
|
|||
|
|
Application.MessageBox('<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ˣ<EFBFBD><CBA3><EFBFBD><EFBFBD>ܲ<EFBFBD><DCB2><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>!','<27><>ʾ',0);
|
|||
|
|
Exit;
|
|||
|
|
end;
|
|||
|
|
try
|
|||
|
|
frmBankMoneyKHInPut:=TfrmBankMoneyKHInPut.Create(Application);
|
|||
|
|
with frmBankMoneyKHInPut do
|
|||
|
|
begin
|
|||
|
|
FMainId:=Trim(Self.CDS_HZ.fieldbyname('YFID').AsString);
|
|||
|
|
if ShowModal=1 then
|
|||
|
|
begin
|
|||
|
|
InitGrid();
|
|||
|
|
end;
|
|||
|
|
end;
|
|||
|
|
finally
|
|||
|
|
frmBankMoneyKHInPut.Free;
|
|||
|
|
end;
|
|||
|
|
end;
|
|||
|
|
|
|||
|
|
procedure TfrmYWLDJSList.Tv2CellDblClick(Sender: TcxCustomGridTableView;
|
|||
|
|
ACellViewInfo: TcxGridTableDataCellViewInfo; AButton: TMouseButton;
|
|||
|
|
AShift: TShiftState; var AHandled: Boolean);
|
|||
|
|
var
|
|||
|
|
FName:string;
|
|||
|
|
begin
|
|||
|
|
FName:=Tv2.Controller.FocusedColumn.DataBinding.FilterFieldName;
|
|||
|
|
if Trim(FName)='SDQty' then
|
|||
|
|
begin
|
|||
|
|
if CDS_HZ.IsEmpty then Exit;
|
|||
|
|
try
|
|||
|
|
frmFjList:=TfrmFjList.Create(Application);
|
|||
|
|
with frmFjList do
|
|||
|
|
begin
|
|||
|
|
fkeyNO:=Trim(CDS_HZ.fieldbyname('YFID').AsString);
|
|||
|
|
fType:='<27>ͻ<EFBFBD><CDBB><EFBFBD><EFBFBD>ù<EFBFBD><C3B9><EFBFBD>';
|
|||
|
|
fstatus:=0;
|
|||
|
|
if ShowModal=1 then
|
|||
|
|
begin
|
|||
|
|
|
|||
|
|
end;
|
|||
|
|
end;
|
|||
|
|
finally
|
|||
|
|
frmFjList.Free;
|
|||
|
|
end;
|
|||
|
|
end;
|
|||
|
|
end;
|
|||
|
|
|
|||
|
|
procedure TfrmYWLDJSList.FKTypeChange(Sender: TObject);
|
|||
|
|
begin
|
|||
|
|
TBFind.Click;
|
|||
|
|
end;
|
|||
|
|
|
|||
|
|
end.
|