With Adodc2 .Mode = adModeReadWrite .ConnectionString = provider & ";" & datasource .CommandType = adCmdTable .RecordSource = "gongyu" .Refresh End With With Adodc3 .Mode = adModeReadWrite .ConnectionString = provider & ";" & datasource .CommandType = adCmdTable .RecordSource = "class" .Refresh End With With Adodc4 .Mode = adModeReadWrite .ConnectionString = provider & ";" & datasource .CommandType = adCmdTable .RecordSource = "weisheng" .Refresh End With With Adodc5 .Mode = adModeReadWrite .ConnectionString = provider & ";" & datasource End With With Adodc6 .Mode = adModeReadWrite .ConnectionString = provider & ";" & datasource .CommandType = adCmdTable .RecordSource = "dengji" .Refresh End With With Adodc7 .Mode = adModeReadWrite .ConnectionString = provider & ";" & datasource .CommandType = adCmdTable .RecordSource = "qinshi" .Refresh End With With Adodc9 .Mode = adModeReadWrite .ConnectionString = provider & ";" & datasource .CommandType = adCmdTable .RecordSource = "zichan" .Refresh End With treeview部分树形显示的初始化在这里已经做了几个过程,调用即可。 4.3系统设置 4.3.1用户管理 ①界面效果图 图4.3用户管理 ② 界面制作与实现方法 这个界面总体来说各个控件比较简单,但是作为一个添加删除管理员的操作,它已经连接到了数据库,与数据库的yonghu表相联。各个控件也与数据库中表的字段绑定。 在窗体初始化的时候要判断当前数据库表中是否有记录,如果没有记录那么有些按钮将会被设置成为失效状态,否则会出现错误。设置代码如下: Dim provider As String Dim datasource As String provider = "provider=Microsoft.jet.oledb.4.0" datasource = "data source=" & App.Path & "\DB.mdb" With Adodc1 .Mode = adModeReadWrite .ConnectionString = provider & ";" & datasource .CommandType = adCmdTable .RecordSource = "yonghu" .Refresh End With Option1.Enabled = False Option2.Enabled = False If Adodc1.Recordset.RecordCount = 0 Then Command2.Enabled = False Command3.Enabled = False Command5.Enabled = False Command6.Enabled = False End If Text2.Text = Text3.Text 上一条与下一条的功能一目了然,它们可以对当前表进行上一条记录或下一条记录依次查看。当找到记录后,可以对其进行相对的删除、修改等操作。上一条记录与下一条的记录在查看时有一个判断。当表中记录移到最前面(BOF)或最后面(EOF)时,会把上一条或下一条其中的一个按钮的enable属性设置为true。即不可以前查看或向后查看。 上一条与下一条主要代码如下: Adodc1.Recordset.MovePrevious '移动记录 Command6.Enabled = True If Adodc1.Recordset.BOF Then Adodc1.Recordset.MoveFirst Command5.Enabled = False End If Adodc1.Recordset.MoveNext '移动记录 Command5.Enabled = True If Adodc1.Recordset.EOF Then Adodc1.Recordset.MoveLast Command6.Enabled = False End If 添加用户可以添加使用该管理软件的用户。添加的时候可以选择所添加人物的级别。软件默认为两个级别:管理员、普通用户。管理员拥有对此软件管理操作等一切的权力。普通用户,只有普通的查看、查询、备份、添加等权力。没有对记录删除等权力。在添加用户时你可以选择一个且必须选择一个。然后输入此用户的用户名和密码即可! 添加用户主要代码: If Command1.Caption = "添加" Then Command2.Enabled = False Command5.Enabled = False Command6.Enabled = False Command1.Caption = "确定" Command3.Caption = "取消" Adodc1.Recordset.AddNew Option1.Enabled = True Option2.Enabled = True Text1.Enabled = True Text2.Enabled = True Text3.Enabled = True Text2.Text = "" ElseIf Text1.Text = "" Then MsgBox "用户名不能为空!", 48, "提示" ElseIf Text2.Text = "" Then MsgBox "密码不能为空!", 48, "提示" ElseIf Text2.Text <> Text3.Text Then MsgBox "密码两次需一致!", 48, "提示" ElseIf Text4.Text = "" Then MsgBox "请选择所建用户类型!", 48, "提示" Else Command2.Enabled = True Command3.Enabled = True Command5.Enabled = True Command6.Enabled = True Command3.Caption = "编辑" Command1.Caption = "添加" Adodc1.Recordset.Update Text1.Enabled = False Text2.Enabled = False Text3.Enabled = False Text4.Enabled = False Option1.Value = False Option2.Value = False Option1.Enabled = False Option2.Enabled = False End If 删除操作可以把当前记录删除掉。一经删除即不可以在恢复。所以在操作前要想好。 删除操作部分代码: If Adodc1.Recordset.RecordCount = 1 Then Command2.Enabled = False End If If (MsgBox 上一页 [1] [2] [3] [4] [5] [6] [7] [8] [9] [10] [11] [12] [13] [14] [15] 下一页 |