unit U_JYJSlist; interface uses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, ComCtrls, ToolWin, StdCtrls, ExtCtrls, cxStyles, cxCustomData, cxGraphics, cxFilter, cxData, cxDataStorage, cxEdit, DB, cxDBData, cxButtonEdit, cxDropDownEdit, cxGridLevel, cxGridCustomTableView, cxGridTableView, cxGridDBTableView, cxClasses, cxControls, cxGridCustomView, cxGrid, DBClient, ADODB, cxGridCustomPopupMenu, cxGridPopupMenu, RM_Common, RM_Class, RM_e_Xls, RM_GridReport, RM_System, RM_Dataset, cxTextEdit, cxPC, cxCheckBox, Menus, U_SLT, jpeg, cxContainer, cxMaskEdit, MovePanel, cxLookAndFeels, cxLookAndFeelPainters, cxNavigator, dxBarBuiltInMenu, MMSystem, dxSkinsCore, dxSkinsDefaultPainters, dxSkinscxPCPainter; type TfrmJYJSlist = class(TForm) ToolBar1: TToolBar; TBRafresh: TToolButton; TBDel: TToolButton; TBExport: TToolButton; TBClose: TToolButton; cxGrid1: TcxGrid; Tv1: TcxGridDBTableView; v1P_CodeName: TcxGridDBColumn; v1P_MF: TcxGridDBColumn; v1Qty: TcxGridDBColumn; v1Note: TcxGridDBColumn; cxGrid1Level1: TcxGridLevel; v1CRTime: TcxGridDBColumn; v1CRNO: TcxGridDBColumn; v1Filler: TcxGridDBColumn; ADOQueryCmd: TADOQuery; ADOQueryTmp: TADOQuery; DataSource1: TDataSource; CDS_Main: TClientDataSet; cxGridPopupMenu1: TcxGridPopupMenu; ADOPrint: TADOQuery; RMXLSExport1: TRMXLSExport; v1custName: TcxGridDBColumn; RMDB_Main: TRMDBDataSet; cxStyleRepository1: TcxStyleRepository; cxStyle1: TcxStyle; cxStyle2: TcxStyle; cxStyle_gridRow: TcxStyle; cxStyle_gridFoot: TcxStyle; cxStyle_gridHead: TcxStyle; cxStyle_gridGroupBox: TcxStyle; cxStyle_yellow: TcxStyle; cxStyle_Red: TcxStyle; cxStyle_fontBlack: TcxStyle; cxStyle_fontclFuchsia: TcxStyle; cxStyle_fontclPurple: TcxStyle; cxStyle_fontclGreen: TcxStyle; cxStyle_fontclBlue: TcxStyle; cxStyle_fontclTeal: TcxStyle; cxStyle_fontclOlive: TcxStyle; ADOQueryMain: TADOQuery; RM1: TRMGridReport; v1Column5: TcxGridDBColumn; PopupMenu1: TPopupMenu; N1: TMenuItem; N2: TMenuItem; adoqueryPicture: TADOQuery; ToolButton1: TToolButton; ComboBox1: TComboBox; v1Column7: TcxGridDBColumn; btnJieShou: TToolButton; MovePanel1: TMovePanel; JSY: TcxButtonEdit; Label3: TLabel; Button1: TButton; Button2: TButton; ToolButton3: TToolButton; ToolButton4: TToolButton; cxStyle3: TcxStyle; cxStyleRepository2: TcxStyleRepository; cxStyle4: TcxStyle; btn2: TToolButton; ToolButton2: TToolButton; Panel1: TPanel; Button3: TButton; Timer2: TTimer; Tv1Column1: TcxGridDBColumn; Tv1Column2: TcxGridDBColumn; Button4: TButton; Button5: TButton; procedure FormClose(Sender: TObject; var Action: TCloseAction); procedure TBAddClick(Sender: TObject); procedure OrderNoChange(Sender: TObject); procedure FormShow(Sender: TObject); procedure FormCreate(Sender: TObject); procedure TBCloseClick(Sender: TObject); procedure TBEditClick(Sender: TObject); procedure TBDelClick(Sender: TObject); procedure TBRafreshClick(Sender: TObject); procedure TBExportClick(Sender: TObject); procedure v1Column6CompareRowValuesForCellMerging(Sender: TcxGridColumn; ARow1: TcxGridDataRow; AProperties1: TcxCustomEditProperties; const AValue1: Variant; ARow2: TcxGridDataRow; AProperties2: TcxCustomEditProperties; const AValue2: Variant; var AAreEqual: Boolean); procedure N1Click(Sender: TObject); procedure N2Click(Sender: TObject); procedure cxTabControl1Change(Sender: TObject); procedure tbChkClick(Sender: TObject); procedure tbChkNoClick(Sender: TObject); procedure btn1Click(Sender: TObject); procedure ToolButton1Click(Sender: TObject); procedure btnJieShouClick(Sender: TObject); procedure JSYPropertiesButtonClick(Sender: TObject; AButtonIndex: Integer); procedure Button2Click(Sender: TObject); procedure Button1Click(Sender: TObject); procedure ToolButton3Click(Sender: TObject); procedure ToolButton4Click(Sender: TObject); procedure btnTJClick(Sender: TObject); procedure btnTJCXClick(Sender: TObject); procedure btn2Click(Sender: TObject); procedure ToolButton2Click(Sender: TObject); procedure Button3Click(Sender: TObject); procedure Timer2Timer(Sender: TObject); procedure Tv1MouseLeave(Sender: TObject); procedure Tv1CustomDrawCell(Sender: TcxCustomGridTableView; ACanvas: TcxCanvas; AViewInfo: TcxGridTableDataCellViewInfo; var ADone: Boolean); procedure Tv1FocusedRecordChanged(Sender: TcxCustomGridTableView; APrevFocusedRecord, AFocusedRecord: TcxCustomGridRecord; ANewItemRecordFocusingChanged: Boolean); procedure Tv1MouseDown(Sender: TObject; Button: TMouseButton; Shift: TShiftState; X, Y: Integer); procedure Button4Click(Sender: TObject); procedure FormDestroy(Sender: TObject); procedure Button5Click(Sender: TObject); private procedure InitGrid(); procedure InitZD(); function YSData(ADO: TADOQuery): Boolean; function YSData_Other(ADO: TADOQuery; fYFName: string; fmoney: double): Boolean; procedure PrintCKMDG(MRKOrdID: string); { Private declarations } public canshu1, canshu2, fCKName: string; { Public declarations } end; var frmJYJSlist: TfrmJYJSlist; var Mach: array of TfrmSlt; FOX, FOY, FCX, FCY: Integer; FCRNO: string; implementation uses U_DataLink, U_Fun10, U_ZDYHelp, U_JYGLCK, u_fun, U_JSPerson; {$R *.dfm} procedure TfrmJYJSlist.PrintCKMDG(MRKOrdID: string); var fPrintFile: string; Txt, fImagePath: string; Moudle: THandle; Makebar: TMakebar; Mixtext: TMixtext; begin if CDS_Main.IsEmpty then Exit; ExportFtErpFile('调样申请单.rmf', ADOQueryTmp); with CDS_Main do begin with ADOPrint do begin Close; sql.Clear; SQL.Add('EXEC P_Print_dysqd4 @FSID=' + quotedstr(Trim(CDS_Main.fieldbyname('CRNO').AsString))); // ShowMessage(SQL.Text); Open; end; try Moudle := LoadLibrary('MakeQRBarcode.dll'); @Makebar := GetProcAddress(Moudle, 'Make'); @Mixtext := GetProcAddress(Moudle, 'MixText'); Txt := Trim(ADOPrint.fieldbyname('FSID').AsString); 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('条形码生成失败!', '提示信息', MB_ICONERROR); exit; end; fPrintFile := ExtractFilePath(Application.ExeName) + 'Report\调样申请单.rmf'; if FileExists(fPrintFile) then begin RMVariables['QRBARCODE'] := fImagePath; RM1.LoadFromFile(fPrintFile); // RM1.DefaultCopies := strtointdef(trim(ComboBox1.Text), 1); // RM2.PrintReport; RM1.ShowReport; end else begin Application.MessageBox(PChar('没有找' + fPrintFile), '提示', 0); Exit; end; end; end; function TfrmJYJSlist.YSData(ADO: TADOQuery): Boolean; var CRID, YFID, Price, PriceUnit, OrderUnit, FComTaiTou, cust: string; begin Result := False; with ADOQueryTmp do begin Close; SQL.Clear; sql.Add('select * from YF_Money_KC where FactoryName=''' + Trim(ADO.fieldbyname('custName').asstring) + ''' and YFDefFlag1=0 '); Open; end; if not ADOQueryTmp.IsEmpty then begin CRID := ADOQueryTmp.fieldbyname('CRID').AsString; end else begin with ADOQueryCmd do begin Close; sql.Clear; sql.Add('Update YF_Money_CRID set CRID=CRID+1'); sql.Add('select * from YF_Money_CRID '); Open; end; CRID := ADOQueryCmd.fieldbyname('CRID').AsString; with ADOQueryCmd do begin Close; SQL.Clear; sql.Add('select * from YF_Money_KC where 1<>1'); Open; end; with ADOQueryCmd do begin Append; FieldByName('CRID').Value := StrToInt(CRID); FieldByName('FactoryName').Value := Trim(ADO.fieldbyname('custName').asstring); FieldByName('ZdyStr1').Value := '应收收'; Post; end; end; with ADOQueryCmd do begin Close; sql.Clear; sql.Add('delete from YF_Money_CR '); sql.Add(' where MainID=''' + Trim(ADO.fieldbyname('CRNO').AsString) + ''''); sql.Add(' and subID=''' + Trim(ADO.fieldbyname('CRID').AsString) + ''''); sql.Add(' and YFName=''产品销售'' '); execsql; end; with ADOQueryTmp do begin Close; sql.Clear; sql.Add('select * from YF_Money_CR '); sql.Add(' where MainID=''' + Trim(ADO.fieldbyname('CRNO').AsString) + ''''); sql.Add(' and subID=''' + Trim(ADO.fieldbyname('CRID').AsString) + ''''); sql.Add(' and YFName=''产品销售'' '); Open; end; if ADOQueryTmp.IsEmpty then begin if GetLSNo(ADOQueryCmd, YFID, 'CS', 'YF_Money_CR', 4, 1) = False then begin Application.MessageBox('取应收最大号失败!', '提示', 0); Exit; end; with ADOQueryCmd do begin Close; sql.Clear; sql.Add('select * from YF_Money_CR where 1<>1'); Open; end; with ADOQueryCmd do begin Append; FieldByName('YFID').Value := Trim(YFID); FieldByName('YFTypeId').Value := Trim(ADO.fieldbyname('CRNO').AsString); FieldByName('CRID').Value := StrToInt(CRID); FieldByName('Filler').Value := Trim(DName); FieldByName('CRType').Value := '应收款登记'; FieldByName('CRFlag').Value := '应收收'; FieldByName('QtyFlag').Value := 1; FieldByName('FactoryName').Value := Trim(ADO.fieldbyname('custName').asstring); FieldByName('CRTime').Value := Trim(FormatDateTime('yyyy-MM-dd', ADO.fieldbyname('CRTime').AsDateTime)); FieldByName('YFType').Value := '自动生成'; FieldByName('ps').Value := ADO.fieldbyname('RollNum').AsFloat; FieldByName('Qty').Value := ADO.fieldbyname('Qty').AsFloat; FieldByName('Price').Value := ADO.fieldbyname('Price').AsFloat; FieldByName('Money').Value := ADO.fieldbyname('Money').AsFloat; FieldByName('BBMoney').Value := ADO.fieldbyname('Money').AsFloat; FieldByName('HuiLv').Value := 1; FieldByName('BZType').Value := '人民币'; FieldByName('QtyUnit').Value := Trim(ADO.fieldbyname('QtyUnit').AsString); FieldByName('ComTaiTou').Value := Trim(cust); FieldByName('YFName').Value := '产品销售'; FieldByName('MainId').Value := Trim(ADO.fieldbyname('CRNO').AsString); FieldByName('subID').Value := Trim(ADO.fieldbyname('CRID').AsString); FieldByName('status').Value := '0'; Post; end; end else begin YFID := Trim(ADOQueryTmp.fieldbyname('YFID').AsString); end; with ADOQueryCmd do begin Close; sql.Clear; sql.Add('Update YF_Money_KC Set KCMoney=(select isnull(Sum(Money*QtyFlag),0) from YF_Money_CR A where A.CRID=YF_Money_KC.CRID)'); sql.Add(',KCBBMoney=(select isnull(Sum(BBMoney*QtyFlag),0) from YF_Money_CR A where A.CRID=YF_Money_KC.CRID)'); sql.Add(' where CRID=' + CRID); ExecSQL; end; Result := True; end; function TfrmJYJSlist.YSData_Other(ADO: TADOQuery; fYFName: string; fmoney: double): Boolean; var CRID, YFID, Price, PriceUnit, OrderUnit, FComTaiTou, cust: string; begin Result := False; with ADOQueryTmp do begin Close; SQL.Clear; sql.Add('select * from YF_Money_KC where FactoryName=''' + Trim(ADO.fieldbyname('custName').asstring) + ''' and YFDefFlag1=0 '); Open; end; if not ADOQueryTmp.IsEmpty then begin CRID := ADOQueryTmp.fieldbyname('CRID').AsString; end else begin with ADOQueryCmd do begin Close; sql.Clear; sql.Add('Update YF_Money_CRID set CRID=CRID+1'); sql.Add('select * from YF_Money_CRID '); Open; end; CRID := ADOQueryCmd.fieldbyname('CRID').AsString; with ADOQueryCmd do begin Close; SQL.Clear; sql.Add('select * from YF_Money_KC where 1<>1'); Open; end; with ADOQueryCmd do begin Append; FieldByName('CRID').Value := StrToInt(CRID); FieldByName('FactoryName').Value := Trim(ADO.fieldbyname('custName').asstring); FieldByName('ZdyStr1').Value := '应收收'; Post; end; end; with ADOQueryCmd do begin Close; sql.Clear; sql.Add('delete from YF_Money_CR '); sql.Add(' where MainID=''' + Trim(ADO.fieldbyname('CRNO').AsString) + ''''); sql.Add(' and subID=''' + Trim(ADO.fieldbyname('CRID').AsString) + ''''); sql.Add(' and YFName=''' + trim(fYFName) + ''' '); execsql; end; with ADOQueryTmp do begin Close; sql.Clear; sql.Add('select * from YF_Money_CR '); sql.Add(' where MainID=''' + Trim(ADO.fieldbyname('CRNO').AsString) + ''''); sql.Add(' and subID=''' + Trim(ADO.fieldbyname('CRID').AsString) + ''''); sql.Add(' and YFName=''' + trim(fYFName) + ''' '); Open; end; if ADOQueryTmp.IsEmpty then begin if GetLSNo(ADOQueryCmd, YFID, 'CS', 'YF_Money_CR', 4, 1) = False then begin Application.MessageBox('取应收最大号失败!', '提示', 0); Exit; end; with ADOQueryCmd do begin Close; sql.Clear; sql.Add('select * from YF_Money_CR where 1<>1'); Open; end; with ADOQueryCmd do begin Append; FieldByName('YFID').Value := Trim(YFID); FieldByName('YFTypeId').Value := Trim(ADO.fieldbyname('CRNO').AsString); FieldByName('CRID').Value := StrToInt(CRID); FieldByName('Filler').Value := Trim(DName); FieldByName('CRType').Value := '应收款登记'; FieldByName('CRFlag').Value := '应收收'; FieldByName('QtyFlag').Value := 1; FieldByName('FactoryName').Value := Trim(ADO.fieldbyname('custName').asstring); FieldByName('CRTime').Value := Trim(FormatDateTime('yyyy-MM-dd', ADO.fieldbyname('CRTIme').AsDateTime)); FieldByName('YFType').Value := '自动生成'; FieldByName('Qty').Value := 1; FieldByName('Price').Value := fmoney; FieldByName('Money').Value := fmoney; FieldByName('BBMoney').Value := fmoney; FieldByName('HuiLv').Value := 1; FieldByName('BZType').Value := '人民币'; FieldByName('QtyUnit').Value := '个'; FieldByName('ComTaiTou').Value := Trim(cust); FieldByName('YFName').Value := fYFName; FieldByName('MainId').Value := Trim(ADO.fieldbyname('CRNO').AsString); FieldByName('subID').Value := Trim(ADO.fieldbyname('CRID').AsString); FieldByName('status').Value := '0'; Post; end; end else begin YFID := Trim(ADOQueryTmp.fieldbyname('YFID').AsString); end; with ADOQueryCmd do begin Close; sql.Clear; sql.Add('Update YF_Money_KC Set KCMoney=(select isnull(Sum(Money*QtyFlag),0) from YF_Money_CR A where A.CRID=YF_Money_KC.CRID)'); sql.Add(',KCBBMoney=(select isnull(Sum(BBMoney*QtyFlag),0) from YF_Money_CR A where A.CRID=YF_Money_KC.CRID)'); sql.Add(' where CRID=' + CRID); ExecSQL; end; Result := True; end; procedure TfrmJYJSlist.Initzd(); begin with ADOQueryTmp do begin close; sql.Clear; sql.Add(' select A.*,row_number() over(order by A.crno) as rownumber '); SQL.Add(' from CK_Sample_CR A '); sql.Add(' where CRFlag=''出库'' and A.valid=''Y'' '); sql.Add(' and VisType=''寄样'' and CKName=' + quotedstr(trim(fCKName))); sql.Add(' and isnull(A.Chkstatus,''-1'')=''0'''); sql.Add('and a.jsperson is null'); // ShowMessage(sql.Text); open; end; if ADOQueryTmp.recordcount > CDS_Main.recordcount then begin Timer2.Enabled := False; PlaySound('wav\新订单.wav', 0, SND_FILENAME or SND_ASYNC); InitGrid(); Timer2.Enabled := true; end else begin Timer2.Enabled := False; InitGrid(); Timer2.Enabled := true; end; // with ADOQueryCmd do // begin // close; // sql.Clear; // sql.Add('update CK_Sample_CR set jsflag=1 '); // // sql.Add(' where CRFlag=''出库'' and valid=''Y'' '); // sql.Add(' and VisType=''寄样'' and CKName=' + quotedstr(trim(fCKName))); // sql.Add(' and isnull(Chkstatus,''-1'')=''0'''); // sql.Add('and jsperson is null AND ISNULL(JSFLAG,0)=0'); // // execsql; // end; // end; end; procedure TfrmJYJSlist.InitGrid(); begin try with ADOQueryMain do begin close; sql.Clear; sql.Add(' select A.*,row_number() over(order by A.crno) as rownumber '); SQL.Add(' from CK_Sample_CR A '); sql.Add(' where CRFlag=''出库'' and A.valid=''Y'' '); sql.Add(' and VisType=''寄样'' and CKName=' + quotedstr(trim(fCKName))); sql.Add(' and isnull(A.Chkstatus,''-1'')=''0'''); sql.Add('and a.jsperson is null '); // ShowMessage(SQL.Text); open; end; SCreateCDS20(ADOQueryMain, CDS_Main); SInitCDSData20(ADOQueryMain, CDS_Main); CDS_Main.locate('CRNO', FCRNO, []); Button3.Enabled := true; finally end; end; procedure TfrmJYJSlist.FormClose(Sender: TObject; var Action: TCloseAction); begin Action := cafree; end; procedure TfrmJYJSlist.TBAddClick(Sender: TObject); begin frmJYGLCK := TfrmJYGLCK.create(self); with frmJYGLCK do begin fkeyNo := ''; fType := 0; fCKName := trim(self.fCKName); canshu1 := Self.canshu1; jyfs := '库存'; if showmodal = 1 then begin TBRafresh.Click; self.CDS_Main.Locate('crNo', trim(fkeyNo), []); end; free; end; end; procedure TfrmJYJSlist.OrderNoChange(Sender: TObject); begin if ADOQuerymain.Active = False then Exit; SCreateCDS20(ADOQuerymain, CDS_Main); SInitCDSData20(ADOQuerymain, CDS_Main); end; procedure TfrmJYJSlist.FormShow(Sender: TObject); begin readCxGrid(trim(self.Caption), Tv1, '样品仓库666'); InitGrid(); Timer2.Enabled := True; end; procedure TfrmJYJSlist.FormCreate(Sender: TObject); begin cxGrid1.Align := alclient; end; procedure TfrmJYJSlist.TBCloseClick(Sender: TObject); begin writeCxGrid(trim(self.Caption), Tv1, '样品仓库666'); close; end; procedure TfrmJYJSlist.TBEditClick(Sender: TObject); begin if cds_main.IsEmpty then exit; if (cds_main.fieldbyname('Filler').AsString <> trim(DName)) and (trim(canshu2) <> '高权限') and (canshu1 <> '仓库') then begin application.MessageBox('操作员不正确,不能修改!', '提示信息', MB_ICONERROR); exit; end; with ADOQueryTmp do begin close; sql.Clear; sql.Add('select * from CK_Sample_CR where Chkstatus=''1'' '); SQL.Add('and inoutno=' + quotedstr(trim(cds_main.fieldbyname('inoutno').AsString))); SQL.Add('AND VALID=''Y'''); Open; end; if ADOQueryTmp.IsEmpty = False then begin application.MessageBox('请先撤销已审核的数据!', '提示信息', MB_ICONERROR); exit; end; frmJYGLCK := TfrmJYGLCK.create(self); with frmJYGLCK do begin fkeyNo := self.cds_main.fieldbyname('crno').AsString; // ShowMessage(fkeyNo); fxiugai := self.cds_main.fieldbyname('inoutno').AsString; fType := 1; InoutNo.Enabled := false; fCKName := trim(self.fCKName); if showmodal = 1 then begin TBRafresh.Click; self.CDS_Main.Locate('CRNO', trim(fkeyNo), []); end; free; end; end; procedure TfrmJYJSlist.TBDelClick(Sender: TObject); var YFID, CRID, note: string; begin if CDS_Main.IsEmpty then Exit; if canshu1 <> '仓库' then begin if Trim(CDS_Main.fieldbyname('Filler').AsString) <> Trim(DName) then begin Application.MessageBox('不能操作他人数据!', '提示', 0); Exit; end; end; with ADOQueryTmp do begin close; sql.Clear; sql.Add('select * from CK_Sample_CR where Chkstatus=''1'' '); SQL.Add('and inoutno=' + quotedstr(trim(cds_main.fieldbyname('inoutno').AsString))); SQL.Add('AND VALID=''Y'''); Open; end; if ADOQueryTmp.IsEmpty = False then begin application.MessageBox('请先撤销已审核的数据!', '提示信息', MB_ICONERROR); exit; end; if Application.MessageBox('确定要删除数据吗?', '提示', 32 + 4) <> IDYES then Exit; try if Trim(CDS_Main.FieldByName('CRNO').AsString) <> '' then begin ADOQueryCmd.Connection.BeginTrans; with ADOQueryCmd do begin Close; SQL.Clear; sql.Add('update CK_Sample_CR set Valid=''N'' where CRNO=' + quotedstr(Trim(CDS_Main.FieldByName('CRNO').AsString))); ExecSQL; end; with ADOQueryCmd do begin Close; SQL.Clear; SQL.Add('exec P_Up_SampleKc ' + quotedstr(trim(CDS_Main.fieldbyname('MJID').AsString))); Open; end; ADOQueryCmd.Connection.CommitTrans; CDS_Main.Delete; end; except Application.MessageBox('数据删除失败!', '提示信息', 0); end; end; procedure TfrmJYJSlist.TBRafreshClick(Sender: TObject); begin initGrid(); end; procedure TfrmJYJSlist.TBExportClick(Sender: TObject); begin if CDS_Main.IsEmpty then Exit; TcxGridToExcel(self.Caption, cxgrid1); end; procedure TfrmJYJSlist.v1Column6CompareRowValuesForCellMerging(Sender: TcxGridColumn; ARow1: TcxGridDataRow; AProperties1: TcxCustomEditProperties; const AValue1: Variant; ARow2: TcxGridDataRow; AProperties2: TcxCustomEditProperties; const AValue2: Variant; var AAreEqual: Boolean); var colIdx0, colIdx1: integer; begin colIdx0 := tv1.GetColumnByFieldName('CRNO').Index; if (ARow1.Values[colIdx0] = ARow2.Values[colIdx0]) then AAreEqual := True else AAreEqual := False; end; procedure TfrmJYJSlist.N1Click(Sender: TObject); begin SelOKNo(CDS_Main, True); end; procedure TfrmJYJSlist.N2Click(Sender: TObject); begin SelOKNo(CDS_Main, False); end; procedure TfrmJYJSlist.cxTabControl1Change(Sender: TObject); begin InitGrid(); end; procedure TfrmJYJSlist.tbChkClick(Sender: TObject); begin if CDS_Main.IsEmpty then exit; if CDS_Main.Locate('ssel', true, []) = false then begin Application.MessageBox('没有选择数据!', '提示', 0); Exit; end; try ADOQueryCmd.Connection.BeginTrans; with CDS_Main do begin DisableControls; First; while not eof do begin if Fieldbyname('ssel').AsBoolean then begin with ADOQueryCmd do begin close; sql.Clear; sql.Add('update CK_Sample_CR SET Chkstatus=''1'',Chktime=getdate(),Chker= ' + quotedstr(trim(DName))); sql.Add('where CRNO=' + quotedstr(trim(CDS_Main.fieldbyname('CRNO').AsString))); execsql; end; // with ADOQueryCmd do // begin // close; // sql.Clear; // sql.Add('select * from CK_Sample_CR '); // sql.Add('where crno=' + quotedstr(trim(CDS_Main.fieldbyname('crno').AsString))); // Open; // end; // if ADOQueryCmd.fieldbyname('mjid').AsString <> '' then // begin // with ADOQueryCmd do // begin // Close; // SQL.Clear; // SQL.Add('exec P_Up_SampleKc ' + quotedstr(trim(CDS_Main.fieldbyname('MJID').AsString))); // Open; // end; // end; end; next; end; First; EnableControls; end; ADOQueryCmd.Connection.CommitTrans; application.MessageBox('审核成功!', '提示信息'); TBRafresh.Click; except ADOQueryCmd.Connection.RollbackTrans; application.MessageBox('审核失败!', '提示信息', 0); end; end; procedure TfrmJYJSlist.tbChkNoClick(Sender: TObject); begin if CDS_Main.IsEmpty then exit; if CDS_Main.Locate('ssel', true, []) = false then begin Application.MessageBox('没有选择数据!', '提示', 0); Exit; end; try ADOQueryCmd.Connection.BeginTrans; with CDS_Main do begin DisableControls; First; while not eof do begin if Fieldbyname('ssel').AsBoolean then begin with ADOQueryCmd do begin close; sql.Clear; sql.Add('update CK_Sample_CR SET Chkstatus=''0'',Chktime=null , Chker=null '); sql.Add('where crno=' + quotedstr(trim(CDS_Main.fieldbyname('crno').AsString))); execsql; end; with ADOQueryCmd do begin Close; SQL.Clear; SQL.Add('exec P_Up_SampleKc ' + quotedstr(trim(CDS_Main.fieldbyname('MJID').AsString))); Open; end; end; next; end; First; EnableControls; end; ADOQueryCmd.Connection.CommitTrans; application.MessageBox('撤销审核成功!', '提示信息'); TBRafresh.Click; except ADOQueryCmd.Connection.RollbackTrans; application.MessageBox('撤销审核失败!', '提示信息', 0); end; end; procedure TfrmJYJSlist.btn1Click(Sender: TObject); begin frmJYGLCK := TfrmJYGLCK.create(self); with frmJYGLCK do begin fkeyNo := ''; fType := 0; fCKName := trim(self.fCKName); canshu1 := Self.canshu1; jyfs := '日常'; if showmodal = 1 then begin TBRafresh.Click; self.CDS_Main.Locate('crNo', trim(fkeyNo), []); end; free; end; end; procedure TfrmJYJSlist.ToolButton1Click(Sender: TObject); var fPrintFile: string; EngMoney: string; Porderno, LBName, SYRName: string; i, j: Integer; OrderKg: Double; FDate: string; Txt, fImagePath: string; Moudle: THandle; Makebar: TMakebar; Mixtext: TMixtext; begin if CDS_Main.IsEmpty then Exit; // if CDS_Main.Locate('SSel', True, []) = False then // begin // Application.MessageBox('没有选择数据', '提示', 0); // Exit; // end; ExportFtErpFile(Trim(ComboBox1.Text) + '.rmf', ADOQueryTmp); fPrintFile := ExtractFilePath(Application.ExeName) + 'Report\' + Trim(ComboBox1.Text) + '.rmf'; // with ADOQueryCmd do // begin // Close; // sql.Clear; // sql.Add('delete TBSubID where DName=''' + Trim(DCode) + ''''); // ExecSQL; // end; // with ADOQueryCmd do // begin // Close; // sql.Clear; // sql.Add('SELECT * FROM TBSubID where 1=2 '); // open; // end; // CDS_Main.DisableControls; // try // ADOQueryCmd.Connection.BeginTrans; // with CDS_Main do // begin // First; // while not Eof do // begin // if Fieldbyname('Ssel').AsBoolean then // begin // // ADOQueryCmd.append; // ADOQueryCmd.fieldbyname('SubId').Value := Trim(CDS_Main.fieldbyname('crno').AsString); // ADOQueryCmd.fieldbyname('Dname').Value := Trim(DCode); // ADOQueryCmd.post; // end; // Next; // end; // end; // ADOQueryCmd.Connection.CommitTrans; // except // ADOQueryCmd.Connection.RollbackTrans; // end; // CDS_Main.EnableControls; if ComboBox1.Text = '样品码单1' then begin with ADOPrint do begin Close; sql.Clear; SQL.Add('EXEC P_Print_YPMD' + QUOTEDSTR(Trim(CDS_Main.fieldbyname('INOUTNO').AsString))); Open; end; end else if ComboBox1.Text = '样品码单2' then begin with ADOPrint do begin Close; sql.Clear; SQL.Add('EXEC P_Print_YPMD2' + QUOTEDSTR(Trim(CDS_Main.fieldbyname('INOUTNO').AsString))); Open; end; end else if ComboBox1.Text = '色卡挂板码单' then begin with ADOPrint do begin Close; sql.Clear; SQL.Add('EXEC P_Print_YPMD2' + QUOTEDSTR(Trim(CDS_Main.fieldbyname('INOUTNO').AsString))); Open; end; end; if FileExists(fPrintFile) then begin RMVariables['CustomerNoName'] := CDS_Main.fieldbyname('ToFactoryName').AsString; RMVariables['ShouHuoer'] := CDS_Main.fieldbyname('SHer').AsString; RMVariables['KHDH'] := CDS_Main.fieldbyname('SHDianHua').AsString; RMVariables['FHDZ'] := CDS_Main.fieldbyname('SHDiZhi').AsString; RMVariables['filler'] := CDS_Main.fieldbyname('filler').AsString; RMVariables['NOTE'] := CDS_Main.fieldbyname('ZBZNOTE').AsString; RMVariables['crtime'] := CDS_Main.fieldbyname('CRTime').AsDateTime; RMVariables['YWY'] := CDS_Main.fieldbyname('SALESMAN').AsString; RMVariables['SQDLX'] := CDS_Main.fieldbyname('CPLeiBie').AsString; //RMVariables['enddate']:=enddate.DateTime; try Moudle := LoadLibrary('MakeQRBarcode.dll'); @Makebar := GetProcAddress(Moudle, 'Make'); @Mixtext := GetProcAddress(Moudle, 'MixText'); Txt := Trim((trim(CDS_Main.fieldbyname('inoutno').AsString))); 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('条形码生成失败!', '提示信息', MB_ICONERROR); exit; end; RM1.LoadFromFile(fPrintFile); RMVariables['QRBARCODE'] := fImagePath; RM1.ShowReport; end else begin Application.MessageBox(PChar('没有找' + fPrintFile), '提示', 0); end; end; procedure TfrmJYJSlist.btnJieShouClick(Sender: TObject); begin if CDS_Main.IsEmpty then exit; if CDS_Main.Locate('ssel', true, []) = false then begin Application.MessageBox('没有选择数据!', '提示', 0); Exit; end; MovePanel1.VISIBLE := True; end; procedure TfrmJYJSlist.JSYPropertiesButtonClick(Sender: TObject; AButtonIndex: Integer); begin try frmZDYHelp := TfrmZDYHelp.Create(Application); with frmZDYHelp do begin flag := 'JSPERSON'; flagname := '接收人'; if ShowModal = 1 then begin JSY.TEXT := Trim(frmZDYHelp.ClientDataSet1.fieldbyname('ZdyName').AsString); end; end; finally frmZDYHelp.Free; end; end; procedure TfrmJYJSlist.Button2Click(Sender: TObject); begin MovePanel1.visible := False; end; procedure TfrmJYJSlist.Button1Click(Sender: TObject); var fPrintFile: string; EngMoney: string; Porderno, LBName, SYRName: string; i, j: Integer; OrderKg: Double; FDate: string; Txt, fImagePath: string; Moudle: THandle; Makebar: TMakebar; Mixtext: TMixtext; begin if JSY.Text = '' then begin application.MessageBox('请先选择接收人!', '提示信息'); Exit; end; try ADOQueryCmd.Connection.BeginTrans; with CDS_Main do begin with ADOQueryCmd do begin Close; sql.Clear; // sql.Add(' select A.* '); // SQL.Add(' from CK_Sample_CR A '); // sql.Add(' where CRFlag=''出库'' and A.valid=''Y'' '); // sql.Add(' and VisType=''寄样'' '); // SQL.Add('and crno=' + quotedstr(Trim(CDS_Main.fieldbyname('crno').AsString))); sql.Add(' select A.* '); SQL.Add(' from CK_Sample_CR A '); sql.Add(' where CRFlag=''出库'' and A.valid=''Y'' '); sql.Add(' and VisType=''寄样'' and CKName=' + quotedstr(trim(fCKName))); sql.Add(' and isnull(A.Chkstatus,''-1'')=''0'''); sql.Add('and a.jsperson is null '); SQL.Add('and crno=' + quotedstr(Trim(CDS_Main.fieldbyname('crno').AsString))); Open; end; if ADOQueryCmd.IsEmpty = True then begin ADOQueryCmd.Connection.RollbackTrans; application.MessageBox('该布已未在已提交状态', '提示信息'); Exit; end; with ADOQueryCmd do begin close; sql.Clear; sql.Add('update CK_Sample_CR SET jsperson=' + quotedstr(Trim(JSY.Text))); sql.Add(',jstime=getdate() '); sql.Add('where CRNO=' + quotedstr(trim(CDS_Main.fieldbyname('CRNO').AsString))); execsql; end; if (CDS_Main.Fieldbyname('CKLX').ASSTRING <> '成品仓库') then begin ExportFtErpFile('样品入库标签.rmf', ADOQueryTmp); fPrintFile := ExtractFilePath(Application.ExeName) + 'Report\样品入库标签.rmf'; with ADOPrint do begin Close; sql.Clear; sql.Add(' select A.* '); SQL.Add(' from CK_Sample_CR A '); sql.Add(' where CRFlag=''出库'' and A.valid=''Y'' '); sql.Add(' and VisType=''寄样'' '); SQL.Add('and crno=' + quotedstr(Trim(CDS_Main.fieldbyname('crno').AsString))); Open; end; if FileExists(fPrintFile) then begin try Moudle := LoadLibrary('MakeQRBarcode.dll'); @Makebar := GetProcAddress(Moudle, 'Make'); @Mixtext := GetProcAddress(Moudle, 'MixText'); Txt := Trim((trim(CDS_Main.fieldbyname('crno').AsString))); 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('条形码生成失败!', '提示信息', MB_ICONERROR); exit; end; RM1.LoadFromFile(fPrintFile); RMVariables['QRBARCODE'] := fImagePath; RM1.ShowReport; end else begin Application.MessageBox(PChar('没有找' + fPrintFile), '提示', 0); end; end; end; ADOQueryCmd.Connection.CommitTrans; application.MessageBox('接收成功!', '提示信息'); MovePanel1.visible := False; TBRafresh.Click; except ADOQueryCmd.Connection.RollbackTrans; application.MessageBox('接收失败!', '提示信息', 0); end; end; procedure TfrmJYJSlist.ToolButton3Click(Sender: TObject); begin try ADOQueryCmd.Connection.BeginTrans; with CDS_Main do begin DisableControls; First; while not eof do begin if Fieldbyname('ssel').AsBoolean then begin with ADOQueryCmd do begin close; sql.Clear; sql.Add('update CK_Sample_CR SET jsperson=NULL'); sql.Add(',jstime=NULL'); sql.Add('where CRNO=' + quotedstr(trim(CDS_Main.fieldbyname('CRNO').AsString))); execsql; end; end; next; end; First; EnableControls; end; ADOQueryCmd.Connection.CommitTrans; application.MessageBox('撤销成功!', '提示信息'); TBRafresh.Click; except ADOQueryCmd.Connection.RollbackTrans; application.MessageBox('撤销失败!', '提示信息', 0); end; end; procedure TfrmJYJSlist.ToolButton4Click(Sender: TObject); var fPrintFile: string; EngMoney: string; Porderno, LBName, SYRName: string; i, j: Integer; OrderKg: Double; FDate: string; Txt, fImagePath: string; Moudle: THandle; Makebar: TMakebar; Mixtext: TMixtext; begin if CDS_Main.IsEmpty then Exit; if CDS_Main.Locate('SSel', True, []) = False then begin Application.MessageBox('没有选择数据', '提示', 0); Exit; end; with ADOQueryCmd do begin Close; sql.Clear; sql.Add('delete TBSubID where DName=''' + Trim(DCode) + ''''); ExecSQL; end; with ADOQueryCmd do begin Close; sql.Clear; sql.Add('SELECT * FROM TBSubID where 1=2 '); open; end; CDS_Main.DisableControls; try ADOQueryCmd.Connection.BeginTrans; with CDS_Main do begin First; while not Eof do begin if Fieldbyname('Ssel').AsBoolean then begin ADOQueryCmd.append; ADOQueryCmd.fieldbyname('SubId').Value := Trim(CDS_Main.fieldbyname('crno').AsString); ADOQueryCmd.fieldbyname('Dname').Value := Trim(DCode); ADOQueryCmd.post; end; Next; end; end; ADOQueryCmd.Connection.CommitTrans; except ADOQueryCmd.Connection.RollbackTrans; end; CDS_Main.EnableControls; ExportFtErpFile('样品入库标签.rmf', ADOQueryTmp); fPrintFile := ExtractFilePath(Application.ExeName) + 'Report\样品入库标签.rmf'; try ADOQueryCmd.Connection.BeginTrans; with CDS_Main do begin First; while not Eof do begin if Fieldbyname('Ssel').AsBoolean then begin with ADOPrint do begin Close; sql.Clear; sql.Add(' select A.* '); SQL.Add(' from CK_Sample_CR A '); sql.Add(' where CRFlag=''出库'' and A.valid=''Y'' '); sql.Add(' and VisType=''寄样'' '); SQL.Add('and crno=' + quotedstr(Trim(CDS_Main.fieldbyname('crno').AsString))); // sql.Add('and EXISTS(select SubId from TBSubID X where X.SubId=A.crno and X.DName=' + quotedstr(Trim(DCode))); // sql.Add(')'); // ShowMessage(sql.Text); Open; end; if FileExists(fPrintFile) then begin // RMVariables['EngMoney']:=EngMoney; //RMVariables['enddate']:=enddate.DateTime; try Moudle := LoadLibrary('MakeQRBarcode.dll'); @Makebar := GetProcAddress(Moudle, 'Make'); @Mixtext := GetProcAddress(Moudle, 'MixText'); Txt := Trim((trim(CDS_Main.fieldbyname('crno').AsString))); 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('条形码生成失败!', '提示信息', MB_ICONERROR); exit; end; RM1.LoadFromFile(fPrintFile); RMVariables['QRBARCODE'] := fImagePath; RM1.ShowReport; end else begin Application.MessageBox(PChar('没有找' + fPrintFile), '提示', 0); end; end; Next; end; end; ADOQueryCmd.Connection.CommitTrans; except ADOQueryCmd.Connection.RollbackTrans; end; end; procedure TfrmJYJSlist.btnTJClick(Sender: TObject); begin if CDS_Main.IsEmpty then exit; if CDS_Main.Locate('ssel', true, []) = false then begin Application.MessageBox('没有选择数据!', '提示', 0); Exit; end; try ADOQueryCmd.Connection.BeginTrans; with CDS_Main do begin DisableControls; First; while not eof do begin if Fieldbyname('ssel').AsBoolean then begin with ADOQueryCmd do begin close; sql.Clear; sql.Add('update CK_Sample_CR SET Chkstatus=''0'' '); sql.Add('where CRNO=' + quotedstr(trim(CDS_Main.fieldbyname('CRNO').AsString))); execsql; end; end; next; end; First; EnableControls; end; ADOQueryCmd.Connection.CommitTrans; application.MessageBox('提交成功!', '提示信息'); TBRafresh.Click; except ADOQueryCmd.Connection.RollbackTrans; application.MessageBox('提交失败!', '提示信息', 0); end; end; procedure TfrmJYJSlist.btnTJCXClick(Sender: TObject); begin if CDS_Main.IsEmpty then exit; if CDS_Main.Locate('ssel', true, []) = false then begin Application.MessageBox('没有选择数据!', '提示', 0); Exit; end; try ADOQueryCmd.Connection.BeginTrans; with CDS_Main do begin DisableControls; First; while not eof do begin if Fieldbyname('ssel').AsBoolean then begin with ADOQueryCmd do begin close; sql.Clear; sql.Add('update CK_Sample_CR SET Chkstatus=''-1'' '); sql.Add('where CRNO=' + quotedstr(trim(CDS_Main.fieldbyname('CRNO').AsString))); execsql; end; end; next; end; First; EnableControls; end; ADOQueryCmd.Connection.CommitTrans; application.MessageBox('提交成功!', '提示信息'); TBRafresh.Click; except ADOQueryCmd.Connection.RollbackTrans; application.MessageBox('提交失败!', '提示信息', 0); end; end; procedure TfrmJYJSlist.btn2Click(Sender: TObject); var fPrintFile: string; Txt, fImagePath: string; Moudle: THandle; Makebar: TMakebar; Mixtext: TMixtext; begin if CDS_Main.Locate('SSel', True, []) = False then begin Application.MessageBox('没有选择数据!', '提示', 0); Exit; end; try ADOQueryCmd.Connection.BeginTrans; with CDS_Main do begin DisableControls; First; while not eof do begin if (cds_main.Fieldbyname('ssel').AsBoolean = true) and (cds_main.fieldbyname('CKLX').AsString = trim('成品仓库')) and (cds_main.fieldbyname('ISSQ').AsBoolean <> True) then begin with ADOQueryCmd do begin Close; SQL.Clear; SQL.Add('exec P_DO_SCDYSCD @crno=' + quotedstr(trim(CDS_Main.fieldbyname('crno').AsString))); SQL.Add(',@dname=' + quotedstr(trim(DName))); ExecSQL; // ShowMessage(sql.Text); end; with ADOPrint do begin Close; sql.Clear; sql.Add('select a.*,fsid=(select top 1 fsid from fhsq_sub v where v.FROMYPID=a.crno) from CK_Sample_CR a where crno=' + quotedstr(Trim(CDS_Main.fieldbyname('crno').AsString))); // SQL.Add('EXEC P_Print_dysqd4 @FSID=' + quotedstr(Trim(CDS_Main.fieldbyname('CRNO').AsString))); // ShowMessage(SQL.Text); Open; end; try Moudle := LoadLibrary('MakeQRBarcode.dll'); @Makebar := GetProcAddress(Moudle, 'Make'); @Mixtext := GetProcAddress(Moudle, 'MixText'); Txt := Trim(ADOPrint.fieldbyname('fsid').AsString); 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('条形码生成失败!', '提示信息', MB_ICONERROR); exit; end; ExportFtErpFile('调成品单.rmf', ADOQueryTmp); fPrintFile := ExtractFilePath(Application.ExeName) + 'Report\调成品单.rmf'; if FileExists(fPrintFile) then begin RMVariables['QRBARCODE'] := fImagePath; RM1.LoadFromFile(fPrintFile); RM1.PrintReport; end else begin CDS_Main.EnableControls; Application.MessageBox(PChar('没有找' + fPrintFile), '提示', 0); Exit; end; end; next; end; // First; EnableControls; end; ADOQueryCmd.Connection.CommitTrans; application.MessageBox('生成成功!', '提示信息'); TBRafresh.Click; except ADOQueryCmd.Connection.RollbackTrans; application.MessageBox('生成失败!', '提示信息', 0); end; // try // // ADOQueryCmd.Connection.BeginTrans; // with ADOQueryCmd do // begin // Close; // SQL.Clear; // SQL.Add('exec P_DO_SCDYSCD @crno=' + quotedstr(trim(CDS_Main.fieldbyname('crno').AsString))); // SQL.Add(',@dname=' + quotedstr(trim(DName))); // ExecSQL; // end; // ADOQueryCmd.Connection.CommitTrans; //// if Application.MessageBox('生成完成是否打印调样单', '提示', 32 + 4) = IDYES then //// begin //// PrintCKMDG(Trim(CDS_Main.fieldbyname('crno').AsString)); //// end; // InitGrid(); // except // Application.MessageBox('数据删除失败!', '提示信息', 0); // end; end; procedure TfrmJYJSlist.ToolButton2Click(Sender: TObject); var fPrintFile: string; Txt, fImagePath: string; Moudle: THandle; Makebar: TMakebar; Mixtext: TMixtext; begin if CDS_Main.IsEmpty then Exit; // if CDS_Main.fieldbyname('ISSQ').AsBoolean <> TRUE then // begin // application.MessageBox('未生成调样申请!', '提示信息', MB_ICONERROR); // exit; // end; if CDS_Main.Locate('SSel', True, []) = False then begin Application.MessageBox('没有选择数据!', '提示', 0); Exit; end; CDS_Main.DisableControls; with CDS_Main do begin First; while not Eof do begin if CDS_Main.FieldByName('SSel').AsBoolean = True then begin with ADOPrint do begin Close; sql.Clear; sql.Add('select a.*,fsid=(select top 1 fsid from fhsq_sub v where v.FROMYPID=a.crno) from CK_Sample_CR a where crno=' + quotedstr(Trim(CDS_Main.fieldbyname('crno').AsString))); // SQL.Add('EXEC P_Print_dysqd4 @FSID=' + quotedstr(Trim(CDS_Main.fieldbyname('CRNO').AsString))); // ShowMessage(SQL.Text); Open; end; try Moudle := LoadLibrary('MakeQRBarcode.dll'); @Makebar := GetProcAddress(Moudle, 'Make'); @Mixtext := GetProcAddress(Moudle, 'MixText'); Txt := Trim(ADOPrint.fieldbyname('fsid').AsString); 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('条形码生成失败!', '提示信息', MB_ICONERROR); exit; end; ExportFtErpFile('调成品单.rmf', ADOQueryTmp); fPrintFile := ExtractFilePath(Application.ExeName) + 'Report\调成品单.rmf'; if FileExists(fPrintFile) then begin RMVariables['QRBARCODE'] := fImagePath; RM1.LoadFromFile(fPrintFile); RM1.PrintReport; end else begin CDS_Main.EnableControls; Application.MessageBox(PChar('没有找' + fPrintFile), '提示', 0); Exit; end; end; Next; end; end; CDS_Main.EnableControls; end; procedure TfrmJYJSlist.Button3Click(Sender: TObject); var fPrintFile: string; EngMoney: string; Porderno, LBName, SYRName: string; i, j: Integer; OrderKg: Double; FDate, fcrno: string; Txt, fImagePath: string; Moudle: THandle; Makebar: TMakebar; Mixtext: TMixtext; begin if CDS_Main.IsEmpty then exit; fcrno := CDS_Main.fieldbyname('CRNO').AsString; if fcrno = '' then Exit; Timer2.Enabled := False; Button3.Enabled := False; try ADOQueryCmd.Connection.BeginTrans; with CDS_Main do begin with ADOQueryCmd do begin close; sql.Clear; sql.Add('update CK_Sample_CR SET jsperson=' + quotedstr(Trim(DName))); sql.Add(',jstime=getdate()'); sql.Add('where CRNO=' + quotedstr(trim(fcrno))); // ShowMessage(sql.Text); execsql; end; if (CDS_Main.Fieldbyname('CKLX').ASSTRING <> '成品仓库') then begin ExportFtErpFile('样品入库标签.rmf', ADOQueryTmp); fPrintFile := ExtractFilePath(Application.ExeName) + 'Report\样品入库标签.rmf'; with ADOPrint do begin Close; sql.Clear; sql.Add(' select A.* '); SQL.Add(' from CK_Sample_CR A '); sql.Add(' where CRFlag=''出库'' and A.valid=''Y'' '); sql.Add(' and VisType=''寄样'' '); SQL.Add('and crno=' + quotedstr(Trim(fcrno))); Open; end; if FileExists(fPrintFile) then begin try Moudle := LoadLibrary('MakeQRBarcode.dll'); @Makebar := GetProcAddress(Moudle, 'Make'); @Mixtext := GetProcAddress(Moudle, 'MixText'); Txt := Trim((trim(CDS_Main.fieldbyname('crno').AsString))); 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('条形码生成失败!', '提示信息', MB_ICONERROR); exit; end; RMVariables['QRBARCODE'] := fImagePath; RM1.DefaultCopies := 1; RM1.LoadFromFile(fPrintFile); RM1.PrintReport; end else begin Application.MessageBox(PChar('没有找' + fPrintFile), '提示', 0); end; end else if (CDS_Main.Fieldbyname('CKLX').ASSTRING = '成品仓库') then begin // Application.MessageBox('是否生成板房调样申请单', '提示', 0); with ADOQueryTmp do begin Close; SQL.Clear; sql.Add('select * from fhsq_sub where fromypid=' + quotedstr(Trim(fcrno))); Open; end; if ADOQueryTmp.IsEmpty = False then begin Application.MessageBox('已生成', '提示', 0); end else begin with CDS_Main do begin with ADOQueryCmd do begin Close; SQL.Clear; SQL.Add('exec P_DO_SCDYSCD @crno=' + quotedstr(trim(fcrno))); SQL.Add(',@dname=' + quotedstr(trim(DName))); ExecSQL; // ShowMessage(sql.Text); end; with ADOPrint do begin Close; sql.Clear; sql.Add('select a.*,fsid=(select top 1 fsid from fhsq_sub v where v.FROMYPID=a.crno) from CK_Sample_CR a where crno=' + quotedstr(Trim(fcrno))); Open; end; if ADOPrint.IsEmpty = False then begin try Moudle := LoadLibrary('MakeQRBarcode.dll'); @Makebar := GetProcAddress(Moudle, 'Make'); @Mixtext := GetProcAddress(Moudle, 'MixText'); Txt := Trim(ADOPrint.fieldbyname('fsid').AsString); 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('条形码生成失败!', '提示信息', MB_ICONERROR); exit; end; ExportFtErpFile('调成品单.rmf', ADOQueryTmp); fPrintFile := ExtractFilePath(Application.ExeName) + 'Report\调成品单.rmf'; if FileExists(fPrintFile) then begin RMVariables['QRBARCODE'] := fImagePath; RM1.DefaultCopies := 1; RM1.LoadFromFile(fPrintFile); RM1.PrintReport; end else begin CDS_Main.EnableControls; Application.MessageBox(PChar('没有找' + fPrintFile), '提示', 0); Exit; end; end; EnableControls; end; end; end; end; ADOQueryCmd.Connection.CommitTrans; CDS_Main.Delete; // application.MessageBox('接收成功!', '提示信息'); // MovePanel1.visible := False; TBRafresh.Click; CDS_Main.First; except ADOQueryCmd.Connection.RollbackTrans; application.MessageBox('接收失败!', '提示信息', 0); end; // try // frmjsPerson := TfrmjsPerson.Create(self); // with frmJSPerson do // begin // // if ShowModal = 1 then // begin //// JSY.Text:= // try // // ADOQueryCmd.Connection.BeginTrans; // with CDS_Main do // begin // // with ADOQueryCmd do // begin // close; // sql.Clear; // sql.Add('update CK_Sample_CR SET jsperson=' + quotedstr(Trim(frmjsPerson.FSDPerson))); // sql.Add(',jstime=getdate()'); // sql.Add('where CRNO=' + quotedstr(trim(CDS_Main.fieldbyname('CRNO').AsString))); //// ShowMessage(sql.Text); // execsql; // end; // if (CDS_Main.Fieldbyname('CKLX').ASSTRING <> '成品仓库') then // begin // ExportFtErpFile('样品入库标签.rmf', ADOQueryTmp); // fPrintFile := ExtractFilePath(Application.ExeName) + 'Report\样品入库标签.rmf'; // with ADOPrint do // begin // Close; // sql.Clear; // sql.Add(' select A.* '); // SQL.Add(' from CK_Sample_CR A '); // sql.Add(' where CRFlag=''出库'' and A.valid=''Y'' '); // sql.Add(' and VisType=''寄样'' '); // SQL.Add('and crno=' + quotedstr(Trim(CDS_Main.fieldbyname('crno').AsString))); // Open; // end; // if FileExists(fPrintFile) then // begin // // try // Moudle := LoadLibrary('MakeQRBarcode.dll'); // @Makebar := GetProcAddress(Moudle, 'Make'); // @Mixtext := GetProcAddress(Moudle, 'MixText'); // Txt := Trim((trim(CDS_Main.fieldbyname('crno').AsString))); // 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('条形码生成失败!', '提示信息', MB_ICONERROR); // exit; // end; // RM1.LoadFromFile(fPrintFile); // RMVariables['QRBARCODE'] := fImagePath; // RM1.PrintReport; // end // else // begin // Application.MessageBox(PChar('没有找' + fPrintFile), '提示', 0); // end; // end // else if (CDS_Main.Fieldbyname('CKLX').ASSTRING = '成品仓库') then // begin //// Application.MessageBox('是否生成板房调样申请单', '提示', 0); // with ADOQueryTmp do // begin // Close; // SQL.Clear; // sql.Add('select * from fhsq_sub where fromypid=' + quotedstr(Trim(CDS_Main.fieldbyname('crno').AsString))); // Open; // end; // if ADOQueryTmp.IsEmpty = False then // begin // Application.MessageBox('已生成', '提示', 0); // // end // else // begin // // with CDS_Main do // begin // with ADOQueryCmd do // begin // Close; // SQL.Clear; // SQL.Add('exec P_DO_SCDYSCD @crno=' + quotedstr(trim(CDS_Main.fieldbyname('crno').AsString))); // SQL.Add(',@dname=' + quotedstr(trim(DName))); // ExecSQL; //// ShowMessage(sql.Text); // end; // with ADOPrint do // begin // Close; // sql.Clear; // sql.Add('select a.*,fsid=(select top 1 fsid from fhsq_sub v where v.FROMYPID=a.crno) from CK_Sample_CR a where crno=' + quotedstr(Trim(CDS_Main.fieldbyname('crno').AsString))); // Open; // end; // if ADOPrint.IsEmpty = False then // begin // try // Moudle := LoadLibrary('MakeQRBarcode.dll'); // @Makebar := GetProcAddress(Moudle, 'Make'); // @Mixtext := GetProcAddress(Moudle, 'MixText'); // Txt := Trim(ADOPrint.fieldbyname('fsid').AsString); // 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('条形码生成失败!', '提示信息', MB_ICONERROR); // exit; // end; // // ExportFtErpFile('调成品单.rmf', ADOQueryTmp); // fPrintFile := ExtractFilePath(Application.ExeName) + 'Report\调成品单.rmf'; // // if FileExists(fPrintFile) then // begin // RMVariables['QRBARCODE'] := fImagePath; // // RM1.LoadFromFile(fPrintFile); // // RM1.PrintReport; // end // else // begin // CDS_Main.EnableControls; // Application.MessageBox(PChar('没有找' + fPrintFile), '提示', 0); // Exit; // end; // // end; // EnableControls; // end; // // end; // end; // // end; // ADOQueryCmd.Connection.CommitTrans; //// application.MessageBox('接收成功!', '提示信息'); // MovePanel1.visible := False; // // TBRafresh.Click; // CDS_Main.First; // except // ADOQueryCmd.Connection.RollbackTrans; // application.MessageBox('接收失败!', '提示信息', 0); // end; // // end; // end; // finally // frmJSPerson.Free; // end; Timer2.Enabled := True; end; procedure TfrmJYJSlist.Timer2Timer(Sender: TObject); begin InitZD(); // try // with ADOQueryMain do // begin // close; // sql.Clear; // sql.Add(' select A.*,row_number() over(order by A.crno) as rownumber '); //// sql.Add(',ISSQ=cast((case when isnull((select count(FROMYPID) from FHSQ_SUB X where X.FROMYPID=A.CRNO ),0)>0 then 1 else 0 end) as bit)'); // // SQL.Add(' from CK_Sample_CR A '); // sql.Add(' where CRFlag=''出库'' and A.valid=''Y'' '); // sql.Add(' and VisType=''寄样'' and CKName=' + quotedstr(trim(fCKName))); // sql.Add(' and isnull(A.Chkstatus,''-1'')=''0'''); // sql.Add('and a.jsperson is null'); //// ShowMessage(sql.Text); // open; // end; // // SInitCDSData20(ADOQueryMain, CDS_Main); // finally // end; end; procedure TfrmJYJSlist.Tv1MouseLeave(Sender: TObject); begin Timer2.Enabled := false; end; procedure TfrmJYJSlist.Tv1CustomDrawCell(Sender: TcxCustomGridTableView; ACanvas: TcxCanvas; AViewInfo: TcxGridTableDataCellViewInfo; var ADone: Boolean); begin // if (AViewInfo.GridRecord.Values[TcxGridDBTableView(Sender).GetColumnByFieldName('rownumber').Index]) mod 2 = 0 then // begin // ACanvas.font.Color := $EEF5FF; // end // else // begin // ACanvas.font.Color := $FFF8F0; // end; end; procedure TfrmJYJSlist.Tv1FocusedRecordChanged(Sender: TcxCustomGridTableView; APrevFocusedRecord, AFocusedRecord: TcxCustomGridRecord; ANewItemRecordFocusingChanged: Boolean); begin fcrno := CDS_Main.fieldbyname('CRNO').AsString; end; procedure TfrmJYJSlist.Tv1MouseDown(Sender: TObject; Button: TMouseButton; Shift: TShiftState; X, Y: Integer); begin if CDS_Main.fieldbyname('CRNO').AsString = '' then Exit; fcrno := CDS_Main.fieldbyname('CRNO').AsString; end; procedure TfrmJYJSlist.Button4Click(Sender: TObject); var fPrintFile: string; Txt, fImagePath: string; Moudle: THandle; Makebar: TMakebar; Mixtext: TMixtext; begin if cds_main.fieldbyname('CKLX').AsString <> trim('成品仓库') then begin application.MessageBox('非成品仓库不能生成!', '提示信息', MB_ICONERROR); exit; end; with ADOQueryTmp do begin Close; SQL.Clear; sql.Add('select * from fhsq_sub where fromypid=' + quotedstr(Trim(CDS_Main.fieldbyname('crno').AsString))); Open; end; if ADOQueryTmp.IsEmpty = False then begin if Application.MessageBox('已生成调样单,是否直接打印?', '提示', 32 + 4) <> IDYES then begin Exit; end else begin with ADOPrint do begin Close; sql.Clear; sql.Add('select a.*,fsid=(select top 1 fsid from fhsq_sub v where v.FROMYPID=a.crno) from CK_Sample_CR a where crno=' + quotedstr(Trim(CDS_Main.fieldbyname('crno').AsString))); Open; end; try Moudle := LoadLibrary('MakeQRBarcode.dll'); @Makebar := GetProcAddress(Moudle, 'Make'); @Mixtext := GetProcAddress(Moudle, 'MixText'); Txt := Trim(ADOPrint.fieldbyname('fsid').AsString); 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('条形码生成失败!', '提示信息', MB_ICONERROR); exit; end; ExportFtErpFile('调成品单.rmf', ADOQueryTmp); fPrintFile := ExtractFilePath(Application.ExeName) + 'Report\调成品单.rmf'; if FileExists(fPrintFile) then begin RMVariables['QRBARCODE'] := fImagePath; RM1.LoadFromFile(fPrintFile); RM1.PrintReport; end else begin CDS_Main.EnableControls; Application.MessageBox(PChar('没有找' + fPrintFile), '提示', 0); Exit; end; end; end else begin try ADOQueryCmd.Connection.BeginTrans; with CDS_Main do begin with ADOQueryCmd do begin Close; SQL.Clear; SQL.Add('exec P_DO_SCDYSCD @crno=' + quotedstr(trim(CDS_Main.fieldbyname('crno').AsString))); SQL.Add(',@dname=' + quotedstr(trim(DName))); ExecSQL; // ShowMessage(sql.Text); end; with ADOPrint do begin Close; sql.Clear; sql.Add('select a.*,fsid=(select top 1 fsid from fhsq_sub v where v.FROMYPID=a.crno) from CK_Sample_CR a where crno=' + quotedstr(Trim(CDS_Main.fieldbyname('crno').AsString))); Open; end; try Moudle := LoadLibrary('MakeQRBarcode.dll'); @Makebar := GetProcAddress(Moudle, 'Make'); @Mixtext := GetProcAddress(Moudle, 'MixText'); Txt := Trim(ADOPrint.fieldbyname('fsid').AsString); 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('条形码生成失败!', '提示信息', MB_ICONERROR); exit; end; ExportFtErpFile('调成品单.rmf', ADOQueryTmp); fPrintFile := ExtractFilePath(Application.ExeName) + 'Report\调成品单.rmf'; if FileExists(fPrintFile) then begin RMVariables['QRBARCODE'] := fImagePath; RM1.LoadFromFile(fPrintFile); RM1.PrintReport; end else begin CDS_Main.EnableControls; Application.MessageBox(PChar('没有找' + fPrintFile), '提示', 0); Exit; end; EnableControls; end; ADOQueryCmd.Connection.CommitTrans; application.MessageBox('生成成功!', '提示信息'); TBRafresh.Click; except ADOQueryCmd.Connection.RollbackTrans; application.MessageBox('生成失败!', '提示信息', 0); end; end; // First; end; procedure TfrmJYJSlist.FormDestroy(Sender: TObject); begin frmJYJSlist := nil; end; procedure TfrmJYJSlist.Button5Click(Sender: TObject); begin InitGrid(); Timer2.Enabled := True; end; end.