?? commsmdljf.pas
字號(hào):
unit CommSmdljf;
interface
uses IniFiles, SysUtils, QuickRpt, Msg_F;
//記錄工作日志
procedure P_Log(v_Log:String;v_Type:String = '');
//修改當(dāng)前用戶(hù)的口令
procedure P_Upd_Password(v_Password:String);
//獲得數(shù)據(jù)庫(kù)操作的消息
procedure p_GetMsg(Var v_Sender, v_Content:String);
Procedure p_SetLNo(vHouseNo:String;vAmmeterOrder:String;vLNo:String);//設(shè)置指定表的邏輯表號(hào)
//設(shè)置指定表的本月抄表數(shù)
procedure p_SetThis_Count(v_House_No:String;V_Ammeter_Order:String;V_This_Count, v_Adjust_Count:Real; V_Note:String);
//設(shè)置指定表的本月抄表數(shù)為空
procedure p_SetThis_Null(v_House_No:String;V_Ammeter_Order:String);
//根據(jù)表號(hào)得到戶(hù)號(hào),戶(hù)名,上次抄表數(shù)
procedure p_GetHouse(v_House_No:String;V_Ammeter_Order:Integer; Var V_House_Name:String; Var v_Last_Count:Real);
//計(jì)算本月電費(fèi)
procedure p_MonthFee;
//存儲(chǔ)并清除上月抄表數(shù)據(jù)
procedure p_NewMonth;
//檢查抄表數(shù)據(jù)的合法性
procedure p_Valid;
//打印或預(yù)覽報(bào)表
procedure p_Print_Report(Rpt:TQuickRep);
//設(shè)置上月抄表數(shù)據(jù)
procedure p_SetLast;
//返回下一可辦事處編號(hào)
function f_NextTownNo:String;
//返回指定辦事處的下一可用村號(hào)
function f_NextVillageNo(V_Town_No:String):String;
//返回指定供電所下一可用線路號(hào)
function f_NextLineNo(V_Station_No:String):String;
//返回指定線路的下一可用編壓器號(hào)
function f_NextTransferNo(V_Line_No:String):String;
//返回指定變壓器的下一可用戶(hù)號(hào)
function f_NextHouseNo(V_Transfer_No:String):String;
//返回指定用戶(hù)的相關(guān)表的信息
procedure p_GetAmmeter(v_House_No:String;
Var A_No1, A_No2, A_No3:String;
Var A_Last1, A_Last2, A_Last3:Extended;
Var A_Count1, A_Count2, A_Count3:Extended);
//根據(jù)用戶(hù)號(hào)得到表號(hào)
procedure p_GetAmmeterNo(v_House_No:String; Var A_No1, A_No2, A_No3:String);
//求農(nóng)網(wǎng)維護(hù)費(fèi)單價(jià)
Function F_GetServicePrice(V_Elect_No:String):Extended;
//求農(nóng)網(wǎng)維護(hù)費(fèi)
Function F_GetServiceFee(V_House_No:String):Extended;
//求農(nóng)網(wǎng)維護(hù)費(fèi)相關(guān)信息
Procedure P_GetService(V_House_No:String;
Var v_Service_Price1, v_Service_Price2, v_Service_Price3, v_Service_Price4,
v_Service_Amount1, V_Service_Amount2, v_Service_Amount3, v_Service_Amount4,
v_Service_Amount: Extended);
//求國(guó)家電價(jià)
Procedure P_GetCountry(V_House_No:String;
Var V_Country_Price1, v_Country_Price2, V_Country_Price3, V_Country_Price4,
v_Country_Amount1, V_Country_Amount2, v_Country_Amount3, v_Country_Amount4,
v_Country_Amount: Extended);
//設(shè)置用戶(hù)的當(dāng)前選擇
//Procedure p_SetCurrent(v_Class:String;v_Value:String);
//根據(jù)用戶(hù)號(hào)求用電地址
Function F_GetAddress(V_House_No:String):String;
//根據(jù)用戶(hù)號(hào)求線路名稱(chēng)
Function F_GetLine(V_House_No:String):String;
//取得當(dāng)前系統(tǒng)月份
Procedure P_GetCurrentYearMonth(Var CYear, CMonth:String);
//顯示消息窗口
Procedure P_OpenMessageBox(v_Caption:String;v_Msg:String);
//關(guān)閉消息窗口
Procedure P_CloseMessageBox;
//得到指定表的計(jì)量數(shù)
Function f_GetUsedCount(v_House_no:String;v_Ammeter_Order:Integer):Extended;
//根據(jù)村、社編號(hào)取得村、社名稱(chēng)
Procedure p_GetVillageName(v_Village_No:String;var v_Village_Name:String);
//設(shè)置變壓器為自主供電
Procedure p_DisbranchTransfer(v_Transfer_No:String);
//設(shè)置變壓器為并戶(hù)供電方式
Procedure p_MergeTransfer(v_STransfer_No, v_DTransfer_No:String);
//用戶(hù)換表
Procedure p_AmmeterReplace(v_House_No:String;v_Ammeter_Order:integer);
//變壓器改編號(hào)
Procedure p_TransferAlterLine(v_STransfer_No, v_DTransfer_No:String);
//移表
Procedure p_AmmeterMove(v_SHouse_No:String;v_Ammeter_No:String;v_DHouse_No:String);
//根據(jù)戶(hù)號(hào)得到變壓器相關(guān)信息
Procedure P_GetTransferInfo(vHouseNo:String;var vTransferNo, vTransferName:String; var vAmmeterCount, vAutoAmmeterCount: Integer);
//計(jì)算電炊用戶(hù)數(shù)
Procedure P_CalcCooks();
//計(jì)算指定臺(tái)變下的電炊用戶(hù)數(shù)
Procedure P_CalcTransferCooks(vTransferNo:String);
//設(shè)置結(jié)算方式
Procedure SetIronMode(IronMode: Boolean);
//從數(shù)據(jù)庫(kù)中讀取結(jié)算方式, 加變損時(shí)返回True
Function GetIronMode():Boolean;
var//定義全局變量
gRootPath: String;//啟動(dòng)目錄
LoginNo: String;//當(dāng)前注冊(cè)用戶(hù)號(hào)
LoginName: String;//當(dāng)前注冊(cè)用戶(hù)名
LoginPassword: String;//當(dāng)前注冊(cè)用戶(hù)口令
LoginPrivilege: SmallInt;//當(dāng)前注冊(cè)用戶(hù)權(quán)限
LoginPrivilegeName: String;//當(dāng)前注冊(cè)用戶(hù)權(quán)限說(shuō)明
IniFile: TIniFile; //用戶(hù)配置文件
WarnExit, WarnBackup:Boolean;//退出前提醒,退出時(shí)提醒備份數(shù)據(jù)
AutoIncrease, AlwaysPreview: Boolean;//自動(dòng)增加,總是預(yù)覽
//以下定義缺省值
DefaultSection: String;//缺省的Ini文件的中Section
Default_Elect_No:Variant;//用電類(lèi)別
Default_Volume_No:String;//卡本號(hào)
Default_Voltage_No:Variant;//電壓類(lèi)別
Default_Station_No:Variant;//供電所
Default_Line_No:Variant;//線路
Default_Transfer_No:Variant;//變壓器
Default_Town_No:Variant;//辦事處
Default_Village_No:Variant;//村
Default_Fix_Date:Boolean;//建卡日期指定
Default_Date:TDateTime;//建卡日期
Default_Comput:String;//核算
Default_Auditing:String;//審核
Default_Use:String;//制作,使用人
Default_Fee:string;//收費(fèi)
Default_ImportServer:String;//自動(dòng)抄表服務(wù)器地址
Default_ExPNoImportPort:Word;//PNo數(shù)據(jù)引入端口
Default_Ammeter_Fix_Date:Boolean;//裝表日期指定
Default_Ammeter_Date:TDateTime;//裝表日期
Default_Ammeter_Model:Variant;//計(jì)量表型號(hào)
Default_CT_Model:Variant;//CT型號(hào)
Default_Box_No:String;//箱號(hào),無(wú)需設(shè)置
CorpName:string;//公司名稱(chēng)
StationName:String;//用戶(hù)供電所名
AutoNo:Boolean;//自動(dòng)生成編號(hào)
AutoLastCount:Boolean;//自動(dòng)底數(shù)
CurrentYear:String;//當(dāng)前年份
CurrentMonth:String;//當(dāng)前月份
PageWidth:Integer;//紙張寬度,單位毫米
PageLength:Integer;//紙張長(zhǎng)度,單位毫米
ProgressBarStep:Integer;//進(jìn)度條的步長(zhǎng)
SysInfoSection: String;//系統(tǒng)信息
DBVer: Integer = 20020327;//數(shù)據(jù)庫(kù)版本
DBYear: Word = 2002;//數(shù)據(jù)庫(kù)數(shù)據(jù)年度
DBMonth:Word = 3;//數(shù)據(jù)庫(kù)數(shù)據(jù)月份
IronMode: Boolean;//加鐵損方式結(jié)算電費(fèi)?
FeeLowLimit: Integer;//允許并入下月收費(fèi)電量低限
gFeeDBServer: String;//中心收費(fèi)數(shù)據(jù)庫(kù)服務(wù)
gEnabledFee: Boolean;//是否使用收費(fèi)功能
implementation
uses Table_Dm, Proc_Dm, Comm, Windows, Dialogs;
//記錄工作日志
procedure P_Log(v_Log:String;v_Type:String);
Begin
Try
With DM_Proc,sp_log Do
Begin
if LoginName <> '' Then
Params.ParamValues['v_log'] := LoginName + ':' + v_Log
else
Params.ParamValues['v_log'] := v_Log;
Params.ParamValues['v_type'] := v_Type;
Prepare();
ExecProc();
UnPrepare();
End;
Except
MessageBeep(MB_OK);
MessageDlg('消息:['+v_Log+']未能正確記入日志', mtWarning, [mbOK], 0 );
End;
End;
//修改當(dāng)前用戶(hù)的口令
procedure P_Upd_Password(v_Password:String);
Begin
With DM_Proc,sp_upd_password Do
Begin
Params.ParamValues['v_Password'] := v_Password;
Params.ParamValues['v_Person_No'] := LoginNo;
Prepare();
ExecProc();
UnPrepare();
End;
P_Log('更改口令');
End;
//獲得數(shù)據(jù)庫(kù)操作的消息
procedure p_GetMsg(Var v_Sender, v_Content:String);
Begin
With DM_Proc,sp_GetMsg Do
Begin
Prepare();
ExecProc();
v_Sender := Trim(Params.ParamValues['v_Sender']);
v_Content := Trim(Params.ParamValues['v_Content']);
UnPrepare();
End;
End;
//設(shè)置指定表的邏輯表號(hào)
Procedure p_SetLNo(vHouseNo:String;vAmmeterOrder:String;vLNo:String);
Begin
If DM_Table.Query.Active Then
DM_Table.Query.Close();
DM_Table.Query.SQL.Text := Format('Update Tb_Ammeter Set f_LNo = ''%s'' Where f_House_No = ''%s'' And f_Ammeter_Order = %s',[vLNo,vHouseNo,vAmmeterOrder]);
DM_Table.Query.ExecSQL();
End;
//設(shè)置指定表的本月抄表數(shù)
procedure p_SetThis_Count(v_House_No:String;V_Ammeter_Order:String;V_This_Count, v_Adjust_Count:Real; V_Note:String);
Begin
With Dm_Proc,sp_SetThis_Count Do
Begin
Params.ParamValues['v_House_No'] := v_House_No;
Params.ParamValues['v_Ammeter_Order'] := StrToInt(v_Ammeter_Order);
Params.ParamValues['v_This_Count'] := Int(v_This_Count);
Params.ParamValues['v_Adjust_Count'] := v_Adjust_Count;
Params.ParamValues['v_Note'] := v_Note;
Prepare();
ExecProc();
UnPrepare();
End;
End;
//設(shè)置指定表的本月抄表數(shù)為空
procedure p_SetThis_Null(v_House_No:String;V_Ammeter_Order:String);
Begin
With Dm_Proc,sp_SetThis_Null Do
Begin
Params.ParamValues['v_House_No'] := v_House_No;
Params.ParamValues['v_Ammeter_Order'] := StrToInt(v_Ammeter_Order);
Prepare();
ExecProc();
UnPrepare();
End;
End;
//根據(jù)表號(hào)得到戶(hù)號(hào),戶(hù)名,上次抄表數(shù)
procedure p_GetHouse(V_House_No:String;v_Ammeter_Order:Integer; Var V_House_Name:String; Var v_Last_Count:Real);
Begin
With Dm_Proc,sp_GetHouse Do
Begin
Params.ParamValues['v_House_No'] := v_House_No;
Params.ParamValues['v_Ammeter_Order'] := v_Ammeter_Order;
Prepare();
ExecProc();
V_House_Name := Params.ParamValues['v_House_Name'];
V_Last_Count := Params.ParamValues['v_Ammeter_Last_Count'];
UnPrepare();
End;
End;
//計(jì)算本月電費(fèi)
procedure p_MonthFee();
Begin
Dm_Proc.sp_MonthFee.ExecProc();
P_Log('計(jì)算電費(fèi)');
end;
//存儲(chǔ)并清除上月抄表數(shù)據(jù)
procedure p_NewMonth();
Begin
Dm_Proc.Sp_NewMonth.ExecProc();
P_Log('執(zhí)行月底結(jié)帳操作');
End;
//檢查抄表數(shù)據(jù)的合法性
procedure p_Valid;
Begin
Dm_Proc.Sp_Valid.ExecProc();
End;
//設(shè)置上月抄表數(shù)據(jù)
procedure p_SetLast;
Begin
Dm_Proc.Sp_SetLast.ExecProc();
P_Log('重置上月抄表數(shù)');
End;
//打印或預(yù)覽報(bào)表
procedure p_Print_Report(Rpt:TQuickRep);
Var
bError: Boolean;
Begin
bError := true;
Try
If AlwaysPreview then
Begin
Rpt.PreviewModal();
P_Log('預(yù)覽報(bào)表'+Rpt.Name);
End
Else
Begin
Rpt.Print;
P_Log('打印報(bào)表'+Rpt.Name);
End;
bError := false;
Finally
if bError Then
Begin
Rpt.Destroy;
P_Log('報(bào)表 '+Rpt.Name+' Error');
End;
End;
end;
//返回下一可辦事處編號(hào)
function f_NextTownNo:String;
Begin
With Dm_Proc, sp_MaxTownNo Do
Begin
Prepare();
ExecProc();
UnPrepare();
Result := F_NextNumber(Params.ParamValues['V_Town_No']);
End;
End;
//返回指定辦事處的下一可用村號(hào)
function f_NextVillageNo(V_Town_No:String):String;
begin
With DM_Proc, sp_MaxVillageNo do
Begin
Prepare();
Params.ParamValues['V_Town_No'] := V_Town_No;
ExecProc();
UnPrepare();
Result := F_NextNumber(Params.ParamValues['V_Village_No']);
End;
end;
//返回指定供電所的下一可用線路號(hào)
function f_NextLineNo(V_Station_No:String):String;
begin
With DM_Proc, sp_MaxLineNo do
Begin
Prepare();
Params.ParamValues['V_Station_No'] := V_Station_No;
ExecProc();
UnPrepare();
Result := F_NextNumber(Params.ParamValues['V_Line_No']);
End;
end;
//返回指定線路的下一可用編壓器號(hào)
function f_NextTransferNo(V_Line_No:String):String;
begin
With DM_Proc, sp_MaxTransferNo do
Begin
Prepare();
Params.ParamValues['V_Line_No'] := V_Line_No;
ExecProc();
UnPrepare();
Result := F_NextNumber(Params.ParamValues['V_Transfer_No']);
End;
end;
//返回下一可用戶(hù)號(hào)
function f_NextHouseNo(V_Transfer_No:String):String;
begin
With DM_Proc, sp_MaxHouseNo do
Begin
Prepare();
Params.ParamValues['V_Transfer_No'] := V_Transfer_No;
ExecProc();
UnPrepare();
Result := F_NextNumber(Params.ParamValues['V_House_No']);
End;
end;
procedure p_GetAmmeter(v_House_No:String;
?? 快捷鍵說(shuō)明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號(hào)
Ctrl + =
減小字號(hào)
Ctrl + -