unit U_MachRollMain; interface uses Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants, System.Classes, Vcl.Graphics, mmsystem, Vcl.Controls, Vcl.Forms, Vcl.Dialogs, cxGraphics, cxControls, cxLookAndFeels, cxLookAndFeelPainters, cxClasses, dxLayoutContainer, dxLayoutControl, dxLayoutcxEditAdapters, cxContainer, cxEdit, Vcl.StdCtrls, cxTextEdit, Vcl.ExtCtrls, dxLayoutControlAdapters, U_BaseList, Data.DB, Data.Win.ADODB, Vcl.Buttons, Vcl.ComCtrls, Vcl.ToolWin, cxImage, cxDBEdit, cxStyles, cxCustomData, cxFilter, cxData, cxDataStorage, cxNavigator, dxDateRanges, dxScrollbarAnnotations, cxDBData, dxBarBuiltInMenu, cxPC, cxGridLevel, cxGridCustomTableView, cxGridTableView, cxGridDBTableView, cxGridCustomView, cxGrid, cxMemo, cxRichEdit, U_frameBads, Datasnap.DBClient, RM_Common, RM_Class, RM_GridReport, cxCheckBox, cxMaskEdit, cxDropDownEdit, Vcl.Menus, cxButtonEdit, RM_Dataset, cxGeometry, dxFramedControl, dxPanel, U_KeyBoard, cxGroupBox, cxGridCustomPopupMenu, cxGridPopupMenu, MovePanel, RM_RichEdit, cxProgressBar, cxCurrencyEdit, dxSkinsCore, frxBarcode, frxRich, frxOLE, frxTableObject, frxExportXLSX, frxClass, frxExportBaseDialog, frxExportPPTX, frxDBSet, dxSkinWXI, dxSkinsDefaultPainters, System.StrUtils, imm, cxLookupEdit, cxDBLookupEdit, cxDBLookupComboBox; type TfrmMachRollMain = class(TfrmBaseList) Panel_right: TPanel; cds_params: TClientDataSet; cds_paramsdabao: TStringField; cds_paramspackRolls: TIntegerField; cds_paramsrollNoMake: TStringField; cds_paramsMinWeight: TIntegerField; cds_paramsMaxWeight: TIntegerField; cds_paramslblLenUnit: TStringField; cds_paramsMinLen: TIntegerField; cds_paramsmaxLen: TIntegerField; cds_paramsweightRule: TIntegerField; cds_paramschen: TStringField; cds_paramsmabiao: TStringField; cds_paramsmbunit: TStringField; cds_paramsmplace: TIntegerField; cds_paramsyplace: TIntegerField; cds_paramskgplace: TIntegerField; cds_paramslabNumber: TIntegerField; CDS_2: TClientDataSet; DS_2: TDataSource; cds_1: TClientDataSet; cds_3: TClientDataSet; ds_3: TDataSource; ds_1: TDataSource; ADOQueryMain: TADOQuery; cds_paramsoutPage: TStringField; ADOQueryPrint: TADOQuery; cds_paramsEndPieceNo: TIntegerField; cds_paramsBeginPieceNo: TIntegerField; cds_paramsFixedLength: TIntegerField; cds_paramspacknoMake: TStringField; cds_paramspieceOrder: TBooleanField; cds_paramsLabVolume: TStringField; cds_paramsLabPackage: TStringField; cxGroupBox_keys: TcxGroupBox; FrameKeyBoard1: TFrameKeyBoard; cds_paramsAddwetPresent: TFloatField; cds_paramsAddLenPresent: TFloatField; GPM_3: TcxGridPopupMenu; ADOQueryImage: TADOQuery; DS_IMAGE: TDataSource; cds_paramspackPrintPreview: TBooleanField; cds_paramspacklabNumber: TIntegerField; cds_paramspackPostAction: TStringField; ADO_CJ: TADOQuery; fRMDB_1: TfrxDBDataset; frxReport1: TfrxReport; frxPPTXExport1: TfrxPPTXExport; frxXLSXExport1: TfrxXLSXExport; frxReportTableObject1: TfrxReportTableObject; frxOLEObject1: TfrxOLEObject; frxRichObject1: TfrxRichObject; frxBarCodeObject1: TfrxBarCodeObject; cxGrid2: TcxGrid; TV2: TcxGridDBTableView; cxGridDBColumn1: TcxGridDBColumn; TV2Column1: TcxGridDBColumn; TV2Column2: TcxGridDBColumn; v1PRTColor: TcxGridDBColumn; v1PRTOrderQty: TcxGridDBColumn; v1OrderUnit: TcxGridDBColumn; cxGridDBColumn7: TcxGridDBColumn; cxGridLevel1: TcxGridLevel; TV2Column3: TcxGridDBColumn; TV2Column4: TcxGridDBColumn; ADO_2: TADOQuery; TV2Column5: TcxGridDBColumn; TV2Column7: TcxGridDBColumn; Panel1: TPanel; edtScan: TcxTextEdit; Label1: TLabel; OrderNo: TcxTextEdit; ColorNo: TcxTextEdit; FtyPCId: TcxTextEdit; Qty: TcxTextEdit; BCIOID: TcxTextEdit; Color: TcxTextEdit; CodeName: TcxTextEdit; Label2: TLabel; Label3: TLabel; Label4: TLabel; Label5: TLabel; Label6: TLabel; Label7: TLabel; Label8: TLabel; Label9: TLabel; InputLen: TcxTextEdit; lblLenUnit: TLabel; Label10: TLabel; InputWeight: TcxTextEdit; Tare: TcxTextEdit; Label11: TLabel; BTPrint: TButton; Coefficient: TcxTextEdit; lblRuleConversion: TcxComboBox; Label12: TLabel; AOrdDefNote1: TcxRichEdit; packnote: TcxMemo; unitPieces: TcxTextEdit; presentWeight: TcxTextEdit; presentLen: TcxTextEdit; bt_printmd: TButton; addWet: TcxTextEdit; addLen: TcxTextEdit; C_GramWeight: TcxTextEdit; C_Width: TcxTextEdit; customStrField2: TcxTextEdit; customStrField1: TcxTextEdit; C_StyleNo: TcxTextEdit; RuleYardstick: TcxTextEdit; C_Pattern: TcxTextEdit; OutPutWeight: TcxTextEdit; cxDBImage1: TcxDBImage; Button1: TButton; TV2Column8: TcxGridDBColumn; Panel2: TPanel; cxGrid3: TcxGrid; Tv3: TcxGridDBTableView; v3PieceNo: TcxGridDBColumn; Tv3Yardage: TcxGridDBColumn; Tv3Meter: TcxGridDBColumn; v3NetWeight: TcxGridDBColumn; v3GrossWeight: TcxGridDBColumn; Tv3Grade: TcxGridDBColumn; tv3CIID: TcxGridDBColumn; cxGridLevel2: TcxGridLevel; ToolBar2: TToolBar; ToolButton3: TToolButton; Trolldel: TToolButton; ToolButton1: TToolButton; Tlog: TToolButton; ToolButton8: TToolButton; ToolButton2: TButton; Tv3Column1: TcxGridDBColumn; TV2Column6: TcxGridDBColumn; TV2Column9: TcxGridDBColumn; TV2Column10: TcxGridDBColumn; ToolButton4: TToolButton; GroupBox1: TGroupBox; Button3: TButton; Label13: TLabel; Label14: TLabel; Label15: TLabel; C_CODE: TcxTextEdit; C_NAME2: TcxComboBox; ADO_PM: TADOQuery; Label16: TLabel; DUNIT: TcxTextEdit; ADO_YS: TADOQuery; Label17: TLabel; C_COLOR: TcxTextEdit; Label18: TLabel; CICUNIT: TcxTextEdit; Panel3: TPanel; cxGrid1: TcxGrid; TV1: TcxGridDBTableView; cxGridDBColumn2: TcxGridDBColumn; cxGridLevel3: TcxGridLevel; CDS_4: TClientDataSet; DS_4: TDataSource; ADO_4: TADOQuery; C_NAME: TcxTextEdit; Tv3Column2: TcxGridDBColumn; cxGridPopupMenu1: TcxGridPopupMenu; cxTextEdit1: TcxTextEdit; cxStyleRepository1: TcxStyleRepository; cxStyle1: TcxStyle; DS_YS: TDataSource; Button4: TButton; Panel4: TPanel; Label19: TLabel; SCAN2: TcxTextEdit; cxGrid4: TcxGrid; TV4: TcxGridDBTableView; cxGridDBColumn3: TcxGridDBColumn; cxGridLevel4: TcxGridLevel; Label20: TLabel; TV4Column1: TcxGridDBColumn; TV4Column2: TcxGridDBColumn; DS_HP: TDataSource; CDS_HP: TClientDataSet; Button5: TButton; Button6: TButton; CheckBox1: TCheckBox; TV2Column11: TcxGridDBColumn; CRTYPE: TcxComboBox; Button2: TButton; C_COLORNO: TcxTextEdit; Panel5: TPanel; cxGrid5: TcxGrid; TV5: TcxGridDBTableView; cxGridDBColumn4: TcxGridDBColumn; cxGridLevel5: TcxGridLevel; CDS_5: TClientDataSet; DS_5: TDataSource; ADO_5: TADOQuery; procedure FormCreate(Sender: TObject); procedure FormShow(Sender: TObject); procedure FormClose(Sender: TObject; var Action: TCloseAction); procedure FormDestroy(Sender: TObject); procedure edtScanDblClick(Sender: TObject); procedure edtScanKeyPress(Sender: TObject; var Key: Char); procedure ToolButton8Click(Sender: TObject); procedure edtScanEnter(Sender: TObject); procedure BTPrintClick(Sender: TObject); procedure TrolldelClick(Sender: TObject); procedure ToolButton3Click(Sender: TObject); procedure Tv3CustomDrawCell(Sender: TcxCustomGridTableView; ACanvas: TcxCanvas; AViewInfo: TcxGridTableDataCellViewInfo; var ADone: Boolean); procedure InputLenKeyPress(Sender: TObject; var Key: Char); procedure InputLenPropertiesChange(Sender: TObject); procedure FrameKeyBoard1SpeedButton_ycClick(Sender: TObject); procedure dxLayoutItem1CaptionClick(Sender: TObject); procedure lblRuleConversionPropertiesChange(Sender: TObject); procedure bt_printmdClick(Sender: TObject); procedure dxLayoutControl_packDblClick(Sender: TObject); procedure ToolButton1Click(Sender: TObject); procedure FrameKeyBoard1SpeedButton1Click(Sender: TObject); procedure ToolButton2Click(Sender: TObject); procedure Button1Click(Sender: TObject); procedure FrameKeyBoard1SpeedButton_backClick(Sender: TObject); procedure ToolButton4Click(Sender: TObject); procedure Button3Click(Sender: TObject); procedure Button2Click(Sender: TObject); procedure C_NAMEExit(Sender: TObject); procedure C_NAMEPropertiesChange(Sender: TObject); procedure c_colornoPropertiesChange(Sender: TObject); procedure C_NAME2Click(Sender: TObject); procedure C_NAME2Enter(Sender: TObject); procedure c_colornoExit(Sender: TObject); procedure c_colornoEnter(Sender: TObject); procedure TV1CellClick(Sender: TcxCustomGridTableView; ACellViewInfo: TcxGridTableDataCellViewInfo; AButton: TMouseButton; AShift: TShiftState; var AHandled: Boolean); procedure C_NAMEClick(Sender: TObject); procedure Panel1Click(Sender: TObject); procedure cxTextEdit1Click(Sender: TObject); procedure Button4Click(Sender: TObject); procedure SCAN2KeyPress(Sender: TObject; var Key: Char); procedure Button6Click(Sender: TObject); procedure Button5Click(Sender: TObject); procedure ColorNoClick(Sender: TObject); procedure C_COLORNOClick(Sender: TObject); procedure TV5CellClick(Sender: TcxCustomGridTableView; ACellViewInfo: TcxGridTableDataCellViewInfo; AButton: TMouseButton; AShift: TShiftState; var AHandled: Boolean); procedure GroupBox1Click(Sender: TObject); private FCIID, FCIFName, FWorkshop: string; FBCIOID, FC_Code, FC_ColorNo, FC_Color, FQtyUnit, FLenUnit, FTMSId, FTMMId: string; Faddwet, faddlen: double; FFtyPCId, FGangNo, FRulePieceNo, FCDUnit: string; FPieceNo: Integer; fIsPack: string; fIsCommopen: Boolean; FPacketCIID: string; fLabPackage, fLabVolume: string; FPacketCount: Integer; fAddwetVirtual: double; fAddLenVirtual: double; fTareType: string; funitPiecesStr: string; //拼匹 procedure setFocusCtrol(controlName: string); procedure QuantityConversion(); procedure ClearGlobal(); procedure InitPlan(MSubID: string); procedure SetUnit(MUnit: string); procedure SetDdetails(); procedure SetINIFile(); procedure GetINIFile(); procedure InitJYGrid(); procedure InitGrid2(); procedure InitGridCP(); procedure InitGridys(); procedure OpenCom(DllName: string); procedure CloseCom(DllName: string); procedure clearCom(DllName: string); function SaveData(): Boolean; procedure PrtData(MCIID: string; againPring: Boolean = false); procedure PrtData2(MCIID: string; againPring: Boolean = false); procedure BadSpeedButtonClick(Sender: TObject); procedure setFormCtrol(); procedure On1201(var Message: Tmessage); message 1201; // 电子称 procedure On1301(var Message: Tmessage); message 1301; // 码表 function CheckData(CKType: string): Boolean; function deletePack(packId: string): boolean; type public fmanage, fzt, FZT2: string; fFlileFlag, FCKLX: string; //FCKLX 出库类型 按照卷条码和配货单出库 end; var frmMachRollMain: TfrmMachRollMain; newh, newh1: hwnd; implementation uses U_DataLink, U_ControlData, U_ParamSet, U_RTFun, U_globalVar, U_FormLayOutDesign, U_ZDYHelp, U_iniParam, U_ProductListHelp, U_SysLogList, U_ProgressUpdate, U_LabelPrint, U_TradeClothTotalOutSel; {$R *.dfm} procedure TfrmMachRollMain.ClearCom(DllName: string); type TMyFunc = function(sCommName: PAnsiChar): hwnd; stdcall; var Tf1: TMyFunc; Tp1: TFarProc; Th1: Thandle; begin Th1 := LoadLibrary(pchar(trim(DllName))); if Th1 > 0 then begin try Tp1 := GetProcAddress(Th1, 'CommClear'); if Tp1 <> nil then begin Tf1 := TMyFunc(Tp1); newh1 := Tf1('Comm1'); end else begin end; finally // FreeLibrary(Th1); end; end else begin Application.MessageBox(pchar('找不到 ' + trim(DllName) + ' 文件!'), '提示'); end; end; procedure TfrmMachRollMain.InitGrid2(); var SqlStr: string; begin if FCKLX = '配货单' then begin SqlStr := ' exec P_Trade_Market_WaitOut_Market '; SqlStr := SqlStr + ' @TMSId =' + quotedstr(trim(FTMSId)); end else begin SqlStr := ' exec P_Trade_Market_WaitOut '; SqlStr := SqlStr + ' @C_Code =' + quotedstr(trim(FC_Code)); SqlStr := SqlStr + ' ,@C_ColorNo =' + quotedstr(trim(FC_ColorNo)); end; // showmessage(SqlStr); InitCDSData(ADO_2, CDS_2, Tv2, SqlStr, '', ''); end; procedure TfrmMachRollMain.InitGridCP(); var SqlStr: string; begin SqlStr := ' select distinct C_CODE,c_name from bs_cloth_info where c_name like ' + quotedstr('%' + trim(C_NAME.Text) + '%'); SqlStr := SqlStr + 'order by C_CODE,c_name'; // showmessage(SqlStr); InitCDSData(ADO_4, CDS_4, Tv1, SqlStr, '', ''); end; procedure TfrmMachRollMain.InitGridys(); var SqlStr: string; begin SqlStr := ' select distinct A.C_Code,B.C_Color,B.C_ColorNo,B.referencePrice AS Price from bs_cloth_info A inner join BS_Cloth_Info_Sub B on A.BCIID=B.BCIID where c_name = ' + quotedstr(trim(C_NAME.Text)); SqlStr := SqlStr + ' AND B.C_ColorNO LIKE ' + quotedstr('%' + trim(C_ColorNO.Text) + '%'); SqlStr := SqlStr + 'order by B.C_Color,B.C_ColorNo'; // showmessage(SqlStr); InitCDSData(ADO_5, CDS_5, Tv5, SqlStr, '', ''); end; function TfrmMachRollMain.CheckData(CKType: string): Boolean; var mvalue: double; mCurPieceNo: Integer; begin Result := false; try if trim(FBCIOID) = '' then raise Exception.create('请扫描流程卡!'); if trim(CKType) = '提交' then begin if trim(lblLenUnit.Caption) = '' then raise Exception.create('长度单位不能为空!'); if trim(InputWeight.Text) <> '' then begin if TryStrToFloat(InputWeight.Text, mvalue) = false then raise Exception.create('重量录入错误!'); if strtofloatdef(trim(InputWeight.Text), 0) < cds_params.fieldbyName('minWeight').AsInteger then raise Exception.create('重量不能小于' + cds_params.fieldbyName('minWeight').AsString + '!'); if strtofloatdef(trim(InputWeight.Text), 0) > cds_params.fieldbyName('maxWeight').AsInteger then raise Exception.create('重量不能大于' + cds_params.fieldbyName('maxWeight').AsString + '!'); end; if trim(InputLen.Text) <> '' then begin if TryStrToFloat(InputLen.Text, mvalue) = false then raise Exception.create('长度录入错误!'); if strtofloatdef(trim(InputLen.Text), 0) < cds_params.fieldbyName('minLen').AsInteger then raise Exception.create('长度不能小于' + cds_params.fieldbyName('minLen').AsString + '米!'); if strtofloatdef(trim(InputLen.Text), 0) > cds_params.fieldbyName('maxLen').AsInteger then raise Exception.create('长度不能大于' + cds_params.fieldbyName('maxLen').AsString + '米!'); end; if UpperCase(CICUNIT.Text) = 'KG' then begin if (strtofloatdef(trim(InputWeight.Text), 0) = 0) then raise Exception.create('重量不能为0!!'); end else if (UpperCase(CICUNIT.Text) = 'M') or (UpperCase(CICUNIT.Text) = 'Y') then begin if (strtofloatdef(trim(InputLen.Text), 0) = 0) then raise Exception.create('长度不能为0!!'); end else begin if (strtofloatdef(trim(InputLen.Text), 0) = 0) and (strtofloatdef(trim(InputWeight.Text), 0) = 0) then raise Exception.create('长度重量不能都为0!!'); end; // if UpperCase(FQtyUnit) = 'KG' then // begin // if (strtofloatdef(trim(InputWeight.Text), 0) = 0) then // raise Exception.create('重量不能为0!!'); // end // else // begin // if (strtofloatdef(trim(InputLen.Text), 0) = 0) then // raise Exception.create('长度不能为0!!'); // end; end; Result := true; except Application.MessageBox(pchar(Exception(ExceptObject).Message), '提示信息', 0); end; end; procedure TfrmMachRollMain.BTPrintClick(Sender: TObject); var fPrintFile, MPacketId: string; mvalue: double; i: Integer; begin if CDS_2.IsEmpty then begin Application.MessageBox('不存在配货单', '提示信息', 0); exit; end; try BTPrint.Enabled := false; edtScan.SetFocus; if CheckData('提交') = false then exit; if SaveData() then begin InputLen.Text := ''; presentLen.Text := ''; funitPiecesStr := ''; presentWeight.Text := ''; if fileexists(ExtractFilePath(Application.ExeName) + '正确.wav') then playSound(pwidechar('正确.wav'), 0, SND_FILENAME or SND_ASYNC); InputWeight.Text := ''; if trim(cds_params.fieldbyName('outPage').AsString) = '√' then begin PrtData(FCIID); end; end; InputLen.SetFocus; setFocusCtrol(InputLen.Name); InitJYGrid(); InitGrid2(); FCIID := ''; finally BTPrint.Enabled := true; end; if fIsCommopen then begin ClearCom(MBDYDllName); end; edtScan.SetFocus(); end; procedure TfrmMachRollMain.bt_printmdClick(Sender: TObject); var WSql: string; begin if cds_3.IsEmpty then Exit; WSql := ''; cds_3.DisableControls; with cds_3 do begin First; while not Eof do begin if WSql <> '' then begin WSql := WSql + ',' + Trim(cds_3.fieldbyname('CIID').AsString); end else begin WSql := Trim(cds_3.fieldbyname('CIID').AsString); end; Next; end; end; cds_3.EnableControls; // try // frmMdPrint := TfrmMdPrint.Create(Application); // with frmMdPrint do // begin // FLMType := '入库码单'; // FFiltration1 := WSql; // FFiltration2 := WSql; // if ShowModal = 1 then // begin //// Self.InitGrid(); // end; // end; // finally // frmMdPrint.Free; // end; try frmLabelPrint := TfrmLabelPrint.Create(Application); with frmLabelPrint do begin FLMType := '入库码单'; FFiltration1 := WSql; if ShowModal = 1 then begin // Self.InitGrid(); end; end; finally frmLabelPrint.Free; end; end; procedure TfrmMachRollMain.Button1Click(Sender: TObject); var fPrintFile, MPacketId, MTMSId: string; mvalue: double; i: Integer; begin try Button1.Enabled := false; MTMSId := Trim(SelTVKey(Tv2, ['TMSId'])[0]); edtScan.SetFocus; try ADOQueryBaseCmd.Connection.BeginTrans; if trim(MTMSId) = '' then raise Exception.create('请选择配货单!'); if trim(FBCIOID) = '' then raise Exception.create('请扫描流程卡!'); with ADOQueryBaseCmd do begin Close; sql.Clear; Sql.Add('exec P_BS_Cloth_Out_DistributionAll '); Sql.Add(' @StkID=' + quotedstr(Trim(FBCIOID))); Sql.Add(' ,@TMSId =' + quotedstr(MTMSId)); Sql.Add(' ,@Dcode=' + quotedstr(Trim(Dcode))); Sql.Add(' ,@DName=' + quotedstr(Trim(DName))); // showmessage(sql.Text); open; end; if ADOQueryBaseCmd.fieldbyName('intReturn').AsInteger = -1 then begin raise Exception.create(pchar(trim(ADOQueryBaseCmd.fieldbyName('ShowMsg').AsString))); end; FCIID := trim(trim(ADOQueryBaseCmd.fieldbyName('MaxIOID2').AsString)); if trim(cds_params.fieldbyName('outPage').AsString) = '√' then begin PrtData(FCIID); end; ADOQueryBaseCmd.Connection.CommitTrans; TradeMarketProgressUpdate(ADOQueryBaseCmd, MTMSId); except ADOQueryBaseCmd.Connection.RollbackTrans; Application.MessageBox(pchar(Exception(ExceptObject).Message), '提示信息', 0); end; InputLen.SetFocus; setFocusCtrol(InputLen.Name); InitJYGrid(); InitGrid2(); FCIID := ''; finally Button1.Enabled := true; end; if fIsCommopen then begin ClearCom(MBDYDllName); end; edtScan.SetFocus(); end; procedure TfrmMachRollMain.Button2Click(Sender: TObject); var Maxno, MBCIOID: string; MInputLen, MMeter, MYardage: double; MInputWeight, MGrossWeight, MNetWeight, MTare, Maddwet, maddLen: double; mYardStick: double; mPresentLen, mpresentWeight: double; begin if C_name.Text = '' then begin application.MessageBox('名称不能为空', '提示信息', 0); exit; end; if C_COlor.Text = '' then begin application.MessageBox('颜色不能为空', '提示信息', 0); exit; end; if DUNIT.Text = '' then begin application.MessageBox('单位不能为空', '提示信息', 0); exit; end; if ((DUNIT.Text = 'M') or (DUNIT.Text = 'Y')) and (StrToFloatDef(InputLen.Text, 0) = 0) then begin application.MessageBox('长度不能为0', '提示信息', 0); exit; end; if (UpperCase(DUNIT.Text) = 'KG') and (StrToFloatDef(InputWEIGHT.Text, 0) = 0) then begin application.MessageBox('重量不能为0', '提示信息', 0); exit; end; with ADOQueryBaseTemp do begin Close; sql.Clear; sql.Add('select * from Bs_Cloth_Info A INNER JOIN BS_Cloth_Info_Sub B ON A.BCIID=B.BCIID '); SQL.Add(' where c_name=' + QuotedStr(C_NAME.Text)); SQL.Add(' AND B.c_COLOR=' + QuotedStr(c_COLOR.Text)); SQL.Add(' AND B.C_ColorNo=' + QuotedStr(C_ColorNo.Text)); open; end; if ADOQueryBaseTemp.IsEmpty then begin application.MessageBox('未找到该产品色号颜色,请重新确认后填写', '提示信息', 0); exit; end; try ADOQueryBaseCmd.Connection.BeginTrans; Maddwet := strTofloatDef(trim(addwet.text), 0); // Faddwet; maddLen := strTofloatDef(trim(addlen.text), 0); // faddlen; mYardStick := strtofloatdef(trim(RuleYardstick.Text), 100); mPresentLen := strTofloatDef(trim(presentlen.text), 0); mpresentWeight := strTofloatDef(trim(presentWeight.text), 0); with ADOQueryBaseTemp do begin Close; sql.Clear; sql.Add('select * from BS_Cloth_IO where 1<>1 '); open; end; if not GetLSNo(ADOQueryBaseCmd, Maxno, 'TC', 'BS_Cloth_IO', 4, 1) then raise Exception.Create('取入库编号失败!'); if (strtoIntdef(Trim(unitPieces.Text), 0) > 0) and (strtoIntdef(trim(InputLen.Text), 0) > 0) then begin if strtoIntdef(trim(InputLen.Text), 0) > strtoIntdef(Trim(unitPieces.Text), 0) then funitPiecesStr := intTostr((strtoIntdef(trim(InputLen.Text), 0)) - strtoIntdef(Trim(unitPieces.Text), 0)) + '+' + Trim(unitPieces.Text); end; //0:不变;1:减去赠送 if gPresentNumFlag = 1 then begin mPresentLen := -1 * mPresentLen; mpresentWeight := -1 * mpresentWeight; end; MTare := strtofloatdef(trim(Tare.Text), 0); // 皮重 MInputWeight := RoundFloat(strtofloatdef(trim(InputWeight.Text), 0), cds_params.fieldbyName('KgPlace').AsInteger); // 净重 MGrossWeight := MInputWeight + Maddwet + mpresentWeight; // 毛重 MNetWeight := MInputWeight + Maddwet + mpresentWeight - MTare; // 净重 +加重 MInputLen := RoundFloat(strtofloatdef(trim(InputLen.Text), 0), 4); // 换算后数量+mAddLen if (uppercase(lblLenUnit.Caption) = 'M') or (lblLenUnit.Caption = '米') then begin MMeter := RoundFloat((MInputLen + maddLen + mPresentLen) / (mYardStick / 100), cds_params.fieldbyName('MPlace').AsInteger); MYardage := RoundFloat(MMeter / 0.9144, cds_params.fieldbyName('YPlace').AsInteger); end else begin MYardage := RoundFloat((MInputLen + maddLen + mPresentLen) / (mYardStick / 100), cds_params.fieldbyName('YPlace').AsInteger); MMeter := RoundFloat(MYardage * 0.9144, cds_params.fieldbyName('MPlace').AsInteger); end; with ADOQueryBaseCmd do begin Close; sql.Clear; sql.Add('select * from BS_Cloth_IO where BCIOID=''' + Trim(Maxno) + ''''); Open; end; with ADOQueryBaseCmd do begin if ADOQueryBaseCmd.ISEMPTY then begin Append; FieldByName('Fillid').Value := Trim(Dcode); FieldByName('Filler').Value := Trim(DName); FieldByName('BCIONO').Value := Trim(Maxno); FieldByName('BCIOID').Value := Trim(Maxno); FieldByName('BCIONO').Value := Trim(Maxno); FieldByName('STKID').Value := Trim(Maxno); FieldByName('CIID').Value := Trim(Maxno); end else begin Edit; FieldByName('Editid').Value := Trim(Dcode); FieldByName('Editer').Value := Trim(DName); FieldByName('EditTime').Value := SGetServerDate(ADOQueryBaseTemp); FieldByName('status').value := '1'; end; FieldByName('C_NAME').Value := C_NAME.Text; FieldByName('C_CODE').Value := C_CODE.Text; FieldByName('C_COLORNO').Value := C_COLORNO.Text; FieldByName('C_COLOR').Value := C_COLOR.Text; FieldByName('IOTime').Value := StrToDate(FormatDateTime('yyyy-mm-dd', SGetServerDate(ADOQueryBaseTemp))); FieldByName('STKName').Value := '贸易布匹'; FieldByName('IOFlag').Value := '入库'; FieldByName('IOTYPE').Value := CRTYPE.Text; FieldByName('IOQtyFlag').Value := 1; FieldByName('piece').Value := 1; FieldByName('stkpiece').Value := 1; FieldByName('GrossWeight').Value := MGrossWeight; FieldByName('NetWeight').Value := MNetWeight; FieldByName('Meter').Value := MMeter; FieldByName('Yardage').Value := MYardage; FieldByName('QTYUNIT').Value := DUNIT.Text; if DUNIT.Text = 'M' then begin FieldByName('qty').Value := MMeter; FieldByName('STKqty').Value := MMeter; end else if DUNIT.Text = 'Y' then begin FieldByName('qty').Value := MYardage; FieldByName('STKqty').Value := MYardage; end else begin FieldByName('qty').Value := MGrossWeight; FieldByName('STKqty').Value := MGrossWeight; end; Post; end; with ADOQueryBaseCmd do begin Close; sql.Clear; sql.Add('Update BS_Cloth_IO Set StkPiece=(select Sum(isnull(Piece,0)*IOQtyFlag) from BS_Cloth_IO A where A.STKID=BS_Cloth_IO.BCIOID )'); sql.Add(',StkQty=(select Sum(isnull(Qty,0)*IOQtyFlag) from BS_Cloth_IO A where A.STKID=BS_Cloth_IO.BCIOID )'); sql.Add(' where BCIOID=''' + Trim(Maxno) + ''''); ExecSQL; end; with ADOQueryBaseCmd do begin Close; sql.Clear; sql.Add('Update BS_Cloth_IO Set status = 1'); sql.Add(' where BCIOID=''' + Trim(Maxno) + ''''); ExecSQL; end; with ADOQueryBaseCmd do begin Close; sql.Clear; sql.Add('insert into Finance_Need_Up(UType,UDataId,UOperation,UOperator,UModule,UDetails) '); sql.Add('values(''贸易待检布入库'' '); sql.Add(',' + quotedstr(Maxno)); sql.Add(',''保存'' '); sql.Add(',' + quotedstr(DName)); sql.Add(',' + quotedstr(trim(self.Caption))); sql.Add(',' + quotedstr(Maxno)); sql.Add(') '); ExecSQL; end; PrtData2(Maxno); ADOQueryBaseCmd.Connection.CommitTrans; InputLen.Text := ''; presentLen.Text := ''; funitPiecesStr := ''; presentWeight.Text := ''; except ADOQueryBaseCmd.Connection.RollbackTrans; application.MessageBox(PChar(Exception(ExceptObject).Message), '提示信息', 0); end; end; procedure TfrmMachRollMain.Button3Click(Sender: TObject); begin if GroupBox1.Visible = FALSE then begin GroupBox1.Visible := True; button2.Visible := True; CRTYPE.Visible := True; end else begin GroupBox1.Visible := false; button2.Visible := false; CRTYPE.Visible := false; end; end; procedure TfrmMachRollMain.Button4Click(Sender: TObject); begin if BCIOID.text = '' then begin application.MessageBox('请先扫描要拼的条码', '提示信息', 0); exit; end else begin Label20.Caption := '合到条码为:' + BCIOID.text; Panel4.Visible := true; with ADOQueryBaseTemp do begin Close; sql.Clear; sql.Add('select * From bs_cloth_io where 1<>1'); open; end; SCreateCDS(ADOQueryBaseTemp, cds_hp); SInitCDSData(ADOQueryBaseTemp, cds_hp); end; end; procedure TfrmMachRollMain.Button5Click(Sender: TObject); begin if CDS_HP.IsEmpty then begin application.MessageBox('明细不能为空', '提示信息', 0); exit; end; with CDS_HP do begin First; while not Eof do begin try ADOQueryBaseCmd.Connection.BeginTrans; with ADOQueryBaseCmd do begin Close; sql.Clear; Sql.Add('exec P_BS_Cloth_Out_DistributionAll_hp '); Sql.Add(' @StkID=' + quotedstr(Trim(CDS_HP.FieldByName('bcioid').AsString))); Sql.Add(' ,@tostkid =' + quotedstr(bcioid.Text)); Sql.Add(' ,@Dcode=' + quotedstr(Trim(Dcode))); Sql.Add(' ,@DName=' + quotedstr(Trim(DName))); // showmessage(sql.Text); open; end; if ADOQueryBaseCmd.fieldbyName('intReturn').AsInteger = -1 then begin raise Exception.create(pchar(trim(ADOQueryBaseCmd.fieldbyName('ShowMsg').AsString))); end; ADOQueryBaseCmd.Connection.CommitTrans; Application.MessageBox(pchar('保存成功'), '提示信息', 0); InitPlan(BCIOID.Text); except ADOQueryBaseCmd.Connection.RollbackTrans; Application.MessageBox(pchar(Exception(ExceptObject).Message), '提示信息', 0); end; Next; end; end; end; procedure TfrmMachRollMain.Button6Click(Sender: TObject); begin Panel4.Visible := false; end; procedure TfrmMachRollMain.FormClose(Sender: TObject; var Action: TCloseAction); begin inherited; if fIsCommopen then begin CloseCom(DZCDYDllName); CloseCom(MBDYDllName); end; Action := caFree; end; procedure TfrmMachRollMain.FormCreate(Sender: TObject); begin inherited; fIsCommopen := false; cds_params.Close; cds_params.CreateDataSet; Panel_right.Align := alClient; end; procedure TfrmMachRollMain.FormDestroy(Sender: TObject); begin inherited; frmMachRollMain := nil; end; procedure TfrmMachRollMain.FormShow(Sender: TObject); var i: Integer; begin inherited; gIsCanDesign := gIsCanDesign; gGridNativeSet := true; ReadCxGrid(trim(Self.Caption) + 'Tv3', Tv3, gDllFileCaption); ReadCxGrid(trim(Self.Caption) + 'Tv21', Tv2, gDllFileCaption); if IsINIFile() then ReadINIFile() else WriteINIFile; GetINIFile(); setFormCtrol(); if trim(fmanage) <> '高权限' then begin if trim(DZCDYDllName) <> '' then OpenCom(DZCDYDllName); if trim(MBDYDllName) <> '' then OpenCom(MBDYDllName); end; if trim(fCanInputFs) = '1' then begin // cxGroupBox_keys.ClientHeight := round(cxGrid3.ClientHeight * 0.6); frameKeyBoard1.SpeedButton10.Visible := true; end else begin // cxGroupBox_keys.ClientHeight := round(cxGrid3.ClientHeight * 0.55); frameKeyBoard1.SpeedButton10.Visible := false; end; with ADO_PM do begin Close; sql.Clear; sql.Add(' SELECT distinct A.C_Name,A.C_CODE,TMSUnit=QTYUNIT '); SQL.ADD(' FROM Bs_Cloth_Info A '); SQL.ADD('order by A.C_Code '); // showmessage(SQL.text); Open; // c_name.Properties.LookupItems.Clear; // while not Eof do // begin // c_name.Properties.LookupItems.Add(Trim(ADO_PM.fieldByName('c_name').AsString)); // Next; // end; end; with ADO_YS do begin Close; sql.Clear; sql.Add(' SELECT DISTINCT A.C_Code,B.C_Color,B.C_ColorNo,B.referencePrice AS Price FROM Bs_Cloth_Info A inner join BS_Cloth_Info_Sub B on A.BCIID=B.BCIID '); sql.Add(' where 1<>1'); SQL.ADD(' order by B.C_ColorNo'); //ShowMessage(sql.text); Open; end; // 支持中文输入 // C_NAME.Properties.DropDownListStyle := lsEditList; // C_NAME.Properties.ImeMode := imChinese; end; procedure TfrmMachRollMain.FrameKeyBoard1SpeedButton1Click(Sender: TObject); var fsj: string; mComponent: TComponent; mkey: Char; NewText: string; begin fsj := trim(TSpeedButton(Sender).Hint); if trim(fsj) = '' then exit; mComponent := FindComponent(trim(TSpeedButton(Sender).Hint)); if mComponent = nil then exit; if TcxTextEdit(mComponent).Name = 'KuangHao' then exit; if (trim(TSpeedButton(Sender).Caption) = '↑') then begin Tare.Text := FloatToStr(strtofloatdef(Tare.Text, 0) + 0.1); end else if (trim(TSpeedButton(Sender).Caption) = '↓') then begin Tare.Text := FloatToStr(strtofloatdef(Tare.Text, 0) - 0.1); end else begin if (TcxTextEdit(mComponent).Name = 'edtScan') and (trim(TSpeedButton(Sender).Caption) = '回车') then begin mkey := #13; edtScanKeyPress(edtScan, mkey); exit; end; fsj := trim(TcxTextEdit(mComponent).Text); if mComponent is TcxCurrencyEdit then begin TcxCurrencyEdit(mComponent).text := fsj + trim(TSpeedButton(Sender).Caption); TcxCurrencyEdit(mComponent).SelectAll; end else if mComponent is TcxTextEdit then begin TcxTextEdit(mComponent).Text := fsj + trim(TSpeedButton(Sender).Caption); TcxTextEdit(mComponent).SelectAll; end else if mComponent is TcxComboBox then begin NewText := fsj + trim(TSpeedButton(Sender).Caption); ; // C_NAME.Properties.OnChange := nil; if TcxComboBox(mComponent).Properties.Items.IndexOf(NewText) = -1 then TcxComboBox(mComponent).Properties.Items.Add(NewText); TcxComboBox(mComponent).ItemIndex := TcxComboBox(mComponent).Properties.Items.IndexOf(NewText); TcxComboBox(mComponent).DroppedDown := True; // C_NAME.Text := C_NAME.Text + '1'; // TcxComboBox(mComponent).Text := fsj + trim(TSpeedButton(Sender).Caption); // TcxComboBox(mComponent).SelectAll; end; end; end; procedure TfrmMachRollMain.FrameKeyBoard1SpeedButton_backClick(Sender: TObject); var fsj: string; begin fsj := Trim(TcxTextEdit(FindComponent(Trim(TSpeedButton(Sender).Hint))).Text); if Trim(fsj) = '' then Exit; TcxTextEdit(FindComponent(Trim(TSpeedButton(Sender).Hint))).Text := Copy(fsj, 1, Length(fsj) - 1); TcxTextEdit(FindComponent(Trim(TSpeedButton(Sender).Hint))).SelectAll; end; procedure TfrmMachRollMain.FrameKeyBoard1SpeedButton_ycClick(Sender: TObject); begin inherited; cxGroupBox_keys.Visible := false; end; procedure TfrmMachRollMain.ClearGlobal(); begin FBCIOID := ''; FQtyUnit := ''; FCIID := ''; FWorkshop := ''; InputLen.Text := ''; Coefficient.Text := ''; AOrdDefNote1.Text := ''; Tare.Text := '0.3'; InputWeight.Text := ''; FLenUnit := ''; Faddwet := 0; faddlen := 0; FPacketCIID := ''; FPacketCount := 0; FC_ColorNo := ''; FC_Code := ''; end; procedure TfrmMachRollMain.QuantityConversion(); begin // if trim(OrderNo.Text)='' then exit; if cds_params.fieldbyName('weightRule').AsInteger = 0 then // InputWeight 毛重 OutPutWeight 净重 begin if lblRuleConversion.Text <> '无需转换' then begin if lblRuleConversion.Text = '长度转公斤' then begin InputWeight.Text := floattostr(strtofloatdef(trim(InputLen.Text), 0) * strtofloatdef(trim(Coefficient.Text), 0) + strtofloatdef(trim(Tare.Text), 0)); end; if lblRuleConversion.Text = '毛重转长度' then begin InputLen.Text := floattostr(strtofloatdef(trim(InputWeight.Text), 0) * strtofloatdef(trim(Coefficient.Text), 0)); end; if lblRuleConversion.Text = '净重转长度' then begin InputLen.Text := floattostr((RoundFloat(strtofloatdef(trim(InputWeight.Text), 0), 1) - strtofloatdef(trim(Tare.Text), 0)) * strtofloatdef(trim(Coefficient.Text), 0)); end; end; if strtofloatdef(trim(InputWeight.Text), 0) > 0 then begin OutPutWeight.Text := floattostr((strtofloatdef(trim(InputWeight.Text), 0) - strtofloatdef(trim(Tare.Text), 0))); // 净重 end; end; if cds_params.fieldbyName('weightRule').AsInteger = 1 then // InputWeight 净重 OutPutWeight 毛重 begin if lblRuleConversion.Text <> '无需转换' then begin if lblRuleConversion.Text = '长度转公斤' then begin InputWeight.Text := floattostr(strtofloatdef(trim(InputLen.Text), 0) * strtofloatdef(trim(Coefficient.Text), 0)); end; if lblRuleConversion.Text = '毛重转长度' then begin InputLen.Text := floattostr((strtofloatdef(trim(InputWeight.Text), 0) + strtofloatdef(trim(Tare.Text), 0)) * strtofloatdef(trim(Coefficient.Text), 0)); end; if lblRuleConversion.Text = '净重转长度' then begin InputLen.Text := floattostr(RoundFloat(strtofloatdef(trim(InputWeight.Text), 0), 1) * strtofloatdef(trim(Coefficient.Text), 0)); end; end; if strtofloatdef(trim(InputWeight.Text), 0) > 0 then begin OutPutWeight.Text := floattostr((strtofloatdef(trim(InputWeight.Text), 0) + strtofloatdef(trim(Tare.Text), 0))); // 毛重 end; end; end; procedure TfrmMachRollMain.InitPlan(MSubID: string); begin if leftstr(MSubID, 2) = 'JS' then begin FCKLX := '配货单'; Button1.visible := false; ToolButton2.visible := False; end else begin FCKLX := '卷条码'; Button1.visible := true; ToolButton2.visible := true; end; with ADOQueryBaseTemp do begin Close; SQL.Clear; if FCKLX = '配货单' then begin SQL.Add('EXEC P_Trade_Insp_Get_Market @TMSId=''' + trim(MSubID) + ''''); end else begin SQL.Add('EXEC P_Trade_Insp_Get_plan @BCIOID=''' + trim(MSubID) + ''''); end; Open; if not IsEmpty then begin FLenUnit := trim(ADOQueryBaseTemp.fieldbyName('LenUnit').AsString); if FLenUnit = '' then begin FLenUnit := 'M'; end; fLabPackage := '默认包标签'; fLabVolume := '客户标签'; // fLabPackage := trim(ADOQueryBaseTemp.fieldbyName('LabPackage').AsString); // fLabVolume := trim(ADOQueryBaseTemp.fieldbyName('LabVolume').AsString); SetUnit(FLenUnit); FCDUnit := lblLenUnit.Caption; CICUNIT.Text := trim(fieldbyName('CICUNIT').AsString); FTMSId := trim(fieldbyName('TMSId').AsString); FTMMId := trim(fieldbyName('TMMId').AsString); FBCIOID := trim(fieldbyName('BCIOID').AsString); FQtyUnit := trim(fieldbyName('QtyUnit').AsString); OrderNo.Text := trim(fieldbyName('FromOrdNo').AsString); CodeName.Text := trim(fieldbyName('C_Name').AsString); C_width.Text := trim(fieldbyName('C_width').AsString); C_GramWeight.Text := trim(fieldbyName('C_GramWeight').AsString); ColorNo.Text := trim(fieldbyName('C_ColorNo').AsString) + ' ' + trim(fieldbyName('C_Color').AsString); Color.Text := trim(fieldbyName('C_Color').AsString); C_Pattern.Text := trim(fieldbyName('C_Pattern').AsString); FFtyPCId := trim(fieldbyName('FtyPCId').AsString); FC_Code := trim(fieldbyName('C_Code').AsString); FC_ColorNo := trim(fieldbyName('C_ColorNo').AsString); FC_Color := trim(fieldbyName('C_Color').AsString); cds_params.Edit; cds_params.fieldbyName('outPage').value := '√'; cds_params.Post; // Coefficient.Text := trim(fieldbyName('Coefficient').AsString); // 转换系数 // lblRuleConversion.ItemIndex := lblRuleConversion.Properties.Items.IndexOf(fieldbyName('RuleConversion').AsString); FtyPCId.Text := FFtyPCId; BCIOID.Text := FBCIOID; Qty.Text := trim(fieldbyName('StkQty').AsString) + trim(fieldbyName('QtyUnit').AsString); // Tare.Text := trim(fieldbyName('RuleLaterTare').AsString); fTareType := ''; RuleYardstick.Text := '100'; packnote.Lines.Clear; InputLen.SetFocus; setFocusCtrol(InputLen.Name); SetDdetails(); end else begin // ClearGlobal(); application.MessageBox('条码异常,请检查条码信息和打卷设置!', '警告信息'); end; end; InitJYGrid(); edtScan.Text := ''; // 显示包 setFormCtrol(); end; procedure TfrmMachRollMain.InputLenKeyPress(Sender: TObject; var Key: Char); begin if Key = #13 then begin Key := #0; SelectNext(ActiveControl as TWinControl, true, true); end; end; procedure TfrmMachRollMain.InputLenPropertiesChange(Sender: TObject); begin // if StrToIntDef(trim(InputWeight.Text), 0) = 0 then // begin // exit; // end; QuantityConversion(); end; procedure TfrmMachRollMain.lblRuleConversionPropertiesChange(Sender: TObject); begin inherited; if lblRuleConversion.Text = '无需转换' then begin OutPutWeight.Text := ''; InputLen.Text := ''; InputWeight.Text := ''; end; QuantityConversion(); end; procedure TfrmMachRollMain.SetUnit(MUnit: string); begin lblLenUnit.Caption := MUnit; end; procedure TfrmMachRollMain.ToolButton1Click(Sender: TObject); begin frmParamSet := TfrmParamSet.create(Self); with frmParamSet do begin cds_params.Data := Self.cds_params.Data; if ShowModal = 1 then begin Self.cds_params.Data := cds_params.Data; setFormCtrol(); end; free; end; SetINIFile(); if trim(fmanage) <> '高权限' then begin if (trim(MBDYDllName) <> '') and not fIsCommopen then OpenCom(MBDYDllName); end; end; procedure TfrmMachRollMain.ToolButton2Click(Sender: TObject); var fPrintFile: string; Txt, fImagePath, Txt2, fImagePath2: string; Moudle: Thandle; Makebar: TMakebar; Mixtext: TMixtext; begin if CDS_2.IsEmpty then begin Application.MessageBox('不存在配货单', '提示信息', 0); exit; end; if cxTextEdit1.Text <> '' then begin BTPrint.Click(); end; with ADOQueryPrint do begin Close; SQL.Clear; SQL.Add(' EXEC P_BS_Cloth_Prt2 '); SQL.Add(' @Filtration=''' + trim(FBCIOID) + ''''); Open; end; if ADOQueryPrint.IsEmpty then begin Application.MessageBox('标签内容未找到!', '提示信息', MB_ICONERROR); exit; end; ExportFtErpFile('库存标签.fr3', ADOQueryBaseTemp); fPrintFile := ExtractFilePath(Application.ExeName) + 'Report\库存标签.fr3'; if FileExists(fPrintFile) then begin frxReport1.LoadFromFile(fPrintFile); frxReport1.PrintOptions.Copies := cds_params.fieldbyName('labNumber').AsInteger; frxReport1.PrintOptions.ShowDialog := false; frxReport1.PrepareReport(True); frxReport1.Print(); end else begin Application.MessageBox(PChar('没有找到' + fPrintFile), '提示', 0); end; end; procedure TfrmMachRollMain.ToolButton3Click(Sender: TObject); begin if cds_3.IsEmpty then exit; PrtData(cds_3.fieldbyName('BCIOID').AsString); end; procedure TfrmMachRollMain.ToolButton4Click(Sender: TObject); begin writeCxGrid(trim(Self.Caption) + 'Tv3', Tv3, gDllFileCaption); writeCxGrid(trim(Self.Caption) + 'Tv21', Tv2, gDllFileCaption); end; procedure TfrmMachRollMain.TrolldelClick(Sender: TObject); var MBCIOID: string; begin if cds_3.IsEmpty then exit; if Application.MessageBox('确定要删除选择的卷数据吗?', '提示', 32 + 4) <> IDYES then exit; ADOQueryBaseCmd.Connection.BeginTrans; try MBCIOID := trim(cds_3.fieldbyName('BCIOID').AsString); with ADOQueryBaseCmd do begin Close; SQL.Clear; Sql.Add('exec P_BS_Cloth_Out_Del '); Sql.Add(' @BCIOIDS=' + quotedstr(MBCIOID)); Sql.Add(',@DCode=' + quotedstr(Trim(DCode))); Sql.Add(',@DName=' + quotedstr(Trim(DName))); Open; end; if ADOQueryBaseCmd.fieldbyName('intReturn').AsInteger = -1 then begin raise Exception.create(pchar(trim(ADOQueryBaseCmd.fieldbyName('ShowMsg').AsString))); end; ADOQueryBaseCmd.Connection.CommitTrans; cds_3.Delete; Application.MessageBox('删除成功!', '提示信息'); InitGrid2(); InitJYGrid(); except ADOQueryBaseCmd.Connection.RollbackTrans; Application.MessageBox(pchar(Exception(ExceptObject).Message), '提示信息', 0); end; end; procedure TfrmMachRollMain.TV1CellClick(Sender: TcxCustomGridTableView; ACellViewInfo: TcxGridTableDataCellViewInfo; AButton: TMouseButton; AShift: TShiftState; var AHandled: Boolean); begin fzt := '0'; C_NAME.Text := CDS_4.FieldByName('c_name').AsString; ADO_PM.Locate('C_Name', C_NAME.Text, []); C_Code.Text := ADO_PM.FieldByName('C_Code').Value; DUnit.TEXT := ADO_PM.FieldByName('TMSUnit').Value; with ADO_YS do begin Close; sql.Clear; sql.Add(' SELECT DISTINCT A.C_Code,B.C_Color,B.C_ColorNo,B.referencePrice AS Price,DBO.GETNUM(B.C_ColorNo) FROM Bs_Cloth_Info A inner join BS_Cloth_Info_Sub B on A.BCIID=B.BCIID '); sql.Add(' where A.C_Code= ' + QuotedStr(C_CODE.TEXT)); SQL.ADD(' order by DBO.GETNUM(B.C_ColorNo)'); // ShowMessage(sql.text); Open; end; C_CoLOR.Text := ''; C_CoLORNO.Text := ''; Panel3.Visible := false; fzt := '1'; end; procedure TfrmMachRollMain.Tv3CustomDrawCell(Sender: TcxCustomGridTableView; ACanvas: TcxCanvas; AViewInfo: TcxGridTableDataCellViewInfo; var ADone: Boolean); begin if AViewInfo.GridRecord.Values[TcxGridDBTableView(Sender).GetColumnByFieldName('Grade').Index] = '次品' then ACanvas.Brush.Color := clRed; end; procedure TfrmMachRollMain.TV5CellClick(Sender: TcxCustomGridTableView; ACellViewInfo: TcxGridTableDataCellViewInfo; AButton: TMouseButton; AShift: TShiftState; var AHandled: Boolean); begin FZT2 := '0'; C_COLOR.Text := CDS_5.FieldByName('C_COLOR').AsString; C_COLORNO.Text := CDS_5.FieldByName('C_COLORNO').AsString; Panel5.Visible := false; FZT2 := '1'; end; procedure TfrmMachRollMain.ToolButton8Click(Sender: TObject); begin inherited; Close; end; procedure TfrmMachRollMain.setFocusCtrol(controlName: string); var i: Integer; begin with FrameKeyBoard1.dxPanel1 do begin for i := 0 to ControlCount - 1 do begin if Controls[i] is TSpeedButton then begin TSpeedButton(Controls[i]).Hint := trim(controlName); if (trim(controlName) = 'edtScan') and (TSpeedButton(Controls[i]).Name = 'SpeedButton_dot') then begin TSpeedButton(Controls[i]).Caption := '回车'; end else if (TSpeedButton(Controls[i]).Name = 'SpeedButton_dot') then begin TSpeedButton(Controls[i]).Caption := '.'; end; end; end; end; cxGroupBox_keys.Left := Panel_right.Left + 5; cxGroupBox_keys.Visible := true; end; procedure TfrmMachRollMain.SetDdetails(); begin AOrdDefNote1.Text := ''; AOrdDefNote1.Text := AOrdDefNote1.Text + '卡号:' + FBCIOID + #13; if FRulePieceNo <> '' then AOrdDefNote1.Text := AOrdDefNote1.Text + '卷号规则:' + FRulePieceNo + #13; if gMachOperators <> '' then AOrdDefNote1.Text := AOrdDefNote1.Text + '机台人员:' + gMachOperators + #13; end; procedure TfrmMachRollMain.SetINIFile(); begin IsDZCDYDll := trim(cds_params.fieldbyName('chen').AsString); IsMBDYDll := trim(cds_params.fieldbyName('mabiao').AsString); IsMBDYDllUnit := trim(cds_params.fieldbyName('mbunit').AsString); LabQty := trim(cds_params.fieldbyName('labNumber').AsString); FMinLen := trim(cds_params.fieldbyName('minLen').AsString); FMaxLen := trim(cds_params.fieldbyName('maxLen').AsString); FMinWeight := trim(cds_params.fieldbyName('minweight').AsString); FMaxWeight := trim(cds_params.fieldbyName('maxweight').AsString); FMPlace := trim(cds_params.fieldbyName('mplace').AsString); FYPlace := trim(cds_params.fieldbyName('yplace').AsString); FKgPlace := trim(cds_params.fieldbyName('kgplace').AsString); WriteINIFile(); end; procedure TfrmMachRollMain.setFormCtrol(); begin FrameKeyBoard1.SpeedButton_zdykey1.Caption := gZdyKey1; // FrameKeyBoard1.SpeedButton_zdykey2.Caption := gZdyKey2; FrameKeyBoard1.SpeedButton_zdykey2.Caption := gZdyKey2; //赠送 presentlen.text := trim(cds_params.fieldbyName('AddLenPresent').AsString); presentWeight.text := trim(cds_params.fieldbyName('AddwetPresent').AsString); end; procedure TfrmMachRollMain.GetINIFile(); begin with cds_params do begin if IsEmpty then Append else edit; fieldbyName('chen').value := IsDZCDYDll; fieldbyName('mabiao').value := IsMBDYDll; fieldbyName('mbunit').value := IsMBDYDllUnit; fieldbyName('MinLen').value := strtointdef(FMinLen, 0); fieldbyName('MaxLen').value := strtointdef(FMaxLen, 100); fieldbyName('MinWeight').value := strtointdef(FMinWeight, 0); fieldbyName('MaxWeight').value := strtointdef(FMaxWeight, 50); fieldbyName('MPlace').value := strtointdef(FMPlace, 1); fieldbyName('YPlace').value := strtointdef(FYPlace, 1); fieldbyName('KgPlace').value := strtointdef(FKgPlace, 1); fieldbyName('labNumber').value := strtointdef(trim(LabQty), 1); Post; end; end; procedure TfrmMachRollMain.GroupBox1Click(Sender: TObject); begin PANEL3.Visible := FALSE; PANEL5.Visible := FALSE; end; procedure TfrmMachRollMain.InitJYGrid(); var MNetWeight, MJYLen: double; begin try cds_3.DisableControls; if FCKLX = '配货单' then begin with ADOQueryMain do begin Close; SQL.Clear; SQL.Add('select A.*,tmmno=(select tmmno from Trade_Market_Main e where e.tmmid=a.tmmid)'); SQL.Add('from Bs_Cloth_IO A where IOType=''销售出库'' and TMSId=''' + trim(FTMSId) + ''''); SQL.Add('order by filltime desc'); Open; end; end else begin with ADOQueryMain do begin Close; SQL.Clear; SQL.Add('select A.*,tmmno=(select tmmno from Trade_Market_Main e where e.tmmid=a.tmmid)'); SQL.Add('from Bs_Cloth_IO A where IOflag=''入库'' and STKID=''' + trim(FBCIOID) + ''''); SQL.Add('order by filltime desc'); Open; end; Qty.Text := trim(ADOQueryMain.fieldbyName('StkQty').AsString) + trim(trim(ADOQueryMain.fieldbyName('QtyUnit').AsString)); // InitPlan(FBCIOID); with ADOQueryMain do begin Close; SQL.Clear; SQL.Add('select A.*,tmmno=(select tmmno from Trade_Market_Main e where e.tmmid=a.tmmid)'); SQL.Add('from Bs_Cloth_IO A where IOType=''销售出库'' and STKID=''' + trim(FBCIOID) + ''''); SQL.Add('order by filltime desc'); Open; end; end; SCreateCDS(ADOQueryMain, cds_3); SInitCDSData(ADOQueryMain, cds_3); finally cds_3.EnableControls; end; end; procedure TfrmMachRollMain.OpenCom(DllName: string); type TMyFunc = function(fhandle: hwnd; sCommName: PAnsiChar; IntTime: Integer; IsMessage: Integer): hwnd; stdcall; var Tf: TMyFunc; Tp: TFarProc; Th: Thandle; begin Th := LoadLibrary(pchar(trim(DllName))); if Th > 0 then begin try Tp := GetProcAddress(Th, 'CommOpen'); if Tp <> nil then begin Tf := TMyFunc(Tp); newh := Tf(Self.Handle, 'Comm1', 500, 1); if newh < 1 then begin Application.MessageBox(pchar('打开串口失败!'), '提示'); end else fIsCommopen := true; end else begin fIsCommopen := false; end; finally // FreeLibrary(Th); end; end else begin fIsCommopen := false; Application.MessageBox(pchar('找不到 ' + trim(DllName) + ' 文件!'), '提示'); end; end; procedure TfrmMachRollMain.CloseCom(DllName: string); type TMyFunc = function(sCommName: PAnsiChar): hwnd; stdcall; var Tf1: TMyFunc; Tp1: TFarProc; Th1: Thandle; begin Th1 := LoadLibrary(pchar(trim(DllName))); if Th1 > 0 then begin try Tp1 := GetProcAddress(Th1, 'CommClose'); if Tp1 <> nil then begin Tf1 := TMyFunc(Tp1); newh1 := Tf1('Comm1'); end else begin end; finally // FreeLibrary(Th1); end; end else begin Application.MessageBox(pchar('找不到 ' + trim(DllName) + ' 文件!'), '提示'); end; end; procedure TfrmMachRollMain.ColorNoClick(Sender: TObject); var i: Integer; begin with FrameKeyBoard1.dxPanel1 do begin for i := 0 to ControlCount - 1 do begin if Controls[i] is TSpeedButton then begin TSpeedButton(Controls[i]).Hint := trim('ColorNo'); end; end; end; cxGroupBox_keys.Left := Panel_right.Left + 5; cxGroupBox_keys.Visible := true; end; procedure TfrmMachRollMain.cxTextEdit1Click(Sender: TObject); begin if Trim(cxTextEdit1.Text) = '' then begin cxTextEdit1.Text := '√'; end else begin cxTextEdit1.Text := ''; end; end; procedure TfrmMachRollMain.C_COLORNOClick(Sender: TObject); begin if C_NAME.Text <> '' then begin FZT2 := '1'; Panel5.Visible := true; Panel3.Visible := false; InitGridys(); setFocusCtrol(TWinControl(Sender).Name); end; end; procedure TfrmMachRollMain.c_colornoEnter(Sender: TObject); var i: Integer; begin with FrameKeyBoard1.dxPanel1 do begin for i := 0 to ControlCount - 1 do begin if Controls[i] is TSpeedButton then begin TSpeedButton(Controls[i]).Hint := trim('C_COLORNO'); end; end; end; cxGroupBox_keys.Left := Panel_right.Left + 5; cxGroupBox_keys.Visible := true; end; procedure TfrmMachRollMain.c_colornoExit(Sender: TObject); var i: Integer; begin with FrameKeyBoard1.dxPanel1 do begin for i := 0 to ControlCount - 1 do begin if Controls[i] is TSpeedButton then begin TSpeedButton(Controls[i]).Hint := trim('C_NAME'); end; end; end; cxGroupBox_keys.Left := Panel_right.Left + 5; cxGroupBox_keys.Visible := true; end; procedure TfrmMachRollMain.c_colornoPropertiesChange(Sender: TObject); begin // ADO_YS.Locate('C_ColorNo', C_ColorNo.Text, []); // // C_Color.Text := ADO_YS.FieldByName('C_Color').ASSTRING; // if FZT2 = '1' then begin Panel5.Visible := true; InitGridYS(); end; end; procedure TfrmMachRollMain.C_NAME2Click(Sender: TObject); var i: Integer; begin with FrameKeyBoard1.dxPanel1 do begin for i := 0 to ControlCount - 1 do begin if Controls[i] is TSpeedButton then begin TSpeedButton(Controls[i]).Hint := trim('C_NAME'); end; end; end; cxGroupBox_keys.Left := Panel_right.Left + 5; cxGroupBox_keys.Visible := true; end; procedure TfrmMachRollMain.C_NAME2Enter(Sender: TObject); var i: Integer; begin with FrameKeyBoard1.dxPanel1 do begin for i := 0 to ControlCount - 1 do begin if Controls[i] is TSpeedButton then begin TSpeedButton(Controls[i]).Hint := trim('C_NAME'); end; end; end; cxGroupBox_keys.Left := Panel_right.Left + 5; cxGroupBox_keys.Visible := true; end; procedure TfrmMachRollMain.C_NAMEClick(Sender: TObject); begin fzt := '1'; Panel3.Visible := true; PANEL5.Visible := FALSE; InitGridCP(); setFocusCtrol(TWinControl(Sender).Name); end; procedure TfrmMachRollMain.C_NAMEExit(Sender: TObject); begin panel3.Visible := False; end; procedure TfrmMachRollMain.C_NAMEPropertiesChange(Sender: TObject); var I: Integer; S: string; begin if fzt = '1' then begin C_CoLOR.Text := ''; C_CoLORNO.Text := ''; Panel3.Visible := true; PANEL5.Visible := FALSE; InitGridCP(); end; end; procedure TfrmMachRollMain.dxLayoutControl_packDblClick(Sender: TObject); begin if gIsCanDesign then layoutDesign(TdxLayoutControl(Sender), ADOQueryBaseCmd, PWideChar(dcode)); end; procedure TfrmMachRollMain.dxLayoutItem1CaptionClick(Sender: TObject); var mkey: Char; begin inherited; // frmProductListHelp := TfrmProductListHelp.create(Self); // with frmProductListHelp do // begin // fType := '10'; // if ShowModal = 1 then // begin // edtScan.Text := trim(order_main.fieldbyName('Subid').AsString); // mkey := #13; // edtScanKeyPress(edtScan, mkey); // end; // free; // end; frmTradeClothTotalOutSel := TfrmTradeClothTotalOutSel.create(Self); with frmTradeClothTotalOutSel do begin if ShowModal = 1 then begin edtScan.Text := trim(CDS_Main.fieldbyName('BCIOID').AsString); end; free; end; mkey := #13; edtScanKeyPress(edtScan, mkey); end; procedure TfrmMachRollMain.edtScanDblClick(Sender: TObject); begin inherited; edtScan.Text := ''; end; procedure TfrmMachRollMain.edtScanEnter(Sender: TObject); begin inherited; setFocusCtrol(TWinControl(Sender).Name); end; procedure TfrmMachRollMain.edtScanKeyPress(Sender: TObject; var Key: Char); var strKeyID: string; begin inherited; if Key = #13 then begin if panel4.Visible = true then begin if trim(edtScan.Text) = FBCIOID then begin Application.MessageBox('原条码不用再次扫描!', '提示信息', MB_ICONERROR); edtScan.Text := ''; exit; end; if cds_hp.Locate('BCIOID', edtScan.Text, []) then begin Application.MessageBox('重复扫描!', '提示信息', MB_ICONERROR); edtScan.Text := ''; exit; // 已找到,后续逻辑 end; with ADOQueryBaseTemp do begin Close; SQL.Clear; SQL.Add('EXEC P_Trade_Insp_Get_plan @BCIOID=''' + trim(edtScan.Text) + ''''); Open; end; if ADOQueryBaseTemp.IsEmpty = false then begin if ADOQueryBaseTemp.fieldbyname('C_NAME').AsString <> CodeName.Text then begin Application.MessageBox('品名不一致!', '提示信息', MB_ICONERROR); edtScan.Text := ''; exit; end; if ADOQueryBaseTemp.fieldbyname('C_COLOR').AsString <> FC_Color then begin Application.MessageBox('颜色不一致!', '提示信息', MB_ICONERROR); edtScan.Text := ''; exit; end; if ADOQueryBaseTemp.fieldbyname('C_COLORno').AsString <> FC_Colorno then begin Application.MessageBox('色号不一致!', '提示信息', MB_ICONERROR); edtScan.Text := ''; exit; end; with CDS_HP do begin Append; CDS_HP.FieldByName('BCIOID').AsString := ADOQueryBaseTemp.FieldByName('BCIOID').AsString; CDS_HP.FieldByName('stkqty').VALUE := ADOQueryBaseTemp.FieldByName('stkqty').ASFLOAT; CDS_HP.FieldByName('qtyunit').VALUE := ADOQueryBaseTemp.FieldByName('qtyunit').AsString; Post; end; end; edtScan.Text := ''; edtScan.SetFocus(); end else begin if trim(edtScan.Text) = '' then exit; if trim(edtScan.Text) = FBCIOID then exit; if checkbox1.Checked then begin if not cds_2.Locate('ssel', True, []) then begin Application.MessageBox('请先选择数据!', '提示信息', MB_OK); Exit; end; strKeyID := cds_2.FieldByName('TMMID').AsString; end; ClearGlobal(); InitPlan(edtScan.Text); InitGrid2(); if trim(OrderNo.Text) <> '' then InputLen.SetFocus; cxGroupBox_keys.Visible := false; if checkbox1.Checked then begin Button1.Click(); if Trim(strKeyID) <> '' then begin cds_2.DisableControls; try cds_2.Locate('TMMID', strKeyID, []); cds_2.Edit; cds_2.FieldByName('ssel').AsBoolean := True; cds_2.Post; finally cds_2.EnableControls; end; end; end; end; end; end; function TfrmMachRollMain.SaveData(): Boolean; var MInputLen, MMeter, MYardage: double; MInputWeight, MGrossWeight, MNetWeight, MTare, Maddwet, maddLen: double; mYardStick: double; mPresentLen, mpresentWeight: double; MTMSId: string; begin Result := false; MTMSId := Trim(SelTVKey(Tv2, ['TMSId'])[0]); Maddwet := strTofloatDef(trim(addwet.text), 0); // Faddwet; maddLen := strTofloatDef(trim(addlen.text), 0); // faddlen; mYardStick := strtofloatdef(trim(RuleYardstick.Text), 100); mPresentLen := strTofloatDef(trim(presentlen.text), 0); mpresentWeight := strTofloatDef(trim(presentWeight.text), 0); if (strtoIntdef(Trim(unitPieces.Text), 0) > 0) and (strtoIntdef(trim(InputLen.Text), 0) > 0) then begin if strtoIntdef(trim(InputLen.Text), 0) > strtoIntdef(Trim(unitPieces.Text), 0) then funitPiecesStr := intTostr((strtoIntdef(trim(InputLen.Text), 0)) - strtoIntdef(Trim(unitPieces.Text), 0)) + '+' + Trim(unitPieces.Text); end; //0:不变;1:减去赠送 if gPresentNumFlag = 1 then begin mPresentLen := -1 * mPresentLen; mpresentWeight := -1 * mpresentWeight; end; try ADOQueryBaseCmd.Connection.BeginTrans; MTare := strtofloatdef(trim(Tare.Text), 0); // 皮重 MInputWeight := RoundFloat(strtofloatdef(trim(InputWeight.Text), 0), cds_params.fieldbyName('KgPlace').AsInteger); // 净重 MGrossWeight := MInputWeight + Maddwet + mpresentWeight; // 毛重 MNetWeight := MInputWeight + Maddwet + mpresentWeight - MTare; // 净重 +加重 MInputLen := RoundFloat(strtofloatdef(trim(InputLen.Text), 0), 4); // 换算后数量+mAddLen if (uppercase(lblLenUnit.Caption) = 'M') or (lblLenUnit.Caption = '米') then begin MMeter := RoundFloat((MInputLen + maddLen + mPresentLen) / (mYardStick / 100), cds_params.fieldbyName('MPlace').AsInteger); MYardage := RoundFloat(MMeter / 0.9144, cds_params.fieldbyName('YPlace').AsInteger); end else begin MYardage := RoundFloat((MInputLen + maddLen + mPresentLen) / (mYardStick / 100), cds_params.fieldbyName('YPlace').AsInteger); MMeter := RoundFloat(MYardage * 0.9144, cds_params.fieldbyName('MPlace').AsInteger); end; if FCKLX = '配货单' then begin with ADOQueryBaseCmd do begin Close; sql.Clear; Sql.Add('exec P_BS_Cloth_Out_Distribution_KC '); Sql.Add(' @GrossWeight=' + quotedstr(Trim(FloatToStr(MGrossWeight)))); Sql.Add(' ,@Tare=' + quotedstr(Trim(FloatToStr(MTare)))); Sql.Add(' ,@NetWeight=' + quotedstr(Trim(FloatToStr(MNetWeight)))); Sql.Add(' ,@Meter=' + quotedstr(Trim(FloatToStr(MMeter)))); Sql.Add(' ,@Yardage=' + quotedstr(Trim(FloatToStr(MYardage)))); Sql.Add(' ,@QtyUnit=' + quotedstr(Trim(lblLenUnit.caption))); Sql.Add(' ,@StkID=' + quotedstr(Trim(FBCIOID))); Sql.Add(' ,@TMSId =' + quotedstr(FTMSId)); Sql.Add(' ,@TMMId =' + quotedstr(FTMSId)); Sql.Add(' ,@Dcode=' + quotedstr(Trim(Dcode))); Sql.Add(' ,@DName=' + quotedstr(Trim(DName))); // ShowMessage(sql.Text); open; end; end else begin with ADOQueryBaseCmd do begin Close; sql.Clear; Sql.Add('exec P_BS_Cloth_Out_Distribution '); Sql.Add(' @GrossWeight=' + quotedstr(Trim(FloatToStr(MGrossWeight)))); Sql.Add(' ,@Tare=' + quotedstr(Trim(FloatToStr(MTare)))); Sql.Add(' ,@NetWeight=' + quotedstr(Trim(FloatToStr(MNetWeight)))); Sql.Add(' ,@Meter=' + quotedstr(Trim(FloatToStr(MMeter)))); Sql.Add(' ,@Yardage=' + quotedstr(Trim(FloatToStr(MYardage)))); Sql.Add(' ,@StkID=' + quotedstr(Trim(FBCIOID))); Sql.Add(' ,@TMSId =' + quotedstr(MTMSId)); Sql.Add(' ,@Dcode=' + quotedstr(Trim(Dcode))); Sql.Add(' ,@DName=' + quotedstr(Trim(DName))); ShowMessage(sql.Text); open; end; end; if ADOQueryBaseCmd.fieldbyName('intReturn').AsInteger = -1 then begin raise Exception.create(pchar(trim(ADOQueryBaseCmd.fieldbyName('ShowMsg').AsString))); end; FCIID := trim(trim(ADOQueryBaseCmd.fieldbyName('MaxIOID2').AsString)); ADOQueryBaseCmd.Connection.CommitTrans; TradeMarketProgressUpdate(ADOQueryBaseCmd, MTMSId); Result := true; except ADOQueryBaseCmd.Connection.RollbackTrans; Application.MessageBox(pchar(Exception(ExceptObject).Message), '提示信息', 0); end; end; procedure TfrmMachRollMain.SCAN2KeyPress(Sender: TObject; var Key: Char); begin if Key = #13 then begin with ADOQueryBaseTemp do begin Close; SQL.Clear; SQL.Add('EXEC P_Trade_Insp_Get_plan @BCIOID=''' + trim(SCAN2.Text) + ''''); Open; end; if ADOQueryBaseTemp.IsEmpty = false then begin if ADOQueryBaseTemp.fieldbyname('C_NAME').AsString <> CodeName.Text then begin Application.MessageBox('品名不一致!', '提示信息', MB_ICONERROR); SCAN2.Text := ''; exit; end; if ADOQueryBaseTemp.fieldbyname('C_COLOR').AsString <> FC_Color then begin Application.MessageBox('颜色不一致!', '提示信息', MB_ICONERROR); SCAN2.Text := ''; exit; end; if ADOQueryBaseTemp.fieldbyname('C_COLORno').AsString <> FC_Colorno then begin Application.MessageBox('色号不一致!', '提示信息', MB_ICONERROR); SCAN2.Text := ''; exit; end; with CDS_HP do begin Append; CDS_HP.FieldByName('BCIOID').AsString := ADOQueryBaseTemp.FieldByName('BCIOID').AsString; CDS_HP.FieldByName('stkqty').VALUE := ADOQueryBaseTemp.FieldByName('stkqty').ASFLOAT; CDS_HP.FieldByName('qtyunit').VALUE := ADOQueryBaseTemp.FieldByName('qtyunit').AsString; Post; end; end; SCAN2.Text := ''; end; end; procedure TfrmMachRollMain.Panel1Click(Sender: TObject); begin Panel3.Visible := false; Panel5.Visible := false; end; procedure TfrmMachRollMain.PrtData(MCIID: string; againPring: Boolean = false); var fPrintFile: string; Txt, fImagePath, Txt2, fImagePath2: string; Moudle: Thandle; Makebar: TMakebar; Mixtext: TMixtext; begin with ADOQueryPrint do begin Close; SQL.Clear; SQL.Add(' EXEC P_BS_Cloth_Prt2 '); SQL.Add(' @Filtration=''' + trim(MCIID) + ''''); Open; end; if ADOQueryPrint.IsEmpty then begin Application.MessageBox('标签内容未找到!', '提示信息', MB_ICONERROR); exit; end; // if trim(ADOQueryPrint.fieldbyName('SLabVolume').AsString) <> '' then // fLabVolume := trim(ADOQueryPrint.fieldbyName('SLabVolume').AsString) // else // fLabVolume := trim(ADOQueryPrint.fieldbyName('LabVolume').AsString); // if fLabVolume = '' then // begin // Application.MessageBox('订单还未设置标签!', '提示信息', MB_ICONERROR); // exit; // end; // // ExportFtErpFile(fLabVolume + '.fr3', ADOQueryBaseTemp); // fPrintFile := ExtractFilePath(Application.ExeName) + 'Report\' + fLabVolume + '.fr3'; ExportFtErpFile('客户标签.fr3', ADOQueryBaseTemp); fPrintFile := ExtractFilePath(Application.ExeName) + 'Report\客户标签.fr3'; if FileExists(fPrintFile) then begin frxReport1.LoadFromFile(fPrintFile); frxReport1.PrintOptions.Copies := cds_params.fieldbyName('labNumber').AsInteger; frxReport1.PrintOptions.ShowDialog := false; frxReport1.PrepareReport(True); frxReport1.Print(); end else begin Application.MessageBox(PChar('没有找到' + fPrintFile), '提示', 0); end; end; procedure TfrmMachRollMain.PrtData2(MCIID: string; againPring: Boolean = false); var fPrintFile: string; Txt, fImagePath, Txt2, fImagePath2: string; Moudle: Thandle; Makebar: TMakebar; Mixtext: TMixtext; begin with ADOQueryPrint do begin Close; SQL.Clear; SQL.Add(' EXEC P_BS_Cloth_Prt2 '); SQL.Add(' @Filtration=''' + trim(MCIID) + ''''); Open; end; if ADOQueryPrint.IsEmpty then begin Application.MessageBox('标签内容未找到!', '提示信息', MB_ICONERROR); exit; end; // if trim(ADOQueryPrint.fieldbyName('SLabVolume').AsString) <> '' then // fLabVolume := trim(ADOQueryPrint.fieldbyName('SLabVolume').AsString) // else // fLabVolume := trim(ADOQueryPrint.fieldbyName('LabVolume').AsString); // if fLabVolume = '' then // begin // Application.MessageBox('订单还未设置标签!', '提示信息', MB_ICONERROR); // exit; // end; // // ExportFtErpFile(fLabVolume + '.fr3', ADOQueryBaseTemp); // fPrintFile := ExtractFilePath(Application.ExeName) + 'Report\' + fLabVolume + '.fr3'; ExportFtErpFile('客户退仓标签.fr3', ADOQueryBaseTemp); fPrintFile := ExtractFilePath(Application.ExeName) + 'Report\客户退仓标签.fr3'; if FileExists(fPrintFile) then begin frxReport1.LoadFromFile(fPrintFile); frxReport1.PrintOptions.Copies := cds_params.fieldbyName('labNumber').AsInteger; frxReport1.PrintOptions.ShowDialog := false; frxReport1.PrepareReport(True); frxReport1.Print(); end else begin Application.MessageBox(PChar('没有找到' + fPrintFile), '提示', 0); end; end; procedure TfrmMachRollMain.BadSpeedButtonClick(Sender: TObject); begin end; procedure TfrmMachRollMain.On1301(var Message: Tmessage); var i1, i2: Integer; unitname: string; fdata: double; begin i1 := Message.WParam; i2 := Message.LParam; if (trim(cds_params.fieldbyName('mabiao').AsString) = '1') then begin InputLen.Text := format('%.2f', [i1 / 100000]); if trim(cds_params.fieldbyName('mbunit').AsString) = '1' then begin if i2 = 0 then begin SetUnit('M'); end else begin SetUnit('Y'); end; end; end; end; procedure TfrmMachRollMain.On1201(var Message: Tmessage); var i1, i2: Integer; unitname: string; fdata: double; begin i1 := Message.WParam; i2 := Message.LParam; if trim(cds_params.fieldbyName('chen').AsString) = '1' then begin InputWeight.Text := format('%.2f', [i1 / 100000]); end; end; ///////////////////////////////////// function TfrmMachRollMain.deletePack(packId: string): boolean; var ccids: string; packNo: integer; begin try ccids := ''; packNo := strtointdef(Trim(cds_3.FieldByName('packetNo').AsString), 0); ADOQueryBaseCmd.Connection.BeginTrans; cds_3.First; while not cds_3.eof do begin if Trim(cds_3.FieldByName('packetid').AsString) = packId then begin ccids := ccids + ',' + Trim(cds_3.FieldByName('CIID').AsString); end; with ADOQueryBaseCmd do begin Close; SQL.Clear; SQL.Add('insert into Trade_Need_Up(UType,UOperation,UDataId,uoperator) values(''检验'',''检验删除'',' + QuotedStr(Trim(cds_3.FieldByName('CIID').AsString)) + ',' + QuotedStr(DName) + ') '); ExecSQL; end; cds_3.Next; end; with ADOQueryBaseCmd do begin Close; SQL.Clear; SQL.Add('exec P_Trade_Insp_Del '); SQL.Add('@CIIDS=' + QuotedStr(ccids)); SQL.Add(',@DCode=' + QuotedStr(DCode)); SQL.Add(',@DName=' + QuotedStr(DName)); Open; end; if ADOQueryBaseCmd.fieldbyName('intReturn').AsInteger = -1 then begin raise Exception.create(pchar(trim(ADOQueryBaseCmd.fieldbyName('ShowMsg').AsString))); end; ADOQueryBaseCmd.Connection.CommitTrans; InitJYGrid(); Application.MessageBox('删除成功!', '提示信息'); except ADOQueryBaseCmd.Connection.RollbackTrans; Application.MessageBox(pchar(Exception(ExceptObject).Message), '提示信息', 0); end; end; end.