📄 frmdelbook.vb
字号:
Imports System.Data
Imports System.Data.SqlClient
Public Class frmDelBook
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 tbDel As System.Windows.Forms.Button
Friend WithEvents bnCancle As System.Windows.Forms.Button
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(frmDelBook))
Me.tbbookid = New System.Windows.Forms.TextBox
Me.Label1 = New System.Windows.Forms.Label
Me.tbDel = New System.Windows.Forms.Button
Me.bnCancle = New System.Windows.Forms.Button
Me.SuspendLayout()
'
'tbbookid
'
Me.tbbookid.Location = New System.Drawing.Point(8, 48)
Me.tbbookid.Name = "tbbookid"
Me.tbbookid.Size = New System.Drawing.Size(168, 21)
Me.tbbookid.TabIndex = 0
Me.tbbookid.Text = ""
'
'Label1
'
Me.Label1.Location = New System.Drawing.Point(8, 24)
Me.Label1.Name = "Label1"
Me.Label1.Size = New System.Drawing.Size(112, 16)
Me.Label1.TabIndex = 1
Me.Label1.Text = "请输入图书编号:"
'
'tbDel
'
Me.tbDel.Location = New System.Drawing.Point(8, 96)
Me.tbDel.Name = "tbDel"
Me.tbDel.TabIndex = 2
Me.tbDel.Text = "删除"
'
'bnCancle
'
Me.bnCancle.Location = New System.Drawing.Point(104, 96)
Me.bnCancle.Name = "bnCancle"
Me.bnCancle.TabIndex = 3
Me.bnCancle.Text = "取消"
'
'frmDelBook
'
Me.AutoScaleBaseSize = New System.Drawing.Size(6, 14)
Me.ClientSize = New System.Drawing.Size(184, 141)
Me.Controls.Add(Me.bnCancle)
Me.Controls.Add(Me.tbDel)
Me.Controls.Add(Me.Label1)
Me.Controls.Add(Me.tbbookid)
Me.Icon = CType(resources.GetObject("$this.Icon"), System.Drawing.Icon)
Me.Name = "frmDelBook"
Me.Text = "----删除图书"
Me.ResumeLayout(False)
End Sub
#End Region
Private Sub tbDel_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles tbDel.Click
Dim strSource As String = "workstation id=郭洪博;packet size=4096;integrated security=SSPI;initial catalog=books;persist security info=False"
Dim strDelete As String = "delete from books where bookid='" + tbBookid.Text.Trim() + "'"
Dim conn As SqlConnection = New SqlConnection(strSource)
Try
conn.Open()
Dim cmd As SqlCommand = New SqlCommand(strDelete, conn)
Dim ret As Integer = cmd.ExecuteNonQuery()
If ret <> 1 Then
MessageBox.Show("操作失败!")
Else
MessageBox.Show("删除成功!")
End If
Catch ex As Exception
MessageBox.Show("操作失败!")
MessageBox.Show(ex.ToString)
End Try
conn.Close()
tbbookid.Clear()
End Sub
Private Sub bnCancle_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles bnCancle.Click
Me.Close()
End Sub
Private Sub frmDelBook_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 + -