unit U_ClothContractInPutSX;

interface

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

type
  TfrmClothContractInPutSX = class(TForm)
    ToolBar1: TToolBar;
    TBSave: TToolButton;
    TBClose: TToolButton;
    ScrollBox1: TScrollBox;
    Label1: TLabel;
    ConNo: TEdit;
    Label4: TLabel;
    DeliveryDate: TDateTimePicker;
    Label5: TLabel;
    ToolBar2: TToolBar;
    ToolButton1: TToolButton;
    ToolButton2: TToolButton;
    cxGrid1: TcxGrid;
    Tv1: TcxGridDBTableView;
    v1PRTSpec: TcxGridDBColumn;
    cxGrid1Level1: TcxGridLevel;
    v1ClothQty: TcxGridDBColumn;
    v1Price: TcxGridDBColumn;
    v1ClothUnit: TcxGridDBColumn;
    ADOTemp: TADOQuery;
    ADOCmd: TADOQuery;
    DataSource1: TDataSource;
    Order_Sub: TClientDataSet;
    DataSource2: TDataSource;
    ADOZDY: TADOQuery;
    CDS_ZDY: TClientDataSet;
    FactoryNoName: TcxButtonEdit;
    ADOQuery1: TADOQuery;
    v1Column1: TcxGridDBColumn;
    v1Column2: TcxGridDBColumn;
    PanZDY: TPanel;
    CXGridZDY: TcxGrid;
    TVZDY: TcxGridDBTableView;
    VHelpZDYName: TcxGridDBColumn;
    CXGridZDYLevel1: TcxGridLevel;
    Button1: TButton;
    v1Column4: TcxGridDBColumn;
    Label2: TLabel;
    QDTime: TDateTimePicker;
    Label3: TLabel;
    CompanyName: TcxButtonEdit;
    Label6: TLabel;
    QDPalce: TEdit;
    Label8: TLabel;
    JHPlace: TcxButtonEdit;
    Label7: TLabel;
    ConTK1: TcxButtonEdit;
    Label9: TLabel;
    ConTk2: TcxButtonEdit;
    Label10: TLabel;
    ConTK3: TcxButtonEdit;
    Label11: TLabel;
    ConTK4: TcxButtonEdit;
    Label12: TLabel;
    ConTK5: TcxButtonEdit;
    Label13: TLabel;
    ConTk6: TcxButtonEdit;
    v1Column3: TcxGridDBColumn;
    procedure TBCloseClick(Sender: TObject);
    procedure TVZDYCellDblClick(Sender: TcxCustomGridTableView;
      ACellViewInfo: TcxGridTableDataCellViewInfo; AButton: TMouseButton;
      AShift: TShiftState; var AHandled: Boolean);
    procedure Button1Click(Sender: TObject);
    procedure PRTCodeNameKeyDown(Sender: TObject; var Key: Word;
      Shift: TShiftState);
    procedure TVZDYKeyPress(Sender: TObject; var Key: Char);
    procedure FormShow(Sender: TObject);
    procedure TBSaveClick(Sender: TObject);
    procedure v1OrderUnitPropertiesButtonClick(Sender: TObject;
      AButtonIndex: Integer);
    procedure v1PRTUnitPropertiesButtonClick(Sender: TObject;
      AButtonIndex: Integer);
    procedure v1PRTColorPropertiesButtonClick(Sender: TObject;
      AButtonIndex: Integer);
    procedure ToolButton1Click(Sender: TObject);
    procedure ToolButton2Click(Sender: TObject);
    procedure FactoryNoNamePropertiesButtonClick(Sender: TObject;
      AButtonIndex: Integer);
    procedure v1Column1PropertiesButtonClick(Sender: TObject;
      AButtonIndex: Integer);
    procedure v1PRTMFPropertiesButtonClick(Sender: TObject;
      AButtonIndex: Integer);
    procedure v1OrderQtyPropertiesButtonClick(Sender: TObject;
      AButtonIndex: Integer);
    procedure v1ClothQtyPropertiesButtonClick(Sender: TObject;
      AButtonIndex: Integer);
    procedure v1Column2PropertiesButtonClick(Sender: TObject;
      AButtonIndex: Integer);
    procedure FactoryNoNamePropertiesChange(Sender: TObject);
    procedure CompanyNamePropertiesButtonClick(Sender: TObject;
      AButtonIndex: Integer);
    procedure JHPlacePropertiesButtonClick(Sender: TObject;
      AButtonIndex: Integer);
    procedure ConTK1PropertiesButtonClick(Sender: TObject;
      AButtonIndex: Integer);
    procedure ConTK3PropertiesButtonClick(Sender: TObject;
      AButtonIndex: Integer);
    procedure ConTK4PropertiesButtonClick(Sender: TObject;
      AButtonIndex: Integer);
    procedure ConTK5PropertiesButtonClick(Sender: TObject;
      AButtonIndex: Integer);
    procedure ConTk6PropertiesButtonClick(Sender: TObject;
      AButtonIndex: Integer);
    procedure ConTk2PropertiesButtonClick(Sender: TObject;
      AButtonIndex: Integer);
    procedure ConNoKeyPress(Sender: TObject; var Key: Char);
  private
    FXS:Integer;
    procedure InitData();
    procedure ZDYHelp(FButn:TcxButtonEdit;LType:string);
    function  SaveData():Boolean;
    { Private declarations }
  public
    PState:Integer;
    FMainId,FConNo:String;
    { Public declarations }
  end;

var
  frmClothContractInPutSX: TfrmClothContractInPutSX;

implementation
uses
  U_DataLink,U_ZDYHelp,U_Fun;

{$R *.dfm}

procedure TfrmClothContractInPutSX.TBCloseClick(Sender: TObject);
begin
  Close;
end;

procedure TfrmClothContractInPutSX.InitData();
begin
  with ADOQuery1 do
  begin
    Close;
    SQL.Clear;
    sql.Add(' exec ClothContractSX_QryList :MainId,:WSql');
    if PState=1 then
    begin
      ADOQuery1.Parameters.ParamByName('MainId').Value:=Trim(FMainId);
      ADOQuery1.Parameters.ParamByName('WSQl').Value:='';
    end;
    if PState=0 then
    begin
      ADOQuery1.Parameters.ParamByName('MainId').Value:=Trim(FMainId);
      ADOQuery1.Parameters.ParamByName('WSql').Value:=' and 1<>1 ';
    end;
    Open;
  end;
  SCreateCDS20(ADOQuery1,Order_Sub);
  SInitCDSData20(ADOQuery1,Order_Sub);
  SCSHData(ADOQuery1,ScrollBox1,0);
  if PState=0 then
  begin
    with ADOTemp do
    begin
      Close;
      SQL.Clear;
      sql.Add('select Top 1* from ContractSX_Main order by FillTime desc ');
      Open;
    end;
    QDTime.DateTime:=SGetServerDate(ADOTemp);
    DeliveryDate.DateTime:=SGetServerDate(ADOTemp);
    QDTime.Checked:=True;
    DeliveryDate.Checked:=False;
    QDPalce.Text:='柯桥';
  end;
  PanZDY.Visible:=False;
end;

procedure TfrmClothContractInPutSX.ZDYHelp(FButn:TcxButtonEdit;LType:string);
var
  FType,ZDYName,FText:String;
begin
  PanZDY.Visible:=True;
  PanZDY.Left:=FButn.Left;
  PanZDY.Top:=FButn.Top+FButn.Height;
  with ADOZDY do
  begin
    Filtered:=False;
    Close;
    SQL.Clear;
    SQL.Add('select RTrim(ZDYNo) ZDYNo,RTrim(ZDYName) ZDYName from KH_ZDY where Type='''+Trim(LType)+'''');
    Open;
  end;
  FText:=Trim(FButn.Text);
  if FText<>'' then
    SDofilter(ADOZDY,' ZDYName like '+QuotedStr('%'+Trim(FText)+'%'))
  else
    SDofilter(ADOZDY,'');
  VHelpZDYName.Summary.GroupFormat:=Trim(FButn.Name);
end;

procedure TfrmClothContractInPutSX.TVZDYCellDblClick(Sender: TcxCustomGridTableView;
  ACellViewInfo: TcxGridTableDataCellViewInfo; AButton: TMouseButton;
  AShift: TShiftState; var AHandled: Boolean);
var
  FName:string;
begin
  if ADOZDY.IsEmpty then Exit;
  FName:=Trim(VHelpZDYName.Summary.GroupFormat);
  TcxButtonEdit(FindComponent(FName)).Text:=Trim(ADOZDY.fieldbyname('ZDYName').AsString);
  TcxButtonEdit(FindComponent(FName)).Hint:=Trim(ADOZDY.fieldbyname('ZDYNO').AsString);
  PanZDY.Visible:=False;
end;

procedure TfrmClothContractInPutSX.Button1Click(Sender: TObject);
begin
  PanZDY.Visible:=False;
end;

procedure TfrmClothContractInPutSX.PRTCodeNameKeyDown(Sender: TObject; var Key: Word;
  Shift: TShiftState);
begin
  {if (key=vk_return) or (Key=vk_Down) then
  begin
    if ADOZDY.Active then
      CXGridZDY.SetFocus;
  end; }
end;

procedure TfrmClothContractInPutSX.TVZDYKeyPress(Sender: TObject; var Key: Char);
begin
  if Key=#13 then
  begin
    if ADOZDY.IsEmpty then Exit;
    TcxButtonEdit(FindComponent(VHelpZDYName.Summary.GroupFormat)).Text:=Trim(ADOZDY.fieldbyname('ZDYName').AsString);
    TcxButtonEdit(FindComponent(VHelpZDYName.Summary.GroupFormat)).Hint:=Trim(ADOZDY.fieldbyname('ZDYNO').AsString);
    PanZDY.Visible:=False;
    ADOZDY.Active:=False;
  end;
end;

procedure TfrmClothContractInPutSX.FormShow(Sender: TObject);
begin
  {if Trim(DParameters1)='1' then
  begin
    v1Price.Visible:=False;
    v1ClothQty.Visible:=False;
    v1PRTQty.Visible:=False;
  end else
  begin
    v1Price.Visible:=True;
    v1ClothQty.Visible:=True;
    v1PRTQty.Visible:=True;
  end;  }
  InitData();
end;

function TfrmClothContractInPutSX.SaveData():Boolean;
var
  maxno:String;
begin
  try
    ADOCmd.Connection.BeginTrans;
    ///保存主表
    if Trim(FMainId)='' then
    begin
      if GetLSNo(ADOCmd,maxno,'SM','ContractSX_Main',2,1)=False then
      begin
        ADOCmd.Connection.RollbackTrans;
        Application.MessageBox('生成流水号异常！','提示',0);
        exit;
      end;
    end else
    begin
      maxno:=Trim(FMainId);
    end;

    with ADOCmd do
    begin
      Close;
      sql.Clear;
      SQL.Add('select * from ContractSX_Main where MainId='''+Trim(FMainId)+'''');
      Open;
    end;
    with ADOCmd do
    begin
      if Trim(FMainId)='' then
      begin
        Append;

      end
      else begin

        Edit;
      end;
      FieldByName('MainId').Value:=Trim(maxno);
      SSetsaveSql(ADOCmd,'ContractSX_Main',ScrollBox1,0);
      if Trim(FMainId)='' then
      begin
        FieldByName('Filler').Value:=Trim(DName);
      end else
      begin
        FieldByName('Editer').Value:=Trim(DName);
        FieldByName('EditTime').Value:=SGetServerDateTime(ADOTemp);
      end;
      Post;
    end;
    FMainId:=Trim(maxno);
    ///保存子表
    with Order_Sub do
    begin
      First;
      while not Eof do
      begin
        if Trim(Order_Sub.fieldbyname('SubId').AsString)='' then
        begin
          if GetLSNo(ADOCmd,maxno,'SS','ContractSX_Sub',3,1)=False then
          begin
            ADOCmd.Connection.RollbackTrans;
            Application.MessageBox('取子流水号失败！','提示',0);
            Exit;
          end;
        end else
        begin
          maxno:=Trim(Order_Sub.fieldbyname('SubId').AsString);
        end;
        with ADOCmd do
        begin
          Close;
          SQL.Clear;
          sql.Add('select * from ContractSX_Sub where MainId='''+Trim(FMainId)+'''');
          sql.Add(' and SubId='''+Trim(maxno)+'''');
          Open;
        end;
        with ADOCmd do
        begin
          if Trim(Order_Sub.fieldbyname('SubId').AsString)='' then
            Append
          else
            Edit;
          FieldByName('MainId').Value:=Trim(FMainId);
          FieldByName('SubId').Value:=Trim(maxno);
          SSetSaveDataCDSNew(ADOCmd,Tv1,Order_Sub,'ContractSX_Sub',0);
          if Trim(Order_Sub.fieldbyname('C_Qty').AsString)='' then
          begin
            FieldByName('C_Qty').Value:=0;
          end;
          if Trim(Order_Sub.fieldbyname('Price').AsString)='' then
          begin
            FieldByName('Price').Value:=0;
          end;
          Post;
        end;
        Order_Sub.Edit;
        Order_Sub.FieldByName('SubId').Value:=Trim(maxno);
        //Order_Sub.Post;
        Next;
      end;
    end;
    ADOCmd.Connection.CommitTrans;
    Result:=True;
  except
    Result:=False;
    ADOCmd.Connection.RollbackTrans;
    Application.MessageBox('保存失败！','提示',0);
  end;
end;

procedure TfrmClothContractInPutSX.TBSaveClick(Sender: TObject);
begin
  DeliveryDate.SetFocus;
  if Trim(ConNo.Text)='' then
  begin
    Application.MessageBox('合同编号不能为空！','提示',0);
    Exit;
  end;
  if Trim(FactoryNoName.Text)='' then
  begin
    Application.MessageBox('供方不能为空！','提示',0);
    Exit;
  end;
  if Order_Sub.IsEmpty then
  begin
    Application.MessageBox('明细不能为空！','提示',0);
    exit;
  end;
  if Order_Sub.Locate('C_Qty',null,[]) then
  begin
    Application.MessageBox('数量不能为空!','提示',0);
    Exit;
  end;
  if Order_Sub.Locate('C_Unit',null,[]) then
  begin
    Application.MessageBox('数量单位不能为空!','提示',0);
    Exit;
  end;
  if PState=1 then
  begin
    with ADOTemp do
    begin
      Close;
      sql.Clear;
      sql.Add('select * from ContractSX_Cloth_DH where MainId='''+Trim(FMainId)+'''');
      Open;
    end;
    if ADOTemp.IsEmpty=False then
    begin
      if Trim(FConNo)<>Trim(ConNo.Text) then
      begin
        Application.MessageBox('已经到货不能修改合同编号!','提示',0);
        Exit;
      end;
    end;
  end;
  if SaveData() then
  begin
    Application.MessageBox('保存成功！','提示',0);
  end;
end;

procedure TfrmClothContractInPutSX.v1OrderUnitPropertiesButtonClick(Sender: TObject;
  AButtonIndex: Integer);
begin
  try
    frmZDYHelp:=TfrmZDYHelp.Create(Application);
    with frmZDYHelp do
    begin
      flag:='OrdUnit';
      flagname:='单位';
      if ShowModal=1 then
      begin
        Self.Order_Sub.Edit;
        Self.Order_Sub.FieldByName('OrderUnit').Value:=Trim(ClientDataSet1.fieldbyname('ZDYName').AsString);
      end;
    end;
  finally
    frmZDYHelp.Free;
  end;
end;

procedure TfrmClothContractInPutSX.v1PRTUnitPropertiesButtonClick(Sender: TObject;
  AButtonIndex: Integer);
begin
  try
    frmZDYHelp:=TfrmZDYHelp.Create(Application);
    with frmZDYHelp do
    begin
      flag:='OrdUnit';
      flagname:='单位';
      if ShowModal=1 then
      begin
        Self.Order_Sub.Edit;
        Self.Order_Sub.FieldByName('PRTUnit').Value:=Trim(ClientDataSet1.fieldbyname('ZDYName').AsString);
      end;
    end;
  finally
    frmZDYHelp.Free;
  end;
end;

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

procedure TfrmClothContractInPutSX.ToolButton1Click(Sender: TObject);
begin
  with Order_Sub do
  begin
    Append;
    Post;
  end;
end;

procedure TfrmClothContractInPutSX.ToolButton2Click(Sender: TObject);
begin
  if Order_Sub.IsEmpty then Exit;
  if Trim(Order_Sub.fieldbyname('SubId').AsString)<>'' then
  begin
    with ADOTemp do
    begin
      Close;
      sql.Clear;
      sql.Add('select * from Contract_Sub_MX where SubId='''+Trim(Order_Sub.fieldbyname('SubId').AsString)+'''');
      Open;
    end;
    if ADOTemp.IsEmpty=False then
    begin
      Application.MessageBox('已到货不能删除数据!','提示',0);
      Exit;
    end;
    if Application.MessageBox('确定要删除数据吗？','提示',32+4)<>IDYES then Exit;
    with ADOCmd do
    begin
      Close;
      sql.Clear;
      sql.Add('delete Contract_Sub where SubId='''+Trim(Order_Sub.fieldbyname('SubId').AsString)+'''');
      ExecSQL;
    end;
  end;
  Order_Sub.Delete;
end;

procedure TfrmClothContractInPutSX.FactoryNoNamePropertiesButtonClick(
  Sender: TObject; AButtonIndex: Integer);
begin
  if Trim(FMainId)<>'' then
  begin
    with ADOTemp do
    begin
      Close;
      sql.Clear;
      sql.Add('select * from YF_Money_CR A where exists(');
      sql.Add('select * from ContractSX_Sub_MX B inner join Contract_Sub C on B.SubId=C.SubId ');
      sql.Add(' where C.Mainid='''+Trim(FMainId)+'''');
      sql.Add(' and B.MXID=A.YFTypeId)');
      Open;
    end;
    if ADOTemp.IsEmpty=False then
    begin
      Application.MessageBox('已经产生应付款不能修改供应商!','提示',0);
      Exit;
    end;
  end;

  try
    frmZDYHelp:=TfrmZDYHelp.Create(Application);
    with frmZDYHelp do
    begin
      flag:='Factory';
      flagname:='供方';
      MainType:='YCLFactory';
      if ShowModal=1 then
      begin
        FXS:=99;
        FactoryNoName.Text:=Trim(ClientDataSet1.fieldbyname('ZDYName').AsString);
        FactoryNoName.Hint:=Trim(ClientDataSet1.fieldbyname('ZDYNo').AsString);
      end;
    end;
  finally
    frmZDYHelp.Free;
  end;
end;

procedure TfrmClothContractInPutSX.v1Column1PropertiesButtonClick(
  Sender: TObject; AButtonIndex: Integer);
begin
  try
    frmZDYHelp:=TfrmZDYHelp.Create(Application);
    with frmZDYHelp do
    begin
      flag:='ClothSX';
      flagname:='纱线名称';
      if ShowModal=1 then
      begin
        Self.Order_Sub.Edit;
        Self.Order_Sub.FieldByName('C_CodeName').Value:=Trim(ClientDataSet1.fieldbyname('ZDYName').AsString);
        Self.Order_Sub.FieldByName('C_Code').Value:=Trim(ClientDataSet1.fieldbyname('ZDYNo').AsString);
      end;
    end;
  finally
    frmZDYHelp.Free;
  end;
end;

procedure TfrmClothContractInPutSX.v1PRTMFPropertiesButtonClick(
  Sender: TObject; AButtonIndex: Integer);
begin
  try
    frmZDYHelp:=TfrmZDYHelp.Create(Application);
    with frmZDYHelp do
    begin
      flag:='KZ';
      flagname:='克重单位';
      if ShowModal=1 then
      begin
        Self.Order_Sub.Edit;
        Self.Order_Sub.FieldByName('KZUnit').Value:=Trim(ClientDataSet1.fieldbyname('ZDYName').AsString);
      end;
    end;
  finally
    frmZDYHelp.Free;
  end;
end;

procedure TfrmClothContractInPutSX.v1OrderQtyPropertiesButtonClick(
  Sender: TObject; AButtonIndex: Integer);
begin
  try
    frmZDYHelp:=TfrmZDYHelp.Create(Application);
    with frmZDYHelp do
    begin
      flag:='MF';
      flagname:='门幅单位';
      if ShowModal=1 then
      begin
        Self.Order_Sub.Edit;
        Self.Order_Sub.FieldByName('MFUnit').Value:=Trim(ClientDataSet1.fieldbyname('ZDYName').AsString);
      end;
    end;
  finally
    frmZDYHelp.Free;
  end;
end;

procedure TfrmClothContractInPutSX.v1ClothQtyPropertiesButtonClick(
  Sender: TObject; AButtonIndex: Integer);
begin
  try
    frmZDYHelp:=TfrmZDYHelp.Create(Application);
    with frmZDYHelp do
    begin
      flag:='PriceUnit';
      flagname:='计价单位';
      if ShowModal=1 then
      begin
        Self.Order_Sub.Edit;
        Self.Order_Sub.FieldByName('PriceUnit').Value:=Trim(ClientDataSet1.fieldbyname('ZDYName').AsString);
      end;
    end;
  finally
    frmZDYHelp.Free;
  end;
end;

procedure TfrmClothContractInPutSX.v1Column2PropertiesButtonClick(
  Sender: TObject; AButtonIndex: Integer);
begin
  try
    frmZDYHelp:=TfrmZDYHelp.Create(Application);
    with frmZDYHelp do
    begin
      flag:='OrderUnit';
      flagname:='单位';
      if ShowModal=1 then
      begin
        Self.Order_Sub.Edit;
        Self.Order_Sub.FieldByName('C_Unit').Value:=Trim(ClientDataSet1.fieldbyname('ZDYName').AsString);
      end;
    end;
  finally
    frmZDYHelp.Free;
  end;
end;

procedure TfrmClothContractInPutSX.FactoryNoNamePropertiesChange(
  Sender: TObject);
begin
  {if FXS=99 then
  begin
    PanZDY.Visible:=False;
    FXS:=0;
    Exit;
  end;
  ZDYHelp(FactoryNoName,'FactoryNo1Name');  }
end;

procedure TfrmClothContractInPutSX.CompanyNamePropertiesButtonClick(
  Sender: TObject; AButtonIndex: Integer);
begin
  try
    frmZDYHelp:=TfrmZDYHelp.Create(Application);
    with frmZDYHelp do
    begin
      flag:='OrdDefStr2';
      flagname:='需方';
      if ShowModal=1 then
      begin
        FXS:=99;
        CompanyName.Text:=Trim(ClientDataSet1.fieldbyname('ZDYName').AsString);
      end;
    end;
  finally
    frmZDYHelp.Free;
  end;
end;

procedure TfrmClothContractInPutSX.JHPlacePropertiesButtonClick(
  Sender: TObject; AButtonIndex: Integer);
begin
  try
    frmZDYHelp:=TfrmZDYHelp.Create(Application);
    with frmZDYHelp do
    begin
      flag:='JHPlace';
      flagname:='交货地点';
      if ShowModal=1 then
      begin
        JHPlace.Text:=Trim(ClientDataSet1.fieldbyname('ZDYName').AsString);
      end;
    end;
  finally
    frmZDYHelp.Free;
  end;
end;

procedure TfrmClothContractInPutSX.ConTK1PropertiesButtonClick(
  Sender: TObject; AButtonIndex: Integer);
begin
  try
    frmZDYHelp:=TfrmZDYHelp.Create(Application);
    with frmZDYHelp do
    begin
      flag:='ConTK1';
      flagname:='供货质量及技术标准';
      if ShowModal=1 then
      begin
        ConTK1.Text:=Trim(ClientDataSet1.fieldbyname('ZDYName').AsString);
      end;
    end;
  finally
    frmZDYHelp.Free;
  end;
end;

procedure TfrmClothContractInPutSX.ConTK3PropertiesButtonClick(
  Sender: TObject; AButtonIndex: Integer);
begin
  try
    frmZDYHelp:=TfrmZDYHelp.Create(Application);
    with frmZDYHelp do
    begin
      flag:='ConTK3';
      flagname:='包装要求';
      if ShowModal=1 then
      begin
        ConTK3.Text:=Trim(ClientDataSet1.fieldbyname('ZDYName').AsString);
      end;
    end;
  finally
    frmZDYHelp.Free;
  end;
end;

procedure TfrmClothContractInPutSX.ConTK4PropertiesButtonClick(
  Sender: TObject; AButtonIndex: Integer);
begin
  try
    frmZDYHelp:=TfrmZDYHelp.Create(Application);
    with frmZDYHelp do
    begin
      flag:='ConTK4';
      flagname:='结算方式';
      if ShowModal=1 then
      begin
        ConTK4.Text:=Trim(ClientDataSet1.fieldbyname('ZDYName').AsString);
      end;
    end;
  finally
    frmZDYHelp.Free;
  end;
end;

procedure TfrmClothContractInPutSX.ConTK5PropertiesButtonClick(
  Sender: TObject; AButtonIndex: Integer);
begin
  try
    frmZDYHelp:=TfrmZDYHelp.Create(Application);
    with frmZDYHelp do
    begin
      flag:='ConTK5';
      flagname:='验收标准、方法及提出异议期限';
      if ShowModal=1 then
      begin
        ConTK5.Text:=Trim(ClientDataSet1.fieldbyname('ZDYName').AsString);
      end;
    end;
  finally
    frmZDYHelp.Free;
  end;
end;

procedure TfrmClothContractInPutSX.ConTk6PropertiesButtonClick(
  Sender: TObject; AButtonIndex: Integer);
begin
  try
    frmZDYHelp:=TfrmZDYHelp.Create(Application);
    with frmZDYHelp do
    begin
      flag:='ConTK6';
      flagname:='其它约定事项';
      if ShowModal=1 then
      begin
        ConTK6.Text:=Trim(ClientDataSet1.fieldbyname('ZDYName').AsString);
      end;
    end;
  finally
    frmZDYHelp.Free;
  end;
end;

procedure TfrmClothContractInPutSX.ConTk2PropertiesButtonClick(
  Sender: TObject; AButtonIndex: Integer);
begin
  try
    frmZDYHelp:=TfrmZDYHelp.Create(Application);
    with frmZDYHelp do
    begin
      flag:='ConTK2';
      flagname:='运输方法及费用承担';
      if ShowModal=1 then
      begin
        ConTK2.Text:=Trim(ClientDataSet1.fieldbyname('ZDYName').AsString);
      end;
    end;
  finally
    frmZDYHelp.Free;
  end;
end;

procedure TfrmClothContractInPutSX.ConNoKeyPress(Sender: TObject;
  var Key: Char);
begin
  if Key=#13 then
  begin
    if Trim(ConNo.Text)<>'' then
    begin
      with ADOTemp do
      begin
        Close;
        sql.Clear;
        sql.Add('select Top 1* from JYOrder_Main where OrderNo='''+Trim(ConNo.Text)+'''');
        Open;
      end;
      FactoryNoName.Text:=Trim(ADOTemp.fieldbyname('YCLFactory').AsString);
    end;
  end;
end;

end.
