355 lines
9.5 KiB
ObjectPascal
355 lines
9.5 KiB
ObjectPascal
unit U_CKProductBCPKCList;
|
||
|
||
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, Menus, cxCheckBox, Clipbrd, cxPC, Math;
|
||
|
||
type
|
||
TfrmCKProductBCPKCListPB = class(TForm)
|
||
ToolBar1: TToolBar;
|
||
TBRafresh: TToolButton;
|
||
TBExport: TToolButton;
|
||
TBClose: TToolButton;
|
||
ADOQueryCmd: TADOQuery;
|
||
ADOQueryMain: TADOQuery;
|
||
ADOQueryTemp: TADOQuery;
|
||
DataSource1: TDataSource;
|
||
cxGridPopupMenu1: TcxGridPopupMenu;
|
||
CDS_Main: TClientDataSet;
|
||
MovePanel2: TMovePanel;
|
||
PopupMenu1: TPopupMenu;
|
||
N1: TMenuItem;
|
||
N2: TMenuItem;
|
||
ToolButton1: TToolButton;
|
||
Panel1: TPanel;
|
||
Label3: TLabel;
|
||
Label4: TLabel;
|
||
Label5: TLabel;
|
||
Label6: TLabel;
|
||
Label12: TLabel;
|
||
Label14: TLabel;
|
||
Label9: TLabel;
|
||
Label13: TLabel;
|
||
C_CodeName: TEdit;
|
||
C_Color: TEdit;
|
||
ConNo: TEdit;
|
||
MJID: TEdit;
|
||
C_Code: TEdit;
|
||
KHName: TEdit;
|
||
CarNo: TEdit;
|
||
APBatchNo: TEdit;
|
||
Panel2: TPanel;
|
||
Panel3: TPanel;
|
||
cxTabControl1: TcxTabControl;
|
||
Panel6: TPanel;
|
||
BTLP: TButton;
|
||
BTNP: TButton;
|
||
TCBNOR: TComboBox;
|
||
Label1: TLabel;
|
||
LBCPAP: TLabel;
|
||
tbOK: TToolButton;
|
||
cxGrid2: TcxGrid;
|
||
Tv1: TcxGridDBTableView;
|
||
v1Sel: TcxGridDBColumn;
|
||
v1Column2: TcxGridDBColumn;
|
||
v1Column8: TcxGridDBColumn;
|
||
v1Column9: TcxGridDBColumn;
|
||
v1Column1: TcxGridDBColumn;
|
||
v1Column3: TcxGridDBColumn;
|
||
v1Column4: TcxGridDBColumn;
|
||
v2Column1: TcxGridDBColumn;
|
||
v2Column3: TcxGridDBColumn;
|
||
v1Column12: TcxGridDBColumn;
|
||
cxgrdPS: TcxGridDBColumn;
|
||
v1Column10: TcxGridDBColumn;
|
||
v1Column6: TcxGridDBColumn;
|
||
v1Column5: TcxGridDBColumn;
|
||
cxgrdMJGW: TcxGridDBColumn;
|
||
cxgrdMJNW: TcxGridDBColumn;
|
||
cxgrdMJTare: TcxGridDBColumn;
|
||
cxgrdMJLen: TcxGridDBColumn;
|
||
v1Column7: TcxGridDBColumn;
|
||
cxGrid2Level1: TcxGridLevel;
|
||
v1Column11: TcxGridDBColumn;
|
||
Label15: TLabel;
|
||
MJDingChang: TComboBox;
|
||
procedure FormDestroy(Sender: TObject);
|
||
procedure FormClose(Sender: TObject; var Action: TCloseAction);
|
||
procedure TBRafreshClick(Sender: TObject);
|
||
procedure ConNoMChange(Sender: TObject);
|
||
procedure TBCloseClick(Sender: TObject);
|
||
procedure FormShow(Sender: TObject);
|
||
procedure TBExportClick(Sender: TObject);
|
||
procedure N1Click(Sender: TObject);
|
||
procedure N2Click(Sender: TObject);
|
||
procedure ToolButton1Click(Sender: TObject);
|
||
procedure BTLPClick(Sender: TObject);
|
||
procedure BTNPClick(Sender: TObject);
|
||
procedure Tv1DblClick(Sender: TObject);
|
||
procedure cxTabControl1Change(Sender: TObject);
|
||
procedure TCBNORChange(Sender: TObject);
|
||
procedure tbOKClick(Sender: TObject);
|
||
procedure ConNoChange(Sender: TObject);
|
||
private
|
||
FLeft, FTop: Integer;
|
||
CurrentPage, RecordsNumber: Integer;
|
||
procedure InitGrid();
|
||
procedure SetStatus();
|
||
{ Private declarations }
|
||
public
|
||
{ Public declarations }
|
||
FPRTCode: string;
|
||
canshu1: string;
|
||
end;
|
||
|
||
//var
|
||
// frmCKProductBCPKCListPB: TfrmCKProductBCPKCListPB;
|
||
|
||
implementation
|
||
|
||
uses
|
||
U_DataLink, U_Fun, U_SysLogHelp;
|
||
|
||
{$R *.dfm}
|
||
procedure TfrmCKProductBCPKCListPB.SetStatus();
|
||
var
|
||
i: Integer;
|
||
begin
|
||
|
||
Panel6.Visible := False;
|
||
case cxTabControl1.TabIndex of
|
||
0:
|
||
begin
|
||
|
||
ClearOrHideControls(Panel1, '0', True, True);
|
||
ClearOrHideControls(Panel1, '1', True, False);
|
||
|
||
for i := 0 to tv1.ColumnCount - 1 do
|
||
begin
|
||
tv1.Columns[i].Visible := false;
|
||
end;
|
||
IsVisibleTV(Panel1, TV1, '0', True);
|
||
cxgrdPS.Visible := True;
|
||
cxgrdMJGW.Visible := True;
|
||
cxgrdMJNW.Visible := True;
|
||
cxgrdMJTare.Visible := True;
|
||
cxgrdMJLen.Visible := True;
|
||
end;
|
||
|
||
1:
|
||
begin
|
||
for i := 0 to tv1.ColumnCount - 1 do
|
||
begin
|
||
tv1.Columns[i].Visible := True;
|
||
end;
|
||
cxgrdPS.Visible := false;
|
||
|
||
ClearOrHideControls(Panel1, '0', False, True);
|
||
ClearOrHideControls(Panel1, '1', False, True);
|
||
Panel6.Visible := True;
|
||
end;
|
||
end;
|
||
end;
|
||
|
||
procedure TfrmCKProductBCPKCListPB.FormDestroy(Sender: TObject);
|
||
begin
|
||
// frmCKProductBCPKCListPB := nil;
|
||
end;
|
||
|
||
procedure TfrmCKProductBCPKCListPB.FormClose(Sender: TObject; var Action: TCloseAction);
|
||
begin
|
||
Action := caFree;
|
||
end;
|
||
|
||
procedure TfrmCKProductBCPKCListPB.InitGrid();
|
||
var
|
||
fwhere, Pwhere: string;
|
||
begin
|
||
Pwhere := SGetFilters(Panel1, 1, 2);
|
||
//ShowMessage(Pwhere);
|
||
if trim(Pwhere) <> '' then
|
||
fwhere := fwhere + ' where ' + trim(Pwhere);
|
||
try
|
||
ADOQueryMain.DisableControls;
|
||
with ADOQueryMain do
|
||
begin
|
||
Filtered := False;
|
||
Close;
|
||
sql.Clear;
|
||
|
||
case cxTabControl1.TabIndex of
|
||
0: /////////////////////////<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>//////////////////////////////
|
||
begin
|
||
SQL.Add('select AA.*,BB.*,CC.* from ( ');
|
||
sql.add(' select A.MainId,A.SubId,A.CKOrdNo,A.CRType,A.C_Code,A.C_CodeName,A.C_Color,A.C_Spec,A.MF,A.KZ,A.MJDingChang');
|
||
sql.add(',COUNT(A.MJID) PS,SUM(A.MJGW) MJGW,SUM(A.MJNW) MJNW,SUM(A.MJTare) MJTare,SUM(A.MJLen) MJLen');
|
||
sql.add(' from GreyCloth_CR A');
|
||
Sql.add(' inner join GreyCloth_KC B on A.MJID=B.MJID where B.KCValid=''Y'' and A.CRFlag=''<27><><EFBFBD><EFBFBD>'' ');
|
||
if canshu1='ɨ<><C9A8>' then
|
||
SQL.Add(' and '+Trim(FPRTCode));
|
||
SQL.Add(' group by A.MainId,A.SubId,A.CKOrdNo,A.CRType,A.C_Code,A.C_CodeName,A.C_Color,A.C_Spec,A.MF,A.KZ,A.MJDingChang ');
|
||
SQL.Add(' ) AA left join Cloth_Main BB on AA.Mainid=BB.MainId');
|
||
SQL.Add(' left join Cloth_Sub CC on AA.SubId=CC.SubId ');
|
||
sql.Add(fwhere);
|
||
end;
|
||
1: /////////////////////////<2F><>ϸ//////////////////////////////
|
||
begin
|
||
sql.Add('exec P_Page_GreyClothKC ');
|
||
sql.Add('@pageIndex=' + inttostr(CurrentPage));
|
||
sql.Add(',@pageSize=' + inttostr(RecordsNumber));
|
||
sql.Add(',@criteria= ' + quotedstr(fwhere));
|
||
end;
|
||
end;
|
||
//showmessage(sql.Text);
|
||
Open;
|
||
end;
|
||
SCreateCDS20(ADOQueryMain, CDS_Main);
|
||
SInitCDSData20(ADOQueryMain, CDS_Main);
|
||
if cxTabControl1.TabIndex = 1 then
|
||
LBCPAP.Caption := inttostr(CurrentPage) + '/' + inttostr(ceil(CDS_Main.FieldByName('TotalCount').AsInteger / RecordsNumber));
|
||
|
||
finally
|
||
ADOQueryMain.EnableControls;
|
||
end;
|
||
end;
|
||
|
||
procedure TfrmCKProductBCPKCListPB.TBRafreshClick(Sender: TObject);
|
||
begin
|
||
ConNo.SetFocus;
|
||
ToolBar1.SetFocus;
|
||
MovePanel2.Visible := True;
|
||
MovePanel2.Refresh;
|
||
InitGrid();
|
||
MovePanel2.Visible := False;
|
||
end;
|
||
|
||
procedure TfrmCKProductBCPKCListPB.ConNoMChange(Sender: TObject);
|
||
begin
|
||
if ADOQueryMain.Active then
|
||
begin
|
||
SDofilter(ADOQueryMain, SGetFilters(Panel1, 1, 2));
|
||
end;
|
||
end;
|
||
|
||
procedure TfrmCKProductBCPKCListPB.TBCloseClick(Sender: TObject);
|
||
begin
|
||
WriteCxGrid(self.Caption, Tv1, '<27><><EFBFBD><EFBFBD><EFBFBD>ֿ<EFBFBD>');
|
||
Close;
|
||
end;
|
||
|
||
procedure TfrmCKProductBCPKCListPB.FormShow(Sender: TObject);
|
||
var
|
||
fsj: string;
|
||
begin
|
||
CurrentPage := 1;
|
||
RecordsNumber := 500;
|
||
|
||
fsj := 'select distinct Code=Null,Name=CRType from GreyCloth_CR order by CRType ';
|
||
// SInitComBoxBySql(ADOQueryTemp, CRType, False, fsj);
|
||
ReadCxGrid(self.Caption, Tv1, '<27><><EFBFBD><EFBFBD><EFBFBD>ֿ<EFBFBD>');
|
||
SetStatus();
|
||
InitGrid();
|
||
end;
|
||
|
||
procedure TfrmCKProductBCPKCListPB.TBExportClick(Sender: TObject);
|
||
begin
|
||
if ADOQueryMain.IsEmpty then
|
||
exit;
|
||
TcxGridToExcel('<27><><EFBFBD><EFBFBD><EFBFBD>б<EFBFBD>', cxGrid2);
|
||
end;
|
||
|
||
procedure TfrmCKProductBCPKCListPB.N1Click(Sender: TObject);
|
||
begin
|
||
SelOKNo(CDS_Main, True);
|
||
end;
|
||
|
||
procedure TfrmCKProductBCPKCListPB.N2Click(Sender: TObject);
|
||
begin
|
||
SelOKNo(CDS_Main, False);
|
||
end;
|
||
|
||
procedure TfrmCKProductBCPKCListPB.ToolButton1Click(Sender: TObject);
|
||
begin
|
||
frmSysLogHelp := TfrmSysLogHelp.create(self);
|
||
with frmSysLogHelp do
|
||
begin
|
||
fModel := self.caption;
|
||
// facction:='<27><><EFBFBD><EFBFBD>ָʾ<D6B8><CABE>ɾ<EFBFBD><C9BE>';
|
||
showmodal;
|
||
free;
|
||
end;
|
||
end;
|
||
|
||
procedure TfrmCKProductBCPKCListPB.BTLPClick(Sender: TObject);
|
||
begin
|
||
if CurrentPage > 1 then
|
||
CurrentPage := CurrentPage - 1;
|
||
InitGrid();
|
||
end;
|
||
|
||
procedure TfrmCKProductBCPKCListPB.BTNPClick(Sender: TObject);
|
||
begin
|
||
if CurrentPage < CDS_Main.FieldByName('TotalCount').AsInteger / RecordsNumber then
|
||
CurrentPage := CurrentPage + 1;
|
||
InitGrid();
|
||
end;
|
||
|
||
procedure TfrmCKProductBCPKCListPB.Tv1DblClick(Sender: TObject);
|
||
var
|
||
Tabint: integer;
|
||
begin
|
||
Tabint := cxTabControl1.TabIndex;
|
||
case Tabint of
|
||
0:
|
||
begin
|
||
AssignmentControls(Panel1, CDS_Main, '0');
|
||
cxTabControl1.TabIndex := 1;
|
||
end;
|
||
end;
|
||
end;
|
||
|
||
procedure TfrmCKProductBCPKCListPB.cxTabControl1Change(Sender: TObject);
|
||
begin
|
||
|
||
SetStatus();
|
||
InitGrid();
|
||
end;
|
||
|
||
procedure TfrmCKProductBCPKCListPB.TCBNORChange(Sender: TObject);
|
||
begin
|
||
RecordsNumber := StrToInt(TCBNOR.Text);
|
||
CurrentPage := 1;
|
||
InitGrid();
|
||
end;
|
||
|
||
procedure TfrmCKProductBCPKCListPB.tbOKClick(Sender: TObject);
|
||
begin
|
||
if CDS_Main.IsEmpty then
|
||
exit;
|
||
|
||
if cds_main.FieldByName('ssel').AsBoolean=False then
|
||
begin
|
||
Application.MessageBox('<27><><EFBFBD><EFBFBD>ѡ<EFBFBD><D1A1><EFBFBD><EFBFBD><EFBFBD>ݣ<EFBFBD>','<27><>ʾ',0);
|
||
Exit;
|
||
end;
|
||
ModalResult := 1;
|
||
end;
|
||
|
||
procedure TfrmCKProductBCPKCListPB.ConNoChange(Sender: TObject);
|
||
begin
|
||
if ADOQueryMain.Active = False then
|
||
Exit;
|
||
SDofilter(ADOQueryMain, SGetFilters(Panel1, 1, 2));
|
||
SCreateCDS20(ADOQueryMain, CDS_Main);
|
||
SInitCDSData20(ADOQueryMain, CDS_Main);
|
||
end;
|
||
|
||
end.
|