unit U_YSFP_WXDJ;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, ComCtrls, ToolWin, ExtCtrls, StdCtrls, cxStyles, cxCustomData,
  cxGraphics, cxFilter, cxData, cxDataStorage, cxEdit, DB, cxDBData,
  cxCalendar, cxButtonEdit, cxTextEdit, cxGridLevel, cxGridCustomTableView,
  cxGridTableView, cxGridDBTableView, cxClasses, cxControls,
  cxGridCustomView, cxGrid, cxGridBandedTableView, cxGridDBBandedTableView,
  DBClient, ADODB, BtnEdit, cxCheckBox, cxCurrencyEdit, cxDropDownEdit;

type
  TfrmYSFP_WXDJ = class(TForm)
    Panel1: TPanel;
    Label2: TLabel;
    Label3: TLabel;
    Panel2: TPanel;
    ToolBar1: TToolBar;
    TBSave: TToolButton;
    TBClose: TToolButton;
    DataSource1: TDataSource;
    Order_PB: TClientDataSet;
    ADOQuery1: TADOQuery;
    Label1: TLabel;
    ToolBar2: TToolBar;
    TADD: TToolButton;
    Tdel: TToolButton;
    Label4: TLabel;
    cxGrid2: TcxGrid;
    Tv2: TcxGridDBTableView;
    cxGridDBColumn5: TcxGridDBColumn;
    cxGridDBColumn6: TcxGridDBColumn;
    v2FPPrice: TcxGridDBColumn;
    VBZ: TcxGridDBColumn;
    v2KP: TcxGridDBColumn;
    v2khConNo: TcxGridDBColumn;
    v2P_CodeName: TcxGridDBColumn;
    v2Column4: TcxGridDBColumn;
    v2PRTColor: TcxGridDBColumn;
    v2Note: TcxGridDBColumn;
    cxGridLevel1: TcxGridLevel;
    filltime: TDateTimePicker;
    Label7: TLabel;
    v2StyleNo: TcxGridDBColumn;
    v2PRTMF: TcxGridDBColumn;
    v2PRTKZ: TcxGridDBColumn;
    ComTaiTou: TBtnEditA;
    KHName: TBtnEditA;
    Label13: TLabel;
    Label14: TLabel;
    GSTel: TBtnEditA;
    GSFax: TBtnEditA;
    v2FPNo: TcxGridDBColumn;
    FPType: TComboBox;
    Label15: TLabel;
    FJTiaoKuan: TMemo;
    GSAddress: TBtnEditA;
    Label5: TLabel;
    Label6: TLabel;
    BankName: TBtnEditA;
    BankNo: TBtnEditA;
    Label8: TLabel;
    Label9: TLabel;
    BankDaiMa: TBtnEditA;
    BankAddress: TBtnEditA;
    ADOQuery2: TADOQuery;
    v2MQty: TcxGridDBColumn;
    v2JQty: TcxGridDBColumn;
    HZConNO: TEdit;
    LAVBE: TLabel;
    v2HYPrice: TcxGridDBColumn;
    v2SPName: TcxGridDBColumn;
    v2HYMoney: TcxGridDBColumn;
    Label10: TLabel;
    TKNote: TBtnEditA;
    Label11: TLabel;
    TELEXNO: TBtnEditA;
    procedure FormClose(Sender: TObject; var Action: TCloseAction);
    procedure FormDestroy(Sender: TObject);
    procedure FormShow(Sender: TObject);
    procedure TBCloseClick(Sender: TObject);
    procedure TADDClick(Sender: TObject);
    procedure v2P_CodeNamePropertiesButtonClick(Sender: TObject;
      AButtonIndex: Integer);
    procedure v2Column4PropertiesButtonClick(Sender: TObject;
      AButtonIndex: Integer);
    procedure v2PRTColorPropertiesButtonClick(Sender: TObject;
      AButtonIndex: Integer);
    procedure v2PRTMFPropertiesButtonClick(Sender: TObject;
      AButtonIndex: Integer);
    procedure v2PRTKZPropertiesButtonClick(Sender: TObject;
      AButtonIndex: Integer);
    procedure v2Column1PropertiesEditValueChanged(Sender: TObject);
    procedure ComTaiTouBtnClick(Sender: TObject);
    procedure FJTiaoKuanDblClick(Sender: TObject);
    procedure BankNameBtnClick(Sender: TObject);
    procedure TdelClick(Sender: TObject);
    procedure TBSaveClick(Sender: TObject);
    procedure KHNameBtnClick(Sender: TObject);
    procedure GSTelBtnClick(Sender: TObject);
    procedure GSFaxBtnClick(Sender: TObject);
    procedure GSAddressBtnClick(Sender: TObject);
    procedure BankNoBtnClick(Sender: TObject);
    procedure BankDaiMaBtnClick(Sender: TObject);
    procedure BankAddressBtnClick(Sender: TObject);
    procedure v2SPNamePropertiesButtonClick(Sender: TObject;
      AButtonIndex: Integer);
    procedure cxGridDBColumn6PropertiesButtonClick(Sender: TObject;
      AButtonIndex: Integer);
    procedure VBZPropertiesButtonClick(Sender: TObject;
      AButtonIndex: Integer);
    procedure TKNoteBtnClick(Sender: TObject);
    procedure TELEXNOBtnClick(Sender: TObject);
  private
    procedure initgrid();
    function SaveData():Boolean;
    { Private declarations }
  public
    FMainid,FFPID,FromID: string;      
    { Public declarations }
  end;

var
  frmYSFP_WXDJ: TfrmYSFP_WXDJ;

implementation
Uses
    U_DataLink,U_ZDYHelp,U_Fun,U_YSCR_CX, U_ZDYHelpSel,U_JYOrderCon_CX;
{$R *.dfm}
function TfrmYSFP_WXDJ.SaveData():Boolean;
var
  maxno,maxsubNo:String;
begin
  if trim(FFPID)='' then
  begin
    if GetLSNo(ADOQuery1,maxno,'PI','JYOrderFPPI_Main',3,1)=False then
    begin
      Application.MessageBox('取最大号失败!','提示',0);
      Exit;
    end;
  end
  else
  begin
    maxno:=Trim(FFPID);
  end;
  with ADOQuery1 do
  begin
    Close;
    sql.Clear;
    SQL.Add('select * from JYOrderFPPI_Main where FPID='''+Trim(maxno)+'''');
    Open;
  end;
  with ADOQuery1 do
  begin
    if isempty then
    begin
      Append;
    end
    else begin
      Edit;
    end;
    FieldByName('FPID').Value:=Trim(maxno);
    fieldbyname('Filler').Value:=trim(DName);
    SSetsaveSqlNew(ADOQuery1,'JYOrderFPPI_Main',panel1,0);
    post;
  end;
  with Order_PB do
  begin
    First;
    while not Eof do
    begin
      if Trim(Order_PB.fieldbyname('PISID').AsString)='' then
      begin
        if GetLSNo(ADOQuery1,maxSubno,'PS','JYOrderFPPI_Sub',4,1)=False then
        begin
          Application.MessageBox('取子流水号失败！','提示',0);
          Exit;
        end;
      end else
      begin
        maxSubno:=Trim(Order_PB.fieldbyname('PISID').AsString);
      end;
      with ADOQuery1 do
      begin
        Close;
        SQL.Clear;
        sql.Add('select * from JYOrderFPPI_Sub where FPID='''+Trim(maxno)+'''');
        sql.Add(' and PISID='''+Trim(maxSubno)+'''');
        Open;
      end;
      with ADOQuery1 do
      begin
        if isempty then
        Append
        else
          Edit;
          FieldByName('FPID').Value:=Trim(maxno);
          FieldByName('PISID').Value:=Trim(maxSubno);
          RTSetSaveDataCDS(ADOQuery1,Tv2,Order_PB,'JYOrderFPPI_Sub',0);
          fieldbyname('YFID').Value:=Order_PB.fieldbyname('YFID').AsString;
          fieldbyname('YFName').Value:=Order_PB.fieldbyname('YFName').AsString;
          fieldbyname('Qty').Value:=Order_PB.Fieldbyname('Qty').AsFloat;
          fieldbyname('HYPrice').Value:=Order_PB.Fieldbyname('HYPrice').AsFloat;
          fieldbyname('FPPrice').Value:=Order_PB.Fieldbyname('FPPrice').AsFloat;
          fieldbyname('Price').Value:=Order_PB.Fieldbyname('FPPrice').AsFloat+Order_PB.Fieldbyname('HYPrice').AsFloat;
          fieldbyname('JQty').Value:=Order_PB.Fieldbyname('JQty').AsFloat;
          fieldbyname('MQty').Value:=Order_PB.Fieldbyname('MQty').AsFloat;
          fieldbyname('KPMoney').Value:=Order_PB.Fieldbyname('KPMoney').AsFloat;
          fieldbyname('HYMoney').Value:=Order_PB.Fieldbyname('HYMoney').AsFloat;
          Post;
      end;
      Order_PB.Edit;
      Order_PB.FieldByName('PISID').Value:=Trim(maxSubno);
      Next;
    end;
  end;
  Application.MessageBox('保存成功！','提示',0);
  ModalResult:=1;
end;

procedure TfrmYSFP_WXDJ.initgrid();
begin
  with Adoquery1 do
  begin
    close;
    sql.clear;
    sql.add('select * from JYOrderFPPI_Main ');
    SQL.Add('where FPID='''+trim(FFPID)+'''');
    open;
  end;
  if ADOQuery1.IsEmpty=False then
  SCSHDataNew(ADOQuery1,panel1,0);
  if FromID='1' then
  FFPID:='';
  with Adoquery1 do
  begin
    close;
    sql.clear;
    sql.add('select * from JYOrderFPPI_Sub ');
    SQL.Add('where FPID='''+trim(FFPID)+'''');
    open;
  end;
  SCreateCDS20(Adoquery1,Order_PB);
  SInitCDSData20(Adoquery1,Order_PB);
end;

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

procedure TfrmYSFP_WXDJ.FormDestroy(Sender: TObject);
begin
  frmYSFP_WXDJ:=nil;
end;

procedure TfrmYSFP_WXDJ.FormShow(Sender: TObject);
begin
  ReadCxGrid('应收款登记外销发票2',Tv2,'财务管理');
  filltime.DateTime:=now;
  initgrid();
end;

procedure TfrmYSFP_WXDJ.TBCloseClick(Sender: TObject);
begin
  WriteCxGrid('应收款登记外销发票2',Tv2,'财务管理');
  Close;
end;

procedure TfrmYSFP_WXDJ.TADDClick(Sender: TObject);
var FHZConNO,FKHConNO:string;
begin
  frmJYorderConCX:=TfrmJYorderConCX.create(self);
  with frmJYorderConCX do
  begin
    formid:='2';
    if showmodal=1 then
    begin
      with Order_Main do
      begin
        first;
        while not eof do
        begin
          if fieldbyname('Ssel').AsBoolean=true then
          begin
            Self.KHName.text:=Order_Main.fieldbyname('ConPerson2').AsString;
            if FHZConNO='' then
            begin
              FHZConNO:=Order_Main.fieldbyname('KHConNo').AsString;
              if self.HZConNO.Text='' then
              self.HZConNO.Text:=self.HZConNO.Text+Order_Main.fieldbyname('KHConNo').AsString
              else
              self.HZConNo.Text:=self.HZConNo.Text+','+Order_Main.fieldbyname('KHConNo').AsString;
            end
            else
            begin
              if FHZConNo<>Order_Main.fieldbyname('KHConNo').AsString then
              begin
                FHZConNO:=Order_Main.fieldbyname('KHConNo').AsString;
                self.HZConNo.Text:=self.HZConNo.Text+','+Order_Main.fieldbyname('KHConNo').AsString;
              end;
            end;
            with Order_PB do
            begin
              append;
              fieldbyname('KHConNo').AsString:=Order_Main.fieldbyname('KHConNo').AsString;
              fieldbyname('YFID').AsString:=Order_Main.fieldbyname('Subid').AsString;
              fieldbyname('StyleNo').Value:=Order_Main.fieldbyname('StyleNo').AsString;
              if Order_Main.fieldbyname('OrderUnit').AsString='KG' then
              fieldbyname('JQty').Value:=Order_Main.fieldbyname('PRTOrderQty').AsFloat
              else
              fieldbyname('MQty').Value:=Order_Main.fieldbyname('PRTOrderQty').AsFloat;
              fieldbyname('Qty').Value:=Order_Main.fieldbyname('PRTOrderQty').AsFloat;
              fieldbyname('QtyUnit').AsString:=Order_Main.fieldbyname('OrderUnit').AsString;
              fieldbyname('FPPrice').asfloat:=Order_Main.fieldbyname('PRTPrice').asfloat;
              fieldbyname('KPMoney').asfloat:=Order_Main.fieldbyname('PRTPrice').asfloat*Order_Main.fieldbyname('PRTOrderQty').AsFloat;
              fieldbyname('BZType').AsString:=Order_Main.fieldbyname('PriceUnit').AsString;
              fieldbyname('P_CodeName').Value:=Order_Main.fieldbyname('PrtCodeName').AsString;
              fieldbyname('P_Spec').AsString:=Order_Main.fieldbyname('PRTspec').AsString;
              fieldbyname('PRTColor').AsString:=Order_Main.fieldbyname('SOrdDefStr4').AsString;
              fieldbyname('PRTMF').AsString:=Order_Main.fieldbyname('PRTMF').AsString;
              fieldbyname('PRTKZ').AsString:=Order_Main.fieldbyname('PRTKZ').AsString;
              post;
            end;
          end;
          next;
        end;
      end;
    end;
    free;
  end;
end;

procedure TfrmYSFP_WXDJ.v2P_CodeNamePropertiesButtonClick(Sender: TObject;
  AButtonIndex: Integer);
begin
  try
    frmZDYHelp:=TfrmZDYHelp.Create(Application);
    with frmZDYHelp do
    begin
      flag:='P_CodeName';
      flagname:='品名';
      if ShowModal=1 then
      begin
        Self.Order_PB.Edit;
        Self.Order_PB.FieldByName('P_CodeName').Value:=Trim(ClientDataSet1.fieldbyname('ZDYName').AsString);
      end;
    end;
  finally
    frmZDYHelp.Free;
  end;
end;

procedure TfrmYSFP_WXDJ.v2Column4PropertiesButtonClick(Sender: TObject;
  AButtonIndex: Integer);
begin
  try
    frmZDYHelp:=TfrmZDYHelp.Create(Application);
    with frmZDYHelp do
    begin
      flag:='P_Spec';
      flagname:='规格';
      if ShowModal=1 then
      begin
        Self.Order_PB.Edit;
        Self.Order_PB.FieldByName('P_Spec').Value:=Trim(ClientDataSet1.fieldbyname('ZDYName').AsString);
      end;
    end;
  finally
    frmZDYHelp.Free;
  end;
end;

procedure TfrmYSFP_WXDJ.v2PRTColorPropertiesButtonClick(Sender: TObject;
  AButtonIndex: Integer);
begin
  try
    frmZDYHelp:=TfrmZDYHelp.Create(Application);
    with frmZDYHelp do
    begin
      flag:='PRTColor';
      flagname:='颜色';
      if ShowModal=1 then
      begin
        Self.Order_PB.Edit;
        Self.Order_PB.FieldByName('PRTColor').Value:=Trim(ClientDataSet1.fieldbyname('ZDYName').AsString);
      end;
    end;
  finally
    frmZDYHelp.Free;
  end;
end;

procedure TfrmYSFP_WXDJ.v2PRTMFPropertiesButtonClick(Sender: TObject;
  AButtonIndex: Integer);
begin
  try
    frmZDYHelp:=TfrmZDYHelp.Create(Application);
    with frmZDYHelp do
    begin
      flag:='PRTMF';
      flagname:='门幅';
      if ShowModal=1 then
      begin
        Self.Order_PB.Edit;
        Self.Order_PB.FieldByName('PRTMF').Value:=Trim(ClientDataSet1.fieldbyname('ZDYName').AsString);
      end;
    end;
  finally
    frmZDYHelp.Free;
  end;
end;

procedure TfrmYSFP_WXDJ.v2PRTKZPropertiesButtonClick(Sender: TObject;
  AButtonIndex: Integer);
begin
  try
    frmZDYHelp:=TfrmZDYHelp.Create(Application);
    with frmZDYHelp do
    begin
      flag:='PRTKZ';
      flagname:='克重';
      if ShowModal=1 then
      begin
        Self.Order_PB.Edit;
        Self.Order_PB.FieldByName('PRTKZ').Value:=Trim(ClientDataSet1.fieldbyname('ZDYName').AsString);
      end;
    end;
  finally
    frmZDYHelp.Free;
  end;
end;

procedure TfrmYSFP_WXDJ.v2Column1PropertiesEditValueChanged(
  Sender: TObject);
var
  mvalue,FFieldName:String;
begin
  mvalue:=TcxTextEdit(Sender).EditingText;
  if Trim(mvalue)='' then
  begin
    mvalue:='0';
  end;
  FFieldName:=Trim(Tv2.Controller.FocusedColumn.DataBinding.FilterFieldName);
  with Order_PB do
  begin
    Edit;
    FieldByName(FFieldName).Value:=Trim(mvalue);
  end;
  with order_PB do
  begin
    edit;
    fieldbyname('KPMoney').Value:=(fieldbyname('FPPrice').AsFloat+fieldbyname('HYPrice').AsFloat)*fieldbyname('Qty').AsFloat;
    fieldbyname('HYMoney').Value:=fieldbyname('HYPrice').AsFloat*fieldbyname('Qty').AsFloat;
  end;
end;

procedure TfrmYSFP_WXDJ.ComTaiTouBtnClick(Sender: TObject);
begin
  try
    frmZDYHelp:=TfrmZDYHelp.Create(Application);
    with frmZDYHelp do
    begin
      flag:='comTaiTouGS';
      flagname:='公司抬头';
      if ShowModal=1 then
      begin
        ComtaiTou.Text:=Trim(ClientDataSet1.fieldbyname('ZDYName').AsString);
          with ADOQuery1 do
          begin
            Close;
            sql.Clear;
            sql.Add('select Top 1* from JYOrderFPPI_Main where ComTaiTou='''+Trim(ClientDataSet1.fieldbyname('ZDYName').AsString)+'''');
            sql.add(' order by FillTime desc');
            Open;
            Self.GSTel.Text:=Trim(ADOQuery1.fieldbyname('GSTel').AsString);
            Self.GSAddress.Text:=Trim(ADOQuery1.fieldbyname('GSAddress').AsString);
            Self.GSFax.Text:=Trim(ADOQuery1.fieldbyname('GSFax').AsString);
          end;
      end;
    end;
  finally
    frmZDYHelp.Free;
  end;
end;

procedure TfrmYSFP_WXDJ.FJTiaoKuanDblClick(Sender: TObject);
var
  fsj:string;
  FWZ:Integer;
  i:integer;
begin
  fsj:=Trim(TMemo(Sender).Hint);
  FWZ:=Pos('/',fsj);
  i:=1;
  try
    frmZDYHelpSel:=TfrmZDYHelpSel.Create(Application);
    with frmZDYHelpSel do
    begin
      flag:=Copy(fsj,1,FWZ-1);
      flagname:=Copy(fsj,FWZ+1,Length(fsj)-fwz);
      if ShowModal=1 then
      begin
        FJTiaoKuan.Lines.Clear;
        with ClientDataSet1 do
        begin
          First;
          while not Eof do
          begin
            if FieldByName('SSel').AsBoolean=True then
            begin
              FJTiaoKuan.Lines.Add(inttostr(i)+'.'+FieldByName('ZDYName').AsString);
              i:=i+1;
            end;
            Next;
          end;
        end;
      end;
    end;
  finally
    frmZDYHelpSel.Free;
  end;
end;

procedure TfrmYSFP_WXDJ.BankNameBtnClick(Sender: TObject);
begin
  try
    frmZDYHelp:=TfrmZDYHelp.Create(Application);
    with frmZDYHelp do
    begin
      flag:='BankNamePI';
      flagname:='银行名称';
      if ShowModal=1 then
      begin
        BankName.Text:=Trim(ClientDataSet1.fieldbyname('ZDYName').AsString);
          with ADOQuery1 do
          begin
            Close;
            sql.Clear;
            sql.Add('select Top 1* from JYOrderFPPI_Main where BankName='''+Trim(ClientDataSet1.fieldbyname('ZDYName').AsString)+'''');
            sql.add(' order by FillTime desc');
            Open;
            Self.BankNo.Text:=Trim(ADOQuery1.fieldbyname('BankNo').AsString);
            Self.BankDaiMa.Text:=Trim(ADOQuery1.fieldbyname('BankDaiMa').AsString);
            Self.BankAddress.Text:=Trim(ADOQuery1.fieldbyname('BankAddress').AsString); 
          end;
      end;
    end;
  finally
    frmZDYHelp.Free;
  end;
end;

procedure TfrmYSFP_WXDJ.TdelClick(Sender: TObject);
begin
  if order_PB.IsEmpty then exit;
  if order_PB.FieldByName('PISID').AsString<>'' then
  begin
    if application.MessageBox('确定要删除吗','提示',1)=2 then exit;
    with ADOQuery2 do
    begin
      close;
      sql.Clear;
      sql.Add('delete from JYOrderFPPI_Sub ');
      sql.add('where PISID='''+trim(order_PB.FieldByName('PISID').AsString)+'''');
      execsql;
    end;
  end;
  Order_PB.Delete;
end;

procedure TfrmYSFP_WXDJ.TBSaveClick(Sender: TObject);
begin
  toolbar1.SetFocus;
  if Trim(ComTaiTou.Text)='' then
  begin
    Application.MessageBox('公司抬头不能为空！','提示',0);
    Exit;
  end;
  if Trim(KHName.Text)='' then
  begin
    Application.MessageBox('客户不能为空！','提示',0);
    Exit;
  end;
  SaveData();

end;

procedure TfrmYSFP_WXDJ.KHNameBtnClick(Sender: TObject);
begin
  frmZDYHelp:=TfrmZDYHelp.Create(Application);
  with frmZDYHelp do
  begin
    flag:='KHName1';
    flagname:='客户';
    if ShowModal=1 then
    begin
      KHName.Text:=Trim(ClientDataSet1.fieldbyname('ZDYName').AsString);
    end;
    free;
  end;
end;

procedure TfrmYSFP_WXDJ.GSTelBtnClick(Sender: TObject);
begin
  frmZDYHelp:=TfrmZDYHelp.Create(Application);
  with frmZDYHelp do
  begin
    flag:='GSTel';
    flagname:='公司电话';
    if ShowModal=1 then
    begin
      GSTel.Text:=Trim(ClientDataSet1.fieldbyname('ZDYName').AsString);
    end;
    free;
  end;
end;

procedure TfrmYSFP_WXDJ.GSFaxBtnClick(Sender: TObject);
begin
  frmZDYHelp:=TfrmZDYHelp.Create(Application);
  with frmZDYHelp do
  begin
    flag:='GSFax';
    flagname:='公司传真';
    if ShowModal=1 then
    begin
      GSFax.Text:=Trim(ClientDataSet1.fieldbyname('ZDYName').AsString);
    end;
    free;
  end;
end;

procedure TfrmYSFP_WXDJ.GSAddressBtnClick(Sender: TObject);
begin
  frmZDYHelp:=TfrmZDYHelp.Create(Application);
  with frmZDYHelp do
  begin
    flag:='GSAddress';
    flagname:='公司地址';
    if ShowModal=1 then
    begin
      GSAddress.Text:=Trim(ClientDataSet1.fieldbyname('ZDYName').AsString);
    end;
    free;
  end;
end;

procedure TfrmYSFP_WXDJ.BankNoBtnClick(Sender: TObject);
begin
  frmZDYHelp:=TfrmZDYHelp.Create(Application);
  with frmZDYHelp do
  begin
    flag:='BankNo1';
    flagname:='银行账号';
    if ShowModal=1 then
    begin
      BankNo.Text:=Trim(ClientDataSet1.fieldbyname('ZDYName').AsString);
    end;
    free;
  end;
end;

procedure TfrmYSFP_WXDJ.BankDaiMaBtnClick(Sender: TObject);
begin
  frmZDYHelp:=TfrmZDYHelp.Create(Application);
  with frmZDYHelp do
  begin
    flag:='BankDaiMa';
    flagname:='银行代码';
    if ShowModal=1 then
    begin
      BankDaiMa.Text:=Trim(ClientDataSet1.fieldbyname('ZDYName').AsString);
    end;
    free;
  end;
end;

procedure TfrmYSFP_WXDJ.BankAddressBtnClick(Sender: TObject);
begin
  frmZDYHelp:=TfrmZDYHelp.Create(Application);
  with frmZDYHelp do
  begin
    flag:='BankAddress';
    flagname:='银行地址';
    if ShowModal=1 then
    begin
      BankAddress.Text:=Trim(ClientDataSet1.fieldbyname('ZDYName').AsString);
    end;
    free;
  end;
end;

procedure TfrmYSFP_WXDJ.v2SPNamePropertiesButtonClick(Sender: TObject;
  AButtonIndex: Integer);
begin
  frmZDYHelp:=TfrmZDYHelp.Create(Application);
  with frmZDYHelp do
  begin
    flag:='SPName';
    flagname:='商品编号';
    if ShowModal=1 then
    begin
      with Order_PB do
      begin
        edit;
        fieldbyname('SPName').AsString:=Trim(ClientDataSet1.fieldbyname('ZDYName').AsString);
      end;
    end;
    free;
  end;
end;

procedure TfrmYSFP_WXDJ.cxGridDBColumn6PropertiesButtonClick(
  Sender: TObject; AButtonIndex: Integer);
begin
  frmZDYHelp:=TfrmZDYHelp.Create(Application);
  with frmZDYHelp do
  begin
    flag:='QtyUnit';
    flagname:='结算数量单位';
    if ShowModal=1 then
    begin
      with Order_PB do
      begin
        edit;
        fieldbyname('QtyUnit').AsString:=Trim(ClientDataSet1.fieldbyname('ZDYName').AsString);
      end;
    end;
    free;
  end;
end;

procedure TfrmYSFP_WXDJ.VBZPropertiesButtonClick(Sender: TObject;
  AButtonIndex: Integer);
begin
  frmZDYHelp:=TfrmZDYHelp.Create(Application);
  with frmZDYHelp do
  begin
    flag:='BZType';
    flagname:='币种';
    if ShowModal=1 then
    begin
      with Order_PB do
      begin
        edit;
        fieldbyname('BZType').AsString:=Trim(ClientDataSet1.fieldbyname('ZDYName').AsString);
      end;
    end;
    free;
  end;
end;

procedure TfrmYSFP_WXDJ.TKNoteBtnClick(Sender: TObject);
begin
  frmZDYHelp:=TfrmZDYHelp.Create(Application);
  with frmZDYHelp do
  begin
    flag:='TKNote';
    flagname:='条款信息';
    if ShowModal=1 then
    begin
      TKNote.Text:=trim(ClientDataSet1.fieldbyname('ZDYName').AsString);
    end;
    free;
  end;
end;

procedure TfrmYSFP_WXDJ.TELEXNOBtnClick(Sender: TObject);
begin
  frmZDYHelp:=TfrmZDYHelp.Create(Application);
  with frmZDYHelp do
  begin
    flag:='TELEXNO';
    flagname:='TELEXNO';
    if ShowModal=1 then
    begin
      TELEXNO.Text:=trim(ClientDataSet1.fieldbyname('ZDYName').AsString);
    end;
    free;
  end;
end;

end.
