?? frmdzwh.vb
字號:
'ComboBox3
'
Me.ComboBox3.Enabled = False
Me.ComboBox3.Items.AddRange(New Object() {"3本", "5本", "10本", "20本", "50本"})
Me.ComboBox3.Location = New System.Drawing.Point(352, 104)
Me.ComboBox3.Name = "ComboBox3"
Me.ComboBox3.Size = New System.Drawing.Size(136, 20)
Me.ComboBox3.TabIndex = 24
'
'Label10
'
Me.Label10.Location = New System.Drawing.Point(264, 104)
Me.Label10.Name = "Label10"
Me.Label10.Size = New System.Drawing.Size(120, 24)
Me.Label10.TabIndex = 23
Me.Label10.Text = "可借書數(shù):"
'
'ComboBox2
'
Me.ComboBox2.Enabled = False
Me.ComboBox2.Items.AddRange(New Object() {"學(xué)生", "教師", "教授", "博士", "博士后"})
Me.ComboBox2.Location = New System.Drawing.Point(352, 64)
Me.ComboBox2.Name = "ComboBox2"
Me.ComboBox2.Size = New System.Drawing.Size(136, 20)
Me.ComboBox2.TabIndex = 22
'
'Label9
'
Me.Label9.Location = New System.Drawing.Point(264, 64)
Me.Label9.Name = "Label9"
Me.Label9.Size = New System.Drawing.Size(120, 24)
Me.Label9.TabIndex = 21
Me.Label9.Text = "讀者類別:"
'
'TextBox5
'
Me.TextBox5.Enabled = False
Me.TextBox5.Location = New System.Drawing.Point(352, 24)
Me.TextBox5.Name = "TextBox5"
Me.TextBox5.Size = New System.Drawing.Size(136, 21)
Me.TextBox5.TabIndex = 20
Me.TextBox5.Text = ""
'
'Label8
'
Me.Label8.Location = New System.Drawing.Point(264, 24)
Me.Label8.Name = "Label8"
Me.Label8.Size = New System.Drawing.Size(120, 24)
Me.Label8.TabIndex = 19
Me.Label8.Text = "學(xué) 號:"
'
'ComboBox1
'
Me.ComboBox1.Enabled = False
Me.ComboBox1.Items.AddRange(New Object() {"男", "女"})
Me.ComboBox1.Location = New System.Drawing.Point(96, 104)
Me.ComboBox1.Name = "ComboBox1"
Me.ComboBox1.Size = New System.Drawing.Size(136, 20)
Me.ComboBox1.TabIndex = 18
'
'Label7
'
Me.Label7.Location = New System.Drawing.Point(8, 104)
Me.Label7.Name = "Label7"
Me.Label7.Size = New System.Drawing.Size(120, 24)
Me.Label7.TabIndex = 17
Me.Label7.Text = "讀者性別:"
'
'TextBox4
'
Me.TextBox4.Enabled = False
Me.TextBox4.Location = New System.Drawing.Point(96, 64)
Me.TextBox4.Name = "TextBox4"
Me.TextBox4.Size = New System.Drawing.Size(136, 21)
Me.TextBox4.TabIndex = 16
Me.TextBox4.Text = ""
'
'Label6
'
Me.Label6.Location = New System.Drawing.Point(8, 64)
Me.Label6.Name = "Label6"
Me.Label6.Size = New System.Drawing.Size(120, 24)
Me.Label6.TabIndex = 15
Me.Label6.Text = "讀者姓名:"
'
'TextBox3
'
Me.TextBox3.Enabled = False
Me.TextBox3.Location = New System.Drawing.Point(96, 24)
Me.TextBox3.Name = "TextBox3"
Me.TextBox3.Size = New System.Drawing.Size(136, 21)
Me.TextBox3.TabIndex = 14
Me.TextBox3.Text = ""
'
'Label5
'
Me.Label5.Location = New System.Drawing.Point(8, 24)
Me.Label5.Name = "Label5"
Me.Label5.Size = New System.Drawing.Size(120, 24)
Me.Label5.TabIndex = 13
Me.Label5.Text = "讀者編號:"
'
'frmDzWh
'
Me.AutoScaleBaseSize = New System.Drawing.Size(6, 14)
Me.ClientSize = New System.Drawing.Size(760, 438)
Me.Controls.Add(Me.GroupBox2)
Me.Controls.Add(Me.DataGrid1)
Me.Controls.Add(Me.GroupBox1)
Me.Controls.Add(Me.ToolBar1)
Me.Name = "frmDzWh"
Me.Text = "讀者信息維護"
Me.GroupBox1.ResumeLayout(False)
CType(Me.DataGrid1, System.ComponentModel.ISupportInitialize).EndInit()
Me.GroupBox2.ResumeLayout(False)
Me.ResumeLayout(False)
End Sub
#End Region
Private Sub frmDzWh_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles MyBase.Load
If conn.State = ConnectionState.Closed Then
conn.Open()
End If
comm.Connection = conn
comm.CommandType = CommandType.Text
comm.CommandText = "select * from 讀者信息表"
da.SelectCommand = comm
da.Fill(ds, "讀者信息表")
bm = Me.BindingContext(ds, "讀者信息表")
DataGrid1.DataSource = ds.Tables("讀者信息表")
'DataGrid1.DataSource = dt.DefaultView
Label4.Text = ds.Tables("讀者信息表").Rows.Count.ToString
Me.DataGrid1_Click(Nothing, Nothing)
If conn.State = ConnectionState.Open Then
conn.Close()
End If
ToolBarButton8.Enabled = False
End Sub
Private Sub ToolBar1_ButtonClick(ByVal sender As Object, ByVal e As System.Windows.Forms.ToolBarButtonClickEventArgs) Handles ToolBar1.ButtonClick
Dim i As New Integer
Dim dzbh As String
Select Case e.Button.Text
Case "首記錄"
''bm.Position = 0
'i = Me.DataGrid1.CurrentRowIndex
'i = 0
'Me.DataGrid1.CurrentRowIndex = i
bm.Position = 0
DataGrid1.CurrentRowIndex = bm.Position
Me.DataGrid1_Click(Nothing, Nothing)
Case "上一條"
'If bm.Position <> 0 Then
' bm.Position -= 1
'End If
'i = Me.DataGrid1.CurrentRowIndex
'i -= 1
'Me.DataGrid1.CurrentRowIndex = i
bm.Position = (bm.Position - 1)
DataGrid1.CurrentRowIndex = bm.Position
Me.DataGrid1_Click(Nothing, Nothing)
Case "下一條"
'If bm.Position <> 0 Then
' bm.Position += 1
'End If
'i = Me.DataGrid1.CurrentRowIndex
'i += 1
'Me.DataGrid1.CurrentRowIndex = i
bm.Position = (bm.Position + 1)
DataGrid1.CurrentRowIndex = bm.Position
Me.DataGrid1_Click(Nothing, Nothing)
Case "尾記錄"
'bm.Position = bm.Count
bm.Position = (ds.Tables("讀者信息表").Rows.Count - 1)
DataGrid1.CurrentRowIndex = bm.Position
Me.DataGrid1_Click(Nothing, Nothing)
Case "修改"
TextBox3.Enabled = True
TextBox4.Enabled = True
TextBox5.Enabled = True
ComboBox1.Enabled = True
ComboBox2.Enabled = True
ComboBox3.Enabled = True
ComboBox4.Enabled = True
ToolBarButton8.Enabled = True
'TextBox3.Text = ds.Tables("讀者信息表").Rows(DataGrid1.CurrentRowIndex).Item(0)
'TextBox4.Text = ds.Tables("讀者信息表").Rows(DataGrid1.CurrentRowIndex).Item(1)
'ComboBox1.SelectedItem = ds.Tables("讀者信息表").Rows(DataGrid1.CurrentRowIndex).Item(2)
'TextBox5.Text = ds.Tables("讀者信息表").Rows(DataGrid1.CurrentRowIndex).Item(3)
'ComboBox2.SelectedItem = ds.Tables("讀者信息表").Rows(DataGrid1.CurrentRowIndex).Item(4)
'ComboBox3.SelectedItem = ds.Tables("讀者信息表").Rows(DataGrid1.CurrentRowIndex).Item(5)
'ComboBox4.SelectedItem = ds.Tables("讀者信息表").Rows(DataGrid1.CurrentRowIndex).Item(6)
Case "刪除"
If conn.State = ConnectionState.Closed Then
conn.Open()
End If
Dim str As String
dzbh = ds.Tables("讀者信息表").Rows(DataGrid1.CurrentRowIndex).Item(0)
If MsgBox("確定要刪除這條記錄嗎?", MsgBoxStyle.YesNo, "刪除提示") = MsgBoxResult.Yes Then
str = "delete from 讀者信息表 where 讀者編號='" & dzbh & "'"
'Dim del As Boolean
'del = UpdateDataBase(SqlStr)
comm.Connection = conn
comm.CommandType = CommandType.Text
comm.CommandText = str
da.SelectCommand = comm
da.Fill(ds, "讀者信息表")
If Me.ds.Tables.Count <> 0 Then
ds.Clear()
comm.Connection = conn
comm.CommandType = CommandType.Text
comm.CommandText = "select * from 讀者信息表 "
da.SelectCommand = comm
da.Fill(ds, "讀者信息表")
MessageBox.Show("刪除讀者信息成功", "提示信息")
Else
End If
If conn.State = ConnectionState.Open Then
conn.Close()
End If
Else
Exit Sub
End If
Case "保存"
If conn.State = ConnectionState.Closed Then
conn.Open()
End If
'dzbh = ds.Tables("讀者信息表").Rows(DataGrid1.CurrentRowIndex).Item(0)
Dim str As String
str = "update 讀者信息表 set 讀者姓名 = '" & TextBox4.Text & "',讀者性別 = '" & ComboBox1.SelectedItem & "',學(xué)號 = '" & TextBox5.Text & "',讀者類別 = '" & ComboBox2.SelectedItem & "',最多可借書數(shù) = '" & ComboBox3.SelectedItem & "',借書證狀態(tài) = '" & ComboBox4.SelectedItem & "' where 讀者編號 = '" & TextBox3.Text & "'"
comm.Connection = conn
comm.CommandType = CommandType.Text
comm.CommandText = str
da.SelectCommand = comm
da.Fill(ds, "讀者信息表")
If Me.ds.Tables.Count <> 0 Then
ds.Clear()
comm.Connection = conn
comm.CommandType = CommandType.Text
comm.CommandText = "select * from 讀者信息表 "
da.SelectCommand = comm
da.Fill(ds, "讀者信息表")
MessageBox.Show("讀者信息保存成功", "提示信息")
TextBox3.Enabled = False
TextBox4.Enabled = False
TextBox5.Enabled = False
ComboBox1.Enabled = False
ComboBox2.Enabled = False
ComboBox3.Enabled = False
ComboBox4.Enabled = False
Me.DataGrid1_Click(Nothing, Nothing)
ToolBarButton8.Enabled = False
End If
Case "退出"
Me.Close()
End Select
End Sub
Private Sub DataGrid1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles DataGrid1.Click
TextBox3.Text = ds.Tables("讀者信息表").Rows(DataGrid1.CurrentRowIndex).Item(0)
TextBox4.Text = ds.Tables("讀者信息表").Rows(DataGrid1.CurrentRowIndex).Item(1)
ComboBox1.SelectedItem = ds.Tables("讀者信息表").Rows(DataGrid1.CurrentRowIndex).Item(2)
TextBox5.Text = ds.Tables("讀者信息表").Rows(DataGrid1.CurrentRowIndex).Item(3)
ComboBox2.SelectedItem = ds.Tables("讀者信息表").Rows(DataGrid1.CurrentRowIndex).Item(4)
ComboBox3.SelectedItem = ds.Tables("讀者信息表").Rows(DataGrid1.CurrentRowIndex).Item(5)
ComboBox4.SelectedItem = ds.Tables("讀者信息表").Rows(DataGrid1.CurrentRowIndex).Item(6)
End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
ds.Clear()
If conn.State = ConnectionState.Closed Then
conn.Open()
End If
comm.Connection = conn
comm.CommandType = CommandType.Text
comm.CommandText = "select * from 讀者信息表 where 讀者姓名 = '" & TextBox2.Text & "'"
da.SelectCommand = comm
da.Fill(ds, "讀者信息表")
DataGrid1.DataSource = ds.Tables("讀者信息表")
Me.DataGrid1_Click(Nothing, Nothing)
If conn.State = ConnectionState.Open Then
conn.Close()
End If
End Sub
End Class
?? 快捷鍵說明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -