unit U_MarkingInspection; interface uses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, StdCtrls, cxStyles, cxCustomData, cxGraphics, cxFilter, cxData, cxDataStorage, cxEdit, DB, cxDBData, cxCalendar, cxGridLevel, cxGridCustomTableView, cxGridTableView, cxGridDBTableView, cxClasses, cxControls, cxGridCustomView, cxGrid, RM_Common, RM_Class, RM_GridReport, RM_System, RM_Dataset, ADODB, DBClient, cxGridCustomPopupMenu, cxGridPopupMenu, ExtCtrls, ComCtrls, ToolWin, cxTextEdit, Buttons, cxSplitter, cxCheckBox, MovePanel, cxLookAndFeels, cxLookAndFeelPainters, cxNavigator, Menus, dxSkinsCore, dxSkinsDefaultPainters, dxSkinscxPCPainter, cxContainer, cxImage, dxSkinBlack, dxSkinBlue, dxSkinBlueprint, dxSkinCaramel, dxSkinCoffee, dxSkinDarkRoom, dxSkinDarkSide, dxSkinDevExpressDarkStyle, dxSkinDevExpressStyle, dxSkinFoggy, dxSkinGlassOceans, dxSkinHighContrast, dxSkiniMaginary, dxSkinLilian, dxSkinLiquidSky, dxSkinLondonLiquidSky, dxSkinMcSkin, dxSkinMetropolis, dxSkinMetropolisDark, dxSkinMoneyTwins, dxSkinOffice2007Black, dxSkinOffice2007Blue, dxSkinOffice2007Green, dxSkinOffice2007Pink, dxSkinOffice2007Silver, dxSkinOffice2010Black, dxSkinOffice2010Blue, dxSkinOffice2010Silver, dxSkinOffice2013DarkGray, dxSkinOffice2013LightGray, dxSkinOffice2013White, dxSkinPumpkin, dxSkinSeven, dxSkinSevenClassic, dxSkinSharp, dxSkinSharpPlus, dxSkinSilver, dxSkinSpringTime, dxSkinStardust, dxSkinSummer2008, dxSkinTheAsphaltWorld, dxSkinValentine, dxSkinVS2010, dxSkinWhiteprint, dxSkinXmas2008Blue; type TZintSymbol = packed record symbology: Integer; height: Integer; whitespace_width: Integer; border_width: Integer; output_options: Integer; fgcolour: array[0..9] of AnsiChar; bgcolour: array[0..9] of AnsiChar; outfile: array[0..255] of AnsiChar; scale: Single; option_1: Integer; option_2: Integer; option_3: Integer; show_hrt: Integer; input_mode: Integer; eci: Integer; text: array[0..127] of AnsiChar; rows: Integer; width: Integer; primary: array[0..127] of AnsiChar; encoded_data: array[0..199, 0..142] of AnsiChar; row_height: array[0..199] of Integer; // Largest symbol is 189 x 189 errtxt: array[0..99] of AnsiChar; bitmap: PAnsiChar; bitmap_width: Integer; bitmap_height: Integer; bitmap_byte_length: Cardinal; dot_size: Single; rendered: Pointer; debug: Integer; end; PZintSymbol = ^TZintSymbol; const // Tbarcode 7 codes BARCODE_QRCODE = 71; type TfrmMarkingInspection = class(TForm) cxStyleRepository1: TcxStyleRepository; cxStyle1: TcxStyle; cxStyle2: TcxStyle; cxGridPopupMenu1: TcxGridPopupMenu; DataSource1: TDataSource; Order_MJ: TClientDataSet; ADOQueryMain: TADOQuery; ADOCmd: TADOQuery; RMDB_Main: TRMDBDataSet; RM2: TRMGridReport; cxGrid3: TcxGrid; Tv3: TcxGridDBTableView; cxGridDBColumn1: TcxGridDBColumn; cxGridLevel2: TcxGridLevel; DataSource2: TDataSource; CDS_MJCD: TClientDataSet; DataSource3: TDataSource; CDS_MJID: TClientDataSet; Timer1: TTimer; ADOQueryPrint: TADOQuery; cxGridPopupMenu2: TcxGridPopupMenu; ADOQueryMainDSC: TADOQuery; Panel2: TPanel; Label9: TLabel; MJLen: TEdit; Label4: TLabel; MJMaoZ: TEdit; Label5: TLabel; Label11: TLabel; BTPrint: TButton; Button5: TButton; Edit3: TEdit; Label10: TLabel; Edit4: TEdit; Label12: TLabel; Panel3: TPanel; SpeedButton1: TSpeedButton; SpeedButton2: TSpeedButton; SpeedButton3: TSpeedButton; SpeedButton4: TSpeedButton; SpeedButton5: TSpeedButton; SpeedButton6: TSpeedButton; SpeedButton7: TSpeedButton; SpeedButton8: TSpeedButton; SpeedButton9: TSpeedButton; SpeedButton10: TSpeedButton; SpeedButton11: TSpeedButton; SpeedButton12: TSpeedButton; SpeedButton49: TSpeedButton; v3Column1: TcxGridDBColumn; v3Column2: TcxGridDBColumn; v3Column3: TcxGridDBColumn; Label26: TLabel; Edit6: TEdit; Label30: TLabel; MJQty3: TEdit; Label31: TLabel; Label32: TLabel; MJQty4: TEdit; MovePanel1: TMovePanel; Label17: TLabel; Label18: TLabel; Label20: TLabel; Label21: TLabel; Label7: TLabel; Label8: TLabel; Edit1: TEdit; Button1: TButton; Button4: TButton; Edit2: TEdit; CDQty: TEdit; RadioGroup1: TRadioGroup; Button2: TButton; Panel7: TPanel; cxGrid2: TcxGrid; Tv2: TcxGridDBTableView; tv2CDType: TcxGridDBColumn; tv2CDWZ: TcxGridDBColumn; v2Column2: TcxGridDBColumn; Tv2CDQty: TcxGridDBColumn; Tv2CDReason: TcxGridDBColumn; v2Column1: TcxGridDBColumn; v2Column3: TcxGridDBColumn; cxGridLevel1: TcxGridLevel; Panel8: TPanel; AOrdDefNote1: TRichEdit; Label34: TLabel; ComboBox1: TComboBox; v3Column4: TcxGridDBColumn; Label36: TLabel; MJStr4: TEdit; Label37: TLabel; v3Column5: TcxGridDBColumn; Label38: TLabel; RM3: TRMGridReport; mjxh: TEdit; MKXS: TEdit; Panel5: TPanel; Panel6: TPanel; Label1: TLabel; Label35: TLabel; Label39: TLabel; APID: TEdit; edtChen: TEdit; Edit8: TEdit; ToolBar1: TToolBar; ToolButton1: TToolButton; TBCD: TToolButton; TBClose: TToolButton; ToolButton3: TToolButton; Label13: TLabel; v3Column6: TcxGridDBColumn; Label14: TLabel; edtYJ: TEdit; Label2: TLabel; v2Column4: TcxGridDBColumn; ADOTmp: TADOQuery; Label3: TLabel; Label6: TLabel; MJFMLen: TEdit; ToolButton2: TToolButton; Button3: TButton; JYPerson: TEdit; Label15: TLabel; Label16: TLabel; edtMaBiao: TEdit; lblbq: TLabel; Button6: TButton; Label19: TLabel; KuangHao: TEdit; v3Column7: TcxGridDBColumn; v3Column8: TcxGridDBColumn; ToolButton4: TToolButton; Button7: TButton; Button8: TButton; Button9: TButton; Tv3Column1: TcxGridDBColumn; ScrollBox1: TScrollBox; SpeedButton13: TSpeedButton; SpeedButton14: TSpeedButton; SpeedButton15: TSpeedButton; SpeedButton16: TSpeedButton; SpeedButton17: TSpeedButton; SpeedButton18: TSpeedButton; SpeedButton21: TSpeedButton; SpeedButton22: TSpeedButton; SpeedButton23: TSpeedButton; SpeedButton24: TSpeedButton; SpeedButton25: TSpeedButton; SpeedButton26: TSpeedButton; SpeedButton29: TSpeedButton; SpeedButton30: TSpeedButton; SpeedButton31: TSpeedButton; SpeedButton32: TSpeedButton; SpeedButton33: TSpeedButton; SpeedButton34: TSpeedButton; SpeedButton37: TSpeedButton; SpeedButton38: TSpeedButton; SpeedButton39: TSpeedButton; SpeedButton40: TSpeedButton; SpeedButton41: TSpeedButton; SpeedButton42: TSpeedButton; SpeedButton45: TSpeedButton; SpeedButton46: TSpeedButton; SpeedButton47: TSpeedButton; SpeedButton48: TSpeedButton; SpeedButton50: TSpeedButton; SpeedButton51: TSpeedButton; SpeedButton54: TSpeedButton; SpeedButton55: TSpeedButton; SpeedButton56: TSpeedButton; SpeedButton57: TSpeedButton; SpeedButton58: TSpeedButton; SpeedButton59: TSpeedButton; SpeedButton62: TSpeedButton; SpeedButton63: TSpeedButton; SpeedButton64: TSpeedButton; SpeedButton65: TSpeedButton; SpeedButton66: TSpeedButton; SpeedButton67: TSpeedButton; SpeedButton70: TSpeedButton; SpeedButton71: TSpeedButton; SpeedButton72: TSpeedButton; SpeedButton73: TSpeedButton; SpeedButton74: TSpeedButton; SpeedButton75: TSpeedButton; SpeedButton19: TSpeedButton; SpeedButton20: TSpeedButton; SpeedButton27: TSpeedButton; SpeedButton28: TSpeedButton; SpeedButton35: TSpeedButton; SpeedButton36: TSpeedButton; SpeedButton43: TSpeedButton; SpeedButton44: TSpeedButton; SpeedButton52: TSpeedButton; SpeedButton53: TSpeedButton; SpeedButton60: TSpeedButton; SpeedButton61: TSpeedButton; SpeedButton68: TSpeedButton; SpeedButton69: TSpeedButton; SpeedButton76: TSpeedButton; SpeedButton77: TSpeedButton; SpeedButton78: TSpeedButton; SpeedButton79: TSpeedButton; SpeedButton80: TSpeedButton; SpeedButton81: TSpeedButton; SpeedButton82: TSpeedButton; SpeedButton83: TSpeedButton; PopupMenu1: TPopupMenu; N1: TMenuItem; Label22: TLabel; edtZDBB: TEdit; CDS_DDB: TClientDataSet; Panel1: TPanel; Label23: TLabel; Label24: TLabel; Button10: TButton; cxImage1: TcxImage; ToolButton6: TToolButton; SpeedButton84: TSpeedButton; SpeedButton85: TSpeedButton; SpeedButton86: TSpeedButton; SpeedButton87: TSpeedButton; SpeedButton88: TSpeedButton; SpeedButton89: TSpeedButton; SpeedButton90: TSpeedButton; SpeedButton91: TSpeedButton; SpeedButton92: TSpeedButton; SpeedButton93: TSpeedButton; SpeedButton94: TSpeedButton; SpeedButton95: TSpeedButton; SpeedButton96: TSpeedButton; SpeedButton97: TSpeedButton; SpeedButton98: TSpeedButton; SpeedButton99: TSpeedButton; SpeedButton100: TSpeedButton; SpeedButton101: TSpeedButton; SpeedButton102: TSpeedButton; SpeedButton103: TSpeedButton; SpeedButton104: TSpeedButton; SpeedButton105: TSpeedButton; SpeedButton106: TSpeedButton; SpeedButton107: TSpeedButton; SpeedButton108: TSpeedButton; SpeedButton109: TSpeedButton; SpeedButton110: TSpeedButton; SpeedButton111: TSpeedButton; SpeedButton112: TSpeedButton; SpeedButton113: TSpeedButton; SpeedButton114: TSpeedButton; SpeedButton115: TSpeedButton; SpeedButton116: TSpeedButton; SpeedButton117: TSpeedButton; SpeedButton118: TSpeedButton; SpeedButton119: TSpeedButton; SpeedButton120: TSpeedButton; SpeedButton121: TSpeedButton; SpeedButton122: TSpeedButton; SpeedButton123: TSpeedButton; procedure FormDestroy(Sender: TObject); procedure FormClose(Sender: TObject; var Action: TCloseAction); procedure TBCloseClick(Sender: TObject); procedure TBCDClick(Sender: TObject); procedure FormShow(Sender: TObject); procedure Tv2CellDblClick(Sender: TcxCustomGridTableView; ACellViewInfo: TcxGridTableDataCellViewInfo; AButton: TMouseButton; AShift: TShiftState; var AHandled: Boolean); procedure BTPrintClick(Sender: TObject); procedure SpeedButton1Click(Sender: TObject); procedure SpeedButton12Click(Sender: TObject); procedure SpeedButton13Click(Sender: TObject); procedure cxGridDBColumn2PropertiesChange(Sender: TObject); procedure Button1Click(Sender: TObject); procedure ToolButton1Click(Sender: TObject); procedure Button5Click(Sender: TObject); procedure SpeedButton49Click(Sender: TObject); procedure APIDKeyPress(Sender: TObject; var Key: Char); procedure Edit1Click(Sender: TObject); procedure Edit2Change(Sender: TObject); procedure Edit3Click(Sender: TObject); procedure Edit4Click(Sender: TObject); procedure Edit6Click(Sender: TObject); procedure MJstr3KeyPress(Sender: TObject; var Key: Char); procedure MJQty4Exit(Sender: TObject); procedure Button2Click(Sender: TObject); procedure MJMaoZChange(Sender: TObject); procedure APIDClick(Sender: TObject); procedure MJQty4KeyPress(Sender: TObject; var Key: Char); procedure FormCreate(Sender: TObject); procedure Edit8Click(Sender: TObject); procedure MJLenChange(Sender: TObject); procedure ToolButton3Click(Sender: TObject); procedure Tv3CustomDrawCell(Sender: TcxCustomGridTableView; ACanvas: TcxCanvas; AViewInfo: TcxGridTableDataCellViewInfo; var ADone: Boolean); procedure Button4Click(Sender: TObject); procedure edtYJClick(Sender: TObject); procedure ToolButton2Click(Sender: TObject); procedure Button3Click(Sender: TObject); procedure edtChenClick(Sender: TObject); procedure Button6Click(Sender: TObject); procedure ToolButton4Click(Sender: TObject); procedure Button7Click(Sender: TObject); procedure Button9Click(Sender: TObject); procedure Button8Click(Sender: TObject); procedure N1Click(Sender: TObject); procedure Button10Click(Sender: TObject); procedure ToolButton6Click(Sender: TObject); private { Private declarations } FColumn, FAPID, FMainId, FSubId, FFFMJID, FOperationStatus, FYXJL, FJHGZ, FMBJS, FBBQFS: string; FBaoId, FBaoNo: string; FCDName, FCP: string; FTongChi: Double; FKSJH: Integer; isCommopen, IsJsMessage: boolean; fxsType, fRollType: string; procedure InitJP(); //刷新疵点选项 procedure InitCDGrid(); //刷新疵点信息 procedure InitCDGridID(); //刷新检验信息 function CheckData(CKType: string): Boolean; //校验数据 function SaveData(): Boolean; //保存数据 procedure InitLCK(); //扫描流程卡 procedure InitDDB(); //扫描待定布 procedure ClearGlobal(); //清除全局ID procedure PrintCKMDG(MRKOrdID: string); //打印入库单 procedure PrtData(FMJID: string); //打印卷标签 procedure QuantityConversion(); //数量换算 procedure GetBaoNo(); //获取包号 procedure PrintBaoLab(BaoId: string); //打印包标签 procedure DaBao(ISSD: string); //获取打包数据并打包 procedure OpenCom(DllName: string); procedure CloseCom(DllName: string); procedure On1201(var Message: Tmessage); message 1201; procedure On1301(var Message: Tmessage); message 1301; public fmanage: string; FKHEWM: string; fkhname: string; { Public declarations } end; const LibName = 'zint.dll'; //struct zint_symbol *ZBarcode_Create(void); function ZBarcode_Create(): PZintSymbol; cdecl; external LibName; //void ZBarcode_Delete(struct zint_symbol *symbol); procedure ZBarcode_Delete(symbol: PZintSymbol); cdecl; external LibName; //int ZBarcode_Encode_and_Buffer(struct zint_symbol *symbol, unsigned char *input, int length, int rotate_angle); function ZBarcode_Encode_and_Buffer(symbol: PZintSymbol; input: PAnsiChar; length, rotate_angle: Integer): Integer; cdecl; external LibName; // create bitmap 这个函数是使用编码后的条码图像数据生成Bitmap文件,不属于zint,因此不在zint.h头文件中,上面的三个在zint.h头文件中。 procedure ZBarcode_To_Bitmap(symbol: PZintSymbol; const ABitmap: TBitmap); var frmMarkingInspection: TfrmMarkingInspection; newh, newh1: hwnd; implementation uses U_DataLink, U_Fun, U_ZDYHelp, U_iniParam, U_ProductOrderListSel, U_JYG, U_ZdyMapSel, U_ZDYHelp2; {$R *.dfm} procedure TfrmMarkingInspection.DaBao(ISSD: string); var FWSql: string; begin with ADOTmp do begin Close; sql.Clear; sql.Add(' select * from WFB_MJJY X '); sql.Add(' where isnull(X.BaoId,'''')='''' and X.subid=' + quotedstr(trim(FSubId))); if Trim(SCXFlag) <> '' then sql.Add(' and X.JTType=' + quotedstr(trim(SCXFlag))); sql.Add(' and X.Filler=' + quotedstr(trim(DName))); Open; end; SCreateCDS20(ADOTmp, CDS_DDB); SInitCDSData20(ADOTmp, CDS_DDB); if not CDS_DDB.IsEmpty then begin if (CDS_DDB.RecordCount = StrToIntDef(FMBJS, 999)) or (Trim(ISSD) = '手动') then begin GetBaoNo(); FWSql := ''; with CDS_DDB do begin First; while not Eof do begin FWSql := FWSql + 'UPDATE WFB_MJJY Set baoid=' + quotedstr(trim(FBaoID)) + ',baono=' + quotedstr(trim(Fbaono)); FWSql := FWSql + ' where MJID=' + quotedstr(trim(CDS_DDB.FieldByName('MJID').AsString)); Next; end; end; with ADOTmp do begin Close; sql.Clear; sql.Add(FWSql); ExecSQL; end; PrintBaoLab(FBaoID); end; end; end; procedure ZBarcode_To_Bitmap(symbol: PZintSymbol; const ABitmap: TBitmap); var SrcRGB: PRGBTriple; Row, RowWidth: Integer; begin ABitmap.PixelFormat := pf24bit; ABitmap.Height := symbol.bitmap_height; ABitmap.Width := symbol.bitmap_width; // ABitmap.Height := 80; // ABitmap.Width := 80; SrcRGB := Pointer(symbol.bitmap); RowWidth := symbol.bitmap_width * 3; for Row := 0 to symbol.bitmap_height - 1 do begin CopyMemory(ABitmap.ScanLine[Row], SrcRGB, RowWidth); Inc(SrcRGB, symbol.bitmap_width); end; SetBitmapBits(ABitmap.Handle, symbol.bitmap_width * symbol.bitmap_height * 3, symbol.bitmap); end; procedure TfrmMarkingInspection.GetBaoNo(); begin FBaoID := ''; FBaoNo := ''; if GetLSNo(ADOTmp, FBaoID, 'BI', 'WFB_MJJY', 3, 1) = False then begin Application.MessageBox('取包条码最大号失败!', '提示', 0); Exit; end; with ADOTmp do begin close; sql.Clear; sql.Add('select max(cast(isnull(baoNO,0) as int))+1 as maxbaoNO from WFB_MJJY '); sql.Add('where subid=' + quotedstr(trim(FSubId))); open; end; FBaoNo := ADOTmp.fieldbyname('maxbaoNO').AsString; end; procedure TfrmMarkingInspection.PrintBaoLab(BaoId: string); var fPrintFile: string; Txt, fImagePath: string; Moudle: THandle; Makebar: TMakebar; Mixtext: TMixtext; i: Integer; begin if Trim(BaoId) = '' then exit; with ADOQueryPrint do begin Close; SQL.Clear; sql.Add('exec P_Do_PrintDaBao ' + quotedstr(Trim(BaoId))); Open; end; if ADOQueryPrint.IsEmpty = True then Exit; try Moudle := LoadLibrary('MakeQRBarcode.dll'); @Makebar := GetProcAddress(Moudle, 'Make'); @Mixtext := GetProcAddress(Moudle, 'MixText'); Txt := trim(BaoId); 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; if Trim(ADOQueryPrint.fieldbyname('NLBName').AsString) <> '' then begin ExportFtErpFile(Trim(ADOQueryPrint.fieldbyname('NLbName').AsString) + '.rmf', ADOTmp); fPrintFile := ExtractFilePath(Application.ExeName) + 'Report\' + Trim(ADOQueryPrint.fieldbyname('NLbName').AsString) + '.rmf' end else fPrintFile := ExtractFilePath(Application.ExeName) + 'Report\包标签.rmf'; if not FileExists(fPrintFile) then begin Application.MessageBox(PChar('没有找' + fPrintFile), '提示', 0); Exit; end; if FileExists(fPrintFile) then begin RMVariables['QRBARCODE'] := fImagePath; RM2.LoadFromFile(fPrintFile); RM2.DefaultCopies := StrToIntDef(FBBQFS, 0); RM2.printReport; end; end; procedure TfrmMarkingInspection.QuantityConversion(); var MLen, MNWet, MGWet, MPWet, MCC, FYJZQty: Double; begin MLen := StrToFloatdef(trim(MJLen.Text), 0); MNWet := StrToFloatdef(trim(MJQty4.Text), 0); MPWet := StrToFloatdef(trim(MJQty3.Text), 0); MGWet := StrToFloatdef(trim(MJMaoZ.Text), 0); MCC := StrToFloatdef(trim(MKXS.Text), 0); //长度 与 减去长度 if TV2.DataController.Summary.FooterSummaryValues[2] <> NULL then begin FYJZQty := StrToFloatdef(TV2.DataController.Summary.FooterSummaryValues[2], 0); end else begin FYJZQty := 0; end; { // 换算重量 if MCC > 0 then begin MGWet := StrToFloat(format('%.1f', [(MLen - FYJZQty) * MCC])); MNWet := MGWet - MPWet; MJMaoZ.Text := FloatToStr(MGWet); MJQty4.Text := FloatToStr(MNWet); end; } MNWet := MGWet - MPWet; //换算米数 if MCC > 0 then begin MLen := RoundFloat(MNWet * MCC, 1); MJLen.Text := FloatToStr(MLen); end; MJQty4.Text := FloatToStr(MNWet); end; function TfrmMarkingInspection.CheckData(CKType: string): Boolean; var mvalue: Double; begin try if Trim(FAPID) = '' then raise Exception.Create('请扫描流程卡!'); if Trim(FMainId) = '' then raise Exception.Create('请扫描流程卡!'); if Trim(FSubId) = '' then raise Exception.Create('请扫描流程卡!'); if Trim(CKType) = '提交' then begin if Trim(KuangHao.Text) = '' then raise Exception.Create('框号不能为空!'); if Trim(JYPerson.Text) = '' then raise Exception.Create('请输入验布工!'); if trim(Label9.Caption) = '' then raise Exception.Create('长度单位不能为空!'); if Trim(MJMaoZ.Text) <> '' then begin if TryStrToFloat(MJMaoZ.Text, mvalue) = False then raise Exception.Create('重量录入错误!'); if strtofloatdef(trim(MJMaoZ.Text), 0) > 80 then raise Exception.Create('重量不能大于80!'); end; if strtofloatdef(trim(MJQty4.Text), 0) <= 0.00 then raise Exception.Create('重量不能小于0!'); if strtofloatdef(trim(MJLen.Text), 0) <= 0.00 then raise Exception.Create('长度不能小于0!'); if Trim(MJLen.Text) <> '' then begin if strtofloatdef(trim(MJLen.Text), 0) > 400 then raise Exception.Create('长度不能大于400!'); end; if (strtofloatdef(trim(MJLen.Text), 0) = 0) and (strtofloatdef(trim(MJQty4.Text), 0) = 0) then raise Exception.Create('长度和重量不能都为0!!'); end; Result := True; except Result := false; application.MessageBox(PChar(Exception(ExceptObject).Message), '提示信息', 0); end; end; procedure TfrmMarkingInspection.ClearGlobal(); begin FAPID := ''; FJHGZ := ''; FMainId := ''; FSubId := ''; FFFMJID := ''; MJXH.Text := ''; MJstr4.Text := ''; MKXS.Text := ''; AOrdDefNote1.Text := ''; MJQty3.Text := ''; MJQty4.Text := ''; Label13.Caption := '实际平均系数:'; Label14.Caption := '理论系数:'; end; procedure TfrmMarkingInspection.PrintCKMDG(MRKOrdID: string); var fPrintFile: string; Txt, fImagePath: string; Moudle: THandle; Makebar: TMakebar; Mixtext: TMixtext; begin with ADOQueryPrint do begin Close; SQL.Clear; sql.Add(' exec P_Print_RKMDGangNo '); SQL.Add(' @RKOrdID=''' + Trim(MRKOrdID) + ''''); Open; end; try Moudle := LoadLibrary('MakeQRBarcode.dll'); @Makebar := GetProcAddress(Moudle, 'Make'); @Mixtext := GetProcAddress(Moudle, 'MixText'); Txt := Trim(ADOQueryPrint.fieldbyname('RKOrdID').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', ADOTmp); fPrintFile := ExtractFilePath(Application.ExeName) + 'Report\验布工仓库码单.rmf'; if FileExists(fPrintFile) then begin RMVariables['QRBARCODE'] := fImagePath; RM2.LoadFromFile(fPrintFile); Rm2.DefaultCopies := 1; RM2.ShowReport; end else begin Application.MessageBox(PChar('没有找' + fPrintFile), '提示', 0); Exit; end; end; procedure TfrmMarkingInspection.InitDDB(); begin with ADOTmp do begin Close; sql.Clear; sql.Add('select * from CK_BanCP_CR where MJID=''' + Trim(APID.Text) + ''' and CRFlag=''入库'''); Open; end; if ADOTmp.IsEmpty = False then begin APID.Text := ''; Application.MessageBox('已产生入库数据检验!', '提示', 0); Exit; end; with ADOTmp do begin Close; sql.Clear; sql.Add('select A.*,B.*,C.*,D.MJID,D.MJXH,D.MKXS,D.MJMaoZ,D.MJQty3,D. MJQty4,D.MJLen '); sql.Add('from CK_SXPB_CR A'); sql.Add('inner join JYOrder_Main B on A.ORDMainIdCK=B.MainId'); sql.Add('inner join JYOrder_Sub C on A.ORDSubIdCK=C.SubId'); sql.Add('inner join WFB_MJJY D on D.APID=A.SPID'); sql.Add('where MJType=''待定'' and MJID=''' + Trim(APID.Text) + ''''); Open; end; if ADOTmp.IsEmpty then begin ClearGlobal(); Application.MessageBox('此条码不是待定状态无法重新检验!', '提示', 0); end else begin FAPID := Trim(ADOTmp.fieldbyname('SPID').AsString); FMainId := Trim(ADOTmp.fieldbyname('ORDMainIdRK').AsString); FSubId := Trim(ADOTmp.fieldbyname('ORDSubIdRK').AsString); FFFMJID := Trim(ADOTmp.fieldbyname('MJID').AsString); MJXH.Text := Trim(ADOTmp.fieldbyname('MJXH').AsString); MJstr4.Text := Trim(ADOTmp.fieldbyname('rcgangNo').AsString); MKXS.Text := Trim(ADOTmp.fieldbyname('Xs').AsString); AOrdDefNote1.Text := '计划单:' + Trim(ADOTmp.fieldbyname('OrderNo').AsString) + #13 + '品名:' + Trim(ADOTmp.fieldbyname('MPRTCodeName').AsString) + #13 + '颜色:' + trim(ADOTmp.fieldbyname('PRTColor').AsString) + #13 + '包装要求:' + Trim(ADOTmp.fieldbyname('MPRTBZNote').AsString) + #13 + '门幅:' + Trim(ADOTmp.fieldbyname('MPRTMF').AsString) + #13 + '克重:' + Trim(ADOTmp.fieldbyname('MPRTKZ').AsString) + #13 + '特别提示:' + Trim(ADOTmp.fieldbyname('Note').AsString); // MJQty3.Text := Trim(ADOTmp.fieldbyname('PiZhong').AsString); MKXS.Text := Trim(ADOTmp.fieldbyname('MKXS').AsString); MJMaoZ.Text := Trim(ADOTmp.fieldbyname('MJMaoZ').AsString); MJQty3.Text := Trim(ADOTmp.fieldbyname('MJQty3').AsString); MJQty4.Text := Trim(ADOTmp.fieldbyname('MJQty4').AsString); MJLen.Text := Trim(ADOTmp.fieldbyname('MJLen').AsString); if Trim(ADOTmp.fieldbyname('OrderUnit').AsString) <> '' then begin Label20.Caption := Label9.Caption; Label7.Caption := Label9.Caption; end; end; with ADOCmd do begin Close; sql.Clear; sql.Add('insert into SY_SysLog(operor,opertime,Model,acction,opevent,result) values( '); sql.Add(' ' + quotedstr(trim(DName))); sql.Add(',getdate() '); sql.Add(',' + quotedstr(trim(self.Caption))); sql.Add(',' + quotedstr(trim('翻布重检验'))); sql.Add(',' + quotedstr(trim('卷号:' + trim(APID.Text)))); sql.Add(',' + quotedstr(trim('成功'))); sql.Add(')'); ExecSQL; end; InitCDGridID(); InitCDGrid(); APID.Text := ''; end; procedure TfrmMarkingInspection.InitLCK(); begin with ADOTmp do begin Close; sql.Clear; sql.Add('select A.CRTYPE,A.ORDMainIdCK,A.ORDSubIdCK,A.rcgangNo,A.TongChi,A.KSJH,A.RCGangNo,A.GangNo,A.PiQty KKPS,A.Qty KKQty,A.QtyUnit KKUnit,A.XS '); sql.Add(',B.*,C.* '); sql.Add(',maxRoll=1+isnull((select cast (max(mjxh) as int) from WFB_MJJY X where X.APID=A.SPID and X.MJType =''正品'' ),0)'); sql.Add(',maxBaoNO=isnull((select max(cast(baoNO as int)) from WFB_MJJY X where X.subid=A.subid ),0)+1'); sql.Add('from CK_SXPB_CR A'); sql.Add('inner join JYOrder_Main B on A.ORDMainIdCK=B.MainId'); sql.Add('inner join JYOrder_Sub C on A.ORDSubIdCK=C.SubId'); sql.Add('where SPID=''' + Trim(APID.Text) + ''''); // ShowMessage(sql.Text); Open; end; if ADOTmp.IsEmpty = False then begin FAPID := Trim(APID.Text); FCP := Trim(ADOTmp.fieldbyname('CRTYPE').AsString); FTongChi := ADOTmp.fieldbyname('TongChi').AsFloat; if FTongChi = 0 then FTongChi := 1; if FKSJH < 1 then FKSJH := 1; FMainId := Trim(ADOTmp.fieldbyname('ORDMainIdCK').AsString); FSubId := Trim(ADOTmp.fieldbyname('ORDSubIdCK').AsString); FYXJL := Trim(ADOTmp.fieldbyname('YXJL').AsString); FJHGZ := Trim(ADOTmp.fieldbyname('JHGZ').AsString); fkhname := Trim(ADOTmp.fieldbyname('CustomerNoName').AsString); FMBJS := Trim(ADOTmp.fieldbyname('MBJS').AsString); FBBQFS := Trim(ADOTmp.fieldbyname('BBQFS').AsString); if FJHGZ = '手动输入' then begin mjxh.ReadOnly := False; end else begin mjxh.ReadOnly := True; end; ComboBox1.Text := Trim(ADOTmp.fieldbyname('LabQty').AsString); if FKSJH > ADOTmp.fieldbyname('maxRoll').AsInteger then MJXH.Text := IntToStr(FKSJH) else MJXH.Text := Trim(ADOTmp.fieldbyname('maxRoll').AsString); MJstr4.Text := Trim(ADOTmp.fieldbyname('gangNo').AsString); KuangHao.Text := ''; MKXS.Text := Trim(ADOTmp.fieldbyname('Xs').AsString); panel1.Visible := True; Label23.Caption := '订单号:' + Trim(ADOTmp.fieldbyname('OrderNo').AsString); Label24.Caption := '颜色:' + Trim(ADOTmp.fieldbyname('PRTColor').AsString); AOrdDefNote1.Text := '计划单:' + Trim(ADOTmp.fieldbyname('OrderNo').AsString) + #13; AOrdDefNote1.Text := AOrdDefNote1.Text + '品名:' + Trim(ADOTmp.fieldbyname('MPRTCodeName').AsString) + #13; AOrdDefNote1.Text := AOrdDefNote1.Text + '颜色:' + Trim(ADOTmp.fieldbyname('PRTColor').AsString) + #13; AOrdDefNote1.Text := AOrdDefNote1.Text + '染厂缸号:' + Trim(ADOTmp.fieldbyname('RCGangNo').AsString) + #13; AOrdDefNote1.Text := AOrdDefNote1.Text + '本厂缸号:' + Trim(ADOTmp.fieldbyname('GangNo').AsString) + #13; AOrdDefNote1.Text := AOrdDefNote1.Text + '匹数:' + Trim(ADOTmp.fieldbyname('KKPS').AsString) + '数量:' + Trim(ADOTmp.fieldbyname('KKQty').AsString) + Trim(ADOTmp.fieldbyname('KKUnit').AsString) + #13; AOrdDefNote1.Text := AOrdDefNote1.Text + '包装要求:' + Trim(ADOTmp.fieldbyname('MPRTBZNote').AsString) + #13; AOrdDefNote1.Text := AOrdDefNote1.Text + '特别提示:' + Trim(ADOTmp.fieldbyname('Note').AsString); MJQty3.Text := Trim(ADOTmp.fieldbyname('PiZhong').AsString); if FYXJL = '米数' then begin MJLen.SetFocus; Edit1Click(MJLen); end else begin MJMaoZ.SetFocus; Edit1Click(MJMaoZ); end; Label14.Caption := '理论系数:' + trim(ADOTmp.fieldbyname('LLXS').AsString); end else begin ClearGlobal(); end; if FCP = '次品出库' then begin Edit4.Text := '√'; Edit3.Text := ''; end else begin Edit3.Text := '√'; Edit4.Text := ''; end; InitCDGridID(); InitCDGrid(); APID.Text := ''; end; procedure TfrmMarkingInspection.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 TfrmMarkingInspection.OpenCom(DllName: string); type TMyFunc = function(fhandle: hwnd; sCommName: PAnsiChar; IntTime: integer; IsMessage: integer): HWND; stdcall; var Tf: TMyFunc; Tp: TFarProc; Th: Thandle; begin // closeCom(FComFile); 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 IsCommOpen := true; end else begin IsCommOpen := false; end; finally // FreeLibrary(Th); end; end else begin IsCommOpen := false; application.MessageBox(Pchar('找不到 ' + trim(DllName) + ' 文件!'), '提示'); end; end; procedure TfrmMarkingInspection.FormDestroy(Sender: TObject); begin frmMarkingInspection := nil; end; procedure TfrmMarkingInspection.On1301(var Message: Tmessage); var i1, i2: integer; unitname: string; fdata: double; begin i1 := Message.WParam; i2 := Message.LParam; if (trim(edtMaBiao.Text) = '√') then begin MJLen.Text := format('%.1f', [i1 / 100000]); if i2 = 0 then Label9.Caption := 'M' else Label9.Caption := 'Y'; edit1.Text := format('%.1f', [i1 / 100000]); end; end; procedure TfrmMarkingInspection.On1201(var Message: Tmessage); var i1, i2: integer; unitname: string; fdata: double; begin i1 := Message.WParam; i2 := Message.LParam; if trim(edtChen.Text) = '√' then begin MJMaoZ.Text := format('%.1f', [i1 / 100000]); end; end; procedure TfrmMarkingInspection.FormClose(Sender: TObject; var Action: TCloseAction); begin //DataLink_WFBProducttion.ADOLink.Connected:=False; if isCommopen then begin closeCom(DZCDYDllName); closeCom(MBDYDllName); end; Action := caFree; end; procedure TfrmMarkingInspection.InitCDGrid(); begin with ADOQueryMain do begin Close; SQL.Clear; sql.Add('select * from WFB_MJJY_CD where MJID=' + quotedstr(Trim(FFFMJID))); Open; end; SCreateCDS20(ADOQueryMain, CDS_MJCD); SInitCDSData20(ADOQueryMain, CDS_MJCD); end; procedure TfrmMarkingInspection.InitCDGridID(); var MMJQty4, MMJLen: double; begin with ADOQueryMain do begin Close; SQL.Clear; sql.Add('select A.*'); sql.Add(',JXXS=(case when MJQty4>0 then round(MJLen/MJQty4,2) else 0 end)'); sql.Add('from WFB_MJJY A where APID=''' + Trim(FAPID) + ''''); // if Trim(SCXFlag) <> '' then // sql.Add(' and JTType=''' + Trim(SCXFlag) + ''''); sql.Add(' and Filler=''' + Trim(DName) + ''''); sql.Add('and convert(varchar(10),filltime,120)=convert(varchar(10),getdate(),120)'); // sql.Add(' and MJstr2=''未入库'' '); sql.Add(' order by filltime desc'); // showmessage(sql.Text); Open; end; SCreateCDS20(ADOQueryMain, CDS_MJID); SInitCDSData20(ADOQueryMain, CDS_MJID); if TV3.DataController.Summary.FooterSummaryValues[1] <> NULL then MMJLen := TV3.DataController.Summary.FooterSummaryValues[1] else MMJLen := 0; if TV3.DataController.Summary.FooterSummaryValues[3] <> NULL then MMJQty4 := TV3.DataController.Summary.FooterSummaryValues[3] else MMJQty4 := 0; if MMJQty4 > 0 then Label13.Caption := '实际平均系数:' + floattostr(RoundFloat(MMJLen / MMJQty4, 2)) else Label13.Caption := '实际平均系数:'; /////////////////////// 显示产量 //////////////////////////////// with ADOTmp do begin Close; SQL.Clear; sql.Add('select COUNT(mjid) PS,SUM(MJMaoZ) MZ,SUM(MJLen) ZD,SUM(MJQty4) JZ '); sql.Add('from WFB_MJJY where CONVERT(varchar(10),Filltime,120)=CONVERT(varchar(10),GETDATE(),120)'); if Trim(SCXFlag) <> '' then sql.Add(' and JTType=''' + Trim(SCXFlag) + ''''); sql.Add(' and Filler=''' + Trim(DName) + ''''); Open; end; lblbq.Caption := '匹数:' + ADOTmp.FieldByname('PS').AsString; lblbq.Caption := lblbq.Caption + ' 米数:' + ADOTmp.FieldByname('ZD').AsString; lblbq.Caption := lblbq.Caption + ' 毛重:' + ADOTmp.FieldByname('MZ').AsString; lblbq.Caption := lblbq.Caption + ' 净重:' + ADOTmp.FieldByname('JZ').AsString; /////////////////////// 显示产量 //////////////////////////////// end; procedure TfrmMarkingInspection.TBCloseClick(Sender: TObject); begin Close; end; procedure TfrmMarkingInspection.TBCDClick(Sender: TObject); begin try frmZDYHelp := TfrmZDYHelp.Create(Application); with frmZDYHelp do begin flag := 'WFBCD'; flagname := '疵点'; fnote := True; V1Note.Caption := '英文名称'; if ShowModal = 1 then begin Self.InitJP(); end; end; finally frmZDYHelp.Free; end; end; procedure TfrmMarkingInspection.FormShow(Sender: TObject); begin InitJP(); InitCDGrid(); if IsINIFile() then ReadINIFile() else WriteINIFile; if trim(fmanage) <> '高权限' then begin if trim(DZCDYDllName) <> '' then OpenCom(DZCDYDllName); if trim(MBDYDllName) <> '' then OpenCom(MBDYDllName); edtChen.Visible := true; edtMaBiao.Visible := true; Label35.Visible := true; end; end; procedure TfrmMarkingInspection.InitJP(); var AA: array[0..150] of string; i, j: Integer; begin with ADOTmp do begin Close; sql.Clear; sql.Add('select ZDYName from KH_Zdy where Type=''WFBCD'' order by ZDYNO '); Open; end; if ADOTmp.IsEmpty then begin Application.MessageBox('没有定义疵点!', '提示', 0); Exit; end; with ADOTmp do begin First; i := 0; while not Eof do begin AA[i] := Trim(fieldbyname('ZDYName').AsString); i := i + 1; Next; end; end; i := i - 1; if i > 109 then begin i := 109; end; for j := 0 to i do begin with ScrollBox1 do begin TSpeedButton(Controls[j]).Visible := True; TSpeedButton(Controls[j]).Hint := AA[j]; if Length(AA[j]) > 4 then begin TSpeedButton(Controls[j]).Caption := Copy(Trim(AA[j]), 1, 4) + #13 + Copy(Trim(AA[j]), 5, Length(AA[j]) - 4); end else TSpeedButton(Controls[j]).Caption := AA[j]; end; end; end; procedure TfrmMarkingInspection.Tv2CellDblClick(Sender: TcxCustomGridTableView; ACellViewInfo: TcxGridTableDataCellViewInfo; AButton: TMouseButton; AShift: TShiftState; var AHandled: Boolean); begin if CDS_MJCD.IsEmpty then Exit; if Trim(CDS_MJCD.fieldbyname('MCID').AsString) = '' then begin if Application.MessageBox('确定要删除数据吗?', '提示', 32 + 4) <> IDYES then Exit; CDS_MJCD.Delete; end; end; function TfrmMarkingInspection.SaveData(): Boolean; var maxno, FMJID, BZID, strsql: string; FMJLen, FYJZQty: Double; begin if FOperationStatus = '翻布重检' then begin FMJID := FFFMJID; end else begin FMJID := ''; end; try ADOCmd.Connection.BeginTrans; ///保存主表 with ADOCmd do begin Close; sql.Clear; SQL.Add('select * from WFB_MJJY where MJId=''' + Trim(FMJID) + ''''); Open; end; with ADOCmd do begin if Trim(FMJID) = '' then begin Append; if GetLSNo(ADOTmp, maxno, Trim(SCXFlag), 'WFB_MJJY', 4, 1) = False then begin ADOCmd.Connection.RollbackTrans; Application.MessageBox('生成流水号异常!', '提示', 0); exit; end; end else begin maxno := Trim(FMJID); Edit; end; FieldByName('MainId').value := Trim(FMainId); FieldByName('SubId').value := Trim(FSubId); FieldByName('FromMainId').value := Trim(FMainId); FieldByName('FromSubId').value := Trim(FSubId); FieldByName('APId').value := Trim(FAPID); FieldByName('MJID').Value := Trim(maxno); FieldByName('MJStr2').Value := '未入库'; FieldByName('MJstr4').Value := Trim(MJstr4.Text); //本厂缸号 FieldByName('KuangHao').Value := Trim(KuangHao.Text); FieldByName('mjxh').Value := strtointdef(trim(mjxh.Text), 0); FieldByName('MJTypeOther').Value := Trim(Label9.Caption); FieldByName('JYPerson').Value := Trim(JYPerson.Text); //长度 与 减去长度 if TV2.DataController.Summary.FooterSummaryValues[2] <> NULL then begin FYJZQty := StrToFloatdef(TV2.DataController.Summary.FooterSummaryValues[2], 0); end else begin FYJZQty := 0; end; //放码 FieldByName('MJFMLen').Value := StrToFloatDef(MJFMLen.Text, 0); FieldByName('YJZQty').Value := FYJZQty; FieldByName('MJLen').Value := RoundFloat(StrToFloatdef(trim(MJLen.Text), 0) / FTongChi, 1); //- FYJZQty - StrToFloatDef(MJFMLen.Text, 0) TongChi FieldByName('MJYLen').Value := RoundFloat(StrToFloatdef(trim(MJLen.Text), 0) / FTongChi / 0.9144, 1); //包号 // FieldByName('BAONO').Value := Trim(baono.Text); //皮重 FieldByName('MJQty3').Value := StrToFloatdef(trim(MJQty3.Text), 0); //毛重 FieldByName('MJMaoZ').Value := StrToFloatdef(trim(MJMaoZ.Text), 0); //净重 FieldByName('MJQty4').Value := StrToFloatdef(trim(MJMaoZ.Text), 0) - StrToFloatdef(trim(MJQty3.Text), 0); //系数 FieldByName('MKXS').Value := StrToFloatdef(trim(MKXS.Text), 0); if Trim(Edit3.Text) <> '' then begin FieldByName('MJType').Value := '正品'; end; if Trim(Edit4.Text) <> '' then begin FieldByName('MJType').Value := '次品'; end; if Trim(FMJID) = '' then begin FieldByName('Filler').Value := Trim(DName); end else begin FieldByName('Editer').Value := Trim(DName); FieldByName('EditTime').Value := SGetServerDateTime(ADOTmp); end; //检验机台号 if Trim(SCXFlag) <> '' then begin FieldByName('JTType').Value := Trim(SCXFlag); end; FieldByName('MJTypeOther').Value := Trim(Label9.Caption); Post; end; // if FJHGZ = '按缸排序' then begin with ADOCmd do begin Close; sql.Clear; sql.Add('update WFB_MJJY SET mjxh=1+isnull((select cast (max(mjxh) as int) from WFB_MJJY X where X.subID=WFB_MJJY.subID and X.MJstr4=WFB_MJJY.Mjstr4 and X.APID=WFB_MJJY.APID and X.MJID<>WFB_MJJY.MJID and X.MJType =''正品''),0)'); sql.Add('where MJID=''' + Trim(maxno) + ''''); sql.Add('update WFB_MJJY SET mjxh=X.KSJH from CK_SXPB_CR X where X.SPID=WFB_MJJY.APID and mjxhWFB_MJJY.MJID and X.MJType =''次品''),0)'); sql.Add('where MJType =''次品'' and MJID=''' + Trim(maxno) + ''''); execsql; end; ////////// 次品的卷号 ///////////////// //查询卷号修改界面 with ADOCmd do begin Close; sql.Clear; sql.Add('select MJXH from WFB_MJJY'); sql.Add('where MJID=''' + Trim(maxno) + ''''); open; if not IsEmpty then begin MJXH.Text := fieldbyname('mjxh').AsString; end; end; FMJID := Trim(maxno); FFFMJID := Trim(maxno); ///保存母卷疵点表 with CDS_MJCD do begin First; while not Eof do begin if Trim(CDS_MJCD.fieldbyname('MCID').AsString) = '' then begin if GetLSNo(ADOTmp, maxno, 'MC', 'WFB_MJJY_CD', 5, 1) = False then begin ADOCmd.Connection.RollbackTrans; Application.MessageBox('取子流水号失败!', '提示', 0); Exit; end; end else begin maxno := Trim(CDS_MJCD.fieldbyname('MCID').AsString); end; with ADOCmd do begin Close; SQL.Clear; sql.Add('select * from WFB_MJJY_CD '); sql.Add(' where MCID=''' + Trim(maxno) + ''''); Open; end; with ADOCmd do begin if Trim(CDS_MJCD.fieldbyname('MCID').AsString) = '' then Append else Edit; FieldByName('MJId').Value := Trim(FMJID); FieldByName('MCID').Value := Trim(maxno); SSetSaveDataCDSNew(ADOCmd, Tv2, CDS_MJCD, 'WFB_MJJY_CD', 0); FieldByName('KouFenType').Value := CDS_MJCD.fieldbyname('KouFenType').Value; Post; end; CDS_MJCD.Edit; CDS_MJCD.FieldByName('MCID').Value := Trim(maxno); Next; end; end; with ADOCmd do begin close; sql.Clear; sql.Add('update WFB_MJJY SET CDList= dbo.F_Get_Order_SubStr(MJID,''MJCDHZSL'')'); sql.Add('where MJID=''' + Trim(FMJID) + ''' '); execsql; end; //出入库及库存 with ADOCmd do begin Close; sql.Clear; sql.Add('exec P_Do_JYCRK @MJID=''' + trim(FMJID) + ''''); execsql; end; if (FCP = '次品出库') or (FCP = '库存开卡') then begin with ADOCmd do begin Close; sql.Clear; sql.Add('update CK_BanCP_KC set CPKCNoet=(select cpyy+'',处理方式为''+clfs from ck_sxpb_Cr where Spid=(select APID FROM WFB_MJJY C WHERE C.MJID=''' + trim(FMJID) + ''''); SQL.Add('))'); SQL.Add('WHERE MJID=''' + trim(FMJID) + ''''); execsql; end; end; //更新开卡 with ADOCmd do begin Close; sql.Clear; sql.Add('exec P_UPdate_LCKJY @APID=''' + trim(FAPID) + ''''); execsql; end; ADOCmd.Connection.CommitTrans; Result := True; except Result := False; ADOCmd.Connection.RollbackTrans; Application.MessageBox('保存失败!', '提示', 0); end; end; procedure TfrmMarkingInspection.BTPrintClick(Sender: TObject); var fPrintFile: string; mvalue: Double; i: Integer; begin APID.SetFocus; if strtofloatdef(trim(MJLen.Text), 0) > 200 then begin if Application.MessageBox('长度大于200继续操作吗?', '提示', 32 + 4) <> IDYES then Exit; end; if CheckData('提交') = False then exit; // if FJHGZ = '手动输入' then // begin // with ADOTmp do // begin // Close; // sql.Clear; // SQL.Add('select * from WFB_MJJY where APID=' + quotedstr(Trim(FAPID))); // SQL.Add(' and mjxh=' + Trim(mjxh.Text)); // Open; // end; // if not ADOTmp.IsEmpty then // begin // if Application.MessageBox('当前卷号已存在,是否继续保存?', '提示', 32 + 4) <> IDYES then // Exit; // end; // end; if SaveData() then begin MJLen.Text := ''; MJFMLen.Text := ''; MJMaoZ.Text := ''; MJQty4.Text := ''; if FCP = '次品出库' then begin Edit4.Text := '√'; Edit3.Text := ''; end else begin Edit3.Text := '√'; Edit4.Text := ''; end; MJXH.Text := inttostr(strTointdef(trim(MJXH.Text), 0) + 1); if Trim(Edit6.Text) = '√' then begin PrtData(FFFMJID); end; end; FOperationStatus := ''; FFFMJID := ''; if Trim(edtZDBB.Text) <> '' then DaBao('自动'); InitCDGridID(); InitCDGrid(); MJLen.SetFocus; Edit1Click(MJLen); end; procedure TfrmMarkingInspection.PrtData(FMJID: string); var fPrintFile: string; Txt, fImagePath, Txt2, fImagePath2, Txt3, fImagePath3, Txt4, fImagePath4: string; Moudle: THandle; Makebar: TMakebar; Mixtext: TMixtext; begin with ADOQueryPrint do begin Close; SQL.Clear; sql.Add(' EXEC P_Print_JYLab '); SQL.Add(' @MJID=''' + Trim(FMJID) + ''''); Open; end; if ADOQueryPrint.IsEmpty then begin application.MessageBox('标签内容未找到!', '提示信息', MB_ICONERROR); exit; end; try Moudle := LoadLibrary('MakeQRBarcode.dll'); @Makebar := GetProcAddress(Moudle, 'Make'); @Mixtext := GetProcAddress(Moudle, 'MixText'); Txt := Trim(ADOQueryPrint.fieldbyname('MJID').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; try Moudle := LoadLibrary('MakeQRBarcode.dll'); @Makebar := GetProcAddress(Moudle, 'Make'); @Mixtext := GetProcAddress(Moudle, 'MixText'); Txt2 := Trim(ADOQueryPrint.fieldbyname('KHEWM').AsString); fImagePath2 := ExtractFilePath(Application.ExeName) + 'image\temp2.bmp'; if not DirectoryExists(pchar(ExtractFilePath(Application.ExeName) + 'image')) then CreateDirectory(pchar(ExtractFilePath(Application.ExeName) + 'image'), nil); if FileExists(fImagePath2) then DeleteFile(fImagePath2); Makebar(pchar(Txt2), Length(Txt2), 3, 3, 0, PChar(fImagePath2), 3); except application.MessageBox('条形码生成失败!', '提示信息', MB_ICONERROR); exit; end; try Moudle := LoadLibrary('MakeQRBarcode.dll'); @Makebar := GetProcAddress(Moudle, 'Make'); @Mixtext := GetProcAddress(Moudle, 'MixText'); Txt3 := Trim(ADOQueryPrint.fieldbyname('MJID2').AsString); fImagePath3 := ExtractFilePath(Application.ExeName) + 'image\temp3.bmp'; if not DirectoryExists(pchar(ExtractFilePath(Application.ExeName) + 'image')) then CreateDirectory(pchar(ExtractFilePath(Application.ExeName) + 'image'), nil); if FileExists(fImagePath3) then DeleteFile(fImagePath3); Makebar(pchar(Txt3), Length(Txt3), 3, 3, 0, PChar(fImagePath3), 3); except application.MessageBox('条形码生成失败!', '提示信息', MB_ICONERROR); exit; end; if fkhname = 'QUALITY TEXTILES' then begin try fImagePath4 := ExtractFilePath(Application.ExeName) + 'image\temp4.bmp'; if not DirectoryExists(pchar(ExtractFilePath(Application.ExeName) + 'image')) then CreateDirectory(pchar(ExtractFilePath(Application.ExeName) + 'image'), nil); if FileExists(fImagePath4) then DeleteFile(fImagePath4); FKHEWM := ADOQueryPrint.fieldbyname('khewm2').AsString; ToolButton6.Click(); except application.MessageBox('条形码生成失败!', '提示信息', MB_ICONERROR); exit; end; end; ExportFtErpFile(Trim(ADOQueryPrint.fieldbyname('LBName').AsString) + '.rmf', ADOTmp); if Trim(ADOQueryPrint.fieldbyname('LBName').AsString) <> '' then begin fPrintFile := ExtractFilePath(Application.ExeName) + 'Report\' + Trim(ADOQueryPrint.fieldbyname('LBName').AsString) + '.rmf' end else begin ExportFtErpFile('通用英文标签.rmf', ADOTmp); fPrintFile := ExtractFilePath(Application.ExeName) + 'Report\通用英文标签.rmf'; end; if FileExists(fPrintFile) then begin RMVariables['QRBARCODE'] := fImagePath; RMVariables['QRBARCODE2'] := fImagePath2; RMVariables['QRBARCODE3'] := fImagePath3; if fkhname = 'QUALITY TEXTILES' then begin RMVariables['QRBARCODE4'] := fImagePath4; end; RM2.LoadFromFile(fPrintFile); if Trim(ADOQueryPrint.fieldbyname('LBName').AsString) <> '次品标签' then Rm2.DefaultCopies := strtointdef(trim(ComboBox1.Text), 1) else Rm2.DefaultCopies := 1; RM2.PrintReport; end else begin Application.MessageBox(PChar('没有找' + fPrintFile), '提示', 0); end; end; procedure TfrmMarkingInspection.SpeedButton1Click(Sender: TObject); var fsj: string; begin fsj := Trim(TSpeedButton(Sender).Hint); if Trim(fsj) = '' then Exit; if TEdit(FindComponent(Trim(TSpeedButton(Sender).Hint))).Name = 'KuangHao' then Exit; fsj := Trim(TEdit(FindComponent(Trim(TSpeedButton(Sender).Hint))).Text); TEdit(FindComponent(Trim(TSpeedButton(Sender).Hint))).Text := fsj + Trim(TSpeedButton(Sender).Caption); TEdit(FindComponent(Trim(TSpeedButton(Sender).Hint))).SelectAll; end; procedure TfrmMarkingInspection.SpeedButton12Click(Sender: TObject); var fsj: string; begin fsj := Trim(TEdit(FindComponent(Trim(TSpeedButton(Sender).Hint))).Text); if Trim(fsj) = '' then Exit; TEdit(FindComponent(Trim(TSpeedButton(Sender).Hint))).Text := Copy(fsj, 1, Length(fsj) - 1); TEdit(FindComponent(Trim(TSpeedButton(Sender).Hint))).SelectAll; end; procedure TfrmMarkingInspection.SpeedButton13Click(Sender: TObject); var i: Integer; begin if CheckData('疵点') = False then exit; FCDName := Trim(TSpeedButton(Sender).Hint); MovePanel1.Visible := True; Label21.Caption := Trim(FCDName); //显示数字键盘 Edit1.SetFocus; Panel3.Visible := True; with Panel3 do begin for i := 0 to ControlCount - 1 do begin if Controls[i] is TSpeedButton then begin TSpeedButton(Controls[i]).Hint := Trim(Edit1.Name); end; end; end; end; procedure TfrmMarkingInspection.cxGridDBColumn2PropertiesChange(Sender: TObject); var fsj: string; begin fsj := Trim(Order_MJ.fieldbyname('SubId').AsString); Order_MJ.DisableControls; with Order_MJ do begin First; while not Eof do begin if Trim(Order_MJ.fieldbyname('SubId').AsString) <> fsj then begin Edit; FieldByName('SSel').Value := False; end; Next; end; end; Order_MJ.EnableControls; Order_MJ.Locate('SubId', fsj, []); end; procedure TfrmMarkingInspection.Button1Click(Sender: TObject); var mvalue: Double; begin { if Trim(Edit1.Text)='' then begin Application.MessageBox('位置不能为空!','提示',0); exit; end; } if Trim(Edit1.Text) <> '' then begin if Trim(Edit2.Text) <> '' then begin if StrToFloat(Edit2.Text) < StrToFloat(Edit1.Text) then begin Application.MessageBox('疵点位置录入错误!', '提示', 0); Exit; end; end; end; if CDQty.Text <> '' then begin if TryStrToFloat(CDQty.Text, mvalue) = False then begin Application.MessageBox('非法数字!', '提示', 0); Exit; end; end; with CDS_MJCD do begin Append; FieldByName('cdname').Value := Trim(FCDName); FieldByName('CDbeg').Value := Trim(Edit1.Text); FieldByName('CDEnd').Value := Trim(Edit2.Text); FieldByName('KouFenQty').Value := 0; if RadioGroup1.ItemIndex > -1 then FieldByName('KouFenType').Value := RadioGroup1.Items.Strings[RadioGroup1.ItemIndex]; if RadioGroup1.ItemIndex > -1 then begin if RadioGroup1.ItemIndex < 3 then begin FieldByName('KouFenQty').Value := RadioGroup1.ItemIndex + 1; end else begin FieldByName('KouFenQty').Value := 4; end; end; if Trim(FCDName) = '测幅宽' then FieldByName('KouFenQty').Value := 0; FieldByName('CDQty').Value := StrToFloatdef(trim(CDQty.Text), 0); if Trim(edtYJ.Text) <> '' then begin FieldByName('YJQty').Value := StrToFloatdef(trim(CDQty.Text), 0); end else begin FieldByName('YJQty').Value := 0; end; Post; end; Edit1.Text := ''; Edit2.Text := ''; CDQty.Text := ''; MovePanel1.Visible := False; Panel3.Visible := False; end; procedure TfrmMarkingInspection.ToolButton1Click(Sender: TObject); begin InitJP(); end; procedure TfrmMarkingInspection.Button5Click(Sender: TObject); var fPrintFile: string; i: Integer; mvalue: Double; begin if CDS_MJID.IsEmpty then Exit; PrtData(CDS_MJID.fieldbyname('MJID').AsString); end; procedure TfrmMarkingInspection.SpeedButton49Click(Sender: TObject); begin Panel3.Visible := False; end; procedure TfrmMarkingInspection.APIDKeyPress(Sender: TObject; var Key: Char); begin if Key = #13 then begin if StrToIntDef(APID.Text, 0) > 0 then APID.Text := 'DC' + APID.Text; ClearGlobal(); FOperationStatus := '打卷检验'; InitLCK(); APID.Text := ''; JYPerson.Text := ''; edtZDBB.Text := ''; end; end; procedure TfrmMarkingInspection.Edit1Click(Sender: TObject); var i: Integer; begin Panel3.Visible := True; with Panel3 do begin for i := 0 to ControlCount - 1 do begin if Controls[i] is TSpeedButton then begin TSpeedButton(Controls[i]).Hint := Trim(TEdit(Sender).Name); end; end; end; end; procedure TfrmMarkingInspection.Edit2Change(Sender: TObject); var mvalue: Double; begin if Trim(Edit1.Text) <> '' then begin if TryStrToFloat(Edit1.Text, mvalue) = False then begin Application.MessageBox('非法数字!', '提示', 0); Exit; end; end else begin Exit; end; if Trim(Edit2.Text) <> '' then begin if TryStrToFloat(Edit2.Text, mvalue) = False then begin Application.MessageBox('非法数字!', '提示', 0); Exit; end; end else begin Exit; end; CDQty.Text := FloatToStr(StrToFloat(Edit2.Text) - StrToFloat(Edit1.Text)); end; procedure TfrmMarkingInspection.Edit3Click(Sender: TObject); begin if Trim(Edit3.Text) = '' then begin Edit3.Text := '√'; Edit4.Text := ''; end else begin Edit3.Text := ''; Edit4.Text := '√'; end; end; procedure TfrmMarkingInspection.Edit4Click(Sender: TObject); begin if Trim(Edit4.Text) = '' then begin Edit4.Text := '√'; Edit3.Text := ''; end else begin Edit4.Text := ''; Edit3.Text := '√'; end; end; procedure TfrmMarkingInspection.Edit6Click(Sender: TObject); begin if Trim(Edit6.Text) = '' then begin Edit6.Text := '√'; end else begin Edit6.Text := ''; end; end; procedure TfrmMarkingInspection.MJstr3KeyPress(Sender: TObject; var Key: Char); begin if Key = #13 then begin Key := #0; SelectNext(ActiveControl as TWinControl, True, True); end; end; procedure TfrmMarkingInspection.MJQty4Exit(Sender: TObject); begin if (trim(MJMaoZ.Text) = '') and (trim(MJQty4.Text) = '') then exit; if (trim(MJMaoZ.Text) = '') and (trim(MJQty3.Text) = '') then exit; if (trim(MJQty4.Text) = '') and (trim(MJQty3.Text) = '') then exit; if (trim(MJQty3.Text) = '') then exit; if (trim(MJQty4.Text) <> '') then begin MJMaoZ.Text := floattostr(strtofloatdef(trim(MJQty3.Text), 0) + strtofloatdef(trim(MJQty4.Text), 0)); exit; end; end; procedure TfrmMarkingInspection.Button2Click(Sender: TObject); begin RadioGroup1.ItemIndex := -1; end; procedure TfrmMarkingInspection.MJMaoZChange(Sender: TObject); begin QuantityConversion(); end; procedure TfrmMarkingInspection.APIDClick(Sender: TObject); var i: Integer; begin Panel3.Visible := True; with Panel3 do begin for i := 0 to ControlCount - 1 do begin if Controls[i] is TSpeedButton then begin TSpeedButton(Controls[i]).Hint := Trim(TEdit(Sender).Name); end; end; end; end; procedure TfrmMarkingInspection.MJQty4KeyPress(Sender: TObject; var Key: Char); begin if Key = #13 then begin BTPrint.Click; end; end; procedure TfrmMarkingInspection.FormCreate(Sender: TObject); begin IsCommopen := false; IsJsMessage := false; end; procedure TfrmMarkingInspection.Edit8Click(Sender: TObject); begin if Trim(Edit8.Text) = '' then begin Edit8.Text := '√'; Button5.Visible := true; Button8.Visible := True; end else begin Edit8.Text := ''; Button5.Visible := false; Button8.Visible := False; end; end; procedure TfrmMarkingInspection.MJLenChange(Sender: TObject); begin //QuantityConversion(); end; procedure TfrmMarkingInspection.ToolButton3Click(Sender: TObject); var SRKOrdID, strsql: string; begin ToolButton3.Enabled := false; if Trim(MJStr4.Text) = '' then begin Application.MessageBox('请输入缸号!', '提示', 0); Exit; end; if Trim(FAPID) = '' then begin Application.MessageBox('请扫描流程卡!', '提示', 0); Exit; end; if Trim(FMainId) = '' then begin Application.MessageBox('请选择指示单!', '提示', 0); Exit; end; if Trim(FSubId) = '' then begin Application.MessageBox('请选择颜色!', '提示', 0); Exit; end; if Application.MessageBox('是否核实好数据', '提示', 32 + 4) <> IDYES then begin ToolButton3.Enabled := true; Exit; end; if GetLSNo(ADOTmp, SRKOrdID, 'RK', 'CK_BanCP_CR', 4, 1) = False then begin Application.MessageBox('生成流水号异常!', '提示', 0); exit; end; try ADOCmd.Connection.BeginTrans; with Self.ADOCmd do begin Close; sql.Clear; sql.Add('UPDATE CK_BanCP_CR Set '); sql.add('RKOrdID=' + quotedstr(trim(SRKOrdID))); sql.Add(' where CK_BanCP_CR.APID=' + quotedstr(trim(FAPID))); sql.Add(' and CK_BanCP_CR.MainId=' + quotedstr(trim(FMainId))); sql.Add(' and CK_BanCP_CR.SubId=' + quotedstr(trim(FSubId))); sql.Add(' and CK_BanCP_CR.ganghao=' + quotedstr(trim(MJStr4.Text))); sql.Add(' and CK_BanCP_CR.CRFlag=''待入库'' '); sql.Add('UPDATE CK_BanCP_CR Set '); sql.add(' CRTime=getdate(),CRType=''检验入库'',CRFlag=''入库'' '); sql.Add(' where CK_BanCP_CR.APID=' + quotedstr(trim(FAPID))); sql.Add(' and CK_BanCP_CR.MainId=' + quotedstr(trim(FMainId))); sql.Add(' and CK_BanCP_CR.SubId=' + quotedstr(trim(FSubId))); sql.Add(' and CK_BanCP_CR.ganghao=' + quotedstr(trim(MJStr4.Text))); sql.Add(' and CK_BanCP_CR.CRFlag=''待入库'' '); sql.Add('UPDATE WFB_MJJY Set '); sql.add('RKOrdID=' + quotedstr(trim(SRKOrdID)) + ' ,MJStr2=''已入库'' '); sql.Add(' where WFB_MJJY.APID=' + quotedstr(trim(FAPID))); sql.Add(' and WFB_MJJY.MainId=' + quotedstr(trim(FMainId))); sql.Add(' and WFB_MJJY.SubId=' + quotedstr(trim(FSubId))); sql.Add(' and WFB_MJJY.MJStr4=' + quotedstr(trim(MJStr4.Text))); SQL.Add('and WFB_MJJY.MJStr2=''未入库'' '); ExecSQL; end; ADOCmd.Connection.CommitTrans; PrintCKMDG(Trim(SRKOrdID)); except ADOCmd.Connection.RollbackTrans; ToolButton3.Enabled := true; application.MessageBox('数据撤销失败!', '提示信息', 0); end; ToolButton3.Enabled := true; end; procedure TfrmMarkingInspection.Tv3CustomDrawCell(Sender: TcxCustomGridTableView; ACanvas: TcxCanvas; AViewInfo: TcxGridTableDataCellViewInfo; var ADone: Boolean); var FMJLen, FMJMaoZ: Double; begin FMJLen := AViewInfo.GridRecord.Values[TcxGridDBTableView(Sender).GetColumnByFieldName('MJLen').Index]; FMJMaoZ := AViewInfo.GridRecord.Values[TcxGridDBTableView(Sender).GetColumnByFieldName('MJMaoZ').Index]; if (FMJLen < 10) or (FMJLen > 200) then begin ACanvas.Brush.Color := $B5E4FF; end; if (FMJMaoZ < 5) or (FMJMaoZ > 40) then begin ACanvas.Brush.Color := $B5E4FF; end end; procedure TfrmMarkingInspection.Button4Click(Sender: TObject); begin MovePanel1.Visible := false; end; procedure TfrmMarkingInspection.edtYJClick(Sender: TObject); begin if Trim(TEdit(Sender).Text) = '' then begin TEdit(Sender).Text := '√'; end else begin TEdit(Sender).Text := ''; end; end; procedure TfrmMarkingInspection.ToolButton2Click(Sender: TObject); begin try frmZDYHelp := TfrmZDYHelp.Create(Application); with frmZDYHelp do begin flag := 'JYPerson'; flagname := '验布工'; // fnote := True; // V1Note.Caption := '编号'; if ShowModal = 1 then begin end; end; finally frmZDYHelp.free; end; end; procedure TfrmMarkingInspection.Button3Click(Sender: TObject); begin try frmJYG := TfrmJYG.Create(self); with frmJYG do begin FlagStr := 'JYPerson'; if ShowModal = 1 then begin JYPerson.Text := frmJYG.FSDPerson; end; end; finally frmJYG.Free; end; end; procedure TfrmMarkingInspection.edtChenClick(Sender: TObject); begin if Trim(TEdit(Sender).Text) = '' then begin TEdit(Sender).Text := '√'; end else begin TEdit(Sender).Text := ''; end; end; procedure TfrmMarkingInspection.Button6Click(Sender: TObject); begin if ScrollBox1.Visible then ScrollBox1.Visible := False else ScrollBox1.Visible := True; end; procedure TfrmMarkingInspection.ToolButton4Click(Sender: TObject); begin try frmZDYHelp2 := TfrmZDYHelp2.Create(Application); with frmZDYHelp2 do begin flag := 'KuangHao'; flagname := '框号'; if ShowModal = 1 then begin Self.InitJP(); end; end; finally frmZDYHelp2.Free; end; end; procedure TfrmMarkingInspection.Button7Click(Sender: TObject); begin try frmZdyMapSel := TfrmZdyMapSel.Create(self); with frmZdyMapSel do begin FlagStr := 'KuangHao'; if ShowModal = 1 then begin self.KuangHao.Text := frmZdyMapSel.FSDPerson; end; end; finally frmZdyMapSel.Free; end; end; procedure TfrmMarkingInspection.Button9Click(Sender: TObject); begin DaBao('手动'); InitCDGridID(); end; procedure TfrmMarkingInspection.Button8Click(Sender: TObject); begin if CDS_MJID.IsEmpty = True then Exit; PrintBaoLab(Trim(CDS_MJID.fieldbyname('BAOID').AsString)); end; procedure TfrmMarkingInspection.N1Click(Sender: TObject); begin with ADOTmp do begin Close; sql.Clear; sql.Add('UPDATE WFB_MJJY Set baoid=null,baono=null'); sql.Add('where baoid=(select top 1 X.baoid from WFB_MJJY X '); sql.Add(' where X.subid=' + quotedstr(trim(FSubId))); if Trim(SCXFlag) <> '' then sql.Add(' and X.JTType=' + quotedstr(trim(SCXFlag))); sql.Add(' and X.Filler=' + quotedstr(trim(DName))); sql.Add(' order by cast(baono as int) desc)'); // ShowMessage(SQL.Text); ExecSQL; end; InitCDGridID(); end; procedure TfrmMarkingInspection.Button10Click(Sender: TObject); begin Panel1.Visible := False; end; procedure TfrmMarkingInspection.ToolButton6Click(Sender: TObject); var lvData: UTF8String; // 使用UTF8编码的字符串 lvBitMap: TBitmap; lvSymbol: PZintSymbol; lvErrorNumber: Integer; lvErrorText: string; bitmap: TBitmap; begin lvSymbol := ZBarcode_Create(); if lvSymbol = nil then Exit; lvBitMap := TBitmap.Create; try //'010872020901234590RS9999-100R1011234567893112005160' lvData := UTF8String(FKHEWM); // 条码类型设置为QRCODE lvSymbol.symbology := BARCODE_QRCODE; // lvSymbol.option_2 := 1; //Data Matrix (ISO 16022)(and HIBC) // 编码 lvErrorNumber := ZBarcode_Encode_and_Buffer(lvSymbol, PAnsiChar(lvData), Length(lvData), 0); // 编码成功 if lvErrorNumber = 0 then begin // 生成Bitmap图形 ZBarcode_To_Bitmap(lvSymbol, lvBitMap); // 显示在Image中 cxImage1.Picture.Bitmap.Width := 80; cxImage1.Picture.Bitmap.Height := 80; cxImage1.Picture.Bitmap.Canvas.Brush.Color := clWhite; cxImage1.Picture.Bitmap.Canvas.FillRect(Rect(0, 0, cxImage1.Width, cxImage1.Height)); cxImage1.Picture.Bitmap.Canvas.StretchDraw(Rect(10, 10, cxImage1.Width - 10, cxImage1.Height - 10), lvBitMap); end else begin cxImage1.Picture.Bitmap.Width := cxImage1.Width; cxImage1.Picture.Bitmap.Height := cxImage1.Height; cxImage1.Picture.Bitmap.Canvas.Brush.Color := clWhite; cxImage1.Picture.Bitmap.Canvas.FillRect(Rect(0, 0, cxImage1.Width, cxImage1.Height)); lvErrorText := string(AnsiString(lvSymbol.errtxt)); ShowMessage('编码时发生错误:' + lvErrorText); end; finally lvBitMap.Free; lvBitMap := nil; ZBarcode_Delete(lvSymbol); end; bitmap := TBitmap.Create; try bitmap.Assign(cxImage1.Picture.Bitmap); bitmap.SaveToFile(ExtractFilePath(Application.ExeName) + 'image\temp4.bmp'); finally bitmap.Free; end; end; end.