366 lines
10 KiB
ObjectPascal
366 lines
10 KiB
ObjectPascal
|
|
unit U_TatKnitterQuery;
|
|||
|
|
|
|||
|
|
interface
|
|||
|
|
|
|||
|
|
uses
|
|||
|
|
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
|
|||
|
|
Dialogs, StdCtrls, ExtCtrls, ComCtrls, ToolWin, cxStyles, cxCustomData,
|
|||
|
|
cxGraphics, cxFilter, cxData, cxDataStorage, cxEdit, DB, cxDBData, ADODB,
|
|||
|
|
cxGridLevel, cxClasses, cxControls, cxGridCustomView, cxGridCustomTableView,
|
|||
|
|
cxGridTableView, cxGridDBTableView, cxGrid, DBClient, cxCheckBox, cxCalendar,
|
|||
|
|
cxPC, Math, U_BaseList, MovePanel, cxLookAndFeels, cxLookAndFeelPainters,
|
|||
|
|
cxNavigator, dxBarBuiltInMenu, dxSkinsCore, dxSkinsDefaultPainters,
|
|||
|
|
dxDateRanges, System.StrUtils, dxScrollbarAnnotations, dxSkinWXI;
|
|||
|
|
|
|||
|
|
type
|
|||
|
|
TfrmTatKnitterQuery = class(TfrmBaseList)
|
|||
|
|
ToolBar1: TToolBar;
|
|||
|
|
TBRafresh: TToolButton;
|
|||
|
|
TBExpSum: TToolButton;
|
|||
|
|
TBExpDet: TToolButton;
|
|||
|
|
TBSaveFmt: TToolButton;
|
|||
|
|
TBClose: TToolButton;
|
|||
|
|
Panel1: TPanel;
|
|||
|
|
Label1: TLabel;
|
|||
|
|
knitter: TEdit;
|
|||
|
|
Label2: TLabel;
|
|||
|
|
C_Name: TEdit;
|
|||
|
|
IsJYTime: TCheckBox;
|
|||
|
|
BegDate: TDateTimePicker;
|
|||
|
|
Label4: TLabel;
|
|||
|
|
EndDate: TDateTimePicker;
|
|||
|
|
cxPageControl1: TcxPageControl;
|
|||
|
|
TabSum: TcxTabSheet;
|
|||
|
|
cxGridS: TcxGrid;
|
|||
|
|
TvS: TcxGridDBTableView;
|
|||
|
|
TvSknitter: TcxGridDBColumn;
|
|||
|
|
TvSC_Name: TcxGridDBColumn;
|
|||
|
|
TvSSumQty: TcxGridDBColumn;
|
|||
|
|
TvSRollCount: TcxGridDBColumn;
|
|||
|
|
cxGridSLevel1: TcxGridLevel;
|
|||
|
|
PanelS: TPanel;
|
|||
|
|
LabelS1: TLabel;
|
|||
|
|
TCBNORS: TComboBox;
|
|||
|
|
BTLPS: TButton;
|
|||
|
|
LBCPAPS: TLabel;
|
|||
|
|
BTNPS: TButton;
|
|||
|
|
TabDet: TcxTabSheet;
|
|||
|
|
cxGridD: TcxGrid;
|
|||
|
|
TvD: TcxGridDBTableView;
|
|||
|
|
TvDCARNO: TcxGridDBColumn;
|
|||
|
|
TvDknitter: TcxGridDBColumn;
|
|||
|
|
TvDC_Name: TcxGridDBColumn;
|
|||
|
|
TvDqty: TcxGridDBColumn;
|
|||
|
|
TvDCIID: TcxGridDBColumn;
|
|||
|
|
cxGridDLevel1: TcxGridLevel;
|
|||
|
|
PanelD: TPanel;
|
|||
|
|
LabelD1: TLabel;
|
|||
|
|
TCBNORD: TComboBox;
|
|||
|
|
BTLPD: TButton;
|
|||
|
|
LBCPAPD: TLabel;
|
|||
|
|
BNTPD: TButton;
|
|||
|
|
MovePanel2: TMovePanel;
|
|||
|
|
ADOQSum: TADOQuery;
|
|||
|
|
ADOQDetail: TADOQuery;
|
|||
|
|
ADOQueryTemp: TADOQuery;
|
|||
|
|
DS_S: TDataSource;
|
|||
|
|
DS_D: TDataSource;
|
|||
|
|
CDS_Sum: TClientDataSet;
|
|||
|
|
CDS_Detail: TClientDataSet;
|
|||
|
|
procedure FormClose(Sender: TObject; var Action: TCloseAction);
|
|||
|
|
procedure FormCreate(Sender: TObject);
|
|||
|
|
procedure FormShow(Sender: TObject);
|
|||
|
|
procedure TBRafreshClick(Sender: TObject);
|
|||
|
|
procedure TBExpSumClick(Sender: TObject);
|
|||
|
|
procedure TBExpDetClick(Sender: TObject);
|
|||
|
|
procedure TBSaveFmtClick(Sender: TObject);
|
|||
|
|
procedure TBCloseClick(Sender: TObject);
|
|||
|
|
procedure knitterKeyPress(Sender: TObject; var Key: Char);
|
|||
|
|
procedure C_NameKeyPress(Sender: TObject; var Key: Char);
|
|||
|
|
procedure BTLPSClick(Sender: TObject);
|
|||
|
|
procedure BTNPSClick(Sender: TObject);
|
|||
|
|
procedure TCBNORSChange(Sender: TObject);
|
|||
|
|
procedure BTLPDClick(Sender: TObject);
|
|||
|
|
procedure BNTPDClick(Sender: TObject);
|
|||
|
|
procedure TCBNORDChange(Sender: TObject);
|
|||
|
|
procedure TvSCustomDrawIndicatorCell(Sender: TcxGridTableView;
|
|||
|
|
ACanvas: TcxCanvas; AViewInfo: TcxCustomGridIndicatorItemViewInfo;
|
|||
|
|
var ADone: Boolean);
|
|||
|
|
procedure TvDCustomDrawIndicatorCell(Sender: TcxGridTableView;
|
|||
|
|
ACanvas: TcxCanvas; AViewInfo: TcxCustomGridIndicatorItemViewInfo;
|
|||
|
|
var ADone: Boolean);
|
|||
|
|
private
|
|||
|
|
FWorkshop: string;
|
|||
|
|
CurrentPageS, RecordsNumberS, CurrentPageD, RecordsNumberD: Integer;
|
|||
|
|
function BuildCriteria(): string;
|
|||
|
|
procedure InitSum();
|
|||
|
|
procedure InitDetail();
|
|||
|
|
{ Private declarations }
|
|||
|
|
public
|
|||
|
|
{ Public declarations }
|
|||
|
|
end;
|
|||
|
|
|
|||
|
|
var
|
|||
|
|
frmTatKnitterQuery: TfrmTatKnitterQuery;
|
|||
|
|
|
|||
|
|
implementation
|
|||
|
|
|
|||
|
|
uses
|
|||
|
|
U_DataLink, U_RTFun;
|
|||
|
|
|
|||
|
|
{$R *.dfm}
|
|||
|
|
|
|||
|
|
procedure TfrmTatKnitterQuery.FormClose(Sender: TObject; var Action: TCloseAction);
|
|||
|
|
begin
|
|||
|
|
inherited;
|
|||
|
|
Action := caFree;
|
|||
|
|
end;
|
|||
|
|
|
|||
|
|
procedure TfrmTatKnitterQuery.FormCreate(Sender: TObject);
|
|||
|
|
begin
|
|||
|
|
inherited;
|
|||
|
|
FWorkshop := Trim(Self.fParameters3);
|
|||
|
|
end;
|
|||
|
|
|
|||
|
|
procedure TfrmTatKnitterQuery.FormShow(Sender: TObject);
|
|||
|
|
begin
|
|||
|
|
inherited;
|
|||
|
|
CurrentPageS := 1;
|
|||
|
|
RecordsNumberS := 500;
|
|||
|
|
CurrentPageD := 1;
|
|||
|
|
RecordsNumberD := 500;
|
|||
|
|
ReadCxGrid(Trim(Self.Caption) + 'TvS', TvS, 'ó<><EFBFBD><D7BC><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>');
|
|||
|
|
ReadCxGrid(Trim(Self.Caption) + 'TvD', TvD, 'ó<><EFBFBD><D7BC><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>');
|
|||
|
|
EndDate.DateTime := SGetServerDate(ADOQueryTemp);
|
|||
|
|
BegDate.DateTime := EndDate.DateTime;
|
|||
|
|
InitSum();
|
|||
|
|
InitDetail();
|
|||
|
|
end;
|
|||
|
|
|
|||
|
|
function TfrmTatKnitterQuery.BuildCriteria(): string;
|
|||
|
|
var
|
|||
|
|
WSql: string;
|
|||
|
|
begin
|
|||
|
|
WSql := SGetFilters(Panel1, 1, 2);
|
|||
|
|
if Trim(WSql) <> '' then
|
|||
|
|
WSql := ' and ' + Trim(WSql);
|
|||
|
|
|
|||
|
|
if Trim(FWorkshop) <> '' then
|
|||
|
|
WSql := WSql + ' and A.Workshop=' + QuotedStr(Trim(FWorkshop));
|
|||
|
|
|
|||
|
|
if IsJYTime.Checked then
|
|||
|
|
begin
|
|||
|
|
WSql := WSql + ' and A.FillTime>' + QuotedStr(FormatDateTime('yyyy-MM-dd', BegDate.DateTime));
|
|||
|
|
WSql := WSql + ' and A.FillTime<=' + QuotedStr(FormatDateTime('yyyy-MM-dd', EndDate.DateTime + 1));
|
|||
|
|
end
|
|||
|
|
else if Trim(WSql) = '' then
|
|||
|
|
WSql := ' and 1=2 ';
|
|||
|
|
|
|||
|
|
Result := WSql;
|
|||
|
|
end;
|
|||
|
|
|
|||
|
|
procedure TfrmTatKnitterQuery.InitSum();
|
|||
|
|
var
|
|||
|
|
WSql: string;
|
|||
|
|
begin
|
|||
|
|
MovePanel2.Left := (Self.Width - MovePanel2.Width) div 2;
|
|||
|
|
MovePanel2.Visible := True;
|
|||
|
|
MovePanel2.Refresh;
|
|||
|
|
WSql := BuildCriteria();
|
|||
|
|
if Trim(WSql) = 'and 1=2' then
|
|||
|
|
Application.MessageBox('<27><>ѡ<EFBFBD><D1A1><EFBFBD><EFBFBD>ʱ<EFBFBD><CAB1><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>', '<27><>ʾ', 0);
|
|||
|
|
|
|||
|
|
try
|
|||
|
|
CDS_Sum.DisableControls;
|
|||
|
|
with ADOQSum do
|
|||
|
|
begin
|
|||
|
|
Close;
|
|||
|
|
SQL.Clear;
|
|||
|
|
SQL.Add('exec P_Tat_Knitter_Sum_Get_Page ');
|
|||
|
|
SQL.Add('@pageIndex=' + IntToStr(CurrentPageS));
|
|||
|
|
SQL.Add(',@pageSize=' + IntToStr(RecordsNumberS));
|
|||
|
|
SQL.Add(',@criteria=' + QuotedStr(WSql));
|
|||
|
|
Open;
|
|||
|
|
end;
|
|||
|
|
SCreateCDS(ADOQSum, CDS_Sum);
|
|||
|
|
SInitCDSData(ADOQSum, CDS_Sum);
|
|||
|
|
LBCPAPS.Caption := IntToStr(CurrentPageS) + '/' + IntToStr(Ceil(ADOQSum.FieldByName('TotalCount').AsInteger / RecordsNumberS));
|
|||
|
|
finally
|
|||
|
|
CDS_Sum.EnableControls;
|
|||
|
|
MovePanel2.Visible := False;
|
|||
|
|
end;
|
|||
|
|
end;
|
|||
|
|
|
|||
|
|
procedure TfrmTatKnitterQuery.InitDetail();
|
|||
|
|
var
|
|||
|
|
WSql: string;
|
|||
|
|
begin
|
|||
|
|
MovePanel2.Left := (Self.Width - MovePanel2.Width) div 2;
|
|||
|
|
MovePanel2.Visible := True;
|
|||
|
|
MovePanel2.Refresh;
|
|||
|
|
WSql := BuildCriteria();
|
|||
|
|
if Trim(WSql) = 'and 1=2' then
|
|||
|
|
Application.MessageBox('<27><>ѡ<EFBFBD><D1A1><EFBFBD><EFBFBD>ʱ<EFBFBD><CAB1><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>', '<27><>ʾ', 0);
|
|||
|
|
|
|||
|
|
try
|
|||
|
|
CDS_Detail.DisableControls;
|
|||
|
|
with ADOQDetail do
|
|||
|
|
begin
|
|||
|
|
Close;
|
|||
|
|
SQL.Clear;
|
|||
|
|
SQL.Add('exec P_Tat_Knitter_Get_Page ');
|
|||
|
|
SQL.Add('@pageIndex=' + IntToStr(CurrentPageD));
|
|||
|
|
SQL.Add(',@pageSize=' + IntToStr(RecordsNumberD));
|
|||
|
|
SQL.Add(',@criteria=' + QuotedStr(WSql));
|
|||
|
|
Open;
|
|||
|
|
end;
|
|||
|
|
SCreateCDS(ADOQDetail, CDS_Detail);
|
|||
|
|
SInitCDSData(ADOQDetail, CDS_Detail);
|
|||
|
|
LBCPAPD.Caption := IntToStr(CurrentPageD) + '/' + IntToStr(Ceil(ADOQDetail.FieldByName('TotalCount').AsInteger / RecordsNumberD));
|
|||
|
|
finally
|
|||
|
|
CDS_Detail.EnableControls;
|
|||
|
|
MovePanel2.Visible := False;
|
|||
|
|
end;
|
|||
|
|
end;
|
|||
|
|
|
|||
|
|
procedure TfrmTatKnitterQuery.TBRafreshClick(Sender: TObject);
|
|||
|
|
begin
|
|||
|
|
CurrentPageS := 1;
|
|||
|
|
CurrentPageD := 1;
|
|||
|
|
InitSum();
|
|||
|
|
InitDetail();
|
|||
|
|
end;
|
|||
|
|
|
|||
|
|
procedure TfrmTatKnitterQuery.TBExpSumClick(Sender: TObject);
|
|||
|
|
begin
|
|||
|
|
if CDS_Sum.IsEmpty then
|
|||
|
|
Exit;
|
|||
|
|
TcxGridToExcel(Trim(Self.Caption) + '-<2D><><EFBFBD><EFBFBD>', cxGridS);
|
|||
|
|
end;
|
|||
|
|
|
|||
|
|
procedure TfrmTatKnitterQuery.TBExpDetClick(Sender: TObject);
|
|||
|
|
begin
|
|||
|
|
if CDS_Detail.IsEmpty then
|
|||
|
|
Exit;
|
|||
|
|
TcxGridToExcel(Trim(Self.Caption) + '-<2D><>ϸ', cxGridD);
|
|||
|
|
end;
|
|||
|
|
|
|||
|
|
procedure TfrmTatKnitterQuery.TBSaveFmtClick(Sender: TObject);
|
|||
|
|
begin
|
|||
|
|
WriteCxGrid(Trim(Self.Caption) + 'TvS', TvS, 'ó<><EFBFBD><D7BC><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>');
|
|||
|
|
WriteCxGrid(Trim(Self.Caption) + 'TvD', TvD, 'ó<><EFBFBD><D7BC><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>');
|
|||
|
|
end;
|
|||
|
|
|
|||
|
|
procedure TfrmTatKnitterQuery.TBCloseClick(Sender: TObject);
|
|||
|
|
begin
|
|||
|
|
Close;
|
|||
|
|
end;
|
|||
|
|
|
|||
|
|
procedure TfrmTatKnitterQuery.knitterKeyPress(Sender: TObject; var Key: Char);
|
|||
|
|
begin
|
|||
|
|
if Key = #13 then
|
|||
|
|
begin
|
|||
|
|
CurrentPageS := 1;
|
|||
|
|
CurrentPageD := 1;
|
|||
|
|
InitSum();
|
|||
|
|
InitDetail();
|
|||
|
|
end;
|
|||
|
|
end;
|
|||
|
|
|
|||
|
|
procedure TfrmTatKnitterQuery.C_NameKeyPress(Sender: TObject; var Key: Char);
|
|||
|
|
begin
|
|||
|
|
if Key = #13 then
|
|||
|
|
begin
|
|||
|
|
CurrentPageS := 1;
|
|||
|
|
CurrentPageD := 1;
|
|||
|
|
InitSum();
|
|||
|
|
InitDetail();
|
|||
|
|
end;
|
|||
|
|
end;
|
|||
|
|
|
|||
|
|
procedure TfrmTatKnitterQuery.BTLPSClick(Sender: TObject);
|
|||
|
|
begin
|
|||
|
|
if CurrentPageS > 1 then
|
|||
|
|
CurrentPageS := CurrentPageS - 1;
|
|||
|
|
InitSum();
|
|||
|
|
end;
|
|||
|
|
|
|||
|
|
procedure TfrmTatKnitterQuery.BTNPSClick(Sender: TObject);
|
|||
|
|
begin
|
|||
|
|
if CurrentPageS < ADOQSum.FieldByName('TotalCount').AsInteger / RecordsNumberS then
|
|||
|
|
CurrentPageS := CurrentPageS + 1;
|
|||
|
|
InitSum();
|
|||
|
|
end;
|
|||
|
|
|
|||
|
|
procedure TfrmTatKnitterQuery.TCBNORSChange(Sender: TObject);
|
|||
|
|
begin
|
|||
|
|
RecordsNumberS := StrToInt(TCBNORS.Text);
|
|||
|
|
CurrentPageS := 1;
|
|||
|
|
InitSum();
|
|||
|
|
end;
|
|||
|
|
|
|||
|
|
procedure TfrmTatKnitterQuery.BTLPDClick(Sender: TObject);
|
|||
|
|
begin
|
|||
|
|
if CurrentPageD > 1 then
|
|||
|
|
CurrentPageD := CurrentPageD - 1;
|
|||
|
|
InitDetail();
|
|||
|
|
end;
|
|||
|
|
|
|||
|
|
procedure TfrmTatKnitterQuery.BNTPDClick(Sender: TObject);
|
|||
|
|
begin
|
|||
|
|
if CurrentPageD < ADOQDetail.FieldByName('TotalCount').AsInteger / RecordsNumberD then
|
|||
|
|
CurrentPageD := CurrentPageD + 1;
|
|||
|
|
InitDetail();
|
|||
|
|
end;
|
|||
|
|
|
|||
|
|
procedure TfrmTatKnitterQuery.TCBNORDChange(Sender: TObject);
|
|||
|
|
begin
|
|||
|
|
RecordsNumberD := StrToInt(TCBNORD.Text);
|
|||
|
|
CurrentPageD := 1;
|
|||
|
|
InitDetail();
|
|||
|
|
end;
|
|||
|
|
|
|||
|
|
procedure TfrmTatKnitterQuery.TvSCustomDrawIndicatorCell(Sender: TcxGridTableView;
|
|||
|
|
ACanvas: TcxCanvas; AViewInfo: TcxCustomGridIndicatorItemViewInfo;
|
|||
|
|
var ADone: Boolean);
|
|||
|
|
var
|
|||
|
|
FValue: string;
|
|||
|
|
FBounds: TRect;
|
|||
|
|
begin
|
|||
|
|
FBounds := AViewInfo.Bounds;
|
|||
|
|
if (AViewInfo is TcxGridIndicatorRowItemViewInfo) then
|
|||
|
|
begin
|
|||
|
|
ACanvas.FillRect(FBounds);
|
|||
|
|
ACanvas.DrawComplexFrame(FBounds, clBlack, clBlack, [bBottom, bLeft, bRight], 1);
|
|||
|
|
FValue := IntToStr(TcxGridIndicatorRowItemViewInfo(AViewInfo).GridRecord.Index + 1);
|
|||
|
|
InflateRect(FBounds, -3, -2);
|
|||
|
|
ACanvas.Font.Color := clBlack;
|
|||
|
|
ACanvas.Brush.Style := bsClear;
|
|||
|
|
ACanvas.DrawText(FValue, FBounds, cxAlignCenter or cxAlignTop);
|
|||
|
|
ADone := True;
|
|||
|
|
end;
|
|||
|
|
end;
|
|||
|
|
|
|||
|
|
procedure TfrmTatKnitterQuery.TvDCustomDrawIndicatorCell(Sender: TcxGridTableView;
|
|||
|
|
ACanvas: TcxCanvas; AViewInfo: TcxCustomGridIndicatorItemViewInfo;
|
|||
|
|
var ADone: Boolean);
|
|||
|
|
var
|
|||
|
|
FValue: string;
|
|||
|
|
FBounds: TRect;
|
|||
|
|
begin
|
|||
|
|
FBounds := AViewInfo.Bounds;
|
|||
|
|
if (AViewInfo is TcxGridIndicatorRowItemViewInfo) then
|
|||
|
|
begin
|
|||
|
|
ACanvas.FillRect(FBounds);
|
|||
|
|
ACanvas.DrawComplexFrame(FBounds, clBlack, clBlack, [bBottom, bLeft, bRight], 1);
|
|||
|
|
FValue := IntToStr(TcxGridIndicatorRowItemViewInfo(AViewInfo).GridRecord.Index + 1);
|
|||
|
|
InflateRect(FBounds, -3, -2);
|
|||
|
|
ACanvas.Font.Color := clBlack;
|
|||
|
|
ACanvas.Brush.Style := bsClear;
|
|||
|
|
ACanvas.DrawText(FValue, FBounds, cxAlignCenter or cxAlignTop);
|
|||
|
|
ADone := True;
|
|||
|
|
end;
|
|||
|
|
end;
|
|||
|
|
|
|||
|
|
end.
|