【编程开发】AspAsp.NetCGIPHPJspXMLPERLC++C#VCVBDelphiPowerBuilderJAVA汇编数据库编程移动开发其它语言

您现在的位置:首页 > 网络学院 > 编程开发 > VB > VB+Access设计图书管理系统

VB+Access设计图书管理系统

来源: 作者: 日期:2006-09-04

【聚杰网VB】VB+Access设计图书管理系统

  MsgBox "没有这个用户", vbOKOnly + vbExclamation, ""

  txtuser.SetFocus

  Else

  sql = "select * from 系统管理 where 用户名='" & txtuser.Text & "'"

  rs_login.Open sql, conn, adOpenKeyset, adLockPessimistic

  If rs_login.EOF = True Then

  MsgBox "没有这个用户", vbOKOnly + vbExclamation, ""

  txtuser.SetFocus

  Else ' 检验密码是否正确

  用户名和密码通过后,要关闭本窗体并打开主窗体。

  If Trim(rs_login.Fields(1)) = Trim(txtpwd.Text) Then

  userID = txtuser.Text

  userpow = rs_login.Fields(2)

  rs_login.Close

  Unload Me

  MDIForm1.Show

  Else

  MsgBox "密码不正确", vbOKOnly + vbExclamation, ""

  txtpwd.SetFocus

  End If

  End If

  End If

  ' 只能输入3次

  cnt = cnt + 1

  If cnt = 3 Then

  Unload Me

  End If

  Exit Sub

  End Sub
 (7) 值班管理子窗体代码

  值班管理子窗体的作用是把值班人员的时间安排形成列表。运行的值班管理子窗体如图44所示。

  

  图44 运行的值班管理子窗体

  先定义连接数据库的变量:

  Option Explicit

  Dim rs_zhiban As New ADODB.Recordset

  然后列出窗体部分的代码。

  Private Sub cmdadd_Click()

  On Error GoTo adderror

  If cmdadd.Caption = "新增记录" Then ' 当此按钮的状态为为“增加记录”时

  cmdadd.Caption = "确定" ' 按钮名称改“确定”

  cmddel.Enabled = False

  DataGrid1.AllowAddNew = True

  DataGrid1.AllowUpdate = True ' 设定DataGrid可以增加记录

  Else

  If Not IsNull(DataGrid1.Bookmark) Then

  If Not IsDate(Trim(DataGrid1.Columns("值班开始日期").CellText(DataGrid1.Bookmark))) Then

  MsgBox "请按照格式yyyy-mm-dd输入值班开始日期", vbOKOnly + vbExclamation, ""

  Exit Sub

  End If

  If Not IsDate(Trim(DataGrid1.Columns("值班开始时间").CellText(DataGrid1.Bookmark))) Then

  MsgBox "请按照格式hh-mm输入值班开始时间", vbOKOnly + vbExclamation, ""

  Exit Sub

  End If

  If Not IsDate(Trim(DataGrid1.Columns("值班截止日期").CellText(DataGrid1.Bookmark))) Then

  MsgBox "请按照格式yyyy-mm-dd输入值班截止日期", vbOKOnly + vbExclamation, ""

  Exit Sub

  End If

  If Not IsDate(Trim(DataGrid1.Columns("值班截止时间").CellText(DataGrid1.Bookmark))) Then

  MsgBox "请按照格式hh-mm输入值班截止时间", vbOKOnly + vbExclamation, ""

  Exit Sub

  End If

  If Trim(DataGrid1.Columns("值班人").CellText(DataGrid1.Bookmark)) = "" Then

  MsgBox "值班人不能为空!", vbOKOnly + vbExclamation, ""

  Exit Sub

  End If

  rs_zhiban.Update

  MsgBox "添加信息成功!", vbOKOnly + vbExclamation, ""

  DataGrid1.AllowAddNew = False

  DataGrid1.AllowUpdate = False

  Else

  MsgBox "没有添加信息!", vbOKOnly + vbExclamation, ""

  End If

  cmdadd.Caption = "新增记录"

  cmddel.Enabled = True

  End If

  adderror:

  If Err.Number <> 0 Then

  MsgBox Err.Description

  End If

  End Sub

  Private Sub cmdcancel_Click()

  Unload Me

  MDIForm1.Show

  End Sub

  Private Sub cmddel_Click()

  Dim answer As String

  On Error GoTo delerror

  answer = MsgBox("确定要删除吗?", vbYesNo, "")

  If answer = vbYes Then

  DataGrid1.AllowDelete = True

  rs_zhiban.Delete

  rs_zhiban.Update

  DataGrid1.Refresh

  MsgBox "成功删除!", vbOKOnly + vbExclamation, ""

上一页 1 2 3 4 5 6 7 8 9 下一页

以下相关文章您是否也应该阅读一下 无相关信息
评论   点击查看全部评论
您的评论参与,将为聚杰带来更大的动力!请不要吝啬!
快速回复
请使用文明语言让我们维护健康绿色网络环境!

匿名发表   验证码: