unit U_KnitDRQuickInPut; interface uses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, cxStyles, cxCustomData, cxGraphics, cxFilter, cxData, cxDataStorage, cxEdit, DB, cxDBData, cxGridLevel, cxGridCustomTableView, cxGridTableView, cxGridDBTableView, cxClasses, cxControls, cxGridCustomView, cxGrid, cxMemo, cxRichEdit, ComCtrls, cxContainer, cxTextEdit, cxMaskEdit, cxButtonEdit, StdCtrls, ToolWin, DBClient, ADODB, ExtCtrls, BtnEdit, cxCalendar, StrUtils, cxDropDownEdit, cxGridCustomPopupMenu, cxGridPopupMenu, cxLookAndFeels, cxLookAndFeelPainters, cxNavigator, dxSkinsCore, dxSkinsDefaultPainters, dxDateRanges, dxBarBuiltInMenu, U_BaseList, dxSkinBasic, 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, dxSkinOffice2016Colorful, dxSkinOffice2016Dark, dxSkinOffice2019Black, dxSkinOffice2019Colorful, dxSkinOffice2019DarkGray, dxSkinOffice2019White, dxSkinPumpkin, dxSkinSeven, dxSkinSevenClassic, dxSkinSharp, dxSkinSharpPlus, dxSkinSilver, dxSkinSpringtime, dxSkinStardust, dxSkinSummer2008, dxSkinTheAsphaltWorld, dxSkinTheBezier, dxSkinValentine, dxSkinVisualStudio2013Blue, dxSkinVisualStudio2013Dark, dxSkinVisualStudio2013Light, dxSkinVS2010, dxSkinWhiteprint, dxSkinWXI, dxSkinXmas2008Blue, dxCore, cxDateUtils; type TfrmKnitDRQuickInPut = class(Tform) ToolBar1: TToolBar; TBSave: TToolButton; TBClose: TToolButton; ScrollBox1: TScrollBox; ADOTemp: TADOQuery; ADOCmd: TADOQuery; ADOQuery1: TADOQuery; Label1: TLabel; Note: TcxTextEdit; Label12: TLabel; Label11: TLabel; cxStyleRepository1: TcxStyleRepository; dazi1: TcxStyle; Label2: TLabel; Label27: TLabel; QtyUnit: TComboBox; Label5: TLabel; DRAddWet: TcxTextEdit; DlyDate: TcxDateEdit; OutType: TcxComboBox; ToCoName: TcxButtonEdit; procedure TBCloseClick(Sender: TObject); procedure FormShow(Sender: TObject); procedure TBSaveClick(Sender: TObject); procedure ToCoNameDblClick(Sender: TObject); procedure ToCoNameOnButtonClick(Sender: TObject; AButtonIndex: Integer); private fuserName: string; procedure InitData(); function SaveData(): Boolean; { Private declarations } public PState, CopyInt: Integer; FDRMID: string; { Public declarations } end; var frmKnitDRQuickInPut: TfrmKnitDRQuickInPut; newh: hwnd; implementation uses U_DataLink, U_ZDYHelp, U_RTFun, U_CompanySel; {$R *.dfm} procedure TfrmKnitDRQuickInPut.TBCloseClick(Sender: TObject); begin Close; end; procedure TfrmKnitDRQuickInPut.InitData(); var fsj: string; begin if PState = 0 then begin DlyDate.Date := strtodatetime(Trim(FormatDateTime('yyyy-MM-dd', Now))); end; with ADOQuery1 do begin Close; sql.Clear; sql.Add('select A.* '); sql.Add(' from Knit_Cloth_DR_Main A'); sql.Add(' where DRMID=''' + Trim(FDRMID) + ''' '); Open; end; SCSHData(ADOQuery1, ScrollBox1, 1); ToCoName.Properties.LookupItems.Text := ADOQuery1.FieldByName('ToCoNo').asstring; end; procedure TfrmKnitDRQuickInPut.FormShow(Sender: TObject); begin InitData(); end; function TfrmKnitDRQuickInPut.SaveData(): Boolean; var MaxMid, MaxSid: string; begin try ADOCmd.Connection.BeginTrans; ///////////////// 保存主表 ///////////////// if Trim(FDRMID) = '' then begin if GetLSNo(ADOCmd, MaxMid, 'DM', 'Knit_Cloth_DR_Main', 4, 1) = False then raise Exception.Create('取最大号失败!'); end else begin MaxMid := Trim(FDRMID); end; with ADOCmd do begin Close; sql.Clear; SQL.Add('select * from Knit_Cloth_DR_Main where DRMID=''' + Trim(MaxMid) + ''''); Open; end; with ADOCmd do begin if Trim(FDRMID) = '' then begin Append; FieldByName('FillID').Value := Trim(DCode); FieldByName('Filler').Value := Trim(DName); end else begin Edit; FieldByName('EditID').Value := Trim(DCode); FieldByName('Editer').Value := Trim(DName); FieldByName('EditTime').Value := SGetServerDateTime(ADOTemp); end; RTSetsavedata(ADOCmd, 'Knit_Cloth_DR_Main', ScrollBox1, 1); FieldByName('DRMID').Value := Trim(MaxMid); FieldByName('ToCoNo').Value := Trim(ToCoName.Properties.LookupItems.Text); FieldByName('Status').Value := '9'; Post; end; ///////////////// 保存主表 ///////////////// FDRMID := Trim(MaxMid); ADOCmd.Connection.CommitTrans; Result := True; except ADOCmd.Connection.RollbackTrans; application.MessageBox(PChar(Exception(ExceptObject).Message), '提示信息', 0); Result := False; end; end; procedure TfrmKnitDRQuickInPut.TBSaveClick(Sender: TObject); var Freal: Double; begin ToolBar1.SetFocus; if Trim(OutType.Text) = '' then begin Application.MessageBox('出库类型不能为空!', '提示', 0); Exit; end; if Trim(ToCoName.Text) = '' then begin Application.MessageBox('收获单位不能为空!', '提示', 0); Exit; end; if SaveData() then begin Application.MessageBox('保存成功!', '提示', 0); ModalResult := 1; end; end; procedure TfrmKnitDRQuickInPut.ToCoNameDblClick(Sender: TObject); begin ToCoName.Text := ''; ToCoName.Properties.LookupItems.Text := ''; end; procedure TfrmKnitDRQuickInPut.ToCoNameOnButtonClick(Sender: TObject; AButtonIndex: Integer); begin try frmCompanySel := TfrmCompanySel.Create(Application); with frmCompanySel do begin FCoType := '客户'; if ShowModal = 1 then begin self.ToCoName.Properties.LookupItems.Text := Trim(frmCompanySel.CDS_1.fieldbyname('CoCode').AsString); self.ToCoName.Text := Trim(frmCompanySel.CDS_1.fieldbyname('CoAbbrName').AsString); end; end; finally frmCompanySel.Free; end; end; end.