unit U_FanYangList_Sub;

interface

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

type
  TFrmFanYangListSub = class(TForm)
    ToolBar1: TToolBar;
    TBSave: TToolButton;
    TBClose: TToolButton;
    ToolBar2: TToolBar;
    ToolButton1: TToolButton;
    ToolButton2: TToolButton;
    cxGrid1: TcxGrid;
    Tv1: TcxGridDBTableView;
    v1XHNo: TcxGridDBColumn;
    v1SOrddefstr1: TcxGridDBColumn;
    v1PRTColor: TcxGridDBColumn;
    v1PRTHX: TcxGridDBColumn;
    v1PRTOrderQty: TcxGridDBColumn;
    v1OrderUnit: TcxGridDBColumn;
    v1SOrdDefNote1: TcxGridDBColumn;
    cxGrid1Level1: TcxGridLevel;
    Panel1: TPanel;
    Label1: TLabel;
    Label7: TLabel;
    Label10: TLabel;
    Label3: TLabel;
    Label14: TLabel;
    Label12: TLabel;
    Label13: TLabel;
    Label2: TLabel;
    Label6: TLabel;
    Label16: TLabel;
    Label19: TLabel;
    Label24: TLabel;
    Label25: TLabel;
    Label26: TLabel;
    Label28: TLabel;
    Label29: TLabel;
    Label35: TLabel;
    Label42: TLabel;
    Label43: TLabel;
    Label45: TLabel;
    Label48: TLabel;
    OrderNo: TEdit;
    ConNo: TEdit;
    OrdDate: TDateTimePicker;
    DLYDate: TDateTimePicker;
    CPCFBi: TEdit;
    OrdDefStr2: TBtnEditA;
    OrdDefStr3: TBtnEditA;
    MPRTKuanNO: TEdit;
    MPRTCodeName: TBtnEditA;
    OrdDefStr1: TBtnEditA;
    CustomerNoName: TBtnEditA;
    RanFactory: TBtnEditA;
    PBFactory: TBtnEditA;
    MPRTKZ: TBtnEditA;
    MPRTMF: TBtnEditA;
    MPRTCode: TBtnEditA;
    OrdDefStr4: TBtnEditA;
    OrdQty1: TcxCurrencyEdit;
    OrdQty5: TcxCurrencyEdit;
    OrdQty3: TcxCurrencyEdit;
    OrdQty6: TcxCurrencyEdit;
    Label4: TLabel;
    Note: TMemo;
    OrdFlag1: TCheckBox;
    Label5: TLabel;
    OrdQty2: TcxCurrencyEdit;
    Label8: TLabel;
    OrdDefStr6: TBtnEditA;
    v1SOrddefstr4: TcxGridDBColumn;
    v1SOrdQty1: TcxGridDBColumn;
    v1SOrddefstr3: TcxGridDBColumn;
    v1SOrddefstr5: TcxGridDBColumn;
    Label9: TLabel;
    MPRTTeBieNote: TMemo;
    Label11: TLabel;
    Label15: TLabel;
    Label17: TLabel;
    MPRTPH: TBtnEditA;
    MPRTNiuDu: TBtnEditA;
    MPRTSL: TBtnEditA;
    Label18: TLabel;
    OrdDefStr5: TBtnEditA;
    Label30: TLabel;
    Label31: TLabel;
    MPRTColorLaoDu4: TBtnEditA;
    MPRTColorLaoDu3: TBtnEditA;
    Label20: TLabel;
    Label21: TLabel;
    Label33: TLabel;
    MPRTDingPoLv: TBtnEditA;
    MPRTColorLaoDu1: TBtnEditA;
    MPRTColorLaoDu2: TBtnEditA;
    DataSource1: TDataSource;
    Order_Sub: TClientDataSet;
    ADOQueryCmd: TADOQuery;
    ADOQueryTmp: TADOQuery;
    CustomerNo: TEdit;
    v1Column1: TcxGridDBColumn;
    v1SOrdQty2: TcxGridDBColumn;
    Label22: TLabel;
    OrdQty7: TcxCurrencyEdit;
    Label23: TLabel;
    orddefstr7: TComboBox;
    Label27: TLabel;
    oldOrderNo: TEdit;
    procedure FormCreate(Sender: TObject);
    procedure FormShow(Sender: TObject);
    procedure TBCloseClick(Sender: TObject);
    procedure ToolButton2Click(Sender: TObject);
    procedure ToolButton1Click(Sender: TObject);
    procedure TBSaveClick(Sender: TObject);
    procedure MPRTCodeBtnClick(Sender: TObject);
    procedure MPRTTeBieNoteDblClick(Sender: TObject);
    procedure CustomerNoNameBtnClick(Sender: TObject);
    procedure v1PRTColorPropertiesButtonClick(Sender: TObject;
      AButtonIndex: Integer);
    procedure v1OrderUnitPropertiesButtonClick(Sender: TObject;
      AButtonIndex: Integer);
    procedure MPRTCodeNameBtnClick(Sender: TObject);
    procedure OrdDefStr1BtnClick(Sender: TObject);
    procedure OrdDefStr2BtnClick(Sender: TObject);
    procedure MPRTMFBtnClick(Sender: TObject);
    procedure MPRTKZBtnClick(Sender: TObject);
    procedure PBFactoryBtnClick(Sender: TObject);
    procedure RanFactoryBtnClick(Sender: TObject);
    procedure OrdDefStr3BtnClick(Sender: TObject);
    procedure OrdDefStr5BtnClick(Sender: TObject);
    procedure MPRTSLBtnClick(Sender: TObject);
    procedure MPRTNiuDuBtnClick(Sender: TObject);
    procedure MPRTPHBtnClick(Sender: TObject);
    procedure MPRTColorLaoDu3BtnClick(Sender: TObject);
    procedure MPRTColorLaoDu4BtnClick(Sender: TObject);
    procedure MPRTColorLaoDu1BtnClick(Sender: TObject);
    procedure MPRTColorLaoDu2BtnClick(Sender: TObject);
    procedure OrdDefStr4BtnClick(Sender: TObject);
    procedure MPRTDingPoLvBtnClick(Sender: TObject);
    procedure OrdDefStr6BtnClick(Sender: TObject);
  private
    procedure initGrid();
    procedure SaveData();
    function SaveDataYP():boolean;
    { Private declarations }
  public
    FMainid: string;
    CopyInt: integer;
    canshu1: string;
    { Public declarations }
  end;

var
  FrmFanYangListSub: TFrmFanYangListSub;

implementation

uses U_DataLink,U_ZDYHelp,U_Fun,U_ZDYHelpSel, U_ZdyAttachment;

{$R *.dfm}
function TFrmFanYangListSub.SaveDataYP():Boolean;
var
  fRKNO,fCKNO:string;
begin
  result:=false;
  if GetLSNo(ADOQueryCmd,fRKNO,'R','YP_InOut',3,1)=False then
  begin
    Application.MessageBox('取最大号失败!','提示',0);
    Exit;
  end;
  if GetLSNo(ADOQueryCmd,fcKNO,'C','YP_InOut',3,1)=False then
  begin
    Application.MessageBox('取最大号失败!','提示',0);
    Exit;
  end;
  with ADOQueryCmd do
  begin
    close;
    sql.Clear;
    sql.Add('delete from YP_InOut ');
    sql.Add('where frommainID='''+trim(Order_Sub.fieldbyname('MainID').AsString)+''' ');
    sql.Add('and fromsubID='''+trim(Order_Sub.fieldbyname('subID').AsString)+''' ');
    sql.Add('and status<''0'' ');
    execsql;
  end;
  with ADOQueryCmd do
  begin
    close;
    sql.Clear;
    sql.Add('select * from YP_InOut ');
    sql.Add('where frommainID='''+trim(Order_Sub.fieldbyname('MainID').AsString)+''' ');
    sql.Add('and fromsubID='''+trim(Order_Sub.fieldbyname('subID').AsString)+''' ');
    open;
  end;

    ADOQueryCmd.Append;
    ADOQueryCmd.FieldByName('CKName').Value:='样品间';
    ADOQueryCmd.FieldByName('CRNO').Value:=trim(fRKNO);
    ADOQueryCmd.FieldByName('CRID').Value:=1;
    ADOQueryCmd.FieldByName('CRTime').Value:=formatdateTime('yyyy-MM-dd',OrdDate.Date);
    ADOQueryCmd.FieldByName('CRType').Value:='生产入库';
    ADOQueryCmd.FieldByName('CRFlag').Value:='入库';
    ADOQueryCmd.FieldByName('ywy').Value:=trim(OrdDefStr1.Text);
    ADOQueryCmd.FieldByName('inoutNo').Value:='R'+Trim(RightBStr(fRKNO,Length(fRKNO)-2));
    ADOQueryCmd.FieldByName('frommainID').Value:=trim(Order_Sub.fieldbyname('mainID').AsString);
    ADOQueryCmd.FieldByName('fromsubID').Value:=trim(Order_Sub.fieldbyname('subID').AsString);
    ADOQueryCmd.FieldByName('RollNum').Value:=0;
    ADOQueryCmd.FieldByName('Qty1').Value:=Order_Sub.fieldbyname('SOrdQty1').AsFloat;
    ADOQueryCmd.FieldByName('defstr1').Value:='KG';
    ADOQueryCmd.FieldByName('QtyUnit').Value:='M';
    ADOQueryCmd.FieldByName('status').Value:=-1;
    ADOQueryCmd.FieldByName('CRSTEM').Value:=1;
    ADOQueryCmd.FieldByName('Filler').Value:=DName;
    ADOQueryCmd.Post;

  IF Order_Sub.fieldbyname('SOrdQty2').AsFloat>0 then
  begin
    ADOQueryCmd.Append;
    ADOQueryCmd.FieldByName('CKName').Value:='样品间';
    ADOQueryCmd.FieldByName('CRNO').Value:=trim(fCKNO);
    ADOQueryCmd.FieldByName('CRID').Value:=1;
    ADOQueryCmd.FieldByName('CRTime').Value:=formatdateTime('yyyy-MM-dd',DLYDate.Date);
    ADOQueryCmd.FieldByName('CRType').Value:='取样去库';
    ADOQueryCmd.FieldByName('CRFlag').Value:='出库';
    ADOQueryCmd.FieldByName('ywy').Value:=trim(OrdDefStr1.Text);
    ADOQueryCmd.FieldByName('custNo').Value:=trim(CustomerNo.Text);
    ADOQueryCmd.FieldByName('custName').Value:=trim(CustomerNoName.Text);
    ADOQueryCmd.FieldByName('inoutNo').Value:='C'+Trim(RightBStr(fCKNO,Length(fCKNO)-2));
    ADOQueryCmd.FieldByName('frommainID').Value:=trim(Order_Sub.fieldbyname('mainID').AsString);
    ADOQueryCmd.FieldByName('fromsubID').Value:=trim(Order_Sub.fieldbyname('subID').AsString);
    ADOQueryCmd.FieldByName('RollNum').Value:=0;
    ADOQueryCmd.FieldByName('Qty').Value:=Order_Sub.fieldbyname('SOrdQty2').AsFloat;
    ADOQueryCmd.FieldByName('QtyUnit').Value:='M';
    ADOQueryCmd.FieldByName('status').Value:=-1;
    ADOQueryCmd.FieldByName('CRSTEM').Value:=1;
    ADOQueryCmd.FieldByName('Filler').Value:=DName;
    ADOQueryCmd.Post;
  end;
  result:=true;
end;
procedure TFrmFanYangListSub.SaveData();
var MaxNo,ForederNo: string;
begin
  try
    ADOQueryCmd.Connection.BeginTrans;
    if Trim(FMainId)='' then
    begin
      if GetLSNo(ADOQueryCmd,FMainId,'FY','JYOrderFY_Main',3,1)=False then
      begin
        ADOQueryCmd.Connection.RollbackTrans;
        Application.MessageBox('取最大号失败!','提示',0);
        Exit;
      end;
     with ADOQueryTmp do
      begin
        close;
        sql.Clear;
        sql.Add('exec P_Get_MaxFYNo ');
        sql.Add(' @MPRTType='+quotedstr(trim(OrdDefStr1.Text)));
        open;
      end;
      IF trim(ADOQueryTmp.FieldByName('maxStr').AsString)='XXX' then
      begin
        if GetLSNo(ADOQueryCmd,ForederNo,trim(OrdDefStr1.text)+formatdateTime('yy',SGetServerDate10(ADOQueryTmp)),'JYOrderFY_Main',3,0)=False then
        begin
          ADOQueryCmd.Connection.RollbackTrans;
          Application.MessageBox('取最大号失败!','提示',0);
          Exit;
        end;
        ForederNo:=Trim(RightBStr(ForederNo,Length(ForederNo)-length(trim(OrdDefStr1.text))));
      end
      else
        ForederNo:=trim(ADOQueryTmp.FieldByName('maxStr').AsString);
        ForederNo:='P'+trim(OrdDefStr1.Text)+ForederNo+trim(CustomerNo.Text);
        orderNo.Text:= ForederNo;
        IF CopyInt<>98 then
        oldOrderNo.Text:=trim(ForederNo);
    end;
   // ForederNo:=trim(orderNo.Text);
    with ADOQueryCmd do
    begin
      Close;
      sql.Clear;
      SQL.Add('select * from JYOrderFy_Main where MainId='''+Trim(FMainId)+'''');
      Open;
      if isempty then
      begin
        Append;
        FieldByName('Filler').Value:=Trim(DName);
        FieldByName('Filltime').Value:=SGetServerDateTime(ADOQueryTmp);

      end
      else
      begin
        Edit;
        FieldByName('Editer').Value:=Trim(DName);
        FieldByName('EditTime').Value:=SGetServerDateTime(ADOQueryTmp);
      end;
      FieldByName('OrderNo').Value:=Trim(orderNo.text);
      FieldByName('MainId').Value:=Trim(FMainid);
      FieldByName('Status').Value:='0';
      SSetsaveSqlNew(ADOQueryCmd,'JYOrderFy_Main',Panel1,2);
      Post;
    end;
    with ADOQueryCmd do
    begin
      Close;
      sql.Clear;
      sql.Add('select * from JYOrderFY_Main where orderno='''+Trim(OrderNo.Text)+'''');
      Open;
    end;
    if ADOQueryCmd.RecordCount>1 then
    begin
      ADOQueryCmd.Connection.RollbackTrans;
      Application.MessageBox('放样单号重复!','提示',0);
      Exit;
    end;
    with Order_Sub do
    begin
      First;
      while not Eof do
      begin
        if Trim(Order_Sub.fieldbyname('SubId').AsString)='' then
        begin
          if GetLSNo(ADOQueryCmd,MaxNo,'FY','JYOrderfy_Sub',4,1)=False then
          begin
            ADOQueryCmd.Connection.RollbackTrans;
            Application.MessageBox('取子流水号失败！','提示',0);
            Exit;
          end;
        end else
        begin
          MaxNo:=Trim(Order_Sub.fieldbyname('SubId').AsString);
        end;
        with ADOQueryCmd do
        begin
          Close;
          SQL.Clear;
          sql.Add('select * from JYOrderFY_Sub where MainId='''+Trim(FMainId)+'''');
          sql.Add(' and SubId='''+Trim(maxno)+'''');
          Open;
          if isempty then
            Append
          else
            Edit;
          FieldByName('MainId').Value:=Trim(FMainId);
          FieldByName('SubId').Value:=Trim(maxno);
          RTSetSaveDataCDS(ADOQueryCmd,Tv1,Order_Sub,'JYOrderFY_Sub',0);
          fieldbyname('PRTOrderQty').Value:=Order_Sub.fieldbyname('PRTOrderQty').AsFloat;
          fieldbyname('PrtPrice').Value:=Order_Sub.fieldbyname('PrtPrice').AsFloat;
          fieldbyname('SOrdQty1').Value:=Order_Sub.fieldbyname('SOrdQty1').AsFloat;
          fieldbyname('SOrdQty2').Value:=Order_Sub.fieldbyname('SOrdQty2').AsFloat;
          Post;
        end;
        Order_Sub.Edit;
        Order_Sub.FieldByName('maiNID').Value:=Trim(FMainId);
        Order_Sub.FieldByName('SubId').Value:=Trim(maxno);
        Order_Sub.Post;
        with ADOQueryTmp do
        begin
          close;
          sql.Clear;
          sql.Add('select * from YP_InOut ');
          sql.Add('where frommainID='''+trim(Order_Sub.fieldbyname('MainID').AsString)+''' ');
          sql.Add('and fromsubID='''+trim(Order_Sub.fieldbyname('subID').AsString)+''' ');
          sql.Add('and status>=''0'' ');
          open;
        end;
        IF (Order_Sub.fieldbyname('SOrdQty1').AsFloat>0) and (ADOQueryTmp.IsEmpty) then
        begin
          if not savedataYP() then
          begin
            ADOQueryCmd.Connection.RollbackTrans;
            Application.MessageBox('保存失败！','提示');
          end;
        end;
        Next;
      end;
    end;
    ADOQueryCmd.Connection.CommitTrans;
    Application.messagebox('保存成功','提示');
    ModalResult:=1;
  except
    ADOQueryCmd.Connection.RollbackTrans;
    Application.MessageBox('保存失败！','提示');
  end;
end;

procedure TFrmFanYangListSub.initGrid();
begin
  with AdoqueryCmd do
  begin
    close;
    sql.clear;
    sql.add('select * from JYOrderFy_Main where Mainid='''+trim(FMainid)+''' ');
    open;
    if not isempty then
    begin
      SCSHDataNew(AdoqueryCmd,Panel1,2);
      OrderNO.Text:=Trim(fieldbyname('ORDERno').AsString);
      orddefstr7.Text:=Trim(fieldbyname('orddefstr7').AsString);
    end;
  end;
  with ADOQueryCmd do
  begin
    close;
    sql.clear;
    sql.add('select * from JYOrderFy_Sub where Mainid='''+trim(FMainid)+''' ');
    open;
  end;
  SCreateCDS20(ADOQueryCmd,Order_Sub);
  SInitCDSData20(ADOQueryCmd,Order_Sub);


  IF CopyInt=99 then
  begin
    FMainid:='';
    OrderNo.Text:='自动产生';
    oldOrderNo.text:='';
    with Order_Sub do
    begin
      First;
      while not Eof do
      begin
        Edit;
        FieldByName('MainId').Value:='';
        FieldByName('SubId').Value:='';
        Post;
        Next;
      end;
      first;
    end;
  end;

  IF CopyInt=98 then
  begin
    FMainid:='';
  //  oldOrderNo.text:=trim(OrderNo.Text);
    OrderNo.Text:='自动产生';
    with Order_Sub do
    begin
      First;
      while not Eof do
      begin
        Edit;
        FieldByName('MainId').Value:='';
        FieldByName('SubId').Value:='';
        Post;
        Next;
      end;
      first;
    end;
  end;
end;

procedure TFrmFanYangListSub.FormCreate(Sender: TObject);
begin
  cxgrid1.Align:=alClient;
end;

procedure TFrmFanYangListSub.FormShow(Sender: TObject);
begin
  ReadCxGrid(self.Caption+Tv1.Name,Tv1,'放样指示单录入');
  ordDate.datetime:=SGetServerDateTime(ADOQueryTmp);
  DLYDate.DateTime:=SGetServerDateTime(ADOQueryTmp);
{  if trim(DParameters1)<>'高权限' then
  begin
    OrdFlag1.Visible:=False;
  end; }
  initGrid();
end;

procedure TFrmFanYangListSub.TBCloseClick(Sender: TObject);
begin
  Close;
  WriteCxGrid(self.Caption+Tv1.Name,Tv1,'放样指示单录入');
end;

procedure TFrmFanYangListSub.ToolButton2Click(Sender: TObject);
begin
  if Order_Sub.IsEmpty then Exit;
  if Application.MessageBox('确定要删除数据吗？','提示',32+4)<>IDYES then Exit;
  with ADOQueryCmd do
  begin
    close;
    sql.clear;
    sql.Add('delete from JYOrderfy_Sub where SubId='''+Trim(Order_Sub.fieldbyname('SubId').AsString)+'''');
    execsql;
  end;
  Order_Sub.Delete;
end;

procedure TFrmFanYangListSub.ToolButton1Click(Sender: TObject);
var j: integer;
begin
  j:=Order_Sub.RecordCount;
  j:=j+1;
  CopyAddRow(Tv1,Order_Sub);
  with order_Sub do
  begin
    edit;
      fieldbyname('XHNo').AsString:=Inttostr(j);
    post;
  end;
end;

procedure TFrmFanYangListSub.TBSaveClick(Sender: TObject);
begin
  if trim(OrderNo.Text)='' then
  begin
    application.MessageBox('放样单号不能为空','提示');
    exit;
  end;
  if trim(CustomerNo.Text)='' then
  begin
    application.MessageBox('客户简称不能为空','提示');
    exit;
  end;
  if trim(CustomerNoName.Text)='' then
  begin
    application.MessageBox('客户不能为空','提示');
    exit;
  end;
  if trim(OrdDefStr1.Text)='' then
  begin
    application.MessageBox('业务组不能为空','提示');
    exit;
  end;
  if order_Sub.IsEmpty then
  begin
    application.MessageBox('明细不能为空','提示');
    exit;
  end;
  if order_Sub.Locate('PRTColor',null,[])=true then
  begin
    application.MessageBox('颜色不能为空','提示');
    exit;
  end;
  SaveData();
end;

procedure TFrmFanYangListSub.MPRTCodeBtnClick(Sender: TObject);
begin
  try
    frmZDYHelp:=TfrmZDYHelp.Create(Application);
    with frmZDYHelp do
    begin
      flag:='MPRTCode';
      flagname:='产品编号';;
      if ShowModal=1 then
      begin
        TEdit(Sender).Text:=Trim(ClientDataSet1.fieldbyname('ZDYName').AsString);
      end;
    end;
  finally
    frmZDYHelp.Free;
  end;
end;

procedure TFrmFanYangListSub.MPRTTeBieNoteDblClick(Sender: TObject);
var i: integer;
begin
  i:=0;
  try
    frmZDYHelpSel:=TfrmZDYHelpSel.Create(Application);
    with frmZDYHelpSel do
    begin
      flag:='MPRTTeBieNote';
      flagname:='注意事项';
      if ShowModal=1 then
      begin
        MPRTTeBieNote.Lines.Clear;
        with ClientDataSet1 do
        begin
          First;
          while not Eof do
          begin
            if FieldByName('SSel').AsBoolean=True then
            begin
              i:=i+1;
              MPRTTeBieNote.Lines.Add(inttostr(i)+'.'+FieldByName('ZDYName').AsString)
            end;
            Next;
          end;
        end;
      end;
    end;
  finally
    frmZDYHelpSel.Free;
  end;
end;

procedure TFrmFanYangListSub.CustomerNoNameBtnClick(Sender: TObject);
begin
 { try
    frmZDYHelp:=TfrmZDYHelp.Create(Application);
    with frmZDYHelp do
    begin
      flag:='CustomerNoName';
      flagname:='客户';
      fnote:=True;
      V1Note.Caption:='客户简称';
      V1Name.Caption:='客户';
      if trim(DParameters1)<>'高权限' then ViewFlag:=true;
      if ShowModal=1 then
      begin
        TEdit(Sender).Text:=Trim(ClientDataSet1.fieldbyname('ZDYName').AsString);
        CustomerNo.text:=Trim(ClientDataSet1.fieldbyname('Note').AsString);
      end;
    end;
  finally
    frmZDYHelp.Free;
  end;  }
  try
    frmZdyAttachment:=TfrmZdyAttachment.Create(Application);
    with frmZdyAttachment do
    begin
      fkhType:='';
       if trim(DParameters1)<>'高权限'  then canshu1:='业务员';
      if ShowModal=1 then
      begin
        CustomerNoName.Text:=Trim(CDS_HZ.fieldbyname('ZDYName').AsString);
       // CustomerNoName.TxtCode:=Trim(CDS_HZ.fieldbyname('ZDYCode').AsString);
        CustomerNo.Text:=Trim(CDS_HZ.fieldbyname('ZDYNameZ').AsString);
      end;
    end;
  finally
    frmZdyAttachment.Free;
  end;
end;

procedure TFrmFanYangListSub.v1PRTColorPropertiesButtonClick(
  Sender: TObject; AButtonIndex: Integer);
begin
  try
    frmZDYHelp:=TfrmZDYHelp.Create(Application);
    with frmZDYHelp do
    begin
      flag:='OrdColor';
      flagname:='颜色';
      V1Name.Caption:='中文名称';
      V1Note.Caption:='英文名称';
      fnote:=True;
      if ShowModal=1 then
      begin
        Self.Order_Sub.Edit;
        Self.Order_Sub.FieldByName('PRTColor').Value:=Trim(ClientDataSet1.fieldbyname('ZDYName').AsString);
        Self.Order_Sub.FieldByName('SOrddefstr4').Value:=Trim(ClientDataSet1.fieldbyname('Note').AsString);
      end;
    end;
  finally
    frmZDYHelp.Free;
  end;
end;

procedure TFrmFanYangListSub.v1OrderUnitPropertiesButtonClick(
  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('OrderUnit').Value:=Trim(ClientDataSet1.fieldbyname('ZDYName').AsString);
      end;
    end;
  finally
    frmZDYHelp.Free;
  end;
end;

procedure TFrmFanYangListSub.MPRTCodeNameBtnClick(Sender: TObject);
begin
  try
    frmZDYHelp:=TfrmZDYHelp.Create(Application);
    with frmZDYHelp do
    begin
      flag:='MPRTCodeName';
      flagname:='产品名称';;
      if ShowModal=1 then
      begin
        TEdit(Sender).Text:=Trim(ClientDataSet1.fieldbyname('ZDYName').AsString);
      end;
    end;
  finally
    frmZDYHelp.Free;
  end;
end;

procedure TFrmFanYangListSub.OrdDefStr1BtnClick(Sender: TObject);
begin
  try
    frmZDYHelp:=TfrmZDYHelp.Create(Application);
    with frmZDYHelp do
    begin
      flag:='YEWUZU';
      flagname:='业务组';;
      if ShowModal=1 then
      begin
        TEdit(Sender).Text:=Trim(ClientDataSet1.fieldbyname('ZDYName').AsString);
      end;
    end;
  finally
    frmZDYHelp.Free;
  end;
end;

procedure TFrmFanYangListSub.OrdDefStr2BtnClick(Sender: TObject);
begin
  try
    frmZDYHelp:=TfrmZDYHelp.Create(Application);
    with frmZDYHelp do
    begin
      flag:='SHENGCHANZU';
      flagname:='生产组';;
      if ShowModal=1 then
      begin
        TEdit(Sender).Text:=Trim(ClientDataSet1.fieldbyname('ZDYName').AsString);
      end;
    end;
  finally
    frmZDYHelp.Free;
  end;
end;

procedure TFrmFanYangListSub.MPRTMFBtnClick(Sender: TObject);
begin
  try
    frmZDYHelp:=TfrmZDYHelp.Create(Application);
    with frmZDYHelp do
    begin
      flag:='MPRTMF';
      flagname:='门幅';
      if ShowModal=1 then
      begin
        TEdit(Sender).Text:=Trim(ClientDataSet1.fieldbyname('ZDYName').AsString);
      end;
    end;
  finally
    frmZDYHelp.Free;
  end;
end;

procedure TFrmFanYangListSub.MPRTKZBtnClick(Sender: TObject);
begin
  try
    frmZDYHelp:=TfrmZDYHelp.Create(Application);
    with frmZDYHelp do
    begin
      flag:='MPRTKZ';
      flagname:='克重';
      if ShowModal=1 then
      begin
        TEdit(Sender).Text:=Trim(ClientDataSet1.fieldbyname('ZDYName').AsString);
      end;
    end;
  finally
    frmZDYHelp.Free;
  end;
end;

procedure TFrmFanYangListSub.PBFactoryBtnClick(Sender: TObject);
begin
  try
    frmZDYHelp:=TfrmZDYHelp.Create(Application);
    with frmZDYHelp do
    begin
      flag:='Factory';
      flagname:='坯布厂';
      if ShowModal=1 then
      begin
        TEdit(Sender).Text:=Trim(ClientDataSet1.fieldbyname('ZDYName').AsString);
      end;
    end;
  finally
    frmZDYHelp.Free;
  end;
end;

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

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

procedure TFrmFanYangListSub.OrdDefStr5BtnClick(Sender: TObject);
begin
  try
    frmZDYHelp:=TfrmZDYHelp.Create(Application);
    with frmZDYHelp do
    begin
      flag:='CESHIBZ';
      flagname:='测试标准';;
      if ShowModal=1 then
      begin
        TEdit(Sender).Text:=Trim(ClientDataSet1.fieldbyname('ZDYName').AsString);
      end;
    end;
  finally
    frmZDYHelp.Free;
  end;
end;

procedure TFrmFanYangListSub.MPRTSLBtnClick(Sender: TObject);
begin
  try
    frmZDYHelp:=TfrmZDYHelp.Create(Application);
    with frmZDYHelp do
    begin
      flag:='MPRTSL';
      flagname:='缩水率';;
      if ShowModal=1 then
      begin
        TEdit(Sender).Text:=Trim(ClientDataSet1.fieldbyname('ZDYName').AsString);
      end;
    end;
  finally
    frmZDYHelp.Free;
  end;
end;

procedure TFrmFanYangListSub.MPRTNiuDuBtnClick(Sender: TObject);
begin
  try
    frmZDYHelp:=TfrmZDYHelp.Create(Application);
    with frmZDYHelp do
    begin
      flag:='MPRTNiuDu';
      flagname:='扭力';;
      if ShowModal=1 then
      begin
        TEdit(Sender).Text:=Trim(ClientDataSet1.fieldbyname('ZDYName').AsString);
      end;
    end;
  finally
    frmZDYHelp.Free;
  end;
end;

procedure TFrmFanYangListSub.MPRTPHBtnClick(Sender: TObject);
begin
  try
    frmZDYHelp:=TfrmZDYHelp.Create(Application);
    with frmZDYHelp do
    begin
      flag:='MPRTPH';
      flagname:='PH值';;
      if ShowModal=1 then
      begin
        TEdit(Sender).Text:=Trim(ClientDataSet1.fieldbyname('ZDYName').AsString);
      end;
    end;
  finally
    frmZDYHelp.Free;
  end;
end;

procedure TFrmFanYangListSub.MPRTColorLaoDu3BtnClick(Sender: TObject);
begin
  try
    frmZDYHelp:=TfrmZDYHelp.Create(Application);
    with frmZDYHelp do
    begin
      flag:='MPRTColorLaoDu3';
      flagname:='沾色牢度';;
      if ShowModal=1 then
      begin
        TEdit(Sender).Text:=Trim(ClientDataSet1.fieldbyname('ZDYName').AsString);
      end;
    end;
  finally
    frmZDYHelp.Free;
  end;
end;

procedure TFrmFanYangListSub.MPRTColorLaoDu4BtnClick(Sender: TObject);
begin
  try
    frmZDYHelp:=TfrmZDYHelp.Create(Application);
    with frmZDYHelp do
    begin
      flag:='MPRTColorLaoDu4';
      flagname:='水洗牢度';;
      if ShowModal=1 then
      begin
        TEdit(Sender).Text:=Trim(ClientDataSet1.fieldbyname('ZDYName').AsString);
      end;
    end;
  finally
    frmZDYHelp.Free;
  end;
end;

procedure TFrmFanYangListSub.MPRTColorLaoDu1BtnClick(Sender: TObject);
begin
  try
    frmZDYHelp:=TfrmZDYHelp.Create(Application);
    with frmZDYHelp do
    begin
      flag:='MPRTColorLaoDu1';
      flagname:='干磨';;
      if ShowModal=1 then
      begin
        TEdit(Sender).Text:=Trim(ClientDataSet1.fieldbyname('ZDYName').AsString);
      end;
    end;
  finally
    frmZDYHelp.Free;
  end;
end;

procedure TFrmFanYangListSub.MPRTColorLaoDu2BtnClick(Sender: TObject);
begin
  try
    frmZDYHelp:=TfrmZDYHelp.Create(Application);
    with frmZDYHelp do
    begin
      flag:='MPRTColorLaoDu2';
      flagname:='湿磨';;
      if ShowModal=1 then
      begin
        TEdit(Sender).Text:=Trim(ClientDataSet1.fieldbyname('ZDYName').AsString);
      end;
    end;
  finally
    frmZDYHelp.Free;
  end;
end;

procedure TFrmFanYangListSub.OrdDefStr4BtnClick(Sender: TObject);
begin
  try
    frmZDYHelp:=TfrmZDYHelp.Create(Application);
    with frmZDYHelp do
    begin
      flag:='SHAZI';
      flagname:='沙子';;
      if ShowModal=1 then
      begin
        TEdit(Sender).Text:=Trim(ClientDataSet1.fieldbyname('ZDYName').AsString);
      end;
    end;
  finally
    frmZDYHelp.Free;
  end;
end;

procedure TFrmFanYangListSub.MPRTDingPoLvBtnClick(Sender: TObject);
begin
  try
    frmZDYHelp:=TfrmZDYHelp.Create(Application);
    with frmZDYHelp do
    begin
      flag:='MPRTDingPoLv';
      flagname:='顶破率';;
      if ShowModal=1 then
      begin
        TEdit(Sender).Text:=Trim(ClientDataSet1.fieldbyname('ZDYName').AsString);
      end;
    end;
  finally
    frmZDYHelp.Free;
  end;
end;

procedure TFrmFanYangListSub.OrdDefStr6BtnClick(Sender: TObject);
begin
  try
    frmZDYHelp:=TfrmZDYHelp.Create(Application);
    with frmZDYHelp do
    begin
      flag:='CYTP';
      flagname:='币种';
      if ShowModal=1 then
      begin
        TEdit(Sender).Text:=Trim(ClientDataSet1.fieldbyname('ZDYName').AsString);
      end;
    end;
  finally
    frmZDYHelp.Free;
  end;
end;

end.
