unit U_FHSQInPut;

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, cxGridCustomPopupMenu, cxGridPopupMenu, cxLookAndFeels,
  cxLookAndFeelPainters, cxNavigator;

type
  TfrmFHSQInPut = class(TForm)
    ToolBar1: TToolBar;
    TBSave: TToolButton;
    TBClose: TToolButton;
    ScrollBox1: TScrollBox;
    ToolBar2: TToolBar;
    ToolButton1: TToolButton;
    ToolButton2: TToolButton;
    cxGrid1: TcxGrid;
    Tv1: TcxGridDBTableView;
    cxGrid1Level1: TcxGridLevel;
    v1PRTColor: TcxGridDBColumn;
    ADOTemp: TADOQuery;
    ADOCmd: TADOQuery;
    DataSource1: TDataSource;
    Order_Sub: TClientDataSet;
    ADOQuery1: TADOQuery;
    Label14: TLabel;
    cxGridPopupMenu2: TcxGridPopupMenu;
    Label1: TLabel;
    CRType: TComboBox;
    Note: TEdit;
    Label12: TLabel;
    Label11: TLabel;
    SHDanWei: TBtnEditC;
    Label13: TLabel;
    FHTaiTou: TBtnEditC;
    Label16: TLabel;
    ranchang: TBtnEditC;
    Label17: TLabel;
    TruckId: TEdit;
    v1Column3: TcxGridDBColumn;
    CustomerNoName: TBtnEditA;
    Label18: TLabel;
    Label26: TLabel;
    SQBatchNoHZ: TEdit;
    Tv1Column2: TcxGridDBColumn;
    Tv1Column3: TcxGridDBColumn;
    Label2: TLabel;
    SJPHONE: TEdit;
    Label3: TLabel;
    SHDZ: TBtnEditC;
    Tv1Column1: TcxGridDBColumn;
    shouhuotaitou: TBtnEditC;
    ze: TToolButton;
    Label4: TLabel;
    SQDate: TDateTimePicker;
    procedure TBCloseClick(Sender: TObject);
    procedure FormShow(Sender: TObject);
    procedure TBSaveClick(Sender: TObject);
    procedure ToolButton1Click(Sender: TObject);
    procedure ToolButton2Click(Sender: TObject);
//    procedure ConNoBtnClick(Sender: TObject);
    procedure SHDanWeiBtnUpClick(Sender: TObject);
    procedure SHDanWeiBtnDnClick(Sender: TObject);
    procedure FHTaiTouBtnDnClick(Sender: TObject);
    procedure FHTaiTouBtnUpClick(Sender: TObject);
    procedure ranchangBtnUpClick(Sender: TObject);
    procedure ShouKuanKeyPress(Sender: TObject; var Key: Char);
    procedure SQPSHZExit(Sender: TObject);
    procedure ScrollBox1Click(Sender: TObject);
//    procedure PrtCodeBtnClick(Sender: TObject);
    procedure CustomerNoNameBtnClick(Sender: TObject);
    procedure v1Column3PropertiesEditValueChanged(Sender: TObject);
    procedure SHDZBtnDnClick(Sender: TObject);
    procedure ranchangBtnDnClick(Sender: TObject);
    procedure SHDZBtnUpClick(Sender: TObject);
    procedure Tv1Column1PropertiesButtonClick(Sender: TObject; AButtonIndex: Integer);
    procedure shouhuotaitouBtnUpClick(Sender: TObject);
    procedure shouhuotaitouBtnDnClick(Sender: TObject);
    procedure v1Column14PropertiesButtonClick(Sender: TObject; AButtonIndex: Integer);
    procedure zeClick(Sender: TObject);
  private
    fuserName: string;
    procedure InitData();
    procedure ZDYHelp(FButn: TcxButtonEdit; LType: string);
    function SaveData(): Boolean;
    { Private declarations }
  public
    PState, CopyInt: Integer;
    FMainId, FFMainId, ChkStr, ConPriceStr: string;
    FXS: Integer;
    { Public declarations }
  end;

var
  frmFHSQInPut: TfrmFHSQInPut;
  newh: hwnd;

implementation

uses
  U_DataLink, U_ZDYHelp, U_RTFun, U_SQKCHZSelList, U_ContractListNXSel,
  U_CPManageFMSel, U_ZdyAttachment, U_ClothSCList;

{$R *.dfm}

procedure TfrmFHSQInPut.TBCloseClick(Sender: TObject);
begin

  WriteCxGrid('发货申请录入1', Tv1, '发货管理9');
  Close;
end;

procedure TfrmFHSQInPut.InitData();
var
  fsj: string;
begin
//  fsj := 'select Name=ZdyName from KH_Zdy where Type=''ClothType'' ';
//  SInitComBoxBySql(ADOTemp, ClothType, False, fsj);
  with ADOQuery1 do
  begin
    Close;
    SQL.Clear;
    sql.Add(' select A.*  ');
    sql.Add(',GCCode=(select GCCode from Cloth_Main CM where CM.MainId=A.Mainid)');
    sql.Add(',BatchNoHZ=(select BatchNoHZ from Cloth_Sub CS where CS.MainId=A.Mainid)');
    sql.Add(' from FHSQ_Sub A');
    if PState = 1 then
    begin
      sql.Add('where FSId=''' + Trim(FMainId) + '''');
    end;
    if PState = 0 then
    begin
      sql.Add(' where 1<>1');
    end;
    Open;
  end;
  SCreateCDS20(ADOQuery1, Order_Sub);
  SInitCDSData20(ADOQuery1, Order_Sub);
  if PState = 0 then
  begin
    SQDate.DateTime := SGetServerDate10(ADOTemp);
  end;
  with ADOQuery1 do
  begin
    Close;
    sql.Clear;
    sql.Add('select A.* ');
    sql.Add(' from FHSQ_Main A');
    sql.Add(' where FSId=''' + Trim(FMainId) + ''' ');
    Open;
  end;
  SCSHDataNew(ADOQuery1, ScrollBox1, 0);
  SCSHDataNew(ADOQuery1, ScrollBox1, 1);
//  ConNo.TxtCode := Trim(ADOQuery1.fieldbyname('ConSubId').AsString);

  if CopyInt = 99 then
  begin
    FMainId := '';
    SQDate.DateTime := SGetServerDate10(ADOTemp);
    with Order_Sub do
    begin
      First;
      while not eof do
      begin
        Edit;
        FieldByName('FSId').Value := '';
        FieldByName('SSid').Value := '';
        Next;
      end;
    end;
  end;
end;

procedure TfrmFHSQInPut.ZDYHelp(FButn: TcxButtonEdit; LType: string);
var
  FType, ZDYName, FText: string;
begin
end;

procedure TfrmFHSQInPut.FormShow(Sender: TObject);
begin
  readCxGrid('发货申请录入1', Tv1, '发货管理9');
  InitData();
end;

function TfrmFHSQInPut.SaveData(): Boolean;
var
  maxno, maxmnno, FSSId: string;
  fconNO, fmxType: string;
begin
  try
    ADOCmd.Connection.BeginTrans;
    ///保存主表
    if Trim(FMainId) = '' then
    begin
      if GetLSNoHZ(ADOCmd, maxno, 'SQ', 'FHSQ_Main', 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 FHSQ_Main where FSID=''' + Trim(FMainId) + '''');
      Open;
    end;
    with ADOCmd do
    begin
      if Trim(FMainId) = '' then
      begin
        Append;
      end
      else
      begin
        Edit;
      end;
      FieldByName('FSID').Value := Trim(maxno);

      RTSetsavedata(ADOCmd, 'FHSQ_Main', ScrollBox1, 1);
//      FieldByName('ConSubId').Value := Trim(ConNo.TxtCode);

      if Trim(FMainId) = '' then
      begin
        FieldByName('Filler').Value := Trim(DName);
//        FieldByName('SQDate').Value := SGetServerDate(ADOTemp);
      end
      else
      begin
        FieldByName('Editer').Value := Trim(DName);
        FieldByName('EditTime').Value := SGetServerDateTime(ADOTemp);
      end;
      Post;
    end;

//    with ADOCmd do
//    begin
//      Close;
//      sql.Clear;
//      sql.Add('UPdate FHSQ_Main Set ConMainId=(select MainId from JYOrderCon_Sub_PB where SubId=''' + Trim(ConNo.TxtCode) + ''')');
//      sql.Add(' where FSID=''' + Trim(maxno) + '''');
//      ExecSQL;
//    end;
    FMainId := Trim(maxno);
    ///保存子表
    Order_Sub.DisableControls;
    with Order_Sub do
    begin
      First;
      while not Eof do
      begin
        if Trim(Order_Sub.fieldbyname('SSId').AsString) = '' then
        begin
          if GetLSNo(ADOCmd, maxno, 'SS', 'FHSQ_Sub', 4, 1) = False then
          begin
            Order_Sub.EnableControls;
            ADOCmd.Connection.RollbackTrans;
            Application.MessageBox('取子流水号失败！', '提示', 0);
            Exit;
          end;
        end
        else
        begin
          maxno := Trim(Order_Sub.fieldbyname('SSId').AsString);
        end;
        with ADOCmd do
        begin
          Close;
          SQL.Clear;
          sql.Add('select * from FHSQ_Sub ');
          sql.Add(' where SSId=''' + Trim(maxno) + '''');
          Open;
        end;
        if ADOCmd.IsEmpty then
        begin
          FSSId := '';
        end
        else
        begin
          FSSId := Trim(maxno);
        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('FSID').Value := Trim(FMainId);
          FieldByName('SSID').Value := Trim(maxno);
          FieldByName('P_cartype').ASSTRING := Order_Sub.fieldbyname('P_cartype').AsString;
          RTSetSaveDataCDS(ADOCmd, Tv1, Order_Sub, 'FHSQ_Sub', 0);
//          FieldByName('MainId').Value := Order_Sub.fieldbyname('MainId').Value;
//          FieldByName('SubId').Value := Order_Sub.fieldbyname('SubId').Value;
//          FieldByName('SSConMainId').Value := Order_Sub.fieldbyname('SSConMainId').Value;
//          FieldByName('SSConSubId').Value := Order_Sub.fieldbyname('SSConSubId').Value;
          Post;
        end;
        with ADOCmd do
        begin
          Close;
          sql.Clear;
          sql.Add('EXEC P_SC_CLOTH @SSID=''' + Trim(maxno) + '''');
          ExecSQL;
        end;
        Order_Sub.Edit;
        Order_Sub.FieldByName('SSID').Value := Trim(maxno);
        Next;
      end;
    end;
    Order_Sub.EnableControls;
    with ADOCmd do
    begin
      Close;
      sql.Clear;
      sql.Add('Update FHSQ_Main Set ');
      sql.Add('SQPSHZ=(select Sum(SQPS) from FHSQ_Sub A where A.FSID=FHSQ_Main.FSID)');
      sql.Add(',SQQTYHZ=(select Sum(SQQTY) from FHSQ_Sub A where A.FSID=FHSQ_Main.FSID)');
      sql.Add(',SQGCCode=dbo.F_Get_Order_SubStr_PB(FHSQ_Main.FSID,''SQGCCode'')');
      sql.Add(',SQBatchNoHZ=dbo.F_Get_Order_SubStr_PB(FHSQ_Main.FSID,''SQBatchNoHZ'')');
      sql.Add('where FSID=''' + Trim(FMainId) + '''');
      ExecSQL;
    end;

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

procedure TfrmFHSQInPut.TBSaveClick(Sender: TObject);
var
  Freal: Double;
begin
  ToolBar1.SetFocus;

  if Trim(CRType.Text) = '' then
  begin
    Application.MessageBox('出库类型不能为空！', '提示', 0);
    Exit;
  end;

  if Order_Sub.IsEmpty then
  begin
    Application.MessageBox('明细不能为空！', '提示', 0);
    Exit;
  end;

  if Order_Sub.Locate('FHKHPM', null, []) = True then
  begin
    Application.MessageBox('客户品名不能为空！', '提示', 0);
    Exit;
  end;

  if Order_Sub.Locate('SQPS', null, []) = True then
  begin
    Application.MessageBox('申请匹数不能为空！', '提示', 0);
    Exit;
  end;
  if Order_Sub.Locate('SQPS', 0, []) = True then
  begin
    Application.MessageBox('申请匹数不能为0！', '提示', 0);
    Exit;
  end;
//  if Order_Sub.Locate('SQQty', null, []) = True then
//  begin
//    Application.MessageBox('申请数量不能为空！', '提示', 0);
//    Exit;
//  end;

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

procedure TfrmFHSQInPut.ToolButton1Click(Sender: TObject);
begin
//  if Trim(PrtCode.Text) = '' then
//  begin
//    Application.MessageBox('没有产品！', '提示', 0);
//    Exit;
//  end;
//  if Order_Sub.IsEmpty = false then
//  begin
//    Application.MessageBox('已有产品，请先删除！', '提示', 0);
//    Exit;
//  end;
  try
    frmSQKCHZSelList := TfrmSQKCHZSelList.Create(Application);
    with frmSQKCHZSelList do
    begin
//      FCode := Trim(Self.PrtCode.Text);
//      FClothType := Trim(ClothType.Text);
//      FSeBie:=Trim(SeBie.Text);
//      KHNAME.Text := Self.CustomerNoName.Text;
      if ShowModal = 1 then
      begin
        if self.Order_Sub.locate('P_NAME', trim(CDS_Main.Fieldbyname('C_CodeName').AsString), []) then
        begin
          Application.MessageBox('已选择该产品！', '提示', 0);
          Exit;
        end;
        with Self.Order_Sub do
        begin
          Append;

          FieldByName('P_CODE').ASSTRING := frmSQKCHZSelList.CDS_Main.fieldbyname('C_Code').ASSTRING;
          FieldByName('P_NAME').ASSTRING := frmSQKCHZSelList.CDS_Main.fieldbyname('C_CodeName').ASSTRING;

          FieldByName('FHKHPM').ASSTRING := frmSQKCHZSelList.CDS_Main.fieldbyname('C_CodeName').ASSTRING;

          FieldByName('SQPRICE').Value := 0;
          FieldByName('SQMONEY').Value := 0;
//            FieldByName('P_NAME').Value := frmSQKCHZSelList.CDS_Main.fieldbyname('C_CodeName').Value;

          Post;
        end;

      end;
    end;
  finally
    frmSQKCHZSelList.Free;
  end;
end;

procedure TfrmFHSQInPut.ToolButton2Click(Sender: TObject);
begin
  if Order_Sub.IsEmpty then
    Exit;
  if Trim(Order_Sub.fieldbyname('SSId').AsString) <> '' then
  begin
    with ADOTemp do
    begin
      Close;
      sql.Clear;
      sql.Add('select * from FHSQ_Sub where SSId=''' + Trim(Order_Sub.fieldbyname('SSId').AsString) + '''');
      sql.add(' and isnull(FHPS,0)>0');
      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 FHSQ_Sub where SSId=''' + Trim(Order_Sub.fieldbyname('SSId').AsString) + '''');
      ExecSQL;
    end;
    with ADOCmd do
    begin
      Close;
      sql.Clear;
      sql.Add('Update FHSQ_Main Set ');
      sql.Add('SQPSHZ=(select Sum(SQPS) from FHSQ_Sub A where A.FSID=FHSQ_Main.FSID)');
      sql.Add('where FSID=''' + Trim(FMainId) + '''');
      ExecSQL;
    end;
  end;
  Order_Sub.Delete;
end;

procedure TfrmFHSQInPut.SHDanWeiBtnUpClick(Sender: TObject);
begin
  try
    frmZDYHelp := TfrmZDYHelp.Create(Application);
    with frmZDYHelp do
    begin
      flag := 'SHDanWei';
      flagname := '收货单位';
      if ShowModal = 1 then
      begin
        Self.SHDanWei.Text := Trim(frmZDYHelp.ClientDataSet1.fieldbyname('ZdyName').AsString);
      end;
    end;
  finally
    frmZDYHelp.Free;
  end;
end;

procedure TfrmFHSQInPut.SHDanWeiBtnDnClick(Sender: TObject);
begin
  SHDanWei.Text := '';
end;

procedure TfrmFHSQInPut.FHTaiTouBtnDnClick(Sender: TObject);
begin
  FHTaiTou.Text := '';
end;

procedure TfrmFHSQInPut.FHTaiTouBtnUpClick(Sender: TObject);
begin
  try
    frmZDYHelp := TfrmZDYHelp.Create(Application);
    with frmZDYHelp do
    begin
      flag := 'FHTaiTou';
      flagname := '发货抬头';
      if ShowModal = 1 then
      begin
        Self.FHTaiTou.Text := Trim(frmZDYHelp.ClientDataSet1.fieldbyname('ZdyName').AsString);
      end;
    end;
  finally
    frmZDYHelp.Free;
  end;
end;

procedure TfrmFHSQInPut.ranchangBtnUpClick(Sender: TObject);
begin
  try
    frmZDYHelp := TfrmZDYHelp.Create(Application);
    with frmZDYHelp do
    begin
      flag := 'ranchang';
      flagname := '染厂';
      if ShowModal = 1 then
      begin
        Self.ranchang.Text := Trim(frmZDYHelp.ClientDataSet1.fieldbyname('ZdyName').AsString);
      end;
    end;
  finally
    frmZDYHelp.Free;
  end;
end;

procedure TfrmFHSQInPut.ShouKuanKeyPress(Sender: TObject; var Key: Char);
begin
  if not (((Key >= '0') and (Key <= '9')) or (Key = '.') or (Key = #8)) then
  begin
    Key := #0;
  end
  else if (pos('.', TEdit(Sender).text) <> 0) then
  begin
    if Key = '.' then
    begin
      Key := #0;
    end;
  end;
end;

procedure TfrmFHSQInPut.SQPSHZExit(Sender: TObject);
begin
//  SQQtyHZ.Text := floattostr(strtofloatdef(SQPSHZ.Text, 0) * strtofloatdef(PiZhong.Text, 0));
end;

procedure TfrmFHSQInPut.ScrollBox1Click(Sender: TObject);
begin
  CustomerNoName.SetFocus();
end;

//procedure TfrmFHSQInPut.PrtCodeBtnClick(Sender: TObject);
//begin
//  try
//    frmCPManageFMSel := TfrmCPManageFMSel.Create(Application);
//    with frmCPManageFMSel do
//    begin
//      if ShowModal = 1 then
//      begin
//        PrtCode.Text := frmCPManageFMSel.CDS_Main.fieldbyname('CYNo').AsString;
//        PrtCodeName.Text := frmCPManageFMSel.CDS_Main.fieldbyname('CYName').AsString;
//        shouhuomingcheng.Text := frmCPManageFMSel.CDS_Main.fieldbyname('CYName').AsString;
//        prtmf.Text := frmCPManageFMSel.CDS_Main.fieldbyname('CYMF').AsString;
//        prtkz.Text := frmCPManageFMSel.CDS_Main.fieldbyname('CYKZ').AsString;
//        prtspec.Text := frmCPManageFMSel.CDS_Main.fieldbyname('CYSpec').AsString;
//      end;
//    end;
//  finally
//    frmCPManageFMSel.Free;
//  end;
//end;

procedure TfrmFHSQInPut.CustomerNoNameBtnClick(Sender: TObject);
begin
  try
    frmZdyAttachment := TfrmZdyAttachment.Create(Application);
    with frmZdyAttachment do
    begin
      if ShowModal = 1 then
      begin
        CustomerNoName.Text := Trim(CDS_HZ.fieldbyname('CoName').AsString);
        shouhuotaitou.Text := Trim(CDS_HZ.fieldbyname('CoName').AsString);
      end;
    end;
  finally
    frmZdyAttachment.Free;
  end;
end;

procedure TfrmFHSQInPut.v1Column3PropertiesEditValueChanged(Sender: TObject);
var
  mvalue, FFieldName: string;
  FQty, FPrice, FMxMoney: double;
begin
  mvalue := TcxTextEdit(Sender).EditingText;
  FFieldName := Trim(Tv1.Controller.FocusedColumn.DataBinding.FilterFieldName);
  if Trim(mvalue) = '' then
  begin
    mvalue := '0';
  end;
  with Order_Sub do
  begin
    Edit;
    FieldByName(FFieldName).Value := Trim(mvalue);
    Post;
  end;
  with Order_Sub do
  begin
    Edit;
    FQty := FieldByName('SQQty').AsFloat;
    FPrice := FieldByName('SQPRICE').AsFloat;
    Post;
  end;
  FMxMoney := strtofloat(format('%.2f', [FQty * FPrice]));
  with Order_Sub do
  begin
    Edit;
    FieldByName(FFieldName).Value := Trim(mvalue);
    FieldbyName('SQMONEY').Value := FMxMoney;
    Post;
  end;
  tv1.Controller.EditingController.ShowEdit();

end;

procedure TfrmFHSQInPut.SHDZBtnDnClick(Sender: TObject);
begin
  SHDZ.Text := '';
end;

procedure TfrmFHSQInPut.ranchangBtnDnClick(Sender: TObject);
begin
  RANCHANG.Text := '';
end;

procedure TfrmFHSQInPut.SHDZBtnUpClick(Sender: TObject);
begin
  try
    frmZDYHelp := TfrmZDYHelp.Create(Application);
    with frmZDYHelp do
    begin
      flag := 'SHDZ';
      flagname := '收货地址';
      if ShowModal = 1 then
      begin
        Self.SHDZ.Text := Trim(frmZDYHelp.ClientDataSet1.fieldbyname('ZdyName').AsString);
      end;
    end;
  finally
    frmZDYHelp.Free;
  end;
end;

procedure TfrmFHSQInPut.Tv1Column1PropertiesButtonClick(Sender: TObject; AButtonIndex: Integer);
begin
  try
    frmZDYHelp := TfrmZDYHelp.Create(Application);
    with frmZDYHelp do
    begin
      flag := 'KHPM';
      flagname := '客户品名';
      if ShowModal = 1 then
      begin
        with Order_Sub do
        begin
          Edit;
          fieldbyname('fhkhpm').AsString := Trim(frmZDYHelp.ClientDataSet1.fieldbyname('ZdyName').AsString);
        end;

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

procedure TfrmFHSQInPut.shouhuotaitouBtnUpClick(Sender: TObject);
begin
  try
    frmZDYHelp := TfrmZDYHelp.Create(Application);
    with frmZDYHelp do
    begin
      flag := 'taitou';
      flagname := '收货单位';
      if ShowModal = 1 then
      begin
        Self.shouhuotaitou.Text := Trim(frmZDYHelp.ClientDataSet1.fieldbyname('ZdyName').AsString);
      end;
    end;
  finally
    frmZDYHelp.Free;
  end;
end;

procedure TfrmFHSQInPut.shouhuotaitouBtnDnClick(Sender: TObject);
begin
  shouhuotaitou.Text := '';
end;

procedure TfrmFHSQInPut.v1Column14PropertiesButtonClick(Sender: TObject; AButtonIndex: Integer);
begin
  try
    frmCPManageFMSel := TfrmCPManageFMSel.Create(Application);
    with frmCPManageFMSel do
    begin
      if ShowModal = 1 then
      begin
        with Order_Sub do
        begin
          Edit;
          FieldByName('P_CODE').AsString := frmCPManageFMSel.CDS_Main.fieldbyname('CYNo').AsString;
          FieldByName('P_NAME').AsString := frmCPManageFMSel.CDS_Main.fieldbyname('CYname').AsString;
          FieldByName('FHKHPM').AsString := frmCPManageFMSel.CDS_Main.fieldbyname('CYname').AsString;
        end;

      end;
    end;
  finally
    frmCPManageFMSel.Free;
  end;
end;

procedure TfrmFHSQInPut.zeClick(Sender: TObject);
begin
  with Self.Order_Sub do
  begin
    Append;
    FieldByName('SQPS').Value := 0;
    FieldByName('SQQTY').Value := 0;
    FieldByName('SQPRICE').Value := 0;
    FieldByName('SQMONEY').Value := 0;
//            FieldByName('P_NAME').Value := frmSQKCHZSelList.CDS_Main.fieldbyname('C_CodeName').Value;

    Post;
  end;
end;

end.

