treeview| Raiders using System;
Using System.Drawing;
Using System.Collections;
Using System.ComponentModel;
Using System.Windows.Forms;
Using System.Data;
Using Com.prm.client.tools;
Using System.Data.OracleClient;
Using Com.prm.client.common;
Data used to hold the functional category of a digital dictionary
Clientdictionary[] Dic_functype;
Used to save the connection property
Private OracleConnection Functableconn;
The primary key (feature ID) that is used to save the newly added record
Private long newfuncid;
Read-only property, which is used to read the primary key (feature ID) of the newly added record
Public long Newfuncid {get {return newfuncid;}}
Used to save the newly added feature records
Private Functiontable Newfuncitem;
Public functiontable Newfuncitem {get {return Newfuncitem}}
<summary>
constructor, initializes the window with the parameter Dic_functype, and obtains the Fatherid by the parameter
The superior function ID of the newly added feature
</summary>
Public sm_addnewfunction (Long fatherid,clientdictionary[] dic_functype)
{
//
Required for Windows Forms Designer support
//
InitializeComponent ();
Newfuncitem=new functiontable ();
Newfuncitem.funcfatherid=fatherid;
Initialize ID to-1, and will be assigned if new success
Newfuncitem.funcid=-1;
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 input data;
Then assign the variable Newfuncitem according to the input, and then call the Insertfuncitem procedure to add a record to 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.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.funcid=querynextfuncid ();
If the newly generated ID of 0 means that the new ID is not successfully generated automatically, it should be returned and no more operations will be performed.
if (newfuncitem.funcid==0) return;
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= "";
Newfuncitem.funcver= "";
Insertfuncitem (Newfuncitem);
This. Close ();
<summary>
Inserts a new record in the menu, taking advantage of the rollback feature, that is, if the insertion is unsuccessful, the function table
Revert to the state before insertion
</summary>
<param name= "NewItem" > Information for the new record to insert </param>
private void Insertfuncitem (Functiontable newitem)
{
Functableconn.open ();
System.Data.OracleClient.OracleTransaction Mytran = Functableconn.begintransaction ();
Try
{
OracleCommand cmd = new OracleCommand ();
Cmd.commandtext = "INSERT into function (function ID, function identification, function name, function description, form, there is no interface, functional category, function, superior function ID, can show, version number) values ('"
+newitem.funcid+ "', '"
+newitem.functag+ "', '"
+newitem.funcname+ "', '"
+newitem.funcdetail+ "', '"
+newitem.funcbelongto+ "', '"
+newitem.funcisinterface+ "', '"
+newitem.functype+ "', '"
+newitem.funcentity+ "', '"
+newitem.funcfatherid+ "', '"
+newitem.funcisexpand+ "', '"
+newitem.funcver+ "')";
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" + "did not add any records!" "," 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)
{
If you click Cancel, the Newfuncitem.funcid assignment is 1.
Newfuncitem.funcid=-1;
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.