unit U_FinishedClothStatistical;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, StdCtrls, ExtCtrls, ComCtrls, ToolWin, cxStyles, cxCustomData,
  cxGraphics, cxFilter, cxData, cxDataStorage, cxEdit, DB, cxDBData, ADODB,
  cxGridCustomPopupMenu, cxGridPopupMenu, cxGridLevel, cxClasses, cxControls,
  cxGridCustomView, cxGridCustomTableView, cxGridTableView, cxGridDBTableView,
  cxGrid, DBClient, cxCheckBox, cxCalendar, cxSplitter, RM_Dataset, RM_System,
  RM_Common, RM_Class, RM_GridReport, RM_e_Xls, Menus, MovePanel, cxTextEdit,
  cxContainer, cxCurrencyEdit, BtnEdit, RM_e_main, RM_e_htm, RM_e_Graphic,
  RM_e_Jpeg, RM_e_txt, RM_e_csv, RM_E_llPDF, Math, Clipbrd, cxPC, cxLookAndFeels,
  cxLookAndFeelPainters, dxSkinsCore, dxSkinsDefaultPainters, dxSkinscxPCPainter,
  cxNavigator, dxSkinBlack, dxSkinBlue, dxSkinBlueprint, dxSkinCaramel,
  dxSkinCoffee, dxSkinDarkRoom, dxSkinDarkSide, dxSkinDevExpressDarkStyle,
  dxSkinDevExpressStyle, dxSkinFoggy, dxSkinGlassOceans, dxSkinHighContrast,
  dxSkiniMaginary, dxSkinLilian, dxSkinLiquidSky, dxSkinLondonLiquidSky,
  dxSkinMcSkin, dxSkinMetropolis, dxSkinMetropolisDark, dxSkinMoneyTwins,
  dxSkinOffice2007Black, dxSkinOffice2007Blue, dxSkinOffice2007Green,
  dxSkinOffice2007Pink, dxSkinOffice2007Silver, dxSkinOffice2010Black,
  dxSkinOffice2010Blue, dxSkinOffice2010Silver, dxSkinOffice2013DarkGray,
  dxSkinOffice2013LightGray, dxSkinOffice2013White, dxSkinPumpkin, dxSkinSeven,
  dxSkinSevenClassic, dxSkinSharp, dxSkinSharpPlus, dxSkinSilver,
  dxSkinSpringTime, dxSkinStardust, dxSkinSummer2008, dxSkinTheAsphaltWorld,
  dxSkinValentine, dxSkinVS2010, dxSkinWhiteprint, dxSkinXmas2008Blue;

type
  TfrmFinishedClothStatistical = class(TForm)
    ToolBar1: TToolBar;
    TBClose: TToolButton;
    Panel1: TPanel;
    BegDate: TDateTimePicker;
    EndDate: TDateTimePicker;
    cxGridPopupMenu1: TcxGridPopupMenu;
    ADOQueryCmd: TADOQuery;
    ADOQueryMain: TADOQuery;
    ADOQueryTemp: TADOQuery;
    DS_Main: TDataSource;
    Label8: TLabel;
    PopupMenu1: TPopupMenu;
    N1: TMenuItem;
    N2: TMenuItem;
    RM2: TRMGridReport;
    RMDB_Main: TRMDBDataSet;
    ADOQueryPrint: TADOQuery;
    MovePanel2: TMovePanel;
    RMXLSExport1: TRMXLSExport;
    IsJYTime: TCheckBox;
    N3: TMenuItem;
    X1: TMenuItem;
    Order_Main: TClientDataSet;
    DCheG: TEdit;
    Label1: TLabel;
    Button1: TButton;
    Label2: TLabel;
    Label3: TLabel;
    Label4: TLabel;
    Label5: TLabel;
    Label6: TLabel;
    Label7: TLabel;
    cxGrid3: TcxGrid;
    Tv3: TcxGridDBTableView;
    cxGridDBColumn1: TcxGridDBColumn;
    Tv3Column3: TcxGridDBColumn;
    Tv3Column4: TcxGridDBColumn;
    v3Column1: TcxGridDBColumn;
    v3Column2: TcxGridDBColumn;
    v3Column3: TcxGridDBColumn;
    Tv3Column1: TcxGridDBColumn;
    Tv3Column2: TcxGridDBColumn;
    cxGridLevel2: TcxGridLevel;
    cxGridPopupMenu2: TcxGridPopupMenu;
    DS_MJID: TDataSource;
    CDS_MJID: TClientDataSet;
    cxStyleRepository1: TcxStyleRepository;
    cxStyle1: TcxStyle;
    Panel2: TPanel;
    Button2: TButton;
    Label9: TLabel;
    Label10: TLabel;
    Label11: TLabel;
    Label14: TLabel;
    Label12: TLabel;
    Label15: TLabel;
    Label16: TLabel;
    Label19: TLabel;
    Label21: TLabel;
    Label22: TLabel;
    Label23: TLabel;
    Label24: TLabel;
    Label25: TLabel;
    Label27: TLabel;
    Label28: TLabel;
    JYLen1: TEdit;
    person1: TEdit;
    person2: TEdit;
    JYLen2: TEdit;
    JYLen3: TEdit;
    person3: TEdit;
    person4: TEdit;
    JYLen4: TEdit;
    person5: TEdit;
    JYLen5: TEdit;
    jyid: TEdit;
    Label13: TLabel;
    jylen: TEdit;
    Label17: TLabel;
    Tv3Column5: TcxGridDBColumn;
    cxStyleRepository2: TcxStyleRepository;
    cxStyle2: TcxStyle;
    Button3: TButton;
    procedure FormClose(Sender: TObject; var Action: TCloseAction);
    procedure FormCreate(Sender: TObject);
    procedure TBCloseClick(Sender: TObject);
    procedure TBFindClick(Sender: TObject);
    procedure FormShow(Sender: TObject);
    procedure N1Click(Sender: TObject);
    procedure N2Click(Sender: TObject);
    procedure MJIDKeyPress(Sender: TObject; var Key: Char);
    procedure conNOKeyPress(Sender: TObject; var Key: Char);
    procedure MJStr2Change(Sender: TObject);
    procedure RKOrdIDKeyPress(Sender: TObject; var Key: Char);
    procedure N3Click(Sender: TObject);
    procedure X1Click(Sender: TObject);
    procedure DCheGClick(Sender: TObject);
    procedure Button1Click(Sender: TObject);
    procedure Button2Click(Sender: TObject);
    procedure Button3Click(Sender: TObject);
    procedure JYLen1MouseDown(Sender: TObject; Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
    procedure JYLen2MouseDown(Sender: TObject; Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
    procedure JYLen3MouseDown(Sender: TObject; Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
    procedure JYLen4MouseDown(Sender: TObject; Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
    procedure JYLen5MouseDown(Sender: TObject; Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
    procedure person1Click(Sender: TObject);
    procedure person2Click(Sender: TObject);
    procedure person3Click(Sender: TObject);
    procedure person4Click(Sender: TObject);
    procedure person5Click(Sender: TObject);
  private
    DQdate: TDateTime;
    FLeft, FTop: Integer;
    CurrentPage, RecordsNumber: Integer;
    function CheckData(CKType: string): Boolean; //校验数据
    procedure InitGrid();
    procedure InitForm();
    function Savedata(): Boolean;
    { Private declarations }
  public
    FFInt: Integer;
    canshu1: string;
    { Public declarations }
  end;

var
  frmFinishedClothStatistical: TfrmFinishedClothStatistical;

implementation

uses
  U_DataLink, U_Fun, U_MJEdit, U_ZDYHelp, U_SysLogHelp, U_SCPerson;

{$R *.dfm}
function TfrmFinishedClothStatistical.CheckData(CKType: string): Boolean;
var
  mvalue, i4: Double;
begin
  try

    if Trim(CKType) = '提交' then
    begin
      if jyid.Text = '' then
        raise Exception.Create('请选择要修改的数据!');
      if (strtofloatdef(trim(JYLen1.Text), 0) + strtofloatdef(trim(JYLen2.Text), 0) + strtofloatdef(trim(JYLen3.Text), 0) + strtofloatdef(trim(JYLen4.Text), 0) + strtofloatdef(trim(JYLen5.Text), 0)) <= 0.00 then
        raise Exception.Create('总长度不能小于等于0!');

      if (Trim(JYLen1.Text) <> '') or (Trim(JYLen2.Text) <> '') or (Trim(JYLen3.Text) <> '') or (Trim(JYLen4.Text) <> '') or (Trim(JYLen5.Text) <> '') then
      begin
        if (strtofloatdef(trim(JYLen1.Text), 0) > 400) or (strtofloatdef(trim(JYLen2.Text), 0) > 400) or (strtofloatdef(trim(JYLen3.Text), 0) > 400) or (strtofloatdef(trim(JYLen4.Text), 0) > 400) or (strtofloatdef(trim(JYLen5.Text), 0) > 400) then
          raise Exception.Create('长度不能大于400!');
      end;

      if (person1.Text <> '') and (JYLen1.Text = '') then
      begin
        raise Exception.Create('选了挡车工1长度不能为0!');
      end;
      if (person2.Text <> '') and (JYLen2.Text = '') then
      begin
        raise Exception.Create('选了挡车工2长度不能为0!');
      end;
      if (person3.Text <> '') and (JYLen3.Text = '') then
      begin
        raise Exception.Create('选了挡车工3长度不能为0!');
      end;
      if (person4.Text <> '') and (JYLen4.Text = '') then
      begin
        raise Exception.Create('选了挡车工4长度不能为0!');
      end;
      if (person5.Text <> '') and (JYLen5.Text = '') then
      begin
        raise Exception.Create('选了挡车工5长度不能为0!');
      end;

      if (strtofloatdef(trim(JYLen1.Text), 0) = 0) and (strtofloatdef(trim(JYLen2.Text), 0) = 0) and (strtofloatdef(trim(JYLen3.Text), 0) = 0) and (strtofloatdef(trim(JYLen4.Text), 0) = 0) and (strtofloatdef(trim(JYLen5.Text), 0) = 0) then
        raise Exception.Create('长度不能为0!!');

      if (strtofloatdef(trim(JYLen.Text), 0) <= 0.00) then
        raise Exception.Create('长度不能小于等于0!!');
//      if (strtofloatdef(trim(JYLen2.Text), 0) + strtofloatdef(trim(JYLen1.Text), 0) + strtofloatdef(trim(JYLen3.Text), 0) + strtofloatdef(trim(JYLen4.Text), 0) + strtofloatdef(trim(JYLen5.Text), 0)) > (strtofloatdef(trim(JYLen.Text), 0) + 3) then
//        raise Exception.Create('产量和不能大于检验长度!!');
      if (strtofloatdef(trim(JYLen2.Text), 0) + strtofloatdef(trim(JYLen1.Text), 0) + strtofloatdef(trim(JYLen3.Text), 0) + strtofloatdef(trim(JYLen4.Text), 0) + strtofloatdef(trim(JYLen5.Text), 0)) = (strtofloatdef(trim(JYLen.Text), 0)) then
        raise Exception.Create('产量和需等于检验长度!!');
//      if Edit7.Text <> '' then
//      begin
//        if I3 <> 0 then
//        begin
//          i4 := RoundFloat(I3 + 0.1, 0);
//        end
//        else
//        begin
//          i4 := StrToFloatDEF(JYLen1.TEXT, 0);
//        end;
//
//        if (JYLen5.Text <> '') and (JYLen4.Text <> '') and (JYLen3.Text <> '') and (JYLen2.Text <> '') and (JYLen1.Text <> '') then
//        begin
//          JYLen5.Text := FloatToStr(i4 - strtofloat(jylen4.Text) - strtofloat(jylen3.Text) - strtofloat(jylen2.Text) - strtofloat(jylen1.Text));
//        end
//        else if (JYLen4.Text <> '') and (JYLen3.Text <> '') and (JYLen2.Text <> '') and (JYLen1.Text <> '') then
//        begin
//          JYLen4.Text := FloatToStr(i4 - strtofloat(jylen3.Text) - strtofloat(jylen2.Text) - strtofloat(jylen1.Text));
//        end
//        else if (JYLen3.Text <> '') and (JYLen2.Text <> '') and (JYLen1.Text <> '') then
//        begin
//          JYLen3.Text := FloatToStr(i4 - strtofloat(jylen2.Text) - strtofloat(jylen1.Text));
//        end
//        else if (JYLen2.Text <> '') and (JYLen1.Text <> '') then
//        begin
//          JYLen2.Text := FloatToStr(i4 - strtofloat(jylen1.Text));
//        end
//        else if (JYLen1.Text <> '') then
//        begin
//          JYLen1.Text := FloatToStr(i4);
//        end;
//      end;

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

procedure TfrmFinishedClothStatistical.FormClose(Sender: TObject; var Action: TCloseAction);
begin
  Action := caFree;
end;

procedure TfrmFinishedClothStatistical.FormCreate(Sender: TObject);
begin

  DQdate := SGetServerDate(ADOQueryTemp);
end;

procedure TfrmFinishedClothStatistical.TBCloseClick(Sender: TObject);
begin
  Close;
end;

procedure TfrmFinishedClothStatistical.InitGrid();
var
  FEndTime, FBegTime: string;
begin

  if IsJYTime.Checked then
  begin
    FBegTime := quotedstr(FormatDateTime('yyyy-MM-dd', BegDate.DateTime));
    FEndTime := quotedstr(FormatDateTime('yyyy-MM-dd', enddate.DateTime + 1));
  end
  else
  begin
    FBegTime := '';
    FEndTime := '';
  end;

  try
    ADOQueryMain.DisableControls;
    with ADOQueryMain do
    begin
      Filtered := False;
      Close;
      sql.Clear;
      sql.Add('exec P_CK_Cloth_DCG');
      sql.Add('@DCheG=' + QuotedStr(Trim(DCheG.Text)));
      sql.Add(',@FBegTime=' + FBegTime);
      sql.Add(',@FEndTime=' + FEndTime);

      Open;
    end;
    SCreateCDS20(ADOQueryMain, Order_Main);
    SInitCDSData20(ADOQueryMain, Order_Main);

    Label6.Caption := Trim(Order_Main.fieldbyname('LenHZ').AsString) + '米';
    Label7.Caption := Trim(Order_Main.fieldbyname('PS').AsString) + '卷';

    with ADOQueryTemp do
    begin
      Close;
      SQL.Clear;
      sql.Add('exec P_CK_Cloth_DCG_MX');
      sql.Add('@DCheG=' + QuotedStr(Trim(DCheG.Text)));
      sql.Add(',@FBegTime=' + FBegTime);
      sql.Add(',@FEndTime=' + FEndTime);
//     ShowMessage(SQL.Text);
      Open;
    end;
    SCreateCDS20(ADOQueryTemp, CDS_MJID);
    SInitCDSData20(ADOQueryTemp, CDS_MJID);

    //MovePanel2.Visible := false;
  finally
    ADOQueryMain.EnableControls;
    //MovePanel2.Visible := false;
  end;
end;

procedure TfrmFinishedClothStatistical.InitForm();
var
  fsj: string;
begin
  BegDate.DateTime := SGetServerDateTime(ADOQueryTemp);
  EndDate.DateTime := SGetServerDateTime(ADOQueryTemp)
end;

procedure TfrmFinishedClothStatistical.TBFindClick(Sender: TObject);
var
  fsj, fwhere: string;
begin

end;

procedure TfrmFinishedClothStatistical.FormShow(Sender: TObject);
begin

  InitForm();
end;

procedure TfrmFinishedClothStatistical.N1Click(Sender: TObject);
begin
  SelOKNo(Order_Main, True);
end;

procedure TfrmFinishedClothStatistical.N2Click(Sender: TObject);
begin
  SelOKNo(Order_Main, False);
end;

function TfrmFinishedClothStatistical.Savedata(): Boolean;
var
  maxno, LLID: string;
  HXPS: Integer;
  HXQty, HXMQty: Double;
begin
  HXPS := 0;
  HXQty := 0;
  with ADOQueryTemp do
  begin
    Close;
    sql.Clear;
    sql.Add('select Top 1 * from Contract_Cloth_LL where OrdSubId=''' + Trim(Order_Main.fieldbyname('SubId').AsString) + '''');
    sql.Add(' and FirstName=''' + Trim(Order_Main.fieldbyname('AOrddefstr4').AsString) + '''');
    Open;
  end;
  LLID := Trim(ADOQueryTemp.fieldbyname('LLID').AsString);
  if Trim(LLID) = '' then
  begin
    Result := False;
    Application.MessageBox('没有相对应的加工厂!', '提示', 0);
    Exit;
  end;
  try
    ADOQueryCmd.Connection.BeginTrans;
    if GetLSNo(ADOQueryCmd, maxno, 'HX', 'Contract_Cloth_BefChkHX', 2, 1) = False then
    begin
      Result := False;
      ADOQueryCmd.Connection.RollbackTrans;
      Application.MessageBox('取回修最大号失败!', '提示', 0);
      Exit;
    end;
    with Order_Main do
    begin
      First;
      while not Eof do
      begin
        if Order_Main.FieldByName('SSel').AsBoolean = True then
        begin
          HXPS := HXPS + 1;
          HXQty := HXQty + Order_Main.FieldByName('MJLen').Value;
        end;
        Next;
      end;
    end;
    with ADOQueryCmd do
    begin
      Close;
      sql.Clear;
      sql.Add('');
      Open;
    end;
  except
  end;
end;

procedure TfrmFinishedClothStatistical.MJIDKeyPress(Sender: TObject; var Key: Char);
begin
  if Key = #13 then
  begin
    CurrentPage := 1;
    InitGrid();
  end;
end;

procedure TfrmFinishedClothStatistical.conNOKeyPress(Sender: TObject; var Key: Char);
begin
  if Key = #13 then
  begin
    CurrentPage := 1;
    InitGrid();
  end;
end;

procedure TfrmFinishedClothStatistical.MJStr2Change(Sender: TObject);
begin
  CurrentPage := 1;
  InitGrid();
end;

procedure TfrmFinishedClothStatistical.RKOrdIDKeyPress(Sender: TObject; var Key: Char);
begin
  if Key = #13 then
  begin
    CurrentPage := 1;
    InitGrid();
  end;
end;

procedure TfrmFinishedClothStatistical.N3Click(Sender: TObject);
var
  SSubId, SGangNo: string;
begin

  with Order_Main do
  begin
    SSubId := trim(FieldByName('SubId').AsString);
    Order_Main.DisableControls;
    first;
    while not eof do
    begin
      if SSubId = trim(FieldByName('SubId').AsString) then
      begin
        edit;
        FieldByName('SSel').value := true;
        Post;
      end
      else
      begin
        edit;
        FieldByName('SSel').value := false;
        Post;
      end;
      Next;
    end;
    Order_Main.Locate('SubId', VarArrayOf([SSubId]), []);
    Order_Main.EnableControls;
  end;
end;

procedure TfrmFinishedClothStatistical.X1Click(Sender: TObject);
var
  str, SSubId: string;
  ZChiShu, DQChiShu: integer;
  ISSel: boolean;
begin
  ISSel := true;
  SSubId := trim(Order_Main.FieldByName('SubId').AsString);
  str := '';
  if InputQuery('选择', '请输入数字', str) then
  begin
    ZChiShu := strtointdef(str, 0);
    if ZChiShu <= 0 then
      exit;

    with Order_Main do
    begin

      Order_Main.DisableControls;
      first;
      DQChiShu := 0;
      while not eof do
      begin

        if SSubId = trim(FieldByName('SubId').AsString) then
        begin
          edit;
          FieldByName('SSel').value := ISSel;
          DQChiShu := DQChiShu + 1;
          Post;
        end
        else
        begin
          edit;
          FieldByName('SSel').value := false;
          Post;
        end;
        if DQChiShu = ZChiShu then
          ISSel := false;
        Next;
      end;
      Order_Main.Locate('SubId', VarArrayOf([SSubId]), []);
      Order_Main.EnableControls;
    end;
  end;

end;

procedure TfrmFinishedClothStatistical.DCheGClick(Sender: TObject);
begin
  try
    frmSCPerson := TfrmSCPerson.Create(self);
    with frmSCPerson do
    begin
      FlagStr := 'SCPerson';
      if ShowModal = 1 then
      begin
        DCheG.Text := frmSCPerson.FSDPerson;
      end;
    end;
  finally
    frmSCPerson.Free;
  end;
end;

procedure TfrmFinishedClothStatistical.Button1Click(Sender: TObject);
begin
  if DCheG.Text = '' then
  begin
    Application.MessageBox('请先选择挡车工！', '提示', 0);
    Exit;
  end;
  InitGrid();

end;

procedure TfrmFinishedClothStatistical.Button2Click(Sender: TObject);
begin
  if CDS_MJID.IsEmpty then
  begin
    Exit;
  end;
  with ADOQueryTemp do
  begin
    Close;
    sql.Clear;
    SQL.Add('select * from JY_CLOTH A WHERE A.JYID=' + QuotedStr(trim(CDS_MJID.fieldbyName('JYID').AsString)));
    OPEN;
  end;
  if ADOQueryTemp.FieldByName('JYCRType').AsString = '已出库' then
  begin
    application.MessageBox('该条码已发货,禁止修改！', '提示信息', 0);
    exit;
  end;
  panel2.Visible := True;
  person1.Text := CDS_MJID.fieldbyname('person1').AsString;
  person2.Text := CDS_MJID.fieldbyname('person2').AsString;
  person3.Text := CDS_MJID.fieldbyname('person3').AsString;
  person4.Text := CDS_MJID.fieldbyname('person4').AsString;
  person5.Text := CDS_MJID.fieldbyname('person5').AsString;
  person1.HINT := CDS_MJID.fieldbyname('group1').AsString;
  person2.HINT := CDS_MJID.fieldbyname('group2').AsString;
  person3.HINT := CDS_MJID.fieldbyname('group3').AsString;
  person4.HINT := CDS_MJID.fieldbyname('group4').AsString;
  person5.HINT := CDS_MJID.fieldbyname('group5').AsString;

  JYLen1.Text := CDS_MJID.fieldbyname('JYLen1').AsString;
  JYLen2.Text := CDS_MJID.fieldbyname('JYLen2').AsString;
  JYLen3.Text := CDS_MJID.fieldbyname('JYLen3').AsString;
  JYLen4.Text := CDS_MJID.fieldbyname('JYLen4').AsString;
  JYLen5.Text := CDS_MJID.fieldbyname('JYLen5').AsString;
  jyid.Text := CDS_MJID.fieldbyname('jyid').AsString;
  jyLEN.Text := CDS_MJID.fieldbyname('jyLEN').AsString;
end;

procedure TfrmFinishedClothStatistical.Button3Click(Sender: TObject);
var
  FPERSON1, FPERSON2, FPERSON3, FPERSON4, FPERSON5: string;
  FMETER1, FMETER2, FMETER3, FMETER4, FMETER5: string;
begin
  if CheckData('提交') = False then
  begin

    exit;
  end;
  with ADOQueryCmd do
  begin
    Close;
    SQL.Clear;
    sql.Add('select * from JY_CLOTH WHERE JYID=' + QuotedStr(JYID.Text));

    open;
  end;
  if ADOQueryCmd.IsEmpty = false then
  begin
    FPERSON1 := ADOQueryCmd.FieldByName('Person1').AsString;
    FPERSON2 := ADOQueryCmd.FieldByName('Person2').AsString;
    FPERSON3 := ADOQueryCmd.FieldByName('Person3').AsString;
    FPERSON4 := ADOQueryCmd.FieldByName('Person4').AsString;
    FPERSON5 := ADOQueryCmd.FieldByName('Person5').AsString;

    FMETER1 := ADOQueryCmd.FieldByName('JYLen1').AsString;
    FMETER2 := ADOQueryCmd.FieldByName('JYLen2').AsString;
    FMETER3 := ADOQueryCmd.FieldByName('JYLen3').AsString;
    FMETER4 := ADOQueryCmd.FieldByName('JYLen4').AsString;
    FMETER5 := ADOQueryCmd.FieldByName('JYLen5').AsString;
    with ADOQueryCmd do
    begin
      Edit;
      FieldByName('Person1').Value := trim(Person1.Text);
      FieldByName('Person2').Value := trim(Person2.Text);
      FieldByName('Person3').Value := trim(Person3.Text);
      FieldByName('Person4').Value := trim(Person4.Text);
      FieldByName('Person5').Value := trim(Person5.Text);
      FieldByName('group1').Value := trim(Person1.hint);
      FieldByName('group2').Value := trim(Person2.hint);
      FieldByName('group3').Value := trim(Person3.hint);
      FieldByName('group4').Value := trim(Person4.hint);
      FieldByName('group5').Value := trim(Person5.hint);


      //挡车工长度
      FieldByName('JYLen1').Value := StrToFloatdef(trim(JYLen1.Text), 0);
      FieldByName('JYLen2').Value := StrToFloatdef(trim(JYLen2.Text), 0);
      FieldByName('JYLen3').Value := StrToFloatdef(trim(JYLen3.Text), 0);
      FieldByName('JYLen4').Value := StrToFloatdef(trim(JYLen4.Text), 0);
      FieldByName('JYLen5').Value := StrToFloatdef(trim(JYLen5.Text), 0);
      post;
    end;
  end;

  with ADOQueryTemp do
  begin
    sql.Add('insert into SY_SysLog(operor,opertime,Model,acction,opevent,result) values( ');
    sql.Add(' ' + quotedstr(trim(DName)));
    sql.Add(',getdate() ');
    sql.Add(',' + quotedstr(trim(self.Caption)));
    sql.Add(',' + quotedstr(trim('修改检验数据')));
    sql.Add(',' + quotedstr('卷条码：' + trim(jyid.Text) + FPERSON1 + FMETER1 + ';改为' + person1.Text + JYLEN1.Text + ';' + FPERSON2 + FMETER2 + ';改为' + person2.Text + JYLEN2.Text + ';' + FPERSON3 + FMETER3 + ';改为' + person3.Text + JYLEN3.Text + ';' + FPERSON4 + FMETER4 + ';改为' + person4.Text + JYLEN4.Text + ';' + FPERSON5 + FMETER5 + ';改为' + person5.Text + JYLEN5.Text + ';'));
    sql.Add(',' + quotedstr(trim('成功')));
    sql.Add(')');
    ExecSQL;
  end;
  Panel2.Visible := False;
  InitGrid();
end;

procedure TfrmFinishedClothStatistical.JYLen1MouseDown(Sender: TObject; Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
begin
  if Trim(person1.Text) = '' then
  begin
    raise Exception.Create('先输入挡车工1!');
  end;
end;

procedure TfrmFinishedClothStatistical.JYLen2MouseDown(Sender: TObject; Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
begin
  if Trim(person2.Text) = '' then
  begin
    raise Exception.Create('先输入挡车工2!');
  end;
end;

procedure TfrmFinishedClothStatistical.JYLen3MouseDown(Sender: TObject; Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
begin
  if Trim(person3.Text) = '' then
  begin
    raise Exception.Create('先输入挡车工3!');
  end;
end;

procedure TfrmFinishedClothStatistical.JYLen4MouseDown(Sender: TObject; Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
begin
  if Trim(person4.Text) = '' then
  begin
    raise Exception.Create('先输入挡车工4!');
  end;
end;

procedure TfrmFinishedClothStatistical.JYLen5MouseDown(Sender: TObject; Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
begin
  if Trim(person5.Text) = '' then
  begin
    raise Exception.Create('先输入挡车工5!');
  end;
end;

procedure TfrmFinishedClothStatistical.person1Click(Sender: TObject);
begin
  try
    frmSCPerson := TfrmSCPerson.Create(self);
    with frmSCPerson do
    begin
      FlagStr := 'SCPerson';
      if ShowModal = 1 then
      begin
        PERSON1.Text := frmSCPerson.FSDPerson;
        Person1.Hint := frmSCPerson.CDS_ZB.FieldByName('note').AsString;
      end;
    end;
  finally
    frmSCPerson.Free;
  end;
end;

procedure TfrmFinishedClothStatistical.person2Click(Sender: TObject);
begin
  try
    frmSCPerson := TfrmSCPerson.Create(self);
    with frmSCPerson do
    begin
      FlagStr := 'SCPerson';
      if ShowModal = 1 then
      begin
        PERSON2.Text := frmSCPerson.FSDPerson;
        Person2.Hint := frmSCPerson.CDS_ZB.FieldByName('note').AsString;
      end;
    end;
  finally
    frmSCPerson.Free;
  end;
end;

procedure TfrmFinishedClothStatistical.person3Click(Sender: TObject);
begin
  try
    frmSCPerson := TfrmSCPerson.Create(self);
    with frmSCPerson do
    begin
      FlagStr := 'SCPerson';
      if ShowModal = 1 then
      begin
        PERSON3.Text := frmSCPerson.FSDPerson;
        Person3.Hint := frmSCPerson.CDS_ZB.FieldByName('note').AsString;
      end;
    end;
  finally
    frmSCPerson.Free;
  end;
end;

procedure TfrmFinishedClothStatistical.person4Click(Sender: TObject);
begin
  try
    frmSCPerson := TfrmSCPerson.Create(self);
    with frmSCPerson do
    begin
      FlagStr := 'SCPerson';
      if ShowModal = 1 then
      begin
        PERSON4.Text := frmSCPerson.FSDPerson;
        Person4.Hint := frmSCPerson.CDS_ZB.FieldByName('note').AsString;
      end;
    end;
  finally
    frmSCPerson.Free;
  end;
end;

procedure TfrmFinishedClothStatistical.person5Click(Sender: TObject);
begin
  try
    frmSCPerson := TfrmSCPerson.Create(self);
    with frmSCPerson do
    begin
      FlagStr := 'SCPerson';
      if ShowModal = 1 then
      begin
        PERSON5.Text := frmSCPerson.FSDPerson;
        Person5.Hint := frmSCPerson.CDS_ZB.FieldByName('note').AsString;
      end;
    end;
  finally
    frmSCPerson.Free;
  end;
end;

end.

