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

📄 refresh.pas

📁 计量功能 事件记录 购电提醒 欠费报警 负荷控制 自检功能 显示功能 用户插卡错误信息显示
💻 PAS
字号:
unit Refresh;

interface

uses
  Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
  Db, DBTables, DBClient, MConnect, StdCtrls, ConstDef, FieldDef;

type
  TFrmRef = class(TForm)
    Label1: TLabel;
    BtnRef: TButton;
    Label2: TLabel;
    BtnCancel: TButton;
    DCOMRef: TDCOMConnection;
    tabLocalEMKind: TTable;
    tabLocalEPKind: TTable;
    procedure FormCreate(Sender: TObject);
    procedure BtnRefClick(Sender: TObject);
    procedure tabLocalEMKindBeforeOpen(DataSet: TDataSet);
    procedure tabLocalEMKindAfterClose(DataSet: TDataSet);
    procedure BtnCancelClick(Sender: TObject);
    procedure tabLocalEPKindBeforeOpen(DataSet: TDataSet);
    procedure tabLocalEPKindAfterClose(DataSet: TDataSet);
  private
    { Private declarations }
  public
    { Public declarations }
    EnterMode: EnterModeType;
  end;

var
  FrmRef: TFrmRef;

Function  btFunSetEMeterKind(RecEKind: RecEMeterKindType):Byte;
   export;far;external 'NImsDB.dll';
Function  btFunClearEMeterKind(RecEKind: RecEMeterKindType):Byte;
   export;far;external 'NImsDB.dll';
Function  btFunSetEPriceKind(RecEKind: RecEPriceKindType):Byte;
   export;far;external 'NImsDB.dll';
Function  btFunClearEPriceKind(RecEKind: RecEPriceKindType):Byte;
   export;far;external 'NImsDB.dll';

implementation

uses ClntMain;

{$R *.DFM}

procedure TFrmRef.FormCreate(Sender: TObject);
begin
  with DCOMRef do begin
    ComputerName:=RecNImsInfo.SrvHost.sHostName;
    ServerGUID:=DefSrvGUID;
    LoginPrompt:=False;  Connected:=False;
   end;
  tabLocalEMKind.DatabaseName:=DefClntAlias;
  tabLocalEPKind.DatabaseName:=DefClntAlias;
end;

procedure TFrmRef.BtnRefClick(Sender: TObject);
var
  iIntA,iIntB: integer;
  fE_Price: Double;
  wsStrA,wsStrB: WideString;
  LogResult: CntResultType;
  btRWDB:    Byte;
  RecEMKind: RecEMeterKindType;
  RecEPKind: RecEPriceKindType;
begin
  if EnterMode = RefreshMode then begin
   try
     RecEMKind.sAilas:=DefClntAlias; //删除旧数据
     btFunClearEMeterKind(RecEMKind);
     iIntA:=0;
     repeat //更新电表数据库
       with DCOMRef do begin
         Connected:=True;
         LogResult:=AppServer.btFunGetEMeter(iIntA,iIntB,wsStrA,wsStrB);
         Connected:=False;
        end;//end DCOMRef
       RecEMKind.iEKind:=iIntA;    RecEMKind.iEConst:=iIntB;
       RecEMKind.sEMemDT:=wsStrA;  RecEMKind.sEMark:=wsStrB;
       if LogResult=CntSuccess then begin //打开数据库并写入记录
         btRWDB:=btFunSetEMeterKind(RecEMKind);
         if btRWDB=Byte(CntFail) then begin
           wFunShowError('本地数据库读写失败!',[mbOK]); Exit;
          end;
        end;
       iIntA:=iIntA+1;
     until LogResult<>CntSuccess;

     RecEPKind.sAilas:=DefClntAlias; //删除旧数据
     btFunClearEPriceKind(RecEPKind);
     iIntA:=0;
     repeat //更新电价数据库
       with DCOMRef do begin
         Connected:=True;
         LogResult:=AppServer.btFunGetEPrice(iIntA,wsStrA,fE_Price,wsStrB);
         Connected:=False;
        end;//end DCOMRef
       RecEPKind.iEPriceKind:=iIntA;  RecEPKind.sEPriceName:=wsStrA;
       RecEPKind.fEPrice:=fE_Price;   RecEPKind.sEPriceMark:=wsStrB;
       if LogResult=CntSuccess then begin  //打开数据库并写入记录
         btRWDB:=btFunSetEPriceKind(RecEPKind);
         if btRWDB=Byte(CntFail) then begin
           wFunShowError('本地数据库读写失败!',[mbOK]); Exit;
          end;
         end;
       iIntA:=iIntA+1;
     until LogResult<>CntSuccess;
    except
      wFunShowError('本地数据库更新失败!',[mbOK]); Exit;
     end;
    wFunShowOK('本地数据库更新成功!',[mbOK]);
    ModalResult:=mrOK;
   end;
end;

procedure TFrmRef.tabLocalEMKindBeforeOpen(DataSet: TDataSet);
begin
  Session.AddPassword(Psw_EMKind);
end;

procedure TFrmRef.tabLocalEMKindAfterClose(DataSet: TDataSet);
begin
  Session.RemovePassword(Psw_EMKind);
end;

procedure TFrmRef.tabLocalEPKindBeforeOpen(DataSet: TDataSet);
begin
  Session.AddPassword(Psw_EPKind);
end;

procedure TFrmRef.tabLocalEPKindAfterClose(DataSet: TDataSet);
begin
  Session.RemovePassword(Psw_EPKind);
end;

procedure TFrmRef.BtnCancelClick(Sender: TObject);
begin
  ModalResult:=mrCancel;
end;

end.

⌨️ 快捷键说明

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