C # in the TreeView class Operation full Raiders (three)

Source: Internet
Author: User
Tags bool empty rollback trim
treeview| Raiders using System;
Using System.Drawing;
Using System.Collections;
Using System.ComponentModel;
Using System.Windows.Forms;
Using Com.prm.client.tools;
Using System.Data.OracleClient;
Using Com.prm.client.common;

Namespace Com.prm.client.forms
{
<summary>
Summary description of the 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;

Used to save the original feature record
Private Functiontable Orifuncitem;

Data used to hold the functional category of a digital dictionary
Clientdictionary[] Dic_functype;
Used to save the connection property
Private OracleConnection Functableconn;
To save the modified record
Private Functiontable Newfuncitem;
Public functiontable Newfuncitem {get {return Newfuncitem}}
Used to determine if the user has made a modification
private bool Isedit=false;
public bool Isedit {get {return isedit;}}
<summary>
The required designer variable.
</summary>
Private System.ComponentModel.Container components = null;

<summary>
constructors, initializing the window with Editfuncitem parameters and Dic_functype
</summary>
Public sm_editfunction (functiontable editfuncitem,clientdictionary[] dic_functype)
{
//
Required for Windows Forms Designer support
//
InitializeComponent ();
Assign value to the corresponding variable in this window by using the parameter value to save
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;

This.txt_name.text=orifuncitem.funcname;
This.txt_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;
this.txt_funentity.text=orifuncitem.funcentity;
This.txt_belongto.text=orifuncitem.funcbelongto;
This.txt_detail.text=orifuncitem.funcdetail;

}

<summary>
Clean up all resources that are in use.
</summary>
protected override void Dispose (bool disposing)
{
if (disposing)
{
if (Components!= null)
{
Components. Dispose ();
}
}
Base. Dispose (disposing);
}

Code generated #region the Windows forms Designer
<summary>
Designer supports required methods-do not use the Code editor to modify
The contents of this method.
</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 ();
This.txt_name = new System.Windows.Forms.TextBox ();
This.txt_tag = new System.Windows.Forms.TextBox ();
This.cbo_type = new System.Windows.Forms.ComboBox ();
This.txt_belongto = new System.Windows.Forms.TextBox ();
This.txt_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 ();
this.txt_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 = "Name:";
//
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 = "Logo:";
//
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 = "Category:";
//
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 = "Functional Body:";
//
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 = "belongs to the window ID:";
//
Txt_name
//
This.txt_Name.ForeColor = System.Drawing.Color.FromArgb ((System.Byte)), ((System.Byte) ()), ((System.Byte) ( 94));
This.txt_Name.Location = new System.Drawing.Point (104, 16);
This.txt_Name.Name = "Txt_name";
This.txt_Name.Size = new System.Drawing.Size (152, 21);
This.txt_Name.TabIndex = 5;
This.txt_Name.Text = "";
//
Txt_tag
//
This.txt_Tag.ForeColor = System.Drawing.Color.FromArgb ((System.Byte)), ((System.Byte) ($)), ((System.Byte) (94 )));
This.txt_Tag.Location = new System.Drawing.Point (104, 48);
This.txt_Tag.Name = "Txt_tag";
This.txt_Tag.Size = new System.Drawing.Size (152, 21);
This.txt_Tag.TabIndex = 6;
This.txt_Tag.Text = "";
//
Cbo_type
//
This.cbo_Type.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
This.cbo_Type.ForeColor = System.Drawing.Color.FromArgb ((System.Byte)), ((System.Byte) ()), ((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
//
This.txt_BelongTo.ForeColor = System.Drawing.Color.FromArgb ((System.Byte)), ((System.Byte) (66)), (( System.Byte) (94));
This.txt_BelongTo.Location = new System.Drawing.Point (104, 168);
This.txt_BelongTo.Name = "Txt_belongto";
This.txt_BelongTo.Size = new System.Drawing.Size (152, 21);
This.txt_BelongTo.TabIndex = 8;
This.txt_BelongTo.Text = "";
//
Txt_detail
//
This.txt_Detail.ForeColor = System.Drawing.Color.FromArgb ((System.Byte) ((System.Byte) ()), ((System.Byte) (94)));
This.txt_Detail.Location = new System.Drawing.Point (104, 200);
This.txt_Detail.Name = "Txt_detail";
This.txt_Detail.Size = new System.Drawing.Size (152, 21);
This.txt_Detail.TabIndex = 9;
This.txt_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 = "description:";
//
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 = "OK";
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 = "Cancel";
This.btn_Cancel.Click + = new System.EventHandler (This.btn_cancel_click);
//
Btn_help
//
This.btn_Help.BackgroundImage = ((System.Drawing.Image) (resources. GetObject ("Btn_help.backgroundimage"));
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 = "Help";
//
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 = "There is no interface:";
//
Txt_funentity
//
This.txt_FunEntity.ForeColor = System.Drawing.Color.FromArgb ((System.Byte)), ((System.Byte) (66)), (( System.Byte) (94));
This.txt_FunEntity.Location = new System.Drawing.Point (104, 136);
This.txt_FunEntity.Name = "Txt_funentity";
This.txt_FunEntity.Size = new System.Drawing.Size (152, 21);
This.txt_FunEntity.TabIndex = 16;
This.txt_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.Add (this.txt_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.Add (This.txt_detail);
This. Controls.Add (THIS.TXT_BELONGTO);
This. Controls.Add (This.cbo_type);
This. Controls.Add (This.txt_tag);
This. Controls.Add (This.txt_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) ((System.Byte) ()), ((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 = "Modify function";
This. ResumeLayout (FALSE);

}
#endregion

<summary>
After pressing the OK button, first check the legality of the data entered; then generate an instance of the Functiontable class
and the corresponding assignment according to the input, and then call the Updatefuncitem process to modify the function table
</summary>
private void Btn_confirm_click (object sender, System.EventArgs e)
{
if (txt_name.text== "")
{
MessageBox.Show ("feature name cannot be empty");
Return
}
if (txt_tag.text== "")
{
MessageBox.Show ("Feature ID cannot be empty");
Return
}
if (this.txt_funentity.text== "")
{
MessageBox.Show ("Function cannot be empty");
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";
}
Else
{
newfuncitem.funcisinterface= "0";
}
Newfuncitem.functype=this.cbo_type.selectedvalue.tostring (). Trim ();
Newfuncitem.funcentity=this.txt_funentity.text.trim ();
Newfuncitem.funcbelongto=this.txt_belongto.text.trim ();
Newfuncitem.funcdetail=this.txt_detail.text.trim ();
Newfuncitem.funcisexpand=orifuncitem.funcisexpand;
Newfuncitem.funcver=orifuncitem.funcver;
Newfuncitem.funcid=orifuncitem.funcid;
Newfuncitem.funcfatherid=orifuncitem.funcfatherid;
Updatefuncitem (Newfuncitem);
Isedit=true;
This. Close ();

}

<summary>
The function table is modified to take advantage of the rollback function, that is, if the modification is unsuccessful, the function table
Revert to the state before the modification
</summary>
<param name= "NewItem" > new record information to be modified </param>
private void Updatefuncitem (Functiontable newitem)
{
Functableconn.open ();
System.Data.OracleClient.OracleTransaction Mytran = Functableconn.begintransaction ();
Try
{
OracleCommand cmd = new OracleCommand ();
Cmd.commandtext = "UPDATE feature set function identification = '" +newitem.functag
+ "', Function name = '" +newitem.funcname
+ "', Function brief = '" +newitem.funcdetail
+ "', belong to form = '" +newitem.funcbelongto
+ "', there is no interface = '" +newitem.funcisinterface
+ "', Functional category = '" +newitem.functype
+ "', functional BODY = '" +newitem.funcentity
+ "', Superior function id= '" +newitem.funcfatherid
+ "', can show = '" +newitem.funcisexpand
+ "', Version number = '" +newitem.funcver
+ "' where function id = '" +newitem.funcid+ "";
Cmd. Transaction = Mytran;
Cmd. Connection =functableconn;
Cmd. ExecuteNonQuery ();
Mytran.commit ();
}
catch (Exception ee)
{
Try
{
Mytran.rollback ();
}
catch (OracleException ex)
{
if (mytran.connection!= null)
{
MessageBox.Show (occurs on rollback) + ex. GetType () + "Exception!" ",
"Warning," System.Windows.Forms.MessageBoxButtons.OK,
System.Windows.Forms.MessageBoxIcon.Warning);
}
}

MessageBox.Show ("occurrence" + EE.) GetType () +
"Exception \ n" + "Modify record failed!" "," warned the System.Windows.Forms.MessageBoxButtons.OK,
System.Windows.Forms.MessageBoxIcon.Warning);
}
Finally
{
Functableconn.close ();
}
}

private void Btn_cancel_click (object sender, System.EventArgs e)
{
When the user clicks the Cancel key, it means that no changes have been made
Isedit=false;
This. Close ();
}

}
}





Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.