📄 frmbookmanage.vb
字号:
Public Class frmBookManage
Inherits System.Windows.Forms.Form
#Region " Windows 窗体设计器生成的代码 "
Public Sub New()
MyBase.New()
'该调用是 Windows 窗体设计器所必需的。
InitializeComponent()
'在 InitializeComponent() 调用之后添加任何初始化
End Sub
'窗体重写处置以清理组件列表。
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 Label1 As System.Windows.Forms.Label
Friend WithEvents Label2 As System.Windows.Forms.Label
Friend WithEvents Label3 As System.Windows.Forms.Label
Friend WithEvents NumericUpDown1 As System.Windows.Forms.NumericUpDown
Friend WithEvents TextBox1 As System.Windows.Forms.TextBox
Friend WithEvents ComboBox1 As System.Windows.Forms.ComboBox
Friend WithEvents Button1 As System.Windows.Forms.Button
<System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()
Me.GroupBox1 = New System.Windows.Forms.GroupBox()
Me.Button1 = New System.Windows.Forms.Button()
Me.ComboBox1 = New System.Windows.Forms.ComboBox()
Me.TextBox1 = New System.Windows.Forms.TextBox()
Me.NumericUpDown1 = New System.Windows.Forms.NumericUpDown()
Me.Label3 = New System.Windows.Forms.Label()
Me.Label2 = New System.Windows.Forms.Label()
Me.Label1 = New System.Windows.Forms.Label()
Me.GroupBox1.SuspendLayout()
CType(Me.NumericUpDown1, System.ComponentModel.ISupportInitialize).BeginInit()
Me.SuspendLayout()
'
'GroupBox1
'
Me.GroupBox1.BackColor = System.Drawing.Color.FromArgb(CType(192, Byte), CType(192, Byte), CType(255, Byte))
Me.GroupBox1.Controls.AddRange(New System.Windows.Forms.Control() {Me.Button1, Me.ComboBox1, Me.TextBox1, Me.NumericUpDown1, Me.Label3, Me.Label2, Me.Label1})
Me.GroupBox1.Dock = System.Windows.Forms.DockStyle.Fill
Me.GroupBox1.Name = "GroupBox1"
Me.GroupBox1.Size = New System.Drawing.Size(292, 169)
Me.GroupBox1.TabIndex = 0
Me.GroupBox1.TabStop = False
'
'Button1
'
Me.Button1.FlatStyle = System.Windows.Forms.FlatStyle.Flat
Me.Button1.ForeColor = System.Drawing.Color.Navy
Me.Button1.Location = New System.Drawing.Point(216, 136)
Me.Button1.Name = "Button1"
Me.Button1.Size = New System.Drawing.Size(64, 24)
Me.Button1.TabIndex = 6
Me.Button1.Text = "注销"
'
'ComboBox1
'
Me.ComboBox1.Items.AddRange(New Object() {"全部注销", "部分注销"})
Me.ComboBox1.Location = New System.Drawing.Point(96, 64)
Me.ComboBox1.Name = "ComboBox1"
Me.ComboBox1.Size = New System.Drawing.Size(184, 20)
Me.ComboBox1.TabIndex = 5
Me.ComboBox1.Text = "全部注销"
'
'TextBox1
'
Me.TextBox1.Location = New System.Drawing.Point(96, 24)
Me.TextBox1.Name = "TextBox1"
Me.TextBox1.Size = New System.Drawing.Size(184, 21)
Me.TextBox1.TabIndex = 4
Me.TextBox1.Text = ""
'
'NumericUpDown1
'
Me.NumericUpDown1.Location = New System.Drawing.Point(96, 104)
Me.NumericUpDown1.Name = "NumericUpDown1"
Me.NumericUpDown1.Size = New System.Drawing.Size(184, 21)
Me.NumericUpDown1.TabIndex = 3
'
'Label3
'
Me.Label3.Location = New System.Drawing.Point(8, 104)
Me.Label3.Name = "Label3"
Me.Label3.Size = New System.Drawing.Size(88, 21)
Me.Label3.TabIndex = 2
Me.Label3.Text = "注销数目"
Me.Label3.TextAlign = System.Drawing.ContentAlignment.MiddleLeft
'
'Label2
'
Me.Label2.Location = New System.Drawing.Point(8, 63)
Me.Label2.Name = "Label2"
Me.Label2.Size = New System.Drawing.Size(88, 21)
Me.Label2.TabIndex = 1
Me.Label2.Text = "注销类别"
Me.Label2.TextAlign = System.Drawing.ContentAlignment.MiddleLeft
'
'Label1
'
Me.Label1.Location = New System.Drawing.Point(8, 24)
Me.Label1.Name = "Label1"
Me.Label1.Size = New System.Drawing.Size(88, 21)
Me.Label1.TabIndex = 0
Me.Label1.Text = "图书 ISBN 号"
Me.Label1.TextAlign = System.Drawing.ContentAlignment.MiddleLeft
'
'frmBookManage
'
Me.AutoScaleBaseSize = New System.Drawing.Size(6, 14)
Me.ClientSize = New System.Drawing.Size(292, 169)
Me.Controls.AddRange(New System.Windows.Forms.Control() {Me.GroupBox1})
Me.Name = "frmBookManage"
Me.Text = "图书注销管理"
Me.GroupBox1.ResumeLayout(False)
CType(Me.NumericUpDown1, System.ComponentModel.ISupportInitialize).EndInit()
Me.ResumeLayout(False)
End Sub
#End Region
Dim sqlstr As String
Dim num As Integer
Private Sub TextBox1_KeyPress(ByVal sender As Object, _
ByVal e As System.Windows.Forms.KeyPressEventArgs) _
Handles TextBox1.KeyPress
If e.KeyChar = Chr(13) Then
Dim isbn As String
isbn = Trim(Me.TextBox1.Text)
If isbn <> "" Then
sqlstr = "SELECT Numbers FROM BookInfo WHERE ISBN='" & isbn & "'"
Dim ds As New DataSet()
ds.Clear()
ds = GetDataFromDB(sqlstr)
If Not ds Is Nothing Then
Me.NumericUpDown1.Maximum = ds.Tables(0).Rows(0)("Numbers")
Me.NumericUpDown1.Value = Me.NumericUpDown1.Maximum
End If
End If
End If
End Sub
Private Sub ComboBox1_SelectedIndexChanged(ByVal sender As System.Object, _
ByVal e As System.EventArgs) Handles ComboBox1.SelectedIndexChanged
Select Case Me.ComboBox1.SelectedIndex
Case 0
Me.NumericUpDown1.Value = Me.NumericUpDown1.Maximum
Me.NumericUpDown1.Enabled = False
Case 1
num = Me.NumericUpDown1.Value
Me.NumericUpDown1.Enabled = True
End Select
End Sub
Private Sub Button1_Click(ByVal sender As System.Object, _
ByVal e As System.EventArgs) Handles Button1.Click
Dim isbn As String
Dim num1 As Integer
isbn = Trim(Me.TextBox1.Text)
If isbn <> "" Then
Select Case Me.ComboBox1.SelectedIndex
Case 0
sqlstr = "UPDATE BookInfo SET Numbers=0 WHERE ISBN ='" & isbn & "'"
Case 1
num1 = Me.NumericUpDown1.Value
num = num - num1
sqlstr = "UPDATE BookInfo SET Numbers='" & num _
& "' WHERE ISBN ='" & isbn & "'"
End Select
If UpdateDataBase(sqlstr) = True Then
MsgBox("祝贺你,图书注销成功。", MsgBoxStyle.OKOnly + _
MsgBoxStyle.Information, "注销成功")
End If
End If
End Sub
End Class
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -