VB+access实验室设备管理系统 第10页
If Not rs1.EOF Then rs1.MoveLast '如记录没到头,那么移到最后一条记录
If rs1.Fields("单位编号") <> "" Then '假如编号不等于空
dm = Trim(rs1.Fields("单位编号")) + 1 '赋值给dm变量
Text1(0).Text = Format(dm, "0000") '赋值给text1(0).text
End If
Else '否则
Text1(0).Text = "0001" '为text1(0).text设初值
End If
'清空数据
For i = 1 To 2
Text1(i).Text = ""
Next i
End Sub
Private Sub ComModify_Click() '允许修改数据
If Adodc1.Recordset.RecordCount > 0 Then '当记录大于零时
Frame1.Visible = True 'frame1可见
'赋值给Text1(i)等
If Adodc1.Recordset.Fields(1) <> "" Then Text1(1).Text = Trim(Adodc1.Recordset.Fields(i))
If Adodc1.Recordset.Fields(2) <> "" Then Text1(2).Text = Trim(Adodc1.Recordset.Fields(i))
Else
MsgBox "没有要修改的记录,请核对!"
End If
End Sub
Private Sub ComDelete_Click() '删除包房信息
Frame1.Visible = False 'frame1不可见
On Error Resume Next
Adodc1.Recordset.Delete '删除记录
Adodc1.Refresh '刷新记录
End Sub
Private Sub ComSave_Click()
txtSQL = "select * from 使用单位信息 where 单位编号='" & Trim(Text1(0).Text) & "'order by 单位编号"
Set rs1 = ESQL(txtSQL)
If rs1.RecordCount > 0 Then '当记录大于零时
Dim a As String '定义字符串变量
a = MsgBox("您确实要修改这条数据吗?", vbYesNo)
If a = vbYes Then
If Text1(1).Text = "" Then
MsgBox ("请输入单位编号!")
Exit Sub
End If
'赋值给数据库字段
rs1.Fields("单位编号") = Text1(0).Text: rs1.Fields("单位名称") = Text1(1).Text
rs1.Fields("设备编号") = Text1(2).Text: rs1.Fields("借入日期") = Format(Date, "long date") & " " & Time
rs1.Update '更新记录集
Adodc1.Refresh
End If
Else
If Text1(0).Text = "" Then
MsgBox ("请输入单位编号!")
Exit Sub
End If
If Text1(1).Text = "" Then
MsgBox ("请输入单位名称!")
Exit Sub
End If
If Text1(2).Text = "" Then
MsgBox ("请输入设备编号!")
Exit Sub
End If
rs1.AddNew
'赋值给数据库字段
rs1.Fields("单位编号") = Text1(0).Text: rs1.Fields("单位名称") = Text1(1).Text
rs1.Fields("设备编号") = Text1(2).Text: rs1.Fields("借入日期") = Format(Date, "long date") & " " & Time
rs1.Update '更新记录集
Adodc1.Refresh
MsgBox "单位信息已成功保存!"
End If
Frame1.Visible = False '设置Frame1不可见
End Sub
Private Sub Comfind_Click() '查询
Select Case Combo4.Text
Case Is = "like"
Adodc1.RecordSource = "select * from 使用单位信息 where (使用单位信息." & Combo3.Text & " like +'%'+ '" + Text2.Text + "'+'%') order by 单位编号"
Adodc1.Refresh
Case Is = "="
Adodc1.RecordSource = "select * from 使用单位信息 where (使用单位信息." & Combo3.Text & " = '" + Text2.Text + "') order by 单位编号"
Adodc1.Refresh
End Select
End Sub
Private Sub ComEsc_Click() '取消操作
Frame1.Visible = False
End Sub
Private Sub ComExit_Click()
Unload Me
Form1.Enabled = True
End Sub
Private Sub Text1_KeyPress(Index As Integer, KeyAscii As Integer)
If Index = 12 Then KeyAscii = valiText(KeyAscii, "0123456789." & Chr(13), True)
End Sub
Private Sub Text2_KeyPress(KeyAscii As Integer)
If KeyAscii = vbKeyReturn Then ComFind.SetFocus
End Sub
6.6密码设置
图6.14 口令设置窗体
'定义数据集对象
Dim rs1 As New ADODB.Recordset
Dim txtSQL As String '定义字符串变量
Private Sub Form_Activate()
'清空文本框数据
Text1.Text = ""
Text2.Text = ""
End Sub
Private Sub Form_Unload(Cancel As Integer)
Form1.Enabled = True
End Sub
Private Sub DataCombo1_KeyDown(KeyCode As Integer, Shift As Integer)
If KeyCode = vbKeyReturn Then Text2.SetFocus '按回车键text2获得焦点
End Sub
Private Sub DataCombo1_Change()
'按操作员名称查询权限信息
txtSQL = "select * from 权限信息表 where 操作员名称='" & DataCombo1.BoundText & "'"
Set rs1 = ESQL(txtSQL)
If rs1.RecordCount > 0 Then '当记录大于零时
Text1.Text = Trim(rs1.Fields("密码")) '赋值给text1.text
Else
Text1.Text = ""
End If
End Sub
Private Sub Command1_Click() '保存操作员信息
'按操作员名称查询权限信息
'按操作员名称查询权限信息
txtSQL = "select * from 权限信息表 where 操作员名称='" & DataCombo1.BoundText & "'"
Set rs1 = ESQL(txtSQL)
If Text2.Text <> "" Then
rs1.Fields("密码") = Trim(Text2.Text) '赋值给rs1.Fields("密码")
rs1.Update '更新记录
'清空文本框内的数据
Text1.Text = ""
Text2.Text = ""
MsgBox "密码设置成功!", , "系统提示"
Unload Me
End If
End Sub
Private Sub Command3_Click()
Form1.Enabled = True
Unload Me
End Sub
Private Sub Text2_KeyPress(KeyAscii As Integer)
If KeyAscii = vbKeyReturn Then Command1.SetFocus
End Sub
6.7密码设置
图6.15 实验室设备管理系统登陆身份窗体
If czy.Caption <> "" And Text1.Text = Trim(Adodc1.Recordset.Fields("密码")) Then
'调入frm_main主窗体
Load Form1
Form1.Show
Form1.St1.Panels(3).Text = czy.Caption
Unload Me
Else
'输入三次错误的密码,系统自动退出
If TIM = 3 Then
MESSAGE = MsgBox("密码输入错误,请向系统管理员查询!", 0, "系统提示")
If MESSAGE = vbOK Then End
End If
If czy.Caption = "" Then
MsgBox "请选择操作员!", , "系统提示"
ListView1.SetFocus 'ListView1获得焦点
Else
If Text1.Text <> Adodc1.Recordset.Fields("密码") Then
MsgBox "密码错误,请重新输入密码!", , "系统提示"
TIM = TIM + 1 '记录输入次数
Text1.SetFocus 'text1获得焦点
End If
End If
End If
End Sub
Private Sub comend_Click()
End
End Sub
上一页 [1] [2] [3] [4] [5] [6] [7] [8] [9] [10] ... 下一页 >>