📄 options.vb
字号:
Imports System.Data.SqlClient
Public Class options
Inherits System.Windows.Forms.Form
Dim cn As New SqlConnection("server=localhost;database=lms;uid=sa;password=;")
Dim cmd As SqlCommand
Dim f_charge As Integer
#Region " Windows Form Designer generated code "
Public Sub New()
MyBase.New()
'This call is required by the Windows Form Designer.
InitializeComponent()
'Add any initialization after the InitializeComponent() call
End Sub
'Form overrides dispose to clean up the component list.
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
'Required by the Windows Form Designer
Private components As System.ComponentModel.IContainer
'NOTE: The following procedure is required by the Windows Form Designer
'It can be modified using the Windows Form Designer.
'Do not modify it using the code editor.
Friend WithEvents btn_add As System.Windows.Forms.Button
Friend WithEvents btn_remove As System.Windows.Forms.Button
Friend WithEvents lbl_name As System.Windows.Forms.Label
Friend WithEvents txt_name As System.Windows.Forms.TextBox
Friend WithEvents lbl_studid As System.Windows.Forms.Label
Friend WithEvents Label1 As System.Windows.Forms.Label
Friend WithEvents Label2 As System.Windows.Forms.Label
Friend WithEvents txt_charge As System.Windows.Forms.TextBox
<System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()
Me.btn_add = New System.Windows.Forms.Button
Me.btn_remove = New System.Windows.Forms.Button
Me.lbl_name = New System.Windows.Forms.Label
Me.txt_name = New System.Windows.Forms.TextBox
Me.lbl_studid = New System.Windows.Forms.Label
Me.txt_charge = New System.Windows.Forms.TextBox
Me.Label1 = New System.Windows.Forms.Label
Me.Label2 = New System.Windows.Forms.Label
Me.SuspendLayout()
'
'btn_add
'
Me.btn_add.Font = New System.Drawing.Font("Tahoma", 8.25!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
Me.btn_add.ForeColor = System.Drawing.SystemColors.ControlText
Me.btn_add.Location = New System.Drawing.Point(64, 96)
Me.btn_add.Name = "btn_add"
Me.btn_add.Size = New System.Drawing.Size(56, 23)
Me.btn_add.TabIndex = 21
Me.btn_add.Text = "OK"
'
'btn_remove
'
Me.btn_remove.Font = New System.Drawing.Font("Tahoma", 8.25!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
Me.btn_remove.ForeColor = System.Drawing.SystemColors.ControlText
Me.btn_remove.Location = New System.Drawing.Point(136, 96)
Me.btn_remove.Name = "btn_remove"
Me.btn_remove.Size = New System.Drawing.Size(56, 23)
Me.btn_remove.TabIndex = 22
Me.btn_remove.Text = "Cancel"
'
'lbl_name
'
Me.lbl_name.AutoSize = True
Me.lbl_name.Font = New System.Drawing.Font("Tahoma", 8.25!, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
Me.lbl_name.ForeColor = System.Drawing.Color.Navy
Me.lbl_name.Location = New System.Drawing.Point(24, 58)
Me.lbl_name.Name = "lbl_name"
Me.lbl_name.Size = New System.Drawing.Size(95, 17)
Me.lbl_name.TabIndex = 20
Me.lbl_name.Text = "Books Allowed :"
'
'txt_name
'
Me.txt_name.Enabled = False
Me.txt_name.Font = New System.Drawing.Font("Tahoma", 8.25!, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
Me.txt_name.Location = New System.Drawing.Point(120, 56)
Me.txt_name.Name = "txt_name"
Me.txt_name.Size = New System.Drawing.Size(48, 21)
Me.txt_name.TabIndex = 19
Me.txt_name.Text = "1"
'
'lbl_studid
'
Me.lbl_studid.AutoSize = True
Me.lbl_studid.Font = New System.Drawing.Font("Tahoma", 8.25!, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
Me.lbl_studid.ForeColor = System.Drawing.Color.Navy
Me.lbl_studid.Location = New System.Drawing.Point(24, 27)
Me.lbl_studid.Name = "lbl_studid"
Me.lbl_studid.Size = New System.Drawing.Size(85, 17)
Me.lbl_studid.TabIndex = 17
Me.lbl_studid.Text = "Fine Charges :"
'
'txt_charge
'
Me.txt_charge.Font = New System.Drawing.Font("Tahoma", 8.25!, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
Me.txt_charge.Location = New System.Drawing.Point(120, 24)
Me.txt_charge.Name = "txt_charge"
Me.txt_charge.Size = New System.Drawing.Size(48, 21)
Me.txt_charge.TabIndex = 18
Me.txt_charge.Text = "1"
'
'Label1
'
Me.Label1.AutoSize = True
Me.Label1.Font = New System.Drawing.Font("Tahoma", 8.25!, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
Me.Label1.Location = New System.Drawing.Point(168, 28)
Me.Label1.Name = "Label1"
Me.Label1.Size = New System.Drawing.Size(71, 17)
Me.Label1.TabIndex = 23
Me.Label1.Text = "Rs. per day."
'
'Label2
'
Me.Label2.AutoSize = True
Me.Label2.Font = New System.Drawing.Font("Tahoma", 8.25!, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
Me.Label2.Location = New System.Drawing.Point(168, 61)
Me.Label2.Name = "Label2"
Me.Label2.Size = New System.Drawing.Size(74, 17)
Me.Label2.TabIndex = 24
Me.Label2.Text = "Per student."
'
'options
'
Me.AcceptButton = Me.btn_add
Me.AutoScaleBaseSize = New System.Drawing.Size(5, 13)
Me.BackColor = System.Drawing.Color.Silver
Me.ClientSize = New System.Drawing.Size(264, 141)
Me.Controls.Add(Me.Label2)
Me.Controls.Add(Me.Label1)
Me.Controls.Add(Me.btn_add)
Me.Controls.Add(Me.btn_remove)
Me.Controls.Add(Me.lbl_name)
Me.Controls.Add(Me.txt_name)
Me.Controls.Add(Me.lbl_studid)
Me.Controls.Add(Me.txt_charge)
Me.MaximizeBox = False
Me.MinimizeBox = False
Me.Name = "options"
Me.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen
Me.Text = "Options"
Me.ResumeLayout(False)
End Sub
#End Region
Private Sub btn_add_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btn_add.Click
cmd = New SqlCommand
cmd.Connection = cn
cmd.CommandText = "delete from options;insert into options values(" & txt_charge.Text & ",1)"
cmd.ExecuteNonQuery()
cmd.Dispose()
MessageBox.Show("Fine Charge successfully changed!!", "LMS", MessageBoxButtons.OK, MessageBoxIcon.Information)
Me.Close()
End Sub
Private Sub btn_remove_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btn_remove.Click
Me.Close()
End Sub
Private Sub options_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Me.Show()
Application.DoEvents()
Try
cn.Open()
cmd = New SqlCommand
With cmd
.Connection = cn
.CommandText = "select F_Charge from options"
End With
' storing fine charge in a variable
f_charge = CType(cmd.ExecuteScalar, Integer)
txt_charge.Text = f_charge
Catch ex As SqlException
MessageBox.Show(ex.Message, "LMS", MessageBoxButtons.OK, MessageBoxIcon.Error)
cmd = Nothing
End Try
End Sub
Private Sub options_Closing(ByVal sender As Object, ByVal e As System.ComponentModel.CancelEventArgs) Handles MyBase.Closing
cn.Close()
End Sub
End Class
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -