287 lines
8.2 KiB
ObjectPascal
287 lines
8.2 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, cxCheckBox, Menus, cxCalendar, RM_Common, RM_Class,
|
||
RM_GridReport, RM_System, RM_Dataset, BtnEdit, Math, Clipbrd,
|
||
cxLookAndFeels, cxLookAndFeelPainters, cxNavigator;
|
||
|
||
type
|
||
TfrmCKProductBCPKCList = 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;
|
||
ThreeColorBase: TcxStyleRepository;
|
||
SHuangSe: TcxStyle;
|
||
SkyBlue: TcxStyle;
|
||
Default: TcxStyle;
|
||
QHuangSe: TcxStyle;
|
||
Red: TcxStyle;
|
||
FontBlue: TcxStyle;
|
||
TextSHuangSe: TcxStyle;
|
||
FonePurple: TcxStyle;
|
||
FoneClMaroon: TcxStyle;
|
||
FoneRed: TcxStyle;
|
||
RowColor: TcxStyle;
|
||
handBlack: TcxStyle;
|
||
cxBlue: TcxStyle;
|
||
RMDB_Main: TRMDBDataSet;
|
||
ADOQueryPrint: TADOQuery;
|
||
RM2: TRMGridReport;
|
||
CDS_HZ: TClientDataSet;
|
||
CDS_PRT: TClientDataSet;
|
||
RM3: TRMGridReport;
|
||
RMDBHZ: TRMDBDataSet;
|
||
RMDBPRT: TRMDBDataSet;
|
||
Panel6: TPanel;
|
||
LBCPAP: TLabel;
|
||
BTLP: TButton;
|
||
BTNP: TButton;
|
||
TCBNOR: TComboBox;
|
||
Panel1: TPanel;
|
||
Label3: TLabel;
|
||
Label1: TLabel;
|
||
Label2: TLabel;
|
||
Label5: TLabel;
|
||
Label6: TLabel;
|
||
Label7: TLabel;
|
||
Label4: TLabel;
|
||
Label10: TLabel;
|
||
MLCodeName: TEdit;
|
||
BegDate: TDateTimePicker;
|
||
EndDate: TDateTimePicker;
|
||
MLOrderNo: TEdit;
|
||
MJID: TEdit;
|
||
CPType: TComboBox;
|
||
JYColor: TEdit;
|
||
GangNo: TEdit;
|
||
cxGrid2: TcxGrid;
|
||
Tv1: TcxGridDBTableView;
|
||
v1Column4: TcxGridDBColumn;
|
||
v1Column2: TcxGridDBColumn;
|
||
v1Column19: TcxGridDBColumn;
|
||
v1Column1: TcxGridDBColumn;
|
||
v2Column1: TcxGridDBColumn;
|
||
v1Column10: TcxGridDBColumn;
|
||
v2Column3: TcxGridDBColumn;
|
||
v1Column18: TcxGridDBColumn;
|
||
v1Column6: TcxGridDBColumn;
|
||
v1Column5: TcxGridDBColumn;
|
||
v1Column3: TcxGridDBColumn;
|
||
v2Column6: TcxGridDBColumn;
|
||
v1Column16: TcxGridDBColumn;
|
||
v2Column5: TcxGridDBColumn;
|
||
v1Column22: TcxGridDBColumn;
|
||
cxGrid2Level1: TcxGridLevel;
|
||
Label8: TLabel;
|
||
Label9: TLabel;
|
||
KHName: TEdit;
|
||
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 Tv1MouseUp(Sender: TObject; Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
|
||
procedure Tv1CellDblClick(Sender: TcxCustomGridTableView; ACellViewInfo: TcxGridTableDataCellViewInfo; AButton: TMouseButton; AShift: TShiftState; var AHandled: Boolean);
|
||
procedure N1Click(Sender: TObject);
|
||
procedure N2Click(Sender: TObject);
|
||
procedure BTNPClick(Sender: TObject);
|
||
procedure BTLPClick(Sender: TObject);
|
||
procedure TCBNORChange(Sender: TObject);
|
||
procedure MLCodeNameKeyPress(Sender: TObject; var Key: Char);
|
||
procedure CPTypeKeyPress(Sender: TObject; var Key: Char);
|
||
private
|
||
FLeft, FTop: Integer;
|
||
CurrentPage, RecordsNumber: Integer;
|
||
procedure InitGrid();
|
||
|
||
{ Private declarations }
|
||
public
|
||
issel: integer;
|
||
{ Public declarations }
|
||
end;
|
||
|
||
var
|
||
frmCKProductBCPKCList: TfrmCKProductBCPKCList;
|
||
|
||
implementation
|
||
|
||
uses
|
||
U_DataLink, U_Fun, U_ZDYHelp;
|
||
|
||
{$R *.dfm}
|
||
|
||
procedure TfrmCKProductBCPKCList.FormDestroy(Sender: TObject);
|
||
begin
|
||
frmCKProductBCPKCList := nil;
|
||
end;
|
||
|
||
procedure TfrmCKProductBCPKCList.FormClose(Sender: TObject; var Action: TCloseAction);
|
||
begin
|
||
Action := caFree;
|
||
end;
|
||
|
||
procedure TfrmCKProductBCPKCList.FormCreate(Sender: TObject);
|
||
begin
|
||
BegDate.DateTime := SGetServerDateTime(ADOQueryTemp);
|
||
EndDate.DateTime := SGetServerDateTime(ADOQueryTemp)
|
||
end;
|
||
|
||
procedure TfrmCKProductBCPKCList.InitGrid();
|
||
var
|
||
fwhere, Pwhere: string;
|
||
begin
|
||
MovePanel2.Left := (self.Width - MovePanel2.Width) div 2;
|
||
MovePanel2.Visible := True;
|
||
MovePanel2.Refresh;
|
||
Pwhere := SGetFilters(Panel1, 1, 2);
|
||
if trim(Pwhere) <> '' then
|
||
fwhere := fwhere + ' where ' + trim(Pwhere);
|
||
|
||
try
|
||
ADOQueryMain.DisableControls;
|
||
with ADOQueryMain do
|
||
begin
|
||
Filtered := False;
|
||
Close;
|
||
sql.Clear;
|
||
sql.Add(' select top ' + inttostr(RecordsNumber) + ' * from ');
|
||
sql.Add('(select rownumber=cast((row_number() over(order by AA.filltime desc)) as int) ');
|
||
sql.Add(',TotalCount=cast((COUNT(1) OVER()) AS int)');
|
||
sql.Add(',* from (select A.* ');
|
||
sql.Add(' ,B.MLOrderNo,B.KHName,B.MLCodeName,B.OrdDate ');
|
||
sql.Add(' ,C.MLColor,C.MLColorNo,C.MLHX');
|
||
sql.Add(' from CK_MLCP_CR A inner join CK_MLCP_KC D on A.MJID=D.MJID ');
|
||
sql.Add(' inner join ML_OrderMainNew B on A.MainId=B.NewMLID ');
|
||
sql.Add(' inner join ML_OrderSubidNew C on A.SubId=C.NewSubid ');
|
||
sql.Add('where A.CRFlag=''<27><><EFBFBD><EFBFBD>'' and D.KCValid=''Y'' ) AA');
|
||
sql.Add(fwhere + ') temp_row');
|
||
sql.Add(' where rownumber> ' + inttostr((CurrentPage - 1) * RecordsNumber));
|
||
Open;
|
||
end;
|
||
SCreateCDS20(ADOQueryMain, CDS_Main);
|
||
SInitCDSData20(ADOQueryMain, CDS_Main);
|
||
LBCPAP.Caption := inttostr(CurrentPage) + '/' + inttostr(ceil(CDS_Main.FieldByName('TotalCount').AsInteger / RecordsNumber));
|
||
MovePanel2.Visible := false;
|
||
finally
|
||
ADOQueryMain.EnableControls;
|
||
MovePanel2.Visible := false;
|
||
end;
|
||
end;
|
||
|
||
procedure TfrmCKProductBCPKCList.TBRafreshClick(Sender: TObject);
|
||
begin
|
||
CurrentPage := 1;
|
||
InitGrid();
|
||
end;
|
||
|
||
procedure TfrmCKProductBCPKCList.ConNoMChange(Sender: TObject);
|
||
begin
|
||
if ADOQueryMain.Active then
|
||
begin
|
||
SDofilter(ADOQueryMain, SGetFilters(Panel1, 1, 2));
|
||
end;
|
||
end;
|
||
|
||
procedure TfrmCKProductBCPKCList.TBCloseClick(Sender: TObject);
|
||
begin
|
||
WriteCxGrid('<27><>Ʒ<EFBFBD><C6B7><EFBFBD><EFBFBD>YX', Tv1, '<27><>Ʒ<EFBFBD>ֿ<EFBFBD>');
|
||
Close;
|
||
end;
|
||
|
||
procedure TfrmCKProductBCPKCList.FormShow(Sender: TObject);
|
||
begin
|
||
CurrentPage := 1;
|
||
RecordsNumber := 500;
|
||
ReadCxGrid('<27><>Ʒ<EFBFBD><C6B7><EFBFBD><EFBFBD>YX', Tv1, '<27><>Ʒ<EFBFBD>ֿ<EFBFBD>');
|
||
|
||
end;
|
||
|
||
procedure TfrmCKProductBCPKCList.TBExportClick(Sender: TObject);
|
||
begin
|
||
if ADOQueryMain.IsEmpty then
|
||
exit;
|
||
TcxGridToExcel('<27><><EFBFBD><EFBFBD><EFBFBD>б<EFBFBD>', cxGrid2);
|
||
end;
|
||
|
||
procedure TfrmCKProductBCPKCList.Tv1MouseUp(Sender: TObject; Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
|
||
begin
|
||
FLeft := X;
|
||
FTop := Y;
|
||
end;
|
||
|
||
procedure TfrmCKProductBCPKCList.Tv1CellDblClick(Sender: TcxCustomGridTableView; ACellViewInfo: TcxGridTableDataCellViewInfo; AButton: TMouseButton; AShift: TShiftState; var AHandled: Boolean);
|
||
begin
|
||
Clipboard.SetTextBuf(PChar(Trim(CDS_Main.fieldbyname(TV1.Controller.FocusedColumn.DataBinding.FilterFieldName).AsString)));
|
||
end;
|
||
|
||
procedure TfrmCKProductBCPKCList.N1Click(Sender: TObject);
|
||
begin
|
||
SelOKNo(CDS_Main, True);
|
||
end;
|
||
|
||
procedure TfrmCKProductBCPKCList.N2Click(Sender: TObject);
|
||
begin
|
||
SelOKNo(CDS_Main, False);
|
||
end;
|
||
|
||
procedure TfrmCKProductBCPKCList.BTNPClick(Sender: TObject);
|
||
begin
|
||
if CurrentPage < CDS_Main.FieldByName('TotalCount').AsInteger / RecordsNumber then
|
||
CurrentPage := CurrentPage + 1;
|
||
InitGrid();
|
||
end;
|
||
|
||
procedure TfrmCKProductBCPKCList.BTLPClick(Sender: TObject);
|
||
begin
|
||
if CurrentPage > 1 then
|
||
CurrentPage := CurrentPage - 1;
|
||
InitGrid();
|
||
end;
|
||
|
||
procedure TfrmCKProductBCPKCList.TCBNORChange(Sender: TObject);
|
||
begin
|
||
RecordsNumber := StrToInt(TCBNOR.Text);
|
||
CurrentPage := 1;
|
||
InitGrid();
|
||
end;
|
||
|
||
procedure TfrmCKProductBCPKCList.MLCodeNameKeyPress(Sender: TObject; var Key: Char);
|
||
begin
|
||
if Key = #13 then
|
||
begin
|
||
CurrentPage := 1;
|
||
InitGrid();
|
||
end;
|
||
end;
|
||
|
||
procedure TfrmCKProductBCPKCList.CPTypeKeyPress(Sender: TObject; var Key: Char);
|
||
begin
|
||
CurrentPage := 1;
|
||
InitGrid();
|
||
end;
|
||
|
||
end.
|
||
|