247 lines
7.1 KiB
ObjectPascal
247 lines
7.1 KiB
ObjectPascal
unit U_KH_XS_YP_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_YP_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;
|
||
factoryName: 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;
|
||
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 factoryNameChange(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_YP_list: TfrmKH_XS_YP_list;
|
||
|
||
implementation
|
||
uses
|
||
U_DataLink,U_Fun;
|
||
|
||
{$R *.dfm}
|
||
procedure TfrmKH_XS_YP_list.Initsub();
|
||
begin
|
||
ADO_Sub.Close;
|
||
IF CDS_Main.IsEmpty then exit;
|
||
with ADO_Sub do
|
||
begin
|
||
close;
|
||
sql.Clear;
|
||
sql.Add('select A.CRTime,A.P_CodeName,A.P_Color,B.PRTPrice, C.CustomerNoName,SUM(Qty) as Qty,cast(SUM(Qty*B.PRTPrice) as decimal(18,0)) 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 BP_INout 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('factoryName').AsString)));
|
||
sql.Add(' and A.CRType=''<27><>Ʒ<EFBFBD><C6B7><EFBFBD>۳<EFBFBD><DBB3><EFBFBD>'' ');
|
||
sql.Add(' group by A.CRTime,A.P_CodeName,A.P_Color,B.PRTPrice,C.CustomerNoName ');
|
||
sql.Add(' order by A.CRTime desc ');
|
||
|
||
open;
|
||
end;
|
||
end;
|
||
|
||
procedure TfrmKH_XS_YP_list.FormDestroy(Sender: TObject);
|
||
begin
|
||
frmKH_XS_YP_list:=nil;
|
||
end;
|
||
|
||
procedure TfrmKH_XS_YP_list.FormClose(Sender: TObject;
|
||
var Action: TCloseAction);
|
||
begin
|
||
Action:=caFree;
|
||
end;
|
||
|
||
procedure TfrmKH_XS_YP_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_YP_list.InitGrid();
|
||
begin
|
||
try
|
||
ADOQueryMain.DisableControls;
|
||
with ADOQueryMain do
|
||
begin
|
||
Close;
|
||
Filtered:=False;
|
||
sql.Clear;
|
||
sql.Add(' exec P_Get_KH_XS_YP ');
|
||
sql.Add(' @begdate='''+formatdatetime('yyyy-MM-dd',begdate.DateTime)+''' ');
|
||
sql.Add(',@enddate='''+formatdatetime('yyyy-MM-dd',enddate.DateTime+1)+''' ');
|
||
Open;
|
||
end;
|
||
SCreateCDS20(ADOQueryMain,CDS_Main);
|
||
SInitCDSData20(ADOQueryMain,CDS_Main);
|
||
finally
|
||
ADOQueryMain.EnableControls;
|
||
TBFind.Click;
|
||
Initsub();
|
||
end;
|
||
end;
|
||
|
||
procedure TfrmKH_XS_YP_list.TBRafreshClick(Sender: TObject);
|
||
begin
|
||
//BegDate.SetFocus;
|
||
MovePanel2.Visible:=True;
|
||
MovePanel2.Refresh;
|
||
InitGrid();
|
||
MovePanel2.Visible:=False;
|
||
end;
|
||
|
||
procedure TfrmKH_XS_YP_list.ConNoMChange(Sender: TObject);
|
||
begin
|
||
if ADOQueryMain.Active then
|
||
begin
|
||
SDofilter(ADOQueryMain,SGetFilters(Panel1,1,2));
|
||
end;
|
||
end;
|
||
|
||
procedure TfrmKH_XS_YP_list.TBCloseClick(Sender: TObject);
|
||
begin
|
||
WriteCxGrid(self.Caption+tv1.Name,Tv1,'<27><>Ʒ<EFBFBD>ֿ<EFBFBD>');
|
||
Close;
|
||
end;
|
||
|
||
procedure TfrmKH_XS_YP_list.FormShow(Sender: TObject);
|
||
begin
|
||
|
||
ReadCxGrid(self.Caption+tv1.Name,Tv1,'<27><>Ʒ<EFBFBD>ֿ<EFBFBD>');
|
||
|
||
//InitGrid();
|
||
end;
|
||
|
||
procedure TfrmKH_XS_YP_list.TBExportClick(Sender: TObject);
|
||
begin
|
||
if ADOQueryMain.IsEmpty then exit;
|
||
TcxGridToExcel(self.Caption,cxGrid2);
|
||
end;
|
||
|
||
procedure TfrmKH_XS_YP_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_YP_list.factoryNameChange(Sender: TObject);
|
||
begin
|
||
TBFind.Click;
|
||
end;
|
||
|
||
procedure TfrmKH_XS_YP_list.Tv1CellClick(Sender: TcxCustomGridTableView;
|
||
ACellViewInfo: TcxGridTableDataCellViewInfo; AButton: TMouseButton;
|
||
AShift: TShiftState; var AHandled: Boolean);
|
||
begin
|
||
Initsub();
|
||
end;
|
||
|
||
end.
|