Using
System;
Using
System.collections;
Using
System.componentmodel;
Using
System.data;
Using
System.drawing;
Using
System.Web;
Using
System.Web.SessionState;
Using
System.Web.ui;
Using
System.Web.ui.WebControls;
Using
System.Web.ui.htmlControls;
Using
System.Data.OleDb;
Using
System.xml;
Using
System.Text;
Namespace
Tree
{/ ** ////
hidTreeid.Value = "0"; txtUpdateTree.Enabled = false; btnUpdate.Enabled = false; btnDelete.Enabled = false;} else {string sqlStr = "SELECT treetitle, treenode FROM tree WHERE treeid =" treeid.ToString (); OleDbCommand cmd = new OleDbCommand (sqlStr, conn); conn.Open (); OleDbDataReader dr = cmd.ExecuteReader (CommandBehavior.SingleRow);. if (dr.Read ()) {lblTreeTitle.Text = dr [ "treetitle"] ToString (); TxtUpdatetree.text = DR ["treetitle"]. TOSTRING (); hidtreeid.value = Treeid.toString ();} Dr.close (); conn.close ();} if (Application ["tree" == NULL) {Treebuild (); } Else {lblTree.Visible = true; lblTree.Text = Application [ "tree"] ToString ();.}}} Private void treeBuild () {string sqlStr = "SELECT * FROM tree ORDER BY treenode"; OleDbDataAdapter da = new OLEDBDataAdapter (Sqlstr, Conn); DataTable DT = New DataTable (); da.fill (dt); Da.dispose (); int treeeevel; char nodechar; string Treenode; stringbuilder treestr =
New stringbuilder (""); for (int i = 0; i
btnDelete.Enabled = false; Application.Remove ( "tree"); treeBuild ();} private void makeXml (string xmlPath) {string sqlStr = "SELECT * FROM tree ORDER BY treenode"; OleDbDataAdapter da = new OleDbDataAdapter (sqlStr, conn DataTable DT = New DataTable (); DA.FILL (DT); DA.Dispose (); int ptreeDepth = -1; int turnTh = 0; XmlTextWriter XW = New XMLTextWriter (xmlpath, null); xw.formatting = Formatting; xw.formatting = formatting .Indented; xw.indentation = 1; xw.writestartDocument (); xw.writestartElement ("Treeroot"); Foreach (Datarow Dr In Dt.Rows) {Treedepth = ChargeNT (DR ["Treenode" ] .ToString (), ','); if (turnepth == ptreedepth) {xw.writeendelement (); xw.writestar TELEMENT ("Treebranch");} else if (turndepth == ptreedepth 1) {xw.writestartelement ("treebranch");} else {for (int i = 0; i ] .Tostring ()); xw.writeAttributeString ("Treenode", DR ["Treenode"]. TOSTRING ()); xw.writeElementString ("treetitle", DR ["treetitle"]. TOSTRING ()); ptreeDepth = TreeDepth } For (int i = 0; i /// summary> private void InitializeComponent () {this.btnAdd.Click = new System.EventHandler (this.btnAdd_Click); this.btnUpdate.Click = new System.EventHandler (this.btnUpdate_Click); this.btnDelete .Click = new System.EventHandler (this.btnDelete_Click); this.lbMakeXml.Click = new System.EventHandler (this.lbMakeXml_Click); this.Load = new System.EventHandler (this.Page_Load);} #endregion private void btnAdd_Click (object sender, System.EventArgs e) {int treeid = int.Parse (hidTreeid.Value); int nodeSerial; string treeTitle = txtAddTree.Text; string treeNode; string sqlStr; OleDbCommand cmd = new OleDbCommand (); cmd. Connection = conn; if (TreeId == 0) {SQLSTR = "SELECT TOP 1 TREENODE from Tree Where Treenode Like '___' Order By Treenode DESC"; cmd.commandt EXT = SQLSTR; conn.open (); object objtreenode = cmd.executescalar (); conn.close (); nodeserial = ((Objtreenode == null)? 0: int.parse (Objtreenode.toString ())) 1 ; treeNode = nodeSerial.ToString ( "D3");} else {sqlStr = "SELECT treenode FROM tree WHERE treeid =" treeid.ToString (); cmd.CommandText = sqlStr; conn.Open (); string parentTreeNode = cmd. EXECUTESCALAR (). TOSTRING (); conn.close (); sqlStr = "SELECT TOP 1 treenode FROM tree WHERE treenode LIKE '" parentTreeNode ", ___' ORDER BY treenode DESC"; cmd.CommandText = sqlStr; conn.Open (); OleDbDataReader dr = cmd.ExecuteReader (CommandBehavior.SingleRow) ; If (Dr.Read ()) {string brothersRee = DR [0] .tostring (); NodeSerial = int.pars (brotherstee.lastindexof (',') 1, 3)) 1;} Else {nodeserial = 1;} Dr.close (); conn.close (); TREENODE = PARENTTREENODE "" NodeSerial.toString ("D3");} SQLSTR = "Insert Into Tree (Tree, Treenode) VALUES @treetitle, @treenode "; cmd.commandtext = SQLSTR; cmd.parameters.add (" @ treetitle ", OLEDBTYPE.VARCHAR, 50); cmd.parameters.add (" @ Treenode ", OLEDBTYPE.VARCHAR, 243);CMD.Parameters ["@ treetitle"]. Value = treetitle; cmd.parameters ["@ Treenode"]. value = treenode; conn.open (); int rt rowaffected = cmd.ExecutenonQuery (); conn.close (); if (Rowaffected> 0) {lblprompt.text = "Branch" Treetitle "Add success"; inittree ();} else {lblprompt.text = "Tree branch" Treetitle "Add failed; }} Private void btnUpdate_Click (object sender, System.EventArgs e) {int treeid = int.Parse (hidTreeid.Value); string treeTitle = Request.Form [ "txtUpdateTree"]; string sqlStr = "UPDATE tree SET treetitle = @treetitle WHERE TREEID = " Treeid.toString (); OLEDBCommand cmd = new oledbcommand (sqlstr, conn); cmd.parameters.add (" @ treetitle ", OLEDBTYPE.VARCHAR, 50); cmd.parameters [" @ treetitle "]. Value = treetitle; conn.open (); int = cmd.executenonQuery (); conn.close (); if (Rowaffected> 0) {lblprompt.text = "Branch" Treetitle "Inittree () } Else {lblprompt.text = "Tree branches" Treetitle "Update Failed";}} private void btndelete_click (Object sender, system.eventargs e) {int treid = int.parse (hidtreeid.value); s tring sqlStr = "SELECT treenode FROM tree WHERE treeid =" treeid.ToString (); OleDbCommand cmd = new OleDbCommand (sqlStr, conn); conn.Open (); string treeNode = cmd.ExecuteScalar () ToString ();. sqlStr = "Delete from tree where treeid =" TREEID.TOSTRING () "or Treenode Like '" Treenode "%'"; cmd.comMandText = SQLSTR; int rotable = cmd.executenonQuery (); conn.close () ; If (Rowaffected>