📄 frmobjectman.vb
字号:
Public Class frmobjectman
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 Label2 As System.Windows.Forms.Label
Friend WithEvents txt_objtype As System.Windows.Forms.TextBox
Friend WithEvents cmd_add As System.Windows.Forms.Button
Friend WithEvents cmd_delete As System.Windows.Forms.Button
Friend WithEvents cmd_modify As System.Windows.Forms.Button
Friend WithEvents cmd_cancel As System.Windows.Forms.Button
Friend WithEvents dg_objtype As System.Windows.Forms.DataGrid
<System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()
Dim resources As System.Resources.ResourceManager = New System.Resources.ResourceManager(GetType(frmobjectman))
Me.GroupBox1 = New System.Windows.Forms.GroupBox
Me.dg_objtype = New System.Windows.Forms.DataGrid
Me.Label2 = New System.Windows.Forms.Label
Me.txt_objtype = New System.Windows.Forms.TextBox
Me.cmd_add = New System.Windows.Forms.Button
Me.cmd_delete = New System.Windows.Forms.Button
Me.cmd_modify = New System.Windows.Forms.Button
Me.cmd_cancel = New System.Windows.Forms.Button
Me.GroupBox1.SuspendLayout()
CType(Me.dg_objtype, System.ComponentModel.ISupportInitialize).BeginInit()
Me.SuspendLayout()
'
'GroupBox1
'
Me.GroupBox1.Controls.Add(Me.dg_objtype)
Me.GroupBox1.Controls.Add(Me.Label2)
Me.GroupBox1.Controls.Add(Me.txt_objtype)
Me.GroupBox1.Location = New System.Drawing.Point(49, 16)
Me.GroupBox1.Name = "GroupBox1"
Me.GroupBox1.Size = New System.Drawing.Size(248, 256)
Me.GroupBox1.TabIndex = 1
Me.GroupBox1.TabStop = False
Me.GroupBox1.Text = "本题库所有题型:"
'
'dg_objtype
'
Me.dg_objtype.AlternatingBackColor = System.Drawing.Color.Lavender
Me.dg_objtype.BackColor = System.Drawing.Color.WhiteSmoke
Me.dg_objtype.BackgroundColor = System.Drawing.Color.LightGray
Me.dg_objtype.CaptionBackColor = System.Drawing.Color.LightSteelBlue
Me.dg_objtype.CaptionForeColor = System.Drawing.Color.MidnightBlue
Me.dg_objtype.DataMember = ""
Me.dg_objtype.FlatMode = True
Me.dg_objtype.Font = New System.Drawing.Font("Tahoma", 8.0!)
Me.dg_objtype.ForeColor = System.Drawing.Color.MidnightBlue
Me.dg_objtype.GridLineColor = System.Drawing.Color.Gainsboro
Me.dg_objtype.HeaderBackColor = System.Drawing.Color.MidnightBlue
Me.dg_objtype.HeaderFont = New System.Drawing.Font("Tahoma", 8.0!, System.Drawing.FontStyle.Bold)
Me.dg_objtype.HeaderForeColor = System.Drawing.Color.WhiteSmoke
Me.dg_objtype.LinkColor = System.Drawing.Color.Teal
Me.dg_objtype.Location = New System.Drawing.Point(8, 24)
Me.dg_objtype.Name = "dg_objtype"
Me.dg_objtype.ParentRowsBackColor = System.Drawing.Color.Gainsboro
Me.dg_objtype.ParentRowsForeColor = System.Drawing.Color.MidnightBlue
Me.dg_objtype.ReadOnly = True
Me.dg_objtype.SelectionBackColor = System.Drawing.Color.CadetBlue
Me.dg_objtype.SelectionForeColor = System.Drawing.Color.WhiteSmoke
Me.dg_objtype.Size = New System.Drawing.Size(232, 184)
Me.dg_objtype.TabIndex = 7
'
'Label2
'
Me.Label2.Location = New System.Drawing.Point(8, 228)
Me.Label2.Name = "Label2"
Me.Label2.Size = New System.Drawing.Size(72, 16)
Me.Label2.TabIndex = 6
Me.Label2.Text = "题型名称:"
'
'txt_objtype
'
Me.txt_objtype.Location = New System.Drawing.Point(88, 220)
Me.txt_objtype.MaxLength = 50
Me.txt_objtype.Name = "txt_objtype"
Me.txt_objtype.Size = New System.Drawing.Size(152, 21)
Me.txt_objtype.TabIndex = 5
Me.txt_objtype.Text = ""
'
'cmd_add
'
Me.cmd_add.FlatStyle = System.Windows.Forms.FlatStyle.Flat
Me.cmd_add.Location = New System.Drawing.Point(16, 288)
Me.cmd_add.Name = "cmd_add"
Me.cmd_add.Size = New System.Drawing.Size(60, 30)
Me.cmd_add.TabIndex = 2
Me.cmd_add.Text = "添 加"
'
'cmd_delete
'
Me.cmd_delete.FlatStyle = System.Windows.Forms.FlatStyle.Flat
Me.cmd_delete.Location = New System.Drawing.Point(101, 288)
Me.cmd_delete.Name = "cmd_delete"
Me.cmd_delete.Size = New System.Drawing.Size(60, 30)
Me.cmd_delete.TabIndex = 3
Me.cmd_delete.Text = "删 除"
'
'cmd_modify
'
Me.cmd_modify.FlatStyle = System.Windows.Forms.FlatStyle.Flat
Me.cmd_modify.Location = New System.Drawing.Point(186, 288)
Me.cmd_modify.Name = "cmd_modify"
Me.cmd_modify.Size = New System.Drawing.Size(60, 30)
Me.cmd_modify.TabIndex = 4
Me.cmd_modify.Text = "修 改"
'
'cmd_cancel
'
Me.cmd_cancel.FlatStyle = System.Windows.Forms.FlatStyle.Flat
Me.cmd_cancel.Location = New System.Drawing.Point(271, 288)
Me.cmd_cancel.Name = "cmd_cancel"
Me.cmd_cancel.Size = New System.Drawing.Size(60, 30)
Me.cmd_cancel.TabIndex = 5
Me.cmd_cancel.Text = "返 回"
'
'frmobjectman
'
Me.AutoScaleBaseSize = New System.Drawing.Size(6, 14)
Me.ClientSize = New System.Drawing.Size(346, 335)
Me.Controls.Add(Me.cmd_cancel)
Me.Controls.Add(Me.cmd_modify)
Me.Controls.Add(Me.cmd_delete)
Me.Controls.Add(Me.cmd_add)
Me.Controls.Add(Me.GroupBox1)
Me.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedSingle
Me.Icon = CType(resources.GetObject("$this.Icon"), System.Drawing.Icon)
Me.MaximizeBox = False
Me.Name = "frmobjectman"
Me.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen
Me.Text = "题型设置"
Me.GroupBox1.ResumeLayout(False)
CType(Me.dg_objtype, System.ComponentModel.ISupportInitialize).EndInit()
Me.ResumeLayout(False)
End Sub
#End Region
Dim dbset As DataSet
Private Sub cmd_cancel_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmd_cancel.Click
Me.Close()
End Sub
Private Sub frmobjectman_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
CurObjtType.Initials()
MyObjtType.Initials()
dbset = MyObjtType.LoadObjTypes()
If Not dbset Is Nothing Then
dg_objtype.DataSource = dbset.Tables(0).DefaultView
dg_objtype.CaptionText = "题型信息"
End If
End Sub
Private Sub dg_objtype_CurrentCellChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles dg_objtype.CurrentCellChanged
If dg_objtype.Item(dg_objtype.CurrentRowIndex, 0) Is Nothing Then
Exit Sub
End If
txt_objtype.Text = dg_objtype.Item(dg_objtype.CurrentRowIndex, 1)
MyObjtType.GetInfo(MakeStr(txt_objtype.Text))
CurObjtType.Equal(MyObjtType)
End Sub
Private Sub cmd_add_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmd_add.Click
If Trim(txt_objtype.Text) = "" Then
MsgBox("题型名称不能为空", MsgBoxStyle.Exclamation, "翼清测试题库系统V1.0")
txt_objtype.Focus()
Exit Sub
End If
If MyObjtType.IsInDB(MakeStr(txt_objtype.Text)) Then
MsgBox("题型名称[" & Trim(txt_objtype.Text) & "]已经存在", MsgBoxStyle.Exclamation, "翼清测试题库系统V1.0")
MyObjtType.Initials()
txt_objtype.Text = ""
txt_objtype.Focus()
Exit Sub
End If
MyObjtType.ObjectTypeID = MyObjtType.GetNewID
MyObjtType.ObjectTypeName = MakeStr(txt_objtype.Text)
MyObjtType.InsertDB()
CurObjtType.Equal(MyObjtType)
dbset = MyObjtType.LoadObjTypes()
If Not dbset Is Nothing Then
dg_objtype.DataSource = dbset.Tables(0).DefaultView
dg_objtype.CaptionText = "题型信息"
End If
End Sub
Private Sub cmd_delete_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmd_delete.Click
If CurObjtType.ObjectTypeID <= 0 Then
MsgBox("请选择您要删除的记录不能为空", MsgBoxStyle.Exclamation, "翼清测试题库系统V1.0")
Exit Sub
End If
If MyObjtType.HaveChild(CurObjtType.ObjectTypeID) Then
MsgBox("题型[" & CurObjtType.ObjectTypeName & "]存在试题,请先删除该类型试题", MsgBoxStyle.Exclamation, "翼清测试题库系统V1.0")
Exit Sub
End If
If MsgBox("您是否真的要删除题型[" & CurObjtType.ObjectTypeName & "]", MsgBoxStyle.YesNo + MsgBoxStyle.Exclamation, "翼清测试题库系统V1.0") = MsgBoxResult.Yes Then
MyObjtType.ObjectTypeID = CurObjtType.ObjectTypeID
If MyObjtType.Delete() Then
CurObjtType.Initials()
dbset = MyObjtType.LoadObjTypes()
txt_objtype.Text = ""
If Not dbset Is Nothing Then
dg_objtype.DataSource = dbset.Tables(0).DefaultView
dg_objtype.CaptionText = "题型信息"
End If
End If
End If
End Sub
Private Sub cmd_modify_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmd_modify.Click
If CurObjtType.ObjectTypeID <= 0 Then
MsgBox("请选择您要删除的记录不能为空", MsgBoxStyle.Exclamation, "翼清测试题库系统V1.0")
Exit Sub
End If
If Trim(txt_objtype.Text) = "" Then
MsgBox("题型名称不能为空", MsgBoxStyle.Exclamation, "翼清测试题库系统V1.0")
txt_objtype.Focus()
Exit Sub
End If
If CurObjtType.ObjectTypeName = Trim(txt_objtype.Text) Then
Exit Sub
End If
If MyObjtType.IsInDB(MakeStr(txt_objtype.Text)) Then
MsgBox("题型名称[" & Trim(txt_objtype.Text) & "]已经存在", MsgBoxStyle.Exclamation, "翼清测试题库系统V1.0")
txt_objtype.Text = CurObjtType.ObjectTypeName
Exit Sub
End If
MyObjtType.ObjectTypeID = CurObjtType.ObjectTypeID
MyObjtType.ObjectTypeName = MakeStr(txt_objtype.Text)
If MyObjtType.Modify() Then
CurObjtType.Equal(MyObjtType)
dg_objtype.Item(dg_objtype.CurrentRowIndex, 1) = CurObjtType.ObjectTypeName
End If
End Sub
Private Sub frmobjectman_Closing(ByVal sender As Object, ByVal e As System.ComponentModel.CancelEventArgs) Handles MyBase.Closing
CurObjtType.Initials()
MyObjtType.Initials()
End Sub
End Class
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -