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

📄 frmduty.vb

📁 师生情况管理系统
💻 VB
字号:
'************************************************************
'Copyright(c) 2007 长沙南方职业学院 信息系 软件2-061班
'All rights reserved
'
'程序名称:学校基本信息管理系统
'
'作者(原):易湘陵
'完成日期:2007-11-14
'作者(改):
'修改日期:
'************************************************************
Public Class FrmDuty
    Inherits System.Windows.Forms.Form

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

    Public Sub New(ByVal l As Boolean, ByVal sql As String)
        MyBase.New()

        '该调用是 Windows 窗体设计器所必需的。
        InitializeComponent()
        MyDoubleClickClose = l
        SqlStr = sql
        LoadDuty()
        '在 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 BtnClose As System.Windows.Forms.Button
    Friend WithEvents ToolBarBtnAdd As System.Windows.Forms.ToolBarButton
    Friend WithEvents ToolBarBtnEdit As System.Windows.Forms.ToolBarButton
    Friend WithEvents ToolBarBtnDel As System.Windows.Forms.ToolBarButton
    Friend WithEvents ToolBarDuty As System.Windows.Forms.ToolBar
    Friend WithEvents GroupBoxDutyList As System.Windows.Forms.GroupBox
    Friend WithEvents DgDutyList As System.Windows.Forms.DataGrid
    Friend WithEvents ImageListTool As System.Windows.Forms.ImageList
    <System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()
        Me.components = New System.ComponentModel.Container
        Dim resources As System.Resources.ResourceManager = New System.Resources.ResourceManager(GetType(FrmDuty))
        Me.BtnClose = New System.Windows.Forms.Button
        Me.ToolBarDuty = New System.Windows.Forms.ToolBar
        Me.ToolBarBtnAdd = New System.Windows.Forms.ToolBarButton
        Me.ToolBarBtnEdit = New System.Windows.Forms.ToolBarButton
        Me.ToolBarBtnDel = New System.Windows.Forms.ToolBarButton
        Me.ImageListTool = New System.Windows.Forms.ImageList(Me.components)
        Me.GroupBoxDutyList = New System.Windows.Forms.GroupBox
        Me.DgDutyList = New System.Windows.Forms.DataGrid
        Me.GroupBoxDutyList.SuspendLayout()
        CType(Me.DgDutyList, System.ComponentModel.ISupportInitialize).BeginInit()
        Me.SuspendLayout()
        '
        'BtnClose
        '
        Me.BtnClose.Location = New System.Drawing.Point(224, 320)
        Me.BtnClose.Name = "BtnClose"
        Me.BtnClose.TabIndex = 6
        Me.BtnClose.Text = "关闭"
        '
        'ToolBarDuty
        '
        Me.ToolBarDuty.Buttons.AddRange(New System.Windows.Forms.ToolBarButton() {Me.ToolBarBtnAdd, Me.ToolBarBtnEdit, Me.ToolBarBtnDel})
        Me.ToolBarDuty.DropDownArrows = True
        Me.ToolBarDuty.ImageList = Me.ImageListTool
        Me.ToolBarDuty.Location = New System.Drawing.Point(0, 0)
        Me.ToolBarDuty.Name = "ToolBarDuty"
        Me.ToolBarDuty.ShowToolTips = True
        Me.ToolBarDuty.Size = New System.Drawing.Size(314, 28)
        Me.ToolBarDuty.TabIndex = 5
        '
        'ToolBarBtnAdd
        '
        Me.ToolBarBtnAdd.ImageIndex = 0
        Me.ToolBarBtnAdd.ToolTipText = "添加"
        '
        'ToolBarBtnEdit
        '
        Me.ToolBarBtnEdit.ImageIndex = 2
        Me.ToolBarBtnEdit.ToolTipText = "修改"
        '
        'ToolBarBtnDel
        '
        Me.ToolBarBtnDel.ImageIndex = 1
        Me.ToolBarBtnDel.ToolTipText = "删除"
        '
        'ImageListTool
        '
        Me.ImageListTool.ColorDepth = System.Windows.Forms.ColorDepth.Depth16Bit
        Me.ImageListTool.ImageSize = New System.Drawing.Size(16, 16)
        Me.ImageListTool.ImageStream = CType(resources.GetObject("ImageListTool.ImageStream"), System.Windows.Forms.ImageListStreamer)
        Me.ImageListTool.TransparentColor = System.Drawing.Color.Transparent
        '
        'GroupBoxDutyList
        '
        Me.GroupBoxDutyList.Controls.Add(Me.DgDutyList)
        Me.GroupBoxDutyList.Location = New System.Drawing.Point(8, 32)
        Me.GroupBoxDutyList.Name = "GroupBoxDutyList"
        Me.GroupBoxDutyList.Size = New System.Drawing.Size(296, 280)
        Me.GroupBoxDutyList.TabIndex = 4
        Me.GroupBoxDutyList.TabStop = False
        Me.GroupBoxDutyList.Text = "职务列表"
        '
        'DgDutyList
        '
        Me.DgDutyList.AllowSorting = False
        Me.DgDutyList.CaptionVisible = False
        Me.DgDutyList.DataMember = ""
        Me.DgDutyList.HeaderForeColor = System.Drawing.SystemColors.ControlText
        Me.DgDutyList.Location = New System.Drawing.Point(8, 16)
        Me.DgDutyList.Name = "DgDutyList"
        Me.DgDutyList.ReadOnly = True
        Me.DgDutyList.RowHeadersVisible = False
        Me.DgDutyList.Size = New System.Drawing.Size(280, 256)
        Me.DgDutyList.TabIndex = 0
        '
        'FrmDuty
        '
        Me.AcceptButton = Me.BtnClose
        Me.AutoScaleBaseSize = New System.Drawing.Size(6, 14)
        Me.ClientSize = New System.Drawing.Size(314, 354)
        Me.Controls.Add(Me.BtnClose)
        Me.Controls.Add(Me.ToolBarDuty)
        Me.Controls.Add(Me.GroupBoxDutyList)
        Me.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedToolWindow
        Me.Icon = CType(resources.GetObject("$this.Icon"), System.Drawing.Icon)
        Me.Name = "FrmDuty"
        Me.Text = "职务列表"
        Me.GroupBoxDutyList.ResumeLayout(False)
        CType(Me.DgDutyList, System.ComponentModel.ISupportInitialize).EndInit()
        Me.ResumeLayout(False)

    End Sub

#End Region


    Private Sub LoadDuty()
        Dim Con As SqlClient.SqlConnection
        Try
            dsDuty.Clear()
            Con = New SqlClient.SqlConnection(FrmMain.DBCONN.DataConStr)
            Con.Open()
            daDuty = New SqlClient.SqlDataAdapter(SqlStr, Con)
            daDuty.Fill(dsDuty, "info")

            Dim MyCommandBuilder As New SqlClient.SqlCommandBuilder(daDuty)
            DgDutyList.SetDataBinding(dsDuty, "info")
        Catch ex As Exception
            MsgBox(ex.Message)
        Finally
            Con.Close()
        End Try
    End Sub

    Public DutyID As String = ""
    Private MyDoubleClickClose As Boolean = False
    Public dsDuty As New DataSet
    Private daDuty As SqlClient.SqlDataAdapter
    Private SqlStr As String = ""

    Private Sub BtnClose_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BtnClose.Click
        If MyDoubleClickClose Then
            DutyID = dsDuty.Tables(0).Rows(DgDutyList.CurrentCell.RowNumber).Item(0)
        End If
        Me.Close()
    End Sub

    Private Sub FrmDuty_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        LoadDuty()
        If MyDoubleClickClose Then
            BtnClose.Text = "选择"
        End If
    End Sub

    Private Sub ToolBarDuty_ButtonClick(ByVal sender As System.Object, ByVal e As System.Windows.Forms.ToolBarButtonClickEventArgs) Handles ToolBarDuty.ButtonClick

        If e.Button Is Me.ToolBarBtnAdd Then
            Dim FrmDutyAdd As New FrmAdd_Edit
            FrmDutyAdd.ShowDialog()
            If FrmDutyAdd.SaveZT Then
                Try
                    Dim MyRow As DataRow = dsDuty.Tables(0).NewRow()
                    MyRow(0) = FrmDutyAdd.ShareID
                    MyRow(1) = FrmDutyAdd.ShareName
                    dsDuty.Tables(0).Rows.Add(MyRow)
                    daDuty.Update(dsDuty, "info")
                Catch ex As Exception
                    MsgBox("添加失败!" & vbCrLf & ex.Message, 64, "失败")
                End Try
            End If
            FrmDutyAdd = Nothing
        End If

        If e.Button Is Me.ToolBarBtnDel Then
            If DgDutyList.CurrentCell.RowNumber > 0 Then
                If MsgBox("你真的要删除当前所选的这一行数据吗?", 64 + 4, "删除") = 6 Then
                    Try
                        dsDuty.Tables(0).Rows(DgDutyList.CurrentCell.RowNumber).Delete()
                        daDuty.Update(dsDuty, "info")
                    Catch ex As Exception
                        MsgBox("删除失败!" & vbCrLf & ex.Message, 64, "失败")
                    End Try
                End If
            End If
        End If

        If e.Button Is Me.ToolBarBtnEdit Then
            Dim FrmDutyEdit As New FrmAdd_Edit(dsDuty.Tables(0).Rows(DgDutyList.CurrentCell.RowNumber).Item(0), dsDuty.Tables(0).Rows(DgDutyList.CurrentCell.RowNumber).Item(1))
            FrmDutyEdit.ShowDialog()
            If FrmDutyEdit.SaveZT Then
                Try
                    dsDuty.Tables(0).Rows(DgDutyList.CurrentCell.RowNumber).Item(0) = FrmDutyEdit.ShareID
                    dsDuty.Tables(0).Rows(DgDutyList.CurrentCell.RowNumber).Item(1) = FrmDutyEdit.ShareName
                    daDuty.Update(dsDuty, "info")
                Catch ex As Exception
                    MsgBox("修改失败!" & vbCrLf & ex.Message, 64, "失败")
                End Try
            End If
            FrmDutyEdit = Nothing
        End If
    End Sub
End Class

⌨️ 快捷键说明

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