unit U_XYZInPut;

interface

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

type
  TfrmXYZInPut = class(TForm)
    ToolBar1: TToolBar;
    TBSave: TToolButton;
    TBClose: TToolButton;
    DataSource3: TDataSource;
    CDS_Sub: TClientDataSet;
    ADOQueryCmd: TADOQuery;
    ADOQueryMain: TADOQuery;
    ADOQueryTemp: TADOQuery;
    cxGridPopupMenu2: TcxGridPopupMenu;
    Panel1: TPanel;
    Label13: TLabel;
    XYNO: TEdit;
    Label4: TLabel;
    XMONEY: TEdit;
    Label5: TLabel;
    XGSMC: TBtnEditA;
    XQYD: TBtnEditA;
    XMDD: TBtnEditA;
    Label15: TLabel;
    Label16: TLabel;
    Label19: TLabel;
    Label18: TLabel;
    FKTS: TEdit;
    Label28: TLabel;
    XKHNAME: TBtnEditA;
    Label30: TLabel;
    XKZRQ: TDateTimePicker;
    Label1: TLabel;
    XTBYQ: TMemo;
    Label3: TLabel;
    XHWMS: TMemo;
    NOTE: TMemo;
    Label6: TLabel;
    XYWDB: TComboBox;
    Label11: TLabel;
    XSDRQ: TDateTimePicker;
    XUNIT: TComboBox;
    Label12: TLabel;
    ZUSDHL: TEdit;
    Label14: TLabel;
    ZUSDJE: TEdit;
    Label20: TLabel;
    XYJBL: TEdit;
    Label21: TLabel;
    XTZRQ: TDateTimePicker;
    Label23: TLabel;
    XTZH: TComboBox;
    Label24: TLabel;
    XTZYHH: TEdit;
    Label25: TLabel;
    XYXQX: TDateTimePicker;
    Label26: TLabel;
    XKZH: TMemo;
    Label29: TLabel;
    Label32: TLabel;
    XKZFS: TComboBox;
    Label33: TLabel;
    XXGCS: TEdit;
    Label34: TLabel;
    XZYQX: TDateTimePicker;
    Label35: TLabel;
    XXYZZT: TComboBox;
    Label36: TLabel;
    XYWY: TComboBox;
    Label37: TLabel;
    XBM: TEdit;
    Label38: TLabel;
    XXYTZRQ: TDateTimePicker;
    Label7: TLabel;
    XSFZY: TComboBox;
    Label8: TLabel;
    XFP: TComboBox;
    Label9: TLabel;
    XSFTZ: TComboBox;
    Label10: TLabel;
    XDBYH: TComboBox;
    Label17: TLabel;
    XSLGC: TEdit;
    Label2: TLabel;
    TTR: TMemo;
    Label22: TLabel;
    TZR: TMemo;
    Label27: TLabel;
    SHREN: TMemo;
    Label31: TLabel;
    FKR: TMemo;
    XORDERNO: TEdit;
    procedure FormClose(Sender: TObject; var Action: TCloseAction);
    procedure TBCloseClick(Sender: TObject);
    procedure FormShow(Sender: TObject);
    procedure TBSaveClick(Sender: TObject);
    procedure ToolButton2Click(Sender: TObject);
    procedure ToolButton3Click(Sender: TObject);
    procedure v1Column5PropertiesButtonClick(Sender: TObject; AButtonIndex: Integer);
    procedure v1Column14PropertiesButtonClick(Sender: TObject; AButtonIndex: Integer);
    procedure v1Column16PropertiesButtonClick(Sender: TObject; AButtonIndex: Integer);
    procedure v1Column17PropertiesButtonClick(Sender: TObject; AButtonIndex: Integer);
    procedure ToolButton1Click(Sender: TObject);
    procedure ToolButton4Click(Sender: TObject);
    procedure v1ZZJGouPropertiesButtonClick(Sender: TObject; AButtonIndex: Integer);
    procedure v1Column12PropertiesButtonClick(Sender: TObject; AButtonIndex: Integer);
    procedure TCXLJClick(Sender: TObject);
    procedure XQYDBtnClick(Sender: TObject);
    procedure KHNameBtnClick(Sender: TObject);
    procedure Tv1Column5PropertiesButtonClick(Sender: TObject; AButtonIndex: Integer);
    procedure Tv1Column12PropertiesButtonClick(Sender: TObject; AButtonIndex: Integer);
    procedure Tv1Column14PropertiesButtonClick(Sender: TObject; AButtonIndex: Integer);
    procedure Tv1Column13PropertiesButtonClick(Sender: TObject; AButtonIndex: Integer);
    procedure Tv1Column9PropertiesButtonClick(Sender: TObject; AButtonIndex: Integer);
    procedure Tv1Column6PropertiesButtonClick(Sender: TObject; AButtonIndex: Integer);
    procedure XKHNAMEBtnClick(Sender: TObject);
    procedure XUNITChange(Sender: TObject);
    procedure XMONEYChange(Sender: TObject);
  private
    { Private declarations }
    function SaveCKData(): Boolean;
  public
    { Public declarations }
    FBCId, canshu3: string;
    CopyStr: string;
  end;

var
  frmXYZInPut: TfrmXYZInPut;

implementation

uses
  U_DataLink, U_RTFun, U_ZDYHelp, U_ZdyAttachment, U_ProductOrderList_Sel,
  U_DCDList_Sel, U_ZdyAttachGYS;

{$R *.dfm}

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

function TfrmXYZInPut.SaveCKData(): Boolean;
var
  FJMID, Maxno, MaxSubNo, FSCID: string;
begin
  try
    ADOQueryCmd.Connection.BeginTrans;
    with ADOQueryTemp do
    begin
      Close;
      sql.Clear;
      sql.Add('select * from XYZ_MAIN where XYID=''' + Trim(FBCId) + '''');
      Open;
    end;
    FBCId := Trim(ADOQueryTemp.fieldbyname('XYID').AsString);
    if Trim(FBCId) = '' then
    begin
      if GetLSNo(ADOQueryCmd, Maxno, 'XY', 'XYZ_MAIN', 3, 1) = False then
      begin
        Result := False;
        ADOQueryCmd.Connection.RollbackTrans;
        Application.MessageBox('取主编号失败!', '提示', 0);
        Exit;
      end;
    end
    else
    begin
      Maxno := Trim(FBCId);
    end;
    with ADOQueryCmd do
    begin
      Close;
      sql.Clear;
      sql.Add('select * from XYZ_MAIN where XYID=''' + Trim(Maxno) + '''');
      Open;
    end;
    with ADOQueryCmd do
    begin
      if Trim(FBCId) = '' then
      begin
        Append;
        FieldByName('Filler').Value := Trim(DName);
        FieldByName('FillerCode').Value := Trim(DCode);
        FieldByName('XXGCS').Value := 0;
//        FieldByName('status').Value := Trim(DCode);
      end
      else
      begin
        Edit;
        FieldByName('Editer').Value := Trim(DName);
        FieldByName('EditerCode').Value := Trim(DCode);
        FieldByName('EditTime').Value := SGetServerDate(ADOQueryTemp);

      end;
      FieldByName('XYID').Value := Trim(Maxno);
      RTSetsavedata(ADOQueryCmd, 'XYZ_MAIN', Panel1, 1);
      RTSetsavedata(ADOQueryCmd, 'XYZ_MAIN', Panel1, 2);
//      if Trim(FBCId) <> '' then
//      begin
//        FieldByName('XXGCS').Value := StrToFloatDEF(XXGCS.Text, 0) + 1;
//      end;

      Post;
    end;
//    with ADOQueryTemp do
//    begin
//      Close;
//      sql.Clear;
//      sql.Add('select * from XYZ_MAIN where XYNO=''' + Trim(XYNO.Text) + ''' and Valid=''Y'' ');
//      Open;
//    end;
//    if ADOQueryTemp.RecordCount > 1 then
//    begin
//      ADOQueryCmd.Connection.RollbackTrans;
//      Application.MessageBox('此发票号已经被使用，不能保存!', '提示', 0);
//      Exit;
//    end;

    ADOQueryCmd.Connection.CommitTrans;
    FBCId := Trim(Maxno);
    Result := True;
  except
    Result := False;
    ADOQueryCmd.Connection.RollbackTrans;
    Application.MessageBox('保存异常!', '提示', 0);
  end;

end;

procedure TfrmXYZInPut.TBCloseClick(Sender: TObject);
begin

  Close;
end;

procedure TfrmXYZInPut.FormShow(Sender: TObject);
begin

  with ADOQueryMain do
  begin
    Close;
    sql.Clear;
    sql.Add(' select A.* ');
    sql.Add(' from XYZ_MAIN A');
    sql.Add(' where XYID=''' + Trim(FBCId) + '''');
    Open;
  end;
  SCSHDataNew(ADOQueryMain, Panel1, 1);
  SCSHDataNew(ADOQueryMain, Panel1, 2);

  if CopyStr = '99' then
  begin
    FBCId := '';

  end;

  if Trim(FBCId) = '' then
  begin
    XYWY.Text := Trim(DName);
    XKZRQ.DateTime := SGetServerDate10(ADOQueryTemp);
    XSDRQ.DateTime := XKZRQ.DateTime;
    XTZRQ.DateTime := XKZRQ.DateTime;
    XYXQX.DateTime := XKZRQ.DateTime;
    XZYQX.DateTime := XKZRQ.DateTime;

    XXYTZRQ.DateTime := XKZRQ.DateTime;
//    XZYQX.DateTime := XKZRQ.DateTime;

  end;

end;

procedure TfrmXYZInPut.TBSaveClick(Sender: TObject);
var
  FReal: Double;
  i: Integer;
begin
  with Panel1 do
  begin
    for i := 0 to ControlCount - 1 do
    begin
      if Controls[i].Tag = 1 then
      begin
        if Controls[i] is TLabel then
          continue;
        if Controls[i].Tag <> 1 then
          continue;
        if Controls[i] is TEdit then
        begin
          if Trim(TEdit(Controls[i]).Text) = '' then
          begin
            Application.MessageBox('蓝色标注的信息为必填，请填写！', '提示', 0);
            Exit;
          end;
        end;
        if Controls[i] is TBtnEditA then
        begin
          if Trim(TBtnEditA(Controls[i]).Text) = '' then
          begin
            Application.MessageBox('蓝色标注的信息为必填，请填写！', '提示', 0);
            Exit;
          end;
        end;
        if Controls[i] is TComboBox then
        begin
          if Trim(TComboBox(Controls[i]).Text) = '' then
          begin
            Application.MessageBox('蓝色标注的信息为必填，请填写！', '提示', 0);
            Exit;
          end;
        end;
      end;
    end;
  end;

  ToolBar1.SetFocus;
  if SaveCKData() then
  begin
    Application.MessageBox('保存成功!', '提示', 0);
    ModalResult := 1;
    Exit;
  end;
end;

procedure TfrmXYZInPut.ToolButton2Click(Sender: TObject);
var
  i: Integer;
begin
  //CopyAddRowCDS(CDS_Sub);
  {with CDS_Sub do
  begin
    Edit;
    FieldByName('BGID').Value:=Null;
    FieldByName('BSID').Value:=Null;
    Post;
  end; }


  frmProductOrderList_Sel := TfrmProductOrderList_Sel.Create(self);
  with frmProductOrderList_Sel do
  begin
    if showmodal = 1 then
    begin
      while frmProductOrderList_Sel.Order_Main.Locate('SSel', True, []) do
      begin
        Self.CDS_Sub.Append;
        i := CDS_Sub.RecordCount;
        Self.CDS_Sub.FieldByName('XHInt').Value := i + 1;
        Self.CDS_Sub.FieldbyName('C6BGPrice').Value := 0;
//        Self.CDS_Sub.FieldbyName('Money').Value := 0;
        Self.CDS_Sub.fieldbyname('orderno').Value := Order_Main.fieldbyname('Orderno').asstring;
        Self.CDS_Sub.fieldbyname('FromMainId').Value := Order_Main.fieldbyname('MainId').asstring;
        Self.CDS_Sub.fieldbyname('C3BGNameEng').Value := Order_Main.fieldbyname('YWNAME').asstring;
        Self.CDS_Sub.fieldbyname('C3BGName').Value := Order_Main.fieldbyname('MPRTCODENAME').asstring;
        Self.CDS_Sub.fieldbyname('YSFuKuan').Value := Order_Main.fieldbyname('MPRTMF').asstring;
        Self.CDS_Sub.fieldbyname('YSKeZhong').Value := Order_Main.fieldbyname('MPRTKZ').asstring;
        Self.CDS_Sub.fieldbyname('YSChenFen').Value := Order_Main.fieldbyname('MPRTCF').asstring;
        Self.CDS_Sub.fieldbyname('C4BGQty').Value := Order_Main.fieldbyname('PRTORDERQTY').ASFLOAT;

        Self.CDS_Sub.fieldbyname('C5BGUnit').Value := Order_Main.fieldbyname('orderunit').asstring;

        Self.CDS_Sub.fieldbyname('ZZFF').Value := Order_Main.fieldbyname('BPBigType').asstring;
        Self.CDS_Sub.fieldbyname('ZDDATE').Value := Order_Main.fieldbyname('filltime').AsDateTime;
        Self.CDS_Sub.fieldbyname('GYLX').Value := Order_Main.fieldbyname('JGType').asstring;
        Self.CDS_Sub.fieldbyname('JSUNIT').Value := '件';
        Self.CDS_Sub.fieldbyname('WL').Value := '平纹';
        Self.CDS_Sub.fieldbyname('sj').Value := '是';

        Self.CDS_Sub.Post;
        frmProductOrderList_Sel.Order_Main.Delete;
      end;
    end;
    free;
  end;
end;

procedure TfrmXYZInPut.ToolButton3Click(Sender: TObject);
begin
  if CDS_Sub.IsEmpty then
    Exit;
  if Trim(CDS_Sub.fieldbyname('BSID').AsString) <> '' then
  begin
    if Application.MessageBox('确定要删除数据吗？', '提示', 32 + 4) <> IDYES then
      Exit;
    with ADOQueryCmd do
    begin
      Close;
      sql.Clear;
      sql.Add('Update JYOrder_BaoGuan_Sub Set SValid=''N'',SEditer=''' + Trim(DName) + ''',SEditTime=getdate() ');
      sql.Add(' where BSID=''' + Trim(CDS_Sub.fieldbyname('BSID').AsString) + '''');
      ExecSQL;
    end;
    with ADOQueryCmd do
    begin
      Close;
      sql.Clear;
      sql.Add('UPdate JYOrder_BaoGuan_Main Set ');
      sql.Add(' C7BGMoneyHZ=(select Sum(C7BGMoney) from JYOrder_BaoGuan_Sub A where A.BGID=JYOrder_BaoGuan_Main.BGID and A.SValid=''Y'' )');
      sql.Add(',E1BZQtyHZ=(select Sum(E1BZQty) from JYOrder_BaoGuan_Sub A where A.BGID=JYOrder_BaoGuan_Main.BGID and A.SValid=''Y'' )');
      sql.Add(',E2ChiMaQtyHZ=(select Sum(E2ChiMaQty) from JYOrder_BaoGuan_Sub A where A.BGID=JYOrder_BaoGuan_Main.BGID and A.SValid=''Y'' )');
      sql.Add(',E3MaoZHZ=(select Sum(E3MaoZ) from JYOrder_BaoGuan_Sub A where A.BGID=JYOrder_BaoGuan_Main.BGID and A.SValid=''Y'' )');
      sql.Add(',E4JingZHZ=(select Sum(E4JingZ) from JYOrder_BaoGuan_Sub A where A.BGID=JYOrder_BaoGuan_Main.BGID and A.SValid=''Y'' )');
      sql.Add(' where BGID=''' + Trim(CDS_Sub.fieldbyname('BGID').AsString) + '''');
      ExecSQL;
    end;
  end;
  CDS_Sub.Delete;
end;

procedure TfrmXYZInPut.v1Column5PropertiesButtonClick(Sender: TObject; AButtonIndex: Integer);
begin
  try
    frmZDYHelp := TfrmZDYHelp.Create(Application);
    with frmZDYHelp do
    begin
      flag := 'C3BGName';
      flagname := '报关品名';
      if ShowModal = 1 then
      begin
        with Self.CDS_Sub do
        begin
          Edit;
          FieldByName('C3BGName').Value := Trim(frmZDYHelp.ClientDataSet1.fieldbyname('ZdyName').AsString);
        end;
        with ADOQueryTemp do
        begin
          Close;
          sql.Clear;
          sql.Add('select Top 1 * from JYOrder_BaoGuan_Sub where C3BGName=''' + Trim(frmZDYHelp.ClientDataSet1.fieldbyname('ZDYName').AsString) + '''');
          sql.add(' and isnull(C2HSNO,'''')<>'''' ');
          sql.Add(' order by SFillTime desc');
          Open;
        end;
        with Self.CDS_Sub do
        begin
          Edit;
          FieldByName('C2HSNO').Value := Trim(ADOQueryTemp.fieldbyname('C2HSNO').asstring);
          FieldByName('C3BGNameEng').Value := Trim(ADOQueryTemp.fieldbyname('C3BGNameEng').asstring);
        end;
      end;
    end;
  finally
    frmZDYHelp.Free;
  end;
end;

procedure TfrmXYZInPut.v1Column14PropertiesButtonClick(Sender: TObject; AButtonIndex: Integer);
begin
  try
    frmZDYHelp := TfrmZDYHelp.Create(Application);
    with frmZDYHelp do
    begin
      flag := 'YSChenFen';
      flagname := '成分含量';
      if ShowModal = 1 then
      begin
        with Self.CDS_Sub do
        begin
          Edit;
          FieldByName('YSChenFen').Value := Trim(frmZDYHelp.ClientDataSet1.fieldbyname('ZdyName').AsString);
        end;
      end;
    end;
  finally
    frmZDYHelp.Free;
  end;
end;

procedure TfrmXYZInPut.v1Column16PropertiesButtonClick(Sender: TObject; AButtonIndex: Integer);
begin
  try
    frmZDYHelp := TfrmZDYHelp.Create(Application);
    with frmZDYHelp do
    begin
      flag := 'YSPinPai';
      flagname := '品牌';
      if ShowModal = 1 then
      begin
        with Self.CDS_Sub do
        begin
          Edit;
          FieldByName('YSPinPai').Value := Trim(frmZDYHelp.ClientDataSet1.fieldbyname('ZdyName').AsString);
        end;
      end;
    end;
  finally
    frmZDYHelp.Free;
  end;
end;

procedure TfrmXYZInPut.v1Column17PropertiesButtonClick(Sender: TObject; AButtonIndex: Integer);
begin
  try
    frmZDYHelp := TfrmZDYHelp.Create(Application);
    with frmZDYHelp do
    begin
      flag := 'YSShengChanShang';
      flagname := '生产商';
      if ShowModal = 1 then
      begin
        with Self.CDS_Sub do
        begin
          Edit;
          FieldByName('YSShengChanShang').Value := Trim(frmZDYHelp.ClientDataSet1.fieldbyname('ZdyName').AsString);
        end;
      end;
    end;
  finally
    frmZDYHelp.Free;
  end;
end;

procedure TfrmXYZInPut.ToolButton1Click(Sender: TObject);
begin
  if CDS_Sub.IsEmpty then
    Exit;

end;

procedure TfrmXYZInPut.ToolButton4Click(Sender: TObject);
var
  fsj: string;
begin
  if FBCId = '' then
    Exit;
  if Application.MessageBox('确定要执行审核操作吗？', '提示', 32 + 4) <> IDYES then
    Exit;

  try

    with ADOQueryCmd do
    begin
      Close;
      sql.Clear;
      sql.Add('UPdate JYOrder_BaoGuan_Main Set Status=''已审核'',ChkTime=getdate(),Chker=''' + Trim(DName) + '''');
      sql.Add(' where BGID=''' + Trim(FBCId) + '''');
      ExecSQL;
    end;
    Application.MessageBox('操作成功!', '提示', 0);
  except

    Application.MessageBox('操作异常!', '提示', 0);
  end;

end;

procedure TfrmXYZInPut.v1ZZJGouPropertiesButtonClick(Sender: TObject; AButtonIndex: Integer);
begin
  try
    frmZDYHelp := TfrmZDYHelp.Create(Application);
    with frmZDYHelp do
    begin
      flag := 'ZZJGou';
      flagname := '组织结构';
      if ShowModal = 1 then
      begin
        with Self.CDS_Sub do
        begin
          Edit;
          FieldByName('ZZJGou').Value := Trim(frmZDYHelp.ClientDataSet1.fieldbyname('ZdyName').AsString);
        end;
      end;
    end;
  finally
    frmZDYHelp.Free;
  end;
end;

procedure TfrmXYZInPut.v1Column12PropertiesButtonClick(Sender: TObject; AButtonIndex: Integer);
begin
  try
    frmZDYHelp := TfrmZDYHelp.Create(Application);
    with frmZDYHelp do
    begin
      flag := 'E5MaiTou';
      flagname := '唛头';
      if ShowModal = 1 then
      begin
        with Self.CDS_Sub do
        begin
          Edit;
          FieldByName('E5MaiTou').Value := Trim(frmZDYHelp.ClientDataSet1.fieldbyname('ZdyName').AsString);
        end;
      end;
    end;
  finally
    frmZDYHelp.Free;
  end;
end;

procedure TfrmXYZInPut.TCXLJClick(Sender: TObject);
begin
  if not Assigned(DataLink_DDMD) then
    DataLink_DDMD := TDataLink_DDMD.Create(Application);
  try
    with DataLink_DDMD.ADOLink do
    begin
      //if not Connected then
      begin
        Connected := false;
        ConnectionString := DConString;
        LoginPrompt := false;
        Connected := true;
      end;
    end;
  except
    application.MessageBox('数据库连接失败！', '错误', mb_Ok + MB_ICONERROR);
  end;
end;

procedure TfrmXYZInPut.XQYDBtnClick(Sender: TObject);
var
  fsj: string;
  FWZ: Integer;
begin
  fsj := Trim(TEdit(Sender).Hint);
  FWZ := Pos('/', fsj);
  try
    frmZDYHelp := TfrmZDYHelp.Create(Application);
    with frmZDYHelp do
    begin

      flag := Copy(fsj, 1, FWZ - 1);
//         ShowMessage(flag);
      flagname := Copy(fsj, FWZ + 1, Length(fsj) - FWZ);
      if flag = 'TOCOUNTRY' then
      begin
        fnote := True;
        V1Note.Caption := '中文名称';
        V1Name.Caption := '英文名称';
      end
      else if (flag = 'LCTOPlace') or (flag = 'LCFromPlace') or (flag = 'YSFS') then
      begin
        fnote := True;
        V1Note.Caption := '备注';
        V1Name.Caption := '名称';
//        V1Name.Caption := '英文名称';
      end
      else
      begin
        fnote := false;
      end;
//      if (flag = 'B6ChuYunGang') or (flag = 'B7DaoHuoGang') or (flag = 'ZMXingZhi')  then
//      begin
//        fnote := True;
//        V1Note.Caption := '备注';
////        V1Name.Caption := '英文名称';
//      end
//      else
//      begin
//        fnote := false;
//      end;

      if ShowModal = 1 then
      begin
        TEdit(Sender).Text := Trim(ClientDataSet1.fieldbyname('ZDYName').AsString);
      end;
    end;
  finally
    frmZDYHelp.Free;
  end;

end;

procedure TfrmXYZInPut.KHNameBtnClick(Sender: TObject);
begin
  try
    frmZdyAttachment := TfrmZdyAttachment.Create(Application);
    with frmZdyAttachment do
    begin

      if ShowModal = 1 then
      begin

        self.XKHName.Text := Trim(CDS_HZ.fieldbyname('CoName').AsString);
      end;
    end;
  finally
    frmZdyAttachment.Free;
  end;
end;

procedure TfrmXYZInPut.Tv1Column5PropertiesButtonClick(Sender: TObject; AButtonIndex: Integer);
begin
  try
    frmZdyAttachGYS := tfrmZdyAttachGYS.Create(Application);
    with frmZdyAttachGYS do
    begin

      if ShowModal = 1 then
      begin
        with CDS_Sub do
        begin
          Edit;
          fieldbyname('gcdm').Value := Trim(CDS_HZ.fieldbyname('CoCode').AsString);
          fieldbyname('gcname').Value := Trim(CDS_HZ.fieldbyname('CoName').AsString);
          fieldbyname('gcaddress').Value := Trim(CDS_HZ.fieldbyname('Coaddress').AsString);
        end;

      end;
    end;
  finally
    frmZdyAttachment.Free;
  end;
end;

procedure TfrmXYZInPut.Tv1Column12PropertiesButtonClick(Sender: TObject; AButtonIndex: Integer);
begin
  try
    frmZDYHelp := TfrmZDYHelp.Create(Application);
    with frmZDYHelp do
    begin
      flag := 'zzff';
      flagname := '织造方法';
      if ShowModal = 1 then
      begin
        with CDS_Sub do
        begin
          edit;
          fieldbyname('zzff').AsString := Trim(ClientDataSet1.fieldbyname('ZDYName').AsString);
        end;

      end;
    end;
  finally
    frmZDYHelp.Free;
  end;
end;

procedure TfrmXYZInPut.Tv1Column14PropertiesButtonClick(Sender: TObject; AButtonIndex: Integer);
begin
  try
    frmZDYHelp := TfrmZDYHelp.Create(Application);
    with frmZDYHelp do
    begin
      flag := 'wenlu';
      flagname := '纹路';
      if ShowModal = 1 then
      begin
        with CDS_Sub do
        begin
          edit;
          fieldbyname('wl').AsString := Trim(ClientDataSet1.fieldbyname('ZDYName').AsString);
        end;

      end;
    end;
  finally
    frmZDYHelp.Free;
  end;

end;

procedure TfrmXYZInPut.Tv1Column13PropertiesButtonClick(Sender: TObject; AButtonIndex: Integer);
begin
  try
    frmZDYHelp := TfrmZDYHelp.Create(Application);
    with frmZDYHelp do
    begin
      flag := 'GYLX';
      flagname := '工艺类型';
      if ShowModal = 1 then
      begin
        with CDS_Sub do
        begin
          edit;
          fieldbyname('gylx').AsString := Trim(ClientDataSet1.fieldbyname('ZDYName').AsString);
        end;

      end;
    end;
  finally
    frmZDYHelp.Free;
  end;
end;

procedure TfrmXYZInPut.Tv1Column9PropertiesButtonClick(Sender: TObject; AButtonIndex: Integer);
begin
  try
    frmZDYHelp := TfrmZDYHelp.Create(Application);
    with frmZDYHelp do
    begin
      flag := 'JSUNIT';
      flagname := '件数单位';
      if ShowModal = 1 then
      begin
        with CDS_Sub do
        begin
          edit;
          fieldbyname('JSUNIT').AsString := Trim(ClientDataSet1.fieldbyname('ZDYName').AsString);
        end;

      end;
    end;
  finally
    frmZDYHelp.Free;
  end;
end;

procedure TfrmXYZInPut.Tv1Column6PropertiesButtonClick(Sender: TObject; AButtonIndex: Integer);
begin
  try
    frmZdyAttachGYS := tfrmZdyAttachGYS.Create(Application);
    with frmZdyAttachGYS do
    begin

      if ShowModal = 1 then
      begin
        with CDS_Sub do
        begin
          Edit;
          fieldbyname('gcdm').Value := Trim(CDS_HZ.fieldbyname('CoCode').AsString);
          fieldbyname('gcname').Value := Trim(CDS_HZ.fieldbyname('CoName').AsString);
          fieldbyname('gcaddress').Value := Trim(CDS_HZ.fieldbyname('Coaddress').AsString);
        end;

      end;
    end;
  finally
    frmZdyAttachment.Free;
  end;
end;

procedure TfrmXYZInPut.XKHNAMEBtnClick(Sender: TObject);
begin
  try
    frmZdyAttachment := TfrmZdyAttachment.Create(Application);
    with frmZdyAttachment do
    begin

      if ShowModal = 1 then
      begin

        self.XKHName.Text := Trim(CDS_HZ.fieldbyname('CoName').AsString);

      end;
    end;
  finally
    frmZdyAttachment.Free;
  end;
end;

procedure TfrmXYZInPut.XUNITChange(Sender: TObject);
begin
  if XUNIT.Text = '美元' then
  begin
    ZUSDHL.Text := '1';
  end;
  if XUNIT.Text = '人民币' then
  begin
    ZUSDHL.Text := '0.156250';
  end;
end;

procedure TfrmXYZInPut.XMONEYChange(Sender: TObject);
begin
//  ZUSDJE.Text := FloatToStr();

  ZUSDJE.Text := FloatToStr(RoundFloat(StrToFloatDEF(XMONEY.Text, 0) * StrToFloatDEF(ZUSDHL.Text, 0), 2));

end;

end.

