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

📄 zhiwu.vb

📁 人事管理系统,用VB+SQL编译的
💻 VB
字号:
Imports System.Data.SqlClient
Public Class zhiwu
    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 ListBox1 As System.Windows.Forms.ListBox
    Friend WithEvents RadioButton1 As System.Windows.Forms.RadioButton
    Friend WithEvents RadioButton2 As System.Windows.Forms.RadioButton
    Friend WithEvents ListBox2 As System.Windows.Forms.ListBox
    Friend WithEvents Label1 As System.Windows.Forms.Label
    Friend WithEvents TextBox1 As System.Windows.Forms.TextBox
    Friend WithEvents Button1 As System.Windows.Forms.Button
    Friend WithEvents Label2 As System.Windows.Forms.Label
    Friend WithEvents Button2 As System.Windows.Forms.Button
    Friend WithEvents Button3 As System.Windows.Forms.Button
    Friend WithEvents Label3 As System.Windows.Forms.Label
    Friend WithEvents TextBox2 As System.Windows.Forms.TextBox
    <System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()
        Dim resources As System.Resources.ResourceManager = New System.Resources.ResourceManager(GetType(zhiwu))
        Me.ListBox1 = New System.Windows.Forms.ListBox
        Me.RadioButton1 = New System.Windows.Forms.RadioButton
        Me.RadioButton2 = New System.Windows.Forms.RadioButton
        Me.ListBox2 = New System.Windows.Forms.ListBox
        Me.Label1 = New System.Windows.Forms.Label
        Me.TextBox1 = New System.Windows.Forms.TextBox
        Me.Button1 = New System.Windows.Forms.Button
        Me.Label2 = New System.Windows.Forms.Label
        Me.Button2 = New System.Windows.Forms.Button
        Me.Button3 = New System.Windows.Forms.Button
        Me.Label3 = New System.Windows.Forms.Label
        Me.TextBox2 = New System.Windows.Forms.TextBox
        Me.SuspendLayout()
        '
        'ListBox1
        '
        Me.ListBox1.ItemHeight = 12
        Me.ListBox1.Location = New System.Drawing.Point(40, 80)
        Me.ListBox1.Name = "ListBox1"
        Me.ListBox1.Size = New System.Drawing.Size(160, 208)
        Me.ListBox1.TabIndex = 0
        '
        'RadioButton1
        '
        Me.RadioButton1.BackColor = System.Drawing.Color.Transparent
        Me.RadioButton1.Location = New System.Drawing.Point(48, 48)
        Me.RadioButton1.Name = "RadioButton1"
        Me.RadioButton1.Size = New System.Drawing.Size(88, 24)
        Me.RadioButton1.TabIndex = 1
        Me.RadioButton1.Text = "职    务"
        '
        'RadioButton2
        '
        Me.RadioButton2.BackColor = System.Drawing.Color.Transparent
        Me.RadioButton2.Location = New System.Drawing.Point(296, 48)
        Me.RadioButton2.Name = "RadioButton2"
        Me.RadioButton2.Size = New System.Drawing.Size(88, 24)
        Me.RadioButton2.TabIndex = 1
        Me.RadioButton2.Text = "级    别"
        '
        'ListBox2
        '
        Me.ListBox2.ItemHeight = 12
        Me.ListBox2.Location = New System.Drawing.Point(296, 80)
        Me.ListBox2.Name = "ListBox2"
        Me.ListBox2.Size = New System.Drawing.Size(160, 208)
        Me.ListBox2.TabIndex = 0
        '
        'Label1
        '
        Me.Label1.AutoSize = True
        Me.Label1.BackColor = System.Drawing.Color.Transparent
        Me.Label1.Font = New System.Drawing.Font("宋体", 12.0!, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, CType(134, Byte))
        Me.Label1.Location = New System.Drawing.Point(40, 16)
        Me.Label1.Name = "Label1"
        Me.Label1.Size = New System.Drawing.Size(113, 22)
        Me.Label1.TabIndex = 2
        Me.Label1.Text = "请选择添加项:"
        '
        'TextBox1
        '
        Me.TextBox1.Location = New System.Drawing.Point(176, 312)
        Me.TextBox1.Name = "TextBox1"
        Me.TextBox1.Size = New System.Drawing.Size(96, 21)
        Me.TextBox1.TabIndex = 3
        Me.TextBox1.Text = ""
        '
        'Button1
        '
        Me.Button1.BackColor = System.Drawing.Color.Snow
        Me.Button1.Location = New System.Drawing.Point(336, 320)
        Me.Button1.Name = "Button1"
        Me.Button1.TabIndex = 4
        Me.Button1.Text = "确定"
        '
        'Label2
        '
        Me.Label2.AutoSize = True
        Me.Label2.BackColor = System.Drawing.Color.Transparent
        Me.Label2.Location = New System.Drawing.Point(56, 320)
        Me.Label2.Name = "Label2"
        Me.Label2.Size = New System.Drawing.Size(85, 17)
        Me.Label2.TabIndex = 5
        Me.Label2.Text = "输入添加内容:"
        '
        'Button2
        '
        Me.Button2.BackColor = System.Drawing.Color.Snow
        Me.Button2.Location = New System.Drawing.Point(216, 128)
        Me.Button2.Name = "Button2"
        Me.Button2.TabIndex = 4
        Me.Button2.Text = "删除"
        '
        'Button3
        '
        Me.Button3.BackColor = System.Drawing.Color.Snow
        Me.Button3.Location = New System.Drawing.Point(216, 208)
        Me.Button3.Name = "Button3"
        Me.Button3.TabIndex = 4
        Me.Button3.Text = "取消"
        '
        'Label3
        '
        Me.Label3.AutoSize = True
        Me.Label3.BackColor = System.Drawing.Color.Transparent
        Me.Label3.Location = New System.Drawing.Point(56, 360)
        Me.Label3.Name = "Label3"
        Me.Label3.Size = New System.Drawing.Size(85, 17)
        Me.Label3.TabIndex = 5
        Me.Label3.Text = "输入基本工资:"
        '
        'TextBox2
        '
        Me.TextBox2.Location = New System.Drawing.Point(176, 352)
        Me.TextBox2.Name = "TextBox2"
        Me.TextBox2.Size = New System.Drawing.Size(96, 21)
        Me.TextBox2.TabIndex = 3
        Me.TextBox2.Text = ""
        '
        'zhiwu
        '
        Me.AutoScaleBaseSize = New System.Drawing.Size(6, 14)
        Me.BackgroundImage = CType(resources.GetObject("$this.BackgroundImage"), System.Drawing.Image)
        Me.ClientSize = New System.Drawing.Size(512, 389)
        Me.Controls.Add(Me.Label2)
        Me.Controls.Add(Me.Button1)
        Me.Controls.Add(Me.TextBox1)
        Me.Controls.Add(Me.Label1)
        Me.Controls.Add(Me.RadioButton1)
        Me.Controls.Add(Me.ListBox1)
        Me.Controls.Add(Me.RadioButton2)
        Me.Controls.Add(Me.ListBox2)
        Me.Controls.Add(Me.Button2)
        Me.Controls.Add(Me.Button3)
        Me.Controls.Add(Me.Label3)
        Me.Controls.Add(Me.TextBox2)
        Me.Icon = CType(resources.GetObject("$this.Icon"), System.Drawing.Icon)
        Me.MaximizeBox = False
        Me.Name = "zhiwu"
        Me.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen
        Me.Text = "职务、级别"
        Me.ResumeLayout(False)

    End Sub

#End Region
    Dim sql As String
    Private Sub RadioButton1_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles RadioButton1.CheckedChanged
        Me.ListBox2.Items.Clear()
        Me.Label3.Visible = False
        Me.TextBox2.Visible = False
        sql = "select * from zhiwu"
        execsql(sql, "zhiwu")
        Dim i As Integer
        Do While i <= mytable.Rows.Count - 1
            ListBox1.Items.Add(mytable.Rows(i).Item(0))
            i = i + 1
        Loop
        myds.Clear()
        mycon.Close()
    End Sub
    Private Sub RadioButton2_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles RadioButton2.CheckedChanged
        Me.ListBox1.Items.Clear()
        Me.Label3.Visible = True
        Me.TextBox2.Visible = True
        sql = "select * from jibie"
        execsql(sql, "jibie")
        Dim i As Integer
        Do While i <= mytable.Rows.Count - 1
            ListBox2.Items.Add(mytable.Rows(i).Item(0))
            i = i + 1
        Loop
        myds.Clear()
        mycon.Close()
    End Sub
    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        If Me.RadioButton1.Checked = True Then
            sql = "select * from zhiwu order by 序号"
            execsql(sql, "zhiwu")
            Dim i As Integer
            For i = 0 To mytable.Rows.Count - 1
                If Trim(Me.TextBox1.Text) = Trim(mytable.Rows(i).Item(0)) Then
                    MsgBox("职称已经存在")
                    Me.TextBox1.Clear()
                    Exit Sub
                End If
            Next
            Dim myrow1 As DataRow
            myrow1 = myds.Tables("zhiwu").NewRow
            ListBox1.Items.Add(Me.TextBox1.Text)
            myrow1.Item(0) = Me.TextBox1.Text
            myds.Tables("zhiwu").Rows.Add(myrow1)
            mycmb = New SqlCommandBuilder(mydad)
            mydad.Update(myds, "zhiwu")
            myds.Clear()
            mycon.Close()
            MsgBox("添加成功")
            Me.TextBox1.Clear()
        Else
            If Me.TextBox2.Text = "" Then
                MsgBox("未填写完成")
                Me.TextBox2.Clear()
                Me.TextBox2.Focus()
                Exit Sub
            End If
            If Me.TextBox1.Text = "" Then
                MsgBox("未填写完成")
                Me.TextBox1.Clear()
                Me.TextBox1.Focus()
                Exit Sub
            End If
            If Not IsNumeric(TextBox2.Text) Then
                MsgBox("您输入的工资不符,请输入数字")
                TextBox2.Text = ""
                Me.TextBox2.Focus()
                Exit Sub
            End If
            sql = "select * from jibie order by 序号"
            execsql(sql, "jibie")
            Dim i As Integer
            For i = 0 To mytable.Rows.Count - 1
                If Trim(Me.TextBox1.Text) = Trim(mytable.Rows(i).Item(0)) Then
                    MsgBox("职称已经存在")
                    Me.TextBox1.Clear()
                    Exit Sub
                End If
            Next
            Dim myrow1 As DataRow
            myrow1 = myds.Tables("jibie").NewRow
            ListBox2.Items.Add(Me.TextBox1.Text)
            myrow1.Item(0) = Me.TextBox1.Text
            myrow1.Item(1) = Me.TextBox2.Text
            myds.Tables("jibie").Rows.Add(myrow1)
            mycmb = New SqlCommandBuilder(mydad)
            mydad.Update(myds, "jibie")
            myds.Clear()
            mycon.Close()
            MsgBox("添加成功")
            Me.TextBox1.Clear()
            Me.TextBox2.Clear()
        End If
    End Sub
    Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
        If Me.RadioButton1.Checked = True Then
            sql = "select * from zhiwu where 职务='" & Trim(Me.ListBox1.SelectedItem) & "'"
            execsql(sql, "zhiwu")
            Dim i As Integer
            For i = 0 To mytable.Rows.Count - 1
                If Trim(Me.ListBox1.SelectedItem) = Trim(mytable.Rows(i).Item(0)) Then
                    myrow = myds.Tables("zhiwu").Rows(i)
                    myrow.Delete()
                    Me.ListBox1.Items.Remove(Me.ListBox1.SelectedItem)
                    mycmb = New SqlCommandBuilder(mydad)
                    mydad.Update(myds, "zhiwu")
                    MsgBox("删除成功")
                End If
            Next i
        Else
            sql = "select * from jibie  where 级别='" & Trim(Me.ListBox2.SelectedItem) & "'"
            execsql(sql, "jibie")
            Dim i As Integer
            For i = 0 To mytable.Rows.Count - 1
                If Trim(Me.ListBox2.SelectedItem) = Trim(mytable.Rows(i).Item(0)) Then
                    myrow = myds.Tables("jibie").Rows(i)
                    myrow.Delete()
                    Me.ListBox2.Items.Remove(Me.ListBox2.SelectedItem)
                    mycmb = New SqlCommandBuilder(mydad)
                    mydad.Update(myds, "jibie")
                    MsgBox("删除成功")
                End If
            Next i
        End If
    End Sub
    Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click
        Me.Close()
    End Sub
End Class

⌨️ 快捷键说明

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