📄 frm_bookmanage.vb
字号:
Imports System.Data.SqlClient
Public Class Frm_BookManage
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 GroupBox1 As System.Windows.Forms.GroupBox
Friend WithEvents Button1 As System.Windows.Forms.Button
Friend WithEvents Button2 As System.Windows.Forms.Button
Friend WithEvents Button3 As System.Windows.Forms.Button
Friend WithEvents Button4 As System.Windows.Forms.Button
Friend WithEvents Button5 As System.Windows.Forms.Button
Friend WithEvents Label1 As System.Windows.Forms.Label
Friend WithEvents Label2 As System.Windows.Forms.Label
Friend WithEvents TextBox1 As System.Windows.Forms.TextBox
Friend WithEvents DataGrid1 As System.Windows.Forms.DataGrid
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 SqlUpdateCommand1 As System.Data.SqlClient.SqlCommand
Friend WithEvents SqlDeleteCommand1 As System.Data.SqlClient.SqlCommand
Friend WithEvents SqlConnection1 As System.Data.SqlClient.SqlConnection
Friend WithEvents Button6 As System.Windows.Forms.Button
Friend WithEvents Button7 As System.Windows.Forms.Button
Friend WithEvents Button8 As System.Windows.Forms.Button
Friend WithEvents Button9 As System.Windows.Forms.Button
Friend WithEvents ComboBox1 As System.Windows.Forms.ComboBox
<System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()
Me.GroupBox1 = New System.Windows.Forms.GroupBox
Me.TextBox1 = New System.Windows.Forms.TextBox
Me.Label1 = New System.Windows.Forms.Label
Me.Button1 = New System.Windows.Forms.Button
Me.Button2 = New System.Windows.Forms.Button
Me.Button3 = New System.Windows.Forms.Button
Me.Button4 = New System.Windows.Forms.Button
Me.Button5 = New System.Windows.Forms.Button
Me.Label2 = New System.Windows.Forms.Label
Me.DataGrid1 = New System.Windows.Forms.DataGrid
Me.SqlDataAdapter1 = New System.Data.SqlClient.SqlDataAdapter
Me.SqlSelectCommand1 = New System.Data.SqlClient.SqlCommand
Me.SqlInsertCommand1 = New System.Data.SqlClient.SqlCommand
Me.SqlUpdateCommand1 = New System.Data.SqlClient.SqlCommand
Me.SqlDeleteCommand1 = New System.Data.SqlClient.SqlCommand
Me.SqlConnection1 = New System.Data.SqlClient.SqlConnection
Me.Button6 = New System.Windows.Forms.Button
Me.Button7 = New System.Windows.Forms.Button
Me.Button8 = New System.Windows.Forms.Button
Me.Button9 = New System.Windows.Forms.Button
Me.ComboBox1 = New System.Windows.Forms.ComboBox
Me.GroupBox1.SuspendLayout()
CType(Me.DataGrid1, System.ComponentModel.ISupportInitialize).BeginInit()
Me.SuspendLayout()
'
'GroupBox1
'
Me.GroupBox1.Anchor = CType(((System.Windows.Forms.AnchorStyles.Top Or System.Windows.Forms.AnchorStyles.Left) _
Or System.Windows.Forms.AnchorStyles.Right), System.Windows.Forms.AnchorStyles)
Me.GroupBox1.Controls.Add(Me.ComboBox1)
Me.GroupBox1.Controls.Add(Me.TextBox1)
Me.GroupBox1.Controls.Add(Me.Label1)
Me.GroupBox1.Controls.Add(Me.Button1)
Me.GroupBox1.Controls.Add(Me.Button2)
Me.GroupBox1.Controls.Add(Me.Button3)
Me.GroupBox1.Controls.Add(Me.Button4)
Me.GroupBox1.Controls.Add(Me.Button5)
Me.GroupBox1.Controls.Add(Me.Label2)
Me.GroupBox1.Controls.Add(Me.Button6)
Me.GroupBox1.Controls.Add(Me.Button7)
Me.GroupBox1.Controls.Add(Me.Button8)
Me.GroupBox1.Controls.Add(Me.Button9)
Me.GroupBox1.Location = New System.Drawing.Point(8, 0)
Me.GroupBox1.Name = "GroupBox1"
Me.GroupBox1.Size = New System.Drawing.Size(640, 96)
Me.GroupBox1.TabIndex = 0
Me.GroupBox1.TabStop = False
Me.GroupBox1.Text = "基本操作"
'
'TextBox1
'
Me.TextBox1.Location = New System.Drawing.Point(352, 64)
Me.TextBox1.Name = "TextBox1"
Me.TextBox1.Size = New System.Drawing.Size(152, 21)
Me.TextBox1.TabIndex = 2
Me.TextBox1.Text = ""
'
'Label1
'
Me.Label1.Location = New System.Drawing.Point(32, 62)
Me.Label1.Name = "Label1"
Me.Label1.Size = New System.Drawing.Size(72, 23)
Me.Label1.TabIndex = 1
Me.Label1.Text = "查询字段:"
'
'Button1
'
Me.Button1.Location = New System.Drawing.Point(16, 24)
Me.Button1.Name = "Button1"
Me.Button1.Size = New System.Drawing.Size(56, 23)
Me.Button1.TabIndex = 0
Me.Button1.Text = "首记录"
'
'Button2
'
Me.Button2.Location = New System.Drawing.Point(88, 24)
Me.Button2.Name = "Button2"
Me.Button2.Size = New System.Drawing.Size(56, 23)
Me.Button2.TabIndex = 0
Me.Button2.Text = "上一条"
'
'Button3
'
Me.Button3.Location = New System.Drawing.Point(168, 24)
Me.Button3.Name = "Button3"
Me.Button3.Size = New System.Drawing.Size(56, 23)
Me.Button3.TabIndex = 0
Me.Button3.Text = "下一条"
'
'Button4
'
Me.Button4.Location = New System.Drawing.Point(248, 24)
Me.Button4.Name = "Button4"
Me.Button4.Size = New System.Drawing.Size(56, 23)
Me.Button4.TabIndex = 0
Me.Button4.Text = "尾记录"
'
'Button5
'
Me.Button5.Location = New System.Drawing.Point(328, 24)
Me.Button5.Name = "Button5"
Me.Button5.Size = New System.Drawing.Size(56, 23)
Me.Button5.TabIndex = 0
Me.Button5.Text = "保存"
'
'Label2
'
Me.Label2.Location = New System.Drawing.Point(272, 62)
Me.Label2.Name = "Label2"
Me.Label2.Size = New System.Drawing.Size(72, 23)
Me.Label2.TabIndex = 1
Me.Label2.Text = "查询数值: "
'
'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.DataMember = ""
Me.DataGrid1.HeaderForeColor = System.Drawing.SystemColors.ControlText
Me.DataGrid1.Location = New System.Drawing.Point(8, 96)
Me.DataGrid1.Name = "DataGrid1"
Me.DataGrid1.Size = New System.Drawing.Size(640, 329)
Me.DataGrid1.TabIndex = 1
'
'SqlDataAdapter1
'
Me.SqlDataAdapter1.DeleteCommand = Me.SqlDeleteCommand1
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("书号", "书号"), New System.Data.Common.DataColumnMapping("书名", "书名"), New System.Data.Common.DataColumnMapping("作者", "作者"), New System.Data.Common.DataColumnMapping("出版社", "出版社"), New System.Data.Common.DataColumnMapping("类别", "类别"), New System.Data.Common.DataColumnMapping("出版日期", "出版日期"), New System.Data.Common.DataColumnMapping("价格", "价格"), New System.Data.Common.DataColumnMapping("库存", "库存"), New System.Data.Common.DataColumnMapping("已借出", "已借出"), New System.Data.Common.DataColumnMapping("备注", "备注")})})
Me.SqlDataAdapter1.UpdateCommand = Me.SqlUpdateCommand1
'
'SqlSelectCommand1
'
Me.SqlSelectCommand1.CommandText = "SELECT 书号, 书名, 作者, 出版社, 类别, 出版日期, 价格, 库存, 已借出, 备注 FROM 书籍总表"
Me.SqlSelectCommand1.Connection = Me.SqlConnection1
'
'SqlInsertCommand1
'
Me.SqlInsertCommand1.CommandText = "INSERT INTO 书籍总表(书号, 书名, 作者, 出版社, 类别, 出版日期, 价格, 库存, 已借出, 备注) VALUES (@书号, @书名, @作" & _
"者, @出版社, @类别, @出版日期, @价格, @库存, @已借出, @备注); SELECT 书号, 书名, 作者, 出版社, 类别, 出版日期, 价格," & _
" 库存, 已借出, 备注 FROM 书籍总表 WHERE (书号 = @书号)"
Me.SqlInsertCommand1.Connection = Me.SqlConnection1
Me.SqlInsertCommand1.Parameters.Add(New System.Data.SqlClient.SqlParameter("@书号", System.Data.SqlDbType.VarChar, 10, "书号"))
Me.SqlInsertCommand1.Parameters.Add(New System.Data.SqlClient.SqlParameter("@书名", System.Data.SqlDbType.VarChar, 50, "书名"))
Me.SqlInsertCommand1.Parameters.Add(New System.Data.SqlClient.SqlParameter("@作者", System.Data.SqlDbType.VarChar, 20, "作者"))
Me.SqlInsertCommand1.Parameters.Add(New System.Data.SqlClient.SqlParameter("@出版社", System.Data.SqlDbType.VarChar, 30, "出版社"))
Me.SqlInsertCommand1.Parameters.Add(New System.Data.SqlClient.SqlParameter("@类别", System.Data.SqlDbType.VarChar, 20, "类别"))
Me.SqlInsertCommand1.Parameters.Add(New System.Data.SqlClient.SqlParameter("@出版日期", System.Data.SqlDbType.DateTime, 4, "出版日期"))
Me.SqlInsertCommand1.Parameters.Add(New System.Data.SqlClient.SqlParameter("@价格", System.Data.SqlDbType.Money, 8, "价格"))
Me.SqlInsertCommand1.Parameters.Add(New System.Data.SqlClient.SqlParameter("@库存", System.Data.SqlDbType.Int, 4, "库存"))
Me.SqlInsertCommand1.Parameters.Add(New System.Data.SqlClient.SqlParameter("@已借出", System.Data.SqlDbType.Int, 4, "已借出"))
Me.SqlInsertCommand1.Parameters.Add(New System.Data.SqlClient.SqlParameter("@备注", System.Data.SqlDbType.VarChar, 50, "备注"))
'
'SqlUpdateCommand1
'
Me.SqlUpdateCommand1.CommandText = "UPDATE 书籍总表 SET 书号 = @书号, 书名 = @书名, 作者 = @作者, 出版社 = @出版社, 类别 = @类别, 出版日期 = @出版日期," & _
" 价格 = @价格, 库存 = @库存, 已借出 = @已借出, 备注 = @备注 WHERE (书号 = @Original_书号) AND (书名 = @O" & _
"riginal_书名) AND (价格 = @Original_价格) AND (作者 = @Original_作者 OR @Original_作者 IS NU" & _
"LL AND 作者 IS NULL) AND (出版日期 = @Original_出版日期 OR @Original_出版日期 IS NULL AND 出版日期" & _
" IS NULL) AND (出版社 = @Original_出版社 OR @Original_出版社 IS NULL AND 出版社 IS NULL) AND" & _
" (备注 = @Original_备注 OR @Original_备注 IS NULL AND 备注 IS NULL) AND (已借出 = @Original" & _
"_已借出) AND (库存 = @Original_库存) AND (类别 = @Original_类别); SELECT 书号, 书名, 作者, 出版社, 类" & _
"别, 出版日期, 价格, 库存, 已借出, 备注 FROM 书籍总表 WHERE (书号 = @书号)"
Me.SqlUpdateCommand1.Connection = Me.SqlConnection1
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -