Front-endCode
Http://www.baidupcs.com/file/043e27183b83917671dfbf5645559cae? FID = 2467423588-250528-2474618939 & time =
1362981939 & Sign = FDTA-DCb740ccc5511e5e8fedcff06b081203-jRy6dVFO4Oj44qlPgo % 2fiwz2ob1i % 3d & expires = 1 h
Background code
Using system;
Using system. Collections. Generic;
Using system. LINQ;
Using system. text;
Using system. Data;
Using system. Data. sqlclient;
Namespace windows_dal
{
Public class treeview_dal
{
Static sqlconnection myconnection = new sqlconnection ("Server =.; database = windows_test; uid = sa; Pwd = 1 ");
Public static datatable getmenutodatatable ()
{
String SQL = "select * From sysmenutree ";
Return dbtools. DB. executedataset (commandtype. Text, SQL). Tables [0];
}
Public static bool update_treeview (string ID, string text)
{
Myconnection. open ();
Sqltransaction mytrans = myconnection. begintransaction ();
Sqlcommand mycommand = new sqlcommand ();
Mycommand. Connection = myconnection;
Mycommand. Transaction = mytrans;
Int COUNT = 0;
Try
{
String SQL = string. Format ("Update sysmenutree set stext = '{0}' Where noteid = '{1}'", text, ID );
Mycommand. commandtext = SQL;
Count = mycommand. executenonquery ();
// Dbtools. DB. executenonquery (commandtype. Text, SQL );
Mytrans. Commit ();
}
Catch (exception)
{
Mytrans. rollback ();
}
Finally
{
Myconnection. Close ();
}
Return count> 0? True: false;
}
Public static bool add_treeview (string ID, string text)
{
Myconnection. open ();
Sqltransaction mytrans = myconnection. begintransaction ();
Sqlcommand mycommand = new sqlcommand ();
Mycommand. Connection = myconnection;
Mycommand. Transaction = mytrans;
Int COUNT = 0;
Try
{
String SQL = string. format ("insert into sysmenutree values ('{0}', '{1}','', '')", ID, text );
Mycommand. commandtext = SQL;
Count = mycommand. executenonquery ();
// Dbtools. DB. executenonquery (commandtype. Text, SQL );
Mytrans. Commit ();
}
Catch (exception)
{
Mytrans. rollback ();
}
Finally
{
Myconnection. Close ();
}
Return count> 0? True: false;
// String SQL = string. format ("insert into sysmenutree values ('{0}', '{1}','', '')", ID, text );
// Return dbtools. DB. executenonquery (commandtype. Text, SQL)> 0? True: false;
}
Public static bool add_treeview (string text)
{
Myconnection. open ();
Sqltransaction mytrans = myconnection. begintransaction ();
Sqlcommand mycommand = new sqlcommand ();
Mycommand. Connection = myconnection;
Mycommand. Transaction = mytrans;
Int COUNT = 0;
Try
{
String SQL = string. format ("insert into sysmenutree values ('0', '{0}','', '')", text );
Mycommand. commandtext = SQL;
Count = mycommand. executenonquery ();
// Dbtools. DB. executenonquery (commandtype. Text, SQL );
Mytrans. Commit ();
}
Catch (exception)
{
Mytrans. rollback ();
}
Finally
{
Myconnection. Close ();
}
Return count> 0? True: false;
// String SQL = string. format ("insert into sysmenutree values ('{0}', '{1}','', '')", ID, text );
// Return dbtools. DB. executenonquery (commandtype. Text, SQL)> 0? True: false;
}
Public static int del_treeview (string ID)
{
String SQL = string. Format ("select count (*) from sysmenutree where parentid = '{0}'", ID );
If (INT) dbtools. DB. executescalar (commandtype. Text, SQL)> 0)
{
Return 3;
}
Else
{
Myconnection. open ();
Sqltransaction mytrans = myconnection. begintransaction ();
Sqlcommand mycommand = new sqlcommand ();
Mycommand. Connection = myconnection;
Mycommand. Transaction = mytrans;
Int COUNT = 0;
Try
{
SQL = string. Format ("delete sysmenutree where noteid = '{0}'", ID );
Mycommand. commandtext = SQL;
Count = mycommand. executenonquery ();
// Dbtools. DB. executenonquery (commandtype. Text, SQL );
Mytrans. Commit ();
}
Catch (exception)
{
Mytrans. rollback ();
}
Finally
{
Myconnection. Close ();
}
Return count> 0? 1: 2;
// SQL = string. Format ("delete sysmenutree where noteid = '{0}'", ID );
// Return dbtools. DB. executenonquery (commandtype. Text, SQL)> 0? True: false;
}
}
}
}
Database Design
Noteid parentid stext
1 0 pharmaceutical experts
2 1 traditional Chinese medicine
You can modify the loading mode and the user experience after completing the operation.