D10szGerun/E04梭织坯布仓库/U_TatClothJXCList.pas

183 lines
5.7 KiB
ObjectPascal
Raw Normal View History

2026-11-04 17:22:39 +08:00
unit U_TatClothJXCList;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, cxStyles, cxCustomData, cxGraphics, cxFilter, cxData, cxDataStorage,
cxEdit, DB, cxDBData, cxGridCustomTableView, cxGridTableView,
cxGridCustomView, cxGridDBTableView, cxGridLevel, cxClasses, cxControls,
cxGrid, StdCtrls, ComCtrls, ExtCtrls, ToolWin, ADODB, DBClient,
cxLookAndFeels, cxLookAndFeelPainters, cxNavigator, dxSkinsCore,
dxScrollbarAnnotations, U_BaseList, dxSkinWXI, dxDateRanges;
type
TfrmTatClothJXCList = class(TfrmBaseList)
ToolBar1: TToolBar;
TBRafresh: TToolButton;
TBExport: TToolButton;
ToolButton4: TToolButton;
TBClose: TToolButton;
Panel1: TPanel;
Label2: TLabel;
Label5: TLabel;
Label1: TLabel;
BegDate: TDateTimePicker;
EndDate: TDateTimePicker;
IsJYTime: TCheckBox;
C_Name: TEdit;
ContractBuyName: TEdit;
cxGrid1: TcxGrid;
Tv1: TcxGridDBTableView;
Tv1ContractBuyName: TcxGridDBColumn;
Tv1CName: TcxGridDBColumn;
Tv1InJS: TcxGridDBColumn;
Tv1InMeter: TcxGridDBColumn;
Tv1InYardage: TcxGridDBColumn;
Tv1OutJS: TcxGridDBColumn;
Tv1OutMeter: TcxGridDBColumn;
Tv1OutYardage: TcxGridDBColumn;
Tv1StkJS: TcxGridDBColumn;
Tv1StkMeter: TcxGridDBColumn;
Tv1StkYardage: TcxGridDBColumn;
cxGrid1Level1: TcxGridLevel;
ADOQueryMain: TADOQuery;
ADOQueryTemp: TADOQuery;
DS_1: TDataSource;
CDS_1: TClientDataSet;
procedure FormClose(Sender: TObject; var Action: TCloseAction);
procedure FormCreate(Sender: TObject);
procedure FormShow(Sender: TObject);
procedure TBRafreshClick(Sender: TObject);
procedure TBExportClick(Sender: TObject);
procedure TBCloseClick(Sender: TObject);
procedure ToolButton4Click(Sender: TObject);
procedure IsJYTimeClick(Sender: TObject);
procedure FilterEditKeyPress(Sender: TObject; var Key: Char);
private
procedure InitGrid();
{ Private declarations }
public
{ Public declarations }
end;
implementation
uses
U_DataLink, U_RTFun;
{$R *.dfm}
procedure TfrmTatClothJXCList.FormClose(Sender: TObject; var Action: TCloseAction);
begin
inherited;
Action := caFree;
end;
procedure TfrmTatClothJXCList.FormCreate(Sender: TObject);
begin
inherited;
EndDate.DateTime := SGetServerDateTime(ADOQueryTemp);
BegDate.DateTime := EndDate.DateTime - 20;
end;
procedure TfrmTatClothJXCList.InitGrid();
var
WSql, mDateSql: string;
begin
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ͳ<EFBFBD><CDB3>V_Tat_Cloth_IO(<28><><EFBFBD><EFBFBD>ѯ<EFBFBD><D1AF><EFBFBD><EFBFBD>), <20><>ǰ<EFBFBD><C7B0><EFBFBD><EFBFBD>ͳ<EFBFBD><CDB3>V_Tat_Cloth_Stk(<28><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>)
WSql := SGetFilters(Panel1, 1, 2);
if Trim(WSql) <> '' then
WSql := ' and ' + WSql;
mDateSql := '';
if IsJYTime.Checked then
begin
mDateSql := ' and IOTime>=' + QuotedStr(FormatDateTime('yyyy-MM-dd', BegDate.DateTime));
mDateSql := mDateSql + ' and IOTime<' + QuotedStr(FormatDateTime('yyyy-MM-dd', EndDate.DateTime + 1));
end;
try
ADOQueryMain.DisableControls;
with ADOQueryMain do
begin
Filtered := False;
Close;
sql.Clear;
sql.Add('select isnull(A.ContractBuyName,B.ContractBuyName) as ContractBuyName,');
sql.Add('isnull(A.C_Name,B.C_Name) as C_Name,');
sql.Add('isnull(A.InJS,0) as InJS,isnull(A.InMeter,0) as InMeter,isnull(A.InYardage,0) as InYardage,');
sql.Add('isnull(A.OutJS,0) as OutJS,isnull(A.OutMeter,0) as OutMeter,isnull(A.OutYardage,0) as OutYardage,');
sql.Add('isnull(B.StkJS,0) as StkJS,isnull(B.StkMeter,0) as StkMeter,isnull(B.StkYardage,0) as StkYardage');
sql.Add('from (select ContractBuyName,C_Name,');
sql.Add('sum(case when IOFlag=''<27><><EFBFBD><EFBFBD>'' then 1 else 0 end) as InJS,');
sql.Add('sum(case when IOFlag=''<27><><EFBFBD><EFBFBD>'' then isnull(Meter,0) else 0 end) as InMeter,');
sql.Add('sum(case when IOFlag=''<27><><EFBFBD><EFBFBD>'' then isnull(Yardage,0) else 0 end) as InYardage,');
sql.Add('sum(case when IOFlag=''<27><><EFBFBD><EFBFBD>'' then 1 else 0 end) as OutJS,');
sql.Add('sum(case when IOFlag=''<27><><EFBFBD><EFBFBD>'' then isnull(Meter,0) else 0 end) as OutMeter,');
sql.Add('sum(case when IOFlag=''<27><><EFBFBD><EFBFBD>'' then isnull(Yardage,0) else 0 end) as OutYardage');
sql.Add('from V_Tat_Cloth_IO where 1=1' + mDateSql + WSql);
sql.Add('group by ContractBuyName,C_Name) A');
sql.Add('full outer join');
sql.Add('(select ContractBuyName,C_Name,count(*) as StkJS,');
sql.Add('sum(isnull(StkMeter,0)) as StkMeter,sum(isnull(StkYardage,0)) as StkYardage');
sql.Add('from V_Tat_Cloth_Stk where 1=1' + WSql);
sql.Add('group by ContractBuyName,C_Name) B');
sql.Add('on isnull(A.ContractBuyName,'''')=isnull(B.ContractBuyName,'''')');
sql.Add('and isnull(A.C_Name,'''')=isnull(B.C_Name,'''')');
sql.Add('order by 1,2');
// showmessage(sql.text);
Open;
end;
SCreateCDS(ADOQueryMain, CDS_1);
SInitCDSData(ADOQueryMain, CDS_1);
finally
ADOQueryMain.EnableControls;
Tv1.DataController.Filter.Clear;
end;
end;
procedure TfrmTatClothJXCList.FormShow(Sender: TObject);
begin
inherited;
ReadCxGrid(trim(self.Caption) + 'Tv1', Tv1, '<27><>Ʒ<EFBFBD>ֿ<EFBFBD>');
InitGrid();
end;
procedure TfrmTatClothJXCList.TBRafreshClick(Sender: TObject);
begin
InitGrid();
end;
procedure TfrmTatClothJXCList.TBExportClick(Sender: TObject);
begin
if ADOQueryMain.IsEmpty then
exit;
TcxGridToExcel(Self.Caption, cxGrid1);
end;
procedure TfrmTatClothJXCList.TBCloseClick(Sender: TObject);
begin
Close;
end;
procedure TfrmTatClothJXCList.ToolButton4Click(Sender: TObject);
begin
WriteCxGrid(trim(self.Caption) + 'Tv1', Tv1, '<27><>Ʒ<EFBFBD>ֿ<EFBFBD>');
end;
procedure TfrmTatClothJXCList.IsJYTimeClick(Sender: TObject);
begin
inherited;
InitGrid();
end;
procedure TfrmTatClothJXCList.FilterEditKeyPress(Sender: TObject; var Key: Char);
begin
if Key = #13 then
begin
InitGrid();
end;
end;
end.