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;
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;
<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);
}
<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);
}
}
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 ();
}
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.