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

📄 commsmdljf.pas

📁 县级供电企业电费核算源码, 在客户处正常运行8年以上, Delphi 5开发,数据库为Interbase/Firebird, 深入使用Procedure和Trigger等, 对入门者具有很好的参考价值
💻 PAS
📖 第 1 页 / 共 2 页
字号:
unit CommSmdljf;

interface
uses IniFiles, SysUtils, QuickRpt, Msg_F;

//记录工作日志
procedure P_Log(v_Log:String;v_Type:String = '');
//修改当前用户的口令
procedure P_Upd_Password(v_Password:String);
//获得数据库操作的消息
procedure p_GetMsg(Var v_Sender, v_Content:String);
Procedure p_SetLNo(vHouseNo:String;vAmmeterOrder:String;vLNo:String);//设置指定表的逻辑表号
//设置指定表的本月抄表数
procedure p_SetThis_Count(v_House_No:String;V_Ammeter_Order:String;V_This_Count, v_Adjust_Count:Real; V_Note:String);
//设置指定表的本月抄表数为空
procedure p_SetThis_Null(v_House_No:String;V_Ammeter_Order:String);
//根据表号得到户号,户名,上次抄表数
procedure p_GetHouse(v_House_No:String;V_Ammeter_Order:Integer; Var V_House_Name:String; Var v_Last_Count:Real);
//计算本月电费
procedure p_MonthFee;
//存储并清除上月抄表数据
procedure p_NewMonth;
//检查抄表数据的合法性
procedure p_Valid;
//打印或预览报表
procedure p_Print_Report(Rpt:TQuickRep);
//设置上月抄表数据
procedure p_SetLast;
//返回下一可办事处编号
function f_NextTownNo:String;
//返回指定办事处的下一可用村号
function f_NextVillageNo(V_Town_No:String):String;
//返回指定供电所下一可用线路号
function f_NextLineNo(V_Station_No:String):String;
//返回指定线路的下一可用编压器号
function f_NextTransferNo(V_Line_No:String):String;
//返回指定变压器的下一可用户号
function f_NextHouseNo(V_Transfer_No:String):String;
//返回指定用户的相关表的信息
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);
//根据用户号得到表号
procedure p_GetAmmeterNo(v_House_No:String;	Var A_No1, A_No2, A_No3:String);
//求农网维护费单价
Function F_GetServicePrice(V_Elect_No:String):Extended;
//求农网维护费
Function F_GetServiceFee(V_House_No:String):Extended;
//求农网维护费相关信息
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);
//求国家电价
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);
//设置用户的当前选择
//Procedure p_SetCurrent(v_Class:String;v_Value:String);

//根据用户号求用电地址
Function F_GetAddress(V_House_No:String):String;
//根据用户号求线路名称
Function F_GetLine(V_House_No:String):String;
//取得当前系统月份
Procedure P_GetCurrentYearMonth(Var CYear, CMonth:String);
//显示消息窗口
Procedure P_OpenMessageBox(v_Caption:String;v_Msg:String);
//关闭消息窗口
Procedure P_CloseMessageBox;
//得到指定表的计量数
Function f_GetUsedCount(v_House_no:String;v_Ammeter_Order:Integer):Extended;
//根据村、社编号取得村、社名称
Procedure p_GetVillageName(v_Village_No:String;var v_Village_Name:String);
//设置变压器为自主供电
Procedure p_DisbranchTransfer(v_Transfer_No:String);
//设置变压器为并户供电方式
Procedure p_MergeTransfer(v_STransfer_No, v_DTransfer_No:String);
//用户换表
Procedure p_AmmeterReplace(v_House_No:String;v_Ammeter_Order:integer);
//变压器改编号
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);
//根据户号得到变压器相关信息
Procedure P_GetTransferInfo(vHouseNo:String;var vTransferNo, vTransferName:String; var vAmmeterCount, vAutoAmmeterCount: Integer);
//计算电炊用户数
Procedure P_CalcCooks();
//计算指定台变下的电炊用户数
Procedure P_CalcTransferCooks(vTransferNo:String);
//设置结算方式
Procedure SetIronMode(IronMode: Boolean);
//从数据库中读取结算方式, 加变损时返回True
Function GetIronMode():Boolean;


var//定义全局变量
	gRootPath:		String;//启动目录
	LoginNo:		String;//当前注册用户号
	LoginName:		String;//当前注册用户名
    LoginPassword:	String;//当前注册用户口令
    LoginPrivilege:	SmallInt;//当前注册用户权限
    LoginPrivilegeName: String;//当前注册用户权限说明
    
	IniFile: TIniFile;		//用户配置文件
    WarnExit, WarnBackup:Boolean;//退出前提醒,退出时提醒备份数据
    AutoIncrease, AlwaysPreview: Boolean;//自动增加,总是预览
//以下定义缺省值
    DefaultSection:	String;//缺省的Ini文件的中Section
    Default_Elect_No:Variant;//用电类别
    Default_Volume_No:String;//卡本号
    Default_Voltage_No:Variant;//电压类别
    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;//收费
    Default_ImportServer:String;//自动抄表服务器地址
    Default_ExPNoImportPort:Word;//PNo数据引入端口
	Default_Ammeter_Fix_Date:Boolean;//装表日期指定
    Default_Ammeter_Date:TDateTime;//装表日期
    Default_Ammeter_Model:Variant;//计量表型号
    Default_CT_Model:Variant;//CT型号
    Default_Box_No:String;//箱号,无需设置
    CorpName:string;//公司名称
    StationName:String;//用户供电所名
	AutoNo:Boolean;//自动生成编号
	AutoLastCount:Boolean;//自动底数
    CurrentYear:String;//当前年份
    CurrentMonth:String;//当前月份
    PageWidth:Integer;//纸张宽度,单位毫米
    PageLength:Integer;//纸张长度,单位毫米
    ProgressBarStep:Integer;//进度条的步长
    SysInfoSection: String;//系统信息
	DBVer: Integer = 20020327;//数据库版本
    DBYear: Word = 2002;//数据库数据年度
    DBMonth:Word = 3;//数据库数据月份
	IronMode: Boolean;//加铁损方式结算电费?
    FeeLowLimit: Integer;//允许并入下月收费电量低限

    gFeeDBServer: String;//中心收费数据库服务
    gEnabledFee: Boolean;//是否使用收费功能

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;

//修改当前用户的口令
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;

//获得数据库操作的消息
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;

//设置指定表的逻辑表号
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;

//设置指定表的本月抄表数
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;

//设置指定表的本月抄表数为空
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;

//根据表号得到户号,户名,上次抄表数
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;

//计算本月电费
procedure p_MonthFee();
Begin
    Dm_Proc.sp_MonthFee.ExecProc();
    P_Log('计算电费');
end;

//存储并清除上月抄表数据
procedure p_NewMonth();
Begin
	Dm_Proc.Sp_NewMonth.ExecProc();
    P_Log('执行月底结帐操作');
End;

//检查抄表数据的合法性
procedure p_Valid;
Begin
	Dm_Proc.Sp_Valid.ExecProc();
End;

//设置上月抄表数据
procedure p_SetLast;
Begin
	Dm_Proc.Sp_SetLast.ExecProc();
    P_Log('重置上月抄表数');
End;

//打印或预览报表
procedure p_Print_Report(Rpt:TQuickRep);
Var
	bError: Boolean;
Begin
	bError := true;
	Try
		If AlwaysPreview then
    	Begin
    		Rpt.PreviewModal();
		    P_Log('预览报表'+Rpt.Name);
    	End
    	Else
    	Begin
    		Rpt.Print;
		    P_Log('打印报表'+Rpt.Name);
        End;
        bError := false;
    Finally
		if bError Then
        Begin
        	Rpt.Destroy;
        	P_Log('报表 '+Rpt.Name+' Error');
        End;

    End;
end;

//返回下一可办事处编号
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;

//返回指定办事处的下一可用村号
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;

//返回指定供电所的下一可用线路号
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;

//返回指定线路的下一可用编压器号
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;

//返回下一可用户号
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;

⌨️ 快捷键说明

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