unit U_ConInPutXF_YGDJ;

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, cxGridCustomPopupMenu,
  cxGridPopupMenu, cxCurrencyEdit, cxGridBandedTableView,
  cxGridDBBandedTableView;

type
  TfrmConInPutXF_YGDJ = class(TForm)
    ToolBar1: TToolBar;
    TBSave: TToolButton;
    TBClose: TToolButton;
    ADOTemp: TADOQuery;
    DataSource1: TDataSource;
    Order_Sub: TClientDataSet;
    ADOQuery1: TADOQuery;
    Label9: TLabel;
    DEFStr7: TEdit;
    Label10: TLabel;
    ConNo: TEdit;
    Label14: TLabel;
    CustomerNoName: TBtnEditC;
    Label22: TLabel;
    BankFastNo: TEdit;
    Label25: TLabel;
    CPTanLi: TCheckBox;
    CPRanYin: TRadioGroup;
    Label26: TLabel;
    CPRanHouGY: TBtnEditC;
    CPType: TRadioGroup;
    Label27: TLabel;
    CPZHName: TEdit;
    CPCFNo: TEdit;
    Label30: TLabel;
    CPCFBi: TEdit;
    Label2: TLabel;
    conDefstr1: TEdit;
    Label12: TLabel;
    conDefstr2: TEdit;
    Label13: TLabel;
    Label31: TLabel;
    conDefstr3: TEdit;
    conDefstr4: TEdit;
    Label32: TLabel;
    conDefstr8: TEdit;
    conDefstr7: TEdit;
    Label33: TLabel;
    Label34: TLabel;
    conDefstr5: TEdit;
    Label35: TLabel;
    Label36: TLabel;
    Label37: TLabel;
    conDefstr6: TEdit;
    Label38: TLabel;
    Label39: TLabel;
    condefNote1: TEdit;
    Label40: TLabel;
    cxGridPopupMenu1: TcxGridPopupMenu;
    ADOCmd: TADOQuery;
    Label45: TLabel;
    Label47: TLabel;
    ScrollBox1: TScrollBox;
    Label29: TLabel;
    PiChang: TBtnEditC;
    cxStyleRepository1: TcxStyleRepository;
    cxStyle1: TcxStyle;
    Panel5: TPanel;
    Panel3: TPanel;
    ToolBar4: TToolBar;
    ToolButton5: TToolButton;
    ToolButton6: TToolButton;
    cxGrid3: TcxGrid;
    TV3: TcxGridDBBandedTableView;
    TV3XHNo: TcxGridDBBandedColumn;
    TV3PrtCodeName: TcxGridDBBandedColumn;
    TV3Qty: TcxGridDBBandedColumn;
    TV3PRTPrice: TcxGridDBBandedColumn;
    TV3Money: TcxGridDBBandedColumn;
    cxGridLevel2: TcxGridLevel;
    Panel2: TPanel;
    ToolBar3: TToolBar;
    ToolButton3: TToolButton;
    ToolButton4: TToolButton;
    cxGrid2: TcxGrid;
    TV4: TcxGridDBBandedTableView;
    TV4XHNo: TcxGridDBBandedColumn;
    TV4PrtCodeName: TcxGridDBBandedColumn;
    TV4XLQty: TcxGridDBBandedColumn;
    TV4PRTPrice: TcxGridDBBandedColumn;
    TV4Money: TcxGridDBBandedColumn;
    cxGridLevel1: TcxGridLevel;
    Panel7: TPanel;
    Panel4: TPanel;
    ToolBar5: TToolBar;
    ToolButton7: TToolButton;
    ToolButton8: TToolButton;
    cxGrid4: TcxGrid;
    TV2: TcxGridDBBandedTableView;
    cxGridDBBandedColumn19: TcxGridDBBandedColumn;
    cxGridDBBandedColumn20: TcxGridDBBandedColumn;
    TV2Qty: TcxGridDBBandedColumn;
    TV2SunHao: TcxGridDBBandedColumn;
    TV2XLQty: TcxGridDBBandedColumn;
    TV2PRTPrice: TcxGridDBBandedColumn;
    TV2Money: TcxGridDBBandedColumn;
    cxGridLevel3: TcxGridLevel;
    Panel1: TPanel;
    cxGrid1: TcxGrid;
    TV1: TcxGridDBBandedTableView;
    V1XHNo: TcxGridDBBandedColumn;
    V1PrtCodeName: TcxGridDBBandedColumn;
    V1Column3: TcxGridDBBandedColumn;
    V1PRTOrderQty: TcxGridDBBandedColumn;
    V1PRTPrice: TcxGridDBBandedColumn;
    V1ConMXMoney: TcxGridDBBandedColumn;
    V1Huilv: TcxGridDBBandedColumn;
    V1RMBMoney: TcxGridDBBandedColumn;
    cxGrid1Level1: TcxGridLevel;
    DataSource2: TDataSource;
    Order_ZL: TClientDataSet;
    DataSource3: TDataSource;
    Order_MLJG: TClientDataSet;
    DataSource4: TDataSource;
    Order_FL: TClientDataSet;
    DataSource5: TDataSource;
    Order_CBJG: TClientDataSet;
    cxStyle2: TcxStyle;
    V2JHDate: TcxGridDBBandedColumn;
    V3JHDate: TcxGridDBBandedColumn;
    V4JHDate: TcxGridDBBandedColumn;
    V2DHDate: TcxGridDBBandedColumn;
    V2DHQty: TcxGridDBBandedColumn;
    V4DHDate: TcxGridDBBandedColumn;
    V4DHQty: TcxGridDBBandedColumn;
    V3DHDate: TcxGridDBBandedColumn;
    V3DHQty: TcxGridDBBandedColumn;
    Panel6: TPanel;
    Label3: TLabel;
    Label4: TLabel;
    Label5: TLabel;
    Label6: TLabel;
    Label7: TLabel;
    Label8: TLabel;
    Label11: TLabel;
    Label15: TLabel;
    Label1: TLabel;
    Label16: TLabel;
    Label17: TLabel;
    Panel8: TPanel;
    ToolBar6: TToolBar;
    ToolButton9: TToolButton;
    ToolButton10: TToolButton;
    cxGrid5: TcxGrid;
    TV5: TcxGridDBBandedTableView;
    TV5XHNo: TcxGridDBBandedColumn;
    TV5PrtCodeName: TcxGridDBBandedColumn;
    TV5Qty: TcxGridDBBandedColumn;
    TV5PRTPrice: TcxGridDBBandedColumn;
    tv5Money: TcxGridDBBandedColumn;
    V5JHDate: TcxGridDBBandedColumn;
    V5DHDate: TcxGridDBBandedColumn;
    V5DHQty: TcxGridDBBandedColumn;
    cxGridLevel4: TcxGridLevel;
    YLYGMoney: TcxCurrencyEdit;
    MLJGMoney: TcxCurrencyEdit;
    FLMoney: TcxCurrencyEdit;
    JGMoney: TcxCurrencyEdit;
    YGLiRun: TcxCurrencyEdit;
    BGYSFee: TcxCurrencyEdit;
    OtherMoney: TcxCurrencyEdit;
    ZJYGMoney: TcxCurrencyEdit;
    KPYGMoney: TcxCurrencyEdit;
    GLMoney: TcxCurrencyEdit;
    SOrdQty8: TcxCurrencyEdit;
    Label18: TLabel;
    KPFeeLV: TcxCurrencyEdit;
    procedure TBCloseClick(Sender: TObject);
    procedure FormShow(Sender: TObject);
    procedure TBSaveClick(Sender: TObject);
    procedure v1PRTColorPropertiesButtonClick(Sender: TObject;
      AButtonIndex: Integer);
    procedure v1Column1PropertiesButtonClick(Sender: TObject;
      AButtonIndex: Integer);
    procedure v1OrderUnitPropertiesButtonClick(Sender: TObject;
      AButtonIndex: Integer);
    procedure v1PriceUnitPropertiesButtonClick(Sender: TObject;
      AButtonIndex: Integer);
    procedure CPRanHouGYBtnDnClick(Sender: TObject);
    procedure v1PRTPricePropertiesEditValueChanged(Sender: TObject);
    procedure v1Column5PropertiesButtonClick(Sender: TObject;
      AButtonIndex: Integer);
    procedure v1Column7PropertiesButtonClick(Sender: TObject;
      AButtonIndex: Integer);
    procedure v1Column8PropertiesButtonClick(Sender: TObject;
      AButtonIndex: Integer);
    procedure v1Column6PropertiesButtonClick(Sender: TObject;
      AButtonIndex: Integer);
    procedure v1PRTMFPropertiesButtonClick(Sender: TObject;
      AButtonIndex: Integer);
    procedure v1PRTKZPropertiesButtonClick(Sender: TObject;
      AButtonIndex: Integer);
    procedure v1PRTHXPropertiesButtonClick(Sender: TObject;
      AButtonIndex: Integer);
    procedure V1HuilvPropertiesEditValueChanged(Sender: TObject);
    procedure ToolButton7Click(Sender: TObject);
    procedure ToolButton5Click(Sender: TObject);
    procedure ToolButton3Click(Sender: TObject);
    procedure ToolButton9Click(Sender: TObject);
    procedure TV2QtyPropertiesEditValueChanged(Sender: TObject);
    procedure TV3QtyPropertiesEditValueChanged(Sender: TObject);
    procedure TV4XLQtyPropertiesEditValueChanged(Sender: TObject);
    procedure TV5QtyPropertiesEditValueChanged(Sender: TObject);
    procedure BGYSFeePropertiesEditValueChanged(Sender: TObject);
    procedure OtherMoneyPropertiesEditValueChanged(Sender: TObject);
    procedure KPYGMoneyPropertiesEditValueChanged(Sender: TObject);
    procedure ToolButton6Click(Sender: TObject);
    procedure ToolButton4Click(Sender: TObject);
    procedure ToolButton8Click(Sender: TObject);
    procedure ToolButton10Click(Sender: TObject);
    procedure TV2StylesGetContentStyle(Sender: TcxCustomGridTableView;
      ARecord: TcxCustomGridRecord; AItem: TcxCustomGridTableItem;
      out AStyle: TcxStyle);
    procedure TV3StylesGetContentStyle(Sender: TcxCustomGridTableView;
      ARecord: TcxCustomGridRecord; AItem: TcxCustomGridTableItem;
      out AStyle: TcxStyle);
    procedure TV4StylesGetContentStyle(Sender: TcxCustomGridTableView;
      ARecord: TcxCustomGridRecord; AItem: TcxCustomGridTableItem;
      out AStyle: TcxStyle);
    procedure TV5StylesGetContentStyle(Sender: TcxCustomGridTableView;
      ARecord: TcxCustomGridRecord; AItem: TcxCustomGridTableItem;
      out AStyle: TcxStyle);
    procedure SOrdQty8PropertiesEditValueChanged(Sender: TObject);
    procedure KPFeeLVPropertiesEditValueChanged(Sender: TObject);
  private
    procedure InitData();
    procedure ZDYHelp(FButn:TcxButtonEdit;LType:string);
    function  SaveData():Boolean;
    function  SaveDataSubOne():Boolean;
    function  SaveDataMain():Boolean;
    function SaveDataSubMore():Boolean;
    procedure HJ();
    { Private declarations }
  public
    PState,CopyInt:Integer;
    FMainId,FSubid,FFMainId,FST,FZT:String;
    FXS:Integer;
    procedure GetKgQty();
    procedure GetKgPrice();
    { Public declarations }
  end;

var
  frmConInPutXF_YGDJ: TfrmConInPutXF_YGDJ;
  newh:hwnd;
implementation
uses
  U_DataLink,U_ZDYHelp,U_Fun,U_ZDYHelpSel,U_ZdyAttachment,U_FjList_RZ;//U_CPManageCX

{$R *.dfm}
procedure TfrmConInPutXF_YGDJ.HJ();
begin
  if BGYSFee.Text='' then BGYSFee.Text:='0';
  if OtherMoney.Text='' then OtherMoney.Text:='0';
  if KPYGMoney.Text='' then KPYGMoney.Text:='0';
  if SOrdQty8.Text='' then SOrdQty8.Text:='0.05';
  if KPFeeLV.Text='' then KPFeeLV.Text:='0.06';
  if TV2.DataController.Summary.FooterSummaryValues[2]<>NULL then
  YLYGMoney.Text:=FloatToStr(TV2.DataController.Summary.FooterSummaryValues[2])
  else
  YLYGMoney.Text:='0';
  if TV3.DataController.Summary.FooterSummaryValues[1]<>NULL then
  MLJGMoney.Text:=FloatToStr(TV3.DataController.Summary.FooterSummaryValues[1])
  else
  MLJGMoney.Text:='0';
  if TV4.DataController.Summary.FooterSummaryValues[1]<>NULL then
  FLMoney.Text:=FloatToStr(TV4.DataController.Summary.FooterSummaryValues[1])
  else
  FLMoney.Text:='0';
  if TV5.DataController.Summary.FooterSummaryValues[1]<>NULL then
  JGMoney.Text:=FloatToStr(TV5.DataController.Summary.FooterSummaryValues[1])
  else
  JGMoney.Text:='0';
  if TV1.DataController.Summary.FooterSummaryValues[2]<>NULL then
  begin
    GLMoney.Text:=FloatToStr(TV1.DataController.Summary.FooterSummaryValues[2]*strtofloat(SOrdQty8.Text));
    KPYGMoney.Text:=FloatToStr(TV1.DataController.Summary.FooterSummaryValues[2]*strtofloat(KPFeeLV.Text));
  end
  else
  begin
    GLMoney.Text:='0';
    KPYGMoney.Text:='0';
  end;
  ZJYGMoney.Text:=floattostr(strtofloat(YLYGMoney.Text)+strtofloat(MLJGMoney.Text)+strtofloat(FLMoney.Text)+strtofloat(JGMoney.Text));
  if TV1.DataController.Summary.FooterSummaryValues[2]<>NULL then
  begin
    YGLiRun.Text:=floattostr(TV1.DataController.Summary.FooterSummaryValues[2]-strtofloat(ZJYGMoney.Text)-strtofloat(BGYSFee.Text)
                -strtofloat(OtherMoney.Text)-strtofloat(KPYGMoney.Text)-strtofloat(GLMoney.Text));
  end
  else
  begin
    YGLiRun.Text:=floattostr(0-strtofloat(ZJYGMoney.Text)-strtofloat(BGYSFee.Text)
                -strtofloat(OtherMoney.Text)-strtofloat(KPYGMoney.Text)-strtofloat(GLMoney.Text));
  end;
end;

procedure TfrmConInPutXF_YGDJ.TBCloseClick(Sender: TObject);
begin
  Close;
  WriteCxBandedGrid('预估成本1',Tv1,'预估成本管理');
  WriteCxBandedGrid('预估成本2',Tv2,'预估成本管理');
  WriteCxBandedGrid('预估成本3',Tv3,'预估成本管理');
  WriteCxBandedGrid('预估成本4',Tv4,'预估成本管理');
  WriteCxBandedGrid('预估成本5',Tv5,'预估成本管理');
end;

procedure TfrmConInPutXF_YGDJ.InitData();
var i:Integer;
begin
  with ADOQuery1 do
  begin
    Close;
    sql.Clear;
    sql.Add('select A.* ');
    sql.Add(',DEFStr7=(select Top 1 B.DEFStr7 from KH_Zdy_Attachment B where B.Type=''KHName'' and B.ZdyName=A.CustomerNoName)');
    sql.add(' from JYOrderCon_Main A where A.MainId='''+Trim(FMainId)+'''');
    Open;
  end;
  ConNo.Text:=Trim(ADOQuery1.fieldbyname('ConNo').AsString);
  CustomerNoName.Text:=Trim(ADOQuery1.fieldbyname('CustomerNoName').AsString);
  DEFStr7.Text:=Trim(ADOQuery1.fieldbyname('DEFStr7').AsString);
  with ADOQuery1 do
  begin
    Close;
    SQL.Clear;
    sql.Add('select A.* ');
    SQL.Add(',DHDate=(select Top 1 C.CRTime from CK_SXPB_CR C inner join JYOrder_Main D on C.OrdMainidRK=D.Mainid ');
    sql.Add('where D.conSubid=A.Subid and C.CKName=''坯布'' and C.CRFlag=''入库'' and C.CRType=''采购入库'' and C.SPName=A.PrtCodeName order by C.CRTime desc)');
    SQL.Add(',DHQty=(select Sum(Qty) from CK_SXPB_CR C inner join JYOrder_Main D on C.OrdMainidRK=D.Mainid ');
    sql.Add('where D.conSubid=A.Subid and C.CKName=''坯布'' and C.CRFlag=''入库'' and C.CRType=''采购入库'' and C.SPName=A.PrtCodeName)');
    sql.Add('from JYOrderCon_YGCB A ');
    sql.Add('where A.Subid='''+Trim(FSubid)+'''');
    sql.add(' and A.CBType=''主料''');
    Open;
  end;
  SCreateCDS20(ADOQuery1,Order_ZL);
  SInitCDSData20(ADOQuery1,Order_ZL);
  with ADOQuery1 do
  begin
    Close;
    SQL.Clear;
    sql.Add('select A.* ');
    SQL.Add(',DHDate=(select Top 1 C.CRTime from CK_SXPB_CR C inner join JYOrder_Main D on C.OrdMainidRK=D.Mainid ');
    sql.Add('where D.conSubid=A.Subid and C.CKName in (''待检布'',''外加工'') and C.CRFlag=''入库'' and C.CRType=''加工完成'' and C.SPName=A.PrtCodeName order by C.CRTime desc)');
    SQL.Add(',DHQty=(select Sum(Qty) from CK_SXPB_CR C inner join JYOrder_Main D on C.OrdMainidRK=D.Mainid ');
    sql.Add('where D.conSubid=A.Subid and C.CKName in (''待检布'',''外加工'') and C.CRFlag=''入库'' and C.CRType=''加工完成'' and C.SPName=A.PrtCodeName)');
    sql.Add('from JYOrderCon_YGCB A ');
    sql.Add('where A.Subid='''+Trim(FSubid)+'''');
    sql.add(' and CBType=''面料加工''');
    Open;
  end;
  SCreateCDS20(ADOQuery1,Order_MLJG);
  SInitCDSData20(ADOQuery1,Order_MLJG);
  with ADOQuery1 do
  begin
    Close;
    SQL.Clear;
    sql.Add('select A.* ');
    SQL.Add(',DHDate=(select Top 1 C.CRTime from CK_SXPB_CR C inner join JYOrder_Main D on C.OrdMainidRK=D.Mainid ');
    sql.Add('where D.conSubid=A.Subid and C.CKName=''辅料'' and C.CRFlag=''入库'' and C.CRType=''采购入库'' and C.SPName=A.PrtCodeName order by C.CRTime desc)');
    SQL.Add(',DHQty=(select Sum(Qty) from CK_SXPB_CR C inner join JYOrder_Main D on C.OrdMainidRK=D.Mainid ');
    sql.Add('where D.conSubid=A.Subid and C.CKName=''辅料'' and C.CRFlag=''入库'' and C.CRType=''采购入库'' and C.SPName=A.PrtCodeName)');
    sql.Add('from JYOrderCon_YGCB A ');
    sql.Add('where Subid='''+Trim(FSubid)+'''');
    sql.add(' and CBType=''辅料''');
    Open;
  end;
  SCreateCDS20(ADOQuery1,Order_FL);
  SInitCDSData20(ADOQuery1,Order_FL);
  with ADOQuery1 do
  begin
    Close;
    SQL.Clear;
    sql.Add('select A.* ');
    SQL.Add(',DHDate=(select Top 1 C.CRTime from CK_SXPB_CR C inner join JYOrder_Main D on C.OrdMainidRK=D.Mainid ');
    sql.Add('where D.conSubid=A.Subid and C.CKName in (''裁剪'',''车工'',''包装'') and C.CRFlag=''入库'' and C.CKName=A.PrtCodeName order by C.CRTime desc)');
    SQL.Add(',DHQty=(select Sum(Qty) from CK_SXPB_CR C inner join JYOrder_Main D on C.OrdMainidRK=D.Mainid ');
    sql.Add('where D.conSubid=A.Subid and C.CKName in (''裁剪'',''车工'',''包装'') and C.CRFlag=''入库'' and C.CKName=A.PrtCodeName)');
    sql.Add('from JYOrderCon_YGCB A ');
    sql.Add('where Subid='''+Trim(FSubid)+'''');
    sql.add(' and CBType=''成品加工''');
    Open;
  end;
  SCreateCDS20(ADOQuery1,Order_CBJG);
  SInitCDSData20(ADOQuery1,Order_CBJG);
  with ADOQuery1 do
  begin
    Close;
    SQL.Clear;
    sql.Add('select *,XHNo=cast(0 as int),RMBMoney=ConMXMoney*HuiLV from JYOrderCon_Sub ');
    sql.Add('where Subid='''+Trim(FSubid)+'''');
    Open;
  end;
  SCreateCDS20(ADOQuery1,Order_Sub);
  SInitCDSData20(ADOQuery1,Order_Sub);
  YLYGMoney.Text:=FloatToStr(ADOQuery1.fieldbyname('YLYGMoney').asfloat);
  FLMoney.Text:=FloatToStr(ADOQuery1.fieldbyname('FLMoney').asfloat);
  MLJGMoney.Text:=FloatToStr(ADOQuery1.fieldbyname('MLJGMoney').asfloat);
  BGYSFee.Text:=FloatToStr(ADOQuery1.fieldbyname('BGYSFee').asfloat);
  JGMoney.Text:=FloatToStr(ADOQuery1.fieldbyname('JGMoney').asfloat);
  OtherMoney.Text:=FloatToStr(ADOQuery1.fieldbyname('OtherMoney').asfloat);
  ZJYGMoney.Text:=FloatToStr(ADOQuery1.fieldbyname('ZJYGMoney').asfloat);
  KPYGMoney.Text:=FloatToStr(ADOQuery1.fieldbyname('KPYGMoney').asfloat);
  GLMoney.Text:=FloatToStr(ADOQuery1.fieldbyname('GLMoney').asfloat);
  YGLiRun.Text:=FloatToStr(ADOQuery1.fieldbyname('YGLiRun').asfloat);
  if ADOQuery1.IsEmpty=false then
  begin
    SOrdQty8.Text:=FloatToStr(ADOQuery1.fieldbyname('SOrdQty8').asfloat);
    KPFeeLV.Text:=FloatToStr(ADOQuery1.fieldbyname('KPFeeLV').asfloat);
  end
  else
  begin
    SOrdQty8.Text:='0.05';
    KPFeeLV.Text:='0.06';
  end;
  with Order_Sub do
  begin
    first;
    i:=1;
    while not eof do
    begin
      edit;
      FieldByName('XHNo').Value:=i;
      i:=i+1;
      next;
    end;
  end;
end;

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

procedure TfrmConInPutXF_YGDJ.FormShow(Sender: TObject);
begin
  ReadCxBandedGrid('预估成本1',Tv1,'预估成本管理');
  ReadCxBandedGrid('预估成本2',Tv2,'预估成本管理');
  ReadCxBandedGrid('预估成本3',Tv3,'预估成本管理');
  ReadCxBandedGrid('预估成本4',Tv4,'预估成本管理');
  ReadCxBandedGrid('预估成本5',Tv5,'预估成本管理');
  if FZT='1' then
  begin
    V2JHDate.visible:=False;
    V3JHDate.visible:=False;
    V4JHDate.visible:=False;
    V5JHDate.Visible:=false;
    ToolBar5.Visible:=true;
    ToolBar3.Visible:=true;
    ToolBar4.Visible:=true;
    ToolBar6.Visible:=true;
  end;
  if FZT='0' then
  begin
    V2JHDate.visible:=true;
    V3JHDate.visible:=true;
    V4JHDate.visible:=true;
    V5JHDate.Visible:=true;
    ToolBar5.Visible:=false;
    ToolBar3.Visible:=false;
    ToolBar4.Visible:=false;
    ToolBar6.Visible:=false;
  end;
  if FZT='3' then
  begin
    V2JHDate.visible:=true;
    V3JHDate.visible:=true;
    V4JHDate.visible:=true;
    V5JHDate.Visible:=true;
    TBSave.Visible:=true;
    ToolBar5.Visible:=false;
    ToolBar3.Visible:=false;
    ToolBar4.Visible:=false;
    ToolBar6.Visible:=false;
  end;
  InitData();
end;

function TfrmConInPutXF_YGDJ.SaveData():Boolean;
var
  maxno:String;
  fconNO,fmxType:string;
begin
  try
    ADOCmd.Connection.BeginTrans;
    ///保存子表
    with Order_Sub do
    begin
      First;
      while not Eof do
      begin
        with ADOCmd do
        begin
          Close;
          SQL.Clear;
          sql.Add('select * from JYOrderCon_Sub where MainId='''+Trim(FMainId)+'''');
          sql.Add(' and SubId='''+Trim(FSubid)+'''');
          Open;
        end;
        with ADOCmd do
        begin
          Edit;
          fieldbyname('Huilv').Value:=Order_Sub.Fieldbyname('Huilv').AsFloat;
          FieldByName('editer').Value:=Trim(DName);
          FieldByName('editDate').Value:=SGetServerDate(ADOQuery1);
          fieldbyname('YLYGMoney').Value:=StrToFloat(YLYGMoney.Text);
          fieldbyname('FLMoney').Value:=StrToFloat(FLMoney.Text);
          fieldbyname('MLJGMoney').Value:=StrToFloat(MLJGMoney.Text);
          fieldbyname('BGYSFee').Value:=StrToFloat(BGYSFee.Text);
          fieldbyname('JGMoney').Value:=StrToFloat(JGMoney.Text);
          fieldbyname('OtherMoney').Value:=StrToFloat(OtherMoney.Text);
          fieldbyname('ZJYGMoney').Value:=StrToFloat(ZJYGMoney.Text);
          fieldbyname('KPYGMoney').Value:=StrToFloat(KPYGMoney.Text);
          fieldbyname('GLMoney').Value:=StrToFloat(GLMoney.Text);
          fieldbyname('YGLiRun').Value:=StrToFloat(YGLiRun.Text);
          FieldByName('SOrdQty8').Value:=StrToFloat(SOrdQty8.Text);
          FieldByName('KPFeeLV').Value:=StrToFloat(KPFeeLV.Text);
          Post;
        end;
        Next;
      end;
    end;
    with Order_ZL do
    begin
      First;
      while not Eof do
      begin
        if Trim(Order_ZL.fieldbyname('YGID').AsString)='' then
        begin
          if GetLSNo(ADOTemp,maxno,'ZL','JYOrderCon_YGCB',4,1)=False then
          begin
            ADOCmd.Connection.RollbackTrans;
            Application.MessageBox('取子流水号失败！','提示',0);
            Exit;
          end;
        end else
        begin
          maxno:=Trim(Order_ZL.fieldbyname('YGID').AsString);
        end;
        with ADOCmd do
        begin
          Close;
          SQL.Clear;
          sql.Add('select * from JYOrderCon_YGCB where YGID='''+Trim(maxno)+'''');
          Open;
        end;
        with ADOCmd do
        begin
          if isempty then
            Append
          else
            Edit;
          FieldByName('MainId').Value:=Trim(FMainId);
          FieldByName('SubId').Value:=Trim(FSubid);
          fieldbyname('YGID').Value:=Trim(maxno);
          FieldByName('CBType').Value:='主料';
          SSetSaveDataCDSBandNew(ADOCmd,Tv2,Order_ZL,'JYOrderCon_YGCB',0);
          fieldbyname('Qty').Value:=Order_ZL.Fieldbyname('Qty').AsFloat;
          fieldbyname('SunHao').Value:=Order_ZL.Fieldbyname('SunHao').AsFloat;
          fieldbyname('XLQty').Value:=Order_ZL.Fieldbyname('XLQty').AsFloat;
          fieldbyname('PRTPrice').Value:=Order_ZL.Fieldbyname('PRTPrice').AsFloat;
          fieldbyname('Money').Value:=Order_ZL.Fieldbyname('Money').AsFloat;
          Post;
        end;
        Order_ZL.Edit;
        Order_ZL.FieldByName('YGID').Value:=Trim(maxno);
        //Order_ZL.Post;
        Next;
      end;
    end;
    with Order_MLJG do
    begin
      First;
      while not Eof do
      begin
        if Trim(Order_MLJG.fieldbyname('YGID').AsString)='' then
        begin
          if GetLSNo(ADOTemp,maxno,'ML','JYOrderCon_YGCB',4,1)=False then
          begin
            ADOCmd.Connection.RollbackTrans;
            Application.MessageBox('取子流水号失败！','提示',0);
            Exit;
          end;
        end else
        begin
          maxno:=Trim(Order_MLJG.fieldbyname('YGID').AsString);
        end;
        with ADOCmd do
        begin
          Close;
          SQL.Clear;
          sql.Add('select * from JYOrderCon_YGCB where YGID='''+Trim(maxno)+'''');
          Open;
        end;
        with ADOCmd do
        begin
          if isempty then
            Append
          else
            Edit;
          FieldByName('MainId').Value:=Trim(FMainId);
          FieldByName('SubId').Value:=Trim(FSubid);
          fieldbyname('YGID').Value:=Trim(maxno);
          FieldByName('CBType').Value:='面料加工';
          SSetSaveDataCDSBandNew(ADOCmd,Tv3,Order_MLJG,'JYOrderCon_YGCB',0);
          fieldbyname('Qty').Value:=Order_MLJG.Fieldbyname('Qty').AsFloat;
          fieldbyname('PRTPrice').Value:=Order_MLJG.Fieldbyname('PRTPrice').AsFloat;
          fieldbyname('Money').Value:=Order_MLJG.Fieldbyname('Money').AsFloat;
          Post;
        end;
        Order_MLJG.Edit;
        Order_MLJG.FieldByName('YGID').Value:=Trim(maxno);
        //Order_MLJG.Post;
        Next;
      end;
    end;
    with Order_FL do
    begin
      First;
      while not Eof do
      begin
        if Trim(Order_FL.fieldbyname('YGID').AsString)='' then
        begin
          if GetLSNo(ADOTemp,maxno,'FL','JYOrderCon_YGCB',4,1)=False then
          begin
            ADOCmd.Connection.RollbackTrans;
            Application.MessageBox('取子流水号失败！','提示',0);
            Exit;
          end;
        end else
        begin
          maxno:=Trim(Order_FL.fieldbyname('YGID').AsString);
        end;
        with ADOCmd do
        begin
          Close;
          SQL.Clear;
          sql.Add('select * from JYOrderCon_YGCB where YGID='''+Trim(maxno)+'''');
          Open;
        end;
        with ADOCmd do
        begin
          if isempty then
            Append
          else
            Edit;
          FieldByName('MainId').Value:=Trim(FMainId);
          FieldByName('SubId').Value:=Trim(FSubid);
          fieldbyname('YGID').Value:=Trim(maxno);
          FieldByName('CBType').Value:='辅料';
          SSetSaveDataCDSBandNew(ADOCmd,Tv4,Order_FL,'JYOrderCon_YGCB',0);
          fieldbyname('XLQty').Value:=Order_FL.Fieldbyname('XLQty').AsFloat;
          fieldbyname('PRTPrice').Value:=Order_FL.Fieldbyname('PRTPrice').AsFloat;
          fieldbyname('Money').Value:=Order_FL.Fieldbyname('Money').AsFloat;
          Post;
        end;
        Order_FL.Edit;
        Order_FL.FieldByName('YGID').Value:=Trim(maxno);
        //Order_FL.Post;
        Next;
      end;
    end;
    with Order_CBJG do
    begin
      First;
      while not Eof do
      begin
        if Trim(Order_CBJG.fieldbyname('YGID').AsString)='' then
        begin
          if GetLSNo(ADOTemp,maxno,'CP','JYOrderCon_YGCB',4,1)=False then
          begin
            ADOCmd.Connection.RollbackTrans;
            Application.MessageBox('取子流水号失败！','提示',0);
            Exit;
          end;
        end else
        begin
          maxno:=Trim(Order_CBJG.fieldbyname('YGID').AsString);
        end;
        with ADOCmd do
        begin
          Close;
          SQL.Clear;
          sql.Add('select * from JYOrderCon_YGCB where YGID='''+Trim(maxno)+'''');
          Open;
        end;
        with ADOCmd do
        begin
          if isempty then
            Append
          else
            Edit;
          FieldByName('MainId').Value:=Trim(FMainId);
          FieldByName('SubId').Value:=Trim(FSubid);
          fieldbyname('YGID').Value:=Trim(maxno);
          FieldByName('CBType').Value:='成品加工';
          SSetSaveDataCDSBandNew(ADOCmd,Tv5,Order_CBJG,'JYOrderCon_YGCB',0);
          fieldbyname('Qty').Value:=Order_CBJG.Fieldbyname('Qty').AsFloat;
          fieldbyname('PRTPrice').Value:=Order_CBJG.Fieldbyname('PRTPrice').AsFloat;
          fieldbyname('Money').Value:=Order_CBJG.Fieldbyname('Money').AsFloat;
          Post;
        end;
        Order_CBJG.Edit;
        Order_CBJG.FieldByName('YGID').Value:=Trim(maxno);
        //Order_CBJG.Post;
        Next;
      end;
    end;
    ADOCmd.Connection.CommitTrans;
    Result:=True;
  except;
    ADOCmd.Connection.RollbackTrans;
    Application.MessageBox('保存失败！','提示',0);
    Result:=False;
  end;
end;

function TfrmConInPutXF_YGDJ.SaveDataMain():Boolean;
var
  maxno:String;
begin
  try
    ADOCmd.Connection.BeginTrans;
    ///保存主表
    with ADOCmd do
    begin
      Close;
      sql.Clear;
      SQL.Add('select * from JYOrder_Main where MainId='''+Trim(FMainId)+'''');
      Open;
    end;
    with ADOCmd do
    begin
      if Trim(FMainId)='' then
      begin
        Append;
        maxno:=Trim(FFMainId);
      end
      else begin
        maxno:=Trim(FMainId);
        Edit;
      end;
      FieldByName('MainId').Value:=Trim(maxno);
      SSetsaveSqlNew(ADOCmd,'JYOrder_Main',ScrollBox1,2);
      if PState=1 then
      begin
        FieldByName('OrdUpDate').Value:=SGetServerDateTime(ADOTemp);
      end;
      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);
    ADOCmd.Connection.CommitTrans;
    Result:=True;
  except
    Result:=False;
    ADOCmd.Connection.RollbackTrans;
    Application.MessageBox('保存失败！','提示',0);
  end;
end;

function TfrmConInPutXF_YGDJ.SaveDataSubOne():Boolean;
begin
  
end;

function TfrmConInPutXF_YGDJ.SaveDataSubMore():Boolean;
begin
 
end;

procedure TfrmConInPutXF_YGDJ.TBSaveClick(Sender: TObject);
begin
  Toolbar1.SetFocus;
  if Trim(ConNo.Text)='' then
  begin
    Application.MessageBox('合同号不能为空！','提示',0);
    Exit;
  end;
  if SaveData() then
  begin
    Application.MessageBox('保存成功！','提示',0);
    ModalResult:=1;
  end;
end;

procedure TfrmConInPutXF_YGDJ.v1PRTColorPropertiesButtonClick(Sender: TObject;
  AButtonIndex: Integer);
begin
  try
    frmZDYHelp:=TfrmZDYHelp.Create(Application);
    with frmZDYHelp do
    begin
      flag:='OrdColor';
      flagname:='颜色';
      V1Name.Caption:='中文名称';
      V1Note.Caption:='英文名称';
      fnote:=True;
      MainType:=Trim(DName);
      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 TfrmConInPutXF_YGDJ.v1Column1PropertiesButtonClick(Sender: TObject;
  AButtonIndex: Integer);
type
  TMyFunc = function(App:Tapplication; FormH:hwnd; FormID:integer;
                  Language: integer; WinStyle:integer;
                  GCode: Pchar; GName: Pchar; DataBase:Pchar;Title:PChar;
                  Parameters1:PChar;Parameters2:PChar;Parameters3:PChar;Parameters4:PChar;
                  Parameters5:PChar;Parameters6:PChar;Parameters7:PChar;Parameters8:PChar;
                  Parameters9:PChar;Parameters10:PChar;DataBaseStr:PChar):hwnd;stdcall;
var
  Tf: TMyFunc;
  Tp: TFarProc;
  Th:Thandle;
  LabInt,labname:String;
begin
  //if PPInt=2 then Exit;
  Ddatabase:=StringOfChar(' ', 32);
  Th := LoadLibrary('LabelSet.dll');
  if Th > 0 then
  begin
    try
      Tp := GetProcAddress(Th, 'GetDllForm');
      if Tp <> nil then
      begin
        Tf := TMyFunc(Tp);
        newh:=Tf(Application,0,2,0,0,
          PChar(DCode),
          PChar(DName),
          PChar(Ddatabase),
          PChar('标签模版设置'),
          PChar(''),
          PChar(''),
          '','','','','','','','',PChar(DConString)
          );
          if Trim(PChar(Ddatabase))<>'' then
          begin
            Ddatabase:=Trim(PChar(Ddatabase));
            LabInt:=Trim( LeftBStr(Ddatabase,Pos('|',Ddatabase)-1) ) ;
            labname:=Trim(RightBStr(Ddatabase,Length(Ddatabase)-Pos('|',Ddatabase) ) );
            with Order_Sub do
            begin
              Edit;
              FieldByName('SLbName').Value:=labname;
              FieldByName('SLbInt').Value:=LabInt;
            end;
          end;
      end
      else
      begin
        ShowMessage('打印执行错误');
      end;
    finally
    // FreeLibrary();
    end;
  end
  else
  begin
    ShowMessage('找不到'+Trim('LabelSet.dll'));
  end;

end;

procedure TfrmConInPutXF_YGDJ.v1OrderUnitPropertiesButtonClick(Sender: TObject;
  AButtonIndex: Integer);
var
  mvalue,FMF,FKZ,FXS,FOrdUnit:string;
  FReal:Double;
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);
        //FOrdUnit:=Trim(ClientDataSet1.fieldbyname('ZDYName').AsString);
      end;
    end;
  finally
    frmZDYHelp.Free;
  end;
  GetKgQty();
  GetKgPrice();
end;
procedure TfrmConInPutXF_YGDJ.GetKgQty();
begin

end;
procedure TfrmConInPutXF_YGDJ.GetKgPrice();
var
  mvalue,FMF,FKZ,FXS,FOrdUnit,FOrdPrice:string;
  FReal:Double;
begin
 
end;

procedure TfrmConInPutXF_YGDJ.v1PriceUnitPropertiesButtonClick(Sender: TObject;
  AButtonIndex: Integer);
begin
  try
    frmZDYHelp:=TfrmZDYHelp.Create(Application);
    with frmZDYHelp do
    begin
      flag:='PriceUnit';
      flagname:='价格单位';
      {if Trim(DParameters1)<>'高权限' then
      begin
        TBAdd.Visible:=False;
        TBEdit.Visible:=False;
        TBDel.Visible:=False;
      end; }
      if ShowModal=1 then
      begin
        Self.Order_Sub.Edit;
        Self.Order_Sub.FieldByName('PriceUnit').Value:=Trim(ClientDataSet1.fieldbyname('ZDYName').AsString);
      end;
    end;
  finally
    frmZDYHelp.Free;
  end;
end;

procedure TfrmConInPutXF_YGDJ.CPRanHouGYBtnDnClick(Sender: TObject);
begin
  TBtnEditC(Sender).Text:='';
  TBtnEditC(Sender).TxtCode:='';
end;

procedure TfrmConInPutXF_YGDJ.v1PRTPricePropertiesEditValueChanged(
  Sender: TObject);
var
  mvalue:string;
begin
  mvalue:=TcxTextEdit(Sender).EditingText;
  if Trim(mvalue)='' then
  begin
    mvalue:='0';
  end;
  with Order_Sub do
  begin
    Edit;
    FieldByName('PRTPrice').Value:=mvalue;
  end;
  GetKgPrice();
end;

procedure TfrmConInPutXF_YGDJ.v1Column5PropertiesButtonClick(Sender: TObject;
  AButtonIndex: Integer);
begin
  try
    frmZDYHelp:=TfrmZDYHelp.Create(Application);
    with frmZDYHelp do
    begin
      flag:='PBName';
      flagname:='产品名称';
      fnote:=true;
      v1note.Caption:='编号';
      if ShowModal=1 then
      begin
        Order_Sub.Edit;
        Order_Sub.fieldbyname('PRTCodeName').Value:=Trim(ClientDataSet1.fieldbyname('ZDYName').AsString);
        Order_Sub.fieldbyname('PRTCode').Value:=Trim(ClientDataSet1.fieldbyname('note').AsString);
      end;
    end;
  finally
    frmZDYHelp.Free;
  end;
end;

procedure TfrmConInPutXF_YGDJ.v1Column7PropertiesButtonClick(Sender: TObject;
  AButtonIndex: Integer);
begin
  try
    frmZDYHelp:=TfrmZDYHelp.Create(Application);
    with frmZDYHelp do
    begin
      flag:='MPRTMF';
      flagname:='门幅信息';
      if ShowModal=1 then
      begin
        Order_Sub.Edit;
        Order_Sub.fieldbyname('PRTMF').Value:=Trim(ClientDataSet1.fieldbyname('ZDYName').AsString);
     //   Order_Sub.fieldbyname('PRTCode').Value:=Trim(ClientDataSet1.fieldbyname('ZDYNo').AsString);
      end;
    end;
  finally
    frmZDYHelp.Free;
  end;
  tv1.Controller.EditingController.ShowEdit();
end;

procedure TfrmConInPutXF_YGDJ.v1Column8PropertiesButtonClick(Sender: TObject;
  AButtonIndex: Integer);
begin
  try
    frmZDYHelp:=TfrmZDYHelp.Create(Application);
    with frmZDYHelp do
    begin
      flag:='MPRTKZ';
      flagname:='克重信息';
      if ShowModal=1 then
      begin
        Order_Sub.Edit;
        Order_Sub.fieldbyname('PRTKZ').Value:=Trim(ClientDataSet1.fieldbyname('ZDYName').AsString);
     //   Order_Sub.fieldbyname('PRTCode').Value:=Trim(ClientDataSet1.fieldbyname('ZDYNo').AsString);
      end;
    end;
  finally
    frmZDYHelp.Free;
  end;
  tv1.Controller.EditingController.ShowEdit();
end;

procedure TfrmConInPutXF_YGDJ.v1Column6PropertiesButtonClick(Sender: TObject;
  AButtonIndex: Integer);
begin
  try
    frmZDYHelp:=TfrmZDYHelp.Create(Application);
    with frmZDYHelp do
    begin
      flag:='PRTspec';
      flagname:='规格成份';
      if ShowModal=1 then
      begin
        Order_Sub.Edit;
        Order_Sub.fieldbyname('PRTspec').Value:=Trim(ClientDataSet1.fieldbyname('ZDYName').AsString);
      end;
    end;
  finally
    frmZDYHelp.Free;
  end;
end;

procedure TfrmConInPutXF_YGDJ.v1PRTMFPropertiesButtonClick(Sender: TObject;
  AButtonIndex: Integer);
begin
  try
    frmZDYHelp:=TfrmZDYHelp.Create(Application);
    with frmZDYHelp do
    begin
      flag:='PRTMF';
      flagname:='门幅';
      if ShowModal=1 then
      begin
        Order_Sub.Edit;
        Order_Sub.fieldbyname('PRTMF').Value:=Trim(ClientDataSet1.fieldbyname('ZDYName').AsString);
      end;
    end;
  finally
    frmZDYHelp.Free;
  end;
end;

procedure TfrmConInPutXF_YGDJ.v1PRTKZPropertiesButtonClick(Sender: TObject;
  AButtonIndex: Integer);
begin
  try
    frmZDYHelp:=TfrmZDYHelp.Create(Application);
    with frmZDYHelp do
    begin
      flag:='PRTKZ';
      flagname:='克重';
      if ShowModal=1 then
      begin
        Order_Sub.Edit;
        Order_Sub.fieldbyname('PRTKZ').Value:=Trim(ClientDataSet1.fieldbyname('ZDYName').AsString);
      end;
    end;
  finally
    frmZDYHelp.Free;
  end;
end;

procedure TfrmConInPutXF_YGDJ.v1PRTHXPropertiesButtonClick(Sender: TObject;
  AButtonIndex: Integer);
begin
  try
    frmZDYHelp:=TfrmZDYHelp.Create(Application);
    with frmZDYHelp do
    begin
      flag:='PRTHX';
      flagname:='花型';
      if ShowModal=1 then
      begin
        Order_Sub.Edit;
        Order_Sub.fieldbyname('PRTHX').Value:=Trim(ClientDataSet1.fieldbyname('ZDYName').AsString);
      end;
    end;
  finally
    frmZDYHelp.Free;
  end;
end;

procedure TfrmConInPutXF_YGDJ.V1HuilvPropertiesEditValueChanged(
  Sender: TObject);
var mavlue:string;
begin
  mavlue:=TcxTextEdit(Sender).EditingText;
  if mavlue='' then
  mavlue:='0';
  with Order_Sub do
  begin
    edit;
    FieldByName('Huilv').Value:=mavlue;
    post;
  end;
  with Order_Sub do
  begin
    edit;
    FieldByName('RMBMoney').Value:=FieldByName('Huilv').AsFloat*FieldByName('ConMXMoney').AsFloat;
    post;
  end;
  tv1.Controller.EditingController.ShowEdit();
  HJ();
end;

procedure TfrmConInPutXF_YGDJ.ToolButton7Click(Sender: TObject);
var i:Integer;
begin
  i:=Order_ZL.RecordCount;
  with Order_ZL do
  begin
    Append;
    FieldByName('XHNo').AsInteger:=i+1;
    post;
  end;
end;

procedure TfrmConInPutXF_YGDJ.ToolButton5Click(Sender: TObject);
var i:Integer;
begin
  i:=Order_MLJG.RecordCount;
  with Order_MLJG do
  begin
    Append;
    FieldByName('XHNo').AsInteger:=i+1;
    post;
  end;
end;

procedure TfrmConInPutXF_YGDJ.ToolButton3Click(Sender: TObject);
var i:Integer;
begin
  i:=Order_FL.RecordCount;
  with Order_FL do
  begin
    Append;
    FieldByName('XHNo').AsInteger:=i+1;
    post;
  end;
end;

procedure TfrmConInPutXF_YGDJ.ToolButton9Click(Sender: TObject);
var i:Integer;
begin
  i:=Order_CBJG.RecordCount;
  with Order_CBJG do
  begin
    Append;
    FieldByName('XHNo').AsInteger:=i+1;
    post;
  end;
end;

procedure TfrmConInPutXF_YGDJ.TV2QtyPropertiesEditValueChanged(
  Sender: TObject);
var mavlue,FFieldName:string;
begin
  mavlue:=TcxTextEdit(Sender).EditingText;
  FFieldName:=Tv2.Controller.FocusedColumn.DataBinding.FilterFieldName;
  if mavlue='' then
  mavlue:='0';
  with Order_ZL do
  begin
    edit;
    FieldByName(FFieldName).Value:=mavlue;
    post;
  end;
  with Order_ZL do
  begin
    edit;
    FieldByName('XLQty').Value:=FieldByName('Qty').AsFloat*FieldByName('SunHao').AsFloat;
    FieldByName('Money').Value:=FieldByName('Qty').AsFloat*FieldByName('SunHao').AsFloat*FieldByName('PRTPrice').AsFloat;
    post;
  end;
  tv2.Controller.EditingController.ShowEdit();
  HJ();
end;

procedure TfrmConInPutXF_YGDJ.TV3QtyPropertiesEditValueChanged(
  Sender: TObject);
var mavlue,FFieldName:string;
begin
  mavlue:=TcxTextEdit(Sender).EditingText;
  FFieldName:=Tv3.Controller.FocusedColumn.DataBinding.FilterFieldName;
  if mavlue='' then
  mavlue:='0';
  with Order_MLJG do
  begin
    edit;
    FieldByName(FFieldName).Value:=mavlue;
    post;
  end;
  with Order_MLJG do
  begin
    edit;
    FieldByName('Money').Value:=FieldByName('Qty').AsFloat*FieldByName('PRTPrice').AsFloat;
    post;
  end;
  tv3.Controller.EditingController.ShowEdit();
  HJ();
end;

procedure TfrmConInPutXF_YGDJ.TV4XLQtyPropertiesEditValueChanged(
  Sender: TObject);
var mavlue,FFieldName:string;
begin
  mavlue:=TcxTextEdit(Sender).EditingText;
  FFieldName:=Tv4.Controller.FocusedColumn.DataBinding.FilterFieldName;
  if mavlue='' then
  mavlue:='0';
  with Order_FL do
  begin
    edit;
    FieldByName(FFieldName).Value:=mavlue;
    post;
  end;
  with Order_FL do
  begin
    edit;
    FieldByName('Money').Value:=FieldByName('XLQty').AsFloat*FieldByName('PRTPrice').AsFloat;
    post;
  end;
  tv4.Controller.EditingController.ShowEdit();
  HJ();
end;

procedure TfrmConInPutXF_YGDJ.TV5QtyPropertiesEditValueChanged(
  Sender: TObject);
var mavlue,FFieldName:string;
begin
  mavlue:=TcxTextEdit(Sender).EditingText;
  FFieldName:=Tv5.Controller.FocusedColumn.DataBinding.FilterFieldName;
  if mavlue='' then
  mavlue:='0';
  with Order_CBJG do
  begin
    edit;
    FieldByName(FFieldName).Value:=mavlue;
    post;
  end;
  with Order_CBJG do
  begin
    edit;
    FieldByName('Money').Value:=FieldByName('Qty').AsFloat*FieldByName('PRTPrice').AsFloat;
    post;
  end;
  tv5.Controller.EditingController.ShowEdit();
  HJ();
end;

procedure TfrmConInPutXF_YGDJ.BGYSFeePropertiesEditValueChanged(
  Sender: TObject);
var mavlue:string;
begin
  mavlue:=TcxCurrencyEdit(Sender).EditingText;
  if mavlue='' then mavlue:='0';
  BGYSFee.Text:=mavlue;
  HJ();
end;

procedure TfrmConInPutXF_YGDJ.OtherMoneyPropertiesEditValueChanged(
  Sender: TObject);
var mavlue:string;
begin
  mavlue:=TcxCurrencyEdit(Sender).EditingText;
  if mavlue='' then mavlue:='0';
  OtherMoney.Text:=mavlue;
  HJ();
end;

procedure TfrmConInPutXF_YGDJ.KPYGMoneyPropertiesEditValueChanged(
  Sender: TObject);
var mavlue:string;
begin
  mavlue:=TcxCurrencyEdit(Sender).EditingText;
  if mavlue='' then mavlue:='0';
  KPYGMoney.Text:=mavlue;
  HJ();
end;

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

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

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

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

procedure TfrmConInPutXF_YGDJ.TV2StylesGetContentStyle(
  Sender: TcxCustomGridTableView; ARecord: TcxCustomGridRecord;
  AItem: TcxCustomGridTableItem; out AStyle: TcxStyle);
var
  id,id10:Integer;
begin
  Id:=Tv2.GetColumnByFieldName('JHDate').Index;
  Id10:=Tv2.GetColumnByFieldName('DHDate').Index;
  if ARecord.Values[id10]<>NULL then Exit;
  if ARecord.Values[id]-SGetServerDate(ADOQuery1)<7 then
    AStyle:=DataLink_TradeManage.Red;
end;

procedure TfrmConInPutXF_YGDJ.TV3StylesGetContentStyle(
  Sender: TcxCustomGridTableView; ARecord: TcxCustomGridRecord;
  AItem: TcxCustomGridTableItem; out AStyle: TcxStyle);
var
  id,id10:Integer;
begin
  Id:=Tv3.GetColumnByFieldName('JHDate').Index;
  Id10:=Tv3.GetColumnByFieldName('DHDate').Index;
  if ARecord.Values[id10]<>NULL then Exit;
  if ARecord.Values[id]-SGetServerDate(ADOQuery1)<7 then
    AStyle:=DataLink_TradeManage.Red;
end;

procedure TfrmConInPutXF_YGDJ.TV4StylesGetContentStyle(
  Sender: TcxCustomGridTableView; ARecord: TcxCustomGridRecord;
  AItem: TcxCustomGridTableItem; out AStyle: TcxStyle);
var
  id,id10:Integer;
begin
  Id:=Tv4.GetColumnByFieldName('JHDate').Index;
  Id10:=Tv4.GetColumnByFieldName('DHDate').Index;
  if ARecord.Values[id10]<>NULL then Exit;
  if ARecord.Values[id]-SGetServerDate(ADOQuery1)<7 then
    AStyle:=DataLink_TradeManage.Red;
end;

procedure TfrmConInPutXF_YGDJ.TV5StylesGetContentStyle(
  Sender: TcxCustomGridTableView; ARecord: TcxCustomGridRecord;
  AItem: TcxCustomGridTableItem; out AStyle: TcxStyle);
var
  id,id10:Integer;
begin
  Id:=Tv5.GetColumnByFieldName('JHDate').Index;
  Id10:=Tv5.GetColumnByFieldName('DHDate').Index;
  if ARecord.Values[id10]<>NULL then Exit;
  if ARecord.Values[id]-SGetServerDate(ADOQuery1)<7 then
    AStyle:=DataLink_TradeManage.Red;
end;

procedure TfrmConInPutXF_YGDJ.SOrdQty8PropertiesEditValueChanged(
  Sender: TObject);
var mavlue:string;
begin
  mavlue:=TcxCurrencyEdit(Sender).EditingText;
  if mavlue='' then mavlue:='0';
  SOrdQty8.Text:=mavlue;
  HJ();
end;

procedure TfrmConInPutXF_YGDJ.KPFeeLVPropertiesEditValueChanged(
  Sender: TObject);
var mavlue:string;
begin
  mavlue:=TcxCurrencyEdit(Sender).EditingText;
  if mavlue='' then mavlue:='0';
  KPFeeLV.Text:=mavlue;
  HJ();
end;

end.
