309 lines
10 KiB
ObjectPascal
309 lines
10 KiB
ObjectPascal
unit U_KHSKListView;
|
||
|
||
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,
|
||
cxLookAndFeels, cxLookAndFeelPainters, cxNavigator;
|
||
|
||
type
|
||
TfrmKHSKListView = class(TForm)
|
||
ToolBar1: TToolBar;
|
||
TBRafresh: TToolButton;
|
||
TBClose: TToolButton;
|
||
ADOQueryTemp: TADOQuery;
|
||
ADOQueryCmd: TADOQuery;
|
||
Panel1: TPanel;
|
||
TBFind: TToolButton;
|
||
ADOQueryMain: TADOQuery;
|
||
Label3: TLabel;
|
||
cxGrid2: TcxGrid;
|
||
Tv2: TcxGridDBTableView;
|
||
cxGridLevel1: TcxGridLevel;
|
||
begdate: TDateTimePicker;
|
||
Enddate: TDateTimePicker;
|
||
cxGridPopupMenu2: TcxGridPopupMenu;
|
||
DS_HZ: TDataSource;
|
||
CDS_HZ: TClientDataSet;
|
||
v2Column3: TcxGridDBColumn;
|
||
CheckBox1: TCheckBox;
|
||
v2Column2: TcxGridDBColumn;
|
||
Label6: TLabel;
|
||
BZType: TComboBox;
|
||
v2Column5: TcxGridDBColumn;
|
||
v2Column15: TcxGridDBColumn;
|
||
FactoryNameHZ: TEdit;
|
||
v2Column4: TcxGridDBColumn;
|
||
cxGrid3: TcxGrid;
|
||
Tv3: TcxGridDBTableView;
|
||
cxGridDBColumn3: TcxGridDBColumn;
|
||
v2Column9: TcxGridDBColumn;
|
||
v2Column10: TcxGridDBColumn;
|
||
cxGridDBColumn25: TcxGridDBColumn;
|
||
v2Column13: TcxGridDBColumn;
|
||
v2Column6: TcxGridDBColumn;
|
||
cxGridLevel3: TcxGridLevel;
|
||
DataSource3: TDataSource;
|
||
cxGridPopupMenu3: TcxGridPopupMenu;
|
||
ClientDataSet3: TClientDataSet;
|
||
procedure FormDestroy(Sender: TObject);
|
||
procedure FormClose(Sender: TObject; var Action: TCloseAction);
|
||
procedure TBCloseClick(Sender: TObject);
|
||
procedure FormShow(Sender: TObject);
|
||
procedure TBRafreshClick(Sender: TObject);
|
||
procedure TBFindClick(Sender: TObject);
|
||
procedure cxTabControl1Change(Sender: TObject);
|
||
procedure Tv2CellDblClick(Sender: TcxCustomGridTableView;
|
||
ACellViewInfo: TcxGridTableDataCellViewInfo; AButton: TMouseButton;
|
||
AShift: TShiftState; var AHandled: Boolean);
|
||
procedure v2Column10CustomDrawCell(Sender: TcxCustomGridTableView;
|
||
ACanvas: TcxCanvas; AViewInfo: TcxGridTableDataCellViewInfo;
|
||
var ADone: Boolean);
|
||
procedure ConNoChange(Sender: TObject);
|
||
procedure YFNameChange(Sender: TObject);
|
||
procedure Tv2StylesGetContentStyle(Sender: TcxCustomGridTableView;
|
||
ARecord: TcxCustomGridRecord; AItem: TcxCustomGridTableItem;
|
||
out AStyle: TcxStyle);
|
||
procedure Tv3CellDblClick(Sender: TcxCustomGridTableView;
|
||
ACellViewInfo: TcxGridTableDataCellViewInfo; AButton: TMouseButton;
|
||
AShift: TShiftState; var AHandled: Boolean);
|
||
private
|
||
{ Private declarations }
|
||
|
||
procedure InitGrid();
|
||
|
||
public
|
||
{ Public declarations }
|
||
FKHNO:String;
|
||
FKBegDate,FKEndDate:TDateTime;
|
||
end;
|
||
|
||
var
|
||
frmKHSKListView: TfrmKHSKListView;
|
||
|
||
implementation
|
||
uses
|
||
U_DataLink,U_Fun,U_ZDYHelp, U_KHListSelJJ,U_RTFun,U_KHSKInPut,U_FjList,U_BankMoneyKHInPut;
|
||
|
||
{$R *.dfm}
|
||
|
||
|
||
|
||
procedure TfrmKHSKListView.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=Convert(varchar(7),A.CRTime,120),A.SKDate,A.FactoryNo,A.FactoryNoSub,A.BZType,A.YFName,A.Payment,A.Note,A.YFID,A.Money,A.ConNo ');
|
||
sql.Add(',FactoryName=(select KHNameJC from KH_Main KM where KM.KHNO=A.FactoryNo)');
|
||
sql.Add(',HuMing=(select HuMing from KH_Sub_Bank KSB where KSB.KHNOSub=A.FactoryNoSub)');
|
||
sql.Add(',FactoryNameHZ=dbo.getpinyin((select KHName from KH_Main KM where KM.KHNO=A.FactoryNo))+(select KHNameJC from KH_Main KM where KM.KHNO=A.FactoryNo)+ ');
|
||
sql.Add('isnull((select HuMing from KH_Sub_Bank KSB where KSB.KHNOSub=A.FactoryNoSub),'''')');
|
||
sql.Add(' +A.FactoryNo+isnull(FactoryNoSub,'''')+dbo.getpinyin(isnull((select HuMing from KH_Sub_Bank KSB where KSB.KHNOSub=A.FactoryNoSub),''''))');
|
||
sql.Add(',SDQty=(select Count(*) from TP_File TF where TF.WBID=A.YFID and TF.TFType=''<27>տ<EFBFBD><D5BF><EFBFBD><EFBFBD><EFBFBD>'' )');
|
||
sql.Add(',Case when isnull(BZType,'''')=''<27><>'' then ShiShouMoney else Null end as MoneyRMB ');
|
||
sql.Add(',Case when isnull(BZType,'''')=''$'' then ShiShouMoney else Null end as MoneyMJ ');
|
||
sql.Add(',B.BankNo,B.BankName,B.HuMingJC,A.GSNO,A.BKNO,A.ShuidanMoney,A.ShouXuMoney,A.JSMoney,A.Filler,A.FillTime,A.ChkStatusP');
|
||
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 A.FactoryNo='''+Trim(FKHNO)+'''');
|
||
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(' and A.CRTime>=''2000-01-01'' ');
|
||
sql.Add(' and CRTime<''2500-01-01'' ');
|
||
end;
|
||
sql.Add(' and A.CRType=''<27>տ<EFBFBD><D5BF>Ǽ<EFBFBD>'')AA where 1=1 ');
|
||
SQL.Add(fsj);
|
||
Open;
|
||
end;
|
||
SCreateCDS20(ADOQueryMain,CDS_HZ);
|
||
SInitCDSData20(ADOQueryMain,CDS_HZ);
|
||
finally
|
||
ADOQueryMain.EnableControls;
|
||
TBFind.Click;
|
||
end;
|
||
try
|
||
ADOQueryTemp.DisableControls;
|
||
with ADOQueryTemp do
|
||
begin
|
||
Filtered:=False;
|
||
Close;
|
||
SQL.Clear;
|
||
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 A.FactoryNo='''+Trim(FKHNO)+'''');
|
||
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(' and A.CRTime>=''2000-01-01'' ');
|
||
sql.Add(' and CRTime<''2500-01-01'' ');
|
||
end;
|
||
sql.Add(' and A.CRType=''<27>ͻ<EFBFBD><CDBB><EFBFBD><EFBFBD>ù<EFBFBD><C3B9><EFBFBD>''');
|
||
Open;
|
||
end;
|
||
SCreateCDS20(ADOQueryTemp,ClientDataSet3);
|
||
SInitCDSData20(ADOQueryTemp,ClientDataSet3);
|
||
finally
|
||
ClientDataSet3.EnableControls;
|
||
end;
|
||
end;
|
||
|
||
|
||
procedure TfrmKHSKListView.FormDestroy(Sender: TObject);
|
||
begin
|
||
frmKHSKListView:=nil;
|
||
end;
|
||
|
||
procedure TfrmKHSKListView.FormClose(Sender: TObject; var Action: TCloseAction);
|
||
begin
|
||
Action:=caFree;
|
||
end;
|
||
|
||
procedure TfrmKHSKListView.TBCloseClick(Sender: TObject);
|
||
begin
|
||
WriteCxGrid('<27>ͻ<EFBFBD><CDBB>տ<EFBFBD><D5BF>б<EFBFBD>JJ',Tv2,'<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>');
|
||
WriteCxGrid('<27>ͻ<EFBFBD><CDBB><EFBFBD><EFBFBD><EFBFBD><EFBFBD>б<EFBFBD>JJ',Tv3,'<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>');
|
||
Close;
|
||
end;
|
||
procedure TfrmKHSKListView.FormShow(Sender: TObject);
|
||
begin
|
||
ReadCxGrid('<27>ͻ<EFBFBD><CDBB>տ<EFBFBD><D5BF>б<EFBFBD>JJ',Tv2,'<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>');
|
||
ReadCxGrid('<27>ͻ<EFBFBD><CDBB><EFBFBD><EFBFBD><EFBFBD><EFBFBD>б<EFBFBD>JJ',Tv3,'<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>');
|
||
InitGrid();
|
||
end;
|
||
|
||
procedure TfrmKHSKListView.TBRafreshClick(Sender: TObject);
|
||
begin
|
||
ToolBar1.SetFocus;
|
||
InitGrid();
|
||
end;
|
||
|
||
procedure TfrmKHSKListView.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 TfrmKHSKListView.cxTabControl1Change(Sender: TObject);
|
||
begin
|
||
InitGrid();
|
||
end;
|
||
|
||
procedure TfrmKHSKListView.Tv2CellDblClick(Sender: TcxCustomGridTableView;
|
||
ACellViewInfo: TcxGridTableDataCellViewInfo; AButton: TMouseButton;
|
||
AShift: TShiftState; var AHandled: Boolean);
|
||
|
||
begin
|
||
try
|
||
frmKHSKInPut:=TfrmKHSKInPut.Create(Application);
|
||
with frmKHSKInPut do
|
||
begin
|
||
FMainId:=Trim(Self.CDS_HZ.fieldbyname('YFID').AsString);
|
||
ToolButton4.Visible:=False;
|
||
Panel1.Enabled:=False;
|
||
if ShowModal=1 then
|
||
begin
|
||
|
||
end;
|
||
end;
|
||
finally
|
||
frmKHSKInPut.Free;
|
||
end;
|
||
end;
|
||
|
||
procedure TfrmKHSKListView.v2Column10CustomDrawCell(
|
||
Sender: TcxCustomGridTableView; ACanvas: TcxCanvas;
|
||
AViewInfo: TcxGridTableDataCellViewInfo; var ADone: Boolean);
|
||
var
|
||
id,id10:Integer;
|
||
begin
|
||
Id:=Tv2.GetColumnByFieldName('ShuidanMoney').Index;
|
||
id10:=Tv2.GetColumnByFieldName('MoneyMJ').Index;
|
||
if AViewInfo.GridRecord.Values[Id]>0 then
|
||
begin
|
||
if AViewInfo.GridRecord.Values[Id10]=Null then
|
||
begin
|
||
ACanvas.Brush.Color:=clRed;
|
||
end;
|
||
end;
|
||
end;
|
||
|
||
procedure TfrmKHSKListView.ConNoChange(Sender: TObject);
|
||
begin
|
||
TBFind.Click;
|
||
end;
|
||
|
||
procedure TfrmKHSKListView.YFNameChange(Sender: TObject);
|
||
begin
|
||
TBFind.Click;
|
||
end;
|
||
|
||
procedure TfrmKHSKListView.Tv2StylesGetContentStyle(
|
||
Sender: TcxCustomGridTableView; ARecord: TcxCustomGridRecord;
|
||
AItem: TcxCustomGridTableItem; out AStyle: TcxStyle);
|
||
var
|
||
id:Integer;
|
||
begin
|
||
Id:=Tv2.GetColumnByFieldName('ChkStatusP').Index;
|
||
if ARecord.Values[id]='<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>' then exit;
|
||
AStyle:=DataLink_Money.SkyBlue;
|
||
end;
|
||
|
||
|
||
procedure TfrmKHSKListView.Tv3CellDblClick(Sender: TcxCustomGridTableView;
|
||
ACellViewInfo: TcxGridTableDataCellViewInfo; AButton: TMouseButton;
|
||
AShift: TShiftState; var AHandled: Boolean);
|
||
begin
|
||
try
|
||
frmBankMoneyKHInPut:=TfrmBankMoneyKHInPut.Create(Application);
|
||
with frmBankMoneyKHInPut do
|
||
begin
|
||
FMainId:=Trim(Self.ClientDataSet3.fieldbyname('YFID').AsString);
|
||
ToolButton4.Visible:=False;
|
||
Panel1.Enabled:=False;
|
||
if ShowModal=1 then
|
||
begin
|
||
InitGrid();
|
||
end;
|
||
end;
|
||
finally
|
||
frmBankMoneyKHInPut.Free;
|
||
end;
|
||
end;
|
||
|
||
end.
|