📄 info.vb
字号:
Imports System.Data
Imports System.Data.SqlClient
Public Class info
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 ToolBar1 As System.Windows.Forms.ToolBar
Friend WithEvents ToolBarButton1 As System.Windows.Forms.ToolBarButton
Friend WithEvents ToolBarButton2 As System.Windows.Forms.ToolBarButton
Friend WithEvents ToolBarButton3 As System.Windows.Forms.ToolBarButton
Friend WithEvents DataGrid1 As System.Windows.Forms.DataGrid
Friend WithEvents ImageList2 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(info))
Me.ToolBar1 = New System.Windows.Forms.ToolBar
Me.ToolBarButton1 = New System.Windows.Forms.ToolBarButton
Me.ToolBarButton2 = New System.Windows.Forms.ToolBarButton
Me.ToolBarButton3 = New System.Windows.Forms.ToolBarButton
Me.ImageList2 = New System.Windows.Forms.ImageList(Me.components)
Me.DataGrid1 = New System.Windows.Forms.DataGrid
CType(Me.DataGrid1, System.ComponentModel.ISupportInitialize).BeginInit()
Me.SuspendLayout()
'
'ToolBar1
'
Me.ToolBar1.Buttons.AddRange(New System.Windows.Forms.ToolBarButton() {Me.ToolBarButton1, Me.ToolBarButton2, Me.ToolBarButton3})
Me.ToolBar1.ButtonSize = New System.Drawing.Size(55, 30)
Me.ToolBar1.DropDownArrows = True
Me.ToolBar1.ImageList = Me.ImageList2
Me.ToolBar1.Location = New System.Drawing.Point(0, 0)
Me.ToolBar1.Name = "ToolBar1"
Me.ToolBar1.ShowToolTips = True
Me.ToolBar1.Size = New System.Drawing.Size(672, 36)
Me.ToolBar1.TabIndex = 0
Me.ToolBar1.TextAlign = System.Windows.Forms.ToolBarTextAlign.Right
'
'ToolBarButton1
'
Me.ToolBarButton1.ImageIndex = 0
Me.ToolBarButton1.Text = "添加"
'
'ToolBarButton2
'
Me.ToolBarButton2.ImageIndex = 2
Me.ToolBarButton2.Text = "修改"
'
'ToolBarButton3
'
Me.ToolBarButton3.ImageIndex = 1
Me.ToolBarButton3.Text = "删除"
'
'ImageList2
'
Me.ImageList2.ImageSize = New System.Drawing.Size(16, 16)
Me.ImageList2.ImageStream = CType(resources.GetObject("ImageList2.ImageStream"), System.Windows.Forms.ImageListStreamer)
Me.ImageList2.TransparentColor = System.Drawing.Color.Green
'
'DataGrid1
'
Me.DataGrid1.BackgroundColor = System.Drawing.SystemColors.ControlDark
Me.DataGrid1.DataMember = ""
Me.DataGrid1.HeaderForeColor = System.Drawing.SystemColors.ControlText
Me.DataGrid1.LinkColor = System.Drawing.SystemColors.ControlLightLight
Me.DataGrid1.Location = New System.Drawing.Point(0, 40)
Me.DataGrid1.Name = "DataGrid1"
Me.DataGrid1.ParentRowsForeColor = System.Drawing.SystemColors.HighlightText
Me.DataGrid1.Size = New System.Drawing.Size(672, 400)
Me.DataGrid1.TabIndex = 1
'
'info
'
Me.AutoScaleBaseSize = New System.Drawing.Size(6, 14)
Me.ClientSize = New System.Drawing.Size(672, 437)
Me.Controls.Add(Me.DataGrid1)
Me.Controls.Add(Me.ToolBar1)
Me.Name = "info"
Me.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen
Me.Text = "基本信息"
CType(Me.DataGrid1, System.ComponentModel.ISupportInitialize).EndInit()
Me.ResumeLayout(False)
End Sub
#End Region
Private Sub info_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
myds.Clear()
Dim strsql As String
strsql = "select * from useinfo"
If Not execsql(strsql, "useinfo") Then
Exit Sub
Else
DataGrid1.DataSource = myds.Tables("useinfo")
End If
End Sub
Private Sub ToolBar1_ButtonClick(ByVal sender As System.Object, ByVal e As System.Windows.Forms.ToolBarButtonClickEventArgs) Handles ToolBar1.ButtonClick
Select Case Me.ToolBar1.Buttons.IndexOf(e.Button)
Case 0
Dim f2 As New infoadd
f2.MdiParent = f
f2.Show()
Case 1
Dim f2 As New infoupdate
f2.MdiParent = f
f2.Show()
Case 2
Dim sqlstr As String
t = Trim(myds.Tables("useinfo").Rows(Me.BindingContext(myds.Tables("useinfo")).Position).Item(0))
sqlstr = "select * from useinfo where 员工编号 ='" & t & "'"
If execsql(sqlstr, "useinfo") Then
Dim i As Integer
For i = 0 To mytable.Rows.Count - 1
If Trim(t) = Trim(mytable.Rows(i).Item(0)) Then
myrow = myds.Tables("useinfo").Rows(i)
myrow.Delete()
mycmb = New SqlCommandBuilder(mydad)
mydad.Update(myds, "useinfo")
Try
myds.Clear()
mycon.Close()
Dim j As Integer
Dim sqlstr1 As String
sqlstr1 = "select * from userid where 帐号 ='" & t & "'"
If execsql(sqlstr1, "userid") Then
For j = 0 To mytable.Rows.Count - 1
If Trim(t) = Trim(mytable.Rows(j).Item(0)) Then
myrow = myds.Tables("userid").Rows(j)
myrow.Delete()
mycmb = New SqlCommandBuilder(mydad)
mydad.Update(myds, "userid")
MsgBox("删除成功")
Dim strsql As String
strsql = "select * from useinfo"
If Not execsql(strsql, "useinfo") Then
Exit Sub
Else
Dim a As New info
a.DataGrid1.DataSource = myds.Tables("useinfo")
End If
Exit Sub
End If
Next
End If
Catch ex As Exception
MsgBox("删除不成功")
End Try
Exit Sub
End If
Next
End If
End Select
End Sub
Private Sub DataGrid1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles DataGrid1.Click
t = Trim(myds.Tables("useinfo").Rows(Me.BindingContext(myds.Tables("useinfo")).Position).Item(0))
'MsgBox(Me.BindingContext(myds.Tables("useinfo")).Position)
End Sub
Private Sub DataGrid1_BindingContextChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles DataGrid1.BindingContextChanged
't = Trim(myds.Tables("useinfo").Rows(Me.BindingContext(myds.Tables("useinfo")).Position).Item(0))
End Sub
Private Sub DataGrid1_Navigate(ByVal sender As System.Object, ByVal ne As System.Windows.Forms.NavigateEventArgs) Handles DataGrid1.Navigate
End Sub
End Class
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -