TMail = class(TAutoObject, IMail)
private
ReturnValue: SmallInt;
ErrMsg: WideString;
GloabInfo: TGloabInfo;
FReg: boolean;
FConn: boolean;
Conn: TADOConnection;
function RegistryODBCSrc(Dsn,DBServer,DBName,User:string):boolean;
function ReadInifile: TGloabInfo;
function ConnectDB(GloabInfo: TGloabInfo
Dsn: string): boolean;
function OpenAdoQuery(var Q: TADOQuery
SqlStr: string): boolean;
function ExecAdoQuery(var Q: TADOQuery
SqlStr: string): boolean;
function GetPassword: string;
function GetFee(PhoneNo: string
SmsType: integer
var Fee: real): boolean;
function WriteWebLog(Q: TADOQuery;PhoneNo,OperId,OperRes,memo: string): boolean;
protected
procedure IsReged(const PhoneNo, PassWord: WideString;
LoginFlag: Smallint)
safecall;
procedure MailToDB(const SrcPhone, DestPhone, PhoneType: WideString;
MailType, SendType: Smallint
SendTime: TDateTime
SendNum,
SendInterVel: SYSINT
const Mail: WideString)
safecall;
procedure UserReg(const PhoneNo: WideString
out PassWord,
Email: WideString)
safecall;
procedure UnReg(const PhoneNo, PassWord: WideString)
safecall;
procedure DBToMail(out SrcPhone, DestAddr: WideString;
out SmsType: Smallint
out ID: Integer
out SMS: WideString);
safecall;
procedure MailResult(ID: Integer
SendTime: TDateTime)
safecall;
procedure SMSToDB(const SrcPhone, DestAddr: WideString
SmsType: Smallint;
const SMS: WideString)
safecall;
procedure DBToSMS(out SrcPhone, DestPhone: WideString;
out SmsType: Smallint
out ID: Integer
out SMS: WideString);
safecall;
procedure SMSResult(ID: Integer
SendTime: TDateTime)
safecall;
procedure QueryCharge(const PhoneNo, PassWord, QueryDateTime: WideString;
QueryType: Smallint
out ResultSmsNumber, ResultMailNumber,
ResultSmsCharge, ResultMailCharge: Integer)
safecall;
procedure QueryList(const PhoneNo, PassWord: WideString
QueryBeginTime,
QueryEndTime: TDateTime
QueryType: Smallint
out ResultSmsTotal,
ResultChargeTotal: Integer
out SmsDataSet, MailDataSet: OleVariant);
safecall;
procedure WebLog(const PhoneNo, OperID, OperRes, Memo: WideString);
safecall;
function Get_ReturnValue: Smallint
safecall;
function Get_ErrMsg: WideString
safecall;
{ Protected declarations }
public
procedure Initialize
override;
Destructor Destroy
override;
end;
IsReged源码如下
procedure TMail.IsReged(const PhoneNo, PassWord: WideString;
LoginFlag: Smallint);
var
Q: TADOQuery;
SQLStr: string;
begin
try
if not ((GloabInfo.DBServer = 'Error') or (GloabInfo.DBName = 'Error') or
(GloabInfo.User = 'Error')) then
begin
if FReg then
begin
if FConn then
begin
Q := TADOQuery.Create(nil);
Q.Connection := Conn;
SQLStr := 'select * from OpUser where PhoneNo = ''' + PhoneNo + '''';
if OpenAdoQuery(Q,SQLStr) then
begin
case LoginFlag of
0: begin //登录
if Q.RecordCount > 0 then
begin
if Trim(Q.FieldByName('Password').AsString) <> PassWord then
begin
ReturnValue := 5;
ErrMsg := '密码错误';
end else begin
if Q.FieldByName('UserState').AsString = '0' then //0:注销 1:注册
begin
ReturnValue := 4;
ErrMsg := '用户已注销';
end else begin
ReturnValue := 3;
ErrMsg := '登录成功';
end;
end;
end else begin
ReturnValue := 2;
ErrMsg := '无此用户手机';
end;
end;
1: begin //注册、注销判断
if Q.RecordCount > 0 then //有此用户
begin
if Q.FieldByName('UserState').AsString = '0' then
begin
ReturnValue := 4;
ErrMsg := '用户已注销';
end else begin
ReturnValue := 1;
ErrMsg := '有此手机';
end;
end else begin
ReturnValue := 2;
ErrMsg := '无此手机';
end;
end;
end;
end else begin
ReturnValue := 0;
ErrMsg := '查询出错';
end;
Q.Free;
end else begin
ReturnValue := 0;
ErrMsg := '数据库链接错误';
end;
end else begin
ReturnValue := 0;
ErrMsg := '访问ODBC数据源失败';
end;
end else begin
ReturnValue := 0;
ErrMsg := 'COM配置文件错误';
end;
except
ReturnValue := 0;
ErrMsg := '不明错误';
end;
end;
我用delphi编的测试程序测试,返回值为
ReturnValue := 3;
ErrMsg := '登录成功';
而用asp测试,返回值为
ReturnValue := 0;
ErrMsg := '访问ODBC数据源失败';
不明白为什么,请指教