📄 kfxx.vb
字号:
Imports System.Data.SqlClient
Public Class kfxx
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 Panel1 As System.Windows.Forms.Panel
Friend WithEvents TextBox1 As System.Windows.Forms.TextBox
Friend WithEvents Button1 As System.Windows.Forms.Button
Friend WithEvents ComboBox1 As System.Windows.Forms.ComboBox
Friend WithEvents Label1 As System.Windows.Forms.Label
Friend WithEvents Button2 As System.Windows.Forms.Button
Friend WithEvents Button4 As System.Windows.Forms.Button
Friend WithEvents SqlConnection1 As System.Data.SqlClient.SqlConnection
Friend WithEvents SqlDataAdapter1 As System.Data.SqlClient.SqlDataAdapter
Friend WithEvents SqlSelectCommand1 As System.Data.SqlClient.SqlCommand
Friend WithEvents SqlInsertCommand1 As System.Data.SqlClient.SqlCommand
Friend WithEvents DataSet11 As 酒店客房管理系统.DataSet1
Friend WithEvents DataGrid1 As System.Windows.Forms.DataGrid
Friend WithEvents DataSet12 As 酒店客房管理系统.DataSet1
<System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()
Me.Panel1 = New System.Windows.Forms.Panel
Me.TextBox1 = New System.Windows.Forms.TextBox
Me.Button1 = New System.Windows.Forms.Button
Me.ComboBox1 = New System.Windows.Forms.ComboBox
Me.Label1 = New System.Windows.Forms.Label
Me.Button2 = New System.Windows.Forms.Button
Me.Button4 = New System.Windows.Forms.Button
Me.SqlConnection1 = New System.Data.SqlClient.SqlConnection
Me.SqlDataAdapter1 = New System.Data.SqlClient.SqlDataAdapter
Me.SqlInsertCommand1 = New System.Data.SqlClient.SqlCommand
Me.SqlSelectCommand1 = New System.Data.SqlClient.SqlCommand
Me.DataSet11 = New 酒店客房管理系统.DataSet1
Me.DataGrid1 = New System.Windows.Forms.DataGrid
Me.DataSet12 = New 酒店客房管理系统.DataSet1
Me.Button3 = New System.Windows.Forms.Button
Me.Panel1.SuspendLayout()
CType(Me.DataSet11, System.ComponentModel.ISupportInitialize).BeginInit()
CType(Me.DataGrid1, System.ComponentModel.ISupportInitialize).BeginInit()
CType(Me.DataSet12, System.ComponentModel.ISupportInitialize).BeginInit()
Me.SuspendLayout()
'
'Panel1
'
Me.Panel1.BackColor = System.Drawing.SystemColors.AppWorkspace
Me.Panel1.Controls.Add(Me.TextBox1)
Me.Panel1.Controls.Add(Me.Button1)
Me.Panel1.Controls.Add(Me.ComboBox1)
Me.Panel1.Controls.Add(Me.Label1)
Me.Panel1.Location = New System.Drawing.Point(24, 16)
Me.Panel1.Name = "Panel1"
Me.Panel1.Size = New System.Drawing.Size(384, 56)
Me.Panel1.TabIndex = 1
'
'TextBox1
'
Me.TextBox1.Font = New System.Drawing.Font("宋体", 10.0!)
Me.TextBox1.Location = New System.Drawing.Point(208, 16)
Me.TextBox1.MaxLength = 10
Me.TextBox1.Name = "TextBox1"
Me.TextBox1.TabIndex = 1
Me.TextBox1.Text = ""
'
'Button1
'
Me.Button1.Location = New System.Drawing.Point(336, 16)
Me.Button1.Name = "Button1"
Me.Button1.Size = New System.Drawing.Size(32, 23)
Me.Button1.TabIndex = 2
Me.Button1.Text = "GO"
'
'ComboBox1
'
Me.ComboBox1.Font = New System.Drawing.Font("宋体", 10.0!)
Me.ComboBox1.Items.AddRange(New Object() {"房间ID", "楼层", "房间状态"})
Me.ComboBox1.Location = New System.Drawing.Point(96, 16)
Me.ComboBox1.Name = "ComboBox1"
Me.ComboBox1.Size = New System.Drawing.Size(80, 21)
Me.ComboBox1.TabIndex = 0
Me.ComboBox1.Text = "房间ID"
'
'Label1
'
Me.Label1.Font = New System.Drawing.Font("宋体", 12.0!)
Me.Label1.Location = New System.Drawing.Point(16, 16)
Me.Label1.Name = "Label1"
Me.Label1.Size = New System.Drawing.Size(72, 23)
Me.Label1.TabIndex = 2
Me.Label1.Text = "检索类别"
'
'Button2
'
Me.Button2.Location = New System.Drawing.Point(424, 32)
Me.Button2.Name = "Button2"
Me.Button2.Size = New System.Drawing.Size(56, 23)
Me.Button2.TabIndex = 2
Me.Button2.Text = "删除"
'
'Button4
'
Me.Button4.Location = New System.Drawing.Point(552, 32)
Me.Button4.Name = "Button4"
Me.Button4.Size = New System.Drawing.Size(56, 23)
Me.Button4.TabIndex = 4
Me.Button4.Text = "退出"
'
'SqlConnection1
'
Me.SqlConnection1.ConnectionString = "workstation id=MINS;packet size=4096;integrated security=SSPI;data source=MINS;pe" & _
"rsist security info=True;initial catalog=RoomManager"
'
'SqlDataAdapter1
'
Me.SqlDataAdapter1.InsertCommand = Me.SqlInsertCommand1
Me.SqlDataAdapter1.SelectCommand = Me.SqlSelectCommand1
Me.SqlDataAdapter1.TableMappings.AddRange(New System.Data.Common.DataTableMapping() {New System.Data.Common.DataTableMapping("Table", "房间信息", New System.Data.Common.DataColumnMapping() {New System.Data.Common.DataColumnMapping("房间ID", "房间ID"), New System.Data.Common.DataColumnMapping("房间属性", "房间属性"), New System.Data.Common.DataColumnMapping("房间状态", "房间状态"), New System.Data.Common.DataColumnMapping("楼层", "楼层")})})
'
'SqlInsertCommand1
'
Me.SqlInsertCommand1.CommandText = "INSERT INTO 房间信息(房间ID, 房间属性, 房间状态, 楼层) VALUES (@房间ID, @房间属性, @房间状态, @楼层); SELECT " & _
"房间ID, 房间属性, 房间状态, 楼层 FROM 房间信息"
Me.SqlInsertCommand1.Connection = Me.SqlConnection1
Me.SqlInsertCommand1.Parameters.Add(New System.Data.SqlClient.SqlParameter("@房间ID", System.Data.SqlDbType.VarChar, 10, "房间ID"))
Me.SqlInsertCommand1.Parameters.Add(New System.Data.SqlClient.SqlParameter("@房间属性", System.Data.SqlDbType.VarChar, 8, "房间属性"))
Me.SqlInsertCommand1.Parameters.Add(New System.Data.SqlClient.SqlParameter("@房间状态", System.Data.SqlDbType.VarChar, 4, "房间状态"))
Me.SqlInsertCommand1.Parameters.Add(New System.Data.SqlClient.SqlParameter("@楼层", System.Data.SqlDbType.VarChar, 2, "楼层"))
'
'SqlSelectCommand1
'
Me.SqlSelectCommand1.CommandText = "SELECT 房间ID, 房间属性, 房间状态, 楼层 FROM 房间信息"
Me.SqlSelectCommand1.Connection = Me.SqlConnection1
'
'DataSet11
'
Me.DataSet11.DataSetName = "DataSet1"
Me.DataSet11.Locale = New System.Globalization.CultureInfo("zh-CN")
'
'DataGrid1
'
Me.DataGrid1.Anchor = CType((((System.Windows.Forms.AnchorStyles.Top Or System.Windows.Forms.AnchorStyles.Bottom) _
Or System.Windows.Forms.AnchorStyles.Left) _
Or System.Windows.Forms.AnchorStyles.Right), System.Windows.Forms.AnchorStyles)
Me.DataGrid1.CaptionBackColor = System.Drawing.SystemColors.ControlDarkDark
Me.DataGrid1.DataMember = ""
Me.DataGrid1.DataSource = Me.DataSet12.房间信息
Me.DataGrid1.HeaderForeColor = System.Drawing.SystemColors.ControlText
Me.DataGrid1.Location = New System.Drawing.Point(24, 96)
Me.DataGrid1.Name = "DataGrid1"
Me.DataGrid1.SelectionBackColor = System.Drawing.SystemColors.AppWorkspace
Me.DataGrid1.Size = New System.Drawing.Size(584, 360)
Me.DataGrid1.TabIndex = 5
'
'DataSet12
'
Me.DataSet12.DataSetName = "DataSet1"
Me.DataSet12.Locale = New System.Globalization.CultureInfo("zh-CN")
'
'Button3
'
Me.Button3.Location = New System.Drawing.Point(488, 32)
Me.Button3.Name = "Button3"
Me.Button3.Size = New System.Drawing.Size(56, 23)
Me.Button3.TabIndex = 3
Me.Button3.Text = "保存"
'
'kfxx
'
Me.AutoScaleBaseSize = New System.Drawing.Size(6, 14)
Me.ClientSize = New System.Drawing.Size(632, 478)
Me.Controls.Add(Me.DataGrid1)
Me.Controls.Add(Me.Button4)
Me.Controls.Add(Me.Button3)
Me.Controls.Add(Me.Button2)
Me.Controls.Add(Me.Panel1)
Me.MinimizeBox = False
Me.Name = "kfxx"
Me.Text = "客房信息维护"
Me.Panel1.ResumeLayout(False)
CType(Me.DataSet11, System.ComponentModel.ISupportInitialize).EndInit()
CType(Me.DataGrid1, System.ComponentModel.ISupportInitialize).EndInit()
CType(Me.DataSet12, System.ComponentModel.ISupportInitialize).EndInit()
Me.ResumeLayout(False)
End Sub
#End Region
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
Dim rowNo As Integer
rowNo = DataGrid1.CurrentRowIndex
DataSet12.房间信息.Rows(rowNo).Delete()
'SqlDataAdapter1.Update(DataSet12.GetChanges)
'DataSet12.AcceptChanges()
End Sub
Private Sub Button4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button4.Click
Close()
End Sub
Private Sub kfxx_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Try
SqlDataAdapter1.Fill(DataSet12)
Catch ex As Exception
MessageBox.Show(ex.Message)
End Try
End Sub
Private Sub TextBox1_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TextBox1.TextChanged
End Sub
Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click
Try
SqlDataAdapter1.Update(DataSet12.GetChanges)
DataSet12.AcceptChanges()
Catch ex As Exception
MessageBox.Show(ex.Message)
End Try
End Sub
Friend WithEvents Button3 As System.Windows.Forms.Button
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
End Sub
End Class
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -