411 lines
11 KiB
ObjectPascal
411 lines
11 KiB
ObjectPascal
unit U_TatClothCKHZList3;
|
||
|
||
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, cxCheckBox, RM_Common, RM_Class, RM_e_Xls, RM_Dataset,
|
||
RM_System, RM_GridReport, Menus, cxCalendar, MovePanel, Math, Clipbrd,
|
||
cxLookAndFeels, cxLookAndFeelPainters, cxNavigator, cxTextEdit, dxSkinsCore,
|
||
dxSkinsDefaultPainters, dxDateRanges, dxBarBuiltInMenu, U_BaseInput, cxPC,
|
||
System.StrUtils, dxScrollbarAnnotations, U_BaseList, System.ImageList,
|
||
Vcl.ImgList;
|
||
|
||
type
|
||
TfrmTatClothCKHZList3 = class(TfrmBaseInput)
|
||
ToolBar1: TToolBar;
|
||
TBRafresh: TToolButton;
|
||
TBExport: TToolButton;
|
||
TBClose: TToolButton;
|
||
Panel1: TPanel;
|
||
ADOQueryCmd: TADOQuery;
|
||
ADOQueryMain: TADOQuery;
|
||
ADOQueryTemp: TADOQuery;
|
||
DS_1: TDataSource;
|
||
GPM_1: TcxGridPopupMenu;
|
||
Label2: TLabel;
|
||
BegDate: TDateTimePicker;
|
||
EndDate: TDateTimePicker;
|
||
CDS_1: TClientDataSet;
|
||
begtime: TDateTimePicker;
|
||
endTime: TDateTimePicker;
|
||
IsJYTime: TCheckBox;
|
||
ToolButton4: TToolButton;
|
||
PM_1: TPopupMenu;
|
||
PM11: TMenuItem;
|
||
N1: TMenuItem;
|
||
Label1: TLabel;
|
||
C_Width: TEdit;
|
||
N2: TMenuItem;
|
||
N3: TMenuItem;
|
||
cxGrid2: TcxGrid;
|
||
Tv2: TcxGridDBTableView;
|
||
cxGridDBColumn1: TcxGridDBColumn;
|
||
cxGridDBColumn2: TcxGridDBColumn;
|
||
cxGridDBColumn3: TcxGridDBColumn;
|
||
cxGridDBColumn5: TcxGridDBColumn;
|
||
Tv2issp: TcxGridDBColumn;
|
||
cxGridDBColumn6: TcxGridDBColumn;
|
||
cxGridDBColumn7: TcxGridDBColumn;
|
||
cxGridDBColumn8: TcxGridDBColumn;
|
||
cxGridDBColumn9: TcxGridDBColumn;
|
||
cxGridDBColumn10: TcxGridDBColumn;
|
||
cxGridDBColumn11: TcxGridDBColumn;
|
||
cxGridLevel1: TcxGridLevel;
|
||
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 orderNoKeyPress(Sender: TObject; var Key: Char);
|
||
procedure BTNPClick(Sender: TObject);
|
||
procedure BTLPClick(Sender: TObject);
|
||
procedure TCBNORChange(Sender: TObject);
|
||
procedure JYTypeChange(Sender: TObject);
|
||
procedure ToolButton2Click(Sender: TObject);
|
||
procedure cxPageControl1Change(Sender: TObject);
|
||
procedure CDS_1BeforeOpen(DataSet: TDataSet);
|
||
procedure Tv1DataControllerFilterBeforeChange(Sender: TcxDBDataFilterCriteria; ADataSet: TDataSet; const AFilterText: string);
|
||
|
||
procedure Tv1TcxGridDBDataControllerTcxDataSummaryFooterSummaryItems6GetText(Sender: TcxDataSummaryItem; const AValue: Variant; AIsFooter: Boolean; var AText: string);
|
||
procedure ToolButton4Click(Sender: TObject);
|
||
procedure PM11Click(Sender: TObject);
|
||
procedure N1Click(Sender: TObject);
|
||
procedure IsJYTimeClick(Sender: TObject);
|
||
procedure C_NameKeyPress(Sender: TObject; var Key: Char);
|
||
procedure IOTypeChange(Sender: TObject);
|
||
procedure N2Click(Sender: TObject);
|
||
procedure N3Click(Sender: TObject);
|
||
private
|
||
CurrentPage, RecordsNumber: Integer;
|
||
lstCust: TStringList;
|
||
procedure InitGrid();
|
||
procedure SetStatus();
|
||
procedure CopyColumnSummaryToClipboard(AColumn: TcxGridColumn);
|
||
{ Private declarations }
|
||
public
|
||
|
||
fissp: string;
|
||
fC_Name: string;
|
||
fioType: string;
|
||
fEndDateTime,fBegDateTime : TDateTime;
|
||
|
||
{ Public declarations }
|
||
end;
|
||
|
||
var
|
||
frmTatClothCKHZList3: TfrmTatClothCKHZList3;
|
||
|
||
implementation
|
||
|
||
uses
|
||
U_DataLink, U_RTFun, U_LabelPrint;
|
||
|
||
{$R *.dfm}
|
||
|
||
procedure TfrmTatClothCKHZList3.SetStatus();
|
||
begin
|
||
|
||
end;
|
||
|
||
procedure TfrmTatClothCKHZList3.FormClose(Sender: TObject; var Action: TCloseAction);
|
||
begin
|
||
inherited;
|
||
FreeAndNil(lstCust);
|
||
Action := caFree;
|
||
end;
|
||
|
||
procedure TfrmTatClothCKHZList3.FormCreate(Sender: TObject);
|
||
begin
|
||
inherited;
|
||
lstCust := TStringList.Create;
|
||
EndDate.DateTime := SGetServerDateTime(ADOQueryTemp);
|
||
BegDate.DateTime := EndDate.DateTime - 20;
|
||
end;
|
||
|
||
procedure TfrmTatClothCKHZList3.InitGrid();
|
||
var
|
||
WSql: string;
|
||
begin
|
||
|
||
WSql := SGetFilters(Panel1, 1, 2);
|
||
if Trim(WSql) <> '' then
|
||
WSql := ' and ' + WSql;
|
||
if IsJYTime.Checked then
|
||
begin
|
||
WSql := WSql + ' and A.IOTime>=' + quotedstr(FormatDateTime('yyyy-MM-dd', BegDate.DateTime));
|
||
WSql := WSql + ' and A.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 A.C_CODE,A.C_Name,A.C_width,A.C_GramWeight,A.IOType ');
|
||
sql.Add(' ,ioTime=CAST(ioTime AS DATE) ');
|
||
sql.Add(' ,js = count(*),Meter=sum(A.meter),NetWeight = sum(A.NetWeight) ');
|
||
sql.Add(' ,pf = CAST(A.C_Width AS DECIMAL(18,2))/100*sum(A.meter) ');
|
||
SQL.Add(',issp=isnull(A.issp,'''') ');
|
||
sql.Add(' FROM V_Tat_Cloth_IO A ');
|
||
sql.Add(' where A.IONo not LIKE ''RSG%'' and A.IOFlag = ''<27><><EFBFBD><EFBFBD>'' ');
|
||
sql.Add(' and A.C_Name = ' + QuotedStr(Trim(fC_Name)));
|
||
// sql.Add(' and isnull(A.issp,'''') = ' + QuotedStr(Trim(fissp)));
|
||
sql.Add(WSql);
|
||
SQL.Add(' group by A.C_CODE,A.C_width,A.C_GramWeight,A.IOType,A.C_Name,isnull(A.issp,''''),CAST(ioTime AS DATE)');
|
||
SQL.Add(' order by A.C_Name,CAST(A.C_width AS INT),A.C_GramWeight,A.IOType,CAST(ioTime AS DATE)');
|
||
|
||
// showmessage(sql.text);
|
||
Open;
|
||
end;
|
||
SCreateCDS(ADOQueryMain, CDS_1);
|
||
SInitCDSData(ADOQueryMain, CDS_1);
|
||
|
||
finally
|
||
ADOQueryMain.EnableControls;
|
||
TV2.DataController.Filter.Clear;
|
||
end;
|
||
|
||
end;
|
||
|
||
procedure TfrmTatClothCKHZList3.IOTypeChange(Sender: TObject);
|
||
begin
|
||
|
||
InitGrid();
|
||
end;
|
||
|
||
procedure TfrmTatClothCKHZList3.IsJYTimeClick(Sender: TObject);
|
||
begin
|
||
inherited;
|
||
InitGrid();
|
||
end;
|
||
|
||
procedure TfrmTatClothCKHZList3.TBRafreshClick(Sender: TObject);
|
||
begin
|
||
CurrentPage := 1;
|
||
InitGrid();
|
||
end;
|
||
|
||
procedure TfrmTatClothCKHZList3.CDS_1BeforeOpen(DataSet: TDataSet);
|
||
begin
|
||
|
||
lstCust.Clear;
|
||
end;
|
||
|
||
procedure TfrmTatClothCKHZList3.ConNoMChange(Sender: TObject);
|
||
begin
|
||
if ADOQueryMain.Active then
|
||
begin
|
||
SDofilter(ADOQueryMain, SGetFilters(Panel1, 1, 2));
|
||
end;
|
||
end;
|
||
|
||
procedure TfrmTatClothCKHZList3.cxPageControl1Change(Sender: TObject);
|
||
begin
|
||
CurrentPage := 1;
|
||
SetStatus();
|
||
InitGrid();
|
||
end;
|
||
|
||
procedure TfrmTatClothCKHZList3.C_NameKeyPress(Sender: TObject; var Key: Char);
|
||
begin
|
||
inherited;
|
||
if Key = #13 then
|
||
begin
|
||
InitGrid();
|
||
end;
|
||
end;
|
||
|
||
procedure TfrmTatClothCKHZList3.TBCloseClick(Sender: TObject);
|
||
begin
|
||
|
||
Close;
|
||
end;
|
||
|
||
procedure TfrmTatClothCKHZList3.FormShow(Sender: TObject);
|
||
begin
|
||
inherited;
|
||
|
||
ReadCxGrid(trim(self.Caption) + 'Tv2', Tv2, '<27><>Ʒ<EFBFBD><C6B7><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>3');
|
||
CurrentPage := 1;
|
||
RecordsNumber := 500;
|
||
// canshu1 := Trim(Self.fParameters1);
|
||
|
||
EndDate.DateTime := fEndDateTime;
|
||
BegDate.DateTime := fBegDateTime;
|
||
SetStatus();
|
||
|
||
InitGrid();
|
||
|
||
end;
|
||
|
||
procedure TfrmTatClothCKHZList3.TBExportClick(Sender: TObject);
|
||
begin
|
||
if ADOQueryMain.IsEmpty then
|
||
exit;
|
||
with CDS_1 do
|
||
begin
|
||
Filtered := false;
|
||
Filter := ' ssel = 1';
|
||
Filtered := true;
|
||
end;
|
||
TcxGridToExcel(Self.Caption, cxGrid2);
|
||
InitGrid();
|
||
end;
|
||
|
||
procedure TfrmTatClothCKHZList3.orderNoKeyPress(Sender: TObject; var Key: Char);
|
||
begin
|
||
if Key = #13 then
|
||
begin
|
||
CurrentPage := 1;
|
||
InitGrid();
|
||
end;
|
||
end;
|
||
|
||
procedure TfrmTatClothCKHZList3.PM11Click(Sender: TObject);
|
||
begin
|
||
SelOKNo(CDS_1, false);
|
||
end;
|
||
|
||
procedure TfrmTatClothCKHZList3.Tv1DataControllerFilterBeforeChange(Sender: TcxDBDataFilterCriteria; ADataSet: TDataSet; const AFilterText: string);
|
||
begin
|
||
lstCust.Clear;
|
||
end;
|
||
|
||
procedure TfrmTatClothCKHZList3.Tv1TcxGridDBDataControllerTcxDataSummaryFooterSummaryItems6GetText(Sender: TcxDataSummaryItem; const AValue: Variant; AIsFooter: Boolean; var AText: string);
|
||
begin
|
||
if lstCust <> nil then
|
||
AText := IntToStr(lstCust.Count);
|
||
end;
|
||
|
||
procedure TfrmTatClothCKHZList3.BTNPClick(Sender: TObject);
|
||
begin
|
||
if CurrentPage < CDS_1.FieldByName('TotalCount').AsInteger / RecordsNumber then
|
||
CurrentPage := CurrentPage + 1;
|
||
InitGrid();
|
||
end;
|
||
|
||
procedure TfrmTatClothCKHZList3.BTLPClick(Sender: TObject);
|
||
begin
|
||
if CurrentPage > 1 then
|
||
CurrentPage := CurrentPage - 1;
|
||
InitGrid();
|
||
end;
|
||
|
||
procedure TfrmTatClothCKHZList3.TCBNORChange(Sender: TObject);
|
||
begin
|
||
|
||
CurrentPage := 1;
|
||
InitGrid();
|
||
end;
|
||
|
||
procedure TfrmTatClothCKHZList3.JYTypeChange(Sender: TObject);
|
||
begin
|
||
CurrentPage := 1;
|
||
InitGrid();
|
||
end;
|
||
|
||
procedure TfrmTatClothCKHZList3.N1Click(Sender: TObject);
|
||
begin
|
||
|
||
SelOKNo(CDS_1, true);
|
||
end;
|
||
|
||
procedure TfrmTatClothCKHZList3.N2Click(Sender: TObject);
|
||
begin
|
||
Clipboard.SetTextBuf(PChar(Trim(CDS_1.fieldbyname(TV2.Controller.FocusedColumn.DataBinding.FilterFieldName).AsString)));
|
||
end;
|
||
|
||
procedure TfrmTatClothCKHZList3.N3Click(Sender: TObject);
|
||
begin
|
||
CopyColumnSummaryToClipboard(TV2.Controller.FocusedColumn);
|
||
end;
|
||
|
||
procedure TfrmTatClothCKHZList3.CopyColumnSummaryToClipboard(AColumn: TcxGridColumn);
|
||
var
|
||
AView: TcxGridDBTableView;
|
||
SummaryIndex: Integer;
|
||
SummaryText: string;
|
||
begin
|
||
AView := Tv2;
|
||
|
||
// <20><><EFBFBD><EFBFBD>ָ<EFBFBD><D6B8><EFBFBD>еĻ<D0B5><C4BB><EFBFBD><EFBFBD><EFBFBD>
|
||
SummaryIndex := AView.DataController.Summary.FooterSummaryItems.IndexOfItemLink(AColumn);
|
||
if SummaryIndex <> -1 then
|
||
begin
|
||
SummaryText := AView.DataController.Summary.FooterSummaryTexts[SummaryIndex];
|
||
Clipboard.AsText := SummaryText;
|
||
end
|
||
else
|
||
ShowMessage('δ<>ҵ<EFBFBD><D2B5><EFBFBD><EFBFBD>еĻ<D0B5><C4BB><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>');
|
||
end;
|
||
|
||
procedure TfrmTatClothCKHZList3.ToolButton2Click(Sender: TObject);
|
||
var
|
||
WSql: string;
|
||
begin
|
||
if CDS_1.IsEmpty then
|
||
Exit;
|
||
if not CDS_1.Locate('SSel', True, []) then
|
||
begin
|
||
Application.MessageBox('û<><C3BB>ѡ<EFBFBD><D1A1><EFBFBD><EFBFBD><EFBFBD><EFBFBD>!', '<27><>ʾ', 0);
|
||
Exit;
|
||
end;
|
||
WSql := '';
|
||
CDS_1.DisableControls;
|
||
with CDS_1 do
|
||
begin
|
||
First;
|
||
while not Eof do
|
||
begin
|
||
if CDS_1.fieldbyname('SSel').AsBoolean then
|
||
begin
|
||
if WSql <> '' then
|
||
begin
|
||
WSql := WSql + ',' + QuotedStr(Trim(CDS_1.fieldbyname('CIID').AsString));
|
||
end
|
||
else
|
||
begin
|
||
WSql := QuotedStr(Trim(CDS_1.fieldbyname('CIID').AsString));
|
||
end;
|
||
end;
|
||
Next;
|
||
end;
|
||
end;
|
||
CDS_1.Locate('SSel', True, []);
|
||
CDS_1.EnableControls;
|
||
try
|
||
frmLabelPrint := TfrmLabelPrint.Create(Application);
|
||
with frmLabelPrint do
|
||
begin
|
||
FLMType := 'TradeClothStk';
|
||
FFiltration1 := WSql;
|
||
if ShowModal = 1 then
|
||
begin
|
||
|
||
end;
|
||
end;
|
||
finally
|
||
frmLabelPrint.Free;
|
||
end;
|
||
end;
|
||
|
||
procedure TfrmTatClothCKHZList3.ToolButton4Click(Sender: TObject);
|
||
begin
|
||
WriteCxGrid(trim(self.Caption) + 'Tv2', Tv2, '<27><>Ʒ<EFBFBD><C6B7><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>3');
|
||
end;
|
||
|
||
end.
|
||
|