C#中TreeView类操作全攻略(三)using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using com.ls;
using System.Data.OracleClient;
//using com.prm.clientmon;
namespace com.prm.client.forms
{
/// <summary>
/
// SM_EditFunction 的摘要说明。
/// </summary>
public class SM_EditFunction: System.Windows.Forms.Form
{
private System.Windows.Forms.Label lbl_Name;
private System.Windows.Forms.TextBox txt_Name;
private System.Windows.Forms.Label lbl_Tag;
private System.Windows.Forms.TextBox txt_Tag;
private System.Windows.Forms.CheckBox ckb_IsInterface;
private System.Windows.Forms.Label lbl_IsInterface;
private System.Windows.Forms.Label lbl_Type;
private System.Windows.Forms.Label lbl_FunEntity;
private System.Windows.Forms.ComboBox cbo_Type;
private System.Windows.Forms.TextBox txt_FunEntity;
private System.Windows.Forms.Label lbl_BelongTo;
private System.Windows.Forms.TextBox txt_BelongTo;
private System.Windows.Forms.TextBox txt_Detail;
private System.Windows.Forms.Label lbl_Detail;
private System.Windows.Forms.Button btn_Confirm;
private System.Windows.Forms.Button btn_Cancel;
private System.Windows.Forms.Button btn_Help;
//⽤来保存原始的功能记录
private FunctionTable oriFuncItem;
//⽤来保存数字字典功能类别的数据
ClientDictionary[] DIC_funcType;
//⽤来保存Connection属性
private OracleConnection funcTableConn;
//⽤来保存修改后的记录
private FunctionTable newFuncItem;
public FunctionTable NewFuncItem {get {return newFuncItem;}}
//⽤来判断是否⽤户进⾏了修改
private bool isEdit=false;
public bool IsEdit {get {return isEdit;}}
/
// <summary>
/// 必需的设计器变量。
/// </summary>
private System.ComponentModel.Container components = null;
/// <summary>
/// 构造函数,通过editFuncItem参数和dic_funcType对窗⼝进⾏初始化值
/// </summary>
public SM_EditFunction(FunctionTable editFuncItem,ClientDictionary[] dic_funcType)
{
//
// Windows 窗体设计器⽀持所必需的
/
/
InitializeComponent();
//⽤参数值对本窗⼝相应的变量进⾏赋值保存
oriFuncItem=editFuncItem;
DIC_funcType=dic_funcType;
const string VALUEMEMBER="valueMember",DISPLAYMEMBER="displayMember",NULLTEXT="";
cbo_Type.DataSource = DIC_funcType;
cbo_Type.ValueMember = VALUEMEMBER;
cbo_Type.DisplayMember = DISPLAYMEMBER;
DataAccessObject funcTableAccessObject=new DataAccessObject();
funcTableConn=funcTableAccessObject.Connection;
<_Name.Text=oriFuncItem.funcName;
<_Tag.Text=oriFuncItem.funcTag;
if (oriFuncItem.funcIsInterface =="0")
{
this.ckb_IsInterface.Checked=false;
}
else
{
this.ckb_IsInterface.Checked=true;
}
this.cbo_Type.SelectedValue=oriFuncItem.funcType;
<_FunEntity.Text=oriFuncItem.funcEntity;
<_BelongTo.Text=oriFuncItem.funcBelongTo;
<_Detail.Text=oriFuncItem.funcDetail;
}
/// <summary>
/// 清理所有正在使⽤的资源。
/// </summary>
protected override void Dispose( bool disposing )
{
if( disposing )
{
if(components != null)
{
components.Dispose();
}
}
base.Dispose( disposing );
}
#region Windows 窗体设计器⽣成的代码
/// <summary>
/// 设计器⽀持所需的⽅法 - 不要使⽤代码编辑器修改
/// 此⽅法的内容。
/
// </summary>
private void InitializeComponent()
{
System.Resources.ResourceManager resources = new System.Resources.ResourceManager(typeof(SM_EditFunction)); this.lbl_Name = new System.Windows.Forms.Label();
this.lbl_Tag = new System.Windows.Forms.Label();
this.lbl_Type = new System.Windows.Forms.Label();
this.lbl_FunEntity = new System.Windows.Forms.Label();
this.lbl_BelongTo = new System.Windows.Forms.Label();
<_Name = new System.Windows.Forms.TextBox();
<_Tag = new System.Windows.Forms.TextBox();
this.cbo_Type = new System.Windows.Forms.ComboBox();
<_BelongTo = new System.Windows.Forms.TextBox();
<_Detail = new System.Windows.Forms.TextBox();
this.lbl_Detail = new System.Windows.Forms.Label();
this.ckb_IsInterface = new System.Windows.Forms.CheckBox();
this.btn_Confirm = new System.Windows.Forms.Button();
this.btn_Cancel = new System.Windows.Forms.Button();
this.btn_Help = new System.Windows.Forms.Button();
this.lbl_IsInterface = new System.Windows.Forms.Label();
<_FunEntity = new System.Windows.Forms.TextBox();
this.SuspendLayout();
/
/
// lbl_Name
//
this.lbl_Name.Location = new System.Drawing.Point(56, 24);
this.lbl_Name.Name = "lbl_Name";
this.lbl_Name.Size = new System.Drawing.Size(48, 23);
this.lbl_Name.TabIndex = 0;
this.lbl_Name.Text = "名称:";
//
// lbl_Tag
//
this.lbl_Tag.Location = new System.Drawing.Point(56, 56);
this.lbl_Tag.Name = "lbl_Tag";
this.lbl_Tag.Size = new System.Drawing.Size(48, 23);
this.lbl_Tag.TabIndex = 1;
this.lbl_Tag.Text = "标识:";
//
// lbl_Type
//
this.lbl_Type.Location = new System.Drawing.Point(56, 112);
this.lbl_Type.Name = "lbl_Type";
this.lbl_Type.Size = new System.Drawing.Size(48, 23);
this.lbl_Type.TabIndex = 2;
this.lbl_Type.Text = "类别:";
//
// lbl_FunEntity
//
this.lbl_FunEntity.Location = new System.Drawing.Point(32, 144);
this.lbl_FunEntity.Name = "lbl_FunEntity";
this.lbl_FunEntity.Size = new System.Drawing.Size(72, 23);
this.lbl_FunEntity.TabIndex = 3;
this.lbl_FunEntity.Text = " 功能体:";
//
/
/ lbl_BelongTo
//
this.lbl_BelongTo.Location = new System.Drawing.Point(8, 176);
this.lbl_BelongTo.Name = "lbl_BelongTo";
this.lbl_BelongTo.Size = new System.Drawing.Size(96, 23);
this.lbl_BelongTo.TabIndex = 4;
this.lbl_BelongTo.Text = "所属窗⼝标识:";
//
// txt_Name
//
<_Name.ForeColor = System.Drawing.Color.FromArgb(((System.Byte)(30)), ((System.Byte)(66)), ((System.Byte)(94))); _Name.Location = new System.Drawing.Point(104, 16);
<_Name.Name = "txt_Name";
<_Name.Size = new System.Drawing.Size(152, 21);
<_Name.TabIndex = 5;
<_Name.Text = "";
//
// txt_Tag
//
<_Tag.ForeColor = System.Drawing.Color.FromArgb(((System.Byte)(30)), ((System.Byte)(66)), ((System.Byte)(94))); _Tag.Location = new System.Drawing.Point(104, 48);
<_Tag.Name = "txt_Tag";
<_Tag.Size = new System.Drawing.Size(152, 21);
<_Tag.TabIndex = 6;
<_Tag.Text = "";
//
// cbo_Type
//
this.cbo_Type.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
this.cbo_Type.ForeColor = System.Drawing.Color.FromArgb(((System.Byte)(30)), ((System.Byte)(66)), ((System.Byte)(94))); this.cbo_Type.Location = new System.Drawing.Point(104, 104);
this.cbo_Type.Name = "cbo_Type";
this.cbo_Type.Size = new System.Drawing.Size(152, 20);
this.cbo_Type.TabIndex = 7;
//
// txt_BelongTo
//
<_BelongTo.ForeColor = System.Drawing.Color.FromArgb(((System.Byte)(30)), ((System.Byte)(66)), ((System.Byte)(94)));
<_BelongTo.Location = new System.Drawing.Point(104, 168);
<_BelongTo.Name = "txt_BelongTo";
<_BelongTo.Size = new System.Drawing.Size(152, 21);
<_BelongTo.TabIndex = 8;
<_BelongTo.Text = "";
//
// txt_Detail
//
<_Detail.ForeColor = System.Drawing.Color.FromArgb(((System.Byte)(30)), ((System.Byte)(66)), ((System.Byte)(94))); _Detail.Location = new System.Drawing.Point(104, 200);
<_Detail.Name = "txt_Detail";
<_Detail.Size = new System.Drawing.Size(152, 21);
<_Detail.TabIndex = 9;
<_Detail.Text = "";
//
// lbl_Detail
//
this.lbl_Detail.Location = new System.Drawing.Point(56, 208);
this.lbl_Detail.Name = "lbl_Detail";
this.lbl_Detail.Size = new System.Drawing.Size(48, 23);
this.lbl_Detail.TabIndex = 10;
this.lbl_Detail.Text = "描述:";
//
// ckb_IsInterface
//
this.ckb_IsInterface.Location = new System.Drawing.Point(104, 72);
this.ckb_IsInterface.Name = "ckb_IsInterface";
this.ckb_IsInterface.Size = new System.Drawing.Size(24, 24);
this.ckb_IsInterface.TabIndex = 11;
//
// btn_Confirm
/
/
this.btn_Confirm.BackgroundImage = ((System.Drawing.Image)(resources.GetObject("btn_Confirm.BackgroundImage"))); this.btn_Confirm.Location = new System.Drawing.Point(40, 240);
this.btn_Confirm.Name = "btn_Confirm";
this.btn_Confirm.Size = new System.Drawing.Size(64, 22);
this.btn_Confirm.TabIndex = 12;
this.btn_Confirm.Text = "确定";
this.btn_Confirm.Click += new System.EventHandler(this.btn_Confirm_Click);
//
// btn_Cancel
//
this.btn_Cancel.BackgroundImage = ((System.Drawing.Image)(resources.GetObject("btn_Cancel.BackgroundImage"))); this.btn_Cancel.Location = new System.Drawing.Point(128, 240);
this.btn_Cancel.Name = "btn_Cancel";
this.btn_Cancel.Size = new System.Drawing.Size(64, 22);
this.btn_Cancel.TabIndex = 13;
this.btn_Cancel.Text = "取消";
this.btn_Cancel.Click += new System.EventHandler(this.btn_Cancel_Click);
//
// btn_Help
//
this.btn_Help.BackgroundImage = ((System.Drawing.Image)(resources.GetObject("btn_Help.Backgrou
ndImage"))); this.btn_Help.Location = new System.Drawing.Point(216, 240);
this.btn_Help.Name = "btn_Help";
this.btn_Help.Size = new System.Drawing.Size(64, 22);
this.btn_Help.TabIndex = 14;
this.btn_Help.Text = "帮助";
//
// lbl_IsInterface
//
this.lbl_IsInterface.Location = new System.Drawing.Point(32, 80);
this.lbl_IsInterface.Name = "lbl_IsInterface";
this.lbl_IsInterface.Size = new System.Drawing.Size(72, 23);
this.lbl_IsInterface.TabIndex = 15;
this.lbl_IsInterface.Text = "有⽆界⾯:";
//
// txt_FunEntity
//
<_FunEntity.ForeColor = System.Drawing.Color.FromArgb(((System.Byte)(30)), ((System.Byte)(66)), ((System.Byte)(94))); _FunEntity.Location = new System.Drawing.Point(104, 136);
<_FunEntity.Name = "txt_FunEntity";
<_FunEntity.Size = new System.Drawing.Size(152, 21);
<_FunEntity.TabIndex = 16;
<_FunEntity.Text = "";
//
// SM_EditFunction
//
this.AutoScaleBaseSize = new System.Drawing.Size(6, 14);
this.BackColor = System.Drawing.Color.FromArgb(((System.Byte)(242)), ((System.Byte)(247)), ((System.Byte)(250)));
this.ClientSize = new System.Drawing.Size(320, 273);
代码编辑器怎么下载this.Controls._FunEntity);
this.Controls.Add(this.lbl_IsInterface);
this.Controls.Add(this.btn_Help);
this.Controls.Add(this.btn_Cancel);
this.Controls.Add(this.btn_Confirm);
this.Controls.Add(this.ckb_IsInterface);
this.Controls.Add(this.lbl_Detail);
this.Controls._Detail);
this.Controls._BelongTo);
this.Controls.Add(this.cbo_Type);
this.Controls._Tag);
this.Controls._Name);
this.Controls.Add(this.lbl_BelongTo);
this.Controls.Add(this.lbl_FunEntity);
this.Controls.Add(this.lbl_Type);
this.Controls.Add(this.lbl_Tag);
this.Controls.Add(this.lbl_Name);
this.ForeColor = System.Drawing.Color.FromArgb(((System.Byte)(30)), ((System.Byte)(66)), ((System.Byte)(94)));
this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon")));
this.Name = "SM_EditFunction";
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
this.Text = "修改功能";
this.ResumeLayout(false);
}
#endregion
/// <summary>
/// 按确定按钮后,先检查输⼊的数据的合法性;接着⽣成⼀个FunctionTable类的实例
/// 并根据输⼊进⾏相应的赋值,接着调⽤UpdateFuncItem过程对功能表进⾏相应的修改
/// </summary>
private void btn_Confirm_Click(object sender, System.EventArgs e)
{
if(txt_Name.Text=="")
{
MessageBox.Show("功能名称不能为空");
return;
}
if(txt_Tag.Text=="")
{
MessageBox.Show("功能标识不能为空");
return;
}
_FunEntity.Text=="")
{
MessageBox.Show("功能体不能为空");
return;
}
newFuncItem=new FunctionTable();
newFuncItem.funcName=txt_Name.Text.Trim();
newFuncItem.funcTag=txt_Tag.Text.Trim();
if(this.ckb_IsInterface.Checked==true)
{
newFuncItem.funcIsInterface="1";
}
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系QQ:729038198,我们将在24小时内删除。
发表评论