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

📄 frmmger.frm

📁 完整的数据库课程设计
💻 FRM
📖 第 1 页 / 共 2 页
字号:
        .Columns(4).Caption = "超出天数"
    End With
End If
End Sub

Private Sub Command2_Click()
If SSTab1.Tab = 0 Or SSTab1.Tab = 1 Then
    With FrmUpd
        .Picture1.Visible = True
        .Picture2.Visible = False
        .Picture3.Visible = False
        .Picture1.Height = 4215
        .Picture1.Top = 480
    End With
    If SSTab1.Tab = 1 Then
        FrmUpd.Label1.Caption = "添加用户信息"
    Else
        FrmUpd.Label1.Caption = "添加管理员信息"
    End If
ElseIf SSTab1.Tab = 2 Then
    With FrmUpd
        .Picture1.Visible = False
        .Picture2.Visible = True
        .Picture3.Visible = False
        .Picture2.Height = 4215
        .Picture2.Top = 480
        .Label1.Caption = "添加图书"
    End With
ElseIf SSTab1.Tab = 3 Then
    With FrmUpd
        .Picture1.Visible = False
        .Picture2.Visible = False
        .Picture3.Visible = True
        .Picture3.Height = 4215
        .Picture3.Top = 480
        .Label1.Caption = "添加借书记录"
    End With
End If
FrmUpd.Show 1
End Sub

Private Sub Command3_Click()
Call connect_db
If SSTab1.Tab = 0 Or SSTab1.Tab = 1 Then
    With FrmUpd
        .Picture1.Visible = True
        .Picture2.Visible = False
        .Picture3.Visible = False
        .Picture1.Height = 4215
        .Picture1.Top = 480
    End With
    If SSTab1.Tab = 0 Then
        FrmUpd.Label1.Caption = "修改管理员信息"
        Call sel_table("Managers", "where Mid='" & Label4.Caption & "'")
        With FrmUpd
            .Text1 = rst("Mid") & ""
            .Label2.Enabled = False
            .Text1.Enabled = False
            .Text2 = rst("Mname") & ""
            .Text3 = rst("Mpwd") & ""
            .Text4 = rst("Msex") & ""
            .Text5 = rst("Mborn") & ""
            .Text6 = rst("Mtel") & ""
            .Text7 = rst("Memail") & ""
            .Text8 = rst("Maddr") & ""
            .Text9 = rst("Mremark") & ""
        End With
    ElseIf SSTab1.Tab = 1 Then
        FrmUpd.Label1.Caption = "修改用户信息"
        Call sel_table("Users", "where Uid='" & DataGrid1.Columns(0).Text & "'")
        With FrmUpd
            .Text1 = rst("Uid") & ""
            .Label2.Enabled = False
            .Text1.Enabled = False
            .Text2 = rst("Uname") & ""
            .Label4.Enabled = False
            .Text3.Enabled = False
            .Text4 = rst("Usex") & ""
            .Text5 = rst("Uborn") & ""
            .Text6 = rst("Utel") & ""
            .Text7 = rst("Uemail") & ""
            .Text8 = rst("Uaddr") & ""
            .Text9 = rst("Uremark") & ""
        End With
    End If
ElseIf SSTab1.Tab = 2 Then
    With FrmUpd
        .Picture1.Visible = False
        .Picture2.Visible = True
        .Picture3.Visible = False
        .Picture2.Height = 4215
        .Picture2.Top = 480
        .Label1.Caption = "修改图书"
    End With
    Call sel_table("Books", "where Bid='" & DataGrid1.Columns(0).Text & "'")
    With FrmUpd
        .Text10 = rst("Bid") & ""
        .Label10.Enabled = False
        .Text10.Enabled = False
        .Text11 = rst("Bname") & ""
        .Text12 = rst("Bclass") & ""
        .Text13 = rst("Bwriter") & ""
        .Text14 = rst("Bbookman") & ""
        .Text15 = rst("Bborn") & ""
        .Text16 = rst("Binstr") & ""
    End With
End If
FrmUpd.Show 1
End Sub

Private Sub Command4_Click()
Call connect_db
If SSTab1.Tab = 0 Or SSTab1.Tab = 1 Then
    With FrmUpd
        .Picture1.Visible = True
        .Picture2.Visible = False
        .Picture3.Visible = False
        .Picture1.Height = 4215
        .Picture1.Top = 480
        .Text1.Enabled = False
        .Text2.Enabled = False
        .Text3.Enabled = False
        .Text4.Enabled = False
        .Text5.Enabled = False
        .Text6.Enabled = False
        .Text7.Enabled = False
        .Text8.Enabled = False
        .Text9.Enabled = False
    End With
    If SSTab1.Tab = 0 Then
        FrmUpd.Label1.Caption = "删除管理员信息"
        Call sel_table("Managers", "where Mid='" & DataGrid1.Columns(0).Text & "'")
        With FrmUpd
            .Text1.Text = rst("Mid") & ""
            .Text2.Text = rst("Mname") & ""
            .Text4.Text = rst("Msex") & ""
            .Text5.Text = rst("Mborn") & ""
            .Text6.Text = rst("Mtel") & ""
            .Text7.Text = rst("Memail") & ""
            .Text8.Text = rst("Maddr") & ""
            .Text9.Text = rst("Mremark") & ""
        End With
    ElseIf SSTab1.Tab = 1 Then
        Call sel_table("UB", "where Uid='" & DataGrid1.Columns(0).Text & "'")
        If rst.RecordCount > 0 Then
            MsgBox ("该用户还有书未还")
            Exit Sub
        End If
        FrmUpd.Label1.Caption = "删除用户信息"
        Call sel_table("Users", "where Uid='" & DataGrid1.Columns(0).Text & "'")
        With FrmUpd
            .Text1.Text = rst("Uid") & ""
            .Text2.Text = rst("Uname") & ""
            .Text4.Text = rst("Usex") & ""
            .Text5.Text = rst("Uborn") & ""
            .Text6.Text = rst("Utel") & ""
            .Text7.Text = rst("Uemail") & ""
            .Text8.Text = rst("Uaddr") & ""
            .Text9.Text = rst("Uremark") & ""
        End With
    End If
ElseIf SSTab1.Tab = 2 Then
    Call sel_table("UB", "where Bid='" & DataGrid1.Columns(0).Text & "'")
    If rst.RecordCount > 0 Then
        MsgBox ("该图书被借用中")
        Exit Sub
    End If
    With FrmUpd
        .Picture1.Visible = False
        .Picture2.Visible = True
        .Picture3.Visible = False
        .Picture2.Height = 4215
        .Picture2.Top = 480
        .Label1.Caption = "删除图书"
        .Text10.Enabled = False
        .Text11.Enabled = False
        .Text12.Enabled = False
        .Text13.Enabled = False
        .Text14.Enabled = False
        .Text15.Enabled = False
        .Text16.Enabled = False
    End With
    Call sel_table("Books", "where Bid='" & DataGrid1.Columns(0).Text & "'")
    With FrmUpd
        .Text10.Text = rst("Bid") & ""
        .Text11.Text = rst("Bname") & ""
        .Text12.Text = rst("Bclass") & ""
        .Text13.Text = rst("Bwriter") & ""
        .Text14.Text = rst("Bbookman") & ""
        .Text15.Text = rst("Bborn") & ""
        .Text16.Text = rst("Binstr") & ""
    End With
ElseIf SSTab1.Tab = 3 Then
    With FrmUpd
        .Picture1.Visible = False
        .Picture2.Visible = False
        .Picture3.Visible = True
        .Picture3.Height = 4215
        .Picture3.Top = 480
        .Label1.Caption = "删除借书记录"
        .Text17.Enabled = False
        .Text18.Enabled = False
    End With
    Call sel_table("UB", "where Bid='" & DataGrid1.Columns(1).Text & "' and Uid='" & DataGrid1.Columns(0).Text & "'")
    With FrmUpd
        .Text17 = rst("Bid")
        .Text18 = rst("Uid")
    End With
End If
FrmUpd.Show 1
End Sub

Private Sub Command5_Click()
Unload Me
End Sub

Private Sub Form_Unload(Cancel As Integer)
FrmMain.Show
End Sub

Private Sub SSTab1_Click(PreviousTab As Integer)
Call connect_db
Select Case SSTab1.Tab
    Case 0:
        Text1.Text = ""
        With Combo1
            .Clear
            .List(0) = "管理员编号"
            .List(1) = "管理员姓名"
            .Text = "管理员编号"
        End With
        Call sel_table("Managers", "")
        Set DataGrid1.DataSource = rst
        If rst.RecordCount > 0 Then
            Label3.Caption = "管理员人数:" & rst.RecordCount & "人"
            Command3.Enabled = True
            Command4.Enabled = True
        Else
            Label3.Caption = "无管理员"
            Command3.Enabled = False
            Command4.Enabled = False
        End If
        With 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
    Case 1:
        Text1.Text = ""
        With Combo1
            .Clear
            .List(0) = "用户编号"
            .List(1) = "用户姓名"
            .Text = "用户编号"
        End With
        Call sel_table("Users", "")
        Set DataGrid1.DataSource = rst
        If rst.RecordCount > 0 Then
            Label3.Caption = "用户人数:" & rst.RecordCount & "人"
            Command3.Enabled = True
            Command4.Enabled = True
        Else
            Label3.Caption = "无用户"
            Command3.Enabled = False
            Command4.Enabled = False
        End If
        With 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
    Case 2:
        Text1.Text = ""
        Combo1.Clear
        With Combo1
            .List(0) = "图书编号"
            .List(1) = "书名"
            .List(2) = "作者"
            .List(3) = "出版社"
            .Text = "图书编号"
        End With
        Call sel_table("Books", "")
        Set DataGrid1.DataSource = rst
        If rst.RecordCount > 0 Then
            Label3.Caption = "图书:" & rst.RecordCount & "本"
            Command3.Enabled = True
            Command4.Enabled = True
        Else
            Label3.Caption = "无图书"
            Command3.Enabled = False
            Command4.Enabled = False
        End If
        With DataGrid1
            .Columns(0).Caption = "编号"
            .Columns(1).Caption = "书名"
            .Columns(2).Caption = "分类"
            .Columns(3).Caption = "作者"
            .Columns(4).Caption = "出版社"
            .Columns(5).Caption = "出版日期"
            .Columns(6).Caption = "图书简介"
        End With
    Case 3:
        Text1.Text = ""
        Command3.Enabled = False
        With Combo1
            .Clear
            .List(0) = "图书编号"
            .List(1) = "用户编号"
            .Text = "图书编号"
        End With
        Call sel_table("UB", "")
        Set DataGrid1.DataSource = rst
        If rst.RecordCount > 0 Then
            Label3.Caption = "借书:" & rst.RecordCount & "本"
            Command4.Enabled = True
            rst.MoveFirst
            Dim num As Integer
            While Not rst.EOF
                num = DateDiff("d", DataGrid1.Columns(3).Text, Date)
                If num <= 0 Then num = 0
                DataGrid1.AllowUpdate = True
                DataGrid1.Columns(4).Text = num
                rst.Update
                DataGrid1.AllowUpdate = False
                rst.MoveNext
            Wend
        Else
            Label3.Caption = "无"
            Command4.Enabled = False
        End If
        With DataGrid1
            .Columns(0).Caption = "用户编号"
            .Columns(1).Caption = "图书编号"
            .Columns(2).Caption = "借书日期"
            .Columns(3).Caption = "应还书日期"
            .Columns(4).Caption = "超出天数"
        End With
End Select
End Sub

⌨️ 快捷键说明

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