📄 fuct_server.pas
字号:
unit fuct_server;
interface
uses
windows,messages,sysutils,classes,graphics,controls,forms,Dialogs,
stdctrls,buttons,Grids, DBGrids,dbtables,db,mask,dbctrls,Qrctrls,
DBClient,MConnect,SConnect,QuickRpt,ADODB,variants,u_main;
//----------------------------------------------------\\
procedure AdoUpdate(connection:TADOConnection;UpdateSQL:string;deltaDS:TCustomClientDataSet);
procedure AdoSetParams(comm:tADOCommand;deltaDS:TCustomClientDataSet);
function do_getmonthday(theyear,month:integer):integer;
function do_getweek(year,month:string):integer;
procedure checkdate(vdbedit:tdbedit);
function getTodayDate():string;
//-----------------------------------------------------\\
implementation
uses UDM;
function do_getmonthday(theyear,month:integer):integer;
begin
result:=0;
case month of
1,3,5,7,8,10,12:result:=31;
4,6,9,11:result:=30;
2:if (theyear mod 4)<>0 then
result:=28
else
result:=29;
end;
end;
function do_getweek(year,month:string):integer;
var date1:tdate;
begin
date1:=strtodate(year+'/'+month+'/01');
result:=dayofweek(date1);
end;
procedure AdoUpdate(connection:TADOConnection;UpdateSQL:string;deltaDS:TCustomClientDataSet);
var
I: Integer;
Old: Boolean;
PName: string;
Field: TField;
Value: Variant;
comm:tADOCommand;
begin
try
comm:=TADOCommand.Create(nil);
comm.Connection:=connection;
comm.CommandText:=UpdateSQL;
for I := 0 to comm.Parameters.Count - 1 do
begin
PName := comm.Parameters[I].Name;
Old := CompareText(Copy(PName, 1, 4), 'OLD_') = 0;
if Old then
System.Delete(PName, 1, 4);
Field := DeltaDS.FindField(PName);
if not Assigned(Field) then
begin
comm.Parameters[i].value:='';
Continue;
end;
if Old then
comm.Parameters[i].value:= Field.OldValue
else
begin
Value := Field.NewValue;
if VarIsClear(Value) then Value := Field.OldValue;
if VarType(Value) = varCurrency then
Value := VarToStr(Value)
else if VarType(Value) = varNull then
Value := '';
comm.Parameters[i].value:=Value;
end;
end;
comm.Prepared;
comm.Execute;
except
raise;
end;
comm.Free;
end;
procedure AdoSetParams(comm:tADOCommand;deltaDS:TCustomClientDataSet);
var
I: Integer;
Old: Boolean;
PName: string;
Field: TField;
Value: Variant;
begin
try
for I := 0 to comm.Parameters.Count - 1 do
begin
PName := comm.Parameters[I].Name;
Old := CompareText(Copy(PName, 1, 4), 'OLD_') = 0;
if Old then
System.Delete(PName, 1, 4);
Field := DeltaDS.FindField(PName);
if not Assigned(Field) then
begin
comm.Parameters[i].value:='';
Continue;
end;
if Old then
comm.Parameters[i].value:= Field.OldValue
else
begin
Value := Field.NewValue;
if VarIsClear(Value) then
Value := Field.OldValue;
if VarType(Value) = varCurrency then
Value := VarToStr(Value)
else if VarType(Value) = varNull then
Value := '';
comm.Parameters[i].value:=Value;
end;
// showmessage(pname+' '+vartostr(comm.Parameters[i].value));
end;
except
raise;
end;
end;
//----------------------------\\
procedure checkdate(vdbedit:tdbedit);
begin
try
strtodate(vdbedit.Text);
except
showmessage('日期格式输入错误');
vdbedit.SetFocus;
end;
end;
function getTodayDate():string;
begin
dm.q_seek.CommandText := 'select getdate() todaydatetime' ;
dm.q_seek.Active :=true;
getTodayDate:=FormatDatetime('YYYY-mm-dd',dm.q_seek.fieldbyName('todaydatetime').asDateTime);
dm.q_seek.Active :=false;
end;
end.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -