📄 uhs.pas
字号:
unit uHS;
{$WARN SYMBOL_PLATFORM OFF}
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
ComServ, ComObj, VCLCom, StdVcl, bdemts, DataBkr, DBClient,
MtsRdm, Mtx, pHS_TLB, DB, ADODB, uPublic;
type
TxzBooksHS = class(TMtsDataModule, IxzBooksHS)
ADOConnection1: TADOConnection;
adsJSB: TADODataSet;
adsBooks: TADODataSet;
adsJSB4BookID: TADODataSet;
adsTimes: TADODataSet;
adsMoney: TADODataSet;
adsUserJSXS: TADODataSet;
adsUserBooks: TADODataSet;
private
function GetDJ(UserDH:string):Single; //获取单借用户每天每本书的价格
{ Private declarations }
protected
class procedure UpdateRegistry(Register: Boolean; const ClassID, ProgID: string); override;
procedure GetJSBWithJYRDH(const id: WideString; var vJRY, vJYRQ, vBookID,
vBookName, vDj, vCS, vResult: OleVariant); safecall;
procedure GetJSBWithBookID(const id: WideString; var JYRDH, JYR, JYRQ,
BookName, DJ, CS, Times, vResult, vMoney: OleVariant); safecall;
procedure HS(const BookID: WideString; var vResult: OleVariant); safecall;
public
{ Public declarations }
end;
var
xzBooksHS: TxzBooksHS;
implementation
{$R *.DFM}
class procedure TxzBooksHS.UpdateRegistry(Register: Boolean; const ClassID, ProgID: string);
begin
if Register then
begin
inherited UpdateRegistry(Register, ClassID, ProgID);
EnableSocketTransport(ClassID);
EnableWebTransport(ClassID);
end else
begin
DisableSocketTransport(ClassID);
DisableWebTransport(ClassID);
inherited UpdateRegistry(Register, ClassID, ProgID);
end;
end;
procedure TxzBooksHS.GetJSBWithJYRDH(const id: WideString; var vJRY, vJYRQ,
vBookID, vBookName, vDj, vCS, vResult: OleVariant);
begin
try
if ADOConnection1.Connected then
ADOConnection1.Connected :=False;
ADOConnection1.ConnectionString:=GetConStr;
adsJSB.Close;
adsJSB.Parameters.ParamByName('aid').Value :=id;
adsJSB.Open;
if adsJSB.IsEmpty then
vResult:='None'
else
begin
end;
finally
adsJSB.Close;
end;
end;
procedure TxzBooksHS.GetJSBWithBookID(const id: WideString; var JYRDH, JYR,
JYRQ, BookName, DJ, CS, Times, vResult, vMoney: OleVariant);
var
ZJ:Single;//如果是按天借,这个变量就存放应缴纳的租金
JSRQ:TDate; //借书的日期;
begin
try
if ADOConnection1.Connected then
ADOConnection1.Connected :=False;
ADOConnection1.ConnectionString:=GetConStr;
adsJSB4BookID.Close;
adsJSB4BookID.Parameters.ParamByName('aid').Value :=id;
adsJSB4BookID.Open;
if adsJSB4BookID.IsEmpty then
begin
vResult:='None';
exit;
end
else
begin
JYRDH:=adsJSB4BookID.fieldbyName('JYRDH').Value;
JYR:=adsJSB4BookID.fieldbyName('JYR').Value;
JYRQ:=adsJSB4BookID.fieldbyName('JYRQ').asstring;
JSRQ:=adsJSB4BookID.fieldbyName('JYRQ').Value;
BookName:=adsJSB4BookID.fieldbyName('BookName').Value;
DJ:=adsJSB4BookID.fieldbyName('DJ').Value;
CS:=adsJSB4BookID.fieldbyName('cs').Value;
adsTimes.Close;
adsTimes.Parameters.ParamByName('aid').Value :=id;
adsTimes.Open;
Times:=adsTimes.FieldByName('Times').AsInteger +1;
zj:=GetDJ(JYRDH); //得到每日的租金
if zj>0 then
begin
vMoney:=(Date-JSRQ+1)*zj;
end;
vResult:='Complete';
end;
finally
adsJSB4BookID.Close;
end;
end;
procedure TxzBooksHS.HS(const BookID: WideString; var vResult: OleVariant);
var
iTimes:integer;
begin
try
try
if ADOConnection1.Connected then
ADOConnection1.Connected :=False;
ADOConnection1.ConnectionString:=GetConStr;
adsJSB4BookID.Close;
adsJSB4BookID.Parameters.ParamByName('aid').Value :=BookID;
adsJSB4BookID.Open;
adsJSB4BookID.Delete;
adsBooks.Close;
adsBooks.Parameters.ParamByName('aid').Value :=BookID;
adsBooks.Open;
adsBooks.Edit;
adsBooks.FieldByName('YJC').AsBoolean:=False;
iTimes:=adsBooks.FieldByName('Times').Value;
adsBooks.FieldByName('Times').Value:=iTimes+1;
adsBooks.Post;
setComplete;
vResult:='Complete';
finally
adsJSB4BookID.Close;
adsBooks.Close;
end;
except
setAbort;
vResult:=ADOConnection1.Errors[0].Description;
end;
end;
function TxzBooksHS.GetDJ(UserDH: string): Single;
var
JSXS:Integer;
begin
try
adsUserJSXS.Close;
adsUserJSXS.Parameters.ParamByName('aid').Value :=UserDH;
adsUserJSXS.Open;
JSXS:=adsUserJSXS.fieldByName('JSXS').AsInteger;
if JSXS>40 then
begin
adsMoney.Close;
adsMoney.Parameters.ParamByName('aid').Value :=JSXS;
adsMoney.Open;
result:=adsMoney.FieldByName('MTJG').Value;
end
else
result:=0;
finally
adsUserJSXS.Close;
adsMoney.Close;
end;
end;
initialization
TComponentFactory.Create(ComServer, TxzBooksHS,
Class_xzBooksHS, ciMultiInstance, tmApartment);
end.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -