unit U_PLRW;

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, cxCalendar, StrUtils,
  cxDropDownEdit, jpeg, IdBaseComponent, IdComponent, IdTCPConnection,
  IdTCPClient, IdFTP, cxPC, cxGridCustomPopupMenu, cxGridPopupMenu, Menus,
  ExtDlgs, cxLookAndFeels, cxLookAndFeelPainters, cxNavigator, 
   dxDateRanges, dxBarBuiltInMenu, dxScrollbarAnnotations;

type
  TfrmPLRW = class(TForm)
    ToolBar1: TToolBar;
    TBClose: TToolButton;
    ADOTemp: TADOQuery;
    ADOCmd: TADOQuery;
    TBSave: TToolButton;
    DataSource1: TDataSource;
    Order_Sub: TClientDataSet;
    ToolButton1: TToolButton;
    ToolButton2: TToolButton;
    cxGrid1: TcxGrid;
    Tv1: TcxGridDBTableView;
    cxGrid1Level1: TcxGridLevel;
    cxStyleRepository1: TcxStyleRepository;
    cxStyle1: TcxStyle;
    cxGridPopupMenu1: TcxGridPopupMenu;
    Tv1Column1: TcxGridDBColumn;
    Tv1Column2: TcxGridDBColumn;
    Tv1Column3: TcxGridDBColumn;
    Tv1Column4: TcxGridDBColumn;
    Tv1Column5: TcxGridDBColumn;
    Tv1Column6: TcxGridDBColumn;
    Tv1Column7: TcxGridDBColumn;
    Tv1Column8: TcxGridDBColumn;
    ToolButton3: TToolButton;
    Tv1Column9: TcxGridDBColumn;
    cxGrid2: TcxGrid;
    TV2: TcxGridDBTableView;
    cxGridDBColumn5: TcxGridDBColumn;
    cxGridDBColumn6: TcxGridDBColumn;
    TV2Column1: TcxGridDBColumn;
    TV2Column2: TcxGridDBColumn;
    TV2Column3: TcxGridDBColumn;
    TV2Column4: TcxGridDBColumn;
    cxGridLevel1: TcxGridLevel;
    DS_2: TDataSource;
    CDS_2: TClientDataSet;
    cxGridPopupMenu2: TcxGridPopupMenu;
    ToolButton4: TToolButton;
    procedure TBCloseClick(Sender: TObject);
    procedure FormShow(Sender: TObject);
    procedure TBSaveClick(Sender: TObject);
    procedure ToolButton1Click(Sender: TObject);
    procedure ToolButton2Click(Sender: TObject);
    procedure v1SYRNamePropertiesButtonClick(Sender: TObject; AButtonIndex: Integer);
    procedure v1Column2PropertiesButtonClick(Sender: TObject; AButtonIndex: Integer);
    procedure Tv1Column3PropertiesButtonClick(Sender: TObject; AButtonIndex: Integer);
    procedure Tv1Column1PropertiesEditValueChanged(Sender: TObject);
    procedure ToolButton3Click(Sender: TObject);
    procedure TV2Column4PropertiesButtonClick(Sender: TObject; AButtonIndex: Integer);
    procedure Tv1FocusedRecordChanged(Sender: TcxCustomGridTableView; APrevFocusedRecord, AFocusedRecord: TcxCustomGridRecord; ANewItemRecordFocusingChanged: Boolean);
    procedure TV2Column3PropertiesEditValueChanged(Sender: TObject);
    procedure ToolButton4Click(Sender: TObject);
  private
    TPInt: Integer;
    procedure InitData();
    procedure InitDataSub();
    function SaveData(): Boolean;
    function SaveMXData(Tv11: TcxGridDBTableView; CDS1: TClientDataSet; FMaxNo, FYOType: string): Boolean;
    procedure SaveImageOther();
    procedure InitImage();
    { Private declarations }
  public
    canshu1, FMCNO: string;
    PState, CopyInt: Integer;
    FMainId, FDPID, FDPName: string;
    { Public declarations }
  end;

var
  frmPLRW: TfrmPLRW;

implementation

uses
  U_DataLink, U_ZDYHelp, U_RTFun, U_TatPlanSel, U_SXRKSel;

{$R *.dfm}

procedure TfrmPLRW.TBCloseClick(Sender: TObject);
begin
  WriteCxGrid('任务安排', Tv1, '管理');
  Close;
end;

procedure TfrmPLRW.InitData();
begin
  with ADOCmd do
  begin
    Close;
    sql.Clear;
    sql.Add(' select MCNO=RTValue,PMID=''               '' ');
    sql.Add(' ,PMType=''               '',OrderNo=''               '',MainID=''               '',SubID=''               '',C_Code=''               '',C_Name=''               '' ');
    sql.Add(' ,[action]=''               '',C_MachLatitudeDensity=''               '',C_FinishLatitudeDensity=''               '' ');
    sql.Add(' from [dbo].[F_Tool_SplitString](' + quotedstr(FMCNo) + ','';'')    ');
//    ShowMessage(sql.text);
    Open;
  end;
  SCreateCDS(ADOCmd, Order_Sub);
  SInitCDSData(ADOCmd, Order_Sub);
end;

procedure TfrmPLRW.InitDataSub();
begin
  with ADOTemp do
  begin
    Close;
    sql.Clear;
    sql.Add(' select A.*');

    sql.Add(' ,case when (select count(*) from Tat_WB_Card_Yarn X where X.WBCNO =''' + Trim(Self.Order_Sub.fieldbyname('PMID').AsString) + ''' and X.RowNo=A.RowNo) > 0 ');
    sql.Add('       then (select BYIOID from Tat_WB_Card_Yarn X where X.WBCNO =''' + Trim(Self.Order_Sub.fieldbyname('PMID').AsString) + ''' and X.RowNo=A.RowNo)  ');
    sql.Add('       else ''            '' end as BYIOID');

    sql.Add(' ,case when (select count(*) from Tat_WB_Card_Yarn X where X.WBCNO =''' + Trim(Self.Order_Sub.fieldbyname('PMID').AsString) + '''and X.RowNo=A.RowNo) > 0 ');
    sql.Add('       then (select PH from Tat_WB_Card_Yarn X where X.WBCNO =''' + Trim(Self.Order_Sub.fieldbyname('PMID').AsString) + ''' and X.RowNo=A.RowNo)  ');
    sql.Add('       else ''            '' end as PH');

    sql.Add(' from Tat_Plan_Yarn A INNER JOIN Tat_Plan_Main B on A.MainId =B.MainId  INNER JOIN Tat_Plan_Sub C on B.MainId =C.MainId');
    sql.Add(' where A.YRType=''纬丝'' and B.OrderNo = ''' + Trim(Self.Order_Sub.fieldbyname('OrderNo').AsString) + '''');

//    showmessage(sql.text);
    Open;
  end;
  SCreateCDS(ADOTemp, CDS_2);
  SInitCDSData(ADOTemp, CDS_2);
end;

procedure TfrmPLRW.FormShow(Sender: TObject);
begin
  ReadCxGrid('任务安排', Tv1, '管理');
  InitData();
  ToolButton3.Click;
end;

function TfrmPLRW.SaveData(): Boolean;
var
  maxno, FHZStatus: string;
begin
  Result := False;
  try
    ADOCmd.Connection.BeginTrans;
    with Order_Sub do
    begin
      first;
      while not eof do
      begin
        if Trim(Order_Sub.fieldbyname('PMID').AsString) = '' then
        begin

          if GetLSNo(ADOCmd, maxno, 'RW', 'Tat_Plan_Mach', 4, 1) = False then
          begin
            ADOCmd.Connection.RollbackTrans;
            Application.MessageBox('取最大号失败!', '提示', 0);
            Exit;
          end;
        end
        else
        begin
          maxno := Trim(Order_Sub.fieldbyname('PMID').AsString);
        end;
        with ADOCmd do
        begin
          Close;
          sql.Clear;
          SQL.Add('select * from Tat_Plan_Mach where PMID=''' + Trim(maxno) + '''');
          Open;
        end;
        with ADOCmd do
        begin
          if ADOCmd.IsEmpty then
          begin
            Append;
            FieldByName('Filler').Value := Trim(DName);
            FieldByName('Filltime').Value := SGetServerDateTime(ADOTemp);
          end
          else
          begin
            edit;
            FieldByName('Editer').Value := Trim(DName);
            FieldByName('Edittime').Value := SGetServerDateTime(ADOTemp);
          end;
          FieldByName('PMID').Value := Trim(maxno);
          FieldByName('FS').Value := '批量';

          FieldByName('MainID').Value := Order_Sub.FieldByName('MainID').value;
          FieldByName('SubID').Value := Order_Sub.FieldByName('SubID').value;

          RTSetSaveDataCDS(ADOCmd, Tv1, Order_Sub, 'SY_Employee', 0);
          post;
        end;

        with ADOCmd do
        begin
          Close;
          sql.Clear;
          sql.Add('EXEC P_Tat_Plan_Mach_SetSequence  @PMID=''' + Trim(maxno) + '''');
          sql.Add(',@Operate=''新增'' ');
          Open;
        end;
        if ADOCmd.FieldByName('intReturn').AsInteger = -1 then
        begin
          raise Exception.Create(pchar(trim(ADOCmd.FieldByName('ShowMsg').AsString)));
        end;

        with Order_Sub do
        begin
          Edit;
          FieldByName('PMID').Value := Trim(maxno);
        end;

//        with ADOCmd do
//        begin
//          Close;
//          SQL.Clear;
//          sql.Add('exec P_EE_in_Account @DataID=''' + Trim(maxno) + '''');
//          Open;
//        end;
//        if ADOCmd.FieldByName('intReturn').AsInteger = -1 then
//        begin
//          ADOCmd.Connection.RollbackTrans;
//          Application.MessageBox(PChar(ADOCmd.fieldbyname('ShowMsg').AsString), '提示', 0);
//          exit;
//        end;

        next;
      end;
    end;
    ADOCmd.Connection.CommitTrans;
    Result := True;
  except
    ;
    Result := False;
    ADOCmd.Connection.RollbackTrans;
    Application.MessageBox('保存失败！', '提示', 0);
  end;
end;

function TfrmPLRW.SaveMXData(Tv11: TcxGridDBTableView; CDS1: TClientDataSet; FMaxNo, FYOType: string): Boolean;
begin

end;

procedure TfrmPLRW.InitImage();
begin

end;

procedure TfrmPLRW.TBSaveClick(Sender: TObject);
var
  FSFNO: string;
begin
  ToolBar1.SetFocus;

  if Order_Sub.Locate('PMType', '', []) = true then
  begin
    application.MessageBox('任务类型不能为空', '提示');
    exit;
  end;

  if Order_Sub.Locate('OrderNo', '', []) = true then
  begin
    application.MessageBox('织造单号不能为空', '提示');
    exit;
  end;

  if Order_Sub.Locate('C_Code', '', []) = true then
  begin
    application.MessageBox('产品编号不能为空', '提示');
    exit;
  end;

  if Order_Sub.Locate('C_Name', '', []) = true then
  begin
    application.MessageBox('产品名称不能为空', '提示');
    exit;
  end;

  if Order_Sub.Locate('action', '', []) = true then
  begin
    application.MessageBox('操作类型不能为空', '提示');
    exit;
  end;

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

procedure TfrmPLRW.SaveImageOther();
begin

end;

procedure TfrmPLRW.ToolButton1Click(Sender: TObject);
var
  Flag: Integer;
begin
  if Tv1.DataController.Summary.FooterSummaryValues[1] = 0 then
  begin
    Flag := 0;
  end
  else
  begin
    Flag := 1;
  end;

  with Order_Sub do
  begin
    Append;
    fieldbyname('EntryDate').Value := SGetServerDate(ADOTemp);
    FieldByName('Dept').Value := Trim(FDPName);

    if Flag = 0 then
    begin
      with ADOCmd do
      begin
        Close;
        sql.Clear;
        sql.Add('select Max(EECode) AS MAXCode from  SY_Employee ');
        Open;
      end;
      FieldByName('EECode').Value := '0' + IntToStr(StrToInt(Trim(ADOCmd.fieldbyname('MAXCode').AsString)) + 1);
    end
    else
    begin
      FieldByName('EECode').Value := '0' + IntToStr(StrToInt(Tv1.DataController.Summary.FooterSummaryValues[0]) + 1);
    end;

    Post;
  end;
end;

procedure TfrmPLRW.ToolButton2Click(Sender: TObject);
begin
  if Order_Sub.IsEmpty then
    Exit;
  if Application.MessageBox('确定要删除数据吗？', '提示', 32 + 4) <> IDYES then
    Exit;

  Order_Sub.Delete;
end;

procedure TfrmPLRW.ToolButton3Click(Sender: TObject);
var
  maxno: string;
begin
  with Order_Sub do
  begin
    first;
    while not eof do
    begin
      if GetLSNo(ADOCmd, maxno, 'RW', 'Tat_Plan_Mach', 4, 1) = False then
      begin
        ADOCmd.Connection.RollbackTrans;
        Application.MessageBox('取最大号失败!', '提示', 0);
        Exit;
      end;

      with Order_Sub do
      begin
        Edit;
        FieldByName('PMID').Value := Trim(maxno);
      end;

      Next;
    end;
  end;
end;

procedure TfrmPLRW.ToolButton4Click(Sender: TObject);
var
  FPMType, FAction, FOrderNo, FMainID, FSubID, FC_Code, FC_Name, FC_MachLatitudeDensity, FC_FinishLatitudeDensity: string;
begin
  FPMType := Order_Sub.FieldByName('PMType').asstring;
  FAction := Order_Sub.FieldByName('Action').asstring;
  FOrderNo := Order_Sub.FieldByName('OrderNo').asstring;
  FMainID := Order_Sub.FieldByName('MainID').asstring;
  FSubID := Order_Sub.FieldByName('SubID').asstring;
  FC_Code := Order_Sub.FieldByName('C_Code').asstring;
  FC_Name := Order_Sub.FieldByName('C_Name').asstring;
  FC_MachLatitudeDensity := Order_Sub.FieldByName('C_MachLatitudeDensity').asstring;
  FC_FinishLatitudeDensity := Order_Sub.FieldByName('C_FinishLatitudeDensity').asstring;

  with Order_Sub do
  begin
    first;
    while not eof do
    begin
      Edit;
      Order_Sub.FieldByName('PMType').Value := FPMType;
      Order_Sub.FieldByName('Action').Value := FAction;
      Order_Sub.FieldByName('OrderNo').Value := FOrderNo;
      Order_Sub.FieldByName('MainID').Value := FMainID;
      Order_Sub.FieldByName('SubID').Value := FSubID;
      Order_Sub.FieldByName('C_Code').Value := FC_Code;
      Order_Sub.FieldByName('C_Name').Value := FC_Name;
      Order_Sub.FieldByName('C_MachLatitudeDensity').Value := FC_MachLatitudeDensity;
      Order_Sub.FieldByName('C_FinishLatitudeDensity').Value := FC_FinishLatitudeDensity;

      with ADOTemp do
      begin
        Close;
        sql.Clear;
        sql.Add(' select * from Tat_WB_Card_Yarn where WBCNO = ''' + Trim(Self.Order_Sub.fieldbyname('PMID').AsString) + '''');
        Open;
      end;

      if ADOTemp.IsEmpty then
      begin
        with ADOCmd do
        begin
          Close;
          sql.Clear;
          sql.Add(' insert into Tat_WB_Card_Yarn(WBCNO,RowNo) values');
          sql.Add(' (' + Quotedstr(Trim(Order_Sub.fieldbyname('PMID').AsString)));
          sql.Add(',' + Quotedstr(Trim('A')));
          sql.Add(' ),');

          sql.Add(' (' + Quotedstr(Trim(Order_Sub.fieldbyname('PMID').AsString)));
          sql.Add(',' + Quotedstr(Trim('B')));
          sql.Add(' ),');

          sql.Add(' (' + Quotedstr(Trim(Order_Sub.fieldbyname('PMID').AsString)));
          sql.Add(',' + Quotedstr(Trim('C')));
          sql.Add(' ),');

          sql.Add(' (' + Quotedstr(Trim(Order_Sub.fieldbyname('PMID').AsString)));
          sql.Add(',' + Quotedstr(Trim('D')));
          sql.Add(' ),');

          sql.Add(' (' + Quotedstr(Trim(Order_Sub.fieldbyname('PMID').AsString)));
          sql.Add(',' + Quotedstr(Trim('E')));
          sql.Add(' ),');

          sql.Add(' (' + Quotedstr(Trim(Order_Sub.fieldbyname('PMID').AsString)));
          sql.Add(',' + Quotedstr(Trim('F')));
          sql.Add(' ),');

          sql.Add(' (' + Quotedstr(Trim(Order_Sub.fieldbyname('PMID').AsString)));
          sql.Add(',' + Quotedstr(Trim('G')));
          sql.Add(' )');
          ExecSQL;
        end;
      end;
      InitDataSub();

      Next;
    end;
  end;

end;

procedure TfrmPLRW.Tv1Column1PropertiesEditValueChanged(Sender: TObject);
var
  mvalue, FFieldName: string;
begin

  mvalue := TcxTextEdit(Sender).EditingText;
  FFieldName := Trim(Tv1.Controller.FocusedColumn.DataBinding.FilterFieldName);
  with Order_Sub do
  begin
    Edit;
    FieldByName(FFieldName).Value := mvalue;
    if mvalue = '下布改机' then
    begin
      Order_Sub.FieldByName('Action').Value := '下布改机';
    end
    else
    begin
      Order_Sub.FieldByName('Action').Value := '接头';
    end;
    Post;
  end;

  Tv1.Controller.EditingController.ShowEdit();

end;

procedure TfrmPLRW.Tv1Column3PropertiesButtonClick(Sender: TObject; AButtonIndex: Integer);
begin
  try
    frmTatPlanSel := TfrmTatPlanSel.Create(Application);
    with frmTatPlanSel do
    begin
      if ShowModal = 1 then
      begin
        Order_Sub.Edit;
        Order_Sub.FieldByName('OrderNo').Value := frmTatPlanSel.CDS_1.fieldbyname('OrderNo').AsString;
        Order_Sub.FieldByName('MainID').Value := frmTatPlanSel.CDS_1.fieldbyname('MainID').AsString;
        Order_Sub.FieldByName('SubID').Value := frmTatPlanSel.CDS_1.fieldbyname('SubID').AsString;
        Order_Sub.FieldByName('C_Code').Value := frmTatPlanSel.CDS_1.fieldbyname('C_Code').AsString;
        Order_Sub.FieldByName('C_Name').Value := frmTatPlanSel.CDS_1.fieldbyname('C_Name').AsString;

        Order_Sub.FieldByName('C_FinishLatitudeDensity').Value := frmTatPlanSel.CDS_1.fieldbyname('C_FinishLatitudeDensity').AsString;
        Order_Sub.FieldByName('C_MachLatitudeDensity').Value := frmTatPlanSel.CDS_1.fieldbyname('C_MachLatitudeDensity').AsString;

        with ADOTemp do
        begin
          Close;
          sql.Clear;
          sql.Add(' select * from Tat_WB_Card_Yarn where WBCNO = ''' + Trim(Self.Order_Sub.fieldbyname('PMID').AsString) + '''');
          Open;
        end;

        if ADOTemp.IsEmpty then
        begin
          with ADOQueryCmd do
          begin
            Close;
            sql.Clear;
            sql.Add(' insert into Tat_WB_Card_Yarn(WBCNO,RowNo) values');
            sql.Add(' (' + Quotedstr(Trim(Order_Sub.fieldbyname('PMID').AsString)));
            sql.Add(',' + Quotedstr(Trim('A')));
            sql.Add(' ),');

            sql.Add(' (' + Quotedstr(Trim(Order_Sub.fieldbyname('PMID').AsString)));
            sql.Add(',' + Quotedstr(Trim('B')));
            sql.Add(' ),');

            sql.Add(' (' + Quotedstr(Trim(Order_Sub.fieldbyname('PMID').AsString)));
            sql.Add(',' + Quotedstr(Trim('C')));
            sql.Add(' ),');

            sql.Add(' (' + Quotedstr(Trim(Order_Sub.fieldbyname('PMID').AsString)));
            sql.Add(',' + Quotedstr(Trim('D')));
            sql.Add(' ),');

            sql.Add(' (' + Quotedstr(Trim(Order_Sub.fieldbyname('PMID').AsString)));
            sql.Add(',' + Quotedstr(Trim('E')));
            sql.Add(' ),');

            sql.Add(' (' + Quotedstr(Trim(Order_Sub.fieldbyname('PMID').AsString)));
            sql.Add(',' + Quotedstr(Trim('F')));
            sql.Add(' ),');

            sql.Add(' (' + Quotedstr(Trim(Order_Sub.fieldbyname('PMID').AsString)));
            sql.Add(',' + Quotedstr(Trim('G')));
            sql.Add(' )');
            ExecSQL;
          end;
        end;
        InitDataSub();
      end;
    end;

  finally
    frmTatPlanSel.Free;
  end;
end;

procedure TfrmPLRW.Tv1FocusedRecordChanged(Sender: TcxCustomGridTableView; APrevFocusedRecord, AFocusedRecord: TcxCustomGridRecord; ANewItemRecordFocusingChanged: Boolean);
begin
  InitDataSub();

end;

procedure TfrmPLRW.TV2Column3PropertiesEditValueChanged(Sender: TObject);
var
  mvalue, FFieldName: string;
begin

  mvalue := TcxTextEdit(Sender).EditingText;
  FFieldName := Trim(Tv2.Controller.FocusedColumn.DataBinding.FilterFieldName);

  with CDS_2 do
  begin
    Edit;
    FieldByName(FFieldName).Value := mvalue;
    Post;
  end;

  with self.ADOCmd do
  begin
    Close;
    SQL.Clear;
    sql.Add(' update Tat_WB_Card_Yarn set PH =''' + Trim(CDS_2.fieldbyname('PH').AsString) + '''');
    sql.Add(' ,BYIOID =''' + Trim(CDS_2.fieldbyname('BYIOID').AsString) + '''');
    sql.Add(' where WBCNO =''' + Trim(Order_Sub.fieldbyname('PMID').AsString) + '''');
    sql.Add(' and RowNo =''' + Trim(CDS_2.fieldbyname('RowNo').AsString) + '''');
    ExecSQL;
  end;
  Tv2.Controller.EditingController.ShowEdit();
end;

procedure TfrmPLRW.TV2Column4PropertiesButtonClick(Sender: TObject; AButtonIndex: Integer);
begin
  try
    frmSXRKSel := TfrmSXRKSel.Create(Application);
    with frmSXRKSel do
    begin
      Y_Name.text := Trim(Self.CDS_2.fieldbyname('Y_Name').AsString);
      Yarn_Name.text := Trim(Self.CDS_2.fieldbyname('Yarn_Name').AsString);

      if ShowModal = 1 then
      begin
        with CDS_2 do
        begin
          Edit;
          FieldByName('BYIOID').Value := Trim(frmSXRKSel.CDS_1.fieldbyname('BYIOID').AsString);
          FieldByName('PH').Value := Trim(frmSXRKSel.CDS_1.fieldbyname('BCPH').AsString);
          Post;
        end;

        with self.ADOCmd do
        begin
          Close;
          sql.Clear;
          sql.Add(' update Tat_WB_Card_Yarn set PH =''' + Trim(self.CDS_2.fieldbyname('PH').AsString) + '''');
          sql.Add(' ,BYIOID =''' + Trim(self.CDS_2.fieldbyname('BYIOID').AsString) + '''');
          sql.Add(' where WBCNO =''' + Trim(self.Order_Sub.fieldbyname('PMID').AsString) + '''');
          sql.Add(' and RowNo =''' + Trim(self.CDS_2.fieldbyname('RowNo').AsString) + '''');
          ExecSQL;
        end;

      end;
    end;
  finally
    frmSXRKSel.Free;
  end;
end;

procedure TfrmPLRW.v1SYRNamePropertiesButtonClick(Sender: TObject; AButtonIndex: Integer);
begin
  frmZDYHelp := TfrmZDYHelp.Create(self);
  with frmZDYHelp do
  begin
    Flag := 'SYRName';
    flagName := '车间';
    if ShowModal = 1 then
    begin
      with Order_Sub do
      begin
        edit;
        FieldByName('SYRName').Value := Trim(ClientDataSet1.fieldbyname('ZDYName').AsString);
      end;
    end;
    free;
  end;
end;

procedure TfrmPLRW.v1Column2PropertiesButtonClick(Sender: TObject; AButtonIndex: Integer);
begin
  try
    frmZDYHelp := TfrmZDYHelp.Create(Application);
    with frmZDYHelp do
    begin
      Flag := 'BZName';
      flagname := '班组名称';
      if ShowModal = 1 then
      begin
        with Order_Sub do
        begin
          Edit;
          FieldByName('BZName').Value := Trim(frmZDYHelp.ClientDataSet1.fieldbyname('ZdyName').AsString);
        end;
      end;
    end;
  finally
    frmZDYHelp.Free;
  end;
end;

end.

