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

📄 admin_deleteadmin.vb

📁 图书馆管理系统,是数据库的课程设计,报告里面包含了需求分析数据字典概念结构设计逻辑结构设计数据库物理设计数据库实施
💻 VB
字号:
Imports System.Data
'引入数据库操作类命名空间
Imports System.Data.OleDb
'引入ADO.NET操作命名空间

Public Class win_deleteadmin
    Inherits System.Windows.Forms.Form
    Dim sqlstr As String 'SQL语句标记
    Dim objDS As DataSet '数据在内存中的缓存
    Dim i As Integer, CheckEvery As Boolean = True

#Region " Windows 窗体设计器生成的代码 "

    Public Sub New()
        MyBase.New()

        '该调用是 Windows 窗体设计器所必需的。
        InitializeComponent()

        '在 InitializeComponent() 调用之后添加任何初始化

    End Sub

    '窗体重写 dispose 以清理组件列表。
    Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean)
        If disposing Then
            If Not (components Is Nothing) Then
                components.Dispose()
            End If
        End If
        MyBase.Dispose(disposing)
    End Sub

    'Windows 窗体设计器所必需的
    Private components As System.ComponentModel.IContainer

    '注意: 以下过程是 Windows 窗体设计器所必需的
    '可以使用 Windows 窗体设计器修改此过程。
    '不要使用代码编辑器修改它。
    Friend WithEvents GroupBox1 As System.Windows.Forms.GroupBox
    Friend WithEvents btchooseall As System.Windows.Forms.Button
    Friend WithEvents btdelete As System.Windows.Forms.Button
    Friend WithEvents clbshowalladmins As System.Windows.Forms.CheckedListBox
    Friend WithEvents Button1 As System.Windows.Forms.Button
    Friend WithEvents Label1 As System.Windows.Forms.Label
    <System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()
        Dim resources As System.Resources.ResourceManager = New System.Resources.ResourceManager(GetType(win_deleteadmin))
        Me.clbshowalladmins = New System.Windows.Forms.CheckedListBox
        Me.GroupBox1 = New System.Windows.Forms.GroupBox
        Me.Label1 = New System.Windows.Forms.Label
        Me.Button1 = New System.Windows.Forms.Button
        Me.btdelete = New System.Windows.Forms.Button
        Me.btchooseall = New System.Windows.Forms.Button
        Me.GroupBox1.SuspendLayout()
        Me.SuspendLayout()
        '
        'clbshowalladmins
        '
        Me.clbshowalladmins.BackColor = System.Drawing.SystemColors.Menu
        Me.clbshowalladmins.CheckOnClick = True
        Me.clbshowalladmins.Location = New System.Drawing.Point(8, 16)
        Me.clbshowalladmins.Name = "clbshowalladmins"
        Me.clbshowalladmins.ScrollAlwaysVisible = True
        Me.clbshowalladmins.Size = New System.Drawing.Size(145, 148)
        Me.clbshowalladmins.TabIndex = 4
        Me.clbshowalladmins.ThreeDCheckBoxes = True
        '
        'GroupBox1
        '
        Me.GroupBox1.Controls.Add(Me.Label1)
        Me.GroupBox1.Controls.Add(Me.Button1)
        Me.GroupBox1.Controls.Add(Me.btdelete)
        Me.GroupBox1.Controls.Add(Me.btchooseall)
        Me.GroupBox1.Controls.Add(Me.clbshowalladmins)
        Me.GroupBox1.ForeColor = System.Drawing.SystemColors.ControlDark
        Me.GroupBox1.Location = New System.Drawing.Point(0, 0)
        Me.GroupBox1.Name = "GroupBox1"
        Me.GroupBox1.Size = New System.Drawing.Size(264, 186)
        Me.GroupBox1.TabIndex = 1
        Me.GroupBox1.TabStop = False
        Me.GroupBox1.Text = "删除管理员"
        '
        'Label1
        '
        Me.Label1.Location = New System.Drawing.Point(72, 168)
        Me.Label1.Name = "Label1"
        Me.Label1.Size = New System.Drawing.Size(128, 16)
        Me.Label1.TabIndex = 4
        Me.Label1.Text = "最高管理员不能删除!"
        Me.Label1.TextAlign = System.Drawing.ContentAlignment.MiddleLeft
        '
        'Button1
        '
        Me.Button1.DialogResult = System.Windows.Forms.DialogResult.Cancel
        Me.Button1.ForeColor = System.Drawing.SystemColors.ControlText
        Me.Button1.Location = New System.Drawing.Point(184, 113)
        Me.Button1.Name = "Button1"
        Me.Button1.Size = New System.Drawing.Size(56, 24)
        Me.Button1.TabIndex = 3
        Me.Button1.Text = "关闭"
        '
        'btdelete
        '
        Me.btdelete.ForeColor = System.Drawing.SystemColors.ControlText
        Me.btdelete.Location = New System.Drawing.Point(184, 81)
        Me.btdelete.Name = "btdelete"
        Me.btdelete.Size = New System.Drawing.Size(56, 24)
        Me.btdelete.TabIndex = 2
        Me.btdelete.Text = "删除"
        '
        'btchooseall
        '
        Me.btchooseall.ForeColor = System.Drawing.SystemColors.ControlText
        Me.btchooseall.Location = New System.Drawing.Point(184, 49)
        Me.btchooseall.Name = "btchooseall"
        Me.btchooseall.Size = New System.Drawing.Size(56, 24)
        Me.btchooseall.TabIndex = 1
        Me.btchooseall.Text = "全部"
        '
        'win_deleteadmin
        '
        Me.AutoScaleBaseSize = New System.Drawing.Size(6, 14)
        Me.CancelButton = Me.Button1
        Me.ClientSize = New System.Drawing.Size(264, 189)
        Me.Controls.Add(Me.GroupBox1)
        Me.Icon = CType(resources.GetObject("$this.Icon"), System.Drawing.Icon)
        Me.MaximizeBox = False
        Me.MaximumSize = New System.Drawing.Size(272, 216)
        Me.MinimumSize = New System.Drawing.Size(272, 216)
        Me.Name = "win_deleteadmin"
        Me.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen
        Me.Text = "图书馆管理系统--删除管理员"
        Me.GroupBox1.ResumeLayout(False)
        Me.ResumeLayout(False)

    End Sub

#End Region

    Private Sub btchooseall_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btchooseall.Click
        If CheckEvery Then
            For i = 0 To clbshowalladmins.Items.Count - 1
                clbshowalladmins.SetItemCheckState(i, CheckState.Checked)
            Next
            CheckEvery = False
        Else
            For i = 0 To clbshowalladmins.Items.Count - 1
                clbshowalladmins.SetItemCheckState(i, CheckState.Unchecked)
            Next
            CheckEvery = True
        End If
    End Sub

    Private Sub win_deleteadmin_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        sqlstr = "select * from admininfo"
        objDS = GetData(sqlstr)
        For i = 0 To objDS.Tables(0).Rows.Count - 1
            clbshowalladmins.Items.Insert(0, objDS.Tables(0).Rows(i)("adminname").ToString)
        Next
    End Sub


    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        Close()
    End Sub

    Private Sub btdelete_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btdelete.Click
        Dim itemChecked As Object
        Try
            If MsgBox("确定要删除该管理员吗?", MsgBoxStyle.YesNo + MsgBoxStyle.Question, "查询") = MsgBoxResult.Yes Then
                For Each itemChecked In clbshowalladmins.CheckedItems
                    sqlstr = "delete from admininfo where adminname='" & itemChecked.ToString & "' and id<>1 "
                    UpdateData(sqlstr)
                Next
                Me.Close()
                MessageBox.Show("数据库操作成功", "成功", MessageBoxButtons.OK, MessageBoxIcon.Information)
            End If
        Catch
            MessageBox.Show("更新数据库失败", "错误", MessageBoxButtons.OK, MessageBoxIcon.Information)
        End Try
    End Sub
End Class

⌨️ 快捷键说明

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