📄 frmaulost.vb
字号:
Imports System.Data.SqlClient
Public Class frmAuLost
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 MonthCalendar1 As System.Windows.Forms.MonthCalendar
Friend WithEvents GroupBox2 As System.Windows.Forms.GroupBox
Friend WithEvents Label1 As System.Windows.Forms.Label
Friend WithEvents txtAu_id As library.mytextbox
Friend WithEvents dbgAuLost As System.Windows.Forms.DataGrid
Friend WithEvents btnDelLost As System.Windows.Forms.Button
Friend WithEvents btnAddlost As System.Windows.Forms.Button
Friend WithEvents Label2 As System.Windows.Forms.Label
<System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()
Me.GroupBox1 = New System.Windows.Forms.GroupBox
Me.dbgAuLost = New System.Windows.Forms.DataGrid
Me.MonthCalendar1 = New System.Windows.Forms.MonthCalendar
Me.GroupBox2 = New System.Windows.Forms.GroupBox
Me.btnDelLost = New System.Windows.Forms.Button
Me.btnAddlost = New System.Windows.Forms.Button
Me.Label1 = New System.Windows.Forms.Label
Me.txtAu_id = New library.mytextbox
Me.Label2 = New System.Windows.Forms.Label
Me.GroupBox1.SuspendLayout()
CType(Me.dbgAuLost, System.ComponentModel.ISupportInitialize).BeginInit()
Me.GroupBox2.SuspendLayout()
Me.SuspendLayout()
'
'GroupBox1
'
Me.GroupBox1.Controls.Add(Me.dbgAuLost)
Me.GroupBox1.Location = New System.Drawing.Point(8, 0)
Me.GroupBox1.Name = "GroupBox1"
Me.GroupBox1.Size = New System.Drawing.Size(568, 280)
Me.GroupBox1.TabIndex = 0
Me.GroupBox1.TabStop = False
Me.GroupBox1.Text = "图书证丢失读者列表"
'
'dbgAuLost
'
Me.dbgAuLost.AllowNavigation = False
Me.dbgAuLost.BackgroundColor = System.Drawing.SystemColors.Info
Me.dbgAuLost.CaptionVisible = False
Me.dbgAuLost.DataMember = ""
Me.dbgAuLost.Dock = System.Windows.Forms.DockStyle.Fill
Me.dbgAuLost.ForeColor = System.Drawing.SystemColors.ControlText
Me.dbgAuLost.HeaderForeColor = System.Drawing.SystemColors.ControlText
Me.dbgAuLost.Location = New System.Drawing.Point(3, 17)
Me.dbgAuLost.Name = "dbgAuLost"
Me.dbgAuLost.ReadOnly = True
Me.dbgAuLost.Size = New System.Drawing.Size(562, 260)
Me.dbgAuLost.TabIndex = 0
'
'MonthCalendar1
'
Me.MonthCalendar1.Location = New System.Drawing.Point(8, 280)
Me.MonthCalendar1.Name = "MonthCalendar1"
Me.MonthCalendar1.TabIndex = 1
'
'GroupBox2
'
Me.GroupBox2.Controls.Add(Me.Label2)
Me.GroupBox2.Controls.Add(Me.btnDelLost)
Me.GroupBox2.Controls.Add(Me.btnAddlost)
Me.GroupBox2.Controls.Add(Me.Label1)
Me.GroupBox2.Controls.Add(Me.txtAu_id)
Me.GroupBox2.Location = New System.Drawing.Point(288, 280)
Me.GroupBox2.Name = "GroupBox2"
Me.GroupBox2.Size = New System.Drawing.Size(288, 144)
Me.GroupBox2.TabIndex = 0
Me.GroupBox2.TabStop = False
Me.GroupBox2.Text = "事务处理"
'
'btnDelLost
'
Me.btnDelLost.Enabled = False
Me.btnDelLost.Location = New System.Drawing.Point(160, 104)
Me.btnDelLost.Name = "btnDelLost"
Me.btnDelLost.Size = New System.Drawing.Size(64, 24)
Me.btnDelLost.TabIndex = 2
Me.btnDelLost.Text = "解挂"
'
'btnAddlost
'
Me.btnAddlost.Location = New System.Drawing.Point(56, 104)
Me.btnAddlost.Name = "btnAddlost"
Me.btnAddlost.Size = New System.Drawing.Size(64, 24)
Me.btnAddlost.TabIndex = 1
Me.btnAddlost.Text = "挂失"
'
'Label1
'
Me.Label1.Location = New System.Drawing.Point(16, 64)
Me.Label1.Name = "Label1"
Me.Label1.Size = New System.Drawing.Size(80, 16)
Me.Label1.TabIndex = 1
Me.Label1.Text = "图书证号:"
'
'txtAu_id
'
Me.txtAu_id.Location = New System.Drawing.Point(112, 64)
Me.txtAu_id.Name = "txtAu_id"
Me.txtAu_id.Size = New System.Drawing.Size(160, 21)
Me.txtAu_id.TabIndex = 0
Me.txtAu_id.Text = ""
'
'Label2
'
Me.Label2.BackColor = System.Drawing.SystemColors.Info
Me.Label2.Location = New System.Drawing.Point(16, 24)
Me.Label2.Name = "Label2"
Me.Label2.Size = New System.Drawing.Size(248, 16)
Me.Label2.TabIndex = 4
Me.Label2.Text = "在图书证丢失读者列表中单击可以进行定位"
'
'frmAuLost
'
Me.AutoScaleBaseSize = New System.Drawing.Size(6, 14)
Me.ClientSize = New System.Drawing.Size(584, 429)
Me.Controls.Add(Me.GroupBox2)
Me.Controls.Add(Me.MonthCalendar1)
Me.Controls.Add(Me.GroupBox1)
Me.FormBorderStyle = System.Windows.Forms.FormBorderStyle.Fixed3D
Me.MaximizeBox = False
Me.MinimizeBox = False
Me.Name = "frmAuLost"
Me.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent
Me.Text = "图书证挂失管理"
Me.GroupBox1.ResumeLayout(False)
CType(Me.dbgAuLost, System.ComponentModel.ISupportInitialize).EndInit()
Me.GroupBox2.ResumeLayout(False)
Me.ResumeLayout(False)
End Sub
#End Region
Private Sub frmAuLost_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
databind()
End Sub
Function databind()
Dim cn As New SqlConnection(cnstr)
Dim da As New SqlDataAdapter
Dim cmd As New SqlCommand
Dim ds As New DataSet
With cmd
.CommandType = CommandType.StoredProcedure
.Connection = cn
.CommandText = "SelectAllLostAu"
End With
da.SelectCommand = cmd
Try
da.Fill(ds)
Me.dbgAuLost.DataSource = ds.Tables(0)
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 dbgAuLost_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles dbgAuLost.Click
If sender.CurrentRowIndex <> -1 Then
txtAu_id.Text = sender.Item(sender.CurrentRowIndex, 1)
Me.btnDelLost.Enabled = True
End If
End Sub
Private Sub btnAddlost_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnAddlost.Click
If Me.txtAu_id.Text.Trim = "" Then
MessageBox.Show("请输入完整信息", "error", MessageBoxButtons.OK, MessageBoxIcon.Exclamation)
txtAu_id.Focus()
Exit Sub
End If
Dim cn As New SqlConnection(cnstr)
'Dim da As New SqlDataAdapter
Dim cmd As New SqlCommand
'Dim ds As New DataSet
With cmd
.CommandType = CommandType.StoredProcedure
.Connection = cn
.CommandText = "Insert1aulost"
End With
'da.SelectCommand = cmd
Dim mLost_id As New SqlParameter("@Lost_id", SqlDbType.NVarChar, 50)
mLost_id.Value = Me.txtAu_id.Text.Trim
cmd.Parameters.Add(mLost_id)
Try
cn.Open()
cmd.ExecuteNonQuery()
Me.databind()
Catch ex As Exception
MessageBox.Show(ex.Message)
Finally
cn.Close()
If Not cn Is Nothing Then
cn.Dispose()
End If
End Try
End Sub
Private Sub btnDelLost_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnDelLost.Click
Dim cn As New SqlConnection(cnstr)
'Dim da As New SqlDataAdapter
Dim cmd As New SqlCommand
'Dim ds As New DataSet
With cmd
.CommandType = CommandType.StoredProcedure
.Connection = cn
.CommandText = "Delete1aulost"
End With
'da.SelectCommand = cmd
Dim mLost_id As New SqlParameter("@Lost_id", SqlDbType.NVarChar, 50)
mLost_id.Value = Me.txtAu_id.Text.Trim
cmd.Parameters.Add(mLost_id)
Try
cn.Open()
cmd.ExecuteNonQuery()
Me.databind()
btnDelLost.Enabled = False
Catch ex As Exception
MessageBox.Show(ex.Message)
Finally
cn.Close()
If Not cn Is Nothing Then
cn.Dispose()
End If
End Try
End Sub
End Class
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -