345 lines
		
	
	
		
			9.0 KiB
		
	
	
	
		
			ObjectPascal
		
	
	
	
	
	
			
		
		
	
	
			345 lines
		
	
	
		
			9.0 KiB
		
	
	
	
		
			ObjectPascal
		
	
	
	
	
	
unit U_LabelAdd;
 | 
						||
 | 
						||
interface
 | 
						||
 | 
						||
uses
 | 
						||
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
 | 
						||
  Dialogs, ComCtrls, ToolWin, StdCtrls, BtnEdit, ExtCtrls, DB, ADODB,
 | 
						||
  RM_System, RM_Common, RM_Class, RM_GridReport, Buttons, FTComboBox,
 | 
						||
  RM_Preview, RM_e_Xls, RM_e_Graphic, RM_e_bmp, RM_BarCode,
 | 
						||
  RM_DsgGridReport, RM_Dataset, cxStyles, cxCustomData, cxGraphics,
 | 
						||
  cxFilter, cxData, cxDataStorage, cxEdit, cxDBData, cxGridLevel,
 | 
						||
  cxGridCustomTableView, cxGridTableView, cxGridDBTableView, cxClasses,
 | 
						||
  cxControls, cxGridCustomView, cxGrid;
 | 
						||
 | 
						||
type
 | 
						||
  TfrmLabelAdd = class(TForm)
 | 
						||
    Panel1: TPanel;
 | 
						||
    Label1: TLabel;
 | 
						||
    Label2: TLabel;
 | 
						||
    Label3: TLabel;
 | 
						||
    customerNo: TBtnEditA;
 | 
						||
    LabelFileName: TBtnEditA;
 | 
						||
    beizhu: TMemo;
 | 
						||
    ToolBar1: TToolBar;
 | 
						||
    Tsave: TToolButton;
 | 
						||
    Tclose: TToolButton;
 | 
						||
    ADOQueryCmd: TADOQuery;
 | 
						||
    OpenDialog1: TOpenDialog;
 | 
						||
    RMGridReport1: TRMGridReport;
 | 
						||
    BtOpen: TBitBtn;
 | 
						||
    Label9: TLabel;
 | 
						||
    LabelCaption: TEdit;
 | 
						||
    Label10: TLabel;
 | 
						||
    LabelType: TFTComboBox;
 | 
						||
    ADOQueryTmp: TADOQuery;
 | 
						||
    RMPreview1: TRMPreview;
 | 
						||
    RMGridReportDesigner1: TRMGridReportDesigner;
 | 
						||
    RMBarCodeObject1: TRMBarCodeObject;
 | 
						||
    RMBMPExport1: TRMBMPExport;
 | 
						||
    RMXLSExport1: TRMXLSExport;
 | 
						||
    RMDS_Main: TRMDBDataSet;
 | 
						||
    RMDataDictionary1: TRMDataDictionary;
 | 
						||
    ADOQuery1: TADOQuery;
 | 
						||
    RMGridReport2: TRMGridReport;
 | 
						||
    procedure TcloseClick(Sender: TObject);
 | 
						||
    procedure FormCreate(Sender: TObject);
 | 
						||
    procedure TsaveClick(Sender: TObject);
 | 
						||
    procedure LabelFileNameBtnClick(Sender: TObject);
 | 
						||
    procedure customerNoBtnClick(Sender: TObject);
 | 
						||
    procedure BtOpenClick(Sender: TObject);
 | 
						||
    procedure FormShow(Sender: TObject);
 | 
						||
    procedure RMPreview1DblClick(Sender: TObject);
 | 
						||
  private
 | 
						||
    fIsChg:Boolean;
 | 
						||
    function SaveData():Boolean;
 | 
						||
    function EditData():Boolean;
 | 
						||
    procedure InitWinData();
 | 
						||
    procedure InitVarDictionary();
 | 
						||
    procedure InitDataSetDictionary();
 | 
						||
  public
 | 
						||
    fcustomNo:string;
 | 
						||
    fKeyNo:string;
 | 
						||
    fWinStatus:integer;
 | 
						||
  end;
 | 
						||
 | 
						||
var
 | 
						||
  frmLabelAdd: TfrmLabelAdd;
 | 
						||
 | 
						||
implementation
 | 
						||
uses
 | 
						||
  U_DataLink,U_RTFun;
 | 
						||
{$R *.dfm}
 | 
						||
 | 
						||
procedure TfrmLabelAdd.TcloseClick(Sender: TObject);
 | 
						||
begin
 | 
						||
  if fIsChg then
 | 
						||
  begin
 | 
						||
    if application.MessageBox('<27><>ǩ<EFBFBD><C7A9><EFBFBD>ƹ<EFBFBD><C6B9><EFBFBD><EFBFBD>Ƿ<EFBFBD>Ҫ<EFBFBD><D2AA><EFBFBD><EFBFBD>?','<27><>ʾ<EFBFBD><CABE>Ϣ',1)=1 then
 | 
						||
    begin
 | 
						||
      Tsave.Click ;
 | 
						||
    end
 | 
						||
    else
 | 
						||
      close;
 | 
						||
  end
 | 
						||
  else
 | 
						||
    close;
 | 
						||
end;
 | 
						||
 | 
						||
procedure TfrmLabelAdd.FormCreate(Sender: TObject);
 | 
						||
begin
 | 
						||
  panel1.Align :=alClient;
 | 
						||
  fIsChg:=false;
 | 
						||
//  ClearWinData(panel1);
 | 
						||
 // InitVarDictionary();
 | 
						||
end;
 | 
						||
 | 
						||
procedure TfrmLabelAdd.TsaveClick(Sender: TObject);
 | 
						||
begin
 | 
						||
  if trim(labelCaption.Text)='' then
 | 
						||
  begin
 | 
						||
    application.MessageBox('<27><>ǩ<EFBFBD><C7A9><EFBFBD>Ʋ<EFBFBD><C6B2><EFBFBD>Ϊ<EFBFBD>գ<EFBFBD>','<27><>ʾ');
 | 
						||
    labelCaption.SetFocus;
 | 
						||
    exit;
 | 
						||
  end;
 | 
						||
  if trim(LabelFileName.Text)='' then
 | 
						||
  begin
 | 
						||
    application.MessageBox('<27><>ǩ<EFBFBD>ļ<EFBFBD><C4BC><EFBFBD><EFBFBD><EFBFBD>Ϊ<EFBFBD>գ<EFBFBD><D5A3><EFBFBD>ѡ<EFBFBD><D1A1><EFBFBD><EFBFBD>ǩ<EFBFBD><C7A9>','<27><>ʾ');
 | 
						||
    LabelFileName.SetFocus;
 | 
						||
    exit;
 | 
						||
  end;
 | 
						||
  if fWinStatus=0 then
 | 
						||
  begin
 | 
						||
    if SaveData() then
 | 
						||
    begin
 | 
						||
      ModalResult:=1;
 | 
						||
    end;
 | 
						||
  end
 | 
						||
  else
 | 
						||
  begin
 | 
						||
    if EditData() then
 | 
						||
    begin
 | 
						||
      ModalResult:=1;
 | 
						||
    end;
 | 
						||
  end;
 | 
						||
end;
 | 
						||
/////////////////////////////////////////////////////////////////////
 | 
						||
  //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ܣ<EFBFBD><DCA3><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
 | 
						||
/////////////////////////////////////////////////////////////////////
 | 
						||
function TfrmLabelAdd.SaveData():Boolean;
 | 
						||
begin
 | 
						||
  try
 | 
						||
     with ADOQueryCmd do
 | 
						||
     begin
 | 
						||
        close;
 | 
						||
        sql.Clear;
 | 
						||
        sql.Add('select * from P_Label');
 | 
						||
        sql.Add('where 1<>1');
 | 
						||
        Open;
 | 
						||
 | 
						||
        Append;
 | 
						||
        fieldByName('CustomerNO').value:=trim(customerno.txtCode);
 | 
						||
        fieldByName('filler').value:=DName;
 | 
						||
        fieldByName('filltime').value:=DServerDate;
 | 
						||
        fieldByName('beizhu').value:= trim(beizhu.text);
 | 
						||
        
 | 
						||
        fieldByName('LabelCaption').value:=trim(LabelCaption.text);
 | 
						||
        fieldByName('LabelType').value:=trim(LabelType.text);
 | 
						||
        fieldByName('LabelFileName').value:= trim(LabelFileName.text);
 | 
						||
        //TBlobField(FieldByName('LabelFile')).LoadFromStream(fStream);
 | 
						||
        RMGridReport1.SaveToBlobField(TBlobField(FieldByName('LabelFile')));
 | 
						||
        Post;
 | 
						||
    end;
 | 
						||
    result:=true;
 | 
						||
  except
 | 
						||
    Result:=false;
 | 
						||
    application.MessageBox('<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ǩģ<C7A9><C4A3><EFBFBD><EFBFBD><EFBFBD><EFBFBD>!','<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϣ',0);
 | 
						||
  end;
 | 
						||
end;
 | 
						||
 | 
						||
/////////////////////////////////////////////////////////////////////
 | 
						||
  //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ܣ<EFBFBD><DCA3><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
 | 
						||
/////////////////////////////////////////////////////////////////////
 | 
						||
function TfrmLabelAdd.EditData():Boolean;
 | 
						||
begin
 | 
						||
  try
 | 
						||
     with ADOQueryCmd do
 | 
						||
     begin
 | 
						||
        close;
 | 
						||
        sql.Clear;
 | 
						||
        sql.Add('select * from P_Label');
 | 
						||
        sql.Add('where labelId='+fkeyNo);
 | 
						||
        Open;
 | 
						||
        Edit;
 | 
						||
        fieldByName('LabelCaption').value:=trim(LabelCaption.text);
 | 
						||
        fieldByName('LabelType').value:=trim(LabelType.text);
 | 
						||
        fieldByName('LabelFileName').value:= trim(LabelFileName.text);
 | 
						||
        RMGridReport1.SaveToBlobField(TBlobField(FieldByName('LabelFile')));
 | 
						||
        fieldByName('Editer').value:=DName;
 | 
						||
        fieldByName('EditTime').value:=DServerDate;
 | 
						||
        fieldByName('beizhu').value:= trim(beizhu.text);
 | 
						||
        Post;
 | 
						||
    end;
 | 
						||
    result:=true;
 | 
						||
  except
 | 
						||
    Result:=false;
 | 
						||
    application.MessageBox('<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ǩģ<C7A9><C4A3><EFBFBD><EFBFBD><EFBFBD><EFBFBD>!','<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϣ',0);
 | 
						||
  end;
 | 
						||
end;
 | 
						||
 | 
						||
procedure TfrmLabelAdd.LabelFileNameBtnClick(Sender: TObject);
 | 
						||
begin
 | 
						||
  if OpenDialog1.Execute() then
 | 
						||
  begin
 | 
						||
    LabelFileName.Text:=OpenDialog1.FileName;
 | 
						||
    RMGridReport1.LoadFromFile(LabelFileName.Text);
 | 
						||
    RMGridReport1.Preview :=RMPreview1;
 | 
						||
    RMGridReport1.ShowReport ;
 | 
						||
  end;
 | 
						||
end;
 | 
						||
 | 
						||
procedure TfrmLabelAdd.customerNoBtnClick(Sender: TObject);
 | 
						||
begin
 | 
						||
 {
 | 
						||
  FormGetCust:=TFormGetCust.Create(self);
 | 
						||
 | 
						||
  if FormGetCust.ShowModal=mrok then
 | 
						||
  begin
 | 
						||
    customNo.TxtCode:=trim(FormGetCust.ADOQuery1.Fieldbyname('customno').AsString);
 | 
						||
    customNo.Text:=trim(FormGetCust.ADOQuery1.Fieldbyname('shortname').AsString);
 | 
						||
  end;
 | 
						||
  FormGetCust.Free;
 | 
						||
  }
 | 
						||
{  frmCustHelp:=TfrmCustHelp.create(self);
 | 
						||
  with frmCustHelp do
 | 
						||
  begin
 | 
						||
    if showModal=1 then
 | 
						||
    begin
 | 
						||
      customNo.TxtCode:=trim(ADOQueryHelp.Fieldbyname('customno').AsString);
 | 
						||
      customNo.Text:=trim(ADOQueryHelp.Fieldbyname('shortname').AsString);
 | 
						||
    end;
 | 
						||
    free;
 | 
						||
  end; }
 | 
						||
end;
 | 
						||
 | 
						||
procedure TfrmLabelAdd.BtOpenClick(Sender: TObject);
 | 
						||
begin
 | 
						||
  with RMGridReport2 do
 | 
						||
  begin
 | 
						||
    if trim(LabelFileName.Text)='' then
 | 
						||
      LoadFromFile(ExtractFilePath(Application.ExeName)+'report/<2F><>ǩģ<C7A9><C4A3>.rmf');
 | 
						||
    InitDataSetDictionary();
 | 
						||
    RMDS_Main.DataSet :=ADOQuery1;
 | 
						||
    application.ProcessMessages;
 | 
						||
 | 
						||
    DesignReport() ;
 | 
						||
    fIsChg:=true;
 | 
						||
    RMDS_Main.DataSet :=nil;
 | 
						||
    RMGridReport1.NewReport;
 | 
						||
    RMGridReport1.LoadFromFile(LabelFileName.Text);
 | 
						||
    RMGridReport1.ShowReport ;
 | 
						||
  end;
 | 
						||
 | 
						||
end;
 | 
						||
////////////////////////////////////////////////////////////
 | 
						||
  //<2F><>ʼ<EFBFBD><CABC><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
 | 
						||
////////////////////////////////////////////////////////////
 | 
						||
procedure TfrmLabelAdd.InitWinData();
 | 
						||
begin
 | 
						||
  try
 | 
						||
    with ADOQueryTmp do
 | 
						||
    begin
 | 
						||
      close;
 | 
						||
      sql.Clear ;
 | 
						||
      sql.Add('select A.*');
 | 
						||
    //  sql.Add('customNoName=isnull((select customName from BC_customer where customNO=A.customNo),A.customNo)');
 | 
						||
      sql.Add('from P_Label A');
 | 
						||
      sql.Add('WHERE LabelId='+fkeyNo);
 | 
						||
      Open;
 | 
						||
      if isEmpty then
 | 
						||
      begin
 | 
						||
        close;
 | 
						||
        exit;
 | 
						||
      end;
 | 
						||
 | 
						||
      SSetWinData(ADOQueryTmp,panel1);
 | 
						||
      RMGridReport1.LoadFromBlobField(tblobfield(fieldbyname('labelFile')));
 | 
						||
      RMGridReport2.FileName:=trim(fieldByName('labelFileName').AsString);
 | 
						||
      RMGridReport2.LoadFromBlobField(tblobfield(fieldbyname('labelFile')));
 | 
						||
      RMGridReport1.Preview :=RMPreview1;
 | 
						||
      //RMGridReport1.PrepareReport;
 | 
						||
      RMGridReport1.ShowReport ;
 | 
						||
    end;
 | 
						||
  except
 | 
						||
  end;
 | 
						||
end;
 | 
						||
 | 
						||
procedure TfrmLabelAdd.FormShow(Sender: TObject);
 | 
						||
begin
 | 
						||
  if fWinStatus>0 then
 | 
						||
    InitWinData();
 | 
						||
end;
 | 
						||
 | 
						||
procedure TfrmLabelAdd.RMPreview1DblClick(Sender: TObject);
 | 
						||
begin
 | 
						||
  //btOpen.Click ;
 | 
						||
end;
 | 
						||
////////////////////////////////////////////////////////////
 | 
						||
  //
 | 
						||
////////////////////////////////////////////////////////////
 | 
						||
procedure TfrmLabelAdd.InitVarDictionary();
 | 
						||
var
 | 
						||
  i:integer;
 | 
						||
begin
 | 
						||
{  try
 | 
						||
    with RMGridReport2 do
 | 
						||
    begin
 | 
						||
        Dictionary.Variables.Clear ;
 | 
						||
        Dictionary.Variables.AddCategory('<27>ͻ<EFBFBD><CDBB><EFBFBD>λ<EFBFBD><CEBB>Ϣ');
 | 
						||
        with ADOQueryTmp do
 | 
						||
        begin
 | 
						||
          close;
 | 
						||
          sql.clear;
 | 
						||
          sql.Add('exec P_Label_CustPrintData');
 | 
						||
          sql.Add(quotedStr(fCustomNo));
 | 
						||
          Open;
 | 
						||
          for i:=0 to FieldCount-1 do
 | 
						||
          begin
 | 
						||
 | 
						||
            Dictionary.Variables.Add(trim(fields[i].FieldName)
 | 
						||
                                ,'');
 | 
						||
            Dictionary.Variables.AsString[trim(fields[i].FieldName)]:=trim(fields[i].AsString);
 | 
						||
          end;
 | 
						||
        end;
 | 
						||
    end;
 | 
						||
  finally
 | 
						||
 | 
						||
  end;  }
 | 
						||
end;
 | 
						||
/////////////////////////////////////////////////
 | 
						||
  //
 | 
						||
/////////////////////////////////////////////////
 | 
						||
procedure TfrmLabelAdd.InitDataSetDictionary();
 | 
						||
begin
 | 
						||
{  with ADOQuery1 do
 | 
						||
  begin
 | 
						||
    close;
 | 
						||
    sql.Clear ;
 | 
						||
    sql.Add('exec P_Label_PrintSet');
 | 
						||
    sql.Add(quotedStr(''));
 | 
						||
    //sql.Add(','+quotedStr(''));
 | 
						||
    //sql.Add(','+quotedStr(''));
 | 
						||
    //sql.Add(','+quotedStr(''));
 | 
						||
    //sql.Add(','+quotedStr(''));
 | 
						||
    OPen;
 | 
						||
  end;
 | 
						||
  with RMGridReport2 do
 | 
						||
  begin
 | 
						||
    Dictionary.FieldAliases.Clear;
 | 
						||
    Dictionary.FieldAliases['RMDS_Main']:= '<27><>ǩ<EFBFBD><C7A9><EFBFBD><EFBFBD>';
 | 
						||
    Dictionary.FieldAliases['RMDS_Main."barcode"']:='<27><>ǩ<EFBFBD><C7A9><EFBFBD><EFBFBD>';
 | 
						||
  end;     }
 | 
						||
end;
 | 
						||
 | 
						||
end.
 |