?? frmxzdz.vb
字號:
Public Class frmXzDz
Inherits System.Windows.Forms.Form
Dim conn As New SqlConnection("Server=.;DataBase=ViBook;Integrated Security=SSPI")
Dim comm As New SqlCommand
Dim ds As New DataSet
Dim da As New SqlDataAdapter
#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 GroupBox1 As System.Windows.Forms.GroupBox
Friend WithEvents Label3 As System.Windows.Forms.Label
Friend WithEvents Label2 As System.Windows.Forms.Label
Friend WithEvents Label1 As System.Windows.Forms.Label
Friend WithEvents Label4 As System.Windows.Forms.Label
Friend WithEvents Label5 As System.Windows.Forms.Label
Friend WithEvents Label6 As System.Windows.Forms.Label
Friend WithEvents Label7 As System.Windows.Forms.Label
Friend WithEvents Button1 As System.Windows.Forms.Button
Friend WithEvents Button2 As System.Windows.Forms.Button
Friend WithEvents DataGrid1 As System.Windows.Forms.DataGrid
Friend WithEvents TextBox1 As System.Windows.Forms.TextBox
Friend WithEvents TextBox2 As System.Windows.Forms.TextBox
Friend WithEvents ComboBox1 As System.Windows.Forms.ComboBox
Friend WithEvents TextBox3 As System.Windows.Forms.TextBox
Friend WithEvents ComboBox2 As System.Windows.Forms.ComboBox
Friend WithEvents ComboBox3 As System.Windows.Forms.ComboBox
Friend WithEvents ComboBox4 As System.Windows.Forms.ComboBox
<System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()
Me.GroupBox1 = New System.Windows.Forms.GroupBox
Me.ComboBox4 = New System.Windows.Forms.ComboBox
Me.ComboBox3 = New System.Windows.Forms.ComboBox
Me.ComboBox2 = New System.Windows.Forms.ComboBox
Me.TextBox3 = New System.Windows.Forms.TextBox
Me.ComboBox1 = New System.Windows.Forms.ComboBox
Me.TextBox2 = New System.Windows.Forms.TextBox
Me.TextBox1 = New System.Windows.Forms.TextBox
Me.Button2 = New System.Windows.Forms.Button
Me.Button1 = New System.Windows.Forms.Button
Me.Label7 = New System.Windows.Forms.Label
Me.Label6 = New System.Windows.Forms.Label
Me.Label5 = New System.Windows.Forms.Label
Me.Label4 = New System.Windows.Forms.Label
Me.Label3 = New System.Windows.Forms.Label
Me.Label2 = New System.Windows.Forms.Label
Me.Label1 = New System.Windows.Forms.Label
Me.DataGrid1 = New System.Windows.Forms.DataGrid
Me.GroupBox1.SuspendLayout()
CType(Me.DataGrid1, System.ComponentModel.ISupportInitialize).BeginInit()
Me.SuspendLayout()
'
'GroupBox1
'
Me.GroupBox1.Controls.Add(Me.ComboBox4)
Me.GroupBox1.Controls.Add(Me.ComboBox3)
Me.GroupBox1.Controls.Add(Me.ComboBox2)
Me.GroupBox1.Controls.Add(Me.TextBox3)
Me.GroupBox1.Controls.Add(Me.ComboBox1)
Me.GroupBox1.Controls.Add(Me.TextBox2)
Me.GroupBox1.Controls.Add(Me.TextBox1)
Me.GroupBox1.Controls.Add(Me.Button2)
Me.GroupBox1.Controls.Add(Me.Button1)
Me.GroupBox1.Controls.Add(Me.Label7)
Me.GroupBox1.Controls.Add(Me.Label6)
Me.GroupBox1.Controls.Add(Me.Label5)
Me.GroupBox1.Controls.Add(Me.Label4)
Me.GroupBox1.Controls.Add(Me.Label3)
Me.GroupBox1.Controls.Add(Me.Label2)
Me.GroupBox1.Controls.Add(Me.Label1)
Me.GroupBox1.Dock = System.Windows.Forms.DockStyle.Left
Me.GroupBox1.Location = New System.Drawing.Point(0, 0)
Me.GroupBox1.Name = "GroupBox1"
Me.GroupBox1.Size = New System.Drawing.Size(264, 398)
Me.GroupBox1.TabIndex = 0
Me.GroupBox1.TabStop = False
'
'ComboBox4
'
Me.ComboBox4.Items.AddRange(New Object() {"可借", "不可借"})
Me.ComboBox4.Location = New System.Drawing.Point(96, 256)
Me.ComboBox4.Name = "ComboBox4"
Me.ComboBox4.Size = New System.Drawing.Size(136, 20)
Me.ComboBox4.TabIndex = 18
'
'ComboBox3
'
Me.ComboBox3.Items.AddRange(New Object() {"3本", "5本", "10本", "20本", "50本"})
Me.ComboBox3.Location = New System.Drawing.Point(96, 216)
Me.ComboBox3.Name = "ComboBox3"
Me.ComboBox3.Size = New System.Drawing.Size(136, 20)
Me.ComboBox3.TabIndex = 17
'
'ComboBox2
'
Me.ComboBox2.Items.AddRange(New Object() {"學生", "教師", "教授", "博士", "博士后"})
Me.ComboBox2.Location = New System.Drawing.Point(96, 176)
Me.ComboBox2.Name = "ComboBox2"
Me.ComboBox2.Size = New System.Drawing.Size(136, 20)
Me.ComboBox2.TabIndex = 16
'
'TextBox3
'
Me.TextBox3.Location = New System.Drawing.Point(96, 136)
Me.TextBox3.Name = "TextBox3"
Me.TextBox3.Size = New System.Drawing.Size(136, 21)
Me.TextBox3.TabIndex = 15
Me.TextBox3.Text = ""
'
'ComboBox1
'
Me.ComboBox1.Items.AddRange(New Object() {"男", "女"})
Me.ComboBox1.Location = New System.Drawing.Point(96, 96)
Me.ComboBox1.Name = "ComboBox1"
Me.ComboBox1.Size = New System.Drawing.Size(136, 20)
Me.ComboBox1.TabIndex = 14
'
'TextBox2
'
Me.TextBox2.Location = New System.Drawing.Point(96, 56)
Me.TextBox2.Name = "TextBox2"
Me.TextBox2.Size = New System.Drawing.Size(136, 21)
Me.TextBox2.TabIndex = 13
Me.TextBox2.Text = ""
'
'TextBox1
'
Me.TextBox1.Location = New System.Drawing.Point(96, 17)
Me.TextBox1.Name = "TextBox1"
Me.TextBox1.Size = New System.Drawing.Size(136, 21)
Me.TextBox1.TabIndex = 12
Me.TextBox1.Text = ""
'
'Button2
'
Me.Button2.Location = New System.Drawing.Point(144, 312)
Me.Button2.Name = "Button2"
Me.Button2.Size = New System.Drawing.Size(96, 24)
Me.Button2.TabIndex = 11
Me.Button2.Text = "取消"
'
'Button1
'
Me.Button1.Location = New System.Drawing.Point(16, 312)
Me.Button1.Name = "Button1"
Me.Button1.Size = New System.Drawing.Size(96, 24)
Me.Button1.TabIndex = 10
Me.Button1.Text = "確定"
'
'Label7
'
Me.Label7.Location = New System.Drawing.Point(8, 256)
Me.Label7.Name = "Label7"
Me.Label7.Size = New System.Drawing.Size(120, 24)
Me.Label7.TabIndex = 9
Me.Label7.Text = "借書證狀態:"
'
'Label6
'
Me.Label6.Location = New System.Drawing.Point(8, 216)
Me.Label6.Name = "Label6"
Me.Label6.Size = New System.Drawing.Size(120, 24)
Me.Label6.TabIndex = 8
Me.Label6.Text = "可借書數:"
'
'Label5
'
Me.Label5.Location = New System.Drawing.Point(8, 176)
Me.Label5.Name = "Label5"
Me.Label5.Size = New System.Drawing.Size(120, 24)
Me.Label5.TabIndex = 7
Me.Label5.Text = "讀者類別:"
'
'Label4
'
Me.Label4.Location = New System.Drawing.Point(8, 136)
Me.Label4.Name = "Label4"
Me.Label4.Size = New System.Drawing.Size(120, 24)
Me.Label4.TabIndex = 6
Me.Label4.Text = "學 號:"
'
'Label3
'
Me.Label3.Location = New System.Drawing.Point(8, 96)
Me.Label3.Name = "Label3"
Me.Label3.Size = New System.Drawing.Size(120, 24)
Me.Label3.TabIndex = 5
Me.Label3.Text = "讀者性別:"
'
'Label2
'
Me.Label2.Location = New System.Drawing.Point(8, 56)
Me.Label2.Name = "Label2"
Me.Label2.Size = New System.Drawing.Size(120, 24)
Me.Label2.TabIndex = 4
Me.Label2.Text = "讀者姓名:"
'
'Label1
'
Me.Label1.Location = New System.Drawing.Point(8, 16)
Me.Label1.Name = "Label1"
Me.Label1.Size = New System.Drawing.Size(120, 24)
Me.Label1.TabIndex = 3
Me.Label1.Text = "讀者編號:"
'
'DataGrid1
'
Me.DataGrid1.BackColor = System.Drawing.SystemColors.InactiveBorder
Me.DataGrid1.CaptionVisible = False
Me.DataGrid1.DataMember = ""
Me.DataGrid1.Dock = System.Windows.Forms.DockStyle.Fill
Me.DataGrid1.HeaderForeColor = System.Drawing.SystemColors.ControlText
Me.DataGrid1.Location = New System.Drawing.Point(264, 0)
Me.DataGrid1.Name = "DataGrid1"
Me.DataGrid1.ReadOnly = True
Me.DataGrid1.RowHeadersVisible = False
Me.DataGrid1.Size = New System.Drawing.Size(336, 398)
Me.DataGrid1.TabIndex = 1
'
'frmXzDz
'
Me.AutoScaleBaseSize = New System.Drawing.Size(6, 14)
Me.ClientSize = New System.Drawing.Size(600, 398)
Me.Controls.Add(Me.DataGrid1)
Me.Controls.Add(Me.GroupBox1)
Me.MaximizeBox = False
Me.MinimizeBox = False
Me.Name = "frmXzDz"
Me.Text = "新增讀者"
Me.GroupBox1.ResumeLayout(False)
CType(Me.DataGrid1, System.ComponentModel.ISupportInitialize).EndInit()
Me.ResumeLayout(False)
End Sub
#End Region
Private Sub frmXzDz_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
'Dim da As New SqlDataAdapter("select * from 學生信息表 ")
da.Fill(ds, "讀者信息表")
DataGrid1.DataSource = ds.Tables("讀者信息表")
If conn.State = ConnectionState.Open Then
conn.Close()
End If
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
Dim str As String
str = "insert into 讀者信息表(讀者編號,讀者姓名,讀者性別,學號,讀者類別,最多可借書數,借書證狀態) values ('" & TextBox1.Text & "','" & TextBox2.Text & "','" & ComboBox1.SelectedItem & "','" & TextBox3.Text & "','" & ComboBox2.SelectedItem & "','" & ComboBox3.SelectedItem & "','" & ComboBox4.SelectedItem & "')"
comm.Connection = conn
comm.CommandType = CommandType.Text
comm.CommandText = str
da.SelectCommand = comm
da.Fill(ds, "讀者信息表")
If Me.ds.Tables.Count <> 0 Then
comm.Connection = conn
comm.CommandType = CommandType.Text
comm.CommandText = "select * from 讀者信息表 "
da.SelectCommand = comm
da.Fill(ds, "讀者信息表")
MessageBox.Show("新增讀者信息成功", "提示信息")
TextBox1.Text = ""
TextBox2.Text = ""
TextBox3.Text = ""
ComboBox1.Text = ""
ComboBox2.Text = ""
ComboBox3.Text = ""
ComboBox4.Text = ""
TextBox1.Focus()
Else
End If
End Sub
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
Me.Close()
End Sub
End Class
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -