unit U_MLMangeRS_SMCX;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, cxGraphics, cxCustomData, cxStyles, cxTL, cxMaskEdit, DB, ADODB,
  cxInplaceContainer, cxDBTL, cxControls, cxTLData, ComCtrls, ToolWin, StdCtrls,
  cxFilter, cxData, cxDataStorage, cxEdit, cxDBData, DBClient,
  cxGridCustomTableView, cxGridTableView, cxGridDBTableView, ExtCtrls,
  cxSplitter, cxGridLevel, cxClasses, cxGridCustomView, cxGrid,
  cxGridCustomPopupMenu, cxGridPopupMenu, RM_Dataset, RM_System, RM_Common,
  RM_Class, RM_GridReport, IdBaseComponent, IdComponent, IdTCPConnection,
  IdTCPClient, IdFTP, ShellAPI, IniFiles, cxCheckBox, cxTextEdit, cxButtonEdit,
  Menus, cxLookAndFeelPainters, cxButtons, cxImage, cxCalendar, jpeg,
  cxContainer, cxLookAndFeels, cxNavigator;

type
  TfrmMLMangeRS_SMCX = class(TForm)
    ADOQueryTemp: TADOQuery;
    ADOQueryCmd: TADOQuery;
    cxGridPopupMenu1: TcxGridPopupMenu;
    Panel1: TPanel;
    DataSource2: TDataSource;
    ADOQueryMain: TADOQuery;
    CDS_Main: TClientDataSet;
    RM1: TRMGridReport;
    RMDB_Main: TRMDBDataSet;
    ODPat: TOpenDialog;
    IdFTP1: TIdFTP;
    SaveDialog1: TSaveDialog;
    cxGridPopupMenu4: TcxGridPopupMenu;
    cxStyleRepository1: TcxStyleRepository;
    cxStyle1: TcxStyle;
    cxGridPopupMenu5: TcxGridPopupMenu;
    cxGrid1: TcxGrid;
    Tv1: TcxGridDBTableView;
    v1MLNo: TcxGridDBColumn;
    v1MLName: TcxGridDBColumn;
    v1MLMF: TcxGridDBColumn;
    v1MLKZ: TcxGridDBColumn;
    v1Column1: TcxGridDBColumn;
    v1Column2: TcxGridDBColumn;
    v1GYLXName: TcxGridDBColumn;
    v1SKID: TcxGridDBColumn;
    cxGrid1Level1: TcxGridLevel;
    v1ColNameKH: TcxGridDBColumn;
    v1ColNameEng: TcxGridDBColumn;
    v1PTID: TcxGridDBColumn;
    v1ColNo: TcxGridDBColumn;
    cxGrid2: TcxGrid;
    TV2: TcxGridDBTableView;
    cxGridLevel1: TcxGridLevel;
    V2MYName: TcxGridDBColumn;
    V2MYCode: TcxGridDBColumn;
    V2GYLXName: TcxGridDBColumn;
    V2MLCF: TcxGridDBColumn;
    V2MYMF: TcxGridDBColumn;
    V2MYColor: TcxGridDBColumn;
    V2JH: TcxGridDBColumn;
    V2MQty: TcxGridDBColumn;
    V2GYType: TcxGridDBColumn;
    V2MYKZ: TcxGridDBColumn;
    V2MYColorNo: TcxGridDBColumn;
    V2CoDYGangNo: TcxGridDBColumn;
    V2KgQty: TcxGridDBColumn;
    cxGrid3: TcxGrid;
    TV3: TcxGridDBTableView;
    v1ZIType: TcxGridDBColumn;
    v1ZIDate: TcxGridDBColumn;
    v1Column7: TcxGridDBColumn;
    v1Column4: TcxGridDBColumn;
    v1Column6: TcxGridDBColumn;
    cxGridDBColumn1: TcxGridDBColumn;
    v1ZICost: TcxGridDBColumn;
    v1Column3: TcxGridDBColumn;
    cxGridDBColumn2: TcxGridDBColumn;
    v1Column5: TcxGridDBColumn;
    v1Column8: TcxGridDBColumn;
    v1Column14: TcxGridDBColumn;
    v1Column12: TcxGridDBColumn;
    v1Column10: TcxGridDBColumn;
    v1Column11: TcxGridDBColumn;
    v1Column13: TcxGridDBColumn;
    cxGridLevel2: TcxGridLevel;
    cxGrid4: TcxGrid;
    TV4: TcxGridDBTableView;
    v1XTNo: TcxGridDBColumn;
    v1CYName: TcxGridDBColumn;
    v1CYNo: TcxGridDBColumn;
    v1GYMXNote: TcxGridDBColumn;
    v1CYCF: TcxGridDBColumn;
    v1CYMF: TcxGridDBColumn;
    v1CYKZ: TcxGridDBColumn;
    v1CYSpec: TcxGridDBColumn;
    v1DefStr6: TcxGridDBColumn;
    cxGridLevel3: TcxGridLevel;
    ADOQuery3: TADOQuery;
    ADOQuery2: TADOQuery;
    ADOQuery6: TADOQuery;
    cxGrid5: TcxGrid;
    TV5: TcxGridDBTableView;
    v1HXType: TcxGridDBColumn;
    v1TJML: TcxGridDBColumn;
    v1MLXXNO: TcxGridDBColumn;
    cxGridDBColumn3: TcxGridDBColumn;
    cxGridDBColumn4: TcxGridDBColumn;
    cxGridDBColumn5: TcxGridDBColumn;
    cxGridDBColumn6: TcxGridDBColumn;
    v1MLXXGYName: TcxGridDBColumn;
    v1TJGYName: TcxGridDBColumn;
    cxGridLevel4: TcxGridLevel;
    Panel3: TPanel;
    Label1: TLabel;
    Label2: TLabel;
    Panel5: TPanel;
    Label3: TLabel;
    Button1: TButton;
    Button2: TButton;
    SMRK: TEdit;
    Button3: TButton;
    Button4: TButton;
    Panel2: TPanel;
    Label28: TLabel;
    Label29: TLabel;
    Label30: TLabel;
    ComboBox2: TComboBox;
    ComboBox1: TComboBox;
    BtnPrt: TButton;
    BtnQX: TButton;
    Button5: TButton;
    Panel4: TPanel;
    Label8: TLabel;
    Image1: TImage;
    cxButton1: TcxButton;
    cxButton2: TcxButton;
    cxButton3: TcxButton;
    Panel6: TPanel;
    Image11: TImage;
    Image22: TImage;
    TJHX: TLabel;
    TJHXType: TLabel;
    TJMLNo: TLabel;
    Image2: TImage;
    cxImage1: TcxImage;
    Panel16: TPanel;
    cxStyle2: TcxStyle;
    PopupMenu1: TPopupMenu;
    N1: TMenuItem;
    cxButton4: TcxButton;
    Panel7: TPanel;
    Label4: TLabel;
    Image3: TImage;
    cxButton5: TcxButton;
    cxButton6: TcxButton;
    cxButton7: TcxButton;
    ADOQueryPrint: TADOQuery;
    CDS_Print: TClientDataSet;
    Label5: TLabel;
    ComboBox3: TComboBox;
    procedure FormDestroy(Sender: TObject);
    procedure FormClose(Sender: TObject; var Action: TCloseAction);
    procedure FormShow(Sender: TObject);
    procedure cxDBTreeList1DblClick(Sender: TObject);
    procedure FormCreate(Sender: TObject);
    procedure Button2Click(Sender: TObject);
    procedure SMRKKeyPress(Sender: TObject; var Key: Char);
    procedure Button1Click(Sender: TObject);
    procedure Tv1CellDblClick(Sender: TcxCustomGridTableView; ACellViewInfo: TcxGridTableDataCellViewInfo; AButton: TMouseButton; AShift: TShiftState; var AHandled: Boolean);
    procedure Button3Click(Sender: TObject);
    procedure BtnQXClick(Sender: TObject);
    procedure BtnPrtClick(Sender: TObject);
    procedure Button4Click(Sender: TObject);
    procedure TV3CellDblClick(Sender: TcxCustomGridTableView; ACellViewInfo: TcxGridTableDataCellViewInfo; AButton: TMouseButton; AShift: TShiftState; var AHandled: Boolean);
    procedure Button5Click(Sender: TObject);
    procedure Image1Click(Sender: TObject);
    procedure cxButton1Click(Sender: TObject);
    procedure cxButton2Click(Sender: TObject);
    procedure cxButton3Click(Sender: TObject);
    procedure Image2Click(Sender: TObject);
    procedure cxImage1DblClick(Sender: TObject);
    procedure TV5CellDblClick(Sender: TcxCustomGridTableView; ACellViewInfo: TcxGridTableDataCellViewInfo; AButton: TMouseButton; AShift: TShiftState; var AHandled: Boolean);
    procedure N1Click(Sender: TObject);
    procedure cxButton4Click(Sender: TObject);
    procedure Image3Click(Sender: TObject);
    procedure cxButton5Click(Sender: TObject);
    procedure cxButton6Click(Sender: TObject);
    procedure cxButton7Click(Sender: TObject);
  private
    { Private declarations }
    PState: Integer;
    FCPID, FTopID, FileName: string;
    procedure InitTree();
    procedure InitGrid();
    procedure ReadINIFile();
    procedure ButtonColorCSH();
    procedure InitSHDY();
    procedure InitRSML();
    procedure GxgridXS();
    procedure InitGSCP();
    procedure InitOldYP();
    procedure InitTJML();
  public
    canshu1: string;
    { Public declarations }
  end;

var
  frmMLMangeRS_SMCX: TfrmMLMangeRS_SMCX;

implementation

uses
  U_DataLink, U_Fun, U_CPAdd, U_FileUp, U_MLManage_LR, U_BPZdy_LR, U_BPZdy_SH,
  U_MLManage_LRRS, U_MLManage_FHLR, U_MLManage_ZHLR, U_BPZdy_HXK, U_MLMange_CX,
  U_BPZdy_LRPB, U_BPZdy_LRGX, U_CPManage_TP, U_BPZdy_LRSHK, U_BPZdy_PanelCX,
  U_MLManage_LRCX, U_RSColorBig, U_ZHCPInPut, U_MLManage_LRTJDY, U_MLManage_LRTJ;

{$R *.dfm}
procedure TfrmMLMangeRS_SMCX.InitTJML();
var
  jpg: TJpegImage;
  myStream: TADOBlobStream;
begin
  try
    ADOQueryMain.DisableControls;
    with ADOQueryMain do
    begin
      Close;
      SQL.Clear;
      SQL.Add('select Top 1 A.*,B.*,E.*,MLDLNo SKID,MLPinYin=dbo.getPinYin(A.MLName) ');
      sql.Add(',ColGS=(select count(B.TJML) from Image_Info B where B.TJML=A.TJML)');
      sql.Add(' from ML_Manage A ');
      sql.Add(' left join Image_Info B on B.TJML=A.TJML ');
      sql.Add(' left join Image_File E on B.IMID=E.IMID ');
      sql.Add(' left join BP_DY C on C.TFID=B.IMID and C.MLID=A.MLID');
      sql.Add(' left join BP_DY D on D.TFID=A.PTID and D.MLID=A.MLID');
      sql.Add(' where isnull(A.MLType,'''')=''烫金面料'' and isnull(C.DYID,D.DYID)=''' + trim(SMRK.Text) + '''');
      Open;
    end;
    SCreateCDS20(ADOQueryMain, CDS_Main);
    SInitCDSData20(ADOQueryMain, CDS_Main);
    if ADOQueryMain.IsEmpty = False then
    begin
      FileName := Trim(CDS_Main.fieldbyname('ImagePath').AsString);
      jpg := TJpegImage.Create();
      myStream := tadoblobstream.Create(tblobfield(ADOQueryMain.fieldbyname('ImageFile')), bmread);
      jpg.LoadFromStream(myStream);
      cxImage1.Picture.Assign(jpg);
      TJHX.Caption := trim(CDS_Main.fieldbyname('TJHX').AsString);
      TJHXType.Caption := trim(CDS_Main.fieldbyname('TJHXType').AsString);
      TJMLNo.Caption := trim(CDS_Main.fieldbyname('TJMLNo').AsString);
    end;
    SMRK.Text := '';
    cxGrid5.Visible := true;
    Button5.Visible := true;
    Panel6.Visible := true;
  finally
    ADOQueryMain.EnableControls;
  end;
end;

procedure TfrmMLMangeRS_SMCX.InitOldYP();
var
  FMXCYID, FColNo, FCYType, CPID: string;
begin
  if Trim(SMRK.Text) = '' then
    Exit;
  with ADOQuery6 do
  begin
    close;
    sql.Clear;
    sql.Add('select A.CYID MXCYType,A.ColorNo,CYType=isnull((select Top 1 C.CYType from CP_YDang B inner join CP_YDang C on C.CYID=B.CYType where B.CYID=A.CYID)');
    SQL.Add(',(select Top 1 B.CYType from CP_YDang B where B.CYID=A.CYID))');
    sql.Add(',CYID=isnull((select Top 1 C.CYID from CP_YDang B inner join CP_YDang C on C.CYID=B.CYType where B.CYID=A.CYID),');
    sql.Add('(select Top 1 B.CYID from CP_YDang B where B.CYID=A.CYID))');
    sql.Add(' from CP_YDang_Color A where A.CLRID=''' + trim(SMRK.Text) + '''');
    //ShowMessage(sql.Text);
    Open;
  end;
  with ADOQuery2 do
  begin
    Close;
    sql.Clear;
    sql.Add('select * from CP_YDang where CYID=''' + Trim(SMRK.Text) + '''');
    Open;
  end;
  with ADOQuery3 do
  begin
    Close;
    sql.Clear;
    sql.Add('select * from CP_YDang where CYID=''' + Trim(ADOQuery2.fieldbyname('CYType').AsString) + '''');
    Open;
  end;
  if ADOQuery6.IsEmpty = false then
  begin
    CPID := Trim(ADOQuery6.fieldbyname('CYType').AsString);
    FMXCYID := Trim(ADOQuery6.fieldbyname('CYID').AsString);
    FColNo := Trim(ADOQuery6.fieldbyname('ColorNo').AsString);
    FCYType := Trim(ADOQuery6.fieldbyname('MXCYType').AsString);
  end;
  if ADOQuery2.IsEmpty = false then
  begin
    CPID := Trim(ADOQuery2.fieldbyname('CYType').AsString);
    FMXCYID := Trim(ADOQuery2.fieldbyname('CYID').AsString);
  end;
  if ADOQuery3.IsEmpty = false then
  begin
    CPID := Trim(ADOQuery3.fieldbyname('CYType').AsString);
    FMXCYID := Trim(ADOQuery3.fieldbyname('CYID').AsString);
    FCYType := Trim(SMRK.Text);
  end;
  with ADOQuery2 do
  begin
    Close;
    sql.Clear;
    sql.Add(' exec P_Select_CP_YDang1 :CYType,:CP,:RON,:WSql,:Stats ');
    Parameters.ParamByName('CYType').Value := CPID;
    Parameters.ParamByName('CP').Value := 1;
    Parameters.ParamByName('RON').Value := 100;
    Parameters.ParamByName('WSql').Value := ' CYID=''' + Trim(FMXCYID) + ''' ';
    Parameters.ParamByName('Stats').Value := 2;
    Open;
  end;
  SCreateCDS20(ADOQuery2, CDS_Main);
  SInitCDSData20(ADOQuery2, CDS_Main);
end;

procedure TfrmMLMangeRS_SMCX.InitGSCP();
begin
  with ADOQueryMain do
  begin
    close;
    sql.Clear;
    sql.Add('Select AA.* From(');
    sql.Add(' select A.* ');
    sql.Add(' ,ImageFileTP=(select ImageFile from Image_Info B inner join Image_File C on B.IMID=C.IMID ');
    sql.Add('             where B.WBID=A.ZIID and B.IMNO=''图片'' and B.Valid=''Y'' and C.Valid=''Y'' and C.IFType=''小'' )');
    sql.Add(' ,ImageFileNR=(select ImageFile from Image_Info B inner join Image_File C on B.IMID=C.IMID ');
    sql.Add('             where B.WBID=A.ZIID and B.IMNO=''内容'' and B.Valid=''Y'' and C.Valid=''Y'' and C.IFType=''小'' )');
    sql.Add(',GS=(select Sum(GGQty) from ZH_CP_Info_KC KC where KC.ZIID=A.ZIID )');
    sql.Add(' from ZH_CP_Info A  ');
    SQL.Add(' inner join ZH_CP_Info_KC B on B.ZIID=A.ZIID');
    sql.Add(' where A.Valid=''Y''  ');
    sql.Add(' and B.DYID=''' + trim(SMRK.Text) + ''')AA');
    open;
  end;
  SCreateCDS20(ADOQueryMain, CDS_Main);
  SInitCDSData20(ADOQueryMain, CDS_Main);
  cxGrid3.Visible := true;
  Button4.Visible := true;
end;

procedure TfrmMLMangeRS_SMCX.InitTree();
begin

end;

procedure TfrmMLMangeRS_SMCX.InitGrid();
begin
  {try
    ADOQueryMain.DisableControls;
    with ADOQueryMain do
    begin
      Close;
      SQL.Clear;
      SQL.Add('select * ');
      sql.Add(',SKID=(select B.SKID from BP_ZDY B where B.BPID=A.MBPID)');
      sql.Add(' from ML_Manage A ');
      sql.Add(' where isnull(MLType,'''')=''染色面料'' ');
      Open;
    end;
    SCreateCDS20(ADOQueryMain,CDS_Main);
    SInitCDSData20(ADOQueryMain,CDS_Main);
  finally
    ADOQueryMain.EnableControls;
  end;}
end;

procedure TfrmMLMangeRS_SMCX.FormDestroy(Sender: TObject);
begin
  frmMLMangeRS_SMCX := nil;
end;

procedure TfrmMLMangeRS_SMCX.FormClose(Sender: TObject; var Action: TCloseAction);
begin
  Action := caFree;
end;

procedure TfrmMLMangeRS_SMCX.FormShow(Sender: TObject);
begin
  N1.Visible := false;
  if canshu1 = '高权限' then
  begin
    N1.Visible := true;
  end;
  InitGrid();
  ReadCxGrid('扫描查询', Tv1, '样品管理');
end;

procedure TfrmMLMangeRS_SMCX.cxDBTreeList1DblClick(Sender: TObject);
begin
  InitGrid();
end;

procedure TfrmMLMangeRS_SMCX.ReadINIFile();
var
  programIni: Tinifile;  //配置文件名
  FileName: string;
begin
  FileName := ExtractFilePath(Paramstr(0)) + 'SYSTEMSET.INI';
  programIni := Tinifile.create(FileName);
  server := programIni.ReadString('SERVER', '服务器地址', '127.0.0.1');
  programIni.Free;
end;

procedure TfrmMLMangeRS_SMCX.ButtonColorCSH();
begin

end;

procedure TfrmMLMangeRS_SMCX.FormCreate(Sender: TObject);
begin
  canshu1 := Trim(DParameters1);
end;

procedure TfrmMLMangeRS_SMCX.Button2Click(Sender: TObject);
begin
  WriteCxGrid('扫描查询', Tv1, '样品管理');
  Close;
end;

procedure TfrmMLMangeRS_SMCX.InitRSML();
var
  fsj: string;
begin
  try
    ADOQueryMain.DisableControls;
    with ADOQueryMain do
    begin
      Close;
      sql.Clear;
      sql.Add('exec P_PRT_QCRK_RSML ');
      sql.Add('@MXID=''' + trim(SMRK.Text) + '''');
      //ShowMessage(sql.Text);
      Open;
    end;
    SCreateCDS20(ADOQueryMain, CDS_Main);
    SInitCDSData20(ADOQueryMain, CDS_Main);
    with ADOQueryCmd do
    begin
      Close;
      sql.Clear;
      sql.Add('select * from RT_PTColor where PTID=''' + Trim(CDS_Main.fieldbyname('PTID').AsString) + '''');
      Open;
    end;
    fsj := Trim(ADOQueryCmd.fieldbyname('ColDaiMa').AsString);
    Panel3.Color := StrToInt('$' + Trim(fsj));
    Label1.Caption := CDS_Main.fieldbyname('MYColorNo').AsString + '#';
    Label2.Caption := CDS_Main.fieldbyname('MYColor').AsString;
    cxgrid2.Visible := true;
    Button3.Visible := true;
    Panel3.Visible := true;
    SMRK.Text := '';
  finally
    ADOQueryMain.EnableControls;
  end;
end;

procedure TfrmMLMangeRS_SMCX.GxgridXS();
begin
  Button1.Visible := false;
  Button3.Visible := false;
  button4.Visible := false;
  Button5.Visible := false;

  cxGrid1.Visible := false;
  cxGrid2.Visible := false;
  cxGrid3.Visible := false;
  cxGrid4.visible := false;
  cxGrid5.Visible := false;

  Panel3.Visible := false;
end;

procedure TfrmMLMangeRS_SMCX.InitSHDY();
begin
  try
    ADOQueryMain.DisableControls;
    with ADOQueryMain do
    begin
      Close;
      sql.Clear;
      sql.Add('exec P_View_RSML ');
      sql.Add('@DYID=''' + trim(SMRK.Text) + '''');
      //ShowMessage(sql.Text);
      Open;
    end;
    SCreateCDS20(ADOQueryMain, CDS_Main);
    SInitCDSData20(ADOQueryMain, CDS_Main);
    cxgrid1.Visible := true;
    button1.Visible := true;
    Panel3.Visible := true;
    if CDS_Main.Fieldbyname('ColDaiMa').AsString <> '' then
      Panel3.Color := StrToInt('$' + Trim(CDS_Main.Fieldbyname('ColDaiMa').AsString));
    Label1.Caption := Trim(CDS_Main.Fieldbyname('ColNo').AsString);
    Label2.Caption := Trim(CDS_Main.Fieldbyname('ColNameKH').AsString);
    SMRK.Text := '';
  finally
    ADOQueryMain.EnableControls;
  end;
end;

procedure TfrmMLMangeRS_SMCX.SMRKKeyPress(Sender: TObject; var Key: Char);
begin
  if Key = #13 then
  begin
    GxgridXS();
    InitOldYP();
    if CDS_Main.IsEmpty then
    begin
      if Copy(SMRK.Text, 1, 4) = 'DY20' then
        InitSHDY();
      if Copy(SMRK.Text, 1, 2) = 'QM' then
        InitRSML();
      if Copy(SMRK.Text, 1, 4) = 'DYKC' then
        InitGSCP();
      if Copy(SMRK.Text, 1, 4) = 'TGML' then
        InitTJML();
    end
    else
    begin
      SMRK.Text := '';
      cxGrid4.visible := true;
    end;
  end;
end;

procedure TfrmMLMangeRS_SMCX.Button1Click(Sender: TObject);
begin
  if CDS_Main.IsEmpty then
    Exit;
  Panel7.Visible := false;
end;

procedure TfrmMLMangeRS_SMCX.Tv1CellDblClick(Sender: TcxCustomGridTableView; ACellViewInfo: TcxGridTableDataCellViewInfo; AButton: TMouseButton; AShift: TShiftState; var AHandled: Boolean);
begin
  frmMLManage_LRCX := TfrmMLManage_LRCX.Create(Self);
  with frmMLManage_LRCX do
  begin
    FCYID := Trim(Self.CDS_Main.fieldbyname('MLID').AsString);
    FGYName := '染色';
    FDYID := Trim(Self.CDS_Main.fieldbyname('DYID').AsString);
    if ShowModal = 1 then
    begin

    end;
    free;
  end;
end;

procedure TfrmMLMangeRS_SMCX.Button3Click(Sender: TObject);
begin
  Panel2.Visible := true;
end;

procedure TfrmMLMangeRS_SMCX.BtnQXClick(Sender: TObject);
begin
  Panel2.Visible := False;
end;

procedure TfrmMLMangeRS_SMCX.BtnPrtClick(Sender: TObject);
var
  fPrintFile, Txt, fImagePath: string;
  i, j: Integer;
  Moudle: THandle;
  Makebar: TMakebar;
  Mixtext: TMixtext;
begin
  if ComboBox2.Text = '' then
  begin
    Application.MessageBox('请选择张数!', '提示', 0);
    Exit;
  end;
  if ComboBox1.Text = '' then
  begin
    Application.MessageBox('请选择尺寸!', '提示', 0);
    Exit;
  end;
  if ComboBox1.Text = '9*7' then
  begin
    fPrintFile := ExtractFilePath(Application.ExeName) + 'Report\期初入库染色面料标签97.rmf';
  end
  else if ComboBox1.Text = '8*5' then
  begin
    fPrintFile := ExtractFilePath(Application.ExeName) + 'Report\期初入库染色面料标签85.rmf';
  end;
  if FileExists(fPrintFile) = False then
  begin
    if ComboBox1.Text = '9*7' then
      Application.MessageBox(PChar('没有找' + ExtractFilePath(Application.ExeName) + 'Report\期初入库染色面料标签97.rmf'), '提示', 0);
    if ComboBox1.Text = '8*5' then
      Application.MessageBox(PChar('没有找' + ExtractFilePath(Application.ExeName) + 'Report\期初入库染色面料标签85.rmf'), '提示', 0);
    exit;
  end;
  try
    Moudle := LoadLibrary('MakeQRBarcode.dll');
    @Makebar := GetProcAddress(Moudle, 'Make');
    @Mixtext := GetProcAddress(Moudle, 'MixText');
    Txt := Trim(CDS_Main.fieldbyname('MXID').AsString);
    fImagePath := ExtractFilePath(Application.ExeName) + 'image\temp.bmp';
    if not DirectoryExists(pchar(ExtractFilePath(Application.ExeName) + 'image')) then
      CreateDirectory(pchar(ExtractFilePath(Application.ExeName) + 'image'), nil);
    if FileExists(fImagePath) then
      DeleteFile(fImagePath);
    Makebar(pchar(Txt), Length(Txt), 3, 3, 0, PChar(fImagePath), 3);
  except
    application.MessageBox('二维码生成失败！', '提示信息', MB_ICONERROR);
    exit;
  end;
  RMVariables['QRBARCODE'] := fImagePath;
  RM1.LoadFromFile(fPrintFile);
  //RM1.ShowReport;
  for i := 1 to StrToInt(ComboBox2.Text) do
  begin
    RM1.PrintReport;
  end;
  ComboBox2.ItemIndex := 0;
  ComboBox1.ItemIndex := -1;
  Panel2.Visible := False;
end;

procedure TfrmMLMangeRS_SMCX.Button4Click(Sender: TObject);
var
  fPrintFile, Txt, fImagePath, maxno: string;
  i, j: Integer;
  Moudle: THandle;
  Makebar: TMakebar;
  Mixtext: TMixtext;
begin
  if CDS_Main.IsEmpty then
    Exit;
  fPrintFile := ExtractFilePath(Application.ExeName) + 'Report\客户标签.rmf';
  if FileExists(fPrintFile) = False then
  begin
    Application.MessageBox(PChar('没有找' + ExtractFilePath(Application.ExeName) + 'Report\客户标签.rmf'), '提示', 0);
    exit;
  end;
  CDS_Main.DisableControls;
  with CDS_Main do
  begin
    //First;
    //while Locate('SSel',True,[]) do

    with ADOQueryTemp do
    begin
      Close;
      SQL.Clear;
      sql.Add(' select A.* ,C.ImageFile');
      sql.Add(' ,CASE WHEN( isnull(MianBu,'''')='''') THEN MianBuName ELSE MianBu END AS MB  ');
      sql.Add(' from ZH_CP_Info A');
      sql.Add(' inner join Image_Info B on A.ZIID=B.WBID');
      sql.Add(' inner join Image_File C on B.IMID=C.IMID');
      sql.Add(' where A.ZIID=''' + Trim(CDS_Main.fieldbyname('ZIID').AsString) + '''');
      sql.Add(' and B.IMNO=''图片'' and A.Valid=''Y'' and B.Valid=''Y'' and C.Valid=''Y'' ');
      Open;
    end;
    SCreateCDS20(ADOQueryTemp, CDS_Print);
    SInitCDSData20(ADOQueryTemp, CDS_Print);

    begin
      try
        ADOQueryCmd.Connection.BeginTrans;
        if GetLSNo(ADOQueryCmd, maxno, 'DYKC', 'ZH_CP_Info_KC', 4, 1, ) = False then
        begin
          ADOQueryCmd.Connection.RollbackTrans;
          Application.MessageBox('取样品打印最大号失败!', '提示', 0);
          Exit;
        end;
        with ADOQueryCmd do
        begin
          Close;
          sql.Clear;
          SQL.Add('select * from ZH_CP_Info_KC where DYId=''' + Trim(maxno) + '''');
          Open;
        end;
        with ADOQueryCmd do
        begin
          Append;
          FieldByName('ZIId').Value := Trim(CDS_Main.fieldbyname('ZIID').AsString);
          FieldByName('DYId').Value := Trim(maxno);
          FieldByName('Filler').Value := Trim(DName);
          FieldByName('FillerCode').Value := Trim(DCode);
          FieldByName('Valid').Value := 'Y';
          Post;
        end;
        with ADOQueryCmd do
        begin
          Close;
          sql.Clear;
          sql.Add('Update ZH_CP_Info_KC Set DYXH=isnull((select max(DYXH) from ZH_CP_Info_KC A ');
          sql.Add(' where A.ZIID=''' + Trim(CDS_Main.fieldbyname('ZIID').AsString) + '''),0)+1 ');
          sql.Add(' where DYID=''' + Trim(maxno) + '''');
          ExecSQL;
        end;
        ADOQueryCmd.Connection.CommitTrans;
      except
        ADOQueryCmd.Connection.RollbackTrans;
        Application.MessageBox('保存打印流水号异常！', '提示', 0);
        Exit;
      end;
      try
        Moudle := LoadLibrary('MakeQRBarcode.dll');
        @Makebar := GetProcAddress(Moudle, 'Make');
        @Mixtext := GetProcAddress(Moudle, 'MixText');
        Txt := Trim(maxno);
        fImagePath := ExtractFilePath(Application.ExeName) + 'image\temp.bmp';
        if not DirectoryExists(pchar(ExtractFilePath(Application.ExeName) + 'image')) then
          CreateDirectory(pchar(ExtractFilePath(Application.ExeName) + 'image'), nil);
        if FileExists(fImagePath) then
          DeleteFile(fImagePath);
        Makebar(pchar(Txt), Length(Txt), 3, 3, 0, PChar(fImagePath), 3);
      except
        application.MessageBox('二维码生成失败！', '提示信息', MB_ICONERROR);
        exit;
      end;
      RMVariables['QRBARCODE'] := fImagePath;
      RMVariables['DYID'] := maxno;
      RM1.LoadFromFile(fPrintFile);
     // RM1.ShowReport;
      RM1.DefaultCopies := StrToIntdef(ComboBox3.Text, 1);
      RM1.PrintReport;
    end;
  end;
  CDS_Main.EnableControls;
end;

procedure TfrmMLMangeRS_SMCX.TV3CellDblClick(Sender: TcxCustomGridTableView; ACellViewInfo: TcxGridTableDataCellViewInfo; AButton: TMouseButton; AShift: TShiftState; var AHandled: Boolean);
begin
  if CDS_Main.IsEmpty then
    Exit;
  try
    frmZHCPInPut := TfrmZHCPInPut.Create(Application);
    with frmZHCPInPut do
    begin
      PState := 1;
      FMainId := Trim(CDS_Main.fieldbyname('ZIID').AsString);
      //TBSave.Visible:=False;
      if ShowModal = 1 then
      begin
        //InitGrid();
      end;
    end;
  finally
    frmZHCPInPut.Free;
  end;
end;

procedure TfrmMLMangeRS_SMCX.Button5Click(Sender: TObject);
begin
  Panel4.Visible := true;
end;

procedure TfrmMLMangeRS_SMCX.Image1Click(Sender: TObject);
begin
  Panel4.Visible := false;
end;

procedure TfrmMLMangeRS_SMCX.cxButton1Click(Sender: TObject);
var
  fPrintFile, Txt, fImagePath, maxno: string;
  i, j: Integer;
  Moudle: THandle;
  Makebar: TMakebar;
  Mixtext: TMixtext;
begin
  if CDS_Main.IsEmpty then
    Exit;
  fPrintFile := ExtractFilePath(Application.ExeName) + 'Report\烫金面料标签.rmf';
  if FileExists(fPrintFile) = False then
  begin
    Application.MessageBox(PChar('没有找' + ExtractFilePath(Application.ExeName) + 'Report\烫金面料标签.rmf'), '提示', 0);
    exit;
  end;
  CDS_Main.DisableControls;
  with CDS_Main do
  begin
    //First;
    //while Locate('SSel',True,[]) do
    begin
      try
        ADOQueryCmd.Connection.BeginTrans;
        if GetLSNo(ADOQueryCmd, maxno, 'TGML', 'BP_DY', 4, 1, ) = False then
        begin
          ADOQueryCmd.Connection.RollbackTrans;
          Application.MessageBox('取样品打印最大号失败!', '提示', 0);
          Exit;
        end;
        with ADOQueryCmd do
        begin
          Close;
          sql.Clear;
          SQL.Add('select * from BP_DY where DYId=''' + Trim(maxno) + '''');
          Open;
        end;
        with ADOQueryCmd do
        begin
          Append;
          FieldByName('MLID').Value := Trim(CDS_Main.fieldbyname('MLID').AsString);
          FieldByName('TFID').Value := Trim(CDS_Main.fieldbyname('PTID').AsString);
          FieldByName('DYId').Value := Trim(maxno);
          FieldByName('Filler').Value := Trim(DName);
          FieldByName('FillerCode').Value := Trim(DCode);
          FieldByName('Valid').Value := 'Y';
          Post;
        end;
        ADOQueryCmd.Connection.CommitTrans;
      except
        ADOQueryCmd.Connection.RollbackTrans;
        Application.MessageBox('保存打印流水号异常！', '提示', 0);
        Exit;
      end;
      try
        Moudle := LoadLibrary('MakeQRBarcode.dll');
        @Makebar := GetProcAddress(Moudle, 'Make');
        @Mixtext := GetProcAddress(Moudle, 'MixText');
        Txt := Trim(maxno);
        fImagePath := ExtractFilePath(Application.ExeName) + 'image\temp.bmp';
        if not DirectoryExists(pchar(ExtractFilePath(Application.ExeName) + 'image')) then
          CreateDirectory(pchar(ExtractFilePath(Application.ExeName) + 'image'), nil);
        if FileExists(fImagePath) then
          DeleteFile(fImagePath);
        Makebar(pchar(Txt), Length(Txt), 3, 3, 0, PChar(fImagePath), 3);
      except
        application.MessageBox('二维码生成失败！', '提示信息', MB_ICONERROR);
        exit;
      end;
      RMVariables['QRBARCODE'] := fImagePath;
      RMVariables['DYID'] := maxno;
      RM1.LoadFromFile(fPrintFile);
     // RM1.ShowReport;
      RM1.PrintReport;
    end;
  end;
  CDS_Main.EnableControls;
  panel2.Visible := false;
end;

procedure TfrmMLMangeRS_SMCX.cxButton2Click(Sender: TObject);
begin
  frmMLManage_LRTJDY := TfrmMLManage_LRTJDY.Create(self);
  with frmMLManage_LRTJDY do
  begin
    FCYID := Trim(Self.CDS_Main.fieldbyname('MLID').AsString);
    FGYName := '烫金';
    formid := '1';
    if ShowModal = 1 then
    begin

    end;
    free;
  end;
  panel2.Visible := false;
end;

procedure TfrmMLMangeRS_SMCX.cxButton3Click(Sender: TObject);
begin
  frmMLManage_LRTJDY := TfrmMLManage_LRTJDY.Create(self);
  with frmMLManage_LRTJDY do
  begin
    formid := '2';
    FCYID := Trim(Self.CDS_Main.fieldbyname('MLID').AsString);
    FGYName := '烫金';
    if ShowModal = 1 then
    begin

    end;
    free;
  end;
  panel2.Visible := false;
end;

procedure TfrmMLMangeRS_SMCX.Image2Click(Sender: TObject);
begin
  Panel6.Visible := false;
end;

procedure TfrmMLMangeRS_SMCX.cxImage1DblClick(Sender: TObject);
var
  IdFTP1: TIdFTP;
  FPath, FFName: string;
  FInt: integer;
  maxno: string;
  j, i: Integer;
  fPrintFile: string;
begin
  if Application.MessageBox('原图下载需要等待时间，确定要查看原图吗？', '提示', 32 + 4) <> IDYES then
    Exit;
  try
    ReadINIFile();
    server := ReadINIFileStr('SYSTEMSET.INI', 'SERVER', '服务器地址', '127.0.0.1');
    IdFTP1 := TIdFTP.Create(self);
    IdFTP1.Host := server;
    IdFTP1.Username := 'three';
    IdFTP1.Password := '641010';
    IdFTP1.Connect();
  except
    IdFTP1.Quit;
    IdFTP1.Free;
    Application.MessageBox('无法连接到文件服务器，请检查！', '提示', MB_ICONWARNING);
    Exit;
  end;
  Panel16.Visible := true;
  Panel16.Refresh;
  fPrintFile := ExtractFilePath(Application.ExeName) + 'Photo\';
  if not DirectoryExists(ExtractFileDir(fPrintFile)) then
    CreateDir(ExtractFileDir(fPrintFile));
  FFName := Trim(FileName);
  FFName := fPrintFile + FFName + '.jpg';
  if not FileExists(FFName) then
  begin
    IdFTP1.Get('TJ\' + FileName, FFName);
  end;
  if IdFTP1.Connected then
  begin
    IdFTP1.Quit;
    IdFTP1.Free;
  end;
  Panel16.Visible := false;
  ShellExecute(Handle, 'open', PChar(FFName), '', '', SW_SHOWNORMAL);
end;

procedure TfrmMLMangeRS_SMCX.TV5CellDblClick(Sender: TcxCustomGridTableView; ACellViewInfo: TcxGridTableDataCellViewInfo; AButton: TMouseButton; AShift: TShiftState; var AHandled: Boolean);
begin
  try
    frmMLManage_LRTJ := TfrmMLManage_LRTJ.Create(Application);
    with frmMLManage_LRTJ do
    begin
      FCYID := Trim(Self.CDS_Main.fieldbyname('MLID').AsString);
      FGYName := '烫金';
      formid := '1';
      //viewFlag:=True;
      TSave.Visible := false;
      Button2.Visible := false;
      if ShowModal = 1 then
      begin
        Self.InitGrid();
      end;
    end;
  finally
    frmMLManage_LRTJ.Free;
  end;
end;

procedure TfrmMLMangeRS_SMCX.N1Click(Sender: TObject);
begin
  if CDS_Main.IsEmpty then
    Exit;
  try
    frmMLManage_LRTJ := TfrmMLManage_LRTJ.Create(Application);
    with frmMLManage_LRTJ do
    begin
      FCYID := Trim(Self.CDS_Main.fieldbyname('MLID').AsString);
      FGYName := '烫金';
      Panel7.Visible := false;
      Button2.Visible := false;
      Button3.Visible := false;
      Panel10.Visible := false;
      TJGYName.Enabled := false;
      TJGYName.Color := clScrollBar;
      if ShowModal = 1 then
      begin
        Self.InitGrid();
        CDS_Main.Locate('MLID', FCYID, []);
      end;
    end;
  finally
    frmMLManage_LRTJ.Free;
  end;
end;

procedure TfrmMLMangeRS_SMCX.cxButton4Click(Sender: TObject);
begin
  frmMLManage_LRTJDY := TfrmMLManage_LRTJDY.Create(self);
  with frmMLManage_LRTJDY do
  begin
    FCYID := Trim(Self.CDS_Main.fieldbyname('MLID').AsString);
    FGYName := '烫金';
    formid := '3';
    if ShowModal = 1 then
    begin

    end;
    free;
  end;
  panel2.Visible := false;
end;

procedure TfrmMLMangeRS_SMCX.Image3Click(Sender: TObject);
begin
  Panel7.Visible := false;
end;

procedure TfrmMLMangeRS_SMCX.cxButton5Click(Sender: TObject);
var
  i, j, x: Integer;
begin
  i := 0;
  j := 0;
  frmBPZDY_PanelCX := TfrmBPZDY_PanelCX.create(self);
  with frmBPZDY_PanelCX do
  begin
    FColorFlag := Trim(self.CDS_Main.fieldbyname('SKID').asstring);
    FBPID := Trim(self.CDS_Main.fieldbyname('MBPID').asstring);
    FMLID := Trim(Self.CDS_Main.fieldbyname('MLID').AsString);
    if ShowModal = 1 then
    begin

    end;
    free;
  end;
  panel7.Visible := False;
end;

procedure TfrmMLMangeRS_SMCX.cxButton6Click(Sender: TObject);
var
  maxno, MaxSub: string;
  fPrintFile, Txt, fImagePath: string;
  Porderno: string;
  i, j: Integer;
  Moudle: THandle;
  Makebar: TMakebar;
  Mixtext: TMixtext;
begin
  with ADOQueryCmd do
  begin
    close;
    sql.Clear;
    SQL.Add('select * from BP_DY ');
    sql.Add('where MLID=''' + trim(CDS_Main.fieldbyname('MLID').AsString) + '''');
    sql.Add(' and DYType=''面料''');
    //ShowMessage(sql.Text);
    Open;
  end;
  if ADOQueryCmd.IsEmpty then
  begin
    if GetLSNo(ADOQueryTemp, maxno, 'DY', 'BP_DY', 3, 1) = False then
    begin
      Application.MessageBox('取最大号失败!', '提示', 0);
      Exit;
    end;
  end
  else
  begin
    maxno := Trim(ADOQueryCmd.fieldbyname('DYID').AsString);
  end;
  with ADOQueryCmd do
  begin
    if IsEmpty then
    begin
      Append;
      FieldByName('filler').Value := Trim(DName);
      FieldByName('DYID').Value := Trim(maxno);
    end
    else
    begin
      edit;
      FieldByName('laster').Value := Trim(DName);
      FieldByName('lasttime').Value := SGetServerDate(ADOQueryTemp);
    end;
    FieldByName('MLID').Value := Trim(CDS_Main.fieldbyname('MLID').AsString);
    FieldByName('TFID').Value := Trim(CDS_Main.fieldbyname('SKID').AsString);
    FieldByName('DYType').Value := '面料';
    FieldByName('BQType').Value := '染色面料标签';
    post;
  end;
  //////////记录
  if GetLSNo(ADOQueryTemp, MaxSub, 'JL', 'BP_DY_JL', 3, 1) = False then
  begin
    Application.MessageBox('取最大号失败!', '提示', 0);
    Exit;
  end;
  with ADOQueryCmd do
  begin
    close;
    sql.Clear;
    SQL.Add('select * from BP_DY_JL ');
    sql.Add('where 1=2');
    Open;
  end;
  with ADOQueryCmd do
  begin
    Append;
    FieldByName('filler').Value := Trim(DName);
    FieldByName('JLID').Value := Trim(MaxSub);
    FieldByName('DYID').Value := Trim(maxno);
    FieldByName('MLID').Value := Trim(CDS_Main.fieldbyname('MLID').AsString);
    FieldByName('TFID').Value := Trim(CDS_Main.fieldbyname('SKID').AsString);
    FieldByName('BQType').Value := '染色面料标签';
    post;
  end;
  //打印
  fPrintFile := ExtractFilePath(Application.ExeName) + 'Report\染色面料标签.rmf';
  with ADOQueryPrint do
  begin
    Close;
    sql.Clear;
    sql.Add('select A.*,B.*,C.DYID,D.ColNo colorNo,D.ColNameKH colorName,B.ColNameEng colorNameEng ');
    sql.Add('from BP_DY C ');
    sql.Add('inner join ML_Manage A on A.MLID=C.MLID ');
    sql.add('left join BP_ZDY BP on A.MBPID=BP.BPID ');
    sql.Add('left join BP_ColZDY D on D.PTID=C.TFID and BP.SKID=D.SKID ');
    sql.Add('left join RT_PTColor B on B.PTID=D.PTID ');
    sql.Add(' Where C.DYID=''' + Trim(maxno) + '''');
    //ShowMessage(sql.Text);
    Open;
  end;
  SCreateCDS20(ADOQueryPrint, CDS_Print);
  SInitCDSData20(ADOQueryPrint, CDS_Print);
  try
    Moudle := LoadLibrary('MakeQRBarcode.dll');
    @Makebar := GetProcAddress(Moudle, 'Make');
    @Mixtext := GetProcAddress(Moudle, 'MixText');
    Txt := Trim(CDS_Print.fieldbyname('DYID').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;
  if FileExists(fPrintFile) then
  begin
    RMVariables['QRBARCODE'] := fImagePath;
    RM1.LoadFromFile(fPrintFile);
    //RM1.ShowReport;
    RM1.PrintReport;
  end
  else
  begin
    Application.MessageBox(PChar('没有找' + ExtractFilePath(Application.ExeName) + 'Report\染色面料标签.rmf'), '提示', 0);
    exit;
  end;
  panel3.Visible := false;
end;

procedure TfrmMLMangeRS_SMCX.cxButton7Click(Sender: TObject);
var
  maxno, MaxSub: string;
  fPrintFile, Txt, fImagePath: string;
  Porderno: string;
  i, j: Integer;
  Moudle: THandle;
  Makebar: TMakebar;
  Mixtext: TMixtext;
begin
  with ADOQueryCmd do
  begin
    close;
    sql.Clear;
    SQL.Add('select * from BP_DY ');
    sql.Add('where MLID=''' + trim(CDS_Main.fieldbyname('MLID').AsString) + '''');
    sql.Add(' and DYType=''面料''');
    //ShowMessage(sql.Text);
    Open;
  end;
  if ADOQueryCmd.IsEmpty then
  begin
    if GetLSNo(ADOQueryTemp, maxno, 'DY', 'BP_DY', 3, 1) = False then
    begin
      Application.MessageBox('取最大号失败!', '提示', 0);
      Exit;
    end;
  end
  else
  begin
    maxno := Trim(ADOQueryCmd.fieldbyname('DYID').AsString);
  end;
  with ADOQueryCmd do
  begin
    if IsEmpty then
    begin
      Append;
      FieldByName('filler').Value := Trim(DName);
      FieldByName('DYID').Value := Trim(maxno);
    end
    else
    begin
      edit;
      FieldByName('laster').Value := Trim(DName);
      FieldByName('lasttime').Value := SGetServerDate(ADOQueryTemp);
    end;
    FieldByName('MLID').Value := Trim(CDS_Main.fieldbyname('MLID').AsString);
    FieldByName('TFID').Value := Trim(CDS_Main.fieldbyname('SKID').AsString);
    FieldByName('DYType').Value := '面料';
    FieldByName('BQType').Value := '染色客户标签';
    post;
  end;
  //////////记录
  if GetLSNo(ADOQueryTemp, MaxSub, 'JL', 'BP_DY_JL', 3, 1) = False then
  begin
    Application.MessageBox('取最大号失败!', '提示', 0);
    Exit;
  end;
  with ADOQueryCmd do
  begin
    close;
    sql.Clear;
    SQL.Add('select * from BP_DY_JL ');
    sql.Add('where 1=2');
    Open;
  end;
  with ADOQueryCmd do
  begin
    Append;
    FieldByName('filler').Value := Trim(DName);
    FieldByName('JLID').Value := Trim(MaxSub);
    FieldByName('DYID').Value := Trim(maxno);
    FieldByName('MLID').Value := Trim(CDS_Main.fieldbyname('MLID').AsString);
    FieldByName('TFID').Value := Trim(CDS_Main.fieldbyname('SKID').AsString);
    FieldByName('BQType').Value := '染色客户标签';
    post;
  end;
  //打印
  fPrintFile := ExtractFilePath(Application.ExeName) + 'Report\染色客户标签.rmf';
  with ADOQueryPrint do
  begin
    Close;
    sql.Clear;
    sql.Add('select A.*,B.*,C.DYID,D.ColNo colorNo,D.ColNameKH colorName,B.ColNameEng colorNameEng ');
    sql.Add('from BP_DY C ');
    sql.Add('inner join ML_Manage A on A.MLID=C.MLID ');
    sql.add('left join BP_ZDY BP on A.MBPID=BP.BPID ');
    sql.Add('left join BP_ColZDY D on D.PTID=C.TFID and BP.SKID=D.SKID ');
    sql.Add('left join RT_PTColor B on B.PTID=D.PTID ');
    sql.Add(' Where C.DYID=''' + Trim(maxno) + '''');
    //ShowMessage(sql.Text);
    Open;
  end;
  SCreateCDS20(ADOQueryPrint, CDS_Print);
  SInitCDSData20(ADOQueryPrint, CDS_Print);
  try
    Moudle := LoadLibrary('MakeQRBarcode.dll');
    @Makebar := GetProcAddress(Moudle, 'Make');
    @Mixtext := GetProcAddress(Moudle, 'MixText');
    Txt := Trim(CDS_Print.fieldbyname('DYID').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;
  if FileExists(fPrintFile) then
  begin
    RMVariables['QRBARCODE'] := fImagePath;
    RM1.LoadFromFile(fPrintFile);
    //RM1.ShowReport;
    RM1.PrintReport;
  end
  else
  begin
    Application.MessageBox(PChar('没有找' + ExtractFilePath(Application.ExeName) + 'Report\染色客户标签.rmf'), '提示', 0);
    exit;
  end;
end;

end.

