unit U_BaseOneTableInput; interface uses Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants, System.Classes, Vcl.Graphics, Vcl.Controls, Vcl.Forms, Vcl.Dialogs, Vcl.ComCtrls, Vcl.ToolWin, cxGraphics, cxControls, cxLookAndFeels, cxLookAndFeelPainters, dxSkinsCore, dxSkinsDefaultPainters, dxSkinWXI, cxClasses, dxLayoutContainer, dxLayoutControl, Data.DB, Data.Win.ADODB,U_WindowFormdesign; type TfrmBaseOneTableInput = class(TForm) ToolBar1: TToolBar; TBSave: TToolButton; Tsj: TToolButton; TBClose: TToolButton; dxLayoutControl_inputGroup_Root: TdxLayoutGroup; dxLayoutControl_input: TdxLayoutControl; ADOQueryBaseCmd: TADOQuery; ADOQueryBaseTemp: TADOQuery; procedure TBCloseClick(Sender: TObject); procedure TsjClick(Sender: TObject); procedure TBSaveClick(Sender: TObject); procedure FormCreate(Sender: TObject); procedure FormShow(Sender: TObject); procedure FormDestroy(Sender: TObject); private fWindowDesign:TWindowFormdesign; function SaveData(): Boolean; public fKeyNo:string; fTabelName:string; end; var frmBaseOneTableInput: TfrmBaseOneTableInput; implementation uses U_RTFun ,U_globalVar,U_dataLink,U_FormLayOutDesign; {$R *.dfm} procedure TfrmBaseOneTableInput.TBCloseClick(Sender: TObject); begin close; end; procedure TfrmBaseOneTableInput.TBSaveClick(Sender: TObject); begin if not mustInCheck(application, dxLayoutControl_input,PWideChar('*')) then exit; if SaveData() then begin end; end; procedure TfrmBaseOneTableInput.TsjClick(Sender: TObject); begin saveLayOut(application,dxLayoutControl_input, ADOQueryBaseCmd, PWideChar( fDllFileName + '|' + SELF.Name + '|' + dxLayoutControl_input.Name+ '.ini')); end; procedure TfrmBaseOneTableInput.FormCreate(Sender: TObject); begin fWindowDesign:=TWindowFormDeSign.Create(); end; procedure TfrmBaseOneTableInput.FormDestroy(Sender: TObject); begin fWindowDesign.free; end; procedure TfrmBaseOneTableInput.FormShow(Sender: TObject); begin fWindowDesign.FormStyleInit10(self,0,ADOQueryBaseTemp,ADOQueryBaseCmd) end; function TfrmBaseOneTableInput.SaveData(): Boolean; var maxno, Smaxno, maxorderno, MaxFNo: string; begin try result := false; ADOQueryBaseCmd.Connection.BeginTrans; /// 保存主表 if trim(fKeyNo) = '' then begin if GetLSNo(ADOQueryBaseCmd, maxno, '', fTabelName, 3, 1) = false then raise Exception.Create('取最大号失败!'); end else begin maxno := trim(fKeyNo); end; with ADOQueryBaseCmd do begin close; sql.Clear; sql.Add('select * from '+fTabelName); sql.Add('where recid=' +quotedstr(trim(fKeyNo))); end; with ADOQueryBaseCmd do begin if IsEmpty then begin Append; fieldbyname('FillId').Value := trim(DCode); fieldbyname('Filler').Value := trim(DName); fieldbyname('status').Value := '0'; end else begin Edit; fieldbyname('EditId').Value := trim(DCode); fieldbyname('Editer').Value := trim(DName); fieldbyname('EditTime').Value := SGetServerDateTime(ADOQueryBaseTemp); end; LRTSetsavedata(ADOQueryBaseCmd, fTabelName, dxLayoutControl_input, 2); fieldbyname('recid').Value := trim(maxno); Post; end; fkeyNo := trim(maxno); ADOQueryBaseCmd.Connection.CommitTrans; result := True; except ADOQueryBaseCmd.Connection.RollbackTrans; Application.MessageBox(PChar(Exception(ExceptObject).Message), '提示信息', 0); end; end; end.