unit U_CPDBAO;

interface

uses
  Windows, Messages, strutils, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, cxStyles, cxCustomData, cxGraphics, cxFilter, cxData, cxDataStorage, cxEdit, DB, cxDBData, cxGridLevel, cxGridCustomTableView, cxGridTableView, cxGridDBTableView, cxClasses, cxControls, cxGridCustomView, cxGrid, StdCtrls, cxContainer, cxTextEdit, cxCurrencyEdit, BtnEdit, ExtCtrls, ComCtrls, ToolWin, DBClient, ADODB, MovePanel, Buttons, Menus, cxLookAndFeelPainters, cxButtons, RM_Common, RM_Class, RM_GridReport,
  RM_System, RM_Dataset, cxCheckBox, MMSystem, cxLookAndFeels, cxNavigator;

type
  TfrmCPDBao = class(TForm)
    Panel1: TPanel;
    PHYG: TBtnEditA;
    defstr2: TComboBox;
    Label16: TLabel;
    Label15: TLabel;
    Label14: TLabel;
    Label1: TLabel;
    ADOQueryMain: TADOQuery;
    ADOQueryCmd: TADOQuery;
    CDSMJID: TClientDataSet;
    DataSource2: TDataSource;
    SmNO: TEdit;
    ADOQueryTmp: TADOQuery;
    kcKw: TBtnEditA;
    Label5: TLabel;
    cxStyleRepository1: TcxStyleRepository;
    cxStyle1: TcxStyle;
    cxStyle2: TcxStyle;
    cxStyle_gridRow: TcxStyle;
    cxStyle_gridFoot: TcxStyle;
    cxStyle_gridHead: TcxStyle;
    cxStyle_gridGroupBox: TcxStyle;
    cxStyle_yellow: TcxStyle;
    cxStyle_Red: TcxStyle;
    cxStyle_fontBlack: TcxStyle;
    cxStyle_fontclFuchsia: TcxStyle;
    cxStyle_fontclPurple: TcxStyle;
    cxStyle_fontclGreen: TcxStyle;
    cxStyle_fontclBlue: TcxStyle;
    cxStyle_fontclTeal: TcxStyle;
    cxStyle_fontclOlive: TcxStyle;
    ADOQuery1: TADOQuery;
    DataSource1: TDataSource;
    ADOQueryTm: TADOQuery;
    DSTm: TDataSource;
    BaoID: TEdit;
    Label4: TLabel;
    FileName: TcxButton;
    RMDB_Main: TRMDBDataSet;
    RM2: TRMGridReport;
    cxButton1: TcxButton;
    ADOQueryPrint: TADOQuery;
    CDSTM: TClientDataSet;
    cxButton2: TcxButton;
    CDSSEL: TClientDataSet;
    DSSEL: TDataSource;
    check_Fbz: TCheckBox;
    Fbq: TBtnEditA;
    ComboBox2: TComboBox;
    BaoBq: TBtnEditA;
    DBCS: TEdit;
    Panel2: TPanel;
    cxGrid2: TcxGrid;
    TV2: TcxGridDBTableView;
    cxGridDBMLCodeName: TcxGridDBColumn;
    cxGridDBJYColor: TcxGridDBColumn;
    VJYColHX: TcxGridDBColumn;
    V2CGangNo: TcxGridDBColumn;
    V2BaoNo: TcxGridDBColumn;
    cxGridDBColumn5: TcxGridDBColumn;
    cxGridDBJYLen: TcxGridDBColumn;
    V2CJYKG: TcxGridDBColumn;
    V2ColJYJZ: TcxGridDBColumn;
    V2SOMLColorNo: TcxGridDBColumn;
    cxGridLevel1: TcxGridLevel;
    cxGrid1: TcxGrid;
    TV1: TcxGridDBTableView;
    cxJYID: TcxGridDBColumn;
    cxJYNo: TcxGridDBColumn;
    cxMLCodeName: TcxGridDBColumn;
    cJYColor: TcxGridDBColumn;
    cxJYColHX: TcxGridDBColumn;
    cxGangNo: TcxGridDBColumn;
    cxJYLen: TcxGridDBColumn;
    cxJYKG: TcxGridDBColumn;
    cJYJZ: TcxGridDBColumn;
    cxGridDBMLColorNo: TcxGridDBColumn;
    cxGridLevel2: TcxGridLevel;
    edtFenShu: TEdit;
    Label2: TLabel;
    cxButton3: TcxButton;
    procedure FormDestroy(Sender: TObject);
    procedure FormClose(Sender: TObject; var Action: TCloseAction);
    procedure FormCreate(Sender: TObject);
    procedure SmNOKeyPress(Sender: TObject; var Key: Char);
    procedure kcKwBtnClick(Sender: TObject);
    procedure baoNoKeyPress(Sender: TObject; var Key: Char);
    procedure SpeedButton1Click(Sender: TObject);
    procedure SpeedButton12Click(Sender: TObject);
    procedure FileNameClick(Sender: TObject);
    procedure cxButton1Click(Sender: TObject);
    procedure BaoBqBtnClick(Sender: TObject);
    procedure TV1CellDblClick(Sender: TcxCustomGridTableView; ACellViewInfo: TcxGridTableDataCellViewInfo; AButton: TMouseButton; AShift: TShiftState; var AHandled: Boolean);
    procedure TV2CellDblClick(Sender: TcxCustomGridTableView; ACellViewInfo: TcxGridTableDataCellViewInfo; AButton: TMouseButton; AShift: TShiftState; var AHandled: Boolean);
    procedure FormShow(Sender: TObject);
    procedure cxButton3Click(Sender: TObject);
  private
    Rolls: integer;
    FCXDB: string;
    procedure InitGrid();
    procedure InitMJID();
    function SaveRK(): Boolean;
    procedure QueryRk();
    procedure QueryTM();
    { Private declarations }
  public
    { Public declarations }
  end;

var
  frmCPDBao: TfrmCPDBao;
  newh: hwnd;

implementation

uses
  U_DataLink, U_Fun, U_ZDYHelp;
{$R *.dfm}

procedure TfrmCPDBao.QueryTm();
begin
end;

procedure TfrmCPDBao.QueryRk();
begin

end;

function TfrmCPDBao.SaveRK(): Boolean;
begin

end;

procedure TfrmCPDBao.InitGrid();
begin

end;

procedure TfrmCPDBao.InitMJID();
begin
  with ADOQueryMain do
  begin
    Close;
    sql.Clear;
    SQL.Add('select A.*,B.*,C.MLCodeName,C.MLOrderNo from JTJY_New A ');
    sql.add('inner join ML_OrderSubidNew B on B.NewSubid=A.NewSubid ');
    sql.add('inner join ML_OrderMainNew C on C.NewMLID=A.NewMLID ');
    sql.Add('where A.JYID=' + quotedstr(trim(SmNO.Text)));
    Open;
    if not IsEmpty then
    begin
      with CDSMJID do
      begin
        CDSMJID.Append;
        CDSMJID.FieldByName('JYID').Value := trim(ADOQueryMain.Fieldbyname('JYID').AsString);
        CDSMJID.FieldByName('JYNo').Value := trim(ADOQueryMain.Fieldbyname('JYNo').AsString);
        CDSMJID.FieldByName('MLCodeName').Value := trim(ADOQueryMain.Fieldbyname('MLCodeName').AsString);
        CDSMJID.FieldByName('JYColor').Value := trim(ADOQueryMain.Fieldbyname('JYColor').AsString);
        CDSMJID.FieldByName('JYColHX').Value := trim(ADOQueryMain.Fieldbyname('JYColHX').AsString);
        CDSMJID.FieldByName('MLColorNo').Value := trim(ADOQueryMain.Fieldbyname('MLColorNo').AsString);
        CDSMJID.FieldByName('GangNo').Value := trim(ADOQueryMain.Fieldbyname('GangNo').AsString);
        CDSMJID.FieldByName('JYLen').Value := ADOQueryMain.Fieldbyname('JYLen').AsFloat;
        CDSMJID.FieldByName('JYKG').Value := ADOQueryMain.Fieldbyname('JYKG').AsFloat;
        CDSMJID.FieldByName('JYJZ').Value := ADOQueryMain.Fieldbyname('JYJZ').AsFloat;
        CDSMJID.FieldByName('NewMLID').Value := trim(ADOQueryMain.Fieldbyname('NewMLID').AsString);
        CDSMJID.FieldByName('NewSubid').Value := trim(ADOQueryMain.Fieldbyname('NewSubid').AsString);
        CDSMJID.Post;
      end;
    end
    else
    begin
      if FileExists(PChar(ExtractFilePath(Application.ExeName) + 'wav\打包错误.wav')) then
        PlaySound(PChar(ExtractFilePath(Application.ExeName) + 'wav\打包错误.wav'), 0, SND_ASYNC);
    end;
  end;
end;

procedure TfrmCPDBao.FormDestroy(Sender: TObject);
begin
  frmCPDBao := nil;
end;

procedure TfrmCPDBao.FormClose(Sender: TObject; var Action: TCloseAction);
begin
  writeCxGrid(self.Caption + tv1.Name, Tv1, '成品仓库');
  writeCxGrid(self.Caption + Tv2.Name, Tv2, '成品仓库');
  Action := cafree;
end;

procedure TfrmCPDBao.FormCreate(Sender: TObject);
begin
  readCxGrid(self.Caption + tv1.Name, Tv1, '成品仓库');
  readCxGrid(self.Caption + Tv2.Name, Tv2, '成品仓库');
  Rolls := 0;
end;

procedure TfrmCPDBao.SmNOKeyPress(Sender: TObject; var Key: Char);
begin
  if key = #13 then
  begin
    if trim(smno.Text) = '' then
      exit;
    if CDSMJID.Locate('JYID', trim(smno.Text), []) then
    begin
      if FileExists(PChar(ExtractFilePath(Application.ExeName) + 'wav\重复扫描.wav')) then
        PlaySound(PChar(ExtractFilePath(Application.ExeName) + 'wav\重复扫描.wav'), 0, SND_ASYNC);
      smno.Text := '';
      smno.SetFocus;
      exit;
    end;
    if not CDSMJID.Locate('JYID', trim(smno.Text), []) then
    begin
      with ADOQuery1 do
      begin
        Close;
        sql.Clear;
        SQL.Add('select A.*,B.*,C.MLCodeName,C.MLOrderNo from JTJY_New A ');
        sql.add('inner join ML_OrderSubidNew B on B.NewSubid=A.NewSubid ');
        sql.add('inner join ML_OrderMainNew C on C.NewMLID=A.NewMLID ');
        sql.Add('where A.JYID=' + quotedstr(trim(SmNO.Text)));
        Open;
        if isempty then
        begin
          if FileExists(PChar(ExtractFilePath(Application.ExeName) + 'wav\扫描错误.wav')) then
            PlaySound(PChar(ExtractFilePath(Application.ExeName) + 'wav\扫描错误.wav'), 0, SND_ASYNC);
          smno.Text := '';
          smno.SetFocus;
          exit;
        end
        else
        begin
          if Fieldbyname('RKType').AsString = '已出库' then
          begin
            if FileExists(PChar(ExtractFilePath(Application.ExeName) + 'wav\扫描错误.wav')) then
              PlaySound(PChar(ExtractFilePath(Application.ExeName) + 'wav\扫描错误.wav'), 0, SND_ASYNC);
            smno.Text := '';
            smno.SetFocus;
            exit;
          end
          else
          begin
            if CDSMJID.isempty = false then
            begin
              if not CDSMJID.Locate('NewSubid', trim(fieldbyname('NewSubid').AsString), []) then
              begin
                if FileExists(PChar(ExtractFilePath(Application.ExeName) + 'wav\扫描错误.wav')) then
                  PlaySound(PChar(ExtractFilePath(Application.ExeName) + 'wav\扫描错误.wav'), 0, SND_ASYNC);
                smno.Text := '';
                smno.SetFocus;
                exit;
              end;
            end;
          end;
        end;
      end;
    end;
    initMJID();
    smno.Text := '';
    smno.SetFocus;
  end;
end;

procedure TfrmCPDBao.kcKwBtnClick(Sender: TObject);
begin
  try
    frmZDYHelp := TfrmZDYHelp.Create(Application);
    with frmZDYHelp do
    begin
      flag := 'CPKWFlag';
      flagname := '库位信息';
      V1Name.Caption := '库位名称';
      V1Note.Caption := '英文名称';
//      MainType:=Trim(DName);
      fnote := FALSE;
      if ShowModal = 1 then
      begin
        kcKw.Text := Trim(ClientDataSet1.fieldbyname('ZDYName').AsString);
      end;
    end;
  finally
    frmZDYHelp.Free;
  end;
end;

procedure TfrmCPDBao.baoNoKeyPress(Sender: TObject; var Key: Char);
var
  FBaoID: string;
begin

end;

procedure TfrmCPDBao.SpeedButton1Click(Sender: TObject);
var
  fsj: string;
begin
  fsj := Trim(TSpeedButton(Sender).Hint);
  if Trim(fsj) = '' 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 TfrmCPDBao.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 TfrmCPDBao.FileNameClick(Sender: TObject);
var
  fPrintFile: string;
  Txt, fImagePath: string;
  Moudle: THandle;
  Makebar: TMakebar;
  Mixtext: TMixtext;
  FBaoID, FBaoNo: string;
  i: Integer;
begin
  if CDSMJID.IsEmpty then
    exit;
  ADOQueryCmd.Connection.BeginTrans;
  with ADOQueryCmd do
  begin
    Close;
    sql.Clear;
    sql.Add('select Max(cast(ISNULL(BaoNo,0) as Int))+1 BaoNo  from JTJY_New ');
    sql.Add('where NewSubID=''' + Trim(CDSMJID.fieldbyname('NewSubID').AsString) + '''');
    sql.Add(' and GangNo=''' + Trim(CDSMJID.fieldbyname('GangNo').AsString) + '''');
//    ShowMessage(SQL.Text);
    open;
  end;
  FBaoNo := Trim(ADOQueryCmd.fieldbyname('BaoNo').AsString);
  if GetLSNo(ADOQueryCmd, FBaoID, 'DB', 'JTJY_New', 4, 1) = False then
  begin
    ADOQueryCmd.Connection.RollbackTrans;
    Application.MessageBox('生成流水号异常！', '提示', 0);
    exit;
  end;
  try
    with CDSMJID do
    begin
      DisableControls;
      first;
      while not eof do
      begin
        with ADOQueryCmd do
        begin
          Close;
          sql.Clear;
          sql.Add('Update JTJY_New Set BaoNo=''' + trim(FBaoNo) + ''',BaoID=''' + trim(FBaoID) + ''' ');
          sql.Add('where JYID=''' + Trim(CDSMJID.fieldbyname('JYID').AsString) + '''');
          ExecSQL;
        end;
        with ADOQueryCmd do
        begin
          Close;
          sql.Clear;
          sql.Add('Update CK_MLCP_CR Set BaoNo=''' + trim(FBaoNo) + ''',BaoID=''' + trim(FBaoID) + ''' ');
          sql.Add('where MJID=''' + Trim(CDSMJID.fieldbyname('JYID').AsString) + '''');
          ExecSQL;
        end;
        Delete;
      end;
      EnableControls;
    end;
    ADOQueryCmd.Connection.CommitTrans;
    if FileExists(PChar(ExtractFilePath(Application.ExeName) + 'wav\正确.wav')) then
      PlaySound(PChar(ExtractFilePath(Application.ExeName) + 'wav\正确.wav'), 0, SND_ASYNC);
  except
    ;
    ADOQueryCmd.Connection.RollbackTrans;
    if FileExists(PChar(ExtractFilePath(Application.ExeName) + 'wav\打包错误.wav')) then
      PlaySound(PChar(ExtractFilePath(Application.ExeName) + 'wav\打包错误.wav'), 0, SND_ASYNC);
    application.MessageBox('数据修改失败！', '提示信息', 0);
    exit;
  end;
  with ADOQueryPrint do
  begin
    Close;
    SQL.Clear;
    sql.Add('exec JYOrder_DB ');
    sql.Add(' @BaoID=''' + trim(FBaoID) + '''');
    Open;
  end;
  if ADOQueryPrint.RecordCount > 1 then
  begin
    application.MessageBox('包条码重复,不能打印', '提示');
    exit;
  end;
  SInitCDSData20(ADOQueryPrint, CDSSEL);
  try
    Moudle := LoadLibrary('MakeQRBarcode.dll');
    @Makebar := GetProcAddress(Moudle, 'Make');
    @Mixtext := GetProcAddress(Moudle, 'MixText');
    Txt := trim(FBaoID);
    fImagePath := ExtractFilePath(Application.ExeName) + 'image\temp.bmp';
    if not DirectoryExists(pchar(ExtractFilePath(Application.ExeName) + 'image')) then
      CreateDirectory(pchar(ExtractFilePath(Application.ExeName) + 'image'), nil);
    if FileExists(fImagePath) then
      DeleteFile(fImagePath);
    Makebar(pchar(Txt), Length(Txt), 3, 3, 0, PChar(fImagePath), 3);
  except
    application.MessageBox('条形码生成失败！', '提示信息', MB_ICONERROR);
    exit;
  end;
  fPrintFile := ExtractFilePath(Application.ExeName) + 'Report\' + ADOQueryPrint.FieldByName('CPBaoBQName').AsString + '.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(edtFenShu.Text, 1);
   //RM2.ShowReport;
    RM2.printReport;
  end;
  SmNO.SetFocus;
end;

procedure TfrmCPDBao.cxButton1Click(Sender: TObject);
begin
  close;
end;

procedure TfrmCPDBao.BaoBqBtnClick(Sender: TObject);
type
  TMyFunc = function(App: Tapplication; FormH: hwnd; FormID: integer; Language: integer; WinStyle: integer; GCode: Pchar; GName: Pchar; DataBase: Pchar; Title: PChar; Parameters1: PChar; Parameters2: PChar; Parameters3: PChar; Parameters4: PChar; Parameters5: PChar; Parameters6: PChar; Parameters7: PChar; Parameters8: PChar; Parameters9: PChar; Parameters10: PChar; DataBaseStr: PChar): hwnd; stdcall;
var
  Tf: TMyFunc;
  Tp: TFarProc;
  Th: Thandle;
  LabInt, labname: string;
begin
  //if PPInt=2 then Exit;
  Ddatabase := StringOfChar(' ', 32);
  Th := LoadLibrary('LabelSet.dll');
  if Th > 0 then
  begin
    try
      Tp := GetProcAddress(Th, 'GetDllForm');
      if Tp <> nil then
      begin
        Tf := TMyFunc(Tp);
        newh := Tf(Application, 0, 2, 0, 0, PChar(DCode), PChar(DName), PChar(Ddatabase), PChar('标签模版设置'), PChar(''), PChar(''), '', '', '', '', '', '', '', '', PChar(DConString));
        if Trim(PChar(Ddatabase)) <> '' then
        begin
          Ddatabase := Trim(PChar(Ddatabase));
          //  LabInt:=Trim( LeftBStr(Ddatabase,Pos('|',Ddatabase)-1) ) ;
          BaoBq.Text := Trim(RightBStr(Ddatabase, Length(Ddatabase) - Pos('|', Ddatabase)));
        end;
      end
      else
      begin
        ShowMessage('打印执行错误');
      end;
    finally
    // FreeLibrary();
    end;
  end
  else
  begin
    ShowMessage('找不到' + Trim('LabelSet.dll'));
  end;

end;

procedure TfrmCPDBao.TV1CellDblClick(Sender: TcxCustomGridTableView; ACellViewInfo: TcxGridTableDataCellViewInfo; AButton: TMouseButton; AShift: TShiftState; var AHandled: Boolean);
begin
  if application.MessageBox('确定要删除吗', '提示', 1) = 2 then
    Exit;
  CDSMJID.Delete;
end;

procedure TfrmCPDBao.TV2CellDblClick(Sender: TcxCustomGridTableView; ACellViewInfo: TcxGridTableDataCellViewInfo; AButton: TMouseButton; AShift: TShiftState; var AHandled: Boolean);
begin
  if CDSSEL.IsEmpty then
    Exit;
  if application.MessageBox('确定要撤销吗', '提示', 1) = 2 then
    exit;
  try
    ADOQueryCmd.Connection.BeginTrans;
    with ADOQueryCmd do
    begin
      Close;
      sql.Clear;
      sql.Add('Update JTJY_New Set baoID='''',baoNo=''''  ');
      sql.Add('where baoID=''' + Trim(CDSSEL.fieldbyname('baoID').AsString) + '''');
      ExecSQL;
    end;
    with ADOQueryCmd do
    begin
      Close;
      sql.Clear;
      sql.Add('Update CK_MLCP_CR Set BaoNo='''',BaoID='''' ');
      sql.Add('where BaoID=''' + Trim(CDSSEL.fieldbyname('BaoID').AsString) + '''');
      ExecSQL;
    end;
    CDSSEL.delete;
    ADOQueryCmd.Connection.CommitTrans;
    application.MessageBox('数据撤销成功！', '提示信息');
    exit;
  except
    ADOQueryCmd.Connection.RollbackTrans;
    application.MessageBox('数据撤销失败！', '提示信息', 0);
  end;
end;

procedure TfrmCPDBao.FormShow(Sender: TObject);
begin
  with ADOQuery1 do
  begin
    Close;
    sql.Clear;
    SQL.Add('select A.*,B.*,C.MLCodeName,C.MLOrderNo ');
    sql.Add(',cast(0 as decimal(18,2)) PS ');
    sql.Add('from JTJY_New A ');
    sql.add('inner join ML_OrderSubidNew B on B.NewSubid=A.NewSubid ');
    sql.add('inner join ML_OrderMainNew C on C.NewMLID=A.NewMLID ');
    sql.Add('where 1=2');
    Open;
  end;
  SCreateCDS20(ADOQuery1, CDSMJID);
  with ADOQueryPrint do
  begin
    Close;
    SQL.Clear;
    sql.Add('exec JYOrder_DB ');
    sql.Add(' @BaoID=''没有''');
    Open;
  end;
  SCreateCDS20(ADOQueryPrint, CDSSEL);
end;

procedure TfrmCPDBao.cxButton3Click(Sender: TObject);
var
  fPrintFile: string;
  Txt, fImagePath: string;
  Moudle: THandle;
  Makebar: TMakebar;
  Mixtext: TMixtext;
  FBaoID, FBaoNo: string;
  i: Integer;
begin
  if CDSSEL.IsEmpty then
    Exit;
  FBaoID := CDSSEL.fieldbyname('BaoID').AsString;
  with ADOQueryPrint do
  begin
    Close;
    SQL.Clear;
    sql.Add('exec JYOrder_DB ');
    sql.Add(' @BaoID=''' + trim(FBaoID) + '''');
    Open;
  end;
  if ADOQueryPrint.RecordCount > 1 then
  begin
    application.MessageBox('包条码重复,不能打印', '提示');
    exit;
  end;

  try
    Moudle := LoadLibrary('MakeQRBarcode.dll');
    @Makebar := GetProcAddress(Moudle, 'Make');
    @Mixtext := GetProcAddress(Moudle, 'MixText');
    Txt := trim(FBaoID);
    fImagePath := ExtractFilePath(Application.ExeName) + 'image\temp.bmp';
    if not DirectoryExists(pchar(ExtractFilePath(Application.ExeName) + 'image')) then
      CreateDirectory(pchar(ExtractFilePath(Application.ExeName) + 'image'), nil);
    if FileExists(fImagePath) then
      DeleteFile(fImagePath);
    Makebar(pchar(Txt), Length(Txt), 3, 3, 0, PChar(fImagePath), 3);
  except
    application.MessageBox('条形码生成失败！', '提示信息', MB_ICONERROR);
    exit;
  end;
  fPrintFile := ExtractFilePath(Application.ExeName) + 'Report\' + ADOQueryPrint.FieldByName('CPBaoBQName').AsString + '.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(edtFenShu.Text, 1);
   //RM2.ShowReport;
    RM2.printReport;
  end;
  SmNO.SetFocus;
end;

end.


