代码
Imports System
Imports System.Drawing
Imports System.Collections
Imports System.ComponentModel
Imports System.Windows.Forms
Imports com.prm.client.tools
Imports System.Data.OracleClient
'using com.prm.client.common;



Namespace com.prm.client.forms
''' <summary>
''' SM_EditFunction 的摘要说明。
''' </summary>
Public Class SM_EditFunction
Inherits System.Windows.Forms.Form
Private lbl_Name As System.Windows.Forms.Label
Private txt_Name As System.Windows.Forms.TextBox
Private lbl_Tag As System.Windows.Forms.Label
Private txt_Tag As System.Windows.Forms.TextBox
Private ckb_IsInterface As System.Windows.Forms.CheckBox
Private lbl_IsInterface As System.Windows.Forms.Label
Private lbl_Type As System.Windows.Forms.Label
Private lbl_FunEntity As System.Windows.Forms.Label
Private cbo_Type As System.Windows.Forms.ComboBox
Private txt_FunEntity As System.Windows.Forms.TextBox
Private lbl_BelongTo As System.Windows.Forms.Label
Private txt_BelongTo As System.Windows.Forms.TextBox
Private txt_Detail As System.Windows.Forms.TextBox
Private lbl_Detail As System.Windows.Forms.Label
Private btn_Confirm As System.Windows.Forms.Button
Private btn_Cancel As System.Windows.Forms.Button
Private btn_Help As System.Windows.Forms.Button



'用来保存原始的功能记录
Private oriFuncItem As FunctionTable

'用来保存数字字典功能类别的数据
Private DIC_funcType As ClientDictionary()
'用来保存Connection属性
Private funcTableConn As OracleConnection
'用来保存修改后的记录
Private newFuncItem As FunctionTable
Public ReadOnly Property NewFuncItem() As FunctionTable
Get
Return newFuncItem
End Get
End Property
'用来判断是否用户进行了修改
Private isEdit As Boolean = False
Public ReadOnly Property IsEdit() As Boolean
Get
Return isEdit
End Get
End Property
''' <summary>
''' 必需的设计器变量。
''' </summary>
Private components As System.ComponentModel.Container = Nothing

''' <summary>
''' 构造函数,通过editFuncItem参数和dic_funcType对窗口进行初始化值
''' </summary>
Public Sub New(editFuncItem As FunctionTable, dic_funcType As ClientDictionary())
'
' Windows 窗体设计器支持所必需的
'
InitializeComponent()
'用参数值对本窗口相应的变量进行赋值保存
oriFuncItem = editFuncItem
DIC_funcType
= dic_funcType
Const VALUEMEMBER As String = "valueMember", DISPLAYMEMBER As String = "displayMember", NULLTEXT As String = ""
cbo_Type.DataSource
= DIC_funcType
cbo_Type.ValueMember
= VALUEMEMBER
cbo_Type.DisplayMember
= DISPLAYMEMBER



Dim funcTableAccessObject As New DataAccessObject()
funcTableConn
= funcTableAccessObject.Connection



Me.txt_Name.Text = oriFuncItem.funcName
Me.txt_Tag.Text = oriFuncItem.funcTag
If oriFuncItem.funcIsInterface = "0" Then
Me.ckb_IsInterface.Checked = False
Else
Me.ckb_IsInterface.Checked = True
End If
Me.cbo_Type.SelectedValue = oriFuncItem.funcType
Me.txt_FunEntity.Text = oriFuncItem.funcEntity
Me.txt_BelongTo.Text = oriFuncItem.funcBelongTo



Me.txt_Detail.Text = oriFuncItem.funcDetail
End Sub



''' <summary>
''' 清理所有正在使用的资源。
''' </summary>
Protected Overrides Sub Dispose(disposing As Boolean)
If disposing Then
If components <> Nothing Then
components.Dispose()
End If
End If
MyBase.Dispose(disposing)
End Sub



#region Windows 窗体设计器生成的代码
''' <summary>
''' 设计器支持所需的方法 - 不要使用代码编辑器修改
''' 此方法的内容。
''' </summary>
Private Sub InitializeComponent()
Dim resources As New System.Resources.ResourceManager(GetType(SM_EditFunction))
Me.lbl_Name = New System.Windows.Forms.Label()
Me.lbl_Tag = New System.Windows.Forms.Label()
Me.lbl_Type = New System.Windows.Forms.Label()
Me.lbl_FunEntity = New System.Windows.Forms.Label()
Me.lbl_BelongTo = New System.Windows.Forms.Label()
Me.txt_Name = New System.Windows.Forms.TextBox()
Me.txt_Tag = New System.Windows.Forms.TextBox()
Me.cbo_Type = New System.Windows.Forms.ComboBox()
Me.txt_BelongTo = New System.Windows.Forms.TextBox()
Me.txt_Detail = New System.Windows.Forms.TextBox()
Me.lbl_Detail = New System.Windows.Forms.Label()
Me.ckb_IsInterface = New System.Windows.Forms.CheckBox()
Me.btn_Confirm = New System.Windows.Forms.Button()
Me.btn_Cancel = New System.Windows.Forms.Button()
Me.btn_Help = New System.Windows.Forms.Button()
Me.lbl_IsInterface = New System.Windows.Forms.Label()
Me.txt_FunEntity = New System.Windows.Forms.TextBox()
Me.SuspendLayout()
'
' lbl_Name
'
Me.lbl_Name.Location = New System.Drawing.Point(56, 24)
Me.lbl_Name.Name = "lbl_Name"
Me.lbl_Name.Size = New System.Drawing.Size(48, 23)
Me.lbl_Name.TabIndex = 0
Me.lbl_Name.Text = "名称:"
'
' lbl_Tag
'
Me.lbl_Tag.Location = New System.Drawing.Point(56, 56)
Me.lbl_Tag.Name = "lbl_Tag"
Me.lbl_Tag.Size = New System.Drawing.Size(48, 23)
Me.lbl_Tag.TabIndex = 1
Me.lbl_Tag.Text = "标识:"
'
' lbl_Type
'
Me.lbl_Type.Location = New System.Drawing.Point(56, 112)
Me.lbl_Type.Name = "lbl_Type"
Me.lbl_Type.Size = New System.Drawing.Size(48, 23)
Me.lbl_Type.TabIndex = 2
Me.lbl_Type.Text = "类别:"
'
' lbl_FunEntity
'
Me.lbl_FunEntity.Location = New System.Drawing.Point(32, 144)
Me.lbl_FunEntity.Name = "lbl_FunEntity"
Me.lbl_FunEntity.Size = New System.Drawing.Size(72, 23)
Me.lbl_FunEntity.TabIndex = 3
Me.lbl_FunEntity.Text = " 功能体:"
'
' lbl_BelongTo
'
Me.lbl_BelongTo.Location = New System.Drawing.Point(8, 176)
Me.lbl_BelongTo.Name = "lbl_BelongTo"
Me.lbl_BelongTo.Size = New System.Drawing.Size(96, 23)
Me.lbl_BelongTo.TabIndex = 4
Me.lbl_BelongTo.Text = "所属窗口标识:"
'
' txt_Name
'
Me.txt_Name.ForeColor = System.Drawing.Color.FromArgb((DirectCast((30), System.Byte)), (DirectCast((66), System.Byte)), (DirectCast((94), System.Byte)))
Me.txt_Name.Location = New System.Drawing.Point(104, 16)
Me.txt_Name.Name = "txt_Name"
Me.txt_Name.Size = New System.Drawing.Size(152, 21)
Me.txt_Name.TabIndex = 5
Me.txt_Name.Text = ""
'
' txt_Tag
'
Me.txt_Tag.ForeColor = System.Drawing.Color.FromArgb((DirectCast((30), System.Byte)), (DirectCast((66), System.Byte)), (DirectCast((94), System.Byte)))
Me.txt_Tag.Location = New System.Drawing.Point(104, 48)
Me.txt_Tag.Name = "txt_Tag"
Me.txt_Tag.Size = New System.Drawing.Size(152, 21)
Me.txt_Tag.TabIndex = 6
Me.txt_Tag.Text = ""
'
' cbo_Type
'
Me.cbo_Type.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList
Me.cbo_Type.ForeColor = System.Drawing.Color.FromArgb((DirectCast((30), System.Byte)), (DirectCast((66), System.Byte)), (DirectCast((94), System.Byte)))
Me.cbo_Type.Location = New System.Drawing.Point(104, 104)
Me.cbo_Type.Name = "cbo_Type"
Me.cbo_Type.Size = New System.Drawing.Size(152, 20)
Me.cbo_Type.TabIndex = 7
'
' txt_BelongTo
'
Me.txt_BelongTo.ForeColor = System.Drawing.Color.FromArgb((DirectCast((30), System.Byte)), (DirectCast((66), System.Byte)), (DirectCast((94), System.Byte)))
Me.txt_BelongTo.Location = New System.Drawing.Point(104, 168)
Me.txt_BelongTo.Name = "txt_BelongTo"
Me.txt_BelongTo.Size = New System.Drawing.Size(152, 21)
Me.txt_BelongTo.TabIndex = 8
Me.txt_BelongTo.Text = ""
'
' txt_Detail
'
Me.txt_Detail.ForeColor = System.Drawing.Color.FromArgb((DirectCast((30), System.Byte)), (DirectCast((66), System.Byte)), (DirectCast((94), System.Byte)))
Me.txt_Detail.Location = New System.Drawing.Point(104, 200)
Me.txt_Detail.Name = "txt_Detail"
Me.txt_Detail.Size = New System.Drawing.Size(152, 21)
Me.txt_Detail.TabIndex = 9
Me.txt_Detail.Text = ""
'
' lbl_Detail
'
Me.lbl_Detail.Location = New System.Drawing.Point(56, 208)
Me.lbl_Detail.Name = "lbl_Detail"
Me.lbl_Detail.Size = New System.Drawing.Size(48, 23)
Me.lbl_Detail.TabIndex = 10
Me.lbl_Detail.Text = "描述:"
'
' ckb_IsInterface
'
Me.ckb_IsInterface.Location = New System.Drawing.Point(104, 72)
Me.ckb_IsInterface.Name = "ckb_IsInterface"
Me.ckb_IsInterface.Size = New System.Drawing.Size(24, 24)
Me.ckb_IsInterface.TabIndex = 11
'
' btn_Confirm
'
Me.btn_Confirm.BackgroundImage = (DirectCast((resources.GetObject("btn_Confirm.BackgroundImage")), System.Drawing.Image))
Me.btn_Confirm.Location = New System.Drawing.Point(40, 240)
Me.btn_Confirm.Name = "btn_Confirm"
Me.btn_Confirm.Size = New System.Drawing.Size(64, 22)
Me.btn_Confirm.TabIndex = 12
Me.btn_Confirm.Text = "确 定"
Me.btn_Confirm.Click += New System.EventHandler(Me.btn_Confirm_Click)
'
' btn_Cancel
'
Me.btn_Cancel.BackgroundImage = (DirectCast((resources.GetObject("btn_Cancel.BackgroundImage")), System.Drawing.Image))
Me.btn_Cancel.Location = New System.Drawing.Point(128, 240)
Me.btn_Cancel.Name = "btn_Cancel"
Me.btn_Cancel.Size = New System.Drawing.Size(64, 22)
Me.btn_Cancel.TabIndex = 13
Me.btn_Cancel.Text = "取 消"
Me.btn_Cancel.Click += New System.EventHandler(Me.btn_Cancel_Click)
'
' btn_Help
'
Me.btn_Help.BackgroundImage = (DirectCast((resources.GetObject("btn_Help.BackgroundImage")), System.Drawing.Image))
Me.btn_Help.Location = New System.Drawing.Point(216, 240)
Me.btn_Help.Name = "btn_Help"
Me.btn_Help.Size = New System.Drawing.Size(64, 22)
Me.btn_Help.TabIndex = 14
Me.btn_Help.Text = "帮 助"
'
' lbl_IsInterface
'
Me.lbl_IsInterface.Location = New System.Drawing.Point(32, 80)
Me.lbl_IsInterface.Name = "lbl_IsInterface"
Me.lbl_IsInterface.Size = New System.Drawing.Size(72, 23)
Me.lbl_IsInterface.TabIndex = 15
Me.lbl_IsInterface.Text = "有无界面:"
'
' txt_FunEntity
'
Me.txt_FunEntity.ForeColor = System.Drawing.Color.FromArgb((DirectCast((30), System.Byte)), (DirectCast((66), System.Byte)), (DirectCast((94), System.Byte)))
Me.txt_FunEntity.Location = New System.Drawing.Point(104, 136)
Me.txt_FunEntity.Name = "txt_FunEntity"
Me.txt_FunEntity.Size = New System.Drawing.Size(152, 21)
Me.txt_FunEntity.TabIndex = 16
Me.txt_FunEntity.Text = ""
'
' SM_EditFunction
'
Me.AutoScaleBaseSize = New System.Drawing.Size(6, 14)
Me.BackColor = System.Drawing.Color.FromArgb((DirectCast((242), System.Byte)), (DirectCast((247), System.Byte)), (DirectCast((250), System.Byte)))
Me.ClientSize = New System.Drawing.Size(320, 273)
Me.Controls.Add(Me.txt_FunEntity)
Me.Controls.Add(Me.lbl_IsInterface)
Me.Controls.Add(Me.btn_Help)
Me.Controls.Add(Me.btn_Cancel)
Me.Controls.Add(Me.btn_Confirm)
Me.Controls.Add(Me.ckb_IsInterface)
Me.Controls.Add(Me.lbl_Detail)
Me.Controls.Add(Me.txt_Detail)
Me.Controls.Add(Me.txt_BelongTo)
Me.Controls.Add(Me.cbo_Type)
Me.Controls.Add(Me.txt_Tag)
Me.Controls.Add(Me.txt_Name)
Me.Controls.Add(Me.lbl_BelongTo)
Me.Controls.Add(Me.lbl_FunEntity)
Me.Controls.Add(Me.lbl_Type)
Me.Controls.Add(Me.lbl_Tag)
Me.Controls.Add(Me.lbl_Name)
Me.ForeColor = System.Drawing.Color.FromArgb((DirectCast((30), System.Byte)), (DirectCast((66), System.Byte)), (DirectCast((94), System.Byte)))
Me.Icon = (DirectCast((resources.GetObject("$this.Icon")), System.Drawing.Icon))
Me.Name = "SM_EditFunction"
Me.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen
Me.Text = "修改功能"
Me.ResumeLayout(False)



End Sub
#endregion



''' <summary>
''' 按确定按钮后,先检查输入的数据的合法性;接着生成一个FunctionTable类的实例
''' 并根据输入进行 相应的赋值,接着调用UpdateFuncItem过程对功能表进行相应的修改
''' </summary>
Private Sub btn_Confirm_Click(sender As Object, e As System.EventArgs)
If txt_Name.Text = "" Then
MessageBox.Show(
"功能名称不能为空")
Return
End If
If txt_Tag.Text = "" Then
MessageBox.Show(
"功能标识不能为空")
Return
End If
If Me.txt_FunEntity.Text = "" Then
MessageBox.Show(
"功能体不能为空")
Return
End If
newFuncItem
= New FunctionTable()
newFuncItem.funcName
= txt_Name.Text.Trim()
newFuncItem.funcTag
= txt_Tag.Text.Trim()
If Me.ckb_IsInterface.Checked = True Then
newFuncItem.funcIsInterface
= "1"
Else
newFuncItem.funcIsInterface
= "0"
End If
newFuncItem.funcType
= Me.cbo_Type.SelectedValue.ToString().Trim()
newFuncItem.funcEntity
= Me.txt_FunEntity.Text.Trim()
newFuncItem.funcBelongTo
= Me.txt_BelongTo.Text.Trim()
newFuncItem.funcDetail
= Me.txt_Detail.Text.Trim()
newFuncItem.funcIsExpand
= oriFuncItem.funcIsExpand
newFuncItem.funcVer
= oriFuncItem.funcVer
newFuncItem.funcID
= oriFuncItem.funcID
newFuncItem.funcFatherID
= oriFuncItem.funcFatherID
UpdateFuncItem(newFuncItem)
isEdit
= True
Me.Close()



End Sub



''' <summary>
''' 对功能表进行修改,利用了回滚功能,即如果修改不成功则功能表
''' 恢复为修改前的状态
''' </summary>
''' <param name="newItem">要修改的新的纪录信息</param>
Private Sub UpdateFuncItem(newItem As FunctionTable)
funcTableConn.Open()
Dim myTran As System.Data.OracleClient.OracleTransaction = funcTableConn.BeginTransaction()
Try
Dim cmd As New OracleCommand()
cmd.CommandText
= "UPDATE 功能 set 功能标识='" + newItem.funcTag + "', 功能名称='" + newItem.funcName + "', 功能简述='" + newItem.funcDetail + "', 所属窗体='" + newItem.funcBelongTo + "', 有无界面='" + newItem.funcIsInterface + "', 功能类别='" + newItem.funcType + "', 功能体='" + newItem.funcEntity + "', 上级功能ID='" + newItem.funcFatherID + "', 可否展显='" + newItem.funcIsExpand + "', 版本号='" + newItem.funcVer + "' where 功能ID = '" + newItem.funcID + "'"
cmd.Transaction
= myTran
cmd.Connection
= funcTableConn
cmd.ExecuteNonQuery()
myTran.Commit()
Catch ee As Exception
Try
myTran.Rollback()
Catch ex As OracleException
If myTran.Connection <> Nothing Then
MessageBox.Show(
"在回滚时发生 " + ex.[GetType]() + " 异常!", "警告", System.Windows.Forms.MessageBoxButtons.OK, System.Windows.Forms.MessageBoxIcon.Warning)
End If
End Try

MessageBox.Show(
"发生" + ee.[GetType]() + "异常" & vbLf + "修改记录失败!", "警告", System.Windows.Forms.MessageBoxButtons.OK, System.Windows.Forms.MessageBoxIcon.Warning)
Finally
funcTableConn.Close()
End Try
End Sub



Private Sub btn_Cancel_Click(sender As Object, e As System.EventArgs)
'用户点击了取消键,则表示没有进行修改
isEdit = False
Me.Close()
End Sub



End Class
End Namespace

 

博客园  ©  2004-2025
浙公网安备 33010602011771号 浙ICP备2021040463号-3