355 lines
10 KiB
ObjectPascal
355 lines
10 KiB
ObjectPascal
![]() |
unit U_DJBRKListSel;
|
|||
|
|
|||
|
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
|
|||
|
TfrmDJBRKListSel = 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;
|
|||
|
v1Column6: TcxGridDBColumn;
|
|||
|
v1Column2: TcxGridDBColumn;
|
|||
|
v1Column4: TcxGridDBColumn;
|
|||
|
v1Column15: TcxGridDBColumn;
|
|||
|
v1Column17: TcxGridDBColumn;
|
|||
|
v1Column14: TcxGridDBColumn;
|
|||
|
v2Column1: TcxGridDBColumn;
|
|||
|
v1Column8: TcxGridDBColumn;
|
|||
|
v1Column7: TcxGridDBColumn;
|
|||
|
v1Column1: TcxGridDBColumn;
|
|||
|
v1Column10: TcxGridDBColumn;
|
|||
|
v1Column9: TcxGridDBColumn;
|
|||
|
v2Column6: TcxGridDBColumn;
|
|||
|
v1Column3: TcxGridDBColumn;
|
|||
|
v1Column12: TcxGridDBColumn;
|
|||
|
cxGrid2Level1: TcxGridLevel;
|
|||
|
Label9: TLabel;
|
|||
|
ToFactoryName: TEdit;
|
|||
|
Label12: TLabel;
|
|||
|
CRType: TComboBox;
|
|||
|
Label10: TLabel;
|
|||
|
KuWei: TEdit;
|
|||
|
v1Column19: TcxGridDBColumn;
|
|||
|
Label11: TLabel;
|
|||
|
RCGangNo: TEdit;
|
|||
|
Label13: TLabel;
|
|||
|
SPColor: TEdit;
|
|||
|
Label15: TLabel;
|
|||
|
SPHX: TEdit;
|
|||
|
v1Column20: TcxGridDBColumn;
|
|||
|
Filler: TEdit;
|
|||
|
Label16: TLabel;
|
|||
|
v1Column24: TcxGridDBColumn;
|
|||
|
ADOQueryPrint: TADOQuery;
|
|||
|
v1Column5: TcxGridDBColumn;
|
|||
|
v1Column11: TcxGridDBColumn;
|
|||
|
RMDB_Main: TRMDBDataSet;
|
|||
|
RM2: TRMGridReport;
|
|||
|
v1Column13: TcxGridDBColumn;
|
|||
|
v1Column16: TcxGridDBColumn;
|
|||
|
v1Column18: TcxGridDBColumn;
|
|||
|
batchNo: TEdit;
|
|||
|
Label14: TLabel;
|
|||
|
begTime: TDateTimePicker;
|
|||
|
endTime: TDateTimePicker;
|
|||
|
v1Column21: TcxGridDBColumn;
|
|||
|
v1Column22: TcxGridDBColumn;
|
|||
|
GYSType: TComboBox;
|
|||
|
Label20: TLabel;
|
|||
|
v1Column23: TcxGridDBColumn;
|
|||
|
SPKZ1: TEdit;
|
|||
|
Label21: TLabel;
|
|||
|
v1Column25: TcxGridDBColumn;
|
|||
|
v1Column26: TcxGridDBColumn;
|
|||
|
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 Tv1DblClick(Sender: TObject);
|
|||
|
private
|
|||
|
canshu1,canshu2:string;
|
|||
|
procedure InitGrid();
|
|||
|
Procedure PrintData(fMJID:string);
|
|||
|
{ Private declarations }
|
|||
|
public
|
|||
|
fckName:string;
|
|||
|
{ Public declarations }
|
|||
|
end;
|
|||
|
|
|||
|
var
|
|||
|
frmDJBRKListSel: TfrmDJBRKListSel;
|
|||
|
|
|||
|
implementation
|
|||
|
uses
|
|||
|
U_DataLink,U_RTFun,U_DJBCKInPut, U_DJBRK_Edit, U_ZdyAttachGYS;
|
|||
|
|
|||
|
{$R *.dfm}
|
|||
|
Procedure TfrmDJBRKListSel.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 TfrmDJBRKListSel.FormDestroy(Sender: TObject);
|
|||
|
begin
|
|||
|
frmDJBRKListSel:=nil;
|
|||
|
end;
|
|||
|
|
|||
|
procedure TfrmDJBRKListSel.FormClose(Sender: TObject;
|
|||
|
var Action: TCloseAction);
|
|||
|
begin
|
|||
|
Action:=cahide;
|
|||
|
end;
|
|||
|
|
|||
|
procedure TfrmDJBRKListSel.FormCreate(Sender: TObject);
|
|||
|
begin
|
|||
|
//cxGrid1.Align:=alClient;
|
|||
|
canshu1:=Trim(DParameters1);
|
|||
|
canshu2:=Trim(DParameters2);
|
|||
|
EndDate.DateTime:=SGetServerDate10(ADOQueryTemp);
|
|||
|
BegDate.DateTime:=SGetServerDate10(ADOQueryTemp);
|
|||
|
end;
|
|||
|
|
|||
|
procedure TfrmDJBRKListSel.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 A.*,cast(spkz as varchar) as spkz1 ');
|
|||
|
sql.Add(' ,C_CodeNameZW=(select Top 1 defnote3 from KH_Zdy_Attachment X where X.ZdyName=A.SPName and Type=''CP'') ');
|
|||
|
sql.Add(' ,GYSType=(select Top 1 defstr5 from KH_Zdy_Attachment X where X.zdyName=A.FactoryName and Type=''GYS'') ');
|
|||
|
sql.Add(' ,MJLen=(select sum(MJlen) from WFB_MJJY X where X.APID=A.SPID ) ');
|
|||
|
sql.Add(' ,TpPS=(select sum(TPPS) from [guoyundata].dbo.XH_Cloth_TP X where X.gangNo=A.RcGangNo and X.DQfactoryName=A.factoryName )');
|
|||
|
sql.Add(' ,TPQty=(select sum(TPQty) from [guoyundata].dbo.XH_Cloth_TP X where X.gangNo=A.RcGangNo and X.DQfactoryName=A.factoryName)');
|
|||
|
sql.Add(' ,TpUnit=(select top 1 TPUnit from [guoyundata].dbo.XH_Cloth_TP X where X.gangNo=A.RcGangNo and X.DQfactoryName=A.factoryName)');
|
|||
|
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,'''')=''<27><><EFBFBD>Ųֿ<C5B2>''');
|
|||
|
sql.Add(' and not exists (select * from CbJdLr X where X.SPID=A.SPID)');
|
|||
|
SQL.Add(' and CRFlag=''<27><><EFBFBD><EFBFBD>'' ');
|
|||
|
Open;
|
|||
|
// ShowMessage(SQL.Text);
|
|||
|
end;
|
|||
|
SCreateCDS20(ADOQueryMain,CDS_Main);
|
|||
|
SInitCDSData20(ADOQueryMain,CDS_Main);
|
|||
|
finally
|
|||
|
ADOQueryMain.EnableControls;
|
|||
|
tbfind.Click;
|
|||
|
end;
|
|||
|
end;
|
|||
|
|
|||
|
procedure TfrmDJBRKListSel.TBRafreshClick(Sender: TObject);
|
|||
|
begin
|
|||
|
BegDate.SetFocus;
|
|||
|
InitGrid();
|
|||
|
end;
|
|||
|
|
|||
|
procedure TfrmDJBRKListSel.ConNoMChange(Sender: TObject);
|
|||
|
begin
|
|||
|
if ADOQueryMain.Active then
|
|||
|
begin
|
|||
|
SDofilter(ADOQueryMain,SGetFilters(Panel1,1,2));
|
|||
|
end;
|
|||
|
end;
|
|||
|
|
|||
|
procedure TfrmDJBRKListSel.TBCloseClick(Sender: TObject);
|
|||
|
begin
|
|||
|
WriteCxGrid(trim(self.Caption),Tv1,'<27><><EFBFBD>첼<EFBFBD>ֿ<EFBFBD>');
|
|||
|
Close;
|
|||
|
end;
|
|||
|
|
|||
|
procedure TfrmDJBRKListSel.FormShow(Sender: TObject);
|
|||
|
begin
|
|||
|
|
|||
|
ReadCxGrid(trim(self.Caption),Tv1,'<27><><EFBFBD>첼<EFBFBD>ֿ<EFBFBD>');
|
|||
|
InitGrid();
|
|||
|
end;
|
|||
|
|
|||
|
procedure TfrmDJBRKListSel.TBExportClick(Sender: TObject);
|
|||
|
begin
|
|||
|
if ADOQueryMain.IsEmpty then exit;
|
|||
|
TcxGridToExcel('<27><><EFBFBD>첼<EFBFBD><ECB2BC><EFBFBD><EFBFBD><EFBFBD>б<EFBFBD>',cxGrid2);
|
|||
|
end;
|
|||
|
|
|||
|
procedure TfrmDJBRKListSel.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 TfrmDJBRKListSel.N1Click(Sender: TObject);
|
|||
|
begin
|
|||
|
SelOKNo(CDS_Main,True);
|
|||
|
end;
|
|||
|
|
|||
|
procedure TfrmDJBRKListSel.N2Click(Sender: TObject);
|
|||
|
begin
|
|||
|
SelOKNo(CDS_Main,False);
|
|||
|
end;
|
|||
|
|
|||
|
procedure TfrmDJBRKListSel.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 TfrmDJBRKListSel.SPIDChange(Sender: TObject);
|
|||
|
begin
|
|||
|
if Length(Trim(SPID.Text))<4 then
|
|||
|
begin
|
|||
|
if Trim(SPID.Text)<>'' then Exit;
|
|||
|
end;
|
|||
|
TBFind.Click;
|
|||
|
end;
|
|||
|
|
|||
|
procedure TfrmDJBRKListSel.SPSpecChange(Sender: TObject);
|
|||
|
begin
|
|||
|
TBFind.Click;
|
|||
|
end;
|
|||
|
|
|||
|
procedure TfrmDJBRKListSel.FactoryNameChange(Sender: TObject);
|
|||
|
begin
|
|||
|
TBFind.Click;
|
|||
|
end;
|
|||
|
|
|||
|
|
|||
|
procedure TfrmDJBRKListSel.Tv1DblClick(Sender: TObject);
|
|||
|
begin
|
|||
|
ModalResult:=1;
|
|||
|
end;
|
|||
|
|
|||
|
end.
|