165 lines
4.2 KiB
ObjectPascal
165 lines
4.2 KiB
ObjectPascal
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,
|
||
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;
|
||
TgridSet: TToolButton;
|
||
procedure TBCloseClick(Sender: TObject);
|
||
procedure TsjClick(Sender: TObject);
|
||
procedure TBSaveClick(Sender: TObject);
|
||
procedure FormCreate(Sender: TObject);
|
||
procedure FormShow(Sender: TObject);
|
||
procedure FormDestroy(Sender: TObject);
|
||
procedure dxLayoutControl_inputDblClick(Sender: TObject);
|
||
private
|
||
fWindowDesign:TWindowFormdesign;
|
||
fDesignCode:string;
|
||
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.dxLayoutControl_inputDblClick(Sender: TObject);
|
||
begin
|
||
layoutDesign(TdxLayoutControl(Sender),ADOQueryBaseCmd,PWideChar(dcode));
|
||
end;
|
||
|
||
procedure TfrmBaseOneTableInput.FormCreate(Sender: TObject);
|
||
var
|
||
mFontSize:integer;
|
||
begin
|
||
getSystemIni();
|
||
if gFontSize<9 then
|
||
begin
|
||
mFontSize := 12;
|
||
end
|
||
else
|
||
begin
|
||
mFontSize:=gFontSize ;
|
||
end;
|
||
|
||
self.Font.Size := gFontSize;
|
||
if trim(gFontName)<>'' then
|
||
self.Font.Name:=gFontName;
|
||
fWindowDesign:=TWindowFormDeSign.Create();
|
||
end;
|
||
|
||
procedure TfrmBaseOneTableInput.FormDestroy(Sender: TObject);
|
||
begin
|
||
fWindowDesign.free;
|
||
end;
|
||
|
||
procedure TfrmBaseOneTableInput.FormShow(Sender: TObject);
|
||
begin
|
||
tGridSet.Visible:=gIsCanDesign;
|
||
fWindowDesign.FormStyleInit10(self,0,ADOQueryBaseTemp,ADOQueryBaseCmd) ;
|
||
if dxLayoutControl_input.Tag<>999 then
|
||
readLayOut(dxLayoutControl_input,ADOQueryBaseTemp,PWideChar( fDllFileName+'|'+self.name+'|'+dxLayoutControl_input.Name+'.ini'));
|
||
|
||
Tsj.Visible:=gIsCanDesign;
|
||
end;
|
||
|
||
function TfrmBaseOneTableInput.SaveData(): Boolean;
|
||
var
|
||
maxno, Smaxno, maxorderno, MaxFNo: string;
|
||
begin
|
||
try
|
||
result := false;
|
||
ADOQueryBaseCmd.Connection.BeginTrans;
|
||
/// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||
if trim(fKeyNo) = '' then
|
||
begin
|
||
if GetLSNo(ADOQueryBaseCmd, maxno, '', fTabelName, 3, 1) = false then
|
||
raise Exception.Create('ȡ<><C8A1><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʧ<EFBFBD><CAA7>!');
|
||
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), '<27><>ʾ<EFBFBD><CABE>Ϣ', 0);
|
||
end;
|
||
end;
|
||
|
||
|
||
end.
|