📄 yjzj.vb
字号:
Imports System.Data.SqlClient
Public Class yjzj
Inherits System.Windows.Forms.Form
Dim constr As String = "server=.;database=RoomManager;integrated security=true"
Dim con As New SqlConnection(constr)
Dim com As SqlCommand
Dim dr As SqlDataReader
#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 TextBox1 As System.Windows.Forms.TextBox
Friend WithEvents Button1 As System.Windows.Forms.Button
Friend WithEvents Button2 As System.Windows.Forms.Button
Friend WithEvents Panel1 As System.Windows.Forms.Panel
Friend WithEvents ComboBox1 As System.Windows.Forms.ComboBox
Friend WithEvents Label2 As System.Windows.Forms.Label
Friend WithEvents Label3 As System.Windows.Forms.Label
Friend WithEvents TextBox2 As System.Windows.Forms.TextBox
Friend WithEvents TextBox3 As System.Windows.Forms.TextBox
Friend WithEvents Button3 As System.Windows.Forms.Button
<System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()
Me.Label1 = New System.Windows.Forms.Label
Me.TextBox1 = New System.Windows.Forms.TextBox
Me.Button1 = New System.Windows.Forms.Button
Me.Button2 = New System.Windows.Forms.Button
Me.Panel1 = New System.Windows.Forms.Panel
Me.ComboBox1 = New System.Windows.Forms.ComboBox
Me.Label2 = New System.Windows.Forms.Label
Me.Label3 = New System.Windows.Forms.Label
Me.TextBox2 = New System.Windows.Forms.TextBox
Me.TextBox3 = New System.Windows.Forms.TextBox
Me.Button3 = New System.Windows.Forms.Button
Me.Panel1.SuspendLayout()
Me.SuspendLayout()
'
'Label1
'
Me.Label1.Font = New System.Drawing.Font("宋体", 12.0!)
Me.Label1.Location = New System.Drawing.Point(16, 16)
Me.Label1.Name = "Label1"
Me.Label1.Size = New System.Drawing.Size(72, 23)
Me.Label1.TabIndex = 0
Me.Label1.Text = "检索类别"
'
'TextBox1
'
Me.TextBox1.Font = New System.Drawing.Font("宋体", 10.0!)
Me.TextBox1.Location = New System.Drawing.Point(184, 16)
Me.TextBox1.Name = "TextBox1"
Me.TextBox1.Size = New System.Drawing.Size(80, 23)
Me.TextBox1.TabIndex = 1
Me.TextBox1.Text = ""
'
'Button1
'
Me.Button1.Location = New System.Drawing.Point(280, 16)
Me.Button1.Name = "Button1"
Me.Button1.Size = New System.Drawing.Size(32, 23)
Me.Button1.TabIndex = 2
Me.Button1.Text = "GO"
'
'Button2
'
Me.Button2.Location = New System.Drawing.Point(304, 120)
Me.Button2.Name = "Button2"
Me.Button2.TabIndex = 3
Me.Button2.Text = "追 加"
'
'Panel1
'
Me.Panel1.BackColor = System.Drawing.SystemColors.AppWorkspace
Me.Panel1.Controls.Add(Me.ComboBox1)
Me.Panel1.Controls.Add(Me.Label1)
Me.Panel1.Controls.Add(Me.TextBox1)
Me.Panel1.Controls.Add(Me.Button1)
Me.Panel1.Location = New System.Drawing.Point(48, 32)
Me.Panel1.Name = "Panel1"
Me.Panel1.Size = New System.Drawing.Size(336, 56)
Me.Panel1.TabIndex = 1
'
'ComboBox1
'
Me.ComboBox1.Font = New System.Drawing.Font("宋体", 10.0!)
Me.ComboBox1.Items.AddRange(New Object() {"ID", "姓名", "房间ID"})
Me.ComboBox1.Location = New System.Drawing.Point(96, 16)
Me.ComboBox1.Name = "ComboBox1"
Me.ComboBox1.Size = New System.Drawing.Size(72, 21)
Me.ComboBox1.TabIndex = 0
Me.ComboBox1.Text = "房间ID"
'
'Label2
'
Me.Label2.Font = New System.Drawing.Font("宋体", 12.0!)
Me.Label2.Location = New System.Drawing.Point(48, 112)
Me.Label2.Name = "Label2"
Me.Label2.Size = New System.Drawing.Size(72, 23)
Me.Label2.TabIndex = 13
Me.Label2.Text = "追加押金"
'
'Label3
'
Me.Label3.Font = New System.Drawing.Font("宋体", 12.0!)
Me.Label3.Location = New System.Drawing.Point(48, 152)
Me.Label3.Name = "Label3"
Me.Label3.Size = New System.Drawing.Size(72, 23)
Me.Label3.TabIndex = 14
Me.Label3.Text = "当前余额"
'
'TextBox2
'
Me.TextBox2.Font = New System.Drawing.Font("宋体", 10.0!)
Me.TextBox2.Location = New System.Drawing.Point(128, 112)
Me.TextBox2.Name = "TextBox2"
Me.TextBox2.Size = New System.Drawing.Size(56, 23)
Me.TextBox2.TabIndex = 2
Me.TextBox2.Text = "100"
Me.TextBox2.TextAlign = System.Windows.Forms.HorizontalAlignment.Right
'
'TextBox3
'
Me.TextBox3.Font = New System.Drawing.Font("宋体", 12.0!, System.Drawing.FontStyle.Bold)
Me.TextBox3.Location = New System.Drawing.Point(128, 152)
Me.TextBox3.Name = "TextBox3"
Me.TextBox3.ReadOnly = True
Me.TextBox3.Size = New System.Drawing.Size(112, 26)
Me.TextBox3.TabIndex = 5
Me.TextBox3.Text = "0.0"
Me.TextBox3.TextAlign = System.Windows.Forms.HorizontalAlignment.Right
'
'Button3
'
Me.Button3.Location = New System.Drawing.Point(304, 160)
Me.Button3.Name = "Button3"
Me.Button3.TabIndex = 4
Me.Button3.Text = "退 出"
'
'yjzj
'
Me.AutoScaleBaseSize = New System.Drawing.Size(6, 14)
Me.ClientSize = New System.Drawing.Size(440, 206)
Me.ControlBox = False
Me.Controls.Add(Me.Button3)
Me.Controls.Add(Me.TextBox3)
Me.Controls.Add(Me.TextBox2)
Me.Controls.Add(Me.Label3)
Me.Controls.Add(Me.Label2)
Me.Controls.Add(Me.Panel1)
Me.Controls.Add(Me.Button2)
Me.MaximizeBox = False
Me.MinimizeBox = False
Me.Name = "yjzj"
Me.Text = "押金追加"
Me.Panel1.ResumeLayout(False)
Me.ResumeLayout(False)
End Sub
#End Region
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
Try
con.Close()
con.Open()
Dim yj As Integer
yj = CInt(TextBox3.Text)
yj = CInt(Trim(TextBox2.Text)) + yj
Dim sql As String = "update 客户信息 set 押金=" + CStr(yj) + " where " + Trim(ComboBox1.Text) + "='" + Trim(TextBox1.Text) + "'"
com = New SqlCommand(sql, con)
com.ExecuteNonQuery()
If com.ExecuteNonQuery Then
MsgBox("押金追加成功!")
TextBox3.Text = CStr(yj)
Else
MsgBox("押金追加未成功!")
End If
Catch ex As Exception
MessageBox.Show(ex.Message)
Finally
con.Close()
End Try
End Sub
Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click
Close()
End Sub
Private Sub TextBox1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles TextBox1.Click, TextBox2.Click
Select Case sender.TABindex
Case 1
TextBox1.SelectAll()
Case 2
TextBox2.SelectAll()
End Select
End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Try
con.Close()
con.Open()
Dim sql As String = "select 押金 from 客户信息 where " + Trim(ComboBox1.Text) + "='" + Trim(TextBox1.Text) + "'"
com = New SqlCommand(sql, con)
dr = com.ExecuteReader
If dr.Read Then
TextBox3.Text = dr(0)
Else
MsgBox("未找到相关信息!")
Exit Sub
End If
Catch ex As Exception
MessageBox.Show(ex.Message)
Finally
con.Close()
End Try
End Sub
Private Sub yjzj_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 + -