📄 frmlibinfo.vb
字号:
Imports System.Data.SqlClient
Public Class frmLibInfo
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 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 Label4 As System.Windows.Forms.Label
Friend WithEvents Label5 As System.Windows.Forms.Label
Friend WithEvents Label6 As System.Windows.Forms.Label
Friend WithEvents btnExit As System.Windows.Forms.Button
Friend WithEvents btnSet As System.Windows.Forms.Button
Friend WithEvents P1txtLib_adr As library.mytextbox
Friend WithEvents P1txtLib_tel As library.mytextbox
Friend WithEvents P1txtLib_org As library.mytextbox
Friend WithEvents P1txtLib_name As library.mytextbox
<System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()
Me.GroupBox1 = New System.Windows.Forms.GroupBox
Me.btnExit = New System.Windows.Forms.Button
Me.btnSet = New System.Windows.Forms.Button
Me.Label4 = New System.Windows.Forms.Label
Me.P1txtLib_adr = New library.mytextbox
Me.Label3 = New System.Windows.Forms.Label
Me.P1txtLib_tel = New library.mytextbox
Me.Label2 = New System.Windows.Forms.Label
Me.P1txtLib_org = New library.mytextbox
Me.Label1 = New System.Windows.Forms.Label
Me.P1txtLib_name = New library.mytextbox
Me.Label5 = New System.Windows.Forms.Label
Me.Label6 = New System.Windows.Forms.Label
Me.GroupBox1.SuspendLayout()
Me.SuspendLayout()
'
'GroupBox1
'
Me.GroupBox1.Controls.Add(Me.btnExit)
Me.GroupBox1.Controls.Add(Me.btnSet)
Me.GroupBox1.Controls.Add(Me.Label4)
Me.GroupBox1.Controls.Add(Me.P1txtLib_adr)
Me.GroupBox1.Controls.Add(Me.Label3)
Me.GroupBox1.Controls.Add(Me.P1txtLib_tel)
Me.GroupBox1.Controls.Add(Me.Label2)
Me.GroupBox1.Controls.Add(Me.P1txtLib_org)
Me.GroupBox1.Controls.Add(Me.Label1)
Me.GroupBox1.Controls.Add(Me.P1txtLib_name)
Me.GroupBox1.Dock = System.Windows.Forms.DockStyle.Bottom
Me.GroupBox1.Location = New System.Drawing.Point(0, 109)
Me.GroupBox1.Name = "GroupBox1"
Me.GroupBox1.Size = New System.Drawing.Size(408, 248)
Me.GroupBox1.TabIndex = 0
Me.GroupBox1.TabStop = False
Me.GroupBox1.Text = "图书馆信息"
'
'btnExit
'
Me.btnExit.Location = New System.Drawing.Point(224, 216)
Me.btnExit.Name = "btnExit"
Me.btnExit.Size = New System.Drawing.Size(80, 24)
Me.btnExit.TabIndex = 1
Me.btnExit.Text = "退出(&X)"
'
'btnSet
'
Me.btnSet.Location = New System.Drawing.Point(80, 216)
Me.btnSet.Name = "btnSet"
Me.btnSet.Size = New System.Drawing.Size(80, 24)
Me.btnSet.TabIndex = 0
Me.btnSet.Text = "设定(&S)"
'
'Label4
'
Me.Label4.Location = New System.Drawing.Point(16, 120)
Me.Label4.Name = "Label4"
Me.Label4.Size = New System.Drawing.Size(88, 21)
Me.Label4.TabIndex = 7
Me.Label4.Text = "详细地址:"
'
'P1txtLib_adr
'
Me.P1txtLib_adr.Location = New System.Drawing.Point(112, 120)
Me.P1txtLib_adr.Multiline = True
Me.P1txtLib_adr.Name = "P1txtLib_adr"
Me.P1txtLib_adr.ScrollBars = System.Windows.Forms.ScrollBars.Vertical
Me.P1txtLib_adr.Size = New System.Drawing.Size(272, 80)
Me.P1txtLib_adr.TabIndex = 5
Me.P1txtLib_adr.Text = ""
'
'Label3
'
Me.Label3.Location = New System.Drawing.Point(16, 88)
Me.Label3.Name = "Label3"
Me.Label3.Size = New System.Drawing.Size(88, 21)
Me.Label3.TabIndex = 5
Me.Label3.Text = "电话号码:"
'
'P1txtLib_tel
'
Me.P1txtLib_tel.Location = New System.Drawing.Point(112, 88)
Me.P1txtLib_tel.Name = "P1txtLib_tel"
Me.P1txtLib_tel.Size = New System.Drawing.Size(272, 21)
Me.P1txtLib_tel.TabIndex = 4
Me.P1txtLib_tel.Text = ""
'
'Label2
'
Me.Label2.Location = New System.Drawing.Point(16, 56)
Me.Label2.Name = "Label2"
Me.Label2.Size = New System.Drawing.Size(88, 21)
Me.Label2.TabIndex = 3
Me.Label2.Text = "隶属单位:"
'
'P1txtLib_org
'
Me.P1txtLib_org.Location = New System.Drawing.Point(112, 56)
Me.P1txtLib_org.Name = "P1txtLib_org"
Me.P1txtLib_org.Size = New System.Drawing.Size(272, 21)
Me.P1txtLib_org.TabIndex = 3
Me.P1txtLib_org.Text = ""
'
'Label1
'
Me.Label1.Location = New System.Drawing.Point(16, 24)
Me.Label1.Name = "Label1"
Me.Label1.Size = New System.Drawing.Size(88, 21)
Me.Label1.TabIndex = 1
Me.Label1.Text = "图书馆名称:"
'
'P1txtLib_name
'
Me.P1txtLib_name.Location = New System.Drawing.Point(112, 24)
Me.P1txtLib_name.Name = "P1txtLib_name"
Me.P1txtLib_name.Size = New System.Drawing.Size(272, 21)
Me.P1txtLib_name.TabIndex = 2
Me.P1txtLib_name.Text = ""
'
'Label5
'
Me.Label5.AutoSize = True
Me.Label5.Font = New System.Drawing.Font("幼圆", 14.25!, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, CType(134, Byte))
Me.Label5.ForeColor = System.Drawing.SystemColors.ControlText
Me.Label5.Location = New System.Drawing.Point(73, 24)
Me.Label5.Name = "Label5"
Me.Label5.Size = New System.Drawing.Size(262, 24)
Me.Label5.TabIndex = 1
Me.Label5.Text = "欢迎使用图书馆管理信息系统"
Me.Label5.TextAlign = System.Drawing.ContentAlignment.MiddleCenter
'
'Label6
'
Me.Label6.AutoSize = True
Me.Label6.BackColor = System.Drawing.SystemColors.ActiveCaption
Me.Label6.ForeColor = System.Drawing.Color.FromArgb(CType(255, Byte), CType(255, Byte), CType(128, Byte))
Me.Label6.Location = New System.Drawing.Point(116, 72)
Me.Label6.Name = "Label6"
Me.Label6.Size = New System.Drawing.Size(177, 17)
Me.Label6.TabIndex = 2
Me.Label6.Text = "请输入您的详细资料以方便管理"
'
'frmLibInfo
'
Me.AutoScaleBaseSize = New System.Drawing.Size(6, 14)
Me.ClientSize = New System.Drawing.Size(408, 357)
Me.Controls.Add(Me.Label6)
Me.Controls.Add(Me.Label5)
Me.Controls.Add(Me.GroupBox1)
Me.FormBorderStyle = System.Windows.Forms.FormBorderStyle.Fixed3D
Me.MaximizeBox = False
Me.MinimizeBox = False
Me.Name = "frmLibInfo"
Me.ShowInTaskbar = False
Me.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent
Me.Text = "图书馆信息维护"
Me.GroupBox1.ResumeLayout(False)
Me.ResumeLayout(False)
End Sub
#End Region
Private Sub btnSet_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnSet.Click
Me.P1UpdateData()
End Sub
'将数据库内容显示到文本诓上
Private Function P1Databind()
Dim cn As New SqlClient.SqlConnection(cnstr)
Dim cmd As New SqlCommand
Dim dr As SqlDataReader
With cmd
.CommandText = "select * from libInfo"
.CommandType = CommandType.Text
.Connection = cn
End With
Try
cn.Open()
dr = cmd.ExecuteReader(CommandBehavior.SingleRow)
While dr.Read
Me.P1txtLib_name.Text = dr.Item("Lib_name")
Me.P1txtLib_adr.Text = dr.Item("Lib_adr")
Me.P1txtLib_org.Text = dr.Item("Lib_org")
Me.P1txtLib_tel.Text = dr.Item("Lib_tel")
End While
Catch ex As Exception
MessageBox.Show(ex.Message)
Finally
dr.Close()
cn.Close()
If Not cn Is Nothing Then
cn.Dispose()
End If
End Try
End Function
'将文本诓内容回写到数据库里
Private Function P1UpdateData()
Dim cn As New SqlClient.SqlConnection(cnstr)
Dim cmd As New SqlCommand
Dim dr As SqlDataReader
With cmd
.CommandText = "UPDATE libInfo " + _
"SET Lib_name = @Lib_name, Lib_org = @Lib_org, Lib_tel = @Lib_tel," + _
"Lib_adr = @Lib_adr " + _
"WHERE (No = 1)"
.CommandType = CommandType.Text
.Connection = cn
End With
Dim mLib_name As New SqlParameter("@Lib_name", SqlDbType.NVarChar)
Dim mLib_adr As New SqlParameter("@Lib_adr", SqlDbType.NVarChar)
Dim mLib_org As New SqlParameter("@Lib_org", SqlDbType.NVarChar)
Dim mLib_tel As New SqlParameter("@Lib_tel", SqlDbType.NVarChar)
With cmd.Parameters
.Add(mLib_name)
.Add(mLib_adr)
.Add(mLib_org)
.Add(mLib_tel)
End With
mLib_name.Value = Me.P1txtLib_name.Text.Trim
mLib_adr.Value = Me.P1txtLib_adr.Text.Trim
mLib_org.Value = Me.P1txtLib_org.Text.Trim
mLib_tel.Value = Me.P1txtLib_tel.Text.Trim
Try
cn.Open()
cmd.ExecuteNonQuery()
MessageBox.Show("修改成功", "success", MessageBoxButtons.OK, MessageBoxIcon.Information)
Catch ex As Exception
MessageBox.Show(ex.Message)
Finally
cn.Close()
If Not cn Is Nothing Then
cn.Dispose()
End If
End Try
End Function
Private Sub frmLibInfo_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles MyBase.Load
Me.SuspendLayout()
Me.P1Databind()
Me.ResumeLayout()
End Sub
Private Sub btnExit_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnExit.Click
Me.Close()
End Sub
End Class
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -