D7wmguihua/桂华管理系统/U_KH_XS_list.pas
DESKTOP-E401PHE\Administrator b4b5840f18 1
2025-01-18 16:22:10 +08:00

269 lines
8.5 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_KH_XS_list;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, cxStyles, cxCustomData, cxGraphics, cxFilter, cxData,
cxDataStorage, cxEdit, DB, cxDBData, cxGridCustomTableView,
cxGridTableView, cxGridBandedTableView, cxGridDBBandedTableView,
cxGridLevel, cxClasses, cxControls, cxGridCustomView, cxGridDBTableView,
cxGrid, StdCtrls, ComCtrls, ExtCtrls, ToolWin, cxGridCustomPopupMenu,
cxGridPopupMenu, ADODB, DBClient, cxDropDownEdit, MovePanel,
cxLookAndFeels, cxLookAndFeelPainters, cxNavigator;
type
TfrmKH_XS_list = class(TForm)
ToolBar1: TToolBar;
TBRafresh: TToolButton;
TBFind: TToolButton;
TBExport: TToolButton;
TBPrint: TToolButton;
TBClose: TToolButton;
Panel1: TPanel;
ADOQueryCmd: TADOQuery;
ADOQueryMain: TADOQuery;
ADOQueryTemp: TADOQuery;
DataSource1: TDataSource;
cxGridPopupMenu1: TcxGridPopupMenu;
Label3: TLabel;
Label4: TLabel;
customerNoName: TEdit;
C_Color: TEdit;
Label1: TLabel;
Label2: TLabel;
BegDate: TDateTimePicker;
EndDate: TDateTimePicker;
CDS_Main: TClientDataSet;
Tv1: TcxGridDBTableView;
cxGrid2Level1: TcxGridLevel;
cxGrid2: TcxGrid;
Label5: TLabel;
conNO: TEdit;
Label6: TLabel;
MJID: TEdit;
Label8: TLabel;
KZ: TEdit;
Label9: TLabel;
MF: TEdit;
Label7: TLabel;
CPType: TComboBox;
MovePanel2: TMovePanel;
Label10: TLabel;
Edit1: TEdit;
v1Column1: TcxGridDBColumn;
v1Column2: TcxGridDBColumn;
v1Column3: TcxGridDBColumn;
v1Column4: TcxGridDBColumn;
v1Column5: TcxGridDBColumn;
v1Column6: TcxGridDBColumn;
v1Column7: TcxGridDBColumn;
v1Column9: TcxGridDBColumn;
v1Column10: TcxGridDBColumn;
cxStyleRepository1: TcxStyleRepository;
cxStyle1: TcxStyle;
cxStyle2: TcxStyle;
cxStyle_gridRow: TcxStyle;
cxStyle_gridFoot: TcxStyle;
cxStyle_gridHead: TcxStyle;
cxStyle_gridGroupBox: TcxStyle;
cxStyle_yellow: TcxStyle;
cxStyle_Red: TcxStyle;
cxStyle_fontBlack: TcxStyle;
cxStyle_fontclFuchsia: TcxStyle;
cxStyle_fontclPurple: TcxStyle;
cxStyle_fontclGreen: TcxStyle;
cxStyle_fontclBlue: TcxStyle;
cxStyle_fontclTeal: TcxStyle;
cxStyle_fontclOlive: TcxStyle;
v1Column11: TcxGridDBColumn;
ywy: TEdit;
Label11: TLabel;
GroupBox1: TGroupBox;
cxGrid1: TcxGrid;
TV2: TcxGridDBTableView;
V2Column2: TcxGridDBColumn;
V2Column3: TcxGridDBColumn;
V2Column4: TcxGridDBColumn;
V2Column5: TcxGridDBColumn;
V2Column6: TcxGridDBColumn;
cxGridLevel1: TcxGridLevel;
DS_sub: TDataSource;
ADO_Sub: TADOQuery;
V2Column7: TcxGridDBColumn;
V2Column8: TcxGridDBColumn;
procedure FormDestroy(Sender: TObject);
procedure FormClose(Sender: TObject; var Action: TCloseAction);
procedure FormCreate(Sender: TObject);
procedure TBRafreshClick(Sender: TObject);
procedure ConNoMChange(Sender: TObject);
procedure TBCloseClick(Sender: TObject);
procedure FormShow(Sender: TObject);
procedure TBExportClick(Sender: TObject);
procedure TBFindClick(Sender: TObject);
procedure customerNoNameChange(Sender: TObject);
procedure Tv1CellClick(Sender: TcxCustomGridTableView;
ACellViewInfo: TcxGridTableDataCellViewInfo; AButton: TMouseButton;
AShift: TShiftState; var AHandled: Boolean);
private
procedure InitGrid();
procedure Initsub();
{ Private declarations }
public
{ Public declarations }
end;
var
frmKH_XS_list: TfrmKH_XS_list;
implementation
uses
U_DataLink,U_Fun;
{$R *.dfm}
procedure TfrmKH_XS_list.Initsub();
begin
ADO_Sub.Close;
IF CDS_Main.IsEmpty then exit;
with ADO_Sub do
begin
close;
sql.Clear;
{ sql.Add('select * from YF_money_CR ');
sql.Add('where CRTime>='''+FormatDateTime('yyyy-MM-dd',BegDate.DateTime)+''' ');
sql.Add('and CRTime<'''+FormatDateTime('yyyy-MM-dd',enddate.DateTime+1)+''' ');
sql.Add('and factoryName='+quotedstr(trim(CDS_Main.fieldbyName('factoryName').AsString)));
// sql.Add('and SYRName='''+trim(canshu1)+'''');
sql.Add('and CRType=''Ӧ<>տ<EFBFBD><D5BF>Ǽ<EFBFBD>'' ');
sql.Add('and YFName=''<27><><EFBFBD>۽<EFBFBD><DBBD><EFBFBD>'' ');
sql.Add('order by CRTime desc '); }
sql.Add('select A.CRTime,A.C_CodeName,A.C_Color,B.PRTPrice, C.CustomerNoName,SUM(Qty) as Qty,SUM(Qty*B.PRTPrice) as money,RollNum=SUM(case when Qty<50 then 0 else 1 end) ');
sql.Add(',ywy=(select Top 1 defstr5 from KH_Zdy_Attachment X where X.zdyName=C.CustomerNoName and Type=''KHName'') ');
sql.Add(' from CK_BanCP_CR A ');
sql.Add(' inner join JYOrder_Sub B on B.MainId=A.MainId and B.SubId=A.SubId ');
sql.Add(' inner join JYOrder_Main C on C.MainId=A.MainId ');
sql.Add(' where A.CRTime>='''+FormatDateTime('yyyy-MM-dd',BegDate.DateTime)+''' ');
sql.Add(' and A.CRTime<'''+FormatDateTime('yyyy-MM-dd',enddate.DateTime+1)+''' ');
sql.Add(' and C.CustomerNoName='+quotedstr(trim(CDS_Main.fieldbyName('CustomerNoName').AsString)));
sql.Add(' and A.CRType=''<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>'' ');
sql.Add(' group by A.CRTime,A.C_CodeName,A.C_Color,B.PRTPrice,C.CustomerNoName ');
sql.Add(' order by A.CRTime desc ');
// showmessage(sql.text);
open;
end;
end;
procedure TfrmKH_XS_list.FormDestroy(Sender: TObject);
begin
frmKH_XS_list:=nil;
end;
procedure TfrmKH_XS_list.FormClose(Sender: TObject;
var Action: TCloseAction);
begin
Action:=caFree;
end;
procedure TfrmKH_XS_list.FormCreate(Sender: TObject);
begin
//cxGrid1.Align:=alClient;
// BegDate.DateTime:=SGetServerDateTime(ADOQueryTemp);
EndDate.DateTime:=SGetServerDateTime(ADOQueryTemp);
begdate.DateTime:=strtodateTime(formatdateTime('yyyy-MM',EndDate.DateTime)+'-01');
end;
procedure TfrmKH_XS_list.InitGrid();
begin
try
ADOQueryMain.DisableControls;
with ADOQueryMain do
begin
Close;
Filtered:=False;
sql.Clear;
sql.Add(' exec P_Get_KH_XS ');
sql.Add(' @begdate='''+formatdatetime('yyyy-MM-dd',begdate.DateTime)+''' ');
sql.Add(',@enddate='''+formatdatetime('yyyy-MM-dd',enddate.DateTime+1)+''' ');
{ sql.Add('select C.CustomerNoName,SUM(Qty) as Qty,SUM(Qty*B.PRTPrice) as money,RollNum=SUM(case when Qty<50 then 0 else 1 end) ');
sql.Add(',ywy=(select Top 1 defstr5 from KH_Zdy_Attachment X where X.zdyName=C.CustomerNoName and Type=''KHName'') ');
sql.Add(' from CK_BanCP_CR A ');
sql.Add(' inner join JYOrder_Sub B on B.MainId=A.MainId and B.SubId=A.SubId ');
sql.Add(' inner join JYOrder_Main C on C.MainId=A.MainId ');
sql.Add(' where A.CRTime>='''+FormatDateTime('yyyy-MM-dd',BegDate.DateTime)+''' ');
sql.Add(' and A.CRTime<'''+FormatDateTime('yyyy-MM-dd',enddate.DateTime+1)+''' ');
sql.Add(' and A.CRType=''<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>'' ');
sql.Add(' group by C.CustomerNoName '); }
Open;
end;
SCreateCDS20(ADOQueryMain,CDS_Main);
SInitCDSData20(ADOQueryMain,CDS_Main);
finally
ADOQueryMain.EnableControls;
TBFind.Click;
Initsub();
end;
end;
procedure TfrmKH_XS_list.TBRafreshClick(Sender: TObject);
begin
//BegDate.SetFocus;
MovePanel2.Visible:=True;
MovePanel2.Refresh;
InitGrid();
MovePanel2.Visible:=False;
end;
procedure TfrmKH_XS_list.ConNoMChange(Sender: TObject);
begin
if ADOQueryMain.Active then
begin
SDofilter(ADOQueryMain,SGetFilters(Panel1,1,2));
end;
end;
procedure TfrmKH_XS_list.TBCloseClick(Sender: TObject);
begin
WriteCxGrid(self.Caption+tv1.Name,Tv1,'<27><>Ʒ<EFBFBD>ֿ<EFBFBD>');
Close;
end;
procedure TfrmKH_XS_list.FormShow(Sender: TObject);
begin
ReadCxGrid(self.Caption+tv1.Name,Tv1,'<27><>Ʒ<EFBFBD>ֿ<EFBFBD>');
//InitGrid();
end;
procedure TfrmKH_XS_list.TBExportClick(Sender: TObject);
begin
if ADOQueryMain.IsEmpty then exit;
TcxGridToExcel(self.Caption,cxGrid2);
end;
procedure TfrmKH_XS_list.TBFindClick(Sender: TObject);
begin
if ADOQueryMain.Active then
begin
SDofilter(ADOQueryMain,SGetFilters(Panel1,1,2));
SCreateCDS20(ADOQueryMain,CDS_Main);
SInitCDSData20(ADOQueryMain,CDS_Main);
end;
end;
procedure TfrmKH_XS_list.customerNoNameChange(Sender: TObject);
begin
TBFind.Click;
end;
procedure TfrmKH_XS_list.Tv1CellClick(Sender: TcxCustomGridTableView;
ACellViewInfo: TcxGridTableDataCellViewInfo; AButton: TMouseButton;
AShift: TShiftState; var AHandled: Boolean);
begin
Initsub();
end;
end.