logo资料库

vb+access固定资产管理系统.doc

第1页 / 共8页
第2页 / 共8页
第3页 / 共8页
第4页 / 共8页
第5页 / 共8页
第6页 / 共8页
第7页 / 共8页
第8页 / 共8页
资料共8页,全文预览结束
vb+access 固定资产管理系统 固定资产管理系统 目 录 摘 要…………………………………………………………………………1 Abstract………………………………………………………………………2 第一章 引言…………………………………………………………………4 1.1 课题背景……………………………………………………………………4 1.2 系统简介……………………………………………………………………5 第二章 系统的分析……………………………………………………………6 2.1 系统开发的目标和思想……………………………………………………6 2.2 系统的可行性分析…………………………………………………………8 第三章 系统的设计……………………………………………………………18 3.1 系统的功能结构设计………………………………………………………18 3.2 界面设计与代码设计………………………………………………………23 3.3 系统的数据库设计…………………………………………………………24 结束语………………………………………………………………………………46 致谢…………………………………………………………………………………47 参考文献……………………………………………………………………………48 摘要 固定资产管理系统是一个企事业单位不可缺少的部分,它的内容对于企事业单位的决策者和管理者来说都至关重要, 所以固定资产管理系统应该能够为用户提供充足的信息和快捷的查询手段。但一直以来人们使用传统人工的方式管理固定 资产的信息,这种管理方式存在着许多缺点,如:效率低、保密性差,另外时间一长,将产生大量的文件和数据,这对于查 找、更新和维护都带来了不少的困难。本论文主要介绍的是固定资产管理系统的整个设计过程。随着计算机技术的不断发 展,计算机应用于各大领域,并给人们的生活带来了极大的便利,在固定管理系统亦是如此。以往固定资产员由于缺乏适 当的软件而给其工作带来了很多不便。本论文所介绍的便是一个固定资产管理系统,以方便在固定资产安排和固定资产管 理上的工作任务。该系统适用于普通固定资产的管理,在使用上力求操作容易,界面美观,另外,本系统具有较高的扩展 性和可维护性,可能在以后需要的时候进行软件升级。 整个系关键字: 固定资产,扩展性,可维护性 Abstract Fixed asset management system is an indispensable part of enterprise units, enterprises and institutions in its content, policy makers and managers is vital, therefore, fixed asset management system should be able to provide users with adequate information and efficient means enquiries. But all along th e way people use traditional artificial fixed asset management information, which means there are many sho rtcomings in the management, such as : low efficiency, confidentiality poor, and As time went on, will pro duce a large number of documents and data, which is essential for identifying, updating and maintenance ha ve brought many difficulties. This paper introduces a fixed asset management system as a whole design proc ess. With the continuous development of computer technology, computer applications major areas, and to the people's life has brought great convenience in the case of fixed management system. Members of the fixed assets in the past due to lack of appropriate software and bring a lot of inconvenience to their work. The
papers presented is a fixed asset management system to facilitate arrangements in fixed assets and fixed asset management tasks. The system applies to ordinary fixed assets management in the operation easy to us e, interface quality, and expansion of the system of higher and Keweihuxing may in the future need time so ftware upgrades. Entire department keywordt : Fixed assets, expansionary, Keweihuxing 第一章 引言 1.1 课题背景 固定资产管理系统是一个企事业单位不可缺少的部分,它的内容对于企事业单位的决策者和管理者来说都至关重要, 所以固定资产管理系统应该能够为用户提供充足的信息和快捷的查询手段。但一直以来人们使用传统人工的方式管理固定 资产的信息,这种管理方式存在着许多缺点,如:效率低、保密性差,另外时间一长,将产生大量的文件和数据,这对于查 找、更新和维护都带来了不少的困难。本论文主要介绍的是固定资产管理系统的整个设计过程。随着计算机技术的不断发 展,计算机应用于各大领域,并给人们的生活带来了极大的便利,在固定管理系统亦是如此。以往固定资产员由于缺乏适 当的软件而给其工作带来了很多不便。本论文所介绍的便是一个固定资产管理系统,以方便在固定资产安排和固定资产管 理上的工作任务。 1.2 系统简介 固定资产管理系统主要服务于企事业单位的决策者与管理者管理本单位的固定资产. 第二章 系统的分析 2.1 系统的开发目标与思想 本固定资产管理系统目标是方便企事业单位管理者管理本单位的固定资产,其主要思想是做到系统管理的人性化,数 据处理的可靠性,可维护性,以及程序的健壮性. 2.2 系统的可行性分析经济可行性: 固定资产管理系统为企事业单位提供更加方便的管理方式,为企事业单位获得更多的盈利机会.而且开发成本不会很 高.所以具有经济可行性. 社会可行性:固定资产的管理对每个单位对社会对国家来说都是有必要和必须的. 第三章 系统的设计 3.1 系统的功能结构设计 本固定资产管理系统主要有一下几大功能构成: 一.设备查询:主要提供”部门,设备名,型号,价格,分类,购置日期,注销日期”等信息的查询. 二.报表管理:主要提供”设备登记卡,部门统计表,注销统计表,折旧统计表”等信息管理. 三.系统管理;主要提供修改密码,退出系统等. 四.用户管理:新增用户,与删除用户等功能. 3.2 界面设计 1 登陆界面设计: 登陆界面代码设计: Private Sub cmdOK_Click() Dim strPwd As String Dim rsPwd As ADODB.Recordset Dim strLogin As String strLogin = Trim(txtUserName.Text) strPwd = Trim(txtPassword.Text) If Len(strLogin) = 0 Then MsgBox "用户名不能为空,请输入用户名" txtUserName.SetFocus Exit Sub
End If If Len(strPwd) = 0 Then MsgBox "密码不能为空,请输入正确的密码" txtPassword.SetFocus Exit Sub End If Set rsPwd = gConn.Execute("SELECT pwd FROM tblUser WHERE login='" & Replace(strLogin, "'", "''") & "' ") If rsPwd.EOF Then MsgBox "用户名不正确,请重新输入!" ElseIf strPwd = rsPwd("pwd").value Then '将代码放在这里传递 '成功到 calling 函数 '设置全局变量时最容易的 LoginSucceeded = True Me.Hide Else MsgBox "无效的密码,请重试!", , "登录" txtPassword.SetFocus SendKeys "{Home}+{End}" End If rsPwd.Close Set rsPwd = Nothing End Sub 2.主界面设计: 主界面代码设计: '执行设备显示列表操作 Private Sub doDevice(iid As String) Dim frm As New frmDevice If Len(iid) > 0 Then frm.loadDevice iid End If frm.setStatus frm.Show vbModal If frm.isUpdate = True Then grdDevice.Tag = "" Call fillDeviceGrid(grdDevice) End If Unload frm Set frm = Nothing End Sub '执行用户显示列表操作 Private Sub doUser(uid As String) Dim frm As New frmUser If Len(uid) > 0 Then frm.loadUser uid End If frm.setStatus frm.Show vbModal If fr m.isUpdate = True Then grdUser.Tag = "" Call fillUserGrid End If Unload frm Set frm = Nothing End Sub Private Sub cmdAdd_Click() Call doDevice("") End Sub Private Sub cmdAll_Click() grdQuery.Tag = "" fillDeviceGrid grdQuery End Sub Private Sub cmdBackup_Click() Dim newPath As String newPath = App.Path & "\data" & FormatDateTime(Date, v bShortDate) & "(" & Right(Rnd(100), 1) & ").mdb" On Error GoTo err_handle FileCopy App.Path & "\data.mdb", newPath MsgBox "数据备份成功,备份文件在:" & newPath Exit Sub err_handle: MsgBox Err.Description MsgBox " 备份不成功!" End Sub Private Sub cmdDelete_Click() Dim iid As String With grdDevice If .Row = 0 Then MsgBox "请选择要删除的设 备!" Else If MsgBox("你是否真的要删除当前选择的设备吗?删除后将不能恢复!", vbOKCancel) = vbOK
Then .Col = 1 iid = .Text Dim device As New classDevice device.deleteData iid grdDevice.Tag = "" Call fillDeviceGrid(grdDevice) End If End If End With End Sub Private Sub cmdDisCard_Click() Dim iid As String Dim strDate As String With grdDevice If .Row = 0 Then MsgBox "请选择要注销的设备!" Els e If MsgBox("你是否真的要注销当前选择的设备吗?注销后将不能恢复!", vbOKCancel) = vbOK Then .Col = 1 iid = . Text strDate = getDate("") If Len(strDate) > 0 Then Dim device As New classDevice If device.Reject(iid, st rDate) = True Then .Tag = "" fillDeviceGrid grdDevice End If Set device = Nothing End If End If End If End With End Sub Private Sub cmdExit_Click() If MsgBox("是否真的要退出系统吗?", vbYesNo) = vbYes Then Unload Me End If End Sub Private Sub cmdGetDate_Click(Index As Integer) Dim thedate As String thedate = getDate(txtDate(Index).Te xt) If Len(thedate) > 0 Then txtDate(Index).Text = thedate End Sub Private Sub cmdLend_Click() Dim iid As String With grdDevice If .Row = 0 Then MsgBox "请选择要操作的设 备!" Else .Col = 1 iid = .Text Dim frm As New frmLend Dim result As Boolean result = frm.loadLendData(iid) If result = False Then Unload frm Exit Sub End If frm.Show vbModal If frm.isUpdate = True Then grdDevice. Tag = "" fillDeviceGrid grdDevice End If Unload frm Set frm = Nothing End If End With End Sub Private Sub cmdPass_Click() Dim oldPass As String Dim newPass1 As String Dim newPass2 As String oldPass = InputBox("请输入旧密码:", "密码修改") If Len(oldPass) > 0 Then If oldPass <> gUser.Password Then MsgBox " 输入密码不正确!" Exit Sub End If newPass1 = InputBox("请输入新密码:", "密码修改") If Len(newPass1) = 0 The n MsgBox "密码修改不成功!" Exit Sub Else newPass2 = InputBox("请再次输入新密码确认:", "密码修改") If Len(n ewPass2) = 0 Then MsgBox "密码修改不成功!" Exit Sub ElseIf newPass1 = newPass2 Then If gUser.resetPassword (newPass1) = False Then MsgBox "数据操作错误,密码修改不成功!" Else MsgBox "密码成功修改!请保存好你的密码!" End If Exit Sub Else MsgBox "两次输入的新密码不一样,修改失败!" Exit Sub End If End If Else MsgBox "密码修 改不成功!" Exit Sub End If End Sub Private Sub cmdQuery_Click() Dim DeptNo As String Dim DeviceName As String Dim DeviceModel As String Dim TypeNo As String Dim Pricefrom As String Dim Priceto As String Dim PurchaseDatefrom As String Dim Purchase Dateto As String Dim RejectDatefrom As String Dim RejectDateto As String Dim strSQL As String If cboQDept. ListIndex > 0 Then DeptNo = getDeptNo() strSQL = "a.deptno='" & DeptNo & "'" End If If cboQTypeNO.ListInde x > 0 Then TypeNo = getTypeNO() If Len(strSQL) > 0 Then strSQL = " AND a.typeno='" & TypeNo & "'" Else str SQL = "a.typeno='" & TypeNo & "'" End If End If DeviceName = Replace(Trim(txtQDeviceName.Text), "'", "''") DeviceModel = Replace(Trim(txtQModel.Text), "'", "''") Pricefrom = Trim(txtQP1.Text) Priceto = Trim(txtQP 2.Text) PurchaseDatefrom = Trim(txtDate(0).Text) PurchaseDateto = Trim(txtDate(1).Text) RejectDatefrom = T rim(txtDate(2).Text) RejectDateto = Trim(txtDate(3).Text) If Len(Pricefrom) > 0 Then If Not IsNumeric(Pric efrom) Then MsgBox "购买价格输入不正确,请重新输入。" txtQP1.SetFocus Exit Sub Else If Len(strSQL) > 0 The n strSQL = strSQL & " AND ProductPrice>=" & Pricefrom Else strSQL = "ProductPrice>=" & Pricefrom End If En d If End If If Len(Priceto) > 0 Then If Not IsNumeric(Priceto) Then MsgBox "购买价格输入不正确,请重新输 入。" txtQP2.SetFocus Exit Sub Else If Len(strSQL) > 0 Then strSQL = strSQL & " AND ProductPrice<=" & Pric eto Else strSQL = "ProductPrice<=" & Priceto End If End If End If If Len(PurchaseDatefrom) > 0 Then If Not IsDate(PurchaseDatefrom) Then MsgBox "购买日期输入不正确,请重新输入。" txtDate(0).SetFocus Exit Sub Else If Len(strSQL) > 0 Then strSQL = strSQL & " AND PurchaseDate>=#" & PurchaseDatefrom & "#" Else strSQL = " ProductPrice>=#" & PurchaseDatefrom & "#" End If End If End If If Len(PurchaseDateto) > 0 Then If Not IsDa te(PurchaseDateto) Then MsgBox "购买日期输入不正确,请重新输入。" txtDate(1).SetFocus Exit Sub Else If Len (strSQL) > 0 Then strSQL = strSQL & " AND PurchaseDate<=#" & PurchaseDateto & "#" Else strSQL = "ProductPr ice<=#" & PurchaseDateto & "#" End If End If End If If Len(RejectDatefrom) > 0 Then If Not IsDate(RejectDa tefrom) Then MsgBox "注销日期输入不正确,请重新输入。" txtDate(2).SetFocus Exit Sub Else If Len(strSQL) > 0 Then strSQL = strSQL & " AND RejectDate>=#" & RejectDatefrom & "#" Else strSQL = "RejectDate>=#" & Rejec tDatefrom & "#" End If End If End If If Len(RejectDateto) > 0 Then If Not IsDate(RejectDateto) Then MsgBox "注销日期输入不正确,请重新输入。" txtDate(3).SetFocus Exit Sub Else If Len(strSQL) > 0 Then strSQL = str SQL & " AND RejectDate<=#" & RejectDateto & "#" Else strSQL = "RejectDate<=#" & RejectDateto & "#" End If
End If End If If Len(DeviceName) > 0 Then If Len(strSQL) > 0 Then strSQL = strSQL & " AND DeviceName LIKE '%" & DeviceName & "%'" Else strSQL = "DeviceName LIKE '%" & DeviceName & "%'" End If End If If Len(Device Model) > 0 Then If Len(strSQL) > 0 Then strSQL = strSQL & " AND DeviceModel LIKE '%" & DeviceModel & "%'" Else strSQL = "DeviceModel LIKE '%" & DeviceModel & "%'" End If End If If Len(strSQL) > 0 Then strSQL = "S ELECT a.*,b.department,c.TypeName FROM (tblDevice AS A INNER JOIN tblDepartment AS B ON a.DeptNO=b.DeptNO) INNER JOIN tblTypeInfo C ON a.TypeNO=c.TypeNO WHERE " & strSQL & " ORDER BY A.IID DESC" Else strSQL = "SE LECT a.*,b.department,c.TypeName FROM (tblDevice AS A INNER JOIN tblDepartment AS B ON a.DeptNO=b.DeptNO) INNER JOIN tblTypeInfo C ON a.TypeNO=c.TypeNO ORDER BY A.IID DESC" End If grdQuery.Tag = "" fillDeviceGrid grdQuery, strSQL End Sub Private Sub cmdReject_Click() Dim iid As String Dim strDate As String With grdDevice If .Row = 0 Then Msg Box "请选择要报废的设备!" Else If MsgBox("你是否真的要报废当前选择的设备吗?报废后将不能恢复!", vbOKCancel) = vbOK Then .Col = 1 iid = .Text strDate = getDate("") If Len(strDate) > 0 Then Dim device As New classDe vice If device.DisCard(iid, strDate) = True Then .Tag = "" fillDeviceGrid grdDevice End If Set device = No thing End If End If End If End With End Sub Private Sub cmdReport1_Click() Dim report As New drDevice Dim rs As ADODB.Recordset Set rs = gConn.Execut e("SELECT * FROM tbldevice") With report Set .DataSource = rs .DataMember = "" .Show vbModal End With Set report = Nothing End Sub Private Sub cmdReport2_Click() Dim report As New drDepartment Dim rs As ADODB.Recordset Set rs = gConn.Ex ecute("SELECT department,count(*) as countofDevice, sum(productprice) as sumofDevice FROM tbldevice a inne r join tbldepartment b on a.deptno=b.deptno group by b.department") With report Set .DataSource = rs .Data Member = "" .Show vbModal End With Set report = Nothing End Sub Private Sub cmdReport3_Click() Dim report As New drReject Dim rs As ADODB.Recordset Set rs = gConn.Execu te("SELECT devicename, department,rejectdate FROM tbldevice a inner join tbldepartment b on a.deptno=b.dep tno where rejectdate is not null") With report Set .DataSource = rs .DataMember = "" .Show vbModal End Wit h Set report = Nothing End Sub Private Sub cmdReport4_Click() Dim report As New drCost Dim rs As ADODB.Recordset Set rs = gConn.Execute ("SELECT devicename, department,productprice, productcost FROM tbldevice a inner join tbldepartment b on a.deptno=b.deptno") With report Set .DataSource = rs .DataMember = "" .Show vbModal End With Set report = Nothing End Sub Private Sub cmdReset_Click() If MsgBox("你是否真的要重置数据库吗?这个操作将会删除所有记录!", vbOKCancel + vbDefaultButton2) = vbOK Then gConn.Execute "delete from tbldevice" gConn.Execute "delete from tbluser" gConn.Execute "delete from tbllend" gConn.Execute "insert into tbluser (login,pwd,level) values ('admin',' 888',-1)" gConn.Close MsgBox "重置数据库成功!管理系统将退出!!!" Unload Me End If End Sub Private Sub cmdUserAdd_Click() Call doUser("") End Sub Private Sub cmdUserDelete_Click() Dim uid As String With grdUser If .Row = 0 Then MsgBox "请选择要删除的 用户!" Else If MsgBox("你是否真的要删除当前选择的用户吗?删除后将不能恢复!", vbOKCancel) = vbOK Then .Col = 1 uid = .Text Dim user As New ClassUser user.deleteData uid grdUser.Tag = "" Call fillUserGrid End If End If End With End Sub Private Sub Form_Load() Dim rs As ADODB.Recordset Dim strSQL As String strSQL = "SELECT * FROM tblTypeInf o ORDER BY TypeNO" Set rs = gConn.Execute(strSQL) cboQTypeNO.AddItem "" With rs Do Until .EOF cboQTypeNO.A ddItem .Fields("TypeNO").value & "-" & .Fields("TypeName").value .MoveNext Loop End With cboQTypeNO.ListIn dex = 0 strSQL = "SELECT * FROM tblDepartment ORDER BY DeptNO" Set rs = gConn.Execute(strSQL) cboQDept.Add Item "" With rs Do Until .EOF cboQDept.AddItem .Fields("DeptNO").value & "-" & .Fields("Department").value .MoveNext Loop End With cboQDept.ListIndex = 0 rs.Close Set rs = Nothing With tabMain Select Case gUser.L evel Case 1 '数据操作员 .TabVisible(3) = False fillDeviceGrid grdDevice frameSystem.Visible = False Case - 1 '系统管理员 fillDeviceGrid grdDevice .TabVisible(0) = False .TabVisible(1) = False .TabVisible(2) = Fals e frameSystem.Visible = True Case Else '普通人员 .Tab = 1 .TabVisible(0) = False .TabVisible(3) = False fr ameSystem.Visible = False End Select End With End Sub Private Sub Form_Unload(Cancel As Integer) gConn.Close Set gConn = Nothing Set gUser = Nothing End Sub Private Sub grdDevice_DblClick() Dim iid As String With grdDevice If .Row > 0 Then .Col = 1 iid = .Text
Call doDevice(iid) End If End With End Sub Private Sub grdUser_DblClick() Dim uid As String With grdUser If .Row > 0 Then .Col = 1 uid = .Text Call doUser(uid) End If End With End Sub Private Sub tabMain_Click(PreviousTab As Integer) Dim strSQL As String Select Case tabMain.Tab Case 0 str SQL = "SELECT a.*,b.department,c.TypeName FROM (tblDevice AS A INNER JOIN tblDepartment AS B ON a.DeptNO= b.DeptNO) INNER JOIN tblTypeInfo C ON a.TypeNO=c.TypeNO ORDER BY A.IID DESC" Call fillDeviceGrid(grdDevic e, strSQL) Case 3 Call fillUserGrid End Select End Sub Private Sub fillDeviceGrid(grid As MSFlexGrid, Optional strSQL As String) Dim rs As ADODB.Recordset Dim s trRowData As String Dim rowindex As Integer If Len(strSQL) = 0 Then strSQL = "SELECT a.*,b.department,c.Ty peName FROM (tblDevice AS A INNER JOIN tblDepartment AS B ON a.DeptNO=b.DeptNO) INNER JOIN tblTypeInfo C O N a.TypeNO=c.TypeNO ORDER BY A.IID DESC" End If rowindex = 1 With grid If .Tag = "" Then Set rs = gConn.Ex ecute(strSQL) .Rows = 1 .Cols = 13 .Row = 0 .Col = 0 .Text = "序号" .Col = 1 .Text = "ID" .ColWidth(1) = 0 .Col = 2 .Text = "设备编号" .Col = 3 .Text = "设备名称" .Col = 4 .Text = "设备型号" .Col = 5 .Text = "设 备分类" .Col = 6 .Text = "所属部门" .Col = 7 .Text = "购买价格" .Col = 8 .Text = "折旧成本" .Col = 9 .Text = "购买日期" .Col = 10 .Text = "状态" .Col = 11 .Text = "报废日期" .Col = 12 .Text = "注销日期" Do Until rs.EOF strRowData = rowindex & vbTab strRowData = strRowData & rs("IID").value & vbTab strRowData = strRow Data & rs("DeviceNO").value & vbTab strRowData = strRowData & rs("DeviceName").value & vbTab strRowData = strRowData & rs("DeviceModel").value & vbTab strRowData = strRowData & rs("TypeName").value & vbTab strRow Data = strRowData & rs("Department").value & vbTab strRowData = strRowData & rs("ProductPrice").value & vb Tab strRowData = strRowData & rs("Productcost").value & vbTab strRowData = strRowData & FormatDateTime(rs ("PurchaseDate").value, vbLongDate) & vbTab If rs("Status").value = 0 Then strRowData = strRowData & "在库 " & vbTab Else strRowData = strRowData & "借出" & vbTab End If strRowData = strRowData & rs("RejectDate"). value & vbTab strRowData = strRowData & rs("DisCardDate").value & vbTab .AddItem strRowData rs.MoveNext ro windex = rowindex + 1 Loop rs.Close Set rs = Nothing .Tag = 1 End If End With End Sub Private Sub fillUserGrid() Dim rs As ADODB.Recordset Dim strRowData As String Dim rowindex As Integer row index = 1 With grdUser If .Tag = "" Then Set rs = gConn.Execute("SELECT * FROM tblUser ORDER BY UID DESC") .Rows = 1 .Cols = 4 .Row = 0 .Col = 0 .Text = "序号" .ColWidth(0) = 500 .Col = 1 .ColWidth(1) = 0 .Col = 2 .Text = "用户名" .ColWidth(2) = 1500 .Col = 3 .Text = "用户级别" .ColWidth(3) = 3000 Do Until rs.EOF str RowData = rowindex & vbTab strRowData = strRowData & rs("UID").value & vbTab strRowData = strRowData & rs ("login").value & vbTab Select Case rs("userlevel").value Case -1 strRowData = strRowData & "系统管理员" & vbTab Case 0 strRowData = strRowData & "普通用户" & vbTab Case 1 strRowData = strRowData & "数据操作员" & vbTab End Select .AddItem strRowData rs.MoveNext rowindex = rowindex + 1 Loop rs.Close Set rs = Nothing . Tag = 1 End If End With End Sub Private Function getDeptNo() As String Dim str As String Dim pos As Integer With cboQDept str = .List(.L istIndex) End With pos = InStr(str, "-") getDeptNo = Left(str, pos - 1) End Function Private Function getTypeNO() As String Dim str As String Dim pos As Integer With cboQTypeNO str = .List (.ListIndex) End With pos = InStr(str, "-") getTypeNO = Left(str, pos - 1) End Function 3.用户管理界面: 用户登陆代码设计: Private Sub cmdCancel_Click() With theUser If .isDirty Then If MsgBox("你已经更改数据,是否做保存数据后再 退出?", vbYesNo) = vbYes Then If saveData() = False Then Exit Sub End If End If End If End With Me.Hide E nd Sub Private Sub cmdDelete_Click() theUser.deleteData (theUser.uid) isUpdate = True Me.Hide End Sub Private Function saveData() As Boolean Dim UserName As String Dim Password As String Dim Level As Integer saveData = False UserName = Trim(txtUserName.Text) Password = txtPassword.Text If Len(UserName) = 0 Then MsgBox "请输入用户名!" txtUserName.SetFocus Exit Function End If If Len(Password) = 0 Then MsgBox "请输入 密码!" txtPassword.SetFocus Exit Function End If With theUser .UserName = UserName .Password = Password S elect Case cboLevel.ListIndex Case 1 .Level = 1 Case 2 .Level = -1 Case Else .Level = 0 End Select If .uid = 0 Then saveData = .addData Else saveData = .saveData End If If saveData = False Then MsgBox "保存不成
功,请检查用户名是否唯一!" End With End Function Private Sub cmdSave_Click() If saveData() = True Then isUpdate = True Me.Hide End If End Sub Private Sub Form_Load() With cboLevel .AddItem "普通用户" .AddItem "数据操作员" .AddItem "系统管理员" .Li stIndex = 0 End With isUpdate = False End Sub Public Sub loadUser(uid As String) '显示用户数据 With theUse r .loadDataByID uid txtUserName.Text = .UserName txtPassword.Text = .Password Select Case .Level Case 1 ' 数据操作员 cboLevel.ListIndex = 1 Case -1 '系统管理员 cboLevel.ListIndex = 2 Case Else '普通用户 cboLevel. ListIndex = 0 End Select End With End Sub Public Sub setStatus() If theUser.uid = 0 Then cmdDelete.Enabled = False Else '控制输入 txtUserName.Locked = True '不允许修改用户名; End If End Sub 4.设备管理界面: 设备 界面代码设计: Private Sub cmdCancel_Click() With theDevice If .isDirty Then If MsgBox("你已经更改数据,是否做保存数据后 再退出?", vbYesNo) = vbYes Then If saveData() = False Then Exit Sub End If End If End If End With Me.Hide End Sub Private Sub cmdDelete_Click() theDevice.deleteData (theDevice.iid) isUpdate = True Me.Hide End Sub Private Sub cmdSave_Click() If saveData() = True Then isUpdate = True Me.Hide End If End Sub Private Sub Form_Load() Dim rs As ADODB.Recordset Dim strSQL As String strSQL = "SELECT * FROM tblTypeIn fo ORDER BY TypeNO" Set rs = gConn.Execute(strSQL) With rs Do Until .EOF cboTypeNO.AddItem .Fields("TypeNO ").value & "-" & .Fields("TypeName").value .MoveNext Loop End With strSQL = "SELECT * FROM tblDepartment O RDER BY DeptNO" Set rs = gConn.Execute(strSQL) With rs Do Until .EOF cboDepartment.AddItem .Fields("DeptNO ").value & "-" & .Fields("Department").value .MoveNext Loop End With rs.Close Set rs = Nothing isUpdate = False End Sub Public Sub loadDevice(iid As String) '显示用户数据 With theDevice .loadDataByID iid txtDevic eNo.Text = .DeviceNo txtDeviceModel.Text = .DeviceModel txtDeviceName.Text = .DeviceName setTypeIndex .Typ eNo setDeptIndex .DeptNo txtPrice.Text = .ProductPrice txtCost.Text = .ProductCost dtPurchaseDate = .Purch aseDate If .Status = 0 Then lblStatus.Caption = "在库" Else lblStatus.Caption = "借出" End If If Len(.Reje ctDate) = 0 Then dtReject.Visible = False Else dtReject.value = .RejectDate End If If Len(.DisCardDate) = 0 Then dtDisCard.Visible = False Else dtDisCard.value = .DisCardDate End If End With End Sub Private Sub setTypeIndex(TypeNo As String) Dim pos As Integer TypeNo = TypeNo & "-" With cboTypeNO For po s = 0 To .ListCount - 1 If Left(.List(pos), Len(TypeNo)) = TypeNo Then .ListIndex = pos Exit For End If Ne xt End With End Sub Private Sub setDeptIndex(DeptNo As String) Dim pos As Integer DeptNo = DeptNo & "-" With cboDepartment Fo r pos = 0 To .ListCount - 1 If Left(.List(pos), Len(DeptNo)) = DeptNo Then .ListIndex = pos Exit For End I f Next End With End Sub Private Function getTypeNO() As String Dim str As String Dim pos As Integer With cboTypeNO str = .List(.L istIndex) End With pos = InStr(str, "-") getTypeNO = Left(str, pos - 1) End Function Private Function getDeptNo() As String Dim str As String Dim pos As Integer With cboDepartment str = .Lis t(.ListIndex) End With pos = InStr(str, "-") getDeptNo = Left(str, pos - 1) End Function Public Sub setSta tus() If theDevice.iid = 0 Then cmdDelete.Enabled = False dtReject.Visible = False dtDisCard.Visible = Fal se End If End Sub Private Function saveData() As Boolean Dim DeviceNo As String Dim DeviceModel As String Dim DeviceName A s String Dim TypeNo As String Dim DeptNo As String Dim Price As String Dim Cost As String Dim PurchaseDate As String saveData = False DeviceNo = Trim(txtDeviceNo.Text) DeviceModel = Trim(txtDeviceModel.Text) Devi ceName = Trim(txtDeviceName.Text) Price = Trim(txtPrice.Text) Cost = Trim(txtCost.Text) PurchaseDate = For matDateTime(dtPurchaseDate.value, vbShortDate) If Len(DeviceNo) = 0 Then MsgBox "请输入设备编号" Exit Func tion End If If cboTypeNO.ListIndex < 0 Then MsgBox "请选择设备类型!" Exit Function End If If cboDepartmen t.ListIndex < 0 Then MsgBox "请选择设备所属部门!" Exit Function End If If IsNumeric(Price) = False Then M sgBox "请输入正确的价格!" Exit Function End If If IsNumeric(Cost) = False Then MsgBox "请输入正确的成本! " Exit Function End If If IsDate(PurchaseDate) = False Then MsgBox "请输入正确的购买日期!" Exit Function E nd If With theDevice .DeviceNo = DeviceNo .DeviceModel = DeviceModel .DeviceName = DeviceName .TypeNo = ge tTypeNO() .DeptNo = getDeptNo() .ProductPrice = Price .ProductCost = Cost .PurchaseDate = PurchaseDate If .iid = 0 Then saveData = .addData Else saveData = .saveData End If If saveData = False Then MsgBox "保存 不成功!请检查设备编号的唯一性!" End With End Function
3.3 系统的数据库设计 1.部门表设计: . 2.设备表设计: 3.出借表: 4.类型信息表: 5.用户表: 结束语 本软件的设计目的是在固定资产管理维护方面为企事业单位和管理人员提供方便和帮助。通过这几个月的毕业设计, 我学到很多以前没有学到的 visual basic 开发技术,在软件工程学上更是取得了很大的进步。经过大量的测试和试用, 作者深信本软件达到了方便和实用的设计目的,并在软件界面和易用实用等方面有着独到之处。虽然软件基本达到设计要 求并且达到同行的先进水平,但由于作者水平有限,软件存在 bug 也是在所难免的 ,您的意见和建议将极大的帮助我改 进并完善软件。真诚的希望你的参与。 致谢我首先感谢我的指导老师吕老师,在他严格的要求下我懂得了开发软件要有 一种极其认真负责的态度。无论做什么事都要大胆的去想去做,这样会有好的创意,才能更有作为。在这里我还要感谢我 们宿舍的其它 5 个同学。他们和我共同生活了四年,在生活和学习上给了我很大的帮助。 参 考 文 献 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
分享到:
收藏