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

📄 adduser.vb

📁 固定资产管理信息系统,虽然还有些不足,但基本功能已实现!希望大家多多改进!
💻 VB
字号:
Imports System.Data
Imports System.Data.sqlClient

Public Class AddUser
    Inherits System.Windows.Forms.Form

    'Dim UserDataSet As DataSet = New DataSet
    'Dim UserDataAdapter As New SqlDataAdapter
    ' Dim conn As New SqlConnection
    'Dim assentTable As DataTable
    ' Dim adduser As DataRow

    'Dim UNAME As String
    'Dim UPWD As String
    'Dim UTYPE As Integer


#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 Label1 As System.Windows.Forms.Label
    Friend WithEvents Label2 As System.Windows.Forms.Label
    Friend WithEvents Label3 As System.Windows.Forms.Label
    Friend WithEvents Label4 As System.Windows.Forms.Label
    Friend WithEvents TextBox1 As System.Windows.Forms.TextBox
    Friend WithEvents TextBox2 As System.Windows.Forms.TextBox
    Friend WithEvents Button1 As System.Windows.Forms.Button
    Friend WithEvents Button2 As System.Windows.Forms.Button
    Friend WithEvents Button3 As System.Windows.Forms.Button
    Friend WithEvents ComboBox1 As System.Windows.Forms.ComboBox
    <System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()
        Me.Label1 = New System.Windows.Forms.Label
        Me.Label2 = New System.Windows.Forms.Label
        Me.Label3 = New System.Windows.Forms.Label
        Me.Label4 = New System.Windows.Forms.Label
        Me.TextBox1 = New System.Windows.Forms.TextBox
        Me.TextBox2 = New System.Windows.Forms.TextBox
        Me.Button1 = New System.Windows.Forms.Button
        Me.Button2 = New System.Windows.Forms.Button
        Me.Button3 = New System.Windows.Forms.Button
        Me.ComboBox1 = New System.Windows.Forms.ComboBox
        Me.SuspendLayout()
        '
        'Label1
        '
        Me.Label1.Font = New System.Drawing.Font("宋体", 14.25!, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, CType(134, Byte))
        Me.Label1.Location = New System.Drawing.Point(160, 40)
        Me.Label1.Name = "Label1"
        Me.Label1.Size = New System.Drawing.Size(96, 24)
        Me.Label1.TabIndex = 0
        Me.Label1.Text = "添加用户"
        '
        'Label2
        '
        Me.Label2.Location = New System.Drawing.Point(96, 88)
        Me.Label2.Name = "Label2"
        Me.Label2.Size = New System.Drawing.Size(96, 23)
        Me.Label2.TabIndex = 1
        Me.Label2.Text = "用户名:"
        '
        'Label3
        '
        Me.Label3.Location = New System.Drawing.Point(96, 128)
        Me.Label3.Name = "Label3"
        Me.Label3.Size = New System.Drawing.Size(88, 23)
        Me.Label3.TabIndex = 2
        Me.Label3.Text = "密 码:"
        '
        'Label4
        '
        Me.Label4.Location = New System.Drawing.Point(96, 168)
        Me.Label4.Name = "Label4"
        Me.Label4.Size = New System.Drawing.Size(88, 23)
        Me.Label4.TabIndex = 3
        Me.Label4.Text = "用户类型:"
        '
        'TextBox1
        '
        Me.TextBox1.Location = New System.Drawing.Point(216, 88)
        Me.TextBox1.Name = "TextBox1"
        Me.TextBox1.TabIndex = 4
        Me.TextBox1.Text = ""
        '
        'TextBox2
        '
        Me.TextBox2.Location = New System.Drawing.Point(216, 128)
        Me.TextBox2.Name = "TextBox2"
        Me.TextBox2.TabIndex = 5
        Me.TextBox2.Text = ""
        '
        'Button1
        '
        Me.Button1.Enabled = False
        Me.Button1.Location = New System.Drawing.Point(88, 216)
        Me.Button1.Name = "Button1"
        Me.Button1.Size = New System.Drawing.Size(48, 23)
        Me.Button1.TabIndex = 7
        Me.Button1.Text = "确定"
        '
        'Button2
        '
        Me.Button2.Enabled = False
        Me.Button2.Location = New System.Drawing.Point(192, 216)
        Me.Button2.Name = "Button2"
        Me.Button2.Size = New System.Drawing.Size(48, 23)
        Me.Button2.TabIndex = 8
        Me.Button2.Text = "取消"
        '
        'Button3
        '
        Me.Button3.Location = New System.Drawing.Point(280, 216)
        Me.Button3.Name = "Button3"
        Me.Button3.Size = New System.Drawing.Size(48, 23)
        Me.Button3.TabIndex = 9
        Me.Button3.Text = "关闭"
        '
        'ComboBox1
        '
        Me.ComboBox1.Items.AddRange(New Object() {"普通用户", "操作员", "审核员"})
        Me.ComboBox1.Location = New System.Drawing.Point(216, 168)
        Me.ComboBox1.Name = "ComboBox1"
        Me.ComboBox1.Size = New System.Drawing.Size(104, 20)
        Me.ComboBox1.TabIndex = 10
        Me.ComboBox1.Text = "普通用户"
        '
        'AddUser
        '
        Me.AutoScaleBaseSize = New System.Drawing.Size(6, 14)
        Me.ClientSize = New System.Drawing.Size(408, 262)
        Me.Controls.Add(Me.ComboBox1)
        Me.Controls.Add(Me.Button3)
        Me.Controls.Add(Me.Button2)
        Me.Controls.Add(Me.Button1)
        Me.Controls.Add(Me.TextBox2)
        Me.Controls.Add(Me.TextBox1)
        Me.Controls.Add(Me.Label4)
        Me.Controls.Add(Me.Label3)
        Me.Controls.Add(Me.Label2)
        Me.Controls.Add(Me.Label1)
        Me.MaximizeBox = False
        Me.Name = "AddUser"
        Me.Text = "-------------添加用户"
        Me.ResumeLayout(False)

    End Sub

#End Region

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


    End Sub

    Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
        TextBox1.Clear()
        TextBox2.Clear()
    End Sub

    Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click
        Me.Visible = False
    End Sub

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
 
        If TextBox1.Text <> "" And TextBox2.Text <> "" Then

            ' Try
            myConnStr = connstr()
            myConnetion = New SqlConnection(myConnStr)
            myConnetion.Open()

            myCommand = New SqlCommand("PR_T_USER", myConnetion)
            myCommand.CommandType = CommandType.StoredProcedure

            Dim myparameter As SqlParameter

            myparameter = myCommand.Parameters.Add("@UNAME", SqlDbType.VarChar, 10)
            myparameter.Direction = ParameterDirection.Input
            myparameter.Value = TextBox1.Text.Trim()

            myparameter = myCommand.Parameters.Add("@UPWD", SqlDbType.VarChar, 6)
            myparameter.Direction = ParameterDirection.Input
            myparameter.Value = TextBox2.Text.Trim()

            Dim a As Integer
            a = CInt(ComboBox1.SelectedIndex)
            MsgBox(a)
            Select Case a

                Case 0
                    myparameter = myCommand.Parameters.Add("@UTYPE", SqlDbType.SmallInt)
                    myparameter.Direction = ParameterDirection.Input
                    myparameter.Value = 1

                Case 1
                    myparameter = myCommand.Parameters.Add("@UTYPE", SqlDbType.SmallInt)
                    myparameter.Direction = ParameterDirection.Input
                    myparameter.Value = 2

                Case 2
                    myparameter = myCommand.Parameters.Add("@UTYPE", SqlDbType.SmallInt)
                    myparameter.Direction = ParameterDirection.Input
                    myparameter.Value = 3


            End Select

            'myDataAdapter.SelectCommand = myCommand

            Dim i As Integer

            'i = 
            myCommand.ExecuteNonQuery()
            ' MsgBox("i is :" & i)
            myConnetion.Close()

            MsgBox("用户添加成功!!!")

            TextBox1.Clear()
            TextBox2.Clear()
            ' Catch ex As Exception
            ' MsgBox("用户添加失败。。。。")
            ' End Try

        Else
            MsgBox("用户名和密码不和为空")
        End If


    End Sub


    Private Sub ComboBox1_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ComboBox1.SelectedIndexChanged
        ' ComboBox1.Items.Item(0) = 1
        ' ComboBox1.Items.Item(1) = 2
        ' ComboBox1.Items.Item(2) = 3
    End Sub

    Private Sub TextBox1_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TextBox1.TextChanged

        If TextBox1.Text.Length <> 0 Or TextBox2.Text.Length <> 0 Then
            Me.Button2.Enabled = True
        Else
            Me.Button2.Enabled = False
        End If

        If TextBox1.Text.Length <> 0 And TextBox2.Text.Length <> 0 Then
            Me.Button1.Enabled = True
        Else
            Me.Button1.Enabled = False
        End If

    End Sub

    Private Sub TextBox2_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TextBox2.TextChanged

        If TextBox1.Text.Length <> 0 Or TextBox2.Text.Length <> 0 Then
            Me.Button2.Enabled = True
        Else
            Me.Button2.Enabled = False
        End If

        If TextBox1.Text.Length <> 0 And TextBox2.Text.Length <> 0 Then
            Me.Button1.Enabled = True
        Else
            Me.Button1.Enabled = False
        End If

    End Sub
End Class

⌨️ 快捷键说明

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