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

📄 frmadduser.vb

📁 图书管理系统,用来管理图书的借还,以及借阅超过时间进行处罚,和管理员用户权限
💻 VB
字号:
Imports System.Data
Imports System.Data.SqlClient
Public Class frmaddUser
    Inherits System.Windows.Forms.Form

#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 bnCancle As System.Windows.Forms.Button
    Friend WithEvents bnClean As System.Windows.Forms.Button
    Friend WithEvents bnAdd As System.Windows.Forms.Button
    Friend WithEvents tbStudNo As System.Windows.Forms.TextBox
    Friend WithEvents tbClass As System.Windows.Forms.TextBox
    Friend WithEvents tbUsername As System.Windows.Forms.TextBox
    Friend WithEvents tbPwdConfirm As System.Windows.Forms.TextBox
    Friend WithEvents tbPwd As System.Windows.Forms.TextBox
    Friend WithEvents Label7 As System.Windows.Forms.Label
    Friend WithEvents Label6 As System.Windows.Forms.Label
    Friend WithEvents Label5 As System.Windows.Forms.Label
    Friend WithEvents Label3 As System.Windows.Forms.Label
    Friend WithEvents Label2 As System.Windows.Forms.Label
    Friend WithEvents Label1 As System.Windows.Forms.Label
    Friend WithEvents GroupBox1 As System.Windows.Forms.GroupBox
    Friend WithEvents tbsex As System.Windows.Forms.TextBox
    Friend WithEvents tbtelno As System.Windows.Forms.TextBox
    Friend WithEvents Label15 As System.Windows.Forms.Label
    Friend WithEvents Label8 As System.Windows.Forms.Label
    Friend WithEvents Label4 As System.Windows.Forms.Label
    Friend WithEvents tbEmail As System.Windows.Forms.TextBox
    Friend WithEvents tbcardid As System.Windows.Forms.TextBox
    <System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()
        Dim resources As System.Resources.ResourceManager = New System.Resources.ResourceManager(GetType(frmaddUser))
        Me.bnCancle = New System.Windows.Forms.Button
        Me.bnClean = New System.Windows.Forms.Button
        Me.bnAdd = New System.Windows.Forms.Button
        Me.tbStudNo = New System.Windows.Forms.TextBox
        Me.tbClass = New System.Windows.Forms.TextBox
        Me.tbUsername = New System.Windows.Forms.TextBox
        Me.tbPwdConfirm = New System.Windows.Forms.TextBox
        Me.tbPwd = New System.Windows.Forms.TextBox
        Me.tbcardid = New System.Windows.Forms.TextBox
        Me.Label7 = New System.Windows.Forms.Label
        Me.Label6 = New System.Windows.Forms.Label
        Me.Label5 = New System.Windows.Forms.Label
        Me.Label3 = New System.Windows.Forms.Label
        Me.Label2 = New System.Windows.Forms.Label
        Me.Label1 = New System.Windows.Forms.Label
        Me.GroupBox1 = New System.Windows.Forms.GroupBox
        Me.tbsex = New System.Windows.Forms.TextBox
        Me.tbtelno = New System.Windows.Forms.TextBox
        Me.Label15 = New System.Windows.Forms.Label
        Me.Label8 = New System.Windows.Forms.Label
        Me.Label4 = New System.Windows.Forms.Label
        Me.tbEmail = New System.Windows.Forms.TextBox
        Me.GroupBox1.SuspendLayout()
        Me.SuspendLayout()
        '
        'bnCancle
        '
        Me.bnCancle.Location = New System.Drawing.Point(288, 118)
        Me.bnCancle.Name = "bnCancle"
        Me.bnCancle.Size = New System.Drawing.Size(88, 24)
        Me.bnCancle.TabIndex = 33
        Me.bnCancle.Text = "取消"
        '
        'bnClean
        '
        Me.bnClean.Location = New System.Drawing.Point(288, 78)
        Me.bnClean.Name = "bnClean"
        Me.bnClean.Size = New System.Drawing.Size(88, 24)
        Me.bnClean.TabIndex = 32
        Me.bnClean.Text = "清空"
        '
        'bnAdd
        '
        Me.bnAdd.Location = New System.Drawing.Point(288, 38)
        Me.bnAdd.Name = "bnAdd"
        Me.bnAdd.Size = New System.Drawing.Size(88, 24)
        Me.bnAdd.TabIndex = 31
        Me.bnAdd.Text = "添加"
        '
        'tbStudNo
        '
        Me.tbStudNo.Location = New System.Drawing.Point(96, 182)
        Me.tbStudNo.Name = "tbStudNo"
        Me.tbStudNo.Size = New System.Drawing.Size(152, 21)
        Me.tbStudNo.TabIndex = 29
        Me.tbStudNo.Text = ""
        '
        'tbClass
        '
        Me.tbClass.Location = New System.Drawing.Point(96, 158)
        Me.tbClass.Name = "tbClass"
        Me.tbClass.Size = New System.Drawing.Size(152, 21)
        Me.tbClass.TabIndex = 28
        Me.tbClass.Text = ""
        '
        'tbUsername
        '
        Me.tbUsername.Location = New System.Drawing.Point(96, 109)
        Me.tbUsername.Name = "tbUsername"
        Me.tbUsername.Size = New System.Drawing.Size(152, 21)
        Me.tbUsername.TabIndex = 27
        Me.tbUsername.Text = ""
        '
        'tbPwdConfirm
        '
        Me.tbPwdConfirm.Location = New System.Drawing.Point(96, 80)
        Me.tbPwdConfirm.Name = "tbPwdConfirm"
        Me.tbPwdConfirm.Size = New System.Drawing.Size(152, 21)
        Me.tbPwdConfirm.TabIndex = 26
        Me.tbPwdConfirm.Text = ""
        '
        'tbPwd
        '
        Me.tbPwd.Location = New System.Drawing.Point(96, 51)
        Me.tbPwd.Name = "tbPwd"
        Me.tbPwd.Size = New System.Drawing.Size(152, 21)
        Me.tbPwd.TabIndex = 25
        Me.tbPwd.Text = ""
        '
        'tbcardid
        '
        Me.tbcardid.Location = New System.Drawing.Point(96, 22)
        Me.tbcardid.Name = "tbcardid"
        Me.tbcardid.Size = New System.Drawing.Size(152, 21)
        Me.tbcardid.TabIndex = 24
        Me.tbcardid.Text = ""
        '
        'Label7
        '
        Me.Label7.Location = New System.Drawing.Point(40, 182)
        Me.Label7.Name = "Label7"
        Me.Label7.Size = New System.Drawing.Size(56, 24)
        Me.Label7.TabIndex = 23
        Me.Label7.Text = "学号:"
        Me.Label7.TextAlign = System.Drawing.ContentAlignment.MiddleRight
        '
        'Label6
        '
        Me.Label6.Location = New System.Drawing.Point(24, 80)
        Me.Label6.Name = "Label6"
        Me.Label6.Size = New System.Drawing.Size(72, 24)
        Me.Label6.TabIndex = 22
        Me.Label6.Text = "确认口令:"
        Me.Label6.TextAlign = System.Drawing.ContentAlignment.MiddleRight
        '
        'Label5
        '
        Me.Label5.Location = New System.Drawing.Point(40, 109)
        Me.Label5.Name = "Label5"
        Me.Label5.Size = New System.Drawing.Size(56, 24)
        Me.Label5.TabIndex = 21
        Me.Label5.Text = "姓名:"
        Me.Label5.TextAlign = System.Drawing.ContentAlignment.MiddleRight
        '
        'Label3
        '
        Me.Label3.Location = New System.Drawing.Point(40, 158)
        Me.Label3.Name = "Label3"
        Me.Label3.Size = New System.Drawing.Size(56, 24)
        Me.Label3.TabIndex = 20
        Me.Label3.Text = "班级:"
        Me.Label3.TextAlign = System.Drawing.ContentAlignment.MiddleRight
        '
        'Label2
        '
        Me.Label2.Location = New System.Drawing.Point(40, 51)
        Me.Label2.Name = "Label2"
        Me.Label2.Size = New System.Drawing.Size(56, 24)
        Me.Label2.TabIndex = 19
        Me.Label2.Text = "口令:"
        Me.Label2.TextAlign = System.Drawing.ContentAlignment.MiddleRight
        '
        'Label1
        '
        Me.Label1.Location = New System.Drawing.Point(32, 22)
        Me.Label1.Name = "Label1"
        Me.Label1.Size = New System.Drawing.Size(64, 24)
        Me.Label1.TabIndex = 18
        Me.Label1.Text = "借阅证号:"
        Me.Label1.TextAlign = System.Drawing.ContentAlignment.MiddleRight
        '
        'GroupBox1
        '
        Me.GroupBox1.Controls.Add(Me.tbsex)
        Me.GroupBox1.Controls.Add(Me.tbtelno)
        Me.GroupBox1.Controls.Add(Me.Label15)
        Me.GroupBox1.Controls.Add(Me.Label8)
        Me.GroupBox1.Controls.Add(Me.Label4)
        Me.GroupBox1.Controls.Add(Me.tbEmail)
        Me.GroupBox1.ForeColor = System.Drawing.Color.Red
        Me.GroupBox1.Location = New System.Drawing.Point(16, 6)
        Me.GroupBox1.Name = "GroupBox1"
        Me.GroupBox1.Size = New System.Drawing.Size(256, 264)
        Me.GroupBox1.TabIndex = 30
        Me.GroupBox1.TabStop = False
        Me.GroupBox1.Text = "办理借书卡"
        '
        'tbsex
        '
        Me.tbsex.Location = New System.Drawing.Point(80, 128)
        Me.tbsex.Name = "tbsex"
        Me.tbsex.Size = New System.Drawing.Size(152, 21)
        Me.tbsex.TabIndex = 148
        Me.tbsex.Text = ""
        '
        'tbtelno
        '
        Me.tbtelno.Location = New System.Drawing.Point(80, 232)
        Me.tbtelno.Name = "tbtelno"
        Me.tbtelno.Size = New System.Drawing.Size(152, 21)
        Me.tbtelno.TabIndex = 147
        Me.tbtelno.Text = ""
        '
        'Label15
        '
        Me.Label15.ForeColor = System.Drawing.Color.Black
        Me.Label15.Location = New System.Drawing.Point(24, 232)
        Me.Label15.Name = "Label15"
        Me.Label15.Size = New System.Drawing.Size(56, 24)
        Me.Label15.TabIndex = 146
        Me.Label15.Text = "电话:"
        Me.Label15.TextAlign = System.Drawing.ContentAlignment.MiddleRight
        '
        'Label8
        '
        Me.Label8.ForeColor = System.Drawing.Color.Black
        Me.Label8.Location = New System.Drawing.Point(32, 136)
        Me.Label8.Name = "Label8"
        Me.Label8.Size = New System.Drawing.Size(48, 16)
        Me.Label8.TabIndex = 18
        Me.Label8.Text = "性别:"
        '
        'Label4
        '
        Me.Label4.ForeColor = System.Drawing.Color.Black
        Me.Label4.Location = New System.Drawing.Point(24, 200)
        Me.Label4.Name = "Label4"
        Me.Label4.Size = New System.Drawing.Size(56, 24)
        Me.Label4.TabIndex = 3
        Me.Label4.Text = "email:"
        Me.Label4.TextAlign = System.Drawing.ContentAlignment.MiddleRight
        '
        'tbEmail
        '
        Me.tbEmail.Location = New System.Drawing.Point(80, 200)
        Me.tbEmail.Name = "tbEmail"
        Me.tbEmail.Size = New System.Drawing.Size(152, 21)
        Me.tbEmail.TabIndex = 11
        Me.tbEmail.Text = ""
        '
        'frmaddUser
        '
        Me.AutoScaleBaseSize = New System.Drawing.Size(6, 14)
        Me.ClientSize = New System.Drawing.Size(392, 277)
        Me.Controls.Add(Me.bnCancle)
        Me.Controls.Add(Me.bnClean)
        Me.Controls.Add(Me.bnAdd)
        Me.Controls.Add(Me.tbStudNo)
        Me.Controls.Add(Me.tbClass)
        Me.Controls.Add(Me.tbUsername)
        Me.Controls.Add(Me.tbPwdConfirm)
        Me.Controls.Add(Me.tbPwd)
        Me.Controls.Add(Me.tbcardid)
        Me.Controls.Add(Me.Label7)
        Me.Controls.Add(Me.Label6)
        Me.Controls.Add(Me.Label5)
        Me.Controls.Add(Me.Label3)
        Me.Controls.Add(Me.Label2)
        Me.Controls.Add(Me.Label1)
        Me.Controls.Add(Me.GroupBox1)
        Me.Icon = CType(resources.GetObject("$this.Icon"), System.Drawing.Icon)
        Me.Name = "frmaddUser"
        Me.Text = "----------办理借书卡"
        Me.GroupBox1.ResumeLayout(False)
        Me.ResumeLayout(False)

    End Sub

#End Region

    Private Sub frmUserModify_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

    End Sub

    Private Sub bnAdd_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)
        
    End Sub

    Private Sub bnCancle_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)
        Me.Close()
    End Sub
    Private Sub clearTb()
        tbcardid.Clear()
        tbPwd.Clear()
        tbPwdConfirm.Clear()
        tbUsername.Clear()
        tbEmail.Clear()
        tbClass.Clear()
        tbStudNo.Clear()
        tbsex.Clear()
        tbtelno.Clear()
        'cbAdmin.Checked = False
    End Sub
    Private Sub bnClean_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)
        clearTb()
    End Sub

    Private Sub bnAdd_Click_1(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles bnAdd.Click
        Dim strbookcardid As String = tbcardid.Text.Trim()
        Dim strPwd As String = tbPwd.Text.Trim()
        Dim strPwdConfirm As String = tbPwdConfirm.Text.Trim()
        Dim strUsername As String = tbUsername.Text.Trim()
        Dim strsex As String = tbsex.Text.Trim()
        Dim strEmail As String = tbEmail.Text.Trim()
        Dim strClass As String = tbClass.Text.Trim()
        Dim strStudNO As String = tbStudNo.Text.Trim()
        Dim strtelno As String = tbtelno.Text.Trim()
        'If cbAdmin.Checked Then
        '    isAdmin = 0
        'Else
        '    isAdmin = 1
        'End If

        '检测是否有没有填写的项,要求全部填写
        If strbookcardid = "" Or strPwd = "" Or strsex = "" Or strPwdConfirm = "" Or strUsername = "" Or strEmail = "" Or strClass = "" Or strStudNO = "" Then
            '这里的检测应该一个个地进行,给出更详细提示信息
            MessageBox.Show("请填写!")
            Exit Sub
        End If

        '检测两次输入的口令是否相等
        If strPwd <> strPwdConfirm Then
            MessageBox.Show("两次输入口令不等!")
            Exit Sub
        End If

        '检测各项是否符合要求,例如长度、格式等。留作作业
        '......

        '输入值完整并可用,插入记录到数据库
        Dim strSource As String = "workstation id=郭洪博;packet size=4096;integrated security=SSPI;initial catalog=books;persist security info=False"
        Dim strInsert As String = "insert into bookcard values('" + strbookcardid + "','" + strPwd + "','" + strUsername + "','" + strsex + "','" + strClass + "','" + strStudNO + "','" + strEmail + "','" + strtelno + "')"

        Dim conn As New SqlConnection(strSource)
        conn.Open()
        Dim cmd As New SqlCommand(strInsert, conn)
        Dim ret As Integer = cmd.ExecuteNonQuery()
        If ret <> 1 Then
            MessageBox.Show("添加失败!")
        Else
            MessageBox.Show("添加成功!")
        End If
        conn.Close()
        clearTb()
    End Sub

    Private Sub bnCancle_Click_1(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles bnCancle.Click
        Me.Close()
    End Sub
End Class

⌨️ 快捷键说明

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