⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 frmupd.frm

📁 完整的数据库课程设计
💻 FRM
📖 第 1 页 / 共 3 页
字号:
   Begin VB.CommandButton Command2 
      Caption         =   "取消"
      Height          =   375
      Left            =   4320
      TabIndex        =   1
      Top             =   4800
      Width           =   1095
   End
   Begin VB.CommandButton Command1 
      Caption         =   "确定"
      Height          =   375
      Left            =   2760
      TabIndex        =   0
      Top             =   4800
      Width           =   1095
   End
   Begin VB.Label Label1 
      Alignment       =   2  'Center
      BeginProperty Font 
         Name            =   "宋体"
         Size            =   14.25
         Charset         =   134
         Weight          =   400
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   375
      Left            =   0
      TabIndex        =   3
      Top             =   120
      Width           =   8415
   End
End
Attribute VB_Name = "FrmUpd"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Private Sub Command1_Click()
Call connect_db
If Label1.Caption = "删除管理员信息" Then
    Call del_table("Managers", "where Mid='" & Text1.Text & "'")
    MsgBox ("删除成功!并在下次登陆时生效!")
    Call sel_table("Managers", "")
    Set FrmMger.DataGrid1.DataSource = rst
    If rst.RecordCount > 0 Then
        With FrmMger
            .Label3.Caption = "管理员人数:" & rst.RecordCount & "人"
            .Command3.Enabled = True
            .Command4.Enabled = True
        End With
    Else
        With FrmMger
            .Label3.Caption = "无管理员"
            .Command3.Enabled = False
            .Command4.Enabled = False
        End With
    End If
    With FrmMger.DataGrid1
        .Columns(0).Caption = "编号"
        .Columns(1).Caption = "姓名"
        .Columns(3).Caption = "性别"
        .Columns(4).Caption = "出生日期"
        .Columns(5).Caption = "联系电话"
        .Columns(6).Caption = "电子邮件"
        .Columns(7).Caption = "联系地址"
        .Columns(8).Caption = "简介"
        .Columns(2).Visible = False
    End With
ElseIf Label1.Caption = "删除用户信息" Then
    Call del_table("Users", "where Uid='" & Text1.Text & "'")
    MsgBox ("删除成功")
    Call sel_table("Users", "")
    Set FrmMger.DataGrid1.DataSource = rst
    If rst.RecordCount > 0 Then
        With FrmMger
            .Label3.Caption = "用户人数:" & rst.RecordCount & "人"
            .Command3.Enabled = True
            .Command4.Enabled = True
        End With
    Else
        With FrmMger
            .Label3.Caption = "无用户"
            .Command3.Enabled = False
            .Command4.Enabled = False
        End With
    End If
    With FrmMger.DataGrid1
        .Columns(0).Caption = "编号"
        .Columns(1).Caption = "姓名"
        .Columns(3).Caption = "性别"
        .Columns(4).Caption = "出生日期"
        .Columns(5).Caption = "联系电话"
        .Columns(6).Caption = "电子邮件"
        .Columns(7).Caption = "联系地址"
        .Columns(8).Caption = "简介"
        .Columns(2).Visible = False
    End With
ElseIf Label1.Caption = "修改管理员信息" Then
    If Text1.Text = "" Then
        MsgBox ("管理员编号不能空")
        Exit Sub
    Else
        Call upd_table("Managers", "Mname='" & Text2.Text & "',Mpwd='" & Text3.Text & "',Msex='" & Text4.Text & "',Mborn='" & Text5.Text & "',Mtel='" & Text6.Text & "', Memail='" & Text7.Text & "',Maddr='" & Text8.Text & "',Mremark='" & Text9.Text & "'", "Mid='" & Text1.Text & "'")
        MsgBox ("修改成功")
        Call sel_table("Managers", "")
        Set FrmMger.DataGrid1.DataSource = rst
        With FrmMger.DataGrid1
            .Columns(0).Caption = "编号"
            .Columns(1).Caption = "姓名"
            .Columns(3).Caption = "性别"
            .Columns(4).Caption = "出生日期"
            .Columns(5).Caption = "联系电话"
            .Columns(6).Caption = "电子邮件"
            .Columns(7).Caption = "联系地址"
            .Columns(8).Caption = "简介"
            .Columns(2).Visible = False
        End With
    End If
ElseIf Label1.Caption = "修改用户信息" Then
    If Text1.Text = "" Then
        MsgBox ("用户编号不能空")
        Exit Sub
    Else
        Call upd_table("Users", "Uname='" & Text2.Text & "',Usex='" & Text4.Text & "',Uborn='" & Text5.Text & "',Utel='" & Text6.Text & "', Uemail='" & Text7.Text & "',Uaddr='" & Text8.Text & "',Uremark='" & Text9.Text & "'", "Uid='" & Text1.Text & "'")
        MsgBox ("修改成功")
        Call sel_table("Users", "")
        Set FrmMger.DataGrid1.DataSource = rst
        With FrmMger.DataGrid1
            .Columns(0).Caption = "编号"
            .Columns(1).Caption = "姓名"
            .Columns(3).Caption = "性别"
            .Columns(4).Caption = "出生日期"
            .Columns(5).Caption = "联系电话"
            .Columns(6).Caption = "电子邮件"
            .Columns(7).Caption = "联系地址"
            .Columns(8).Caption = "简介"
            .Columns(2).Visible = False
        End With
    End If
ElseIf Label1.Caption = "添加管理员信息" Then
    If Text1.Text = "" Then
        MsgBox ("管理员编号不能空")
        Exit Sub
    Else
        Call ins_table("Managers", "", "values('" & Text1.Text & "','" & Text2.Text & "','" & Text3.Text & "','" & Text4.Text & "','" & Text5.Text & "','" & Text6.Text & "','" & Text7.Text & "','" & Text8.Text & "','" & Text9.Text & "')")
        MsgBox ("添加成功")
        Call sel_table("Managers", "")
        Set FrmMger.DataGrid1.DataSource = rst
        FrmMger.Command3.Enabled = True
        FrmMger.Command4.Enabled = True
        With FrmMger.DataGrid1
            .Columns(0).Caption = "编号"
            .Columns(1).Caption = "姓名"
            .Columns(3).Caption = "性别"
            .Columns(4).Caption = "出生日期"
            .Columns(5).Caption = "联系电话"
            .Columns(6).Caption = "电子邮件"
            .Columns(7).Caption = "联系地址"
            .Columns(8).Caption = "简介"
            .Columns(2).Visible = False
        End With
    End If
ElseIf Label1.Caption = "添加用户信息" Then
    If Text1.Text = "" Then
        MsgBox ("用户编号不能空")
        Exit Sub
    Else
        Call ins_table("Users", "", "values('" & Text1.Text & "','" & Text2.Text & "','" & Text3.Text & "','" & Text4.Text & "','" & Text5.Text & "','" & Text6.Text & "','" & Text7.Text & "','" & Text8.Text & "','" & Text9.Text & "')")
        MsgBox ("添加成功")
        Call sel_table("Users", "")
        Set FrmMger.DataGrid1.DataSource = rst
        FrmMger.Command3.Enabled = True
        FrmMger.Command4.Enabled = True
        With FrmMger.DataGrid1
            .Columns(0).Caption = "编号"
            .Columns(1).Caption = "姓名"
            .Columns(3).Caption = "性别"
            .Columns(4).Caption = "出生日期"
            .Columns(5).Caption = "联系电话"
            .Columns(6).Caption = "电子邮件"
            .Columns(7).Caption = "联系地址"
            .Columns(8).Caption = "简介"
            .Columns(2).Visible = False
        End With
    End If
ElseIf Label1.Caption = "添加图书" Then
    If Text10.Text = "" Or Text11.Text = "" Then
        MsgBox ("图书编号和书名不能空")
        Exit Sub
    Else
        Call ins_table("Books", "", "values('" & Text10.Text & "','" & Text11.Text & "','" & Text12.Text & "','" & Text13.Text & "','" & Text14.Text & "','" & Text15.Text & "','" & Text16.Text & "')")
        MsgBox ("添加成功")
        Call sel_table("Books", "")
        Set FrmMger.DataGrid1.DataSource = rst
        FrmMger.Label3.Caption = "图书:" & rst.RecordCount & "本"
        FrmMger.Command3.Enabled = True
        FrmMger.Command4.Enabled = True
        With FrmMger.DataGrid1
            .Columns(0).Caption = "编号"
            .Columns(1).Caption = "书名"
            .Columns(2).Caption = "分类"
            .Columns(3).Caption = "作者"
            .Columns(4).Caption = "出版社"
            .Columns(5).Caption = "出版日期"
            .Columns(6).Caption = "图书简介"
        End With
    End If
ElseIf Label1.Caption = "修改图书" Then
    If Text10.Text = "" Or Text11.Text = "" Then
        MsgBox ("图书编号和书名不能空")
        Exit Sub
    Else
        Call upd_table("Books", "Bname='" & Text11.Text & "',Bclass='" & Text12.Text & "',Bwriter='" & Text13.Text & "',Bbookman='" & Text14.Text & "',Bborn='" & Text15.Text & "',Binstr='" & Text16.Text & "'", "Bid='" & Text10.Text & "'")
        MsgBox ("修改成功")
        Call sel_table("Books", "")
        Set FrmMger.DataGrid1.DataSource = rst
        FrmMger.Label3.Caption = "图书:" & rst.RecordCount & "本"
        FrmMger.Command3.Enabled = True
        FrmMger.Command4.Enabled = True
        With FrmMger.DataGrid1
            .Columns(0).Caption = "编号"
            .Columns(1).Caption = "书名"
            .Columns(2).Caption = "分类"
            .Columns(3).Caption = "作者"
            .Columns(4).Caption = "出版社"
            .Columns(5).Caption = "出版日期"
            .Columns(6).Caption = "图书简介"
        End With
    End If
ElseIf Label1.Caption = "删除图书" Then
    Call del_table("Books", "where Bid='" & Text10.Text & "'")
    MsgBox ("删除成功")
    Call sel_table("Books", "")
    Set FrmMger.DataGrid1.DataSource = rst
    If rst.RecordCount > 0 Then
        FrmMger.Label3.Caption = "图书:" & rst.RecordCount & "本"
        FrmMger.Command3.Enabled = True
        FrmMger.Command4.Enabled = True
    Else
        FrmMger.Label3.Caption = "无图书"
        FrmMger.Command3.Enabled = False
        FrmMger.Command4.Enabled = False
    End If
    With FrmMger.DataGrid1
        .Columns(0).Caption = "编号"
        .Columns(1).Caption = "书名"
        .Columns(2).Caption = "分类"
        .Columns(3).Caption = "作者"
        .Columns(4).Caption = "出版社"
        .Columns(5).Caption = "出版日期"
        .Columns(6).Caption = "图书简介"
    End With
ElseIf Label1.Caption = "添加借书记录" Then
    If Text17.Text = "" Or Text18.Text = "" Then
        MsgBox ("图书编号和用户编号不能为空")
        Exit Sub
    End If
    Call sel_table("Books", "where Bid='" & Text17.Text & "'")
    If rst.RecordCount <= 0 Then
        MsgBox ("图书编号输入错误")
        Exit Sub
    End If
    Call sel_table("UB", "where Bid='" & Text17.Text & "'")
    If rst.RecordCount > 0 Then
        MsgBox ("该图书已被借用")
        Exit Sub
    End If
    Call sel_table("Users", "where Uid='" & Text18.Text & "'")
    If rst.RecordCount <= 0 Then
        MsgBox ("无该用户")
        Exit Sub
    End If
    Call sel_table("UB", "where Uid='" & Text18.Text & "'")
    If rst.RecordCount > 14 Then
        MsgBox ("该用户借用图书本数超出限制本数(15本)")
        Exit Sub
    End If
    Dim T_date As String
    Dim R_date As String
    T_date = Date
    R_date = DateAdd("d", 60, Date)
    Call ins_table("UB", "", "values('" & Text18.Text & "','" & Text17.Text & "','" & T_date & "','" & R_date & "','0')")
    MsgBox ("添加成功")
    Call sel_table("UB", "")
    Set FrmMger.DataGrid1.DataSource = rst
    FrmMger.Label3.Caption = "借书:" & rst.RecordCount & "本"
    FrmMger.Command3.Enabled = True
    FrmMger.Command4.Enabled = True
    With FrmMger.DataGrid1
        .Columns(0).Caption = "用户编号"
        .Columns(1).Caption = "图书编号"
        .Columns(2).Caption = "借书日期"
        .Columns(3).Caption = "应还书日期"
        .Columns(4).Caption = "超出天数"
    End With
ElseIf Label1.Caption = "删除借书记录" Then
    Call del_table("UB", "where Bid='" & Text17.Text & "' and Uid='" & Text18.Text & "'")
    MsgBox ("删除成功")
    Unload Me
    Call sel_table("UB", "")
    Set FrmMger.DataGrid1.DataSource = rst
    If rst.RecordCount > 0 Then
        FrmMger.Label3.Caption = "借书:" & rst.RecordCount & "本"
        FrmMger.Command4.Enabled = True
    Else
        FrmMger.Label3.Caption = "无"
        FrmMger.Command4.Enabled = False
    End If
    With FrmMger.DataGrid1
        .Columns(0).Caption = "用户编号"
        .Columns(1).Caption = "图书编号"
        .Columns(2).Caption = "借书日期"
        .Columns(3).Caption = "应还书日期"
        .Columns(4).Caption = "超出天数"
    End With
    Exit Sub
End If
Unload Me
End Sub

Private Sub Command2_Click()
Unload Me
End Sub

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -