354 lines
10 KiB
ObjectPascal
354 lines
10 KiB
ObjectPascal
unit U_DJBRKHZList;
|
||
|
||
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, cxButtonEdit, cxTextEdit, BtnEdit;
|
||
|
||
type
|
||
TfrmDJBRKHZList = class(TForm)
|
||
ToolBar1: TToolBar;
|
||
TBRafresh: TToolButton;
|
||
TBFind: TToolButton;
|
||
TBExport: TToolButton;
|
||
TBClose: TToolButton;
|
||
Panel1: TPanel;
|
||
ADOQueryCmd: TADOQuery;
|
||
ADOQueryMain: TADOQuery;
|
||
ADOQueryTemp: TADOQuery;
|
||
DataSource1: TDataSource;
|
||
cxGridPopupMenu1: TcxGridPopupMenu;
|
||
Label1: TLabel;
|
||
Label2: TLabel;
|
||
BegDate: TDateTimePicker;
|
||
EndDate: TDateTimePicker;
|
||
CDS_Main: TClientDataSet;
|
||
RM1: TRMGridReport;
|
||
RMDBMain: TRMDBDataSet;
|
||
RMXLSExport1: TRMXLSExport;
|
||
PopupMenu1: TPopupMenu;
|
||
N1: TMenuItem;
|
||
N2: TMenuItem;
|
||
Label3: TLabel;
|
||
Label4: TLabel;
|
||
Label5: TLabel;
|
||
Label8: TLabel;
|
||
SPName: TEdit;
|
||
FactoryName: TEdit;
|
||
SPID: TEdit;
|
||
SPSpec: TEdit;
|
||
Label6: TLabel;
|
||
SPCF: TEdit;
|
||
Label7: TLabel;
|
||
OrderNo: TEdit;
|
||
cxGrid2: TcxGrid;
|
||
Tv1: TcxGridDBTableView;
|
||
v2Column1: TcxGridDBColumn;
|
||
v1Column1: TcxGridDBColumn;
|
||
v1Column10: TcxGridDBColumn;
|
||
v1Column9: TcxGridDBColumn;
|
||
v2Column6: TcxGridDBColumn;
|
||
v1Column3: TcxGridDBColumn;
|
||
cxGrid2Level1: TcxGridLevel;
|
||
Label9: TLabel;
|
||
ToFactoryName: TEdit;
|
||
Label10: TLabel;
|
||
KuWei: TEdit;
|
||
Label11: TLabel;
|
||
RCGangNo: TEdit;
|
||
Label13: TLabel;
|
||
SPColor: TEdit;
|
||
Label15: TLabel;
|
||
SPKZ1: TEdit;
|
||
Filler: TEdit;
|
||
Label16: TLabel;
|
||
ADOQueryPrint: TADOQuery;
|
||
RMDB_Main: TRMDBDataSet;
|
||
RM2: TRMGridReport;
|
||
v1Column13: TcxGridDBColumn;
|
||
v1Column16: TcxGridDBColumn;
|
||
batchNo: TEdit;
|
||
Label14: TLabel;
|
||
begTime: TDateTimePicker;
|
||
endTime: TDateTimePicker;
|
||
v1Column21: TcxGridDBColumn;
|
||
v1Column2: TcxGridDBColumn;
|
||
v1Column4: TcxGridDBColumn;
|
||
CRType: TComboBox;
|
||
Label17: TLabel;
|
||
TBMX: TToolButton;
|
||
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 TBFindClick(Sender: TObject);
|
||
procedure N1Click(Sender: TObject);
|
||
procedure N2Click(Sender: TObject);
|
||
procedure SPIDKeyPress(Sender: TObject; var Key: Char);
|
||
procedure SPIDChange(Sender: TObject);
|
||
procedure SPSpecChange(Sender: TObject);
|
||
procedure FactoryNameChange(Sender: TObject);
|
||
procedure TBMXClick(Sender: TObject);
|
||
procedure Tv1CellDblClick(Sender: TcxCustomGridTableView;
|
||
ACellViewInfo: TcxGridTableDataCellViewInfo; AButton: TMouseButton;
|
||
AShift: TShiftState; var AHandled: Boolean);
|
||
private
|
||
canshu1,canshu2:string;
|
||
procedure InitGrid();
|
||
Procedure PrintData(fMJID:string);
|
||
{ Private declarations }
|
||
public
|
||
fckName:string;
|
||
{ Public declarations }
|
||
end;
|
||
|
||
var
|
||
frmDJBRKHZList: TfrmDJBRKHZList;
|
||
|
||
implementation
|
||
uses
|
||
U_DataLink,U_RTFun,U_DJBCKInPut, U_DJBRKlist;
|
||
|
||
{$R *.dfm}
|
||
Procedure TfrmDJBRKHZList.PrintData(fMJID:string);
|
||
var
|
||
fPrintFile:String;
|
||
Txt,fImagePath:string;
|
||
Moudle: THandle;
|
||
Makebar:TMakebar;
|
||
Mixtext:TMixtext;
|
||
begin
|
||
try
|
||
Moudle:=LoadLibrary('MakeQRBarcode.dll');
|
||
@Makebar:=GetProcAddress(Moudle,'Make');
|
||
@Mixtext:=GetProcAddress(Moudle,'MixText');
|
||
Txt:=Trim(fMJID);
|
||
fImagePath:=ExtractFilePath(Application.ExeName)+'image\temp.bmp' ;
|
||
if not DirectoryExists(pchar(ExtractFilePath(Application.ExeName)+'image')) then
|
||
CreateDirectory(pchar(ExtractFilePath(Application.ExeName)+'image'),nil);
|
||
if FileExists(fImagePath) then DeleteFile(fImagePath);
|
||
Makebar(pchar(Txt),Length(Txt),3,3,0,PChar(fImagePath),3);
|
||
except
|
||
application.MessageBox('<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʧ<EFBFBD>ܣ<EFBFBD>','<27><>ʾ<EFBFBD><CABE>Ϣ',MB_ICONERROR);
|
||
exit;
|
||
end;
|
||
with ADOQueryPrint do
|
||
begin
|
||
Close;
|
||
SQL.Clear;
|
||
sql.Add('select A.*,C_CodeNameZW=(select Top 1 defnote3 from KH_Zdy_Attachment X where X.ZdyName=A.C_CodeName and Type=''CP'') ');
|
||
sql.Add(',C_colorName=(select Top 1 DEFstr6 from KH_Zdy_Attachment X where X.ZdyName=A.C_CodeName and X.DEFstr3=A.C_Color and Type=''CP'') ');
|
||
sql.Add(' from WFB_MJJY A') ;
|
||
SQL.Add(' where A.MJID='''+Trim(fMJID)+'''');
|
||
Open;
|
||
end;
|
||
|
||
fPrintFile:=ExtractFilePath(Application.ExeName)+'Report\ͨ<>ñ<EFBFBD>ǩ.rmf' ;
|
||
if FileExists(fPrintFile) then
|
||
begin
|
||
RMVariables['QRBARCODE']:=fImagePath;
|
||
RM2.LoadFromFile(fPrintFile);
|
||
RM2.DefaultCopies:=1;
|
||
RM2.PrintReport;
|
||
end
|
||
else
|
||
begin
|
||
Application.MessageBox(PChar('û<><C3BB><EFBFBD>ҵ<EFBFBD>'+trim(fPrintFile)),'<27><>ʾ',0);
|
||
end;
|
||
end;
|
||
|
||
procedure TfrmDJBRKHZList.FormDestroy(Sender: TObject);
|
||
begin
|
||
frmDJBRKHZList:=nil;
|
||
end;
|
||
|
||
procedure TfrmDJBRKHZList.FormClose(Sender: TObject;
|
||
var Action: TCloseAction);
|
||
begin
|
||
Action:=caFree;
|
||
end;
|
||
|
||
procedure TfrmDJBRKHZList.FormCreate(Sender: TObject);
|
||
begin
|
||
//cxGrid1.Align:=alClient;
|
||
canshu1:=Trim(DParameters1);
|
||
canshu2:=Trim(DParameters2);
|
||
EndDate.DateTime:=SGetServerDate10(ADOQueryTemp);
|
||
BegDate.DateTime:=SGetServerDate10(ADOQueryTemp);
|
||
end;
|
||
|
||
procedure TfrmDJBRKHZList.InitGrid();
|
||
var
|
||
mBegdate,mEnddate:string;
|
||
begin
|
||
mbegdate:=FormatDateTime('yyyy-MM-dd',begdate.Date)+' '+FormatDateTime('HH:nn',begTime.Time);
|
||
menddate:=FormatDateTime('yyyy-MM-dd',enddate.Date)+' '+FormatDateTime('HH:nn',endTime.Time);
|
||
try
|
||
ADOQueryMain.DisableControls;
|
||
with ADOQueryMain do
|
||
begin
|
||
|
||
Close;
|
||
Filtered:=False;
|
||
sql.Clear;
|
||
sql.Add(' select factoryName,CRType,SPName,C_CodeNameZW,SPMF,SPKZ,QtyUnit,cast(SPKZ as varchar) as SPKZ1, sum(piQty) as piQty,sum(Qty) as Qty,sum(Qty1) as Qty1,sum(MJlen) as MJlen ');
|
||
sql.Add(' from( ');
|
||
sql.Add(' SELECT A.factoryName,A.CRType,A.SPName,A.SPMF,A.SPKZ,A.piQty,A.Qty,A.Qty1,A.QtyUnit ');
|
||
sql.Add(' ,C_CodeNameZW=(select Top 1 defnote3 from KH_Zdy_Attachment X where X.ZdyName=A.SPName and Type=''CP'') ');
|
||
sql.Add(' ,MJLen=(select sum(MJlen) from WFB_MJJY X where X.APID=A.SPID ) ');
|
||
sql.Add(' from CK_SXPB_CR A');
|
||
sql.add(' where A.CRTime>='''+FormatDateTime('yyyy-MM-dd',begdate.Date)+''' ');
|
||
sql.add(' and A.CRTime<'''+FormatDateTime('yyyy-MM-dd',enddate.Date+1)+''' ');
|
||
sql.Add(' and isnull(CKName,'''')='''+trim(fckName)+'''');
|
||
SQL.Add(' and CRFlag=''<27><><EFBFBD><EFBFBD>'' ');
|
||
sql.Add(' )AA group by factoryName,CRType,SPName,C_CodeNameZW,SPMF,SPKZ,QtyUnit ');
|
||
Open;
|
||
// ShowMessage(SQL.Text);
|
||
end;
|
||
SCreateCDS20(ADOQueryMain,CDS_Main);
|
||
SInitCDSData20(ADOQueryMain,CDS_Main);
|
||
finally
|
||
ADOQueryMain.EnableControls;
|
||
end;
|
||
end;
|
||
|
||
procedure TfrmDJBRKHZList.TBRafreshClick(Sender: TObject);
|
||
begin
|
||
BegDate.SetFocus;
|
||
InitGrid();
|
||
end;
|
||
|
||
procedure TfrmDJBRKHZList.ConNoMChange(Sender: TObject);
|
||
begin
|
||
if ADOQueryMain.Active then
|
||
begin
|
||
SDofilter(ADOQueryMain,SGetFilters(Panel1,1,2));
|
||
end;
|
||
end;
|
||
|
||
procedure TfrmDJBRKHZList.TBCloseClick(Sender: TObject);
|
||
begin
|
||
WriteCxGrid(self.Caption,Tv1,'<27><><EFBFBD>첼<EFBFBD>ֿ<EFBFBD>');
|
||
Close;
|
||
end;
|
||
|
||
procedure TfrmDJBRKHZList.FormShow(Sender: TObject);
|
||
begin
|
||
ReadCxGrid(self.Caption,Tv1,'<27><><EFBFBD>첼<EFBFBD>ֿ<EFBFBD>');
|
||
InitGrid();
|
||
end;
|
||
|
||
procedure TfrmDJBRKHZList.TBExportClick(Sender: TObject);
|
||
begin
|
||
if ADOQueryMain.IsEmpty then exit;
|
||
TcxGridToExcel(self.Caption,cxGrid2);
|
||
end;
|
||
|
||
procedure TfrmDJBRKHZList.TBFindClick(Sender: TObject);
|
||
begin
|
||
if ADOQueryMain.Active then
|
||
begin
|
||
SDofilter(ADOQueryMain,SGetFilters(Panel1,1,2));
|
||
SCreateCDS20(ADOQueryMain,CDS_Main);
|
||
SInitCDSData20(ADOQueryMain,CDS_Main);
|
||
end;
|
||
end;
|
||
|
||
procedure TfrmDJBRKHZList.N1Click(Sender: TObject);
|
||
begin
|
||
SelOKNo(CDS_Main,True);
|
||
end;
|
||
|
||
procedure TfrmDJBRKHZList.N2Click(Sender: TObject);
|
||
begin
|
||
SelOKNo(CDS_Main,False);
|
||
end;
|
||
|
||
procedure TfrmDJBRKHZList.SPIDKeyPress(Sender: TObject; var Key: Char);
|
||
begin
|
||
if Key=#13 then
|
||
begin
|
||
{if Length(Trim(SPID.Text))<4 then Exit;
|
||
try
|
||
ADOQueryMain.DisableControls;
|
||
with ADOQueryMain do
|
||
begin
|
||
Filtered:=False;
|
||
Close;
|
||
sql.Clear;
|
||
sql.Add(' select A.* ');
|
||
sql.Add(',ConNo=(select ConNo from Contract_Main CM where CM.MainId=A.CGMainId)');
|
||
//sql.Add(' ,ConNo=(select ConNo from Contract_Main CM where CM.MainId=A.CGMainId )');
|
||
sql.Add(' from CK_SXPB_CR A');
|
||
sql.add(' where SPID like :SXID');
|
||
Parameters.ParamByName('SXID').Value:='%'+Trim(SXID.Text)+'%';
|
||
Open;
|
||
//ShowMessage(SQL.Text);
|
||
end;
|
||
SCreateCDS20(ADOQueryMain,CDS_Main);
|
||
SInitCDSData20(ADOQueryMain,CDS_Main);
|
||
finally
|
||
ADOQueryMain.EnableControls;
|
||
end; }
|
||
end;
|
||
end;
|
||
|
||
procedure TfrmDJBRKHZList.SPIDChange(Sender: TObject);
|
||
begin
|
||
TBFind.Click;
|
||
end;
|
||
|
||
procedure TfrmDJBRKHZList.SPSpecChange(Sender: TObject);
|
||
begin
|
||
TBFind.Click;
|
||
end;
|
||
|
||
procedure TfrmDJBRKHZList.FactoryNameChange(Sender: TObject);
|
||
begin
|
||
TBFind.Click;
|
||
end;
|
||
|
||
procedure TfrmDJBRKHZList.TBMXClick(Sender: TObject);
|
||
begin
|
||
IF CDS_Main.IsEmpty then exit;
|
||
frmDJBRKList:=TfrmDJBRKList.Create(self);
|
||
with frmDJBRKList do
|
||
begin
|
||
fckName:=self.fckName;
|
||
TBadd.Visible:=false;
|
||
TBedit.Visible:=false;
|
||
TBdel.Visible:=false;
|
||
TBTSedit.Visible:=false;
|
||
begdate.DateTime:=self.BegDate.DateTime;
|
||
enddate.DateTime:=self.EndDate.DateTime;
|
||
factoryName.Text:=self.CDS_Main.fieldbyName('factoryname').AsString;
|
||
CRType.ItemIndex:=CRType.Items.IndexOf(self.CDS_Main.fieldbyName('CRType').AsString);
|
||
SPName.Text:=self.CDS_Main.fieldbyName('SPName').AsString;
|
||
SPKZ1.Text:=self.CDS_Main.fieldbyName('SPKZ1').AsString;
|
||
|
||
show;
|
||
end;
|
||
|
||
end;
|
||
|
||
procedure TfrmDJBRKHZList.Tv1CellDblClick(Sender: TcxCustomGridTableView;
|
||
ACellViewInfo: TcxGridTableDataCellViewInfo; AButton: TMouseButton;
|
||
AShift: TShiftState; var AHandled: Boolean);
|
||
begin
|
||
TBMX.Click;
|
||
end;
|
||
|
||
end.
|