📄 srvtest.pas
字号:
unit SrvTest;
interface
uses
Windows, Messages, SysUtils, Classes, Graphics,
Controls, Forms, Dialogs, Menus, NetImsServer_tlb,
DBTables, SrvRmt, ConstDef, StdCtrls;
type
TFrmSrvTest = class(TForm)
MainMenu: TMainMenu;
MeuTestItf: TMenuItem;
ItmRmtCnt: TMenuItem;
ItmAnswer: TMenuItem;
ItmLogIn: TMenuItem;
ItmLogOff: TMenuItem;
ItmChgPsw: TMenuItem;
MeuCustTest: TMenuItem;
ItmNewCust: TMenuItem;
MeuNIms: TMenuItem;
ItmStrTest: TMenuItem;
ItmRemove: TMenuItem;
ItmOpenEMeter: TMenuItem;
ItmOpenEPrice: TMenuItem;
ItmGetDefRec: TMenuItem;
ItmFind: TMenuItem;
ItmExit: TMenuItem;
Label1: TLabel;
ItmDBTest: TMenuItem;
N2: TMenuItem;
N3: TMenuItem;
N1: TMenuItem;
procedure FormCreate(Sender: TObject);
procedure ItmRmtCntClick(Sender: TObject);
procedure ItmAnswerClick(Sender: TObject);
procedure ItmLogInClick(Sender: TObject);
procedure ItmLogOffClick(Sender: TObject);
procedure ItmChgPswClick(Sender: TObject);
procedure ItmNewCustClick(Sender: TObject);
procedure ItmStrTestClick(Sender: TObject);
procedure ItmRemoveClick(Sender: TObject);
procedure ItmOpenEMeterClick(Sender: TObject);
procedure ItmOpenEPriceClick(Sender: TObject);
procedure ItmGetDefRecClick(Sender: TObject);
procedure ItmFindClick(Sender: TObject);
procedure ItmExitClick(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
FrmSrvTest: TFrmSrvTest;
Function bFunNImsInied: Boolean;
export;far;external 'NIMSsys.dll';
Function sFunCheckStr(sStrIn: String): widestring;
export;far;external 'NIMStrans.dll';
Function sFunGetStrByDate(dtDate: TDateTime): WideString;
export;far;external 'NIMStrans.dll';
Function btFunGetEMeterKind(var RecEKind: RecEMeterKindType):Byte;
export;far;external 'NImsDB.dll';
implementation
{$R *.DFM}
procedure TFrmSrvTest.FormCreate(Sender: TObject);
begin
BorderIcons:=[biSystemMenu,biMinimize];
end;
procedure TFrmSrvTest.ItmStrTestClick(Sender: TObject);
var
s,sA,sB,sMsg: String;
begin
sMsg:='字符测试'+#13;
sA:='00009'; sB:=sFunCheckStr(sA);
s:='"'+sA+'" --> "'+sB+'" '+floattostr(strtofloat(sB));
sMsg:=sMsg+#13+s+' ';
sA:='01a.1'; sB:=sFunCheckStr(sA);
s:='"'+sA+'" --> "'+sB+'" '+floattostr(strtofloat(sB));
sMsg:=sMsg+#13+s+' ';
sA:='01..1'; sB:=sFunCheckStr(sA);
s:='"'+sA+'" --> "'+sB+'" '+floattostr(strtofloat(sB));
sMsg:=sMsg+#13+s+' ';
sA:='01 .1'; sB:=sFunCheckStr(sA);
s:='"'+sA+'" --> "'+sB+'" '+floattostr(strtofloat(sB));
sMsg:=sMsg+#13+s+' ';
sA:=' 01.1'; sB:=sFunCheckStr(sA);
s:='"'+sA+'" --> "'+sB+'" '+floattostr(strtofloat(sB));
sMsg:=sMsg+#13+s+' ';
sA:='01.100000'; sB:=sFunCheckStr(sA);
s:='"'+sA+'" --> "'+sB+'" '+floattostr(strtofloat(sB));
sMsg:=sMsg+#13+s+' ';
sA:='A01.1'; sB:=sFunCheckStr(sA);
s:='"'+sA+'" --> "'+sB+'" '+floattostr(strtofloat(sB));
sMsg:=sMsg+#13+s+' ';
sA:='5233.1a'; sB:=sFunCheckStr(sA);
s:='"'+sA+'" --> "'+sB+'" '+floattostr(strtofloat(sB));
sMsg:=sMsg+#13+s+' ';
wFunShowOK(sMsg,[mbOK]);
end;
procedure TFrmSrvTest.ItmRmtCntClick(Sender: TObject);
var
btRet: Byte;
ItfTest: INImsSrv;
begin
ItfTest:=TNImsSrv.Create(self);
btRet:=ItfTest.btFunRmtCnt('TRSOFT',42,127,119,119,122);
ItfTest:=nil;
if btRet=Byte(CntSuccess) then wFunShowOK('连接成功,系统软件正常!',[mbOK])
else wFunShowError('连接失败,系统软件不正常!',[mbOK]);
end;
procedure TFrmSrvTest.ItmAnswerClick(Sender: TObject);
var
btRet: Byte;
ItfTest: INImsSrv;
begin
ItfTest:=TNImsSrv.Create(self);
btRet:=ItfTest.btFunAnswer(Byte(CntAsk));
ItfTest:=nil;
if btRet = Byte(CntAsk) then
wFunShowOK('应答成功,网络连接正常!',[mbOK])
else wFunShowError('应答失败,网络连接不正常!',[mbOK]);
end;
procedure TFrmSrvTest.ItmLogInClick(Sender: TObject);
var
btRet: Byte;
ItfTest: INImsSrv;
sAccount,sPsw: String;
wsOpName,wsOpMark: WideString;
btClass: Byte;
begin
ItfTest:=TNImsSrv.Create(self);
sAccount:=InputBox('登录帐号','请输入系统操作员登录帐号','');
btClass:=Byte(DefSysOpChar);
sPsw:=InputBox('登录口令','请输入系统操作员[帐号:'+sAccount+']登录口令','');
btRet:=ItfTest.btFunRmtLogIn(sAccount,sPsw,btClass,wsOpName,wsOpMark);
ItfTest:=nil;
if btRet=Byte(CntLogOK) then
wFunShowOK(sAccount+'/'+wsOpName+'/'+wsOpMark+#13+'登录成功!',[mbOK])
else wFunShowError('登录NIms失败!',[mbOK]);
end;
procedure TFrmSrvTest.ItmChgPswClick(Sender: TObject);
var
btRet: Byte;
ItfTest: INImsSrv;
sAccount,sPsw1,sPsw2: String;
bInput: Boolean;
begin
sAccount:=InputBox('登录帐号','请输入系统操作员登录帐号','');
sPsw1:=''; sPsw2:='';
bInput:=InputQuery('登录口令','请输入系统操作员[帐号:'+sAccount+']登录口令',sPsw1);
if not bInput then Exit;
bInput:=InputQuery('新口令','请输入系统操作员[帐号:'+sAccount+']新口令',sPsw2);
if not bInput then Exit;
ItfTest:=TNImsSrv.Create(self);
btRet:=ItfTest.btFunRmtChgPsw(sAccount,sPsw1,sPsw2);
ItfTest:=nil;
if btRet=Byte(CntChgPswOK) then
wFunShowOK(sAccount+#13+'更改口令成功!',[mbOK])
else wFunShowError('更改口令失败!',[mbOK]);
end;
procedure TFrmSrvTest.ItmLogOffClick(Sender: TObject);
var
ItfTest: INImsSrv;
btRet,btClass: Byte;
sAccount: String;
begin
sAccount:=InputBox('登录帐号','请输入系统操作员登录帐号','');
btClass:=Byte(DefSysOpChar);
ItfTest:=TNImsSrv.Create(self);
btRet:=ItfTest.btFunRmtLogOff(sAccount,btClass);
ItfTest:=nil;
if btRet=Byte(CntLogOK) then
wFunShowOK(sAccount+'/'+Char(btClass)+#13+'退出成功!',[mbOK])
else wFunShowError('系统提示:退出NIms失败!',[mbOK]);
end;
procedure TFrmSrvTest.ItmNewCustClick(Sender: TObject);
var
ItfTest: INImsSrv;
btRet: array[1..5] of Byte;
iCustNo: integer;
sENo,sCustName,sIDNo,sICRC,sMark: WideString;
dtDate: TDateTime;
begin
iCustNo:=0; sENo:='000000';
sCustName:='吴江'; sICRC:='B62307';
sIDNo:='110108730514971'; sMark:='阎良区凌云路2号';
ItfTest:=TNImsSrv.Create(self);
btRet[1]:=ItfTest.btFunAddNewCust(iCustNo,sCustName,sIDNo,sICRC,sMark);
btRet[2]:=ItfTest.btFunAddNewEMeterInfo(iCustNo,sENo,dtDate,
0,0,720,200,10,5,0,0);
btRet[3]:=ItfTest.btFunAddBuyRecord(iCustNo,0,dtDate,10,0,
0.35,'WuJiang','Computer');
if (btRet[1] and btRet[2] and btRet[3])=Byte(CntRecOK) then
wFunShowOK('开户成功:(开户日期'+sFunGetStrByDate(dtDate)+')'+#13+#13
+'用户号['+inttostr(iCustNo)+']'+'电表号['+sENo+']'+#13
+'用户[ '+sCustName+' : '+sIDNo+' ]'+#13+sMark,[mbOK])
else wFunShowError('系统提示:开户失败!',[mbOK]);
ItfTest.btFunClearDefEMeterInfo(iCustNo);
ItfTest.btFunClearDefCust(iCustNo);
ItfTest.btFunClearDefBuyRecord(iCustNo,0);
ItfTest:=nil;
end;
procedure TFrmSrvTest.ItmRemoveClick(Sender: TObject);
var
ItfTest: INImsSrv;
btRet: Byte;
bInput: Boolean;
iCustNo: integer;
sGetStr: string;
begin
bInput:=InputQuery('删除指定用户','请输入指定用户号',sGetStr);
if not bInput then Exit
else iCustNo:=strtoint(sGetStr);
ItfTest:=TNImsSrv.Create(self);
btRet:=ItfTest.btFunClearDefCust(iCustNo);
ItfTest:=nil;
if btRet=Byte(CntRecOK) then
wFunShowOK('用户记录已删除![用户号:'+inttostr(iCustNo)+']',[mbOK])
else wFunShowError('系统提示:删除失败!',[mbOK]);
end;
procedure TFrmSrvTest.ItmGetDefRecClick(Sender: TObject);
var
ItfTest: INImsSrv;
btRet: Byte;
wAnswer: word;
iIntA,iIntB,iECurBuy,iEPriceKind: integer;
dtBuyDate: TDateTime;
fEPrice: Double;
s,wsOpName,wsHostName: widestring;
begin
iIntB:=0;
ItfTest:=TNImsSrv.Create(self);
repeat
iIntA:=1; iIntB:=iIntB+1;
btRet:=ItfTest.btFunGetDefBuyRecord(iIntA,iIntB,dtBuyDate,
iECurBuy,iEPriceKind,fEPrice,wsOpName,wsHostName);
if btRet=Byte(CntRecOK) then
s:='用户['+inttostr(iIntA)+'] 购电次数:'+inttostr(iIntB)+#13+sFunGetStrByDate(dtBuyDate)
+' 购电量:'+inttostr(iECurBuy)+' 电价类型'+inttostr(iEPriceKind)
+' 电价:'+floattostr(fEPrice)+#13+'售电操作员:'+wsOpName+' 售电机:'+wsHostName
else s:='未找到指定记录'+#13+'用户['+inttostr(iIntA)+'] 购电次数:'+inttostr(iIntB);
wAnswer:=wFunShowASK(s,[mbOK]+[mbCancel]);
until (btRet<>Byte(CntRecOK)) or (wAnswer<>mrOK);
ItfTest:=nil;
end;
procedure TFrmSrvTest.ItmFindClick(Sender: TObject);
var
ItfTest: INImsSrv;
btRet: Byte; i,iCustNo:integer;
wsName,wsIDNo: widestring;
s,sFind: string;
begin
i:=1;
ItfTest:=TNImsSrv.Create(self);
repeat
iCustNo:=0; wsName:=''; wsIDNo:='0';
sFind:='[ '+inttostr(iCustNo)+' / '+wsName+' / '+wsIDNo+' ]';
btRet:=ItfTest.btFunFindLikeCust(iCustNo,wsName,wsIDNo,i);
if btRet=Byte(CntRecOK) then
s:='查找用户'+sFind+'成功!'+#13
+'[ '+inttostr(iCustNo)+' / '+wsName+' / '+wsIDNo+' ]'
else s:='未找到用户'+sFind+'记录'; i:=i+1;
wFunShowOK(s,[mbOK]);
until btRet<>Byte(CntRecOK);
ItfTest:=nil;
end;
procedure TFrmSrvTest.ItmOpenEMeterClick(Sender: TObject);
var
s: String;
RecEKind: RecEMeterKindType;
begin
with RecEKind do begin
iEKind:=0; sAilas:=DefSrvAlias;
if btFunGetEMeterKind(RecEKind)=Byte(CntSuccess) then
begin
s:='电表类型 '+inttostr(iEKind)+' 读取成功'+#13+#13+'电表参数: '
+inttostr(iEConst)+' IC卡数据格式 "'+sEMemDT+'" '+sEMark;
wFunShowOK(s,[mbOK]);
end;
end;
end;
procedure TFrmSrvTest.ItmOpenEPriceClick(Sender: TObject);
var
s: String;
RecEPKind: RecEPriceKindType;
begin
with RecEPKind do begin
iEPriceKind:=0; sAilas:=DefSrvAlias;
if btFunGetEPriceKind(RecEPKind)=Byte(CntSuccess) then
begin
s:='电表类型 '+inttostr(iEPriceKind)+' 读取成功'+#13+#13
+sEPriceName+' '+floattostr(fEPrice)+'元/度'+' '+sEPriceMark;
wFunShowOK(s,[mbOK]);
end;
end;
end;
procedure TFrmSrvTest.ItmExitClick(Sender: TObject);
begin
close;
end;
end.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -