📄 frmaddbook.vb
字号:
Imports System.Data
Imports System.Data.SqlClient
Public Class frmAddBook
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 Label1 As System.Windows.Forms.Label
Friend WithEvents tbBookName As System.Windows.Forms.TextBox
Friend WithEvents tbAuthor As System.Windows.Forms.TextBox
Friend WithEvents Label4 As System.Windows.Forms.Label
Friend WithEvents tbAdd As System.Windows.Forms.Button
Friend WithEvents bnClean As System.Windows.Forms.Button
Friend WithEvents bnCancel As System.Windows.Forms.Button
Friend WithEvents Label3 As System.Windows.Forms.Label
Friend WithEvents tbpublish As System.Windows.Forms.TextBox
Friend WithEvents Label5 As System.Windows.Forms.Label
Friend WithEvents GroupBox1 As System.Windows.Forms.GroupBox
Friend WithEvents tbbookclass As System.Windows.Forms.TextBox
Friend WithEvents Label2 As System.Windows.Forms.Label
Friend WithEvents tbbookid As System.Windows.Forms.TextBox
<System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()
Dim resources As System.Resources.ResourceManager = New System.Resources.ResourceManager(GetType(frmAddBook))
Me.Label1 = New System.Windows.Forms.Label
Me.tbBookName = New System.Windows.Forms.TextBox
Me.tbAuthor = New System.Windows.Forms.TextBox
Me.Label4 = New System.Windows.Forms.Label
Me.tbAdd = New System.Windows.Forms.Button
Me.bnClean = New System.Windows.Forms.Button
Me.bnCancel = New System.Windows.Forms.Button
Me.tbbookid = New System.Windows.Forms.TextBox
Me.Label3 = New System.Windows.Forms.Label
Me.tbpublish = New System.Windows.Forms.TextBox
Me.Label5 = New System.Windows.Forms.Label
Me.GroupBox1 = New System.Windows.Forms.GroupBox
Me.tbbookclass = New System.Windows.Forms.TextBox
Me.Label2 = New System.Windows.Forms.Label
Me.SuspendLayout()
'
'Label1
'
Me.Label1.Location = New System.Drawing.Point(24, 72)
Me.Label1.Name = "Label1"
Me.Label1.Size = New System.Drawing.Size(72, 16)
Me.Label1.TabIndex = 0
Me.Label1.Text = "图 书 名:"
Me.Label1.TextAlign = System.Drawing.ContentAlignment.MiddleRight
'
'tbBookName
'
Me.tbBookName.Location = New System.Drawing.Point(104, 72)
Me.tbBookName.Name = "tbBookName"
Me.tbBookName.Size = New System.Drawing.Size(136, 21)
Me.tbBookName.TabIndex = 1
Me.tbBookName.Text = ""
'
'tbAuthor
'
Me.tbAuthor.Location = New System.Drawing.Point(104, 104)
Me.tbAuthor.Name = "tbAuthor"
Me.tbAuthor.Size = New System.Drawing.Size(136, 21)
Me.tbAuthor.TabIndex = 7
Me.tbAuthor.Text = ""
'
'Label4
'
Me.Label4.Location = New System.Drawing.Point(24, 104)
Me.Label4.Name = "Label4"
Me.Label4.Size = New System.Drawing.Size(72, 16)
Me.Label4.TabIndex = 6
Me.Label4.Text = "作 者:"
Me.Label4.TextAlign = System.Drawing.ContentAlignment.MiddleRight
'
'tbAdd
'
Me.tbAdd.Location = New System.Drawing.Point(296, 64)
Me.tbAdd.Name = "tbAdd"
Me.tbAdd.TabIndex = 8
Me.tbAdd.Text = "添加"
'
'bnClean
'
Me.bnClean.Location = New System.Drawing.Point(296, 104)
Me.bnClean.Name = "bnClean"
Me.bnClean.TabIndex = 9
Me.bnClean.Text = "清除"
'
'bnCancel
'
Me.bnCancel.Location = New System.Drawing.Point(296, 152)
Me.bnCancel.Name = "bnCancel"
Me.bnCancel.TabIndex = 10
Me.bnCancel.Text = "取消"
'
'tbbookid
'
Me.tbbookid.Location = New System.Drawing.Point(104, 40)
Me.tbbookid.Name = "tbbookid"
Me.tbbookid.Size = New System.Drawing.Size(136, 21)
Me.tbbookid.TabIndex = 12
Me.tbbookid.Text = ""
'
'Label3
'
Me.Label3.Location = New System.Drawing.Point(24, 40)
Me.Label3.Name = "Label3"
Me.Label3.Size = New System.Drawing.Size(72, 16)
Me.Label3.TabIndex = 11
Me.Label3.Text = "图书编号:"
Me.Label3.TextAlign = System.Drawing.ContentAlignment.MiddleRight
'
'tbpublish
'
Me.tbpublish.Location = New System.Drawing.Point(104, 136)
Me.tbpublish.Name = "tbpublish"
Me.tbpublish.Size = New System.Drawing.Size(136, 21)
Me.tbpublish.TabIndex = 14
Me.tbpublish.Text = ""
'
'Label5
'
Me.Label5.Location = New System.Drawing.Point(24, 136)
Me.Label5.Name = "Label5"
Me.Label5.Size = New System.Drawing.Size(72, 16)
Me.Label5.TabIndex = 13
Me.Label5.Text = "出 版 社:"
Me.Label5.TextAlign = System.Drawing.ContentAlignment.MiddleRight
'
'GroupBox1
'
Me.GroupBox1.ForeColor = System.Drawing.Color.Red
Me.GroupBox1.Location = New System.Drawing.Point(8, 8)
Me.GroupBox1.Name = "GroupBox1"
Me.GroupBox1.Size = New System.Drawing.Size(264, 208)
Me.GroupBox1.TabIndex = 15
Me.GroupBox1.TabStop = False
Me.GroupBox1.Text = "添加图书"
'
'tbbookclass
'
Me.tbbookclass.Location = New System.Drawing.Point(104, 168)
Me.tbbookclass.Name = "tbbookclass"
Me.tbbookclass.Size = New System.Drawing.Size(136, 21)
Me.tbbookclass.TabIndex = 3
Me.tbbookclass.Text = ""
'
'Label2
'
Me.Label2.Location = New System.Drawing.Point(24, 168)
Me.Label2.Name = "Label2"
Me.Label2.Size = New System.Drawing.Size(72, 16)
Me.Label2.TabIndex = 2
Me.Label2.Text = "图书类别:"
Me.Label2.TextAlign = System.Drawing.ContentAlignment.MiddleRight
'
'frmAddBook
'
Me.AutoScaleBaseSize = New System.Drawing.Size(6, 14)
Me.ClientSize = New System.Drawing.Size(392, 245)
Me.Controls.Add(Me.tbpublish)
Me.Controls.Add(Me.Label5)
Me.Controls.Add(Me.tbbookid)
Me.Controls.Add(Me.Label3)
Me.Controls.Add(Me.bnCancel)
Me.Controls.Add(Me.bnClean)
Me.Controls.Add(Me.tbAdd)
Me.Controls.Add(Me.tbAuthor)
Me.Controls.Add(Me.Label4)
Me.Controls.Add(Me.tbbookclass)
Me.Controls.Add(Me.Label2)
Me.Controls.Add(Me.tbBookName)
Me.Controls.Add(Me.Label1)
Me.Controls.Add(Me.GroupBox1)
Me.Icon = CType(resources.GetObject("$this.Icon"), System.Drawing.Icon)
Me.Name = "frmAddBook"
Me.Text = "---------添加图书"
Me.ResumeLayout(False)
End Sub
#End Region
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles bnClean.Click
tbbookid.Text = ""
tbBookName.Text = ""
tbAuthor.Text = ""
tbpublish.Text = ""
tbbookclass.Text = ""
End Sub
Private Sub bnCancel_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles bnCancel.Click
Me.Close()
End Sub
Private Sub tbAdd_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles tbAdd.Click
Dim strBookid As String = tbbookid.Text.Trim()
Dim strBookName As String = tbBookName.Text.Trim()
Dim strAuthor As String = tbAuthor.Text.Trim()
Dim strBookpublish As String = tbpublish.Text.Trim()
Dim strBookclass As String = tbbookclass.Text.Trim()
Dim strSource As String = "workstation id=郭洪博;packet size=4096;integrated security=SSPI;initial catalog=books;persist security info=False"
Dim strInsert As String = "insert into books values ('" + strBookid + "','" + strBookName + "','" + strAuthor + "','" + strBookpublish + "','" + strBookclass + "',1)"
Dim conn As SqlConnection = New SqlConnection(strSource)
Try
conn.Open()
Dim cmd As SqlCommand = New SqlCommand(strInsert, conn)
Dim rst As Integer = cmd.ExecuteNonQuery()
If rst <> 1 Then
MessageBox.Show("添加错误!")
Else
MessageBox.Show("添加成功!")
End If
Catch ex As Exception
MessageBox.Show(ex.ToString)
End Try
conn.Close()
End Sub
Private Sub frmAddBook_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
End Sub
End Class
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -