319 lines
9.1 KiB
ObjectPascal
319 lines
9.1 KiB
ObjectPascal
![]() |
unit U_CKProductBCPOutListHZFS;
|
|||
|
|
|||
|
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, RM_Common, RM_Class, RM_e_Xls, RM_Dataset, RM_System,
|
|||
|
RM_GridReport, cxCheckBox, Menus, MovePanel, cxCalendar, Math,
|
|||
|
Clipbrd, cxLookAndFeels, cxLookAndFeelPainters, cxNavigator, dxSkinsCore,
|
|||
|
dxSkinsDefaultPainters, dxDateRanges, dxBarBuiltInMenu;
|
|||
|
|
|||
|
type
|
|||
|
TfrmCKProductBCPOutListHZFS = class(TForm)
|
|||
|
ToolBar1: TToolBar;
|
|||
|
TBRafresh: TToolButton;
|
|||
|
TBExport: TToolButton;
|
|||
|
TBClose: TToolButton;
|
|||
|
Panel1: TPanel;
|
|||
|
ADOQueryCmd: TADOQuery;
|
|||
|
ADOQueryMain: TADOQuery;
|
|||
|
ADOQueryTemp: TADOQuery;
|
|||
|
DataSource1: TDataSource;
|
|||
|
Label3: TLabel;
|
|||
|
Label4: TLabel;
|
|||
|
MPRTCodeName: TEdit;
|
|||
|
CDS_Main: TClientDataSet;
|
|||
|
Tv1: TcxGridDBTableView;
|
|||
|
cxGrid2Level1: TcxGridLevel;
|
|||
|
cxGrid2: TcxGrid;
|
|||
|
v2Column1: TcxGridDBColumn;
|
|||
|
v2Column3: TcxGridDBColumn;
|
|||
|
v2Column5: TcxGridDBColumn;
|
|||
|
v2Column6: TcxGridDBColumn;
|
|||
|
v1Column1: TcxGridDBColumn;
|
|||
|
v1Column2: TcxGridDBColumn;
|
|||
|
Label5: TLabel;
|
|||
|
orderNo: TEdit;
|
|||
|
v1Column7: TcxGridDBColumn;
|
|||
|
v1Column8: TcxGridDBColumn;
|
|||
|
v1Column9: TcxGridDBColumn;
|
|||
|
RMXLSExport1: TRMXLSExport;
|
|||
|
v1Column4: TcxGridDBColumn;
|
|||
|
v1Column10: TcxGridDBColumn;
|
|||
|
PopupMenu1: TPopupMenu;
|
|||
|
N1: TMenuItem;
|
|||
|
N2: TMenuItem;
|
|||
|
MovePanel2: TMovePanel;
|
|||
|
DS_JuanPRT: TDataSource;
|
|||
|
cxGridPopupMenu2: TcxGridPopupMenu;
|
|||
|
Label11: TLabel;
|
|||
|
v1Column15: TcxGridDBColumn;
|
|||
|
v1Column19: TcxGridDBColumn;
|
|||
|
conNo: TEdit;
|
|||
|
Label15: TLabel;
|
|||
|
Label17: TLabel;
|
|||
|
apid: TEdit;
|
|||
|
v1Column21: TcxGridDBColumn;
|
|||
|
begtime: TDateTimePicker;
|
|||
|
endTime: TDateTimePicker;
|
|||
|
ADOQueryPrint: TADOQuery;
|
|||
|
RMDB_Main: TRMDBDataSet;
|
|||
|
RM3: TRMGridReport;
|
|||
|
v1Column24: TcxGridDBColumn;
|
|||
|
Label22: TLabel;
|
|||
|
KHName: TEdit;
|
|||
|
Label24: TLabel;
|
|||
|
PRTColor: TEdit;
|
|||
|
ganghao: TEdit;
|
|||
|
v1Column13: TcxGridDBColumn;
|
|||
|
CRType: TComboBox;
|
|||
|
Label6: TLabel;
|
|||
|
Edit1: TEdit;
|
|||
|
Label7: TLabel;
|
|||
|
ywy: TEdit;
|
|||
|
v1Column3: TcxGridDBColumn;
|
|||
|
v1Column5: TcxGridDBColumn;
|
|||
|
v1Column6: TcxGridDBColumn;
|
|||
|
v1Column11: TcxGridDBColumn;
|
|||
|
Label8: TLabel;
|
|||
|
KuanHao: TEdit;
|
|||
|
v1Column12: TcxGridDBColumn;
|
|||
|
ToolButton1: TToolButton;
|
|||
|
ComboBox1: TComboBox;
|
|||
|
CDS_Label: TClientDataSet;
|
|||
|
v1Column14: TcxGridDBColumn;
|
|||
|
v1Column16: TcxGridDBColumn;
|
|||
|
Label9: TLabel;
|
|||
|
Label12: TLabel;
|
|||
|
MPRTCode: TEdit;
|
|||
|
PRTHX: TEdit;
|
|||
|
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 orderNoKeyPress(Sender: TObject; var Key: Char);
|
|||
|
procedure Tv1CellDblClick(Sender: TcxCustomGridTableView; ACellViewInfo: TcxGridTableDataCellViewInfo; AButton: TMouseButton; AShift: TShiftState; var AHandled: Boolean);
|
|||
|
procedure Tv1MouseUp(Sender: TObject; Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
|
|||
|
procedure CPTypeChange(Sender: TObject);
|
|||
|
procedure CRTypeChange(Sender: TObject);
|
|||
|
procedure edtSMNOKeyPress(Sender: TObject; var Key: Char);
|
|||
|
procedure FormDestroy(Sender: TObject);
|
|||
|
procedure ToolButton1Click(Sender: TObject);
|
|||
|
private
|
|||
|
FLeft, FTop: Integer;
|
|||
|
CurrentPage, RecordsNumber: Integer;
|
|||
|
procedure InitGrid();
|
|||
|
{ Private declarations }
|
|||
|
public
|
|||
|
FCKOrdNo: string;
|
|||
|
{ Public declarations }
|
|||
|
end;
|
|||
|
|
|||
|
var
|
|||
|
frmCKProductBCPOutListHZFS: TfrmCKProductBCPOutListHZFS;
|
|||
|
|
|||
|
implementation
|
|||
|
|
|||
|
uses
|
|||
|
U_DataLink, U_RTFun;
|
|||
|
|
|||
|
{$R *.dfm}
|
|||
|
|
|||
|
procedure TfrmCKProductBCPOutListHZFS.FormClose(Sender: TObject; var Action: TCloseAction);
|
|||
|
begin
|
|||
|
Action := caFree;
|
|||
|
end;
|
|||
|
|
|||
|
procedure TfrmCKProductBCPOutListHZFS.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
|
|||
|
Close;
|
|||
|
sql.Clear;
|
|||
|
sql.Add(' select AAA.* from ( ');
|
|||
|
sql.Add(' select AA.* ');
|
|||
|
sql.Add(' ,B.orderNo,B.MPRTCode,B.MPRTCodeName,B.MPRTMF,B.MPRTKZ,B.conNo,B.KHconNo,B.lidan,B.ywy ');
|
|||
|
sql.Add(' ,C.PRTColor,C.PRTEColor,C.PRTHX');
|
|||
|
sql.Add(' from ( ');
|
|||
|
sql.Add(' select count(A.MJID) PS,SUM(A.NETKGQty) NETKGQty,SUM(A.KGQty) KGQty, SUM(A.Qty) Qty, SUM(A.MJYLen) MJYLen,A.CKOrdNo,A.MainId,A.SubId,A.QtyUnit,A.APID ,A.ganghao,A.kuanhao ');
|
|||
|
sql.Add(' ,A.CDDanwei,convert(varchar(10),A.CRTime,120) CRTime,A.CRType');
|
|||
|
sql.Add(' from CK_BanCP_CR A ');
|
|||
|
sql.Add(' where A.CRFlag=''<27><><EFBFBD><EFBFBD>'' ');
|
|||
|
sql.Add(' and A.CKOrdNo =' + quotedstr(FCKOrdNo));
|
|||
|
sql.Add(' GROUP BY A.CKOrdNo,A.MainId,A.SubId,A.QtyUnit,A.kuanhao ,A.ganghao ,A.APID,A.CDDanwei,convert(varchar(10),A.CRTime,120),A.CRType ) AA ');
|
|||
|
sql.Add(' inner join JYOrder_Main B on AA.MainId=B.MainId inner join JYOrder_Sub C on AA.SubId=C.SubId ');
|
|||
|
sql.Add(' ) AAA ');
|
|||
|
sql.Add(fwhere);
|
|||
|
Open;
|
|||
|
end;
|
|||
|
SCreateCDS(ADOQueryMain, CDS_Main);
|
|||
|
SInitCDSData(ADOQueryMain, CDS_Main);
|
|||
|
|
|||
|
MovePanel2.Visible := false;
|
|||
|
finally
|
|||
|
ADOQueryMain.EnableControls;
|
|||
|
MovePanel2.Visible := false;
|
|||
|
end;
|
|||
|
|
|||
|
end;
|
|||
|
|
|||
|
procedure TfrmCKProductBCPOutListHZFS.TBRafreshClick(Sender: TObject);
|
|||
|
begin
|
|||
|
InitGrid();
|
|||
|
end;
|
|||
|
|
|||
|
procedure TfrmCKProductBCPOutListHZFS.ConNoMChange(Sender: TObject);
|
|||
|
begin
|
|||
|
if ADOQueryMain.Active then
|
|||
|
begin
|
|||
|
SDofilter(ADOQueryMain, SGetFilters(Panel1, 1, 2));
|
|||
|
end;
|
|||
|
end;
|
|||
|
|
|||
|
procedure TfrmCKProductBCPOutListHZFS.TBCloseClick(Sender: TObject);
|
|||
|
begin
|
|||
|
WriteCxGrid(trim(self.Caption), Tv1, '<27><>Ʒ<EFBFBD>ֿ<EFBFBD>999');
|
|||
|
Close;
|
|||
|
end;
|
|||
|
|
|||
|
procedure TfrmCKProductBCPOutListHZFS.FormShow(Sender: TObject);
|
|||
|
var
|
|||
|
fsj: string;
|
|||
|
begin
|
|||
|
ReadCxGrid(trim(self.Caption), Tv1, '<27><>Ʒ<EFBFBD>ֿ<EFBFBD>999');
|
|||
|
fsj := 'select distinct(LMName) name from Lbael_Map where LMType=''<27><><EFBFBD><EFBFBD><EFBFBD>뵥'' ';
|
|||
|
SInitComBoxBySql(ADOQueryCmd, ComboBox1, true, fsj);
|
|||
|
|
|||
|
with ADOQueryTemp do
|
|||
|
begin
|
|||
|
Filtered := False;
|
|||
|
Close;
|
|||
|
sql.Clear;
|
|||
|
Sql.Add('select * from Lbael_Map where LMType=''<27><><EFBFBD><EFBFBD><EFBFBD>뵥''');
|
|||
|
|
|||
|
Open;
|
|||
|
end;
|
|||
|
SCreateCDS(ADOQueryTemp, CDS_Label);
|
|||
|
SInitCDSData(ADOQueryTemp, CDS_Label);
|
|||
|
InitGrid();
|
|||
|
end;
|
|||
|
|
|||
|
procedure TfrmCKProductBCPOutListHZFS.TBExportClick(Sender: TObject);
|
|||
|
begin
|
|||
|
if ADOQueryMain.IsEmpty then
|
|||
|
exit;
|
|||
|
// SelExportData(Tv1, ADOQueryMain, '');
|
|||
|
end;
|
|||
|
|
|||
|
procedure TfrmCKProductBCPOutListHZFS.N1Click(Sender: TObject);
|
|||
|
begin
|
|||
|
SelOKNo(CDS_Main, True);
|
|||
|
end;
|
|||
|
|
|||
|
procedure TfrmCKProductBCPOutListHZFS.N2Click(Sender: TObject);
|
|||
|
begin
|
|||
|
SelOKNo(CDS_Main, False);
|
|||
|
end;
|
|||
|
|
|||
|
procedure TfrmCKProductBCPOutListHZFS.orderNoKeyPress(Sender: TObject; var Key: Char);
|
|||
|
begin
|
|||
|
if Key = #13 then
|
|||
|
begin
|
|||
|
CurrentPage := 1;
|
|||
|
InitGrid();
|
|||
|
end;
|
|||
|
end;
|
|||
|
|
|||
|
procedure TfrmCKProductBCPOutListHZFS.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 TfrmCKProductBCPOutListHZFS.Tv1MouseUp(Sender: TObject; Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
|
|||
|
begin
|
|||
|
FLeft := X;
|
|||
|
FTop := Y;
|
|||
|
end;
|
|||
|
|
|||
|
procedure TfrmCKProductBCPOutListHZFS.CPTypeChange(Sender: TObject);
|
|||
|
begin
|
|||
|
CurrentPage := 1;
|
|||
|
InitGrid();
|
|||
|
end;
|
|||
|
|
|||
|
procedure TfrmCKProductBCPOutListHZFS.CRTypeChange(Sender: TObject);
|
|||
|
begin
|
|||
|
CurrentPage := 1;
|
|||
|
InitGrid();
|
|||
|
end;
|
|||
|
|
|||
|
procedure TfrmCKProductBCPOutListHZFS.edtSMNOKeyPress(Sender: TObject; var Key: Char);
|
|||
|
begin
|
|||
|
if Key = #13 then
|
|||
|
begin
|
|||
|
|
|||
|
end;
|
|||
|
end;
|
|||
|
|
|||
|
procedure TfrmCKProductBCPOutListHZFS.FormDestroy(Sender: TObject);
|
|||
|
begin
|
|||
|
frmCKProductBCPOutListHZFS := nil;
|
|||
|
end;
|
|||
|
|
|||
|
procedure TfrmCKProductBCPOutListHZFS.ToolButton1Click(Sender: TObject);
|
|||
|
var
|
|||
|
fPrintFile, fPrintFile10, FMainID, FKHName, FFPNo: string;
|
|||
|
begin
|
|||
|
if CDS_Main.IsEmpty then
|
|||
|
Exit;
|
|||
|
ExportFtErpFile(trim(ComboBox1.Text) + '.rmf', ADOQueryTemp);
|
|||
|
|
|||
|
if CDS_Label.Locate('LMName', trim(ComboBox1.Text), []) then
|
|||
|
begin
|
|||
|
with ADOQueryPrint do
|
|||
|
begin
|
|||
|
Close;
|
|||
|
sql.Clear;
|
|||
|
sql.add('exec ' + trim(CDS_Label.fieldbyname('LMSql').AsString) + ' @CKOrdNo=' + quotedstr(Trim(CDS_Main.fieldbyname('CKOrdNo').AsString)));
|
|||
|
Open;
|
|||
|
end;
|
|||
|
end;
|
|||
|
|
|||
|
fPrintFile := ExtractFilePath(Application.ExeName) + 'Report\' + Trim(ComboBox1.Text) + '.rmf';
|
|||
|
if FileExists(fPrintFile) then
|
|||
|
begin
|
|||
|
RM3.LoadFromFile(fPrintFile);
|
|||
|
RMVariables['ZDR'] := trim(DName);
|
|||
|
RM3.ShowReport;
|
|||
|
end
|
|||
|
else
|
|||
|
begin
|
|||
|
Application.MessageBox(PChar('û<><C3BB><EFBFBD>ҵ<EFBFBD>' + fPrintFile), '<27><>ʾ', 0);
|
|||
|
end;
|
|||
|
end;
|
|||
|
|
|||
|
end.
|
|||
|
|