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; type TfrmKnitDRQuickInPut = class(Tform) ToolBar1: TToolBar; TBSave: TToolButton; TBClose: TToolButton; ScrollBox1: TScrollBox; ADOTemp: TADOQuery; ADOCmd: TADOQuery; ADOQuery1: TADOQuery; Label1: TLabel; OutType: TComboBox; Note: TEdit; Label12: TLabel; Label11: TLabel; ToCoName: TBtnEditC; cxStyleRepository1: TcxStyleRepository; dazi1: TcxStyle; Label2: TLabel; DlyDate: TDateTimePicker; Label27: TLabel; QtyUnit: TComboBox; Label5: TLabel; DRAddWet: TEdit; procedure TBCloseClick(Sender: TObject); procedure FormShow(Sender: TObject); procedure TBSaveClick(Sender: TObject); procedure ToCoNameBtnUpClick(Sender: TObject); procedure ToCoNameBtnDnClick(Sender: TObject); 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.DateTime := 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.TxtCode := 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.TxtCode); 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.ToCoNameBtnUpClick(Sender: TObject); begin try frmCompanySel := TfrmCompanySel.Create(Application); with frmCompanySel do begin FCoType := '客户'; if ShowModal = 1 then begin self.ToCoName.TxtCode := Trim(frmCompanySel.CDS_1.fieldbyname('CoCode').AsString); self.ToCoName.Text := Trim(frmCompanySel.CDS_1.fieldbyname('CoAbbrName').AsString); end; end; finally frmCompanySel.Free; end; end; procedure TfrmKnitDRQuickInPut.ToCoNameBtnDnClick(Sender: TObject); begin ToCoName.Text := ''; end; end.