📄 addclass.vb
字号:
Imports System.Data
Imports System.Data.sqlClient
Public Class AddClass
Inherits System.Windows.Forms.Form
Dim i As Integer
#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 Label2 As System.Windows.Forms.Label
Friend WithEvents Label3 As System.Windows.Forms.Label
Friend WithEvents TextBox1 As System.Windows.Forms.TextBox
Friend WithEvents TextBox2 As System.Windows.Forms.TextBox
Friend WithEvents Button1 As System.Windows.Forms.Button
Friend WithEvents Button3 As System.Windows.Forms.Button
Friend WithEvents Button4 As System.Windows.Forms.Button
Friend WithEvents Button2 As System.Windows.Forms.Button
Friend WithEvents ComboBox1 As System.Windows.Forms.ComboBox
<System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()
Me.Label1 = New System.Windows.Forms.Label
Me.Label2 = New System.Windows.Forms.Label
Me.Label3 = New System.Windows.Forms.Label
Me.TextBox1 = New System.Windows.Forms.TextBox
Me.TextBox2 = New System.Windows.Forms.TextBox
Me.Button1 = New System.Windows.Forms.Button
Me.Button3 = New System.Windows.Forms.Button
Me.Button4 = New System.Windows.Forms.Button
Me.Button2 = New System.Windows.Forms.Button
Me.ComboBox1 = New System.Windows.Forms.ComboBox
Me.SuspendLayout()
'
'Label1
'
Me.Label1.Font = New System.Drawing.Font("宋体", 14.25!, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, CType(134, Byte))
Me.Label1.Location = New System.Drawing.Point(152, 40)
Me.Label1.Name = "Label1"
Me.Label1.Size = New System.Drawing.Size(120, 23)
Me.Label1.TabIndex = 0
Me.Label1.Text = "添加资产类型"
'
'Label2
'
Me.Label2.Location = New System.Drawing.Point(64, 96)
Me.Label2.Name = "Label2"
Me.Label2.TabIndex = 1
Me.Label2.Text = "资产类型名:"
'
'Label3
'
Me.Label3.Location = New System.Drawing.Point(64, 144)
Me.Label3.Name = "Label3"
Me.Label3.TabIndex = 2
Me.Label3.Text = "资产类代号:"
'
'TextBox1
'
Me.TextBox1.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle
Me.TextBox1.Location = New System.Drawing.Point(168, 96)
Me.TextBox1.Name = "TextBox1"
Me.TextBox1.TabIndex = 3
Me.TextBox1.Text = ""
'
'TextBox2
'
Me.TextBox2.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle
Me.TextBox2.Location = New System.Drawing.Point(168, 144)
Me.TextBox2.Name = "TextBox2"
Me.TextBox2.TabIndex = 4
Me.TextBox2.Text = ""
'
'Button1
'
Me.Button1.Location = New System.Drawing.Point(288, 144)
Me.Button1.Name = "Button1"
Me.Button1.Size = New System.Drawing.Size(48, 24)
Me.Button1.TabIndex = 5
Me.Button1.Text = "检测"
'
'Button3
'
Me.Button3.Enabled = False
Me.Button3.Location = New System.Drawing.Point(72, 208)
Me.Button3.Name = "Button3"
Me.Button3.Size = New System.Drawing.Size(56, 23)
Me.Button3.TabIndex = 7
Me.Button3.Text = "确 定"
'
'Button4
'
Me.Button4.Location = New System.Drawing.Point(184, 208)
Me.Button4.Name = "Button4"
Me.Button4.Size = New System.Drawing.Size(56, 23)
Me.Button4.TabIndex = 8
Me.Button4.Text = "清 空"
'
'Button2
'
Me.Button2.Location = New System.Drawing.Point(288, 208)
Me.Button2.Name = "Button2"
Me.Button2.Size = New System.Drawing.Size(56, 23)
Me.Button2.TabIndex = 9
Me.Button2.Text = "关 闭"
'
'ComboBox1
'
Me.ComboBox1.Location = New System.Drawing.Point(184, 184)
Me.ComboBox1.Name = "ComboBox1"
Me.ComboBox1.Size = New System.Drawing.Size(0, 20)
Me.ComboBox1.TabIndex = 10
Me.ComboBox1.Text = "ComboBox1"
'
'AddClass
'
Me.AutoScaleBaseSize = New System.Drawing.Size(6, 14)
Me.ClientSize = New System.Drawing.Size(408, 262)
Me.Controls.Add(Me.ComboBox1)
Me.Controls.Add(Me.Button2)
Me.Controls.Add(Me.Button4)
Me.Controls.Add(Me.Button3)
Me.Controls.Add(Me.Button1)
Me.Controls.Add(Me.TextBox2)
Me.Controls.Add(Me.TextBox1)
Me.Controls.Add(Me.Label3)
Me.Controls.Add(Me.Label2)
Me.Controls.Add(Me.Label1)
Me.MaximizeBox = False
Me.Name = "AddClass"
Me.Text = "---------添加资产类"
Me.ResumeLayout(False)
End Sub
#End Region
Private Sub Button4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button4.Click
TextBox1.Clear()
TextBox2.Clear()
End Sub
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
Close()
End Sub
Private Sub AddClass_Closing(ByVal sender As Object, ByVal e As System.ComponentModel.CancelEventArgs) Handles MyBase.Closing
falg = 0
End Sub
Private Sub AddClass_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
'AssentClass()
For Each ClassRow In ClassDataSet.Tables("T_ASSET_TYPE").Rows
Me.ComboBox1.Items.Add(ClassRow("TYPE_CODE"))
Next
Me.ComboBox1.Text = Me.ComboBox1.Items.Item(0)
If TextBox1.Text.Length <> 0 Or TextBox2.Text.Length <> 0 Then
Me.Button4.Enabled = True
Else
Me.Button4.Enabled = False
End If
End Sub
Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click
Try
myConnStr = connstr()
myConnetion = New SqlConnection(myConnStr)
myConnetion.Open()
myCommand = New SqlCommand("INSERT INTO T_ASSET_TYPE VALUES(@TYPE_CODE,@TYPE_NAME)", myConnetion)
myCommand.Parameters.Add(New SqlParameter("@TYPE_CODE", SqlDbType.Char, 1))
myCommand.Parameters("@TYPE_CODE").Value = TextBox2.Text
myCommand.Parameters.Add(New SqlParameter("@TYPE_NAME", SqlDbType.Char, 20))
myCommand.Parameters("@TYPE_NAME").Value = TextBox1.Text
Dim im As Integer
myCommand.ExecuteNonQuery()
MsgBox("资产类型添加成功!!!")
TextBox1.Clear()
TextBox2.Clear()
Catch ex As Exception
MsgBox("对不起!!!" & Chr(10) & "您创建的资产类型失败.....")
End Try
End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
If TextBox1.Text.Length <> 0 And TextBox2.Text.Length <> 0 Then
For i = 0 To ComboBox1.Items.Count - 1
'MsgBox(TextBox2.Text.Trim())
'MsgBox(ComboBox1.Items.Item(i))
If TextBox2.Text.Trim() = ComboBox1.Items.Item(i) Then
MsgBox("对不起!!!" & Chr(10) & TextBox2.Text & "已经被创建" & "请从新创建一个代号....")
Me.Button3.Enabled = False
Exit Sub
Else
End If
Next
MsgBox("恭喜您!!! " & Chr(10) & TextBox2.Text & "还没有被占用,你可以有" & TextBox2.Text & "做为" & TextBox1.Text & "的代号")
Me.Button3.Enabled = True
Else
Me.Button3.Enabled = False
MsgBox("资产名称和代号不能为空......")
End If
End Sub
Private Sub TextBox1_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TextBox1.TextChanged
If TextBox1.Text.Length <> 0 Or TextBox2.Text.Length <> 0 Then
Me.Button4.Enabled = True
Else
Me.Button4.Enabled = False
End If
End Sub
Private Sub TextBox2_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TextBox2.TextChanged
If TextBox1.Text.Length <> 0 Or TextBox2.Text.Length <> 0 Then
Me.Button4.Enabled = True
Else
Me.Button4.Enabled = False
End If
End Sub
End Class
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -