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

📄 salary.vb

📁 这是一个基于.NET平台
💻 VB
📖 第 1 页 / 共 3 页
字号:
    End Sub

    Private Sub Button5_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button5.Click

        If ComboBox1.Text = "请选择查询方式" Then
            MsgBox("请选择查询方式!")
        End If

        If ComboBox1.Text = "按员工编号" Then
            ds.Clear()
            If TextBox7.Text = "" Then
                MsgBox("请输入员工编号!")
            Else
                'ds.Clear()

                'Dim tablename As String
                'tablename = "salary"  '表的名称
                'Dim SearchSQL As String
                SearchSQL = "select biid 员工编号,samon 月份,sabs 基本工资,sajob 岗位工资,saw 奖金津贴,sasa 实发工资,saac 银行帐号,safine 罚金,saco 出勤天数,sasick 病假天数,sathing 事假天数,saabsent 旷工天数 from salary  where biid='" & TextBox7.Text & " '"
                Try
                    Try
                        Dim ADOcmd As SqlDataAdapter
                        ADOcmd = New SqlDataAdapter(SearchSQL, strCon)
                        '建立DataSet对象 
                        'Dim ds As DataSet = New DataSet '建立ADODataSetCommand对象

                        'Dim mytable As DataTable
                        Dim rownumber As Integer '定义一个整型变量来存放当前行数

                        '建立表单对象


                        '建立ADODataSetCommand对象
                        ADOcmd.Fill(ds, tablename) '取得表单
                        mytable = ds.Tables.Item(0) '取得名为table的表

                        DataGrid1.DataSource = mytable
                    Catch
                        'MsgBox("没有该员工!")
                    End Try

                    str2() '调用函数
                    'End If
                Catch
                    MsgBox("没有该员工!", vbOKOnly + vbExclamation, "警告")
                End Try
            End If
        End If

        If ComboBox1.SelectedIndex = 1 Then
            ds.Clear()

            If TextBox7.Text = "" Then
                MsgBox("请输入银行帐号 !")
            Else
                'ds.Clear()

                'Dim tablename As String
                'tablename = "salary"  '表的名称
                'Dim SearchSQL As String
                SearchSQL = "select biid 员工编号,samon 月份,sabs 基本工资,sajob 岗位工资,saw 奖金津贴,sasa 实发工资,saac 银行帐号,safine 罚金,saco 出勤天数,sasick 病假天数,sathing 事假天数,saabsent 旷工天数 from salary  where saac='" & TextBox7.Text.ToString & " '"
                Try
                    Try
                        Dim ADOcmd As SqlDataAdapter
                        ADOcmd = New SqlDataAdapter(SearchSQL, strCon)
                        '建立DataSet对象 
                        'Dim ds As DataSet = New DataSet '建立ADODataSetCommand对象

                        'Dim mytable As DataTable
                        Dim rownumber As Integer '定义一个整型变量来存放当前行数

                        '建立表单对象


                        '建立ADODataSetCommand对象
                        ADOcmd.Fill(ds, tablename) '取得表单
                        mytable = ds.Tables.Item(0) '取得名为table的表

                        DataGrid1.DataSource = mytable
                    Catch
                        'MsgBox("没有该员工!")
                    End Try
                    str2() '调用函数
                    'End If
                Catch
                    MsgBox("没有该员工!", vbOKOnly + vbExclamation, "警告")
                End Try
            End If
        End If

    End Sub

    Private Sub Button8_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button8.Click
        Dim strCon As String
        strCon = "Server=(local); Database=mydb; User Id=sa; Password=;"
        Dim Conn As New SqlConnection(strCon)
        If TextBox1.Text = "" Then
            MsgBox("请输入员工编号!")
        Else

            Dim strSql As String = "insert into salary values('" & TextBox1.Text & "','" & TextBox2.Text & "','" & TextBox9.Text & "','" & TextBox6.Text & "','" & TextBox3.Text & "','" & TextBox8.Text & "','" & TextBox5.Text & "','" & TextBox10.Text & "','" & TextBox12.Text & "','" & TextBox13.Text & "','" & TextBox14.Text & "','" & TextBox11.Text & "')"
            Dim Cmd As New SqlCommand(strSql, Conn)
            Dim dtAdapter As New SqlDataAdapter
            dtAdapter.SelectCommand = Cmd
            Dim dsResult As New DataSet
            Conn.Open()

            dtAdapter.Fill(dsResult)
            Conn.Close()
            MsgBox("数据增加成功!", MsgBoxStyle.Information + MsgBoxStyle.OKOnly, "系统提示")
            'DataGrid1.DataSource = dsResult.Tables(1)
        End If
    End Sub
   
    Private Sub ComboBox1_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ComboBox1.SelectedIndexChanged
        If ComboBox1.Text = "按员工编号" Then
            Label15.Text = "请输入员工编号"
            TextBox7.Focus()
        End If
        If ComboBox1.Text = "按银行账号" Then
            Label15.Text = "请输入银行账号"
            TextBox7.Focus()
        End If
    End Sub
    Private Sub Button9_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button9.Click
        If TextBox1.Text = "" Then
            MsgBox("请输入员工编号!")
        Else
            Dim strCon As String
            strCon = "Server=(local); Database=mydb; User Id=sa; Password=;"
            Dim Conn As New SqlConnection(strCon)
            Dim strSql As String = "update salary set samon='" & TextBox2.Text & "',sabs='" & TextBox9.Text & "',sajob='" & TextBox6.Text & "',saw='" & TextBox3.Text & "',sasa='" & TextBox8.Text & "',saac='" & TextBox5.Text & "',safine='" & TextBox10.Text & "',saco='" & TextBox12.Text & "',sasick='" & TextBox13.Text & "',sathing='" & TextBox14.Text & "',saabsent='" & TextBox11.Text & "' where biid='" & TextBox1.Text & "' "
            Dim Cmd As New SqlCommand(strSql, Conn)
            Dim dtAdapter As New SqlDataAdapter
            dtAdapter.SelectCommand = Cmd
            Dim dsResult As New DataSet
            Conn.Open()
            dtAdapter.Fill(dsResult)
            Conn.Close()
            MsgBox("信息修改成功!", MsgBoxStyle.Information + MsgBoxStyle.OKOnly, "系统提示")
        End If

    End Sub
    Private Sub Button10_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button10.Click
        If TextBox1.Text = "" Then
            MsgBox("请输入员工编号!")
        Else
            Dim strCon As String
            strCon = "Server=(local); Database=mydb; User Id=sa; Password=;"
            Dim Conn As New SqlConnection(strCon)
            Dim strSql As String = "delete from salary where biid= '" & TextBox1.Text & "'"
            Dim Cmd As New SqlCommand(strSql, Conn)
            Dim dtAdapter As New SqlDataAdapter
            dtAdapter.SelectCommand = Cmd

            Dim dsResult As New DataSet
            Conn.Open()
            dtAdapter.Fill(dsResult)
            Conn.Close()
            MsgBox("信息删除成功!", MsgBoxStyle.Information + MsgBoxStyle.OKOnly, "系统提示")

        End If
    End Sub
    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        str6()
        str2()
        DataGrid1.DataSource = ds.Tables(0)
    End Sub
    Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
        str6()
        str3()
        'ds.Clear()
        DataGrid1.DataSource = ds.Tables(0)
    End Sub
    Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click
        str6()
        str4()
        DataGrid1.DataSource = ds.Tables(0)
    End Sub
    Private Sub Button4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button4.Click
        str6()
        i = ds.Tables(0).Rows.Count - 1
        str5()
        DataGrid1.DataSource = ds.Tables(0)
    End Sub

    Private Sub str()
        TextBox1.Text = ""
        TextBox2.Text = ""
        TextBox3.Text = ""
        TextBox5.Text = ""
        TextBox6.Text = ""
        TextBox7.Text = ""
        TextBox8.Text = ""
        TextBox9.Text = ""
        TextBox10.Text = ""
        TextBox11.Text = ""
        TextBox12.Text = ""
        TextBox13.Text = ""
        TextBox14.Text = ""
        Label15.Text = ""
        ComboBox1.Text = "请选择查询方式"
        ds.Clear()
    End Sub

    Private Sub str2()
        TextBox1.Text = ds.Tables(0).Rows(0).Item(0)
        TextBox2.Text = ds.Tables(0).Rows(0).Item(1)
        TextBox9.Text = ds.Tables(0).Rows(0).Item(2)
        TextBox6.Text = ds.Tables(0).Rows(0).Item(3)
        TextBox3.Text = ds.Tables(0).Rows(0).Item(4)
        TextBox8.Text = ds.Tables(0).Rows(0).Item(5)
        TextBox5.Text = ds.Tables(0).Rows(0).Item(6)
        TextBox10.Text = ds.Tables(0).Rows(0).Item(7)
        TextBox12.Text = ds.Tables(0).Rows(0).Item(8)
        TextBox13.Text = ds.Tables(0).Rows(0).Item(9)
        TextBox14.Text = ds.Tables(0).Rows(0).Item(10)
        TextBox11.Text = ds.Tables(0).Rows(0).Item(11)
    End Sub
    Private Sub str3()
        i = i - 1
        If i < 0 Then i = i + ds.Tables(0).Rows.Count
        str5()
    End Sub
    Private Sub str4()
        i = i + 1
        If i >= ds.Tables(0).Rows.Count Then i = i - ds.Tables(0).Rows.Count
        str5()

    End Sub
    Private Sub str5()
        TextBox1.Text = ds.Tables(0).Rows(i).Item(0)
        TextBox2.Text = ds.Tables(0).Rows(i).Item(1)
        TextBox9.Text = ds.Tables(0).Rows(i).Item(2)
        TextBox6.Text = ds.Tables(0).Rows(i).Item(3)
        TextBox3.Text = ds.Tables(0).Rows(i).Item(4)
        TextBox8.Text = ds.Tables(0).Rows(i).Item(5)
        TextBox5.Text = ds.Tables(0).Rows(i).Item(6)
        TextBox10.Text = ds.Tables(0).Rows(i).Item(7)
        TextBox12.Text = ds.Tables(0).Rows(i).Item(8)
        TextBox13.Text = ds.Tables(0).Rows(i).Item(9)
        TextBox14.Text = ds.Tables(0).Rows(i).Item(10)
        TextBox11.Text = ds.Tables(0).Rows(i).Item(11)
    End Sub
    Private Sub str6()
        ds.Clear()
        Dim strCon As String
        strCon = "Server=(local); Database=mydb; User Id=sa; Password=;"
        Dim Conn As New SqlConnection(strCon)
        SearchSQL = "select biid 员工编号,samon 月份,sabs 基本工资,sajob 岗位工资,saw 奖金津贴,sasa 实发工资,saac 银行帐号,safine 罚金,saco 出勤天数,sasick 病假天数,sathing 事假天数,saabsent 旷工天数 from salary"
        Dim Cmd As New SqlCommand(SearchSQL, Conn)

        Dim dtAdapter As New SqlDataAdapter
        dtAdapter.SelectCommand = Cmd
        Conn.Open()
        dtAdapter.Fill(ds)
        Conn.Close()
    End Sub
End Class

⌨️ 快捷键说明

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