⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 srvrmt.pas

📁 计量功能 事件记录 购电提醒 欠费报警 负荷控制 自检功能 显示功能 用户插卡错误信息显示
💻 PAS
📖 第 1 页 / 共 2 页
字号:
end;

function TNImsSrv.btFunGetDefCust(iCustNo: Integer; var wsCustName: WideString; var wsIDNo: WideString;
                  var wsICSC: WideString; var wsMark: WideString): Byte; safecall;
begin
  try //tabCust的字段SIDNo被置为0则此记录被认为删除
    with tabCust do begin
      DatabaseName:=DefSrvAlias; Open;
      Setkey;
      FieldByName(FLDiCustNo).AsInteger:=iCustNo;
      if not GotoKey then begin//查找指定记录
         Result:=Byte(CntRecNotExist);//若指定记录不存在
         tabCust.close; Exit;
       end; Edit;
      wsIDNo:=FieldByName(FLDSIDNo).AsString;
      wsCustName:=FieldByName(FLDSCustName).AsString;
      wsICSC:=FieldByName(FLDSICSC).AsString;
      wsMark:=FieldByName(FLDSMark).AsString;
      Result := Byte(CntRecOK);
     end;
    tabCust.close;
  except
    Result := Byte(CntRecFail);
   end;
end;

function TNImsSrv.btFunSetDefCust(iCustNo: Integer; const wsMark: WideString): Byte; safecall;
begin
  try //tabCust的字段SIDNo被置为0则此记录被认为删除
    with tabCust do begin
      DatabaseName:=DefSrvAlias; Open;
      Setkey;
      FieldByName(FLDiCustNo).AsInteger:=iCustNo;
      if not GotoKey then begin
         Result:=Byte(CntRecNotExist);
         tabCust.close; Exit;
       end;
      Edit;
      FieldByName(FLDSMark).AsString:=wsMark;
      Post; Result := Byte(CntRecOK);
     end;
    tabCust.close;
  except
    Result := Byte(CntRecFail);
   end;
end;

function TNImsSrv.btFunClearDefCust(iCustNo: Integer): Byte; safecall;
begin
  try //tabCust的字段SIDNo被置为0则此记录被认为删除
    with tabCust do begin
      DatabaseName:=DefSrvAlias; Open;
      Setkey;
      FieldByName(FLDiCustNo).AsInteger:=iCustNo;
      if not GotoKey then begin
         Result:=Byte(CntRecNotExist);
         tabCust.close; Exit;
       end;
      Delete; Result := Byte(CntRecOK);
     end;
    tabCust.close;
  except
    Result := Byte(CntRecFail);
   end;
end;

function TNImsSrv.btFunFindLikeCust(var iCustNo: Integer; var wsName: WideString;
                  var wsIDNo: WideString; var iRecNo: Integer): Byte; safecall;
var
  bFind: Boolean;
  iGetCustNo: integer;
  wsGetName,wsGetIDNo:widestring;
  b1,b2,b3: Boolean;
begin
  try
    with tabCust do begin
      DatabaseName:=DefSrvAlias; Open;
      bFind:=False;
      while not bFind do begin
        if (EOF or (iRecNo>RecordCount)) then break
        else if iRecNo<1 then RecNo:=1;
        RecNo:=iRecNo;
        iGetCustNo:=FieldByName(FLDiCustNo).AsInteger;
        wsGetIDNo:=FieldByName(FLDSIDNo).AsString;
        wsGetName:=FieldByName(FLDSCustName).AsString;
        if iCustNo=0 then b1:=True  else b1:=(iCustNo=iGetCustNo);
        if wsName='' then b2:=True  else b2:=(Pos(wsName,wsGetName)>0);
        if wsIDNo='' then b3:=True  else b3:=(Pos(wsIDNo,wsGetIDNo)>0);
        if b1 and b2 and b3 then begin
           iCustNo:=iGetCustNo;  wsName:=wsGetName;
           wsIDNo:=wsGetIDNo;  bFind:=True;  break;
          end;
        iRecNo:=iRecNo+1;
       end;//end while
      if not bFind then //未找到指定记录
         Result:=Byte(CntRecNotExist)
      else Result := Byte(CntRecOK);
     end;
    tabCust.close;
  except
    Result := Byte(CntRecFail);
   end;
end;

function TNImsSrv.btFunAddNewEMeterInfo(iCustNo: Integer; const wsENo: WideString;
                  var dtEDate: TDateTime; iEDegree: Integer; iEConstKind: Integer;
                  iEConst: Integer; iEBuyLmt: Integer; iERemind: Integer;
                  iEWarn: Integer; iESum: Integer; iTotalNum: Integer): Byte; safecall;
begin
  try //添加tabEMeterInfo数据库记录
    with tabEMeterInfo do begin
      DatabaseName:=DefSrvAlias; Open;
      IndexName:='IdxSENo'; SetKey;
      FieldByName(FLDSENo).AsString:=wsENo;
      if GotoKey then begin//查找电表编号是否存在
        Result := Byte(CntRecExisted);
        tabEMeterInfo.close; Exit;
       end
      else begin //若电表编号不存在,查找用户编号
        IndexFieldNames:=FLDiCustNo; SetKey;
        if GotoKey then Delete;//用户编号存在则删除
       end;
      Last; Insert;
      FieldByName(FLDiCustNo).AsInteger:=iCustNo;
      FieldByName(FLDSENo).AsString:=wsENo;
      dtEDate:=Date;
      FieldByName(FLDDTEDate).AsDateTime:=dtEDate;
      FieldByName(FLDiEDegree).AsInteger:=iEDegree;
      FieldByName(FLDiEConstKind).AsInteger:=iEConstKind;
      FieldByName(FLDiEConst).AsInteger:=iEConst;
      FieldByName(FLDiEBuyLmt).AsInteger:=iEBuyLmt;
      FieldByName(FLDiERemind).AsInteger:=iERemind;
      FieldByName(FLDiEWarn).AsInteger:=iEWarn;
      FieldByName(FLDiESum).AsInteger:=iESum;
      FieldByName(FLDiTotalNum).AsInteger:=iTotalNum;
      Post; Result := Byte(CntRecOK);
     end;
    tabEMeterInfo.close;
  except
    Result := Byte(CntRecFail);
   end;
end;

function TNImsSrv.btFunGetDefEMeterInfo(iCustNo: Integer; var wsENo: WideString; var dtEDate: TDateTime;
                  var iEDegree: Integer; var iEConstKind: Integer;
                  var iEConst: Integer; var iEBuyLmt: Integer;
                  var iERemind: Integer; var iEWarn: Integer; var iESum: Integer;
                  var iTotalNum: Integer): Byte; safecall;
begin
  try //获取指定tabEMeterInfo数据库记录
    with tabEMeterInfo do begin
      DatabaseName:=DefSrvAlias; Open;
      Setkey;
      FieldByName(FLDiCustNo).AsInteger:=iCustNo;
      if not GotoKey then begin//查找用户是否存在
         Result:=Byte(CntRecNotExist);//若指定记录不存在
         tabEMeterInfo.close; Exit;
       end;
      wsENo:=FieldByName(FLDSENo).AsString;
      dtEDate:=FieldByName(FLDDTEDate).AsDateTime;
      iEDegree:=FieldByName(FLDiEDegree).AsInteger;
      iEConstKind:=FieldByName(FLDiEConstKind).AsInteger;
      iEConst:=FieldByName(FLDiEConst).AsInteger;
      iEBuyLmt:=FieldByName(FLDiEBuyLmt).AsInteger;
      iERemind:=FieldByName(FLDiERemind).AsInteger;
      iEWarn:=FieldByName(FLDiEWarn).AsInteger;
      iESum:=FieldByName(FLDiESum).AsInteger;
      iTotalNum:=FieldByName(FLDiTotalNum).AsInteger;
      Result := Byte(CntRecOK);
     end;
    tabEMeterInfo.close;
  except
    Result := Byte(CntRecFail);
   end;
end;

function TNImsSrv.btFunSetDefEMeterInfo(iCustNo: Integer; iEBuyLmt: Integer; iERemind: Integer;
                  iEWarn: Integer; iESum: Integer; iTotalNum: Integer): Byte; safecall;
begin
  try //设置指定tabEMeterInfo数据库记录
    with tabEMeterInfo do begin
      DatabaseName:=DefSrvAlias; Open;
      Setkey;
      FieldByName(FLDiCustNo).AsInteger:=iCustNo;
      if not GotoKey then begin//查找用户是否存在
         Result:=Byte(CntRecNotExist);//若指定记录不存在
         tabEMeterInfo.close; Exit;
       end;
      Edit;
      FieldByName(FLDiEBuyLmt).AsInteger:=iEBuyLmt;
      FieldByName(FLDiERemind).AsInteger:=iERemind;
      FieldByName(FLDiEWarn).AsInteger:=iEWarn;
      FieldByName(FLDiESum).AsInteger:=iESum;
      FieldByName(FLDiTotalNum).AsInteger:=iTotalNum;
      Post; Result := Byte(CntRecOK);
     end;
    tabEMeterInfo.close;
  except
    Result := Byte(CntRecFail);
   end;
end;

function TNImsSrv.btFunClearDefEMeterInfo(iCustNo: Integer): Byte; safecall;
begin
  try //删除tabEMeterInfo指定记录
    with tabEMeterInfo do begin
      DatabaseName:=DefSrvAlias; Open;
      Setkey;
      FieldByName(FLDiCustNo).AsInteger:=iCustNo;
      if not GotoKey then begin//查找用户是否存在
         Result:=Byte(CntRecNotExist);//若指定记录不存在
         tabEMeterInfo.close; Exit;
       end;
      Delete; Result := Byte(CntRecOK);//删除指定记录
     end;
    tabEMeterInfo.close;
  except
    Result := Byte(CntRecFail);
   end;
end;

function TNImsSrv.btFunAddBuyRecord(iCustNo: Integer; iBuyNum: Integer; var dtBuyDate: TDateTime;
                  iECurBuy: Integer; iEPriceKind: Integer; fEPrice: Double;
                  const wsOpName: WideString; const wsHostName: WideString): Byte; safecall;
var
  iTBuyNum: integer;
begin
  try //添加tabTabBuy数据库记录
    with tabBuy do begin
      DatabaseName:=DefSrvAlias; Open;
      SetKey; iTBuyNum:=iBuyNum;
      FieldByName(FLDICustNo).AsInteger:=iCustNo;
      FieldByName(FLDiBuyNum).AsInteger:=iTBuyNum;
      while GotoKey do begin
        Delete; SetKey;//申购记录若存在则删除以后的所有记录
        FieldByName(FLDICustNo).AsInteger:=iCustNo;
        iTBuyNum:=iTBuyNum+1;
        FieldByName(FLDiBuyNum).AsInteger:=iTBuyNum;
       end;
      Last; Insert;
      FieldByName(FLDiCustNo).AsInteger:=iCustNo;
      FieldByName(FLDiBuyNum).AsInteger:=iBuyNum;
      FieldByName(FLDiECurBuy).AsInteger:=iECurBuy;
      FieldByName(FLDiEPriceKind).AsInteger:=iEPriceKind;
      FieldByName(FLDfEPrice).AsFloat:=fEPrice;
      FieldByName(FLDSOpName).AsString:=wsOpName;
      FieldByName(FLDSHostName).AsString:=wsHostName;
      dtBuyDate:=Date; //置申购日期
      FieldByName(FLDDTBuyDate).AsDateTime:=dtBuyDate;
      Post; Result := Byte(CntRecOK);
     end;
    tabBuy.close;
  except
    Result := Byte(CntRecFail);
   end;
end;

function TNImsSrv.btFunGetDefBuyRecord(iCustNo: Integer; iBuyNum: Integer; var dtBuyDate: TDateTime;
                  var iECurBuy: Integer; var iEPriceKind: Integer;
                  var fEPrice: Double; var wsOpName: WideString;
                  var wsHostName: WideString): Byte; safecall;
begin
  try //获取指定tabTabBuy数据库记录
    with tabBuy do begin
      DatabaseName:=DefSrvAlias; Open;
      SetKey;
      FieldByName(FLDICustNo).AsInteger:=iCustNo;
      FieldByName(FLDiBuyNum).AsInteger:=iBuyNum;
      if not GotoKey then begin
        Result := Byte(CntRecNotExist);
        tabBuy.close; Exit;
       end;
      iECurBuy:=FieldByName(FLDiECurBuy).AsInteger;
      iEPriceKind:=FieldByName(FLDiEPriceKind).AsInteger;
      fEPrice:=FieldByName(FLDfEPrice).AsFloat;
      wsOpName:=FieldByName(FLDSOpName).AsString;
      wsHostName:=FieldByName(FLDSHostName).AsString;
      dtBuyDate:=FieldByName(FLDDTBuyDate).AsDateTime;
      Result := Byte(CntRecOK);
     end;
    tabBuy.close;
  except
    Result := Byte(CntRecFail);
   end;
end;

function TNImsSrv.btFunClearDefBuyRecord(iCustNo: Integer; iBuyNum: Integer): Byte; safecall;
var
  iNum: integer;
  bDeled: Boolean;
begin
  try //tabCust的字段SIDNo被置为0则此记录被认为删除
    with tabBuy do begin
      DatabaseName:=DefSrvAlias; Open;
      SetKey; bDeled:=False; iNum:=iBuyNum;
      FieldByName(FLDICustNo).AsInteger:=iCustNo;
      FieldByName(FLDiBuyNum).AsInteger:=iNum;
      while GotoKey do begin //申购记录若存在则删除以后的所有记录
        Delete; bDeled:=True;  SetKey;
        FieldByName(FLDICustNo).AsInteger:=iCustNo;
        iNum:=iNum+1;
        FieldByName(FLDiBuyNum).AsInteger:=iNum;
       end;
      if bDeled then Result := Byte(CntRecOK)
      else Result := Byte(CntRecNotExist);
     end;
    tabBuy.close;
  except
    Result := Byte(CntRecFail);
   end;
end;

procedure TNImsSrv.NImsSrvCreate(Sender: TObject);
begin
  with Session do begin
    AddPassword(Psw_Log);    AddPassword(Psw_SoftInfo);
    AddPassword(Psw_Cust);   AddPassword(Psw_EMKind);
    AddPassword(Psw_EPKind); AddPassword(Psw_EMeterInfo);
    AddPassword(Psw_Buy);
   end;
end;

procedure TNImsSrv.NImsSrvDestroy(Sender: TObject);
begin
  with Session do begin
    RemovePassword(Psw_Log);    RemovePassword(Psw_SoftInfo);
    RemovePassword(Psw_Cust);   RemovePassword(Psw_EMKind);
    RemovePassword(Psw_EPKind); RemovePassword(Psw_EMeterInfo);
    RemovePassword(Psw_Buy);
   end; 
end;

initialization
  TComponentFactory.Create(ComServer, TNImsSrv,
    Class_NImsSrv, ciMultiInstance, tmApartment);
end.

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -