unit U_TatClothInfoInput;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, cxStyles, cxCustomData, cxGraphics, cxFilter, cxData, cxDataStorage,
  cxEdit, DB, cxDBData, ADODB, DBClient, cxGridLevel, cxGridCustomTableView,
  cxGridTableView, cxGridDBTableView, cxClasses, cxControls, cxGridCustomView,
  cxGrid, ComCtrls, ToolWin, cxGridCustomPopupMenu, cxGridPopupMenu, cxTextEdit,
  cxButtonEdit, StdCtrls, ExtCtrls, cxCurrencyEdit, BtnEdit, U_BaseList,
  cxLookAndFeels, cxLookAndFeelPainters, dxSkinsCore, dxSkinsDefaultPainters,
  cxNavigator, dxDateRanges, U_SLT, dxBarBuiltInMenu, cxPC,
  dxScrollbarAnnotations, StrUtils, IdBaseComponent, IdComponent, JPEG,
  IdTCPConnection, IdTCPClient, IdExplicitTLSClientServerBase, IdFTP, ShellAPI;

type
  FdDy = record
    inc: integer; //客户端套接字句柄
    FDdys: string[32]; //客户端套接字
    FdDysName: string[32]; //客户端套接字
  end;

type
  TfrmTatClothInfoInput = class(TForm)
    ToolBar1: TToolBar;
    ToolButton1: TToolButton;
    TBClose: TToolButton;
    ADOQueryCmd: TADOQuery;
    ADOQueryTemp: TADOQuery;
    ScrollBox1: TScrollBox;
    Label1: TLabel;
    Label5: TLabel;
    Label15: TLabel;
    Label22: TLabel;
    Label3: TLabel;
    C_Code: TEdit;
    C_Name: TEdit;
    C_Width: TBtnEditC;
    C_GramWeight: TBtnEditC;
    ToolButton6: TToolButton;
    BCIID: TEdit;
    Label9: TLabel;
    C_Spec: TEdit;
    Panel1: TPanel;
    cxPageControl2: TcxPageControl;
    cxGrid1: TcxGrid;
    TV1: TcxGridDBTableView;
    cxGridDBColumn3: TcxGridDBColumn;
    cxGridDBColumn4: TcxGridDBColumn;
    cxGridDBColumn5: TcxGridDBColumn;
    cxGridDBColumn8: TcxGridDBColumn;
    cxGridDBColumn7: TcxGridDBColumn;
    TV1Column1: TcxGridDBColumn;
    TV1Column2: TcxGridDBColumn;
    cxGridLevel2: TcxGridLevel;
    Panel3: TPanel;
    Panel4: TPanel;
    Label20: TLabel;
    ToolBar2: TToolBar;
    ToolButton2: TToolButton;
    ToolButton3: TToolButton;
    ToolButton5: TToolButton;
    Panel2: TPanel;
    cxPageControl1: TcxPageControl;
    cxGrid2: TcxGrid;
    Tv2: TcxGridDBTableView;
    v2Column10: TcxGridDBColumn;
    cxGridDBColumn1: TcxGridDBColumn;
    v2Column2: TcxGridDBColumn;
    v2Column5: TcxGridDBColumn;
    v2Column6: TcxGridDBColumn;
    Tv2Column1: TcxGridDBColumn;
    Tv2Column2: TcxGridDBColumn;
    cxGridLevel1: TcxGridLevel;
    Panel5: TPanel;
    Panel6: TPanel;
    Label21: TLabel;
    ToolBar3: TToolBar;
    ToolButton4: TToolButton;
    ToolButton7: TToolButton;
    ToolButton8: TToolButton;
    CDS_1: TClientDataSet;
    DS_1: TDataSource;
    CDS_2: TClientDataSet;
    DS_2: TDataSource;
    Label2: TLabel;
    Label4: TLabel;
    C_COLOR: TEdit;
    C_colorno: TEdit;
    Label6: TLabel;
    C_GONGYI: TEdit;
    Label7: TLabel;
    C_Composition: TEdit;
    Panel9: TPanel;
    Panel10: TPanel;
    GroupBox1: TGroupBox;
    ScrollBox2: TScrollBox;
    ToolButton9: TToolButton;
    adoqueryPicture: TADOQuery;
    IdFTP1: TIdFTP;
    Panel7: TPanel;
    ToolBar4: TToolBar;
    ToolButton10: TToolButton;
    ToolButton11: TToolButton;
    cxGrid3: TcxGrid;
    TV3: TcxGridDBTableView;
    v1Column3: TcxGridDBColumn;
    cxGrid1Level1: TcxGridLevel;
    CDS_3: TClientDataSet;
    DS_3: TDataSource;
    Label8: TLabel;
    FBMETER: TEdit;
    Label10: TLabel;
    XJMETER: TEdit;
    Label11: TLabel;
    CBGS: TEdit;
    procedure FormShow(Sender: TObject);
    procedure TBCloseClick(Sender: TObject);
    procedure ToolButton1Click(Sender: TObject);
    procedure CYColorKeyPress(Sender: TObject; var Key: Char);
    procedure CYKZExit(Sender: TObject);
    procedure CYMFExit(Sender: TObject);
    procedure FormCreate(Sender: TObject);
    procedure CYJGGYBtnDnClick(Sender: TObject);
    procedure C_WidthBtnDnClick(Sender: TObject);
    procedure C_WidthBtnUpClick(Sender: TObject);
    procedure ToolButton6Click(Sender: TObject);
    procedure ToolButton2Click(Sender: TObject);
    procedure ToolButton3Click(Sender: TObject);
    procedure ToolButton7Click(Sender: TObject);
    procedure ToolButton4Click(Sender: TObject);
    procedure ToolButton5Click(Sender: TObject);
    procedure ToolButton8Click(Sender: TObject);
    procedure ToolButton9Click(Sender: TObject);
    procedure ToolButton10Click(Sender: TObject);
    procedure ToolButton11Click(Sender: TObject);
    procedure FormClose(Sender: TObject; var Action: TCloseAction);
  private
    canshu1: string;
    Fint: Integer;
    procedure InitGrid();
    function SaveData(): Boolean;
    procedure CALCYarnQty();
    procedure InitImage();
    procedure LookImage(FileName: string);
    { Private declarations }
  public
    FBCIID, FCTID: string;
    CopyInt: Integer;

  public
    dFdDy: array[0..20] of FdDy; //客户端连接数组
    { Public declarations }
  end;

var
  Mach: array of TfrmSlt;

var
  frmTatClothInfoInput: TfrmTatClothInfoInput;

implementation

uses
  U_DataLink, U_RTFun, U_iniParam, U_CloInfoFileUp, U_ZDYHelp,
  U_AttachmentUpload, U_YarnInfoSel;

{$R *.dfm}
procedure TfrmTatClothInfoInput.LookImage(FileName: string);
var
  sFieldName: string;
begin

  sFieldName := leftbstr(ExtractFilePath(Application.ExeName), 1) + ':\图片查看';

  if not DirectoryExists(pchar(sFieldName)) then
    CreateDirectory(pchar(sFieldName), nil);

  sFieldName := sFieldName + '\' + trim(FileName);

  try
    IdFTP1.Host := ReadINIFileStr('SYSTEMSET.INI', 'SERVER', '服务器地址', '127.0.0.1');
    IdFTP1.Username := 'three';
    IdFTP1.Password := '641010';
    IdFTP1.Connect();
  except

  end;

  if IdFTP1.Connected then
  begin
    application.ProcessMessages;
    try
//      ShowMessage(PChar(Trim('D:\' + Trim(FileName))));
      IdFTP1.Get(Trim(UserDataFlag + 'YP\' + FileName), sFieldName, true, false);
    except
      Application.MessageBox('客户图样文件不存在', '提示', MB_ICONWARNING);
      IdFTP1.Quit;
      Exit;
    end;
  end
  else
  begin
    Application.MessageBox('无法连接文件服务器', '提示', MB_ICONWARNING);
    IdFTP1.Quit;
    Exit;
  end;
  if IdFTP1.Connected then
    IdFTP1.Quit;
  ShellExecute(Handle, 'open', PChar(sFieldName), '', '', SW_SHOWNORMAL);
end;

procedure TfrmTatClothInfoInput.InitImage();
var
  i, j: integer;
  jpg: TJpegImage;
  myStream: TADOBlobStream;
begin

  j := length(Mach);
  if j > 0 then
  begin
    for i := 0 to j - 1 do
    begin
      Mach[i].free;
    end;
  end;
  SetLength(Mach, 0);
  if FBCIID = '' then
    exit;
  try
    with adoqueryPicture do
    begin
      close;
      sql.Clear;
      sql.Add(' select A.TFID,A.WBID,A.FilesOther,A.FileName from TP_File A  ');
      sql.add('where  A.WBID=' + quotedstr(trim(FBCIID)));

      open;
    end;
    j := adoqueryPicture.RecordCount;
    if j < 1 then
      exit;
    adoqueryPicture.DisableControls;
    adoqueryPicture.First;
    SetLength(Mach, j);
    jpg := TJpegImage.Create();
    for i := 0 to j - 1 do
    begin
      if triM(adoqueryPicture.fieldbyname('FilesOther').AsString) <> '' then
      begin
        myStream := tadoblobstream.Create(tblobfield(adoqueryPicture.fieldbyname('FilesOther')), bmread);
        jpg.LoadFromStream(myStream);
        Mach[i] := TfrmSlt.Create(Self);
        Mach[i].Name := trim(adoqueryPicture.fieldbyname('TFID').AsString);
        Mach[i].Parent := ScrollBox2;
        Mach[i].Left := 0 + i * 165;
        Mach[i].Init(adoqueryPicture.fieldbyname('TFID').AsString, adoqueryPicture.fieldbyname('FileName').AsString, jpg);
      end;
      adoqueryPicture.Next;
    end;
    adoqueryPicture.EnableControls;
  finally
    jpg.free;
    application.ProcessMessages;
  end;
end;

procedure TfrmTatClothInfoInput.CALCYarnQty();
var
  MYarnQty, MOrdQty, MWidth, MMachLatitudeDensity: Double;
begin

end;

procedure TfrmTatClothInfoInput.InitGrid();
begin

  with ADOQueryTemp do
  begin
    Close;
    SQL.Clear;
    SQL.Add('select * from BS_Cloth_Info where BCIID=''' + Trim(FBCIID) + '''');
    Open;
  end;

  SCSHData(ADOQueryTemp, ScrollBox1, 2);
  SCSHData(ADOQueryTemp, ScrollBox1, 0);

  with ADOQueryTemp do
  begin
    Close;
    sql.Clear;
    sql.Add('select A.*  from BS_Cloth_mf A ');
    sql.Add(' where  A.BCIID=''' + Trim(FBCIID) + '''');
    if CopyInt = 1 then
    begin
      sql.Add('and 1<>1');
    end;

    Open;
  end;
  SCreateCDS(ADOQueryTemp, CDS_3);
  SInitCDSData(ADOQueryTemp, CDS_3);

end;

procedure TfrmTatClothInfoInput.FormShow(Sender: TObject);
begin
  InitGrid();
  if CopyInt = 1 then
  begin
    FBCIID := '';
    BCIID.text := '';
    C_Code.text := '';

  end;
  InitImage();
//  if C_Code.text = '' then
//  begin
//    with ADOQueryTemp do
//    begin
//      Close;
//      sql.Clear;
//      sql.Add(' exec P_YP_Get_CPBH  ');
//      sql.Add('@CTID=' + quotedstr(Trim(FCTID)));
//
//      Open;
//    end;
//  end;
//  if trim(C_Code.Text) = '' then
//  begin
//    with ADOQueryTemp do
//    begin
//      Close;
//      sql.Clear;
//      sql.Add(' exec P_YP_Get_No @Str=''CP'' ');
//      Open;
//    end;
//    C_Code.Text := trim(ADOQueryTemp.FieldByName('NewC_Code').asstring);
//  end;

//  if FCPName = '针织' then
//  begin
//    CYPUnit.text := 'KG';
//  end;
//  if FCPName = '梭织' then
//  begin
//    CYPUnit.text := 'M';
//  end;

end;

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

function TfrmTatClothInfoInput.SaveData(): Boolean;
var
  maxId, maxpbno: string;
begin
  try
    ADOQueryCmd.Connection.BeginTrans;
    if Trim(FBCIID) = '' then
    begin
      if GetLSNo(ADOQueryCmd, maxId, 'Y', 'BS_Cloth_Info', 4, 1) = False then
      begin
        Result := False;
        ADOQueryCmd.Connection.RollbackTrans;
        Application.MessageBox('取最大号失败！', '提示', 0);
        Exit;
      end;

      BCIID.Text := trim(maxId);
    end
    else
    begin
      maxId := Trim(FBCIID);
    end;
    with ADOQueryCmd do
    begin
      Close;
      SQL.Clear;
      sql.Add('select * from BS_Cloth_Info where BCIID=''' + Trim(FBCIID) + '''');
      Open;
    end;
    with ADOQueryCmd do
    begin
      if Trim(FBCIID) = '' then
      begin
        Append;
        FieldByName('CTID').Value := Trim(FCTID);
        FieldByName('FILLID').Value := Trim(DCode);
        FieldByName('FILLER').Value := Trim(DName);
        FieldByName('FILLTIME').Value := SGetServerDateTime(ADOQueryTemp);
      end
      else
      begin
        Edit;
        FieldByName('EDITER').Value := Trim(DName);
        FieldByName('EDITTIME').Value := SGetServerDateTime(ADOQueryTemp);
      end;
      FieldByName('BCIID').Value := Trim(maxId);
      if trim(C_Code.Text) = '' then
        C_Code.Text := Trim(maxId);
      RTSetsavedata(ADOQueryCmd, 'BS_Cloth_Info', ScrollBox1, 2);
      Post;
    end;
    with ADOQueryTemp do
    begin
      Close;
      sql.Clear;
      sql.Add('select count(*) as AA from BS_Cloth_Info where C_Code=''' + Trim(C_Code.Text) + '''');
      Open;
      if FieldByName('AA').AsInteger > 1 then
      begin
        ADOQueryCmd.Connection.RollbackTrans;
        Result := False;
        Application.MessageBox('编号重复！', '提示', 0);
        Exit;
      end;
    end;
    //////////////////////////            保存经丝配比表              //////////////////////////
    with CDS_3 do
    begin
      First;
      while not Eof do
      begin
        if Trim(CDS_3.fieldbyname('MFId').AsString) = '' then
        begin
          if GetLSNo(ADOQueryTemp, maxpbno, 'MF', 'BS_Cloth_MF', 4, 1) = False then
          begin
            ADOQueryCmd.Connection.RollbackTrans;
            Application.MessageBox('取子流水号失败！', '提示', 0);
            Exit;
          end;
        end
        else
        begin
          maxpbno := Trim(CDS_3.fieldbyname('MFId').AsString);
        end;
        with ADOQueryCmd do
        begin
          Close;
          SQL.Clear;
          sql.Add('select * from BS_Cloth_MF where ');
          sql.Add('  MFID=''' + Trim(maxpbno) + '''');
          Open;
        end;
        with ADOQueryCmd do
        begin
          if Trim(CDS_3.fieldbyname('MFId').AsString) = '' then
          begin
            Append;
//            FieldByName('Filler').Value := Trim(DName);
//            FieldByName('FillTime').Value := SGetServerDateTime(ADOQueryTemp);
          end
          else
          begin
            Edit;
//            FieldByName('Editer').Value := Trim(DName);
//            FieldByName('EditTime').Value := SGetServerDateTime(ADOQueryTemp);
          end;
//          FieldByName('YRType').Value := '经丝';
          FieldByName('BCIID').Value := Trim(maxId);
          FieldByName('MFId').Value := Trim(maxpbno);
          FieldByName('C_CODE').Value := Trim(C_CODE.Text);
          FieldByName('C_NAME').Value := Trim(C_NAME.Text);
          RTSetSaveDataCDS(ADOQueryCmd, Tv3, CDS_3, 'BS_Cloth_Yarn', 0);
          Post;
        end;
        CDS_3.Edit;
        CDS_3.FieldByName('BCIID').Value := Trim(maxId);
        CDS_3.FieldByName('MFId').Value := Trim(maxpbno);

        Next;
      end;
    end;
//////////////////////////            保存经丝配比表              //////////////////////////
          //////////////////////////
    ADOQueryCmd.Connection.CommitTrans;
    FBCIID := maxId;
    Result := True;
  except
    Result := False;
    ADOQueryCmd.Connection.RollbackTrans;
    Application.MessageBox('保存失败!', '提示', 0);
  end;
end;

procedure TfrmTatClothInfoInput.CYJGGYBtnDnClick(Sender: TObject);
begin
  TBtnEditC(Sender).Text := '';
end;

procedure TfrmTatClothInfoInput.ToolButton10Click(Sender: TObject);
begin
  with CDS_3 do
  begin
    Append;

    Post;
  end;
end;

procedure TfrmTatClothInfoInput.ToolButton11Click(Sender: TObject);
begin
  if CDS_3.IsEmpty then
    Exit;
  if Trim(CDS_3.fieldbyname('mfid').AsString) <> '' then
  begin
    if Application.MessageBox('确定要删除数据吗？', '提示', 32 + 4) <> IDYES then
      Exit;
    with ADOQueryCmd do
    begin
      Close;
      sql.Clear;
      sql.Add('delete BS_Cloth_mf where MFId=''' + Trim(CDS_3.fieldbyname('MFId').AsString) + '''');
      ExecSQL;
    end;
  end;
  CDS_3.Delete;
end;

procedure TfrmTatClothInfoInput.ToolButton1Click(Sender: TObject);
var
  MC_Code: string;
begin
  C_Name.SetFocus;
  if C_Name.Text = '' then
  begin
    Application.MessageBox('产品名称不能为空！', '提示', 0);
    Exit;
  end;
  if trim(C_Code.Text) = '' then
  begin
    with ADOQueryTemp do
    begin
      Close;
      sql.Clear;
//          sql.Add(' exec P_BS_Com_Get_No @Str=''K'' ');
      sql.Add(' exec P_BS_clothinfo_Get_No @Str=''C''');
      Open;
    end;
//    if GetLSNo(ADOQueryCmd, MC_Code, 'C', 'BS_Cloth_Info', 4, 0) = False then
//    begin
//      Application.MessageBox('取最成品编号失败!', '提示', 0);
//      Exit;
//    end;
    C_Code.Text := trim(ADOQueryTemp.FieldByName('NewCoCode').asstring);

  end;
  CALCYarnQty();
  if SaveData() then
  begin
    Application.MessageBox('保存成功！', '提示', 0);
//    ModalResult := 1;
  end;
end;

procedure TfrmTatClothInfoInput.ToolButton2Click(Sender: TObject);
begin
  try
    frmYarnInfoSel := TfrmYarnInfoSel.Create(Application);
    with frmYarnInfoSel do
    begin
      if ShowModal = 1 then
      begin
        with self.CDS_1 do
        begin
          Append;
          FieldByName('Brand').Value := frmYarnInfoSel.CDS_1.fieldbyname('Brand').Value;
          FieldByName('Y_Code').Value := frmYarnInfoSel.CDS_1.fieldbyname('Y_Code').Value;
          FieldByName('Y_Name').Value := frmYarnInfoSel.CDS_1.fieldbyname('Y_Name').Value;
          FieldByName('Y_Spec').Value := frmYarnInfoSel.CDS_1.fieldbyname('Y_Spec').Value;
          FieldByName('Y_Color').Value := frmYarnInfoSel.CDS_1.fieldbyname('Y_Color').Value;
          FieldByName('Denier').Value := frmYarnInfoSel.CDS_1.fieldbyname('Denier').Value;
          FieldByName('Y_Ratio').Value := 0;
          Post;
        end;

      end;
    end;
  finally
    frmYarnInfoSel.Free;
  end;
end;

procedure TfrmTatClothInfoInput.ToolButton3Click(Sender: TObject);
begin
  if CDS_1.IsEmpty then
    Exit;
  if Trim(CDS_1.fieldbyname('YRId').AsString) <> '' then
  begin
    if Application.MessageBox('确定要删除数据吗？', '提示', 32 + 4) <> IDYES then
      Exit;
    with ADOQueryCmd do
    begin
      Close;
      sql.Clear;
      sql.Add('delete BS_Cloth_Yarn where YRId=''' + Trim(CDS_1.fieldbyname('YRId').AsString) + '''');
      ExecSQL;
    end;
  end;
  CDS_1.Delete;
end;

procedure TfrmTatClothInfoInput.ToolButton4Click(Sender: TObject);
begin
  try
    frmYarnInfoSel := TfrmYarnInfoSel.Create(Application);
    with frmYarnInfoSel do
    begin
      if ShowModal = 1 then
      begin
        with self.CDS_2 do
        begin
          Append;
          FieldByName('Brand').Value := frmYarnInfoSel.CDS_1.fieldbyname('Brand').Value;
          FieldByName('Y_Code').Value := frmYarnInfoSel.CDS_1.fieldbyname('Y_Code').Value;
          FieldByName('Y_Name').Value := frmYarnInfoSel.CDS_1.fieldbyname('Y_Name').Value;
          FieldByName('Y_Spec').Value := frmYarnInfoSel.CDS_1.fieldbyname('Y_Spec').Value;
          FieldByName('Y_Color').Value := frmYarnInfoSel.CDS_1.fieldbyname('Y_Color').Value;
          FieldByName('Denier').Value := frmYarnInfoSel.CDS_1.fieldbyname('Denier').Value;
          FieldByName('Y_Ratio').Value := 0;
          Post;
        end;
      end;
    end;
  finally
    frmYarnInfoSel.Free;
  end;
end;

procedure TfrmTatClothInfoInput.ToolButton5Click(Sender: TObject);
begin
  C_Name.SetFocus;
  CALCYarnQty();
end;

procedure TfrmTatClothInfoInput.CYColorKeyPress(Sender: TObject; var Key: Char);
begin
  if Key = #13 then
  begin
    Key := #0;
    SelectNext(ActiveControl as TWinControl, True, True);
  end;
end;

procedure TfrmTatClothInfoInput.CYKZExit(Sender: TObject);
begin
//  if pos('G/M2', trim(CYKZ.Text)) = 0 then
//  begin
//    if pos('G/M', trim(CYKZ.Text)) = 0 then
//    begin
//      CYKZ.Text := trim(CYKZ.Text) + 'G/M2';
//    end;
//  end;
end;

procedure TfrmTatClothInfoInput.C_WidthBtnDnClick(Sender: TObject);
begin
  TBtnEditC(Sender).Text := '';
  TBtnEditC(Sender).TxtCode := '';
end;

procedure TfrmTatClothInfoInput.C_WidthBtnUpClick(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);
      flagname := Copy(fsj, FWZ + 1, Length(fsj) - FWZ);
      if ShowModal = 1 then
      begin
        TEdit(Sender).Text := Trim(ClientDataSet1.fieldbyname('ZDYName').AsString);
      end;
    end;
  finally
    frmZDYHelp.Free;
  end;
end;

procedure TfrmTatClothInfoInput.CYMFExit(Sender: TObject);
begin
//  if pos('"', trim(CYMF.Text)) = 0 then
//  begin
//    if pos('CM', trim(CYMF.Text)) = 0 then
//      CYMF.Text := trim(CYMF.Text) + 'CM';
//  end;

end;

procedure TfrmTatClothInfoInput.FormClose(Sender: TObject; var Action: TCloseAction);
var
  i, j: integer;
begin
  inherited;
  j := length(Mach);
  if j > 0 then
  begin
    for i := 0 to j - 1 do
    begin
      Mach[i].free;
    end;
  end;
  SetLength(Mach, 0);
  Action := cafree;
end;

procedure TfrmTatClothInfoInput.FormCreate(Sender: TObject);
begin

//  LaYangDate.DateTime := SGetServerDateTime(ADOQueryTemp);
end;

procedure TfrmTatClothInfoInput.ToolButton6Click(Sender: TObject);
begin
  if trim(C_Code.Text) = '' then
    Exit;
  try
    frmAttachmentUpload := TfrmAttachmentUpload.Create(Application);
    with frmAttachmentUpload do
    begin
      FEditAuthority := True;
      fkeyNO := trim(C_Code.Text);
      fType := '成品档案';
      if ShowModal = 1 then
      begin

      end;
    end;
  finally
    frmAttachmentUpload.Free;
  end;
end;

procedure TfrmTatClothInfoInput.ToolButton7Click(Sender: TObject);
begin
  if CDS_2.IsEmpty then
    Exit;
  if Trim(CDS_2.fieldbyname('YRId').AsString) <> '' then
  begin
    if Application.MessageBox('确定要删除数据吗？', '提示', 32 + 4) <> IDYES then
      Exit;
    with ADOQueryCmd do
    begin
      Close;
      sql.Clear;
      sql.Add('delete BS_Cloth_Yarn where YRId=''' + Trim(CDS_2.fieldbyname('YRId').AsString) + '''');
      ExecSQL;
    end;
  end;
  CDS_2.Delete;
end;

procedure TfrmTatClothInfoInput.ToolButton8Click(Sender: TObject);
begin
  C_Name.SetFocus;
  CALCYarnQty();
end;

procedure TfrmTatClothInfoInput.ToolButton9Click(Sender: TObject);
begin
  if FBCIID = '' then
  begin
    Application.MessageBox('请先保存!', '提示', 0);
    Exit;
  end;
  try
    frmCloInfoFileUp := TfrmCloInfoFileUp.Create(Application);
    with frmCloInfoFileUp do
    begin
      Code.Text := Trim(C_Code.Text);
      FBCIID := self.FBCIID;
      if ShowModal = 1 then
      begin
        Self.InitGrid();
//        Self.CDS_1.Locate('BCIID', BCIID, []);
      end;
    end;
  finally
    frmCloInfoFileUp.Free;
  end;
  InitImage();
end;

end.

