摘 要…………………………………………………………………………1
Abstract………………………………………………………………………2
第一章 引言…………………………………………………………………4
1.1 课题背景……………………………………………………………………4
1.2 系统简介……………………………………………………………………5
第二章 系统的分析……………………………………………………………6
2.1 系统开发的目标和思想……………………………………………………6
2.2 系统的可行性分析…………………………………………………………8
第三章 系统的设计……………………………………………………………18
3.1 系统的功能结构设计………………………………………………………18
3.2 系统的数据库设计
3.3 界面设计与代码设计……………………………………………………………………23
…………………………………………………………24
结束语………………………………………………………………………………46
致谢…………………………………………………………………………………47
参考文献……………………………………………………………………………48
摘 要
传统的电费管理都是由工作人员手工查表,抄表完成的,其中要完成用户电费的收取,每月抄度,用户购电情况查询,以及列出欠费用户的信息名单,之类的信息.其工作强度大,工作流程繁琐,由于工作人员的不细心,将会造成电费收支的出错也是经常发生的.鉴于以上原因我们有必要开发一种帮作电费管理人员的软件系统,可以完成检查用户用电情况,每月抄度,信息录入以及基本数据维护的各项功能.本系统采用visual basic 6.0与微软Access数据库方式.界面尽量做到人性化,数据维护方面做到可靠安全.
关键字: 电费管理,visual basic, Access,数据库
Abstract
Electricity from the traditional management staff are artisanal Chabiao, meter reading completed, which should be completed by the users of electricity per month penalty for users to buy electricity enquiries, and a list of user information channels list such information. Its work-intensive, cumbersome workflow, because staff are not careful. would result in the tariff revenue is recurring mistakes. Given the above reasons we need to develop a management software to help make electricity system, the user can complete the inspection of electricity monthly copied degrees, Information includes basic data and the maintenance function. with the system using visual basic Microsoft Access 6.0 database. as far as possible humanization interface, data maintenance to reliable security.
keyword : tariff management, visual basic, Access, the database
-
引言
-
课题背景
-
传统的电费管理都是由工作人员手工查表,抄表完成的,其中要完成用户电费的收取,每月抄度,用户购电情况查询,以及列出欠费用户的信息名单,之类的信息.其工作强度大,工作流程繁琐,由于工作人员的不细心,将会造成电费收支的出错也是经常发生的.鉴于以上原因我们有必要开发一种帮作电费管理人员的软件系统,可以完成检查用户用电情况,每月抄度,信息录入以及基本数据维护的各项功能.本系统采用visual basic 6.0与微软Access数据库方式.界面尽量做到人性化,数据维护方面做到可靠安全.
-
- 系统简介
本系统主要由以下几大功能模块组成:
- 用户交费:(交纳电费,本日小节)
- 本月抄度:(单户抄度 多户抄度)
- 资料导出 (全部清单,欠费清单)
- 数据查询 (电费查询与统计,用户欠费查询)
- 信息录入 (资料录入,资料修改, 资料删除)
- 系统数据维护 (数据备份,数据恢复)
- 基本数据维护 (用户类型维护, 操作员维护)
- 帮助
- 退出
-
系统的分析
-
-
系统开发的目标和思想
-
本系统主要服务于电费管理人员的日常工作.设计思路主要参照工作人员抄表,记录资料,资料管理,信息录入等方面的工作流程展开的.
-
-
系统的可行性分析
-
本系统采用visual basic6.0与微软的access作为数据库结合.在系统编写上具有可行性.
经济方面:本系统可以服务电厂,电费管理单位,为企业节省人力开支.
社会方面:服务于大众,方便抄表人员工作,可靠方便.
-
系统的设计
-
-
系统的功能结构设计
-
-
- 系统的数据库设计
- 用户类型表:
字段名称 | 数据类型 | 说明 |
ATypeID | 自动编号 | |
AType | 文本 | 电费类型 |
UNITPRICE | 货币 | |
Adate | 日期/时间 | 电费设置日期 |
- 密码表:
字段名称 | 数据类型 |
姓名 | 文本 |
操作权限 | 文本 |
密码 | 文本 |
- MaxID表:
字段名称 | 数据说明 |
TableName | 文本 |
MaxID | 数字 |
-
- 界面设计与代码设计
1.用户登陆界面设计:
-
- 界面设计与代码设计
用户登陆界面代码分析:
Private Sub Command1_Click()
Dim rstpchard As New ADODB.Recordset
Dim reHard As String
Dim getid As String
reHard = GetpcHard(getid)
rstpchard.Open "select * from getpchard ", gCnn, adOpenKeyset, adLockBatchOptimistic
If rstpchard.RecordCount = 0 Then
rstpchard.AddNew
rstpchard.Fields(0) = reHard
rstpchard.UpdateBatch adAffectCurrent
Else
If Trim(reHard) <> Trim(rstpchard.Fields(0)) Then
MsgBox " 对不起,使用不合法请与开发者联系! ", vbInformation
End
End If
End If
If Check1.Value = 1 Then
Set rec = New ADODB.Recordset
rec.Open "select * from 记住密码", gCnn, 3, 3
rec("标记") = "1"
If Combo2.Text <> "" Then
rec("姓名") = Combo2.Text
Else
rec("姓名") = ""
End If
If Combo1.Text <> "" Then
rec("权限") = Combo1.Text
Else
rec("权限") = ""
End If
If Text2.Text <> "" Then
rec("密码") = Text2.Text
Else
rec("密码") = ""
End If
rec.Update
rec.Close
Else
Set rec = New ADODB.Recordset
rec.Open "select * from 记住密码", gCnn, 3, 3
rec("标记") = "0"
rec.Update
rec.Close
End If
Dim rec1 As ADODB.Recordset
Set rec1 = New ADODB.Recordset
rec1.Open "select * from 登录人员", gCnn, 3, 3
Set rec = New ADODB.Recordset
rec.Open "select * from 密码表 where 姓名='" & Combo2.Text & "'and 操作权限='" & Combo1.Text & "'and 密码='" & Text2.Text & "'", gCnn, 3, 3
If rec.EOF = False Then
If rec("操作权限") <> "管理员" Then
' FRMMAIN.XZCK.Enabled = False
MDIme.mczy.Enabled = False
MDIme.xtwh.Enabled = False
MDIme.del.Enabled = False
' FRMMAIN.DJGL.Enabled = False
' FRMMAIN.delte.Enabled = False
Else
' Me.XZCK.Enabled = True
MDIme.mczy.Enabled = True
MDIme.xtwh.Enabled = True
CreateNewKey HKEY_CURRENT_USER, "ZhiYuanTechnologe"
SetKeyValue HKEY_CURRENT_USER, "ZhiYuanTechnologe", "UserName", dlj, REG_SZ
SetKeyValue HKEY_CURRENT_USER, "ZhiYuanTechnologe", "PassWord", dlj, REG_SZ
' FRMMAIN.DJGL.Enabled = True
' FRMMAIN.delte.Enabled = True
End If
rec1("姓名") = Combo2.Text
rec1.Update
rec1.Close
Me.Hide
Guser = Combo2.Text
MDIme.Show
Else
MsgBox "权限或密码不正确,请重试!", vbInformation
End If
rec.Close
End Sub
Private Sub Command11_Click()
End Sub
Private Sub Command2_Click()
Combo2.Text = ""
Text2.Text = ""
Combo1.Text = ""
End Sub
Private Sub Command3_Click()
End
End Sub
Private Sub Command4_Click()
Me.Hide
FRMMMXG.Show 1
End Sub
Private Sub Form_Activate()
Text2.Text = ""
Combo1.Text = ""
Combo2.Text = ""
Set rec = New ADODB.Recordset
rec.Open "select * from 记住密码", gCnn, 3, 3
If rec("标记") = "0" Or rec("标记") = "1" Then
Check1.Value = rec("标记")
End If
rec.Close
Set rec = New ADODB.Recordset
rec.Open "select * from 记住密码", gCnn, 3, 3
If rec("标记") = 1 Then
Combo2.Text = rec("姓名")
Combo1.Text = rec("权限")
Text2.Text = rec("密码")
End If
rec.Close
Command1.SetFocus
End Sub
Private Sub Form_Load()
gCnn.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Jet OLEDB:database password= " & DbPassword & " ;Data Source= " & _
App.Path & "\data\dbdb.mdb;Persist Security Info=False"
gCnn.CursorLocation = adUseClient
gCnn.Open
Set rec = New ADODB.Recordset
rec.Open "select distinct 姓名 from 密码表", gCnn, 3, 3
With Combo2
Do Until rec.EOF
.AddItem rec("姓名")
rec.MoveNext
Loop
End With
rec.Close
Set rec = Nothing
End Sub
Private Sub Form_QueryUnload(Cancel As Integer, UnloadMode As Integer)
Cancel = True
Select Case MsgBox("此操作将退出本系统,继续吗?", vbYesNo, "警告")
Case vbYes
Cancel = False
End
Case Else
Cancel = True
End Select
End Sub
2.主界面设计:
主界面代码设计:
Private Sub alllm_Click()
frmList.qfFlg = False
frmList.Show
End Sub
Private Sub backup_Click()
frmbeifen.Show
End Sub
Private Sub benrixiaojie_Click()
frmCount.Show
End Sub
Private Sub Command1_Click()
frameFee.Visible = False
End Sub
Private Sub cmdQuery_Click()
Dim rst As New ADODB.Recordset
rst.Open " select * from panelinfo where holder='" & Me.txtUser & "' and delflag<>true ", gCnn, adOpenStatic, adLockBatchOptimistic
If rst.RecordCount <> 0 Then
dcvalue.Text = rst.Fields(2)
txtUserName(0) = rst.Fields(1)
txtUserName(1) = rst.Fields!nowecount
txtUserName(2) = rst.Fields!cendcode
dtpwdate.Value = rst.Fields(4)
txtUserName(3) = Format(rst.Fields!lMoney, "###0.00")
txtUserName(4) = Format(rst.Fields!bmoney, "###0.00")
txtUserName(6) = Format(rst.Fields!lsFee, "###0.00")
'txtUserName(5) = txtUserName(1) * rst.Fields!lMoney * (rst.Fields!lightScale / 100) + txtUserName(1) * txtUserName(4) * (1 - rst.Fields!lightScale / 100)
txtUserName(5) = Format(txtUserName(1) * rst.Fields!lMoney * (rst.Fields!lightScale / 100) + rst.Fields!nowecount * rst.Fields!bmoney * (1 - rst.Fields!lightScale / 100), "###0.00")
txtUserName(8) = rst.Fields(9)
txtUserName(7) = Format(Val(txtUserName(5)) + Val(txtUserName(6)), "####0.00")
dcNum.Text = rst.Fields(1)
Else
MsgBox " 没有查询到数据! ", vbInformation
End If
rst.Close
Set rst = Nothing
End Sub
Private Sub dcNum_Click(Area As Integer)
Dim rst As New ADODB.Recordset
rst.Open " select * from panelinfo where holderid='" & dcNum.Text & "'and delflag<>true ", gCnn, adOpenKeyset, adLockBatchOptimistic
If Not rst.EOF Then
dcvalue.Text = rst.Fields(2)
txtUserName(0) = rst.Fields(1)
txtUserName(1) = rst.Fields!nowecount
txtUserName(2) = rst.Fields!cendcode
dtpwdate.Value = rst.Fields(4)
txtUserName(3) = Format(rst.Fields!lMoney, "###0.00")
txtUserName(4) = Format(rst.Fields!bmoney, "###0.00")
txtUserName(6) = Format(rst.Fields(8), "####0.00")
txtUserName(5) = Format(txtUserName(1) * txtUserName(3) * (rst.Fields!lightScale / 100) + txtUserName(1) * txtUserName(4) * (1 - rst.Fields!lightScale / 100), "####0.00")
txtUserName(8) = rst.Fields(9)
txtUserName(7) = Format(Val(txtUserName(5)) + Val(txtUserName(6)), "####0.00")
End If
rst.Close
End Sub
Private Sub dcvalue_Click(Area As Integer)
Dim rst As New ADODB.Recordset
rst.Open " select * from panelinfo where holderid='" & dcvalue.BoundText & "' and delflag<>true ", gCnn, adOpenStatic, adLockBatchOptimistic
If Not rst.EOF Then
dcvalue.Text = rst.Fields(2)
txtUserName(0) = rst.Fields(1)
txtUserName(1) = rst.Fields!nowecount
txtUserName(2) = rst.Fields!cendcode
dtpwdate.Value = rst.Fields(4)
txtUserName(3) = Format(rst.Fields!lMoney, "###0.00")
txtUserName(4) = Format(rst.Fields!bmoney, "###0.00")
txtUserName(6) = Format(rst.Fields!lsFee, "###0.00")
'txtUserName(5) = txtUserName(1) * rst.Fields!lMoney * (rst.Fields!lightScale / 100) + txtUserName(1) * txtUserName(4) * (1 - rst.Fields!lightScale / 100)
txtUserName(5) = Format(txtUserName(1) * rst.Fields!lMoney * (rst.Fields!lightScale / 100) + rst.Fields!nowecount * rst.Fields!bmoney * (1 - rst.Fields!lightScale / 100), "###0.00")
txtUserName(8) = rst.Fields(9)
txtUserName(7) = Format(Val(txtUserName(5)) + Val(txtUserName(6)), "####0.00")
dcNum.Text = rst.Fields(1)
End If
rst.Close
Set rst = Nothing
End Sub
Private Sub dcvalue_KeyPress(KeyAscii As Integer)
KeyAscii = 0
End Sub
Private Sub del_Click()
frmdel.Show
End Sub
Private Sub dhcb_Click()
usrcopyP.Show
End Sub
Private Sub dhcp_Click()
frmCopyP.Show
End Sub
Private Sub duohu_Click()
frmCuifei.muser1 = 2
frmCuifei.Show
End Sub
Private Sub edit_Click()
frmEdit.Show
End Sub
Private Sub exit_Click()
End
End Sub
Private Sub insert_Click()
frmInsert.Show 1
End Sub
Private Sub jiaonadianfei_Click()
frmFee.Show
End Sub
Private Sub M_USERYTPE_Click()
FRMUSERTYPE.Show 1
End Sub
Private Sub MDIForm_Load()
loadAdd
End Sub
Public Sub loadAdd()
If rst.State = 1 Then
rst.Close
End If
rst.Open " select * from panelinfo where delflag<>true ", gCnn, adOpenKeyset, adLockBatchOptimistic
If rst.RecordCount <> 0 Then
Set dcvalue.RowSource = rst
dcvalue.BoundColumn = "holderID"
dcvalue.ListField = "holder"
Set dcNum.DataSource = rst
Set dcNum.RowSource = rst
dcNum.ListField = "holderid"
If Not rst.EOF Then
dcNum.Text = rst.Fields!holderid
dcvalue.Text = rst.Fields(2)
txtUserName(0) = rst.Fields(1)
txtUserName(1) = rst.Fields!nowecount
txtUserName(2) = rst.Fields!cendcode
dtpwdate.Value = rst.Fields(4)
txtUserName(3) = Format(rst.Fields!lMoney, "##0.00")
txtUserName(4) = Format(rst.Fields!bmoney, "###.0.00")
txtUserName(6) = rst.Fields!lsFee
txtUserName(5) = Val(txtUserName(1)) * Val(txtUserName(3)) * (Val(rst.Fields!lightScale) / 100) + Val(txtUserName(1)) * Val(txtUserName(4)) * (1 - rst.Fields!lightScale / 100)
txtUserName(8) = rst.Fields(9)
txtUserName(7) = Val(txtUserName(5)) + Val(txtUserName(6))
rst.Fields!cFeeMoney = txtUserName(7)
rst.UpdateBatch adAffectCurrent
End If
End If
End Sub
Public Sub loadData(Hid As String)
Dim rst As New ADODB.Recordset
Dim cnn As New ADODB.Connection
Dim Atimes As Integer
Dim sqlAdd As String
cnn.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Jet OLEDB:database password= " & DbPassword & " ;Data Source= " & _
App.Path & "\data\dbdb.mdb;Persist Security Info=False"
cnn.CursorLocation = adUseClient
cnn.Open
If Trim(Hid) <> "" Then
rst.Open " select * from panelinfo where holderid='" & Hid & "' and delflag<>true ", cnn, adOpenStatic, adLockBatchOptimistic
Else
rst.Open " select * from panelinfo where delflag<>true ", cnn, adOpenStatic, adLockBatchOptimistic
End If
If Not rst.EOF Then
dcNum.Text = rst.Fields!holderid
dcvalue.Text = rst.Fields(2)
txtUserName(0) = rst.Fields(1)
txtUserName(1) = rst.Fields!nowecount
txtUserName(2) = rst.Fields!cendcode
dtpwdate.Value = rst.Fields(4)
txtUserName(3) = Format(rst.Fields!lMoney, "####0.00")
txtUserName(4) = Format(rst.Fields!bmoney, "####0.00")
txtUserName(6) = Format(rst.Fields!lsFee, "####0.00")
'txtUserName(5) = Format(txtUserName(1) * txtUserName(3) * (rst.Fields!lightScale / 100) + txtUserName(1) * txtUserName(4) * (1 - rst.Fields!lightScale / 100), "####0.00")
If rst.Fields!Atimes = 0 Then
Atimes = 1
Else
Atimes = rst.Fields!Atimes
End If
txtUserName(5) = Format(Val(txtUserName(1)) * txtUserName(3) * Atimes, "####0.00")
txtUserName(8) = rst.Fields(9)
txtUserName(7) = Format(Val(txtUserName(5)) + Val(txtUserName(6)), "####0.00")
rst.Fields!cFeeMoney = txtUserName(7)
rst.UpdateBatch adAffectCurrent
End If
rst.Close
cnn.Close
End Sub
Private Sub MDIForm_Unload(Cancel As Integer)
gCnn.Close
Set gcon = Nothing
End Sub
Private Sub mgcf_Click()
frmFeefind.Show
End Sub
Private Sub mhf_Click()
frmdaoru.Show
End Sub
Private Sub msf_Click()
frmFind1.Show
End Sub
Private Sub qianfeilm_Click()
frmList.qfFlg = True
frmList.Show
End Sub
Private Sub Toolbar1_ButtonClick(ByVal Button As MSComctlLib.Button)
Select Case Trim(Button.Key)
Case "a"
frmFee.Show 1
Case "b"
frmCopyP.Show
Case "c"
frmFee.Show 1
Case "d"
frmbeifen.Show 1
Case "e"
frmdaoru.Show 1
Case "f"
frmFeefind.Show 1
Case "g"
frmFind1.Show 1
Case "dhcb1"
Case "dbcb2"
Case "j"
X = MsgBox("真的要退出吗?", vbYesNo + vbQuestion, "警告")
If X = vbYes Then
End
Else
End If
End Select
End Sub
Private Sub Toolbar1_ButtonMenuClick(ByVal ButtonMenu As MSComctlLib.ButtonMenu)
Select Case ButtonMenu.Key
Case "dhcb1"
frmCopyP.Show
Case "dhcb2"
usrcopyP.Show
End Select
End Sub
Private Sub weihu_Click()
FRMYHSD.Show
End Sub
Private Sub yihu_Click()
frmCuifei.muser1 = 1
frmCuifei.Show
End Sub
- 备份界面设计:
:
备份代码设计:
Private Sub Command1_Click()
Dim a As String
a = App.Path
a = a & "\"
b = Text1.Text
'On Error GoTo errhandle:
Dim filename As String
filename = "" & Text1.Text & "dbdb.mdb"
If a = Text1.Text Then
MsgBox "备份目录与原文件目录相同,请重新选择!"
Exit Sub
End If
If Dir("" & b & "dbdb.mdb") <> "" Then
Dim llp As String
llp = MsgBox("此目录下已有该文件,要覆盖吗?", vbYesNo, "备份文件")
If llp = vbYes Then
Kill ("" & b & "dbdb.mdb")
FileCopy "" & a & "\data\dbdb.mdb", "" & b & "dbdb.mdb"
Dim l
l = MsgBox(" 备份成功! ", vbOKOnly, "提示")
Else
Exit Sub
End If
Else
FileCopy "" & a & "\data\dbdb.mdb", "" & b & "dbdb.mdb"
Dim ll
ll = MsgBox(" 备份成功! ", vbOKOnly, "提示")
End If
Exit Sub
'errhandle:
'MsgBox "出现错误,不能复制", vbOKOnly + vbCritical, "复制文件"
'Resume Next
End Sub
Private Sub Command2_Click()
'dy
'Me.Hide
Unload Me
End Sub
Private Sub Dir1_Change()
'Drive1.Drive = Dir1
If Right(Dir1.Path, 1) <> "\" Then
Text1.Text = Dir1.Path + "\"
Else
Text1.Text = Dir1.Path
End If
Command1.Enabled = True
End Sub
Private Sub Dir1_Click()
If Right(Dir1.Path, 1) <> "\" Then
Text1.Text = Dir1.Path + "\"
Else
Text1.Text = Dir1.Path
End If
Command1.Enabled = True
End Sub
Private Sub Drive1_Change()
Dir1.Path = Drive1.Drive
End Sub
Private Sub Form_Activate()
Command1.Enabled = False
gCnn.Close
ChDrive App.Path
ChDir App.Path
'Text1.SetFocus
'Text1.Text = "c:\"
Text1.Text = CurDir()
Text1.Enabled = False
End Sub
Private Sub Form_Load()
ChDrive App.Path
ChDir App.Path
End Sub
Private Sub Form_QueryUnload(Cancel As Integer, UnloadMode As Integer)
dy
End Sub
Private Sub Form_Unload(Cancel As Integer)
If gCnn.State = 0 Then
gCnn.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Jet OLEDB:database password= " & DbPassword & " ;Data Source= " & _
App.Path & "\data\dbdb.mdb;Persist Security Info=False"
gCnn.CursorLocation = adUseClient
gCnn.Open
End If
MDIme.loadAdd
End Sub
- 单户抄表界面设计:
单户抄表代码设计:
Private Sub Command2_Click()
Dim cnn As New ADODB.Connection
Dim rstE As New ADODB.Recordset
Dim cmdExe As New ADODB.Command
Dim nowEv As Double
Dim sqlAdd As String
If Trim(txtUserName(0).Text) = "" Then
MsgBox " 没有要抄表用户,请先添加用户! ", vbInformation
Exit Sub
End If
If Trim(txtUserName(9).Text) = "" Then
MsgBox " 请先输入数据! ", vbInformation
Exit Sub
End If
If Trim(txtUserName(9).Text) < Trim(txtUserName(2).Text) Then
MsgBox " 输入数据错误,当前止码太小! ", vbInformation
Exit Sub
End If
cnn.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Jet OLEDB:database password= " & DbPassword & " ;Data Source= " & _
App.Path & "\data\dbdb.mdb;Persist Security Info=False"
cnn.CursorLocation = adUseClient
cnn.Open
cmdExe.ActiveConnection = cnn
rstE.Open "select nowecount from panelinfo where holderID= '" & Trim(txtUserName(0)) & "'", cnn, adOpenStatic, adLockBatchOptimistic
nowEv = Val(rstE.Fields(0).Value) + (Val(txtUserName(9)) - Val(txtUserName(2)))
sqlAdd = "update panelinfo set LEndPCode=" & Val(txtUserName(2).Text) & ",cEndCode=" & Val(txtUserName(9).Text) & ",nowEcount=" & nowEv & " ,writedate=#" & dtpwdate(1) & "# where holderID= '" & Trim(txtUserName(0)) & "'"
cmdExe.CommandText = sqlAdd
cmdExe.Execute sqlAdd
' cnn.Execute sqlAdd
txtUserName(2).Text = txtUserName(9)
txtUserName(9) = ""
cnn.Close
MsgBox " 数据保存完成! ", vbInformation
Unload Me
End Sub
Private Sub Form_Load()
Dim rst As New ADODB.Recordset
Dim sqlEdit As String
dtpwdate(1).Value = Format(Now, "yyyy-mm-dd")
sqlEdit = "select * from panelinfo "
sqlEdit = sqlEdit & " where holderid='" & Trim(MDIme.txtUserName(0)) & "'and delflag<>true"
rst.Open sqlEdit, gCnn, adOpenStatic, adLockBatchOptimistic
If Not rst.EOF Then
txtUserName(0) = rst.Fields(1)
txtUserName(1) = rst.Fields(2)
txtUserName(2) = rst.Fields!cendcode
dtpwdate(0).Value = rst.Fields(4)
End If
buttontime = False
End Sub
Private Sub Form_Unload(Cancel As Integer)
MDIme.loadData (txtUserName(0))
Cancel = 0
End Sub
Private Sub nextuser_Click()
Dim rst As New ADODB.Recordset
Dim sqlEdit As String
- 数据导入界面设计:
Private Sub Command1_Click()
End If
Dir1.Path = Drive1.Drive
End Sub
Private Sub File1_Click()
Text1.Text = Text1.Text + File1.filename
Command1.Enabled = True
End Sub
Private Sub Form_Activate()
gCnn.Close
Command1.Enabled = False
'Text1.Text = "c:\"
Text1.Text = CurDir()
Text1.Enabled = False
End Sub
Private Sub Form_QueryUnload(Cancel As Integer, UnloadMode As Integer)
dy
Unload Me
End Sub
Private Sub Form_Unload(Cancel As Integer)
If gCnn.State = 0 Then
gCnn.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Jet OLEDB:database password= " & DbPassword & " ;Data Source= " & _
App.Path & "\data\dbdb.mdb;Persist Security Info=False"
gCnn.CursorLocation = adUseClient
gCnn.Open
End If
MDIme.loadAdd
End Sub
- 数据删除界面设计:
数据删除代码设计:
Private Sub cmdAsure_Click()
If MsgBox(" 你确定要删除该数据吗? ", vbInformation + vbYesNo) <> vbYes Then
Exit Sub
End If
If Trim(MDIme.dcvalue.BoundText) <> "" Then
For i = 0 To 10
If i <> 9 Then
MDIme.txtUserName(i) = ""
End If
- 数据修改界面设计:
数据修改代码设计:
Di
End Sub
Private Sub Command1_Click()
txtUserName(0) = rst.Fields(1)
txtUserName(1) = rst.Fields(2)
txtUserName(2) = rst.Fields(3)
- 开始收费界面设计:
开始收费代码设计:
10:数据查询界面设计:
数据查询代码设计:
Private Sub cmdExport_Click()
'导出网格数据到EXCEL中
Export rsdg, Me.dgexp, " 数据查询", "日期:" & Format(Now, "yyyy-mm-dd"), " 总电量:" & txtCountA & " 度 总金额:" & txtCount & " 元"
End Sub
Private Sub cmdQuery_Click()
Dim Sqlstr As String
Dim whrStr As String
Dim feeC As Double
Dim znjC As Double
Dim rstRg As New ADODB.Recordset
'拼Where 语句
whrStr = getWhrStr()
'取得网格的数据
Sqlstr = "select * from feels " & whrStr & " "
'MsgBox Sqlstr
If rsdg.State = 1 Then
rsdg.Close
End If
rsdg.Open Sqlstr, gCnn, adOpenStatic, adLockOptimistic
'Debug.Print Sqlstr
Set rsdg = getQueryData(Sqlstr)
Set dgexp.DataSource = rsdg
Sqlstr = " select sum(feeMoney),sum(Ecount) from feels " & whrStr & " "
If rstRg.State = 1 Then
rstRg.Close
End If
rstRg.Open Sqlstr, gCnn, adOpenStatic, adLockBatchOptimistic
txtCount = Format(rstRg.Fields(0), "####0.00") & " "
txtCountA = rstRg.Fields(1) & " "
rstRg.Close
MsgBox " 数据查询完成,共" & rsdg.RecordCount & " 条纪录!", vbInformation
End Sub
Private Function getWhrStr() As String
'功能描述:拼凑Where语句
'返回串值
Dim whrStr As String
'拼Where 语句
whrStr = "where 1 = 1 "
If Trim(Me.txtID) <> "" Then
whrStr = whrStr & " and holderid ='" & Trim(Me.txtID) & "' "
End If
If Trim(Me.txtUser) <> "" Then
whrStr = whrStr + " and holder like '%" & txtUser & "%'"
End If
If Trim(Me.txtMoney) <> "" Then
whrStr = whrStr + " and qianFee>= " & Me.txtMoney & ""
End If
whrStr = whrStr + " and Feedate>= #" & Me.dtpS & "# and Feedate<= #" & Me.dtpE & "# "
getWhrStr = whrStr
End Function
Private Sub cmdReturn_Click()
Unload Me
End Sub
Private Sub Form_Load()
dtpE.Value = Format(Now, "yyyy-mm-dd")
End Sub
Private Sub Form_Unload(Cancel As Integer)
If rsdg.State = 1 Then
rsdg.Close
End If
End Sub
11:费用查询界面设计:
费用查询代码设计:
Private Sub cmdExport_Click()
'导出网格数据到EXCEL中
Export rsdg, Me.dgexp, " 数据查询", Format(Now, "yyyy-mm-dd")
End Sub
Private Sub cmdQuery_Click()
Dim Sqlstr As String
Dim whrStr As String
Dim feeC As Double
Dim znjC As Double
'拼Where 语句
whrStr = getWhrStr()
'取得网格的数据 '2957387
Sqlstr = "select * from panelInfo " & whrStr & " "
'MsgBox Sqlstr
If rsdg.State = 1 Then
rsdg.Close
End If
rsdg.Open Sqlstr, gCnn, adOpenStatic, adLockOptimistic
Set rsdg = getQueryData(Sqlstr)
Set dgexp.DataSource = rsdg
MsgBox " 数据查询完成,共" & rsdg.RecordCount & " 条纪录!", vbInformation
End Sub
Private Function getWhrStr() As String
'功能描述:拼凑Where语句
'返回串值
Dim whrStr As String
'拼Where 语句
whrStr = "where 1 = 1 "
If Trim(Me.txtID) <> "" Then
whrStr = whrStr & " and holderid ='" & Trim(Me.txtID) & "' "
End If
If Trim(Me.txtUser) <> "" Then
whrStr = whrStr + " and holder like '%" & txtUser & "%'"
End If
If Trim(Me.txtMoney) <> "" Then
whrStr = whrStr + " and cFeeMoney>= " & Me.txtMoney & ""
End If
getWhrStr = whrStr
End Function
Private Sub cmdReturn_Click()
Unload Me
End Sub
Private Sub Form_Unload(Cancel As Integer)
If rsdg.State = 1 Then
rsdg.Close
End If
End Sub
结束语
本软件的设计目的是在电表收费管理维护方面为企事业单位和管理人员提供方便和帮助。通过这几个月的毕业设计,我学到很多以前没有学到的visual basic开发技术,在软件工程学上更是取得了很大的进步。经过大量的测试和试用,作者深信本软件达到了方便和实用的设计目的,并在软件界面和易用实用等方面有着独到之处。
虽然软件基本达到设计要求并且达到同行的先进水平,但由于作者水平有限,软件存在bug也是在所难免的 ,您的意见和建议将极大的帮助我改进并完善软件。真诚的希望你的参与。
参 考 文 献
1陈明 . 软件工程学教程 .科技出版社,2002
2 萨师煊,王珊 . 数据库系统概论 . 第三版 . 高等教育出版社,2000
3 飞思科技产品研发中心 . visual basic 6.0数据库应用开发 .电子工业出版社,2003
4 飞思科技产品研发中心 . visual basic 6.0开发者手册 . 电子工业出版社, 2002
5 申旻 . visual basic 6.0高手突破 . 清华大学出版社,2002,302
6 Steve Teixeira,Xaviver Pacheco著,龙劲松,王瑜,谢尚书译 . visual basic 6.0开发人员指南 . 机械工业出版社 .2003
7 乔林 .参透Delphi/Kylix . 中国铁道出版社 .2003
8 李维 .Inside 深入核心 VCL 架构剖析 . 电子工业出版社 .2004
9 张立科编写组 .Windows API 函数参考手册 .人民邮电出版社 .2002
严蔚敏,吴伟民 .数据结构 .第二版 .清华大学出版社 .2001
10 王珍玲 。实用软件工程教程 高等教育出版社 2004
11 (英)Ian Sommerville 机械工业出版社 2003
12 美Cantu,U. 王辉等译visual basic 6.0 从入门到精通 电子工业出版社 2003
13 李维 面向对象开发实践之路(visual basic 6.0版)(BORLAND资深顾问著名visual basic 6.0专家李维最新力作) 电子工业出版社 2005.4
14 秦斌 等 visual basic 6.0数据库系统开发与应用 中国水利水电出版社 2006 .1
15 刘艺 visual basic 6.0面向对象编程思想 机械工业出版社 2003
16.visual basic 程序设计第二版 谭浩强 清华大学出版社 2003
17. visual basic6.0 程序设计教程. 胡同森 赵剑锋等. 浙江科学技术出版社,2002.1
18.软件工程学教程 (第二版) 周苏 王文 著 科学出版社 2003
19.Visual Basic 6.0 程序设计与开发技术 求是科技 人民邮电出版社 2004.9