unit U_MLLR;

interface

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

type
  TfrmMLLR = class(TForm)
    ToolBar1: TToolBar;
    TBSave: TToolButton;
    TBClose: TToolButton;
    Panel1: TPanel;
    cxGrid1: TcxGrid;
    Tv1: TcxGridDBTableView;
    v1CodeName: TcxGridDBColumn;
    v1Qty: TcxGridDBColumn;
    v1Note: TcxGridDBColumn;
    cxGrid1Level1: TcxGridLevel;
    ADOQueryCmd: TADOQuery;
    ADOQueryTmp: TADOQuery;
    DataSource1: TDataSource;
    CDS_Main: TClientDataSet;
    ToolBar2: TToolBar;
    ToolButton1: TToolButton;
    ToolButton2: TToolButton;
    cxGridPopupMenu1: TcxGridPopupMenu;
    Label6: TLabel;
    Label9: TLabel;
    v1MF: TcxGridDBColumn;
    v1KZ: TcxGridDBColumn;
    v1Column2: TcxGridDBColumn;
    Tv1Column1: TcxGridDBColumn;
    KHName: TBtnEditA;
    ADOCmd: TADOQuery;
    ADOTemp: TADOQuery;
    ADOQuery1: TADOQuery;
    Tv1Column2: TcxGridDBColumn;
    Label4: TLabel;
    ConNo: TBtnEditA;
    Label2: TLabel;
    KHConNO: TBtnEditA;
    Label3: TLabel;
    ConMainID: TBtnEditA;
    Label5: TLabel;
    KHNO: TBtnEditA;
    Tv1Column4: TcxGridDBColumn;
    ToolButton3: TToolButton;
    Label1: TLabel;
    Label7: TLabel;
    GYNoteZ: TMemo;
    Note: TMemo;
    Label11: TLabel;
    JHDate: TDateTimePicker;
    Label8: TLabel;
    CRTime: TDateTimePicker;
    procedure FormDestroy(Sender: TObject);
    procedure FormClose(Sender: TObject; var Action: TCloseAction);
    procedure FormShow(Sender: TObject);
    procedure TBSaveClick(Sender: TObject);
    procedure ToolButton1Click(Sender: TObject);
    procedure ToolButton2Click(Sender: TObject);
    procedure TBCloseClick(Sender: TObject);
    procedure v1P_ColorPropertiesButtonClick(Sender: TObject; AButtonIndex: Integer);
    procedure v1QtyPropertiesEditValueChanged(Sender: TObject);
    procedure fromFactoryNameBtnClick(Sender: TObject);
    procedure kuweiBtnClick(Sender: TObject);
    procedure v1NotePropertiesButtonClick(Sender: TObject; AButtonIndex: Integer);
    procedure v1PRTSpecPropertiesButtonClick(Sender: TObject; AButtonIndex: Integer);
    procedure FactoryNameBtnClick(Sender: TObject);
    procedure v1QtyUnitPropertiesButtonClick(Sender: TObject; AButtonIndex: Integer);
    procedure ToolButton3Click(Sender: TObject);
    procedure v1CodeNamePropertiesButtonClick(Sender: TObject; AButtonIndex: Integer);
    procedure RangchangBtnClick(Sender: TObject);
    procedure Tv1Column5PropertiesButtonClick(Sender: TObject; AButtonIndex: Integer);
    procedure ConNoBtnClick(Sender: TObject);
    procedure Tv1Column3PropertiesButtonClick(Sender: TObject; AButtonIndex: Integer);
    procedure GYNoteZBtnClick(Sender: TObject);
    procedure NoteBtnClick(Sender: TObject);
    procedure v1Column2PropertiesButtonClick(Sender: TObject; AButtonIndex: Integer);
  private
    procedure InitGrid();
    procedure SetFrom();
    function savedate(): Boolean;
    function CheckData(): Boolean;
    { Private declarations }
  public
    fkeyNO: string;
    FType, PState: integer;
    fCRType, FZZType: string;
    FMainId, FFMainId: string;
    { Public declarations }
  end;

var
  frmMLLR: TfrmMLLR;

implementation

uses
  U_DataLink, U_Fun10, U_ZDYHelp, U_GYSList, U_RTFun, U_BPZDY_LRM,
  U_ProductOrderNewList_New2, U_MLConTract_NXSel;
{$R *.dfm}

function TfrmMLLR.CheckData(): Boolean;
begin
  try

    if Trim(ConNo.Text) = '' then
      raise Exception.Create('系统合同号不能为空！');
    if CDS_Main.IsEmpty then
      raise Exception.Create('明细不能为空！');

    if CDS_Main.Locate('CPName', null, []) then
      raise Exception.Create('产品名称不能为空！');
    if CDS_Main.Locate('CPName', '', []) then
      raise Exception.Create('产品名称不能为空！');

    if CDS_Main.Locate('CPCode', null, []) then
      raise Exception.Create('产品编号不能为空！');
    if CDS_Main.Locate('CPCode', '', []) then
      raise Exception.Create('产品编号不能为空！');

    Result := True;
  except
    Result := false;
    application.MessageBox(PChar(Exception(ExceptObject).Message), '提示信息', 0);
  end;
end;

procedure TfrmMLLR.SetFrom();
begin

end;

function TfrmMLLR.savedate(): Boolean;
var
  maxno, maxSubNo, maxmnno, FSSId: string;
  fconNO, fmxType: string;
begin
  try
    ADOCmd.Connection.BeginTrans;
    ///保存主表
    if Trim(FMainId) = '' then
    begin
      if GetLSNoHZ(ADOCmd, maxno, 'MC', 'MLSC', 3, 1, 3) = 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 MLSC 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);
      RTSetsavedata(ADOCmd, 'MLSC', Panel1, 2);

      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);
    ///保存子表
    CDS_Main.DisableControls;
    with CDS_Main do
    begin
      First;
      while not Eof do
      begin
        if Trim(CDS_Main.fieldbyname('SubID').AsString) = '' then
        begin
          if GetLSNo(ADOCmd, maxSubNo, 'MCS', 'MLSC_Sub', 4, 1) = False then
          begin
            CDS_Main.EnableControls;
            ADOCmd.Connection.RollbackTrans;
            Application.MessageBox('取子流水号失败！', '提示', 0);
            Exit;
          end;
        end
        else
        begin
          maxSubNo := Trim(CDS_Main.fieldbyname('SubID').AsString);
        end;
        with ADOCmd do
        begin
          Close;
          SQL.Clear;
          sql.Add('select * from MLSC_Sub ');
          sql.Add(' where SubID=''' + Trim(maxSubNo) + '''');
          Open;
        end;
        if ADOCmd.IsEmpty then
        begin
          FSSId := '';
        end
        else
        begin
          FSSId := Trim(maxSubNo);
        end;
        with ADOCmd do
        begin
          if Trim(FSSId) = '' then
          begin
            Append;
            FieldByName('Filler').Value := Trim(DName);
          end
          else
          begin
            Edit;
            FieldByName('Editer').Value := Trim(DName);
            FieldByName('EditTime').Value := SGetServerDateTime(ADOTemp);
          end;
          FieldByName('MainID').Value := Trim(FMainId);                          
          FieldByName('SubID').Value := Trim(maxSubNo);
          FieldByName('ConSubID').Value := Trim(CDS_Main.FieldByName('ConSubID').AsString);
          RTSetSaveDataCDS(ADOCmd, Tv1, CDS_Main, 'CG_Sub', 0);
          Post;
        end;
        CDS_Main.Edit;
        CDS_Main.FieldByName('SubID').Value := Trim(maxSubNo);
        Next;
      end;
    end;
    CDS_Main.EnableControls;
    ADOCmd.Connection.CommitTrans;
    Result := True;
  except
    ADOCmd.Connection.RollbackTrans;
    Application.MessageBox('保存失败！', '提示', 0);
    Result := False;
  end;
end;

procedure TfrmMLLR.InitGrid();
begin

  with ADOQuery1 do
  begin
    Close;
    SQL.Clear;
    if PState = 1 then
    begin
      sql.Add(' select A.*  ');
      sql.Add(' from MLSC_Sub A');
      sql.Add('where MainID=''' + Trim(FMainId) + '''');
    end;
    if PState = 0 then
    begin
      sql.Add(' select A.*  ');
      sql.Add(' from MLSC_Sub A');
      sql.Add(' where 1<>1');

      CRTIme.DateTime := SGetServerDateTime(ADOTemp);
      JHDate.Date := CRTIme.Date;
    end;
    Open;
  end;
  SCreateCDS20(ADOQuery1, CDS_Main);
  SInitCDSData20(ADOQuery1, CDS_Main);

  with ADOQuery1 do
  begin
    Close;
    sql.Clear;
    sql.Add('select A.* ');
    sql.Add(' from MLSC A');
    sql.Add(' where MainID=''' + Trim(FMainId) + ''' ');
    Open;
  end;
  SCSHDataNew(ADOQuery1, Panel1, 2);

end;

procedure TfrmMLLR.FormDestroy(Sender: TObject);
begin
  frmMLLR := nil;
end;

procedure TfrmMLLR.FormClose(Sender: TObject; var Action: TCloseAction);
begin
  writeCxGrid(self.Caption + tv1.Name + '11', Tv1, '采购棉');
  Action := cahide;
end;

procedure TfrmMLLR.FormShow(Sender: TObject);
begin
  readCxGrid(self.Caption + tv1.Name + '11', Tv1, '采购棉');
  InitGrid();
end;

procedure TfrmMLLR.TBSaveClick(Sender: TObject);
begin

  ConNo.SetFocus;
  if CheckData() = false then
    exit;

  if savedate() then
  begin
    application.MessageBox('数据保存成功！', '提示信息');
    ModalResult := 1;
  end
  else
  begin
    application.MessageBox('数据保存失败！', '提示信息', MB_ICONERROR);
  end;
end;

procedure TfrmMLLR.ToolButton1Click(Sender: TObject);
begin
  with CDS_Main do
  begin
    append;
    post;
  end;

//  frmBPZDY_LRM := TfrmBPZDY_LRM.create(self);
//  with frmBPZDY_LRM do
//  begin
//    flag := 'MName';
//    flagName := '棉';
//    ViewFlag := true;
//    Panel4.Align := alClient;
//    ToolBar3.Visible := false;
//    Button1.Visible := False;
//    if ShowModal = 1 then
//    begin
//      Self.CDS_Main.append;
//      Self.CDS_Main.FieldByName('CPName').Value := Trim(ClientDataSet1.fieldbyname('BPName').AsString);
//      Self.CDS_Main.FieldByName('MF').Value := Trim(ClientDataSet1.fieldbyname('BPMF').AsString);
//      Self.CDS_Main.FieldByName('KZ').Value := Trim(ClientDataSet1.fieldbyname('BPKZ').AsString);
//      Self.CDS_Main.FieldByName('FLNote').Value := Trim(ClientDataSet1.fieldbyname('BPNote').AsString);
//      Self.CDS_Main.FieldByName('PMHH').Value := Trim(ClientDataSet1.fieldbyname('PMHH').AsString);
//      Self.CDS_Main.FieldbyName('ps').Value := 0;
//      Self.CDS_Main.FieldbyName('Qty').Value := 0;
//    end;
//    free;
//  end;

end;

procedure TfrmMLLR.ToolButton2Click(Sender: TObject);
begin
  if CDS_Main.IsEmpty then
    exit;
  if Trim(CDS_Main.FieldByName('SubID').AsString) = '' then
  begin
    CDS_Main.Delete;
  end
  else
  begin
    ADOQueryCmd.Connection.BeginTrans;
    with ADOQueryCmd do
    begin
      Close;
      SQL.Clear;
      sql.Add('update MLSC_Sub set MainID=MainID+''删'' where SubID=' + quotedstr(Trim(CDS_Main.FieldByName('SubID').AsString)));
      ExecSQL;
    end;
    ADOQueryCmd.Connection.CommitTrans;
    CDS_Main.Delete;
  end;
end;

procedure TfrmMLLR.TBCloseClick(Sender: TObject);
begin
  close;
end;

procedure TfrmMLLR.v1P_ColorPropertiesButtonClick(Sender: TObject; AButtonIndex: Integer);
begin
  try
    frmZDYHelp := TfrmZDYHelp.Create(Application);
    with frmZDYHelp do
    begin
      flag := 'OrdColor';
      flagname := '颜色';
      V1Name.Caption := '中文名称';
      V1Note.Caption := '英文名称';
      MainType := Trim(DName);
      fnote := True;
      if ShowModal = 1 then
      begin
        Self.CDS_Main.Edit;
        Self.CDS_Main.FieldByName('P_Color').Value := Trim(ClientDataSet1.fieldbyname('ZDYName').AsString);
        Self.CDS_Main.Post;
      end;
    end;
  finally
    frmZDYHelp.Free;
  end;
  self.tv1.Controller.EditingController.ShowEdit();
end;

procedure TfrmMLLR.v1QtyPropertiesEditValueChanged(Sender: TObject);
var
  mvalue, FFieldName: string;
begin
  mvalue := TcxTextEdit(Sender).EditingText;
  if Trim(mvalue) = '' then
  begin
    mvalue := '0';
  end;
  FFieldName := Trim(Tv1.Controller.FocusedColumn.DataBinding.FilterFieldName);
//  with CDS_Main do
//  begin
//    Edit;
//    FieldByName(FFieldName).Value := Trim(mvalue);
//    FieldbyName('PS').Value := format('%.0f', [FieldByName('Qty').AsFloat / FieldByName('PiChang').AsFloat]);
//    Post;
//  end;
//  tv1.Controller.EditingController.ShowEdit();
end;

procedure TfrmMLLR.fromFactoryNameBtnClick(Sender: TObject);
begin
//  if Trim(CRType.Text) = '客供入库' then
//  begin
//    try
//      frmZdyAttachment := TfrmZdyAttachment.Create(Application);
//      with frmZdyAttachment do
//      begin
//        if ShowModal = 1 then
//        begin
//          fromFactoryName.Text := Trim(CDS_HZ.fieldbyname('CoName').AsString);
//        end;
//      end;
//    finally
//      frmZdyAttachment.Free;
//    end;
//  end
//  else
//  begin
//    try
//      frmZdyAttachGYS := TfrmZdyAttachGYS.Create(Application);
//      with frmZdyAttachGYS do
//      begin
//        if ShowModal = 1 then
//        begin
//          fromFactoryName.Text := Trim(CDS_HZ.fieldbyname('CoName').AsString);
//        end;
//      end;
//    finally
//      frmZdyAttachGYS.Free;
//    end;
//  end;

  try
    frmZDYHelp := TfrmZDYHelp.Create(Application);
    with frmZDYHelp do
    begin
      flag := 'LaiZiDW';
      flagname := '来自单位';
      if ShowModal = 1 then
      begin
        TEdit(Sender).Text := Trim(ClientDataSet1.fieldbyname('ZDYName').AsString);
      end;
    end;
  finally
    frmZDYHelp.Free;
  end;

end;

procedure TfrmMLLR.kuweiBtnClick(Sender: TObject);
begin
  try
    frmZDYHelp := TfrmZDYHelp.Create(Application);
    with frmZDYHelp do
    begin
      flag := 'kuwei';
      flagname := '库位';
      if ShowModal = 1 then
      begin
        TEdit(Sender).Text := Trim(ClientDataSet1.fieldbyname('ZDYName').AsString);
      end;
    end;
  finally
    frmZDYHelp.Free;
  end;
end;

procedure TfrmMLLR.v1NotePropertiesButtonClick(Sender: TObject; AButtonIndex: Integer);
begin
  try
    frmZDYHelp := TfrmZDYHelp.Create(Application);
    with frmZDYHelp do
    begin
      flag := 'MLSCNote';
      flagname := '备注';

      if ShowModal = 1 then
      begin
        Self.CDS_Main.Edit;
        Self.CDS_Main.FieldByName('MXNote').Value := Trim(ClientDataSet1.fieldbyname('ZDYName').AsString);
        Self.CDS_Main.Post;
      end;
    end;
  finally
    frmZDYHelp.Free;
  end;
  self.tv1.Controller.EditingController.ShowEdit();
end;

procedure TfrmMLLR.v1PRTSpecPropertiesButtonClick(Sender: TObject; AButtonIndex: Integer);
begin
  try
    frmZDYHelp := TfrmZDYHelp.Create(Application);
    with frmZDYHelp do
    begin
      flag := 'flSPEC';
      flagname := '辅料规格';
      if ShowModal = 1 then
      begin
        Self.CDS_Main.Edit;
        Self.CDS_Main.FieldByName('SPEC').Value := Trim(ClientDataSet1.fieldbyname('ZDYName').AsString);

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

procedure TfrmMLLR.FactoryNameBtnClick(Sender: TObject);
begin
//  try
//    frmZdyAttachGYS := TfrmZdyAttachGYS.Create(Application);
//    with frmZdyAttachGYS do
//    begin
//      if ShowModal = 1 then
//      begin
//        FactoryName.Text := Trim(CDS_HZ.fieldbyname('CoName').AsString);
//      end;
//    end;
//  finally
//    frmZdyAttachGYS.Free;
//  end;
  try
    frmZDYHelp := TfrmZDYHelp.Create(Application);
    with frmZDYHelp do
    begin
      flag := 'CunFangCangKu';
      flagname := '存放仓库';
      if ShowModal = 1 then
      begin
        TEdit(Sender).Text := Trim(ClientDataSet1.fieldbyname('ZDYName').AsString);
      end;
    end;
  finally
    frmZDYHelp.Free;
  end;
end;

procedure TfrmMLLR.v1QtyUnitPropertiesButtonClick(Sender: TObject; AButtonIndex: Integer);
begin
  try
    frmZDYHelp := TfrmZDYHelp.Create(Application);
    with frmZDYHelp do
    begin
      flag := 'FLqtyUnit';
      flagname := '单位';
      if ShowModal = 1 then
      begin
        Self.CDS_Main.Edit;
        Self.CDS_Main.FieldByName('qtyUnit').Value := Trim(ClientDataSet1.fieldbyname('ZDYName').AsString);

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

procedure TfrmMLLR.ToolButton3Click(Sender: TObject);
begin

  if CDS_Main.IsEmpty then
    Exit;
  OneKeyPost(Tv1, CDS_Main);

end;

procedure TfrmMLLR.v1CodeNamePropertiesButtonClick(Sender: TObject; AButtonIndex: Integer);
begin
  frmBPZDY_LRM := TfrmBPZDY_LRM.create(self);
  with frmBPZDY_LRM do
  begin
    flag := 'MName';
    flagName := '棉';
    ViewFlag := true;
    Panel4.Align := alClient;
    ToolBar3.Visible := false;
    Button1.Visible := False;
    if ShowModal = 1 then
    begin
      Self.CDS_Main.Edit;
      Self.CDS_Main.FieldByName('CPName').Value := Trim(ClientDataSet1.fieldbyname('BPName').AsString);
      Self.CDS_Main.FieldByName('MF').Value := Trim(ClientDataSet1.fieldbyname('BPMF').AsString);
      Self.CDS_Main.FieldByName('KZ').Value := Trim(ClientDataSet1.fieldbyname('BPKZ').AsString);
      Self.CDS_Main.FieldByName('FLNote').Value := Trim(ClientDataSet1.fieldbyname('BPNote').AsString);
      Self.CDS_Main.FieldByName('PMHH').Value := Trim(ClientDataSet1.fieldbyname('PMHH').AsString);
    end;
    free;
  end;

end;

procedure TfrmMLLR.RangchangBtnClick(Sender: TObject);
begin
  try
    frmZDYHelp := TfrmZDYHelp.Create(Application);
    with frmZDYHelp do
    begin
      flag := 'Rangchang';
      flagname := '染厂';
      if ShowModal = 1 then
      begin
        TEdit(Sender).Text := Trim(ClientDataSet1.fieldbyname('ZDYName').AsString);
      end;
    end;
  finally
    frmZDYHelp.Free;
  end;
end;

procedure TfrmMLLR.Tv1Column5PropertiesButtonClick(Sender: TObject; AButtonIndex: Integer);
begin
  try
    frmProductOrderNewList_New2 := TfrmProductOrderNewList_New2.Create(Application);
    with frmProductOrderNewList_New2 do
    begin
      if ShowModal = 1 then
      begin
        Self.CDS_Main.Edit;
        Self.CDS_Main.FieldByName('OrderNo').Value := Trim(Order_Main.fieldbyname('MLOrderNo').AsString);
        Self.CDS_Main.FieldByName('ConNo').Value := Trim(Order_Main.fieldbyname('MLConNo').AsString);
        Self.CDS_Main.FieldByName('MainID').Value := Trim(Order_Main.fieldbyname('NewMLID').AsString);
        Self.CDS_Main.FieldByName('SubID').Value := Trim(Order_Main.fieldbyname('NewSubid').AsString);
        Self.CDS_Main.FieldByName('KHNO').Value := Trim(Order_Main.fieldbyname('KHNO').AsString);
      end;
    end;
  finally
    frmProductOrderNewList_New2.Free;
  end;
end;

procedure TfrmMLLR.ConNoBtnClick(Sender: TObject);
begin
  try
    frmMLConTract_NXSel := TfrmMLConTract_NXSel.Create(Application);
    with frmMLConTract_NXSel do
    begin
      if ShowModal = 1 then
      begin
        Self.ConMainID.text := Trim(Order_Main.fieldbyname('MLConID').AsString);
        Self.ConNO.text := Trim(Order_Main.fieldbyname('ConNO').AsString);
        Self.KHConNO.text := Trim(Order_Main.fieldbyname('KHConNO').AsString);
        Self.KHName.text := Trim(Order_Main.fieldbyname('KHNameJC').AsString);
        Self.KHNO.text := Trim(Order_Main.fieldbyname('KHNO').AsString);

        with frmMLConTract_NXSel.Order_Sub do
        begin
          First;
          while not Eof do
          begin
            if Fieldbyname('ssel').AsBoolean then
            begin
              with Self.CDS_Main do
              begin
                Append;
                FieldByName('ConSubID').Value := Trim(frmMLConTract_NXSel.Order_Sub.fieldbyname('CSID').AsString);
                FieldByName('CPCode').Value := Trim(frmMLConTract_NXSel.Order_Sub.fieldbyname('ConCode').AsString);
                FieldByName('CPName').Value := Trim(frmMLConTract_NXSel.Order_Sub.fieldbyname('ConCodeName').AsString);
                FieldByName('CPColor').Value := Trim(frmMLConTract_NXSel.Order_Sub.fieldbyname('ConColor').AsString);
                FieldByName('QtyUnit').Value := Trim(frmMLConTract_NXSel.Order_Sub.fieldbyname('QtyUnit').AsString);
                FieldByName('SeHao').Value := Trim(frmMLConTract_NXSel.Order_Sub.fieldbyname('ConColNo').AsString);
                Post;
              end;
            end;
            Next;
          end;
        end;
      end;
    end;
  finally
    frmMLConTract_NXSel.Free;
  end;
end;

procedure TfrmMLLR.Tv1Column3PropertiesButtonClick(Sender: TObject; AButtonIndex: Integer);
begin
  try
    frmZDYHelp := TfrmZDYHelp.Create(Application);
    with frmZDYHelp do
    begin
      flag := 'MLSCGYNote';
      flagname := '工艺要求';

      if ShowModal = 1 then
      begin
        Self.CDS_Main.Edit;
        Self.CDS_Main.FieldByName('GYNote').Value := Trim(ClientDataSet1.fieldbyname('ZDYName').AsString);
        Self.CDS_Main.Post;
      end;
    end;
  finally
    frmZDYHelp.Free;
  end;
  self.tv1.Controller.EditingController.ShowEdit();
end;

procedure TfrmMLLR.GYNoteZBtnClick(Sender: TObject);
begin
  try
    frmZDYHelp := TfrmZDYHelp.Create(Application);
    with frmZDYHelp do
    begin
      flag := 'GYNoteZ';
      flagname := '工艺备注';
      if ShowModal = 1 then
      begin
        GYNoteZ.text := Trim(ClientDataSet1.fieldbyname('ZDYName').AsString);
      end;
    end;
  finally
    frmZDYHelp.Free;
  end;
end;

procedure TfrmMLLR.NoteBtnClick(Sender: TObject);
begin
  try
    frmZDYHelp := TfrmZDYHelp.Create(Application);
    with frmZDYHelp do
    begin
      flag := 'MLSCNoteZ';
      flagname := '备注';
      if ShowModal = 1 then
      begin
        Note.text := Trim(ClientDataSet1.fieldbyname('ZDYName').AsString);
      end;
    end;
  finally
    frmZDYHelp.Free;
  end;
end;

procedure TfrmMLLR.v1Column2PropertiesButtonClick(Sender: TObject; AButtonIndex: Integer);
begin
  try
    frmZDYHelp := TfrmZDYHelp.Create(Application);
    with frmZDYHelp do
    begin
      flag := 'MLSCUnit';
      flagname := '数量单位';
      if ShowModal = 1 then
      begin
        Self.CDS_Main.Edit;
        Self.CDS_Main.FieldByName('QtyUnit').Value := Trim(ClientDataSet1.fieldbyname('ZDYName').AsString);
        Self.CDS_Main.Post;
      end;
    end;
  finally
    frmZDYHelp.Free;
  end;
end;

end.

