📄 frmaddbookclass.vb
字号:
Imports System.Data
Imports System.Data.SqlClient
Public Class frmaddbookclass
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 Label3 As System.Windows.Forms.Label
Friend WithEvents bnCancel As System.Windows.Forms.Button
Friend WithEvents bnClean As System.Windows.Forms.Button
Friend WithEvents tbAdd As System.Windows.Forms.Button
Friend WithEvents Label1 As System.Windows.Forms.Label
Friend WithEvents GroupBox1 As System.Windows.Forms.GroupBox
Friend WithEvents tbclassid As System.Windows.Forms.TextBox
Friend WithEvents tbclassname As System.Windows.Forms.TextBox
<System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()
Dim resources As System.Resources.ResourceManager = New System.Resources.ResourceManager(GetType(frmaddbookclass))
Me.tbclassid = New System.Windows.Forms.TextBox
Me.Label3 = New System.Windows.Forms.Label
Me.bnCancel = New System.Windows.Forms.Button
Me.bnClean = New System.Windows.Forms.Button
Me.tbAdd = New System.Windows.Forms.Button
Me.tbclassname = New System.Windows.Forms.TextBox
Me.Label1 = New System.Windows.Forms.Label
Me.GroupBox1 = New System.Windows.Forms.GroupBox
Me.GroupBox1.SuspendLayout()
Me.SuspendLayout()
'
'tbclassid
'
Me.tbclassid.Location = New System.Drawing.Point(120, 48)
Me.tbclassid.Name = "tbclassid"
Me.tbclassid.Size = New System.Drawing.Size(136, 21)
Me.tbclassid.TabIndex = 26
Me.tbclassid.Text = ""
'
'Label3
'
Me.Label3.Location = New System.Drawing.Point(40, 48)
Me.Label3.Name = "Label3"
Me.Label3.Size = New System.Drawing.Size(72, 16)
Me.Label3.TabIndex = 25
Me.Label3.Text = "类别编号:"
Me.Label3.TextAlign = System.Drawing.ContentAlignment.MiddleRight
'
'bnCancel
'
Me.bnCancel.Location = New System.Drawing.Point(160, 104)
Me.bnCancel.Name = "bnCancel"
Me.bnCancel.TabIndex = 24
Me.bnCancel.Text = "取消"
'
'bnClean
'
Me.bnClean.Location = New System.Drawing.Point(80, 104)
Me.bnClean.Name = "bnClean"
Me.bnClean.TabIndex = 23
Me.bnClean.Text = "清除"
'
'tbAdd
'
Me.tbAdd.Location = New System.Drawing.Point(8, 104)
Me.tbAdd.Name = "tbAdd"
Me.tbAdd.TabIndex = 22
Me.tbAdd.Text = "添加"
'
'tbclassname
'
Me.tbclassname.Location = New System.Drawing.Point(120, 80)
Me.tbclassname.Name = "tbclassname"
Me.tbclassname.Size = New System.Drawing.Size(136, 21)
Me.tbclassname.TabIndex = 17
Me.tbclassname.Text = ""
'
'Label1
'
Me.Label1.Location = New System.Drawing.Point(40, 80)
Me.Label1.Name = "Label1"
Me.Label1.Size = New System.Drawing.Size(72, 16)
Me.Label1.TabIndex = 16
Me.Label1.Text = "类别名:"
Me.Label1.TextAlign = System.Drawing.ContentAlignment.MiddleRight
'
'GroupBox1
'
Me.GroupBox1.Controls.Add(Me.tbAdd)
Me.GroupBox1.Controls.Add(Me.bnClean)
Me.GroupBox1.Controls.Add(Me.bnCancel)
Me.GroupBox1.ForeColor = System.Drawing.Color.Red
Me.GroupBox1.Location = New System.Drawing.Point(24, 16)
Me.GroupBox1.Name = "GroupBox1"
Me.GroupBox1.Size = New System.Drawing.Size(264, 160)
Me.GroupBox1.TabIndex = 29
Me.GroupBox1.TabStop = False
Me.GroupBox1.Text = "添加图书类别"
'
'frmaddbookclass
'
Me.AutoScaleBaseSize = New System.Drawing.Size(6, 14)
Me.ClientSize = New System.Drawing.Size(320, 213)
Me.Controls.Add(Me.tbclassid)
Me.Controls.Add(Me.Label3)
Me.Controls.Add(Me.tbclassname)
Me.Controls.Add(Me.Label1)
Me.Controls.Add(Me.GroupBox1)
Me.Icon = CType(resources.GetObject("$this.Icon"), System.Drawing.Icon)
Me.Name = "frmaddbookclass"
Me.Text = "----------添加图书类别"
Me.GroupBox1.ResumeLayout(False)
Me.ResumeLayout(False)
End Sub
#End Region
Private Sub tbAdd_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles tbAdd.Click
Dim strclassid As String = tbclassid.Text.Trim()
Dim strclassname As String = tbclassname.Text.Trim()
If strclassid = "" Or strclassname = "" Then
'这里的检测应该一个个地进行,给出更详细提示信息
MessageBox.Show("请填写!")
Exit Sub
End If
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 bookclassinfo values('" + strclassid + "','" + strclassname + "')"
Dim conn As New SqlConnection(strSource)
conn.Open()
Dim cmd As New SqlCommand(strInsert, conn)
Dim ret As Integer = cmd.ExecuteNonQuery()
If ret <> 1 Then
MessageBox.Show("添加失败!")
Else
MessageBox.Show("添加成功!")
End If
conn.Close()
End Sub
Private Sub bnClean_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles bnClean.Click
tbclassid.Clear()
tbclassname.Clear()
End Sub
Private Sub bnCancel_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles bnCancel.Click
Me.Close()
End Sub
End Class
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -