C # Infinite column grading program code sharing good Things 1th/3 page _c# Tutorial

Source: Internet
Author: User
The structure of a database table must have the following fields:
screen.width*0.7) {this.resized=true; this.width=screen.width*0.7 this.alt= ' Click here to open new Window\nctrl+mouse Wheel to zoom in/out ';} ' Border=0>
Description of each field:
screen.width*0.7) {this.resized=true; this.width=screen.width*0.7 this.alt= ' Click here to open new Window\nctrl+mouse Wheel to zoom in/out ';} ' Border=0>
3, the core of this example is Idb.cs,db.cs and Action.cs, respectively, explaining the effect
Idb.cs: The interface of the database operation class, the code is as follows: using System;
Using System.Data;

Namespace Catalog
{
<summary>
A summary note by IDB.
</summary>
Interface IDB
{
//
void open (); Constructors are certainly not declared in interfaces

System.Data.IDbConnection Getcon
{
Get
Set
}

String Constr
{
Get
}

System.Data.IDbCommand command (String sql);

int exesql (String sql);

Object GetValue (String sql);

void Close ();

DataTable GetData (String sql);

System.Data.IDataReader GETDR (String sql);
}
}





Db.cs instance this interface: using System;
Using System.Data;
Using System.Data.OleDb;
Using System.Data.SqlClient;
Using System.Configuration;
Using System.Web;

Namespace Catalog
{
<summary>
A summary description of DB.
</summary>
public class Db:idb
{
Private IDbConnection con;
Private IDbCommand cm;
private string dbtype= "access";

Public db ()
{
//
TODO: Add constructor logic here
//
dbtype=configurationsettings.appsettings["DbType"];
if (dbtype==null)
Dbtype= "";
if (DbType. ToLower () = = "SQL Server")
{
Con=new SqlConnection ();
cm= new SqlCommand ();
}
Else
{
Con=new OleDbConnection ();
cm= new OleDbCommand ();
}

String cnstring=configurationsettings.appsettings["Cnstr"];
Con. connectionstring=cnstring;

Open ();
Cm. Connection=con;
}

Public db (String constr)
{
//
TODO: Add constructor logic here
//
dbtype=configurationsettings.appsettings["DbType"];
if (dbtype==null)
Dbtype= "";
if (DbType. ToLower () = = "SQL Server")
{
Con=new SqlConnection ();
cm= new SqlCommand ();
}
Else
{
Con=new OleDbConnection ();
cm= new OleDbCommand ();
}

Con. CONNECTIONSTRING=CONSTR;
Open ();
Cm. Connection=con;
}

private void Open ()
{
Con. Open ();
}

Public System.Data.IDbConnection Getcon
{
Get{return con;
set{};
}

public int exesql (String sql)
{
Cm.commandtext=sql;
Return to CM. ExecuteNonQuery ();
}

public Object GetValue (String sql)
{
Cm.commandtext=sql;
Return to CM. ExecuteScalar ();
Object o=cm. ExecuteScalar ();
return o;
}

public void Close ()
{
Cm. Dispose ();
Con. Close ();
Con. Dispose ();
Con=null;
}

Public DataTable GetData (String sql)
{
DataTable dt=new DataTable ();
if (DbType. ToLower () = = "SQL Server")
{
SqlDataAdapter adapter = new SqlDataAdapter ();
Cm.commandtext=sql;
Adapter. selectcommand= (SqlCommand) cm;
Adapter. Fill (DT);
}
Else
{
OleDbDataAdapter adapter = new OleDbDataAdapter ();
Cm.commandtext=sql;
Adapter. selectcommand= (OleDbCommand) cm;
Adapter. Fill (DT);
}
return DT;
}

Public IDataReader GETDR (String sql)
{
Cm.commandtext=sql;
Return to CM. ExecuteReader ();

}

public string Constr
{
Get{return configurationsettings.appsettings["Cnstr"];}
}

Public System.Data.IDbCommand Command (String sql)
{
Cm.commandtext=sql;
return cm;
}
}
}
C # Unlimited column classification program code sharing [2] core class description

This program is written in C # for scripting, while supporting the Access/sql server database.
This procedure function: column infinite classification, column move, add, sort, delete (column tree), easy to operate, deployment, use simpler, provide a unified interface program.
This procedure only then develops, inevitably has the mistake or the bug, welcome to propose, is not very grateful.

Core class file Method invocation description
public void Deleteallcatalog (string table)//Empty column table
public int Downclass (string table,int classid)//column Move down one
public int Upclass (string table,int classid)/column Move up one
The move of the public int moveclass (string table,int classid,int target)//column
public int DeleteTree (string table,int classid)/Delete column tree
Public DataTable list (string table)//For listing columns
public int Getclassidordernum (string table,int classid)//Get Sort ID of column
public bool Checkexist (string table,int classid)/Check column exists
public string GetChildren (string table,int classid)//List all sub columns of a column
public int Modiclass (string table,int classid,string classname)/Modify column
public string Classmap (string table,int classid)//column navigation, map
public string GetClassName (string table,int classid)//Get column name
public int reset (string table)//Reset bit all category to one level column
public int Deleteclass (string table,int classid)/Delete column
public static void ItemCreated (Object Sender, System.Web.UI.WebControls.RepeaterItemEventArgs e,string ctlname,string CTLNAME2)//column of the time of the repeater event
public static string GetOptions (String Table,int type,int selected)//options for Select
public Object AddClass (string table,string classname,int ParentID)//Add Category
Current 1/3 page 123 Next read the full text
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.