unit U_TatPlanInPut; 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, cxDropDownEdit, StrUtils, cxPC, ShellAPI, cxCalendar, Math, cxLookAndFeels, cxLookAndFeelPainters, dxBarBuiltInMenu, cxNavigator, dxSkinsCore, dxSkinsDefaultPainters, dxDateRanges, U_BaseInput, System.ImageList, Vcl.ImgList, Vcl.Menus; type TfrmTatPlanInPut = class(TfrmBaseInput) ToolBar1: TToolBar; TBSave: TToolButton; TBClose: TToolButton; ScrollBox1: TScrollBox; Label1: TLabel; Label2: TLabel; OrdDate: TDateTimePicker; Label3: TLabel; Label14: TLabel; ADOQueryTemp: TADOQuery; Label18: TLabel; Panel2: TPanel; Label22: TLabel; ADOQueryCmd: TADOQuery; Label5: TLabel; DlyDate: TDateTimePicker; Label8: TLabel; Label12: TLabel; OrdPieceLen: TEdit; OrdPiece: TEdit; Label13: TLabel; OrdQty: TEdit; Label16: TLabel; cxPageControl1: TcxPageControl; CDS_2: TClientDataSet; DS_1: TDataSource; CDS_1: TClientDataSet; DS_2: TDataSource; Label26: TLabel; Label31: TLabel; OrdSNote: TRichEdit; Label47: TLabel; C_GramWeight: TEdit; C_Width: TEdit; C_Name: TEdit; Label43: TLabel; lbl2: TLabel; CustName: TBtnEditC; C_Code: TBtnEditC; ConNo: TBtnEditC; Saleser: TEdit; OurCoName: TBtnEditC; Label7: TLabel; OrderNo: TEdit; C_Spec: TRichEdit; OrdType: TComboBox; Label4: TLabel; FtyCoName: TBtnEditC; ToolButton8: TToolButton; Label6: TLabel; Label9: TLabel; C_FinishLatitudeDensity: TEdit; C_MachLatitudeDensity: TEdit; Label10: TLabel; C_FinishLongitudeDensity: TEdit; Label11: TLabel; C_YarnQty: TEdit; Label15: TLabel; Label17: TLabel; C_LatitudeSpec: TEdit; C_LongitudeSpec: TEdit; Label19: TLabel; C_ReedNo: TEdit; cxGrid2: TcxGrid; Tv2: TcxGridDBTableView; v2Column10: TcxGridDBColumn; cxGridDBColumn1: TcxGridDBColumn; v2Column2: TcxGridDBColumn; v2Column5: TcxGridDBColumn; v2Column6: TcxGridDBColumn; cxGridLevel1: TcxGridLevel; Panel1: TPanel; cxPageControl2: TcxPageControl; cxGrid1: TcxGrid; TV1: TcxGridDBTableView; cxGridDBColumn3: TcxGridDBColumn; cxGridDBColumn4: TcxGridDBColumn; cxGridDBColumn5: TcxGridDBColumn; cxGridDBColumn7: TcxGridDBColumn; cxGridDBColumn8: TcxGridDBColumn; cxGridLevel2: TcxGridLevel; Panel3: TPanel; Panel4: TPanel; ToolBar2: TToolBar; ToolButton1: TToolButton; ToolButton2: TToolButton; Label20: TLabel; Panel5: TPanel; Panel6: TPanel; Label21: TLabel; ToolBar3: TToolBar; ToolButton3: TToolButton; ToolButton4: TToolButton; TV1Column1: TcxGridDBColumn; Tv2Column1: TcxGridDBColumn; TV1Column2: TcxGridDBColumn; Tv2Column2: TcxGridDBColumn; ToolButton5: TToolButton; ToolButton6: TToolButton; Label23: TLabel; C_MachLongitudeDensity: TEdit; Label24: TLabel; C_ReedQty1: TEdit; C_ReedQty2: TEdit; Label25: TLabel; Label27: TLabel; C_YarnQty2: TEdit; C_YarnQty1: TEdit; Label28: TLabel; Label29: TLabel; C_Width2: TEdit; C_Width1: TEdit; Label30: TLabel; Label32: TLabel; C_FinishGramWeight: TEdit; Label33: TLabel; C_FinishWidth: TEdit; Label34: TLabel; WB_Code: TBtnEditC; WB_Spec: TEdit; procedure TBCloseClick(Sender: TObject); procedure FormShow(Sender: TObject); procedure TBSaveClick(Sender: TObject); procedure cxGridDBColumn1PropertiesButtonClick(Sender: TObject; AButtonIndex: Integer); procedure v2Column11PropertiesButtonClick(Sender: TObject; AButtonIndex: Integer); procedure OrdPieceLenChange(Sender: TObject); procedure OrdPieceChange(Sender: TObject); procedure C_CodeKeyPress(Sender: TObject; var Key: Char); procedure ConNoKeyPress(Sender: TObject; var Key: Char); procedure MCTypeBtnUpClick(Sender: TObject); procedure CustNameBtnUpClick(Sender: TObject); procedure C_CodeBtnUpClick(Sender: TObject); procedure ConNoBtnUpClick(Sender: TObject); procedure CustNameBtnDnClick(Sender: TObject); procedure OurCoNameBtnUpClick(Sender: TObject); procedure FtyCoNameBtnUpClick(Sender: TObject); procedure ToolButton2Click(Sender: TObject); procedure ToolButton1Click(Sender: TObject); procedure ToolButton3Click(Sender: TObject); procedure ToolButton4Click(Sender: TObject); procedure ToolButton5Click(Sender: TObject); procedure ToolButton6Click(Sender: TObject); procedure cxGridDBColumn4PropertiesButtonClick(Sender: TObject; AButtonIndex: Integer); private FXS, FGridFlag: Integer; procedure InitData(); procedure CALCYarnQty(); function SaveData(): Boolean; procedure InitClothYarn(MC_Code: string); { Private declarations } public PState, FCopyInt: Integer; FConNo, FMainId, FSubId: string; { Public declarations } end; var frmTatPlanInPut: TfrmTatPlanInPut; newh: hwnd; implementation uses U_DataLink, U_ZDYHelp, U_RTFun, U_TatClothInfoSel, U_CompanySel, U_YarnInfoSel; {$R *.dfm} procedure TfrmTatPlanInPut.InitClothYarn(MC_Code: string); begin with ADOQueryTemp do begin Close; sql.Clear; sql.Add('select A.* from Bs_Cloth_Info A'); sql.Add(' where A.C_Code=''' + Trim(MC_Code) + ''''); Open; end; WB_Code.Text := ADOQueryTemp.FieldByName('WB_Code').AsString; WB_Spec.Text := ADOQueryTemp.FieldByName('WB_Spec').AsString; with ADOQueryTemp do begin Close; sql.Clear; sql.Add('select A.*,MainId=cast('''' as varchar(30)),SubId=cast('''' as varchar(30)) from BS_Cloth_Yarn A inner join Bs_Cloth_Info B on A.BCIID=B.BCIID'); sql.Add(' where A.YRType=''经丝'' and B.C_Code=''' + Trim(MC_Code) + ''''); Open; end; SCreateCDS(ADOQueryTemp, CDS_1); SInitCDSData(ADOQueryTemp, CDS_1); with ADOQueryTemp do begin Close; sql.Clear; sql.Add('select A.*,MainId=cast('''' as varchar(30)),SubId=cast('''' as varchar(30)) from BS_Cloth_Yarn A inner join Bs_Cloth_Info B on A.BCIID=B.BCIID'); sql.Add(' where A.YRType=''纬丝'' and B.C_Code=''' + Trim(MC_Code) + ''''); Open; end; SCreateCDS(ADOQueryTemp, CDS_2); SInitCDSData(ADOQueryTemp, CDS_2); CALCYarnQty(); end; procedure TfrmTatPlanInPut.CALCYarnQty(); var MYarnQty, MOrdQty, MWidth, MMachLatitudeDensity: Double; begin MYarnQty := STRTOFLOATDEF(C_YarnQty.Text, 0); MOrdQty := STRTOFLOATDEF(OrdQty.Text, 0); MWidth := STRTOFLOATDEF(StringReplace(C_Width.Text, 'CM', '', [rfReplaceAll, rfIgnoreCase]), 0); MMachLatitudeDensity := STRTOFLOATDEF(C_MachLatitudeDensity.Text, 0); with CDS_1 do begin DisableControls; First; while not Eof do begin Edit; FieldByName('Y_Qty').Value := MYarnQty * MOrdQty * FieldByName('Y_Ratio').AsFloat / 100 / 9000 * FieldByName('Denier').AsFloat / 1000; Next; end; EnableControls; end; with CDS_2 do begin DisableControls; First; while not Eof do begin Edit; FieldByName('Y_Qty').Value := MMachLatitudeDensity * MOrdQty * MWidth * FieldByName('Y_Ratio').AsFloat / 100 / 9000 * FieldByName('Denier').AsFloat / 1000; Next; end; EnableControls; end; end; procedure TfrmTatPlanInPut.TBCloseClick(Sender: TObject); begin ModalResult := 1; end; procedure TfrmTatPlanInPut.InitData(); var PBNO, PBFlag: string; begin if PState = 1 then begin ConNo.enabled := false; end; with ADOQueryTemp do begin Close; SQL.Clear; sql.Add('select * from Tat_Plan_Main A where A.MainId=''' + Trim(FMainId) + ''''); Open; end; SCSHData(ADOQueryTemp, ScrollBox1, 0); with ADOQueryTemp do begin Close; SQL.Clear; sql.Add('select * from Tat_Plan_Sub A where A.MainId=''' + Trim(FMainId) + ''''); Open; end; SCSHData(ADOQueryTemp, ScrollBox1, 2); with ADOQueryTemp do begin Close; sql.Clear; sql.Add('select A.* from Tat_Plan_Yarn A '); sql.Add(' where YRType=''经丝'' and A.MainId=''' + Trim(FMainId) + ''''); Open; end; SCreateCDS(ADOQueryTemp, CDS_1); SInitCDSData(ADOQueryTemp, CDS_1); with ADOQueryTemp do begin Close; sql.Clear; sql.Add('select A.* from Tat_Plan_Yarn A '); sql.Add(' where YRType=''纬丝'' and A.MainId=''' + Trim(FMainId) + ''''); Open; end; SCreateCDS(ADOQueryTemp, CDS_2); SInitCDSData(ADOQueryTemp, CDS_2); if FCopyInt = 1 then begin FConNo := ''; FMainId := ''; FSubId := ''; OrderNo.Text := ''; ClearCDSColumn(CDS_1, ['MainId', 'SubId', 'YRId']); ClearCDSColumn(CDS_2, ['MainId', 'SubId', 'YRId']); end; end; procedure TfrmTatPlanInPut.FormShow(Sender: TObject); begin InitData(); end; function TfrmTatPlanInPut.SaveData(): Boolean; var maxno, maxsubno, maxpbno, maxpzno, maxsjno: string; begin try ADOQueryCmd.Connection.BeginTrans; if Trim(FMainId) = '' then begin if GetLSNo(ADOQueryCmd, maxno, 'SZ', 'Tat_Plan_Main', 4, 1) = False then raise Exception.Create('生成流水号异常!'); OrderNo.Text := maxno; end else begin maxno := Trim(FMainId); end; ////////////////////////// 保存主表 ////////////////////////// with ADOQueryCmd do begin Close; sql.Clear; SQL.Add('select * from Tat_Plan_Main where MainId=''' + Trim(FMainId) + ''''); Open; end; with ADOQueryCmd do begin if Trim(FMainId) = '' then begin Append; FieldByName('Filler').Value := Trim(DName); end else begin Edit; FieldByName('Editer').Value := Trim(DName); FieldByName('EditTime').Value := SGetServerDateTime(ADOQueryTemp); end; FieldByName('MainId').Value := Trim(maxno); RTSetsavedata(ADOQueryCmd, 'Tat_Plan_Main', ScrollBox1, 0); Post; end; ////////////////////////// 保存主表 ////////////////////////// /// ////////////////////////// 保存子表 ////////////////////////// if Trim(FSubId) = '' then begin if GetLSNo(ADOQueryTemp, maxsubno, 'SZS', 'Tat_Plan_Sub', 4, 1) = False then raise Exception.Create('取子流水号失败!'); end else begin maxsubno := Trim(FSubId); end; with ADOQueryCmd do begin Close; SQL.Clear; sql.Add('select * from Tat_Plan_Sub where '); sql.Add(' SubId=''' + Trim(maxsubno) + ''''); Open; end; with ADOQueryCmd do begin if Trim(FSubId) = '' then Append else Edit; FieldByName('MainId').Value := Trim(maxno); FieldByName('SubId').Value := Trim(maxsubno); RTSetsavedata(ADOQueryCmd, 'Tat_Plan_Sub', ScrollBox1, 2); Post; end; ////////////////////////// 保存子表 ////////////////////////// ////////////////////////// 保存经丝配比表 ////////////////////////// with CDS_1 do begin First; while not Eof do begin if Trim(CDS_1.fieldbyname('YRId').AsString) = '' then begin if GetLSNo(ADOQueryTemp, maxpbno, 'RJ', 'Tat_Plan_Yarn', 4, 1) = False then raise Exception.Create('取配比子流水号失败!'); end else begin maxpbno := Trim(CDS_1.fieldbyname('YRId').AsString); end; with ADOQueryCmd do begin Close; SQL.Clear; sql.Add('select * from Tat_Plan_Yarn where '); sql.Add(' YRId=''' + Trim(maxpbno) + ''''); Open; end; with ADOQueryCmd do begin if Trim(CDS_1.fieldbyname('YRId').AsString) = '' then begin Append; FieldByName('Filler').Value := Trim(DName); FieldByName('FillTime').Value := SGetServerDateTime(ADOQueryTemp); end else begin Edit; FieldByName('Editer').Value := Trim(DName); FieldByName('EditTime').Value := SGetServerDateTime(ADOQueryTemp); end; FieldByName('YRType').Value := '经丝'; FieldByName('MainId').Value := Trim(maxno); FieldByName('SubId').Value := Trim(maxsubno); FieldByName('YRId').Value := Trim(maxpbno); RTSetSaveDataCDS(ADOQueryCmd, Tv2, CDS_1, 'Tat_Plan_Yarn', 0); Post; end; CDS_1.Edit; CDS_1.FieldByName('SubId').Value := Trim(maxsubno); CDS_1.FieldByName('MainId').Value := Trim(maxno); CDS_1.FieldByName('YRId').Value := Trim(maxpbno); Next; end; end; ////////////////////////// 保存经丝配比表 ////////////////////////// ////////////////////// ////////////////////////// 保存纬丝配比表 ////////////////////////// with CDS_2 do begin First; while not Eof do begin if Trim(CDS_2.fieldbyname('YRId').AsString) = '' then begin if GetLSNo(ADOQueryTemp, maxpbno, 'RJ', 'Tat_Plan_Yarn', 4, 1) = False then raise Exception.Create('取配比子流水号失败!'); end else begin maxpbno := Trim(CDS_2.fieldbyname('YRId').AsString); end; with ADOQueryCmd do begin Close; SQL.Clear; sql.Add('select * from Tat_Plan_Yarn where '); sql.Add(' YRId=''' + Trim(maxpbno) + ''''); Open; end; with ADOQueryCmd do begin if Trim(CDS_2.fieldbyname('YRId').AsString) = '' then begin Append; FieldByName('Filler').Value := Trim(DName); FieldByName('FillTime').Value := SGetServerDateTime(ADOQueryTemp); end else begin Edit; FieldByName('Editer').Value := Trim(DName); FieldByName('EditTime').Value := SGetServerDateTime(ADOQueryTemp); end; FieldByName('YRType').Value := '纬丝'; FieldByName('MainId').Value := Trim(maxno); FieldByName('SubId').Value := Trim(maxsubno); FieldByName('YRId').Value := Trim(maxpbno); RTSetSaveDataCDS(ADOQueryCmd, Tv2, CDS_2, 'Tat_Plan_Yarn', 0); Post; end; CDS_2.Edit; CDS_2.FieldByName('SubId').Value := Trim(maxsubno); CDS_2.FieldByName('MainId').Value := Trim(maxno); CDS_2.FieldByName('YRId').Value := Trim(maxpbno); Next; end; end; ////////////////////////// 保存纬丝配比表 ////////////////////////// ADOQueryCmd.Connection.CommitTrans; FMainId := Trim(maxno); FSubId := Trim(maxsubno); Result := True; except Result := False; CDS_1.EnableControls; CDS_2.EnableControls; ADOQueryCmd.Connection.RollbackTrans; application.MessageBox(PChar(Exception(ExceptObject).Message), '提示信息', 0); end; end; procedure TfrmTatPlanInPut.TBSaveClick(Sender: TObject); var FReal: Double; maxConNo: string; begin OrdDate.SetFocus; CALCYarnQty(); if Trim(CustName.Text) = '' then begin Application.MessageBox('客户不能为空!', '提示', 0); Exit; end; if Trim(C_Name.Text) = '' then begin Application.MessageBox('产品名称不能为空!', '提示', 0); Exit; end; if Trim(C_Code.Text) = '' then begin Application.MessageBox('产品编号不能为空!', '提示', 0); Exit; end; if Trim(OrdQty.Text) = '' then begin Application.MessageBox('总数量不能为空!', '提示', 0); Exit; end; if Trim(OrdPieceLen.Text) = '' then begin Application.MessageBox('匹长不能为空!', '提示', 0); Exit; end; if Trim(OrdPiece.Text) = '' then begin Application.MessageBox('匹数不能为空!', '提示', 0); Exit; end; if TryStrToFloat(OrdQty.Text, FReal) = False then begin Application.MessageBox('总数量非法数字!', '提示', 0); Exit; end; if TryStrToFloat(OrdPiecelen.Text, FReal) = False then begin Application.MessageBox('匹长非法数字!', '提示', 0); Exit; end; if TryStrToFloat(OrdPiece.Text, FReal) = False then begin Application.MessageBox('匹数非法数字!', '提示', 0); Exit; end; if SaveData() then begin Application.MessageBox('保存成功!', '提示', 0); ModalResult := 1; end; end; procedure TfrmTatPlanInPut.ToolButton1Click(Sender: TObject); begin try frmYarnInfoSel := TfrmYarnInfoSel.Create(Application); with frmYarnInfoSel do begin if ShowModal = 1 then begin with self.CDS_1 do begin Append; FieldByName('Brand').Value := frmYarnInfoSel.CDS_1.fieldbyname('Brand').Value; FieldByName('Y_Code').Value := frmYarnInfoSel.CDS_1.fieldbyname('Y_Code').Value; FieldByName('Y_Name').Value := frmYarnInfoSel.CDS_1.fieldbyname('Y_Name').Value; FieldByName('Y_Spec').Value := frmYarnInfoSel.CDS_1.fieldbyname('Y_Spec').Value; FieldByName('Y_Color').Value := frmYarnInfoSel.CDS_1.fieldbyname('Y_Color').Value; FieldByName('Denier').Value := frmYarnInfoSel.CDS_1.fieldbyname('Denier').Value; FieldByName('Y_Ratio').Value := 0; Post; end; end; end; finally frmYarnInfoSel.Free; end; end; procedure TfrmTatPlanInPut.ToolButton2Click(Sender: TObject); begin if CDS_1.IsEmpty then Exit; if Trim(CDS_1.fieldbyname('YRId').AsString) <> '' then begin if Application.MessageBox('确定要删除数据吗?', '提示', 32 + 4) <> IDYES then Exit; with ADOQueryCmd do begin Close; sql.Clear; sql.Add('delete Tat_Plan_Yarn where YRId=''' + Trim(CDS_1.fieldbyname('YRId').AsString) + ''''); ExecSQL; end; end; CDS_1.Delete; end; procedure TfrmTatPlanInPut.ToolButton3Click(Sender: TObject); begin try frmYarnInfoSel := TfrmYarnInfoSel.Create(Application); with frmYarnInfoSel do begin if ShowModal = 1 then begin with self.CDS_2 do begin Append; FieldByName('Brand').Value := frmYarnInfoSel.CDS_1.fieldbyname('Brand').Value; FieldByName('Y_Code').Value := frmYarnInfoSel.CDS_1.fieldbyname('Y_Code').Value; FieldByName('Y_Name').Value := frmYarnInfoSel.CDS_1.fieldbyname('Y_Name').Value; FieldByName('Y_Spec').Value := frmYarnInfoSel.CDS_1.fieldbyname('Y_Spec').Value; FieldByName('Y_Color').Value := frmYarnInfoSel.CDS_1.fieldbyname('Y_Color').Value; FieldByName('Denier').Value := frmYarnInfoSel.CDS_1.fieldbyname('Denier').Value; FieldByName('Y_Ratio').Value := 0; Post; end; end; end; finally frmYarnInfoSel.Free; end; end; procedure TfrmTatPlanInPut.ToolButton4Click(Sender: TObject); begin if CDS_2.IsEmpty then Exit; if Trim(CDS_2.fieldbyname('YRId').AsString) <> '' then begin if Application.MessageBox('确定要删除数据吗?', '提示', 32 + 4) <> IDYES then Exit; with ADOQueryCmd do begin Close; sql.Clear; sql.Add('delete Tat_Plan_Yarn where YRId=''' + Trim(CDS_2.fieldbyname('YRId').AsString) + ''''); ExecSQL; end; end; CDS_2.Delete; end; procedure TfrmTatPlanInPut.ToolButton5Click(Sender: TObject); begin OrdDate.SetFocus; CALCYarnQty(); end; procedure TfrmTatPlanInPut.ToolButton6Click(Sender: TObject); begin OrdDate.SetFocus; CALCYarnQty(); end; procedure TfrmTatPlanInPut.cxGridDBColumn1PropertiesButtonClick(Sender: TObject; AButtonIndex: Integer); begin try frmYarnInfoSel := TfrmYarnInfoSel.Create(Application); with frmYarnInfoSel do begin if ShowModal = 1 then begin with self.CDS_2 do begin Edit; FieldByName('Brand').Value := frmYarnInfoSel.CDS_1.fieldbyname('Brand').Value; FieldByName('Y_Code').Value := frmYarnInfoSel.CDS_1.fieldbyname('Y_Code').Value; FieldByName('Y_Name').Value := frmYarnInfoSel.CDS_1.fieldbyname('Y_Name').Value; FieldByName('Y_Spec').Value := frmYarnInfoSel.CDS_1.fieldbyname('Y_Spec').Value; FieldByName('Y_Color').Value := frmYarnInfoSel.CDS_1.fieldbyname('Y_Color').Value; FieldByName('Denier').Value := frmYarnInfoSel.CDS_1.fieldbyname('Denier').Value; Post; end; end; end; finally frmYarnInfoSel.Free; end; end; procedure TfrmTatPlanInPut.cxGridDBColumn4PropertiesButtonClick(Sender: TObject; AButtonIndex: Integer); begin try frmYarnInfoSel := TfrmYarnInfoSel.Create(Application); with frmYarnInfoSel do begin if ShowModal = 1 then begin with self.CDS_1 do begin Append; FieldByName('Brand').Value := frmYarnInfoSel.CDS_1.fieldbyname('Brand').Value; FieldByName('Y_Code').Value := frmYarnInfoSel.CDS_1.fieldbyname('Y_Code').Value; FieldByName('Y_Name').Value := frmYarnInfoSel.CDS_1.fieldbyname('Y_Name').Value; FieldByName('Y_Spec').Value := frmYarnInfoSel.CDS_1.fieldbyname('Y_Spec').Value; FieldByName('Y_Color').Value := frmYarnInfoSel.CDS_1.fieldbyname('Y_Color').Value; FieldByName('Denier').Value := frmYarnInfoSel.CDS_1.fieldbyname('Denier').Value; Post; end; end; end; finally frmYarnInfoSel.Free; end; end; procedure TfrmTatPlanInPut.v2Column11PropertiesButtonClick(Sender: TObject; AButtonIndex: Integer); begin try frmCompanySel := TfrmCompanySel.Create(Application); with frmCompanySel do begin if ShowModal = 1 then begin with Self.CDS_1 do begin Edit; FieldByName('GYSName').Value := Trim(CDS_1.fieldbyname('CoName').AsString); end; end; end; finally frmCompanySel.Free; end; end; procedure TfrmTatPlanInPut.OrdPieceLenChange(Sender: TObject); var FOrdQty, FOrdPieceLen: Double; begin FOrdQty := StrToFloatDef(OrdQty.Text, 0); FOrdPieceLen := StrToFloatDef(OrdPieceLen.Text, 0); if FOrdPieceLen > 0 then OrdPiece.Text := IntToStr(Ceil(FOrdQty / FOrdPieceLen)); end; procedure TfrmTatPlanInPut.OurCoNameBtnUpClick(Sender: TObject); begin try frmCompanySel := TfrmCompanySel.Create(Application); with frmCompanySel do begin FCoType := '我司'; if ShowModal = 1 then begin OurCoName.TxtCode := Trim(CDS_1.fieldbyname('CoCode').AsString); OurCoName.Text := Trim(CDS_1.fieldbyname('CoAbbrName').AsString); FtyCoName.TxtCode := Trim(CDS_1.fieldbyname('CoCode').AsString); FtyCoName.Text := Trim(CDS_1.fieldbyname('CoAbbrName').AsString); end; end; finally frmCompanySel.Free; end; end; procedure TfrmTatPlanInPut.OrdPieceChange(Sender: TObject); var FOrdQty, FOrdPieceLen, FOrdPiece: Double; begin FOrdPieceLen := StrToFloatDef(OrdPieceLen.Text, 0); FOrdPiece := StrToFloatDef(OrdPiece.Text, 0); if FOrdPiece > 0 then OrdQty.Text := FloatToStr(FOrdPieceLen * FOrdPiece) else OrdQty.Text := '0'; end; procedure TfrmTatPlanInPut.C_CodeKeyPress(Sender: TObject; var Key: Char); begin if Key = #13 then begin Key := #0; SelectNext(ActiveControl as TWinControl, True, True); end; end; procedure TfrmTatPlanInPut.MCTypeBtnUpClick(Sender: TObject); var fsj: string; FWZ: Integer; begin fsj := Trim(TBtnEditC(Sender).Hint); FWZ := Pos('/', fsj); try frmZDYHelp := TfrmZDYHelp.Create(Application); with frmZDYHelp do begin flag := Copy(fsj, 1, FWZ - 1); flagname := Copy(fsj, FWZ + 1, Length(fsj) - FWZ); if ShowModal = 1 then begin TBtnEditC(Sender).Text := Trim(ClientDataSet1.fieldbyname('ZDYName').AsString); end; end; finally frmZDYHelp.Free; end; end; procedure TfrmTatPlanInPut.ConNoKeyPress(Sender: TObject; var Key: Char); begin if Key = #13 then begin Key := #0; SelectNext(ActiveControl as TWinControl, True, True); end; end; procedure TfrmTatPlanInPut.FtyCoNameBtnUpClick(Sender: TObject); begin try frmCompanySel := TfrmCompanySel.Create(Application); with frmCompanySel do begin FCoType := '供应商'; if ShowModal = 1 then begin FtyCoName.TxtCode := Trim(CDS_1.fieldbyname('CoCode').AsString); FtyCoName.Text := Trim(CDS_1.fieldbyname('CoAbbrName').AsString); end; end; finally frmCompanySel.Free; end; end; procedure TfrmTatPlanInPut.ConNoBtnUpClick(Sender: TObject); begin // try // frmContractListNXSel := TfrmContractListNXSel.Create(Application); // with frmContractListNXSel do // begin // if ShowModal = 1 then // begin // self.ConNo.Text := frmContractListNXSel.Order_Main.fieldbyname('ConNo').AsString; //合同号 // self.Custname.Text := frmContractListNXSel.Order_Main.fieldbyname('CustomerNoName').AsString; //客户 // self.YWY.Text := frmContractListNXSel.Order_Main.fieldbyname('ConPerson1').AsString; //下单员 // self.KHConNo.Text := frmContractListNXSel.Order_Main.fieldbyname('KHConNo').AsString; //客户 // self.ConMainId.Text := frmContractListNXSel.ClientDataSet2.fieldbyname('MainId').AsString; //ConMainId // self.ConSubId.Text := frmContractListNXSel.ClientDataSet2.fieldbyname('SubID').AsString; //ConSubId // // self.C_Code.Text := frmContractListNXSel.ClientDataSet2.fieldbyname('PrtCode').AsString; //编号 // self.C_Name.Text := frmContractListNXSel.ClientDataSet2.fieldbyname('PrtCodeName').AsString; //品名 // self.C_Spec.Text := frmContractListNXSel.ClientDataSet2.fieldbyname('prtspec').AsString; //规格 // self.C_Color.Text := frmContractListNXSel.ClientDataSet2.fieldbyname('PRTColor').AsString; //颜色 // self.MF.Text := frmContractListNXSel.ClientDataSet2.fieldbyname('prtmf').AsString; //门幅 // self.KZ.Text := frmContractListNXSel.ClientDataSet2.fieldbyname('prtkz').AsString; //克重 // // // self.OrdPiece.Text := frmContractListNXSel.ClientDataSet2.fieldbyname('pishu').AsString; //匹数 // self.OrdPieceWeight.Text := frmContractListNXSel.ClientDataSet2.fieldbyname('OrdTare').AsString; //匹重 // self.OrdQty.Text := frmContractListNXSel.ClientDataSet2.fieldbyname('PRTOrderQty').AsString; //总重量 // end; // end; // finally // frmContractListNXSel.Free; // end; end; procedure TfrmTatPlanInPut.C_CodeBtnUpClick(Sender: TObject); begin try frmTatClothInfoSel := TfrmTatClothInfoSel.Create(Application); with frmTatClothInfoSel do begin if ShowModal = 1 then begin Self.C_Code.Text := frmTatClothInfoSel.CDS_1.fieldbyname('C_Code').AsString; Self.C_Name.Text := frmTatClothInfoSel.CDS_1.fieldbyname('C_Name').AsString; Self.C_Width.Text := frmTatClothInfoSel.CDS_1.fieldbyname('C_Width').AsString; Self.C_GramWeight.Text := frmTatClothInfoSel.CDS_1.fieldbyname('C_GramWeight').AsString; Self.C_MachLatitudeDensity.Text := frmTatClothInfoSel.CDS_1.fieldbyname('C_MachLatitudeDensity').AsString; Self.C_FinishLatitudeDensity.Text := frmTatClothInfoSel.CDS_1.fieldbyname('C_FinishLatitudeDensity').AsString; Self.C_FinishLongitudeDensity.Text := frmTatClothInfoSel.CDS_1.fieldbyname('C_FinishLongitudeDensity').AsString; Self.C_LatitudeSpec.Text := frmTatClothInfoSel.CDS_1.fieldbyname('C_LatitudeSpec').AsString; Self.C_LongitudeSpec.Text := frmTatClothInfoSel.CDS_1.fieldbyname('C_LongitudeSpec').AsString; Self.C_YarnQty.Text := frmTatClothInfoSel.CDS_1.fieldbyname('C_YarnQty').AsString; Self.C_ReedNo.Text := frmTatClothInfoSel.CDS_1.fieldbyname('C_ReedNo').AsString; InitClothYarn(frmTatClothInfoSel.CDS_1.fieldbyname('C_Code').AsString); end; end; finally frmTatClothInfoSel.Free; end; end; procedure TfrmTatPlanInPut.CustNameBtnDnClick(Sender: TObject); begin TBtnEditC(Sender).TxtCode := ''; TBtnEditC(Sender).Text := ''; end; procedure TfrmTatPlanInPut.CustNameBtnUpClick(Sender: TObject); begin try frmCompanySel := TfrmCompanySel.Create(Application); with frmCompanySel do begin FCoType := '客户'; if ShowModal = 1 then begin CustName.TxtCode := Trim(CDS_1.fieldbyname('CoCode').AsString); CustName.Text := Trim(CDS_1.fieldbyname('CoAbbrName').AsString); end; end; finally frmCompanySel.Free; end; end; end.