C#无限栏目分级程序代码分享 好东西第1/3页
数据库表的结构必须有以下字段:
screen.width*0.7) {this.resized=true; this.width=screen.width*0.7; this.style.cursor='hand'; this.alt='Click here to open new window\nCTRL+Mouse wheel to zoom in/out';}" onclick="if(!this.resized) {return true;} else {window.open('http://ent.omeweb.com/book/admin/arti_ad/eWebEditor/UploadFile/200612278462542.gif');}" alt="" src="http://ent.omeweb.com/book/admin/arti_ad/eWebEditor/UploadFile/200612278462542.gif" onload="if(this.width>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>
各个字段的说明:
screen.width*0.7) {this.resized=true; this.width=screen.width*0.7; this.style.cursor='hand'; this.alt='Click here to open new window\nCTRL+Mouse wheel to zoom in/out';}" onclick="if(!this.resized) {return true;} else {window.open('http://ent.omeweb.com/book/admin/arti_ad/eWebEditor/UploadFile/200612278595784.gif');}" alt="" src="http://ent.omeweb.com/book/admin/arti_ad/eWebEditor/UploadFile/200612278595784.gif" onload="if(this.width>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,本示例核心为idb.cs,db.cs和action.cs,分别说明下作用
idb.cs:数据库操作类的接口,代码如下: using System;
using System.Data;
namespace catalog
{
/// <summary>
/// idb 的摘要说明。
/// </summary>
interface idb
{
//
//void open();构造函数当然不能在接口里声明
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实例这个接口: using System;
using System.Data;
using System.Data.OleDb;
using System.Data.SqlClient;
using System.Configuration;
//using System.Web;
namespace catalog
{
/// <summary>
/// db 的摘要说明。
/// </summary>
public class db:idb
{
private IDbConnection con;
private IDbCommand cm;
private string dbtype="access";
public db()
{
//
// TODO: 在此处添加构造函数逻辑
//
dbtype=ConfigurationSettings.AppSettings["dbtype"];
if (dbtype==null)
dbtype="";
if (dbtype.ToLower()=="sqlserver")
{
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: 在此处添加构造函数逻辑
//
dbtype=ConfigurationSettings.AppSettings["dbtype"];
if (dbtype==null)
dbtype="";
if (dbtype.ToLower()=="sqlserver")
{
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 cm.ExecuteNonQuery();
}
public object getvalue(string sql)
{
cm.CommandText=sql;
//return 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()=="sqlserver")
{
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 cm.ExecuteReader();
}
public string constr
{
get{return ConfigurationSettings.AppSettings["cnstr"];}
}
public System.Data.IDbCommand command(string sql)
{
cm.CommandText=sql;
return cm;
}
}
}
C#无限栏目分级程序代码分享[2] 核心类说明
本程序采用C#为脚本编写,同时支持ACCESS/SQL SERVER数据库。
本程序功能:栏目无限分级,栏目的移动,添加,排序,删除(栏目树),操作方便,部署、使用更为简单,提供统一的接口程序。
本程序才开发完毕,难免有错误或者BUG,欢迎提出,不甚感激。
核心类文件方法调用说明
public void deleteAllCatalog(string table) //清空栏目表
public int downClass(string table,int classid) //栏目向下移动一位
public int upClass(string table,int classid)//栏目向上移动一位
public int moveClass(string table,int classid,int target)//栏目的移动
public int deleteTree(string table,int classid)//删除栏目树
public DataTable list(string table)//用于列出栏目列表
public int getClassidOrderNum(string table,int classid)//得到栏目的排序ID
public bool checkExist(string table,int classid)//检查栏目是否存在
public string getChildren(string table,int classid)//列出一个栏目所有的子栏目
public int modiClass(string table,int classid,string classname)//修改栏目
public string classMap(string table,int classid)//栏目导航,地图
public string getClassName(string table,int classid)//得到栏目名称
public int reset(string table)//重新置位全部类别为一级栏目
public int deleteClass(string table,int classid)//删除栏目
public static void itemcreated(Object Sender, System.Web.UI.WebControls.RepeaterItemEventArgs e,string ctlname,string ctlname2)//列栏目的时候的repeater的事件
public static string getOptions(string table,int type,int selected)//用于select的options
public object addClass(string table,string classname,int parentid)//添加类别
当前1/3页 123下一页阅读全文