?? frmduty.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 + -