|
Server : Microsoft-IIS/10.0 System : Windows NT EBS-6136 10.0 build 17763 (Windows Server 2016) i586 User : jxgj ( 0) PHP Version : 7.0.33 Disable Function : passthru,exec,system,shell_exec,proc_open,popen,pcntl_exec,socket_bind,stream_socket_server Directory : D:/tmp_aspnet/root/5f1e4137/8eca010b/ |
?#pragma checksum "D:\wwwroot\njjbjycom\wwwroot\App_Code\DataBaseHepler.cs" "{ff1816ec-aa5e-4d10-87f7-6f4963833460}" "C0B6AAFF9E650084E3A5A33F4BE4D2F8134D0A35"
#line 1 "D:\wwwroot\njjbjycom\wwwroot\App_Code\DataBaseHepler.cs"
using System;
using System.Data;
using System.Configuration;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using System.Data.OleDb;
using System.Data.SqlClient;
using System.Data.Common;
using System.Xml.Serialization;
using System.IO;
using System.Text;
public enum DataBaseType
{
Access,
SQL
}
/// <summary>
///DataBaseHepler 的提要注明
///对数据库进行的一系列操作
/// </summary>
public sealed class DataBaseHepler
{
private static DataBaseType dbtDataSourceType;
private static string strConnection;
/// <summary>
/// 数据库链接字符串
/// </summary>
public static string ConnectionString
{
get { return strConnection; }
set { strConnection = value; }
}
/// <summary>
/// 数据库类型
/// </summary>
public static DataBaseType DataSourceType
{
get { return dbtDataSourceType; }
set { dbtDataSourceType = value; }
}
static DataBaseHepler()
{
//判断数据库的类型
if (ConfigurationManager.AppSettings["DataType"] == "ACCESS")
{
dbtDataSourceType = DataBaseType.Access; //access数据库
string str = HttpContext.Current.Server.MapPath(@"~\App_Data\CMSDB.mdb");
strConnection = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source='" + str + "'";
}
else
{
//sql数据库
dbtDataSourceType = DataBaseType.SQL;
strConnection = System.Configuration.ConfigurationSettings.AppSettings["SqlConnStr"];
byte[] data = Convert.FromBase64String(strConnection);
strConnection = System.Text.ASCIIEncoding.ASCII.GetString(data);
}
}
/// <summary>
/// 获得一个链接对象
/// </summary>
/// <returns></returns>
public static IDbConnection GetConnection()
{
IDbConnection cnn;
switch (DataSourceType)
{
case DataBaseType.Access:
cnn = new OleDbConnection(ConnectionString);
break;
case DataBaseType.SQL:
cnn = new SqlConnection(ConnectionString);
break;
default:
cnn = new OleDbConnection(ConnectionString);
break;
}
return cnn;
}
/// <summary>
/// 获得一个链接对象
/// </summary>
/// <returns></returns>
public static OleDbConnection GetConn()
{
OleDbConnection cnn = new OleDbConnection(ConnectionString);
return cnn;
}
public static IDbCommand GetCommand()
{
IDbCommand cmd;
switch (DataSourceType)
{
case DataBaseType.Access:
cmd = new OleDbCommand("", (OleDbConnection)GetConnection());
break;
case DataBaseType.SQL:
cmd = new SqlCommand("", (SqlConnection)GetConnection());
break;
default:
cmd = new OleDbCommand("", (OleDbConnection)GetConnection());
break;
}
return cmd;
}
public static IDbCommand GetCommand(string sql)
{
IDbCommand cmd;
switch (DataSourceType)
{
case DataBaseType.Access:
cmd = new OleDbCommand(sql, (OleDbConnection)GetConnection());
break;
case DataBaseType.SQL:
cmd = new SqlCommand(sql, (SqlConnection)GetConnection());
break;
default:
cmd = new OleDbCommand(sql, (OleDbConnection)GetConnection());
break;
}
return cmd;
}
public static IDbCommand GetCommand(string sql, IDbConnection cnn)
{
IDbCommand cmd;
switch (DataSourceType)
{
case DataBaseType.Access:
cmd = new OleDbCommand(sql, (OleDbConnection)cnn);
break;
case DataBaseType.SQL:
cmd = new SqlCommand(sql, (SqlConnection)cnn);
break;
default:
cmd = new OleDbCommand(sql, (OleDbConnection)cnn);
break;
}
return cmd;
}
public static DbDataAdapter GetAdapter()
{
DbDataAdapter da;
switch (dbtDataSourceType)
{
case DataBaseType.Access:
da = new OleDbDataAdapter((OleDbCommand)GetCommand());
break;
case DataBaseType.SQL:
da = new SqlDataAdapter((SqlCommand)GetCommand());
break;
default:
da = new OleDbDataAdapter((OleDbCommand)GetCommand());
break;
}
return da;
}
public static DbDataAdapter GetAdapter(string sql)
{
DbDataAdapter da;
switch (dbtDataSourceType)
{
case DataBaseType.Access:
da = new OleDbDataAdapter((OleDbCommand)GetCommand(sql));
break;
case DataBaseType.SQL:
da = new SqlDataAdapter((SqlCommand)GetCommand(sql));
break;
default:
da = new OleDbDataAdapter((OleDbCommand)GetCommand(sql));
break;
}
return da;
}
/// <summary>
/// 凭据SQL语句创建DataSet数据集;
/// 能够执行多条SELECT查问语句,查问语句之间用分号象征,如下所示:
/// SELECT * FROM TABLE1;SELECT * FROM TABLE2
/// </summary>
/// <param name="sqlQuery">SQL语句</param>
/// <returns>返回DataSet数据集,表名为table1,table2....</returns>
public static DataSet GetDataSet(string sql)
{
DbDataAdapter da = null;
DataSet ds = new DataSet();
int i = 1;
string[] strSqls = sql.Split(';');
foreach (string strSql in strSqls)
{
da = GetAdapter(strSql);
da.Fill(ds, "table" + i.ToString());
i++;
}
return ds;
}
public static void ReturnDt(DataTable dt, string sql)
{
HttpContext.Current.Response.Write(GetConnection().ConnectionString.ToString());
OleDbCommand odc = new OleDbCommand(sql, (OleDbConnection)GetConnection());
OleDbDataAdapter odda = new OleDbDataAdapter(odc);
odda.Fill(dt);
}
/// <summary>
/// 执行SELECT查问语句,并将了局以TABLE的大局参与到指定DataSet数据集;
/// 能够执行多条SELECT查问语句,查问语句之间用分号象征,如下所示:
/// SELECT * FROM TABLE1;SELECT * FROM TABLE2
/// </summary>
/// <param name="sqlQuery">SQL语句</param>
/// <param name="dsTarget">已存在的DataSet数据集</param>
/// <returns>返回DataSet数据集,表名为table1,table2....</returns>
public static DataSet GetDataSet(string sql, DataSet ds)
{
DbDataAdapter da = null;
int i = ds.Tables.Count + 1;
string[] strSqls = sql.Split(';');
foreach (string strSql in strSqls)
{
da = GetAdapter(strSql);
da.Fill(ds, "table" + i.ToString());
i++;
}
return ds;
}
/// <summary>
/// 凭据SQL语句创建DataReader
/// </summary>
/// <param name="sqlQuery">SQL语句</param>
/// <returns>返回DataReader</returns>
public static IDataReader GetDataReader(string sql)
{
IDbConnection cnn = GetConnection();
cnn.Open();
IDbCommand cmd = GetCommand(sql, cnn);
IDataReader da = cmd.ExecuteReader(CommandBehavior.CloseConnection);
return da;
cnn.Close();
}
/// <summary>
/// 凭据SQL语句执行ExecuteNonQuery操作
/// </summary>
/// <param name="sqlQuery">SQL语句</param>
public static int ExecCommand(string sql)
{
IDbConnection cnn = GetConnection();
cnn.Open();
IDbCommand cmd = GetCommand(sql, cnn);
int i = cmd.ExecuteNonQuery();
cnn.Close();
cnn.Dispose();
return i;
}
/// <summary>
/// 返回sql语句第一列第一行的值
/// </summary>
/// <param name="sql"></param>
/// <returns></returns>
public static string GetSqlResult(string sql)
{
string str = "";
IDbConnection cnn = GetConnection();
cnn.Open();
IDbCommand cmd = GetCommand(sql, cnn);
if (cmd.ExecuteScalar() == null)
{
cnn.Close();
return "";
}
else
{
str = cmd.ExecuteScalar().ToString();
}
cnn.Close();
cnn.Dispose();
return str;
}
/// <summary>
/// 获取单页标题
/// </summary>
public static string GetSingleTitle(object id)
{
string strTitle = string.Empty;
int id1 = 1;
if (id != null && id != "")
{
id1 = Convert.ToInt32(id);
}
DataTable dtSingle = BusinessLogic.ReturnDt("select * from system_Contents where ID=" + id1);
if (dtSingle.Rows.Count > 0)
{
strTitle = Convert.ToString(dtSingle.Rows[0]["Title"]);
}
return strTitle;
}
/// <summary>
/// 获取单页内容
/// </summary>
public static string GetSingleContent(object id)
{
string strContent = string.Empty;
int id1 = 1;
if (id != null && id != "")
{
id1 = Convert.ToInt32(id);
}
DataTable dtSingle = BusinessLogic.ReturnDt("select * from system_Contents where ID=" + id1);
if (dtSingle.Rows.Count > 0)
{
strContent = Convert.ToString(dtSingle.Rows[0]["Content"]);
}
return strContent;
}
public static string GetSingleService(object id)
{
string strContent = string.Empty;
int id1 = 1;
if (id != null && id != "")
{
id1 = Convert.ToInt32(id);
}
DataTable dtSingle = BusinessLogic.ReturnDt("select * from system_Services where ID=" + id1);
if (dtSingle.Rows.Count > 0)
{
strContent = Convert.ToString(dtSingle.Rows[0]["Content"]);
}
return strContent;
}
/// <summary>
/// 获取单页内容
/// </summary>
///
public static string GetSingleContent(object id,int length)
{
string strContent = string.Empty;
int id1 = 1;
if (id != null && id != "")
{
id1 = Convert.ToInt32(id);
}
DataTable dtSingle = BusinessLogic.ReturnDt("select * from system_Contents where ID=" + id1);
if (dtSingle.Rows.Count > 0)
{
strContent = StringPlus.CutString(StringPlus.DropHTML(Convert.ToString(dtSingle.Rows[0]["Content"])), length);
}
return strContent;
}
public static string GetAnliContent(object id, int length)
{
string strContent = string.Empty;
int id1 = 1;
if (id != null && id != "")
{
id1 = Convert.ToInt32(id);
}
DataTable dtSingle = BusinessLogic.ReturnDt("select * from system_CaseTypes where ID=" + id1);
if (dtSingle.Rows.Count > 0)
{
strContent = StringPlus.CutString(StringPlus.DropHTML(Convert.ToString(dtSingle.Rows[0]["Content"])), length);
}
return strContent;
}
//public static string GetJMContent(object id, int length)
//{
// string strContent = string.Empty;
// int id1 = 1;
// if (id != null && id != "")
// {
// id1 = Convert.ToInt32(id);
// }
// DataTable dtSingle = BusinessLogic.ReturnDt("select * from system_ServiceTypes where ID=" + id1);
// if (dtSingle.Rows.Count > 0)
// {
// strContent = StringPlus.CutString(StringPlus.DropHTML(Convert.ToString(dtSingle.Rows[0]["Content"])), length);
// }
// return strContent;
//}
/// <summary>
/// 获取单页内容
/// </summary>
public static string GetSingleJianJie(object id, int length)
{
string strContent = string.Empty;
int id1 = 1;
if (id != null && id != "")
{
id1 = Convert.ToInt32(id);
}
DataTable dtSingle = BusinessLogic.ReturnDt("select * from system_Contents where ID=" + id1);
if (dtSingle.Rows.Count > 0)
{
strContent = StringPlus.CutString(Convert.ToString(dtSingle.Rows[0]["Contents1"]), length);
}
return strContent;
}
/// <summary>
/// 获取单页标题
/// </summary>
public static string GetColumnInfoTitle(object id)
{
string strTitle = string.Empty;
int id1 = Convert.ToInt32(id);
DataTable dtSingle = BusinessLogic.ReturnDt("select * from system_ColumnInfo where ID=" + id1);
if (dtSingle.Rows.Count > 0)
{
strTitle = Convert.ToString(dtSingle.Rows[0]["Title"]);
}
return strTitle;
}
/// <summary>
/// 获取单页内容
/// </summary>
public static string GetColumnInfoContent(object id)
{
string strContent = string.Empty;
int id1 = Convert.ToInt32(id);
DataTable dtSingle = BusinessLogic.ReturnDt("select * from system_ColumnInfo where ID=" + id1);
if (dtSingle.Rows.Count > 0)
{
strContent = Convert.ToString(dtSingle.Rows[0]["Content"]);
}
return strContent;
}
/// <summary>
/// 获取单页标题
/// </summary>
public static string GetStandardTitle(object id)
{
string strTitle = string.Empty;
int id1 = Convert.ToInt32(id);
DataTable dtSingle = BusinessLogic.ReturnDt("select * from system_Products where ID=" + id1);
if (dtSingle.Rows.Count > 0)
{
strTitle = Convert.ToString(dtSingle.Rows[0]["Title"]);
}
return strTitle;
}
/// <summary>
/// 获取单页内容
/// </summary>
public static string GetStandardContent(object id)
{
string strContent = string.Empty;
int id1 = Convert.ToInt32(id);
DataTable dtSingle = BusinessLogic.ReturnDt("select * from system_Products where ID=" + id1);
if (dtSingle.Rows.Count > 0)
{
strContent = Convert.ToString(dtSingle.Rows[0]["Content"]);
}
return strContent;
}
/// <summary>
/// 获取单页内容
/// </summary>
public static string GetColumnInfoContent(object id, int length)
{
string strContent = string.Empty;
int id1 = Convert.ToInt32(id);
DataTable dtSingle = BusinessLogic.ReturnDt("select * from system_ColumnInfo where ID=" + id1);
if (dtSingle.Rows.Count > 0)
{
strContent = StringPlus.CutString(StringPlus.DropHTML(Convert.ToString(dtSingle.Rows[0]["Content"])), length);
}
return strContent;
}
/// <summary>
/// 获取单页内容
/// </summary>
public static string GetSingleContent(object id, bool result)
{
string strContent = string.Empty;
int id1 = 1;
if (id != null && id != "")
{
id1 = Convert.ToInt32(id);
}
DataTable dtSingle = BusinessLogic.ReturnDt("select * from system_Contents where ID=" + id1);
if (dtSingle.Rows.Count > 0)
{
strContent = StringPlus.DropHTML(Convert.ToString(dtSingle.Rows[0]["Content"]));
}
return strContent;
}
/// <summary>
/// 获取图片
/// </summary>
public static string GetSingleImage(object id)
{
string strImage = string.Empty;
int id1 = 1;
if (id != null && id != "")
{
id1 = Convert.ToInt32(id);
}
DataTable dtSingle = BusinessLogic.ReturnDt("select * from system_Contents where ID=" + id1);
if (dtSingle.Rows.Count > 0)
{
strImage = Convert.ToString(dtSingle.Rows[0]["ImgUrl"]);
}
return strImage;
}
public static string GetBanner(object sort)
{
string strImage = string.Empty;
int sort1 = 1;
if (sort != null && sort != "")
{
sort1 = Convert.ToInt32(sort);
}
DataTable dtSingle = BusinessLogic.ReturnDt("select * from system_Banaers where ClassId=1 and Sort=" + sort1);
if (dtSingle.Rows.Count > 0)
{
strImage = Convert.ToString(dtSingle.Rows[0]["ImgUrl"]);
}
return strImage;
}
/// <summary>
/// 获取单页内容
/// </summary>
public static string GetSeoValueContent(int id)
{
string strContent = string.Empty;
DataTable dtSeoValue = BusinessLogic.ReturnDt("select * from system_Columns where ID=" + id);
if (dtSeoValue.Rows.Count > 0)
{
strContent = Convert.ToString(dtSeoValue.Rows[0]["MiaoSu"]);
}
return strContent;
}
/// <summary>
/// 获取援手中心单页标题
/// </summary>
public static string GetHelpSingleTitle(object id)
{
string strTitle = string.Empty;
int id1 = 4;
if (id != null && id != "")
{
id1 = Convert.ToInt32(id);
}
DataTable dtSingle = BusinessLogic.ReturnDt("select * from system_Contents where ID=" + id1);
if (dtSingle.Rows.Count > 0)
{
strTitle = Convert.ToString(dtSingle.Rows[0]["Title"]);
}
return strTitle;
}
/// <summary>
/// 获取援手中心单页内容
/// </summary>
public static string GetHelpSingleContent(object id)
{
string strContent = string.Empty;
int id1 = 4;
if (id != null && id != "")
{
id1 = Convert.ToInt32(id);
}
DataTable dtSingle = BusinessLogic.ReturnDt("select * from system_Contents where ID=" + id1);
if (dtSingle.Rows.Count > 0)
{
strContent = Convert.ToString(dtSingle.Rows[0]["Content"]);
}
return strContent;
}
/// <summary>
/// 获取单页内容
/// </summary>
public static string GetSingleContent1(object id)
{
string strContent = string.Empty;
int id1 = 4;
if (id != null && id != "")
{
id1 = Convert.ToInt32(id);
}
DataTable dtSingle = BusinessLogic.ReturnDt("select * from system_Contents where ID=" + id1);
if (dtSingle.Rows.Count > 0)
{
strContent = Convert.ToString(dtSingle.Rows[0]["Contents1"]);
}
return strContent;
}
/// <summary>
/// 获取图片
/// </summary>
public static string GetSeoValueImg(int id)
{
string strImage = string.Empty;
DataTable dtSeoValue = BusinessLogic.ReturnDt("select * from system_Columns where ID=" + id);
if (dtSeoValue.Rows.Count > 0)
{
strImage = "<img src='" + Convert.ToString(dtSeoValue.Rows[0]["ImgUrl"]) + "' width='520px' height='170px' alt='" + Convert.ToString(dtSeoValue.Rows[0]["Title"]) + "'";
}
return strImage;
}
/// <summary>
/// 获取产品类型名称
/// </summary>
public static string GetPtName(int id)
{
string ptname = string.Empty;
DataTable dtSingle = BusinessLogic.ReturnDt("select * from system_ProductTypes where ID=" + id);
if (dtSingle.Rows.Count > 0)
{
ptname = Convert.ToString(dtSingle.Rows[0]["Title"]);
}
return ptname;
}
/// <summary>
/// 获取产品父类名称
/// </summary>
public static string GetParentPtName(int id)
{
string ptname = string.Empty;
DataTable dtSingle = BusinessLogic.ReturnDt("select * from system_ProductTypes where ID=" + id);
if (dtSingle.Rows.Count > 0)
{
DataTable dtPt = BusinessLogic.ReturnDt("select * from system_ProductTypes where ID=" + Convert.ToInt32(dtSingle.Rows[0]["ClassID"]));
if (dtPt.Rows.Count > 0)
{
ptname = Convert.ToString(dtPt.Rows[0]["Title"]);
}
}
return ptname;
}
/// <summary>
/// 获取产品父类ID
/// </summary>
public static string GetParentPtID(int id)
{
string ptID = string.Empty;
DataTable dtSingle = BusinessLogic.ReturnDt("select * from system_ProductTypes where ID=" + id);
if (dtSingle.Rows.Count > 0)
{
DataTable dtPt = BusinessLogic.ReturnDt("select * from system_ProductTypes where ID=" + Convert.ToInt32(dtSingle.Rows[0]["ClassID"]));
if (dtPt.Rows.Count > 0)
{
ptID = Convert.ToString(dtPt.Rows[0]["ID"]);
}
}
return ptID;
}
/// <summary>
/// 获取链接地址
/// </summary>
public static string GetLinkUrl(int id)
{
string linkUrl = string.Empty;
DataTable dtSingle = BusinessLogic.ReturnDt("select * from system_Links where ID=" + id);
if (dtSingle.Rows.Count > 0)
{
linkUrl = Convert.ToString(dtSingle.Rows[0]["LinkUrl"]);
}
return linkUrl;
}
/// <summary>
/// 凭据提供的sql语句获取system_ColumnInfo信息
/// </summary>
/// <returns></returns>
public static DataTable SQLDataTableArticle(string order)
{
DataTable dtSql = BusinessLogic.ReturnDt("select * from system_ColumnInfo "+order);
return dtSql;
}
/// <summary>
/// 凭据提供的sql语句获取system_ColumnInfo信息(top)
/// </summary>
/// <returns></returns>
public static DataTable SQLDataTableArticle(string order,string condition)
{
DataTable dtSql = BusinessLogic.ReturnDt("select * from system_ColumnInfo " + condition + " " + order);
return dtSql;
}
/// <summary>
/// 凭据提供的sql语句获取system_ColumnInfo信息(top,where)
/// </summary>
/// <returns></returns>
public static DataTable SQLDataTableArticle(int top, string condition, string order)
{
DataTable dtSql = BusinessLogic.ReturnDt("select top " + top + " * from system_ColumnInfo " + condition + " " + order);
return dtSql;
}
/// <summary>
/// 凭据ID获取会员信息
/// </summary>
/// <returns></returns>
public static string SQLDataTableMemberID(int id)
{
string mName = string.Empty;
DataTable dtSql = BusinessLogic.ReturnDt("select * from system_Members where ID="+id);
if (dtSql.Rows.Count > 0)
{ mName = Convert.ToString(dtSql.Rows[0]["MenAccount"]); }
return mName;
}
/// <summary>
/// 凭据会员名称获取会员信息
/// </summary>
/// <returns></returns>
public static int SQLDataTableMemberName(string mName)
{
int mId = 0;
DataTable dtSql = BusinessLogic.ReturnDt("select * from system_Members where MenAccount='" + mName + "' or MenEmail='" + mName + "'");
if (dtSql.Rows.Count > 0)
{ mId = Convert.ToInt32(dtSql.Rows[0]["ID"]); }
return mId;
}
/// <summary>
/// 获取产品凭据前提
/// </summary>
/// <returns></returns>
public static DataTable SQLGetProductByOrder(string whereby)
{
DataTable dtProduct = BusinessLogic.ReturnDt("select ID,ClassId,Title,Code,XingHao,onePrice,twoPrice,threePrice,fivePrice,Bxtj,Ycl,YclImg,Shrq,Shjr,Clicks,ImgUrl,ImgTwoUrl,SmallImg,SmallImg,PostTime,Introduction,Content,Content1,Content2,Recommend,NewPro,Hot,CuXiao,MarqueePro,ParentID,Sort,Products1,Products2,Products3 from system_Products where " + whereby + " order by Sort asc,ID desc");
return dtProduct;
}
/// <summary>
/// 获取Top产品凭据前提
/// </summary>
/// <returns></returns>
public static DataTable SQLGetProductByOrder(int top, string whereby)
{
DataTable dtProduct = BusinessLogic.ReturnDt("select top " + top + " ID,ClassId,Title,Code,XingHao,onePrice,twoPrice,threePrice,fivePrice,Bxtj,Ycl,YclImg,Shrq,Shjr,Clicks,ImgUrl,ImgTwoUrl,SmallImg,SmallImg,PostTime,Introduction,Content,Content1,Content2,Recommend,NewPro,Hot,CuXiao,MarqueePro,ParentID,Sort,Products1,Products2,Products3 from system_Products where " + whereby + " order by Sort asc,ID desc");
return dtProduct;
}
/// <summary>
/// 获取单页栏目列表
/// </summary>
/// <param name="columnid"></param>
/// <returns></returns>
public static StringBuilder ContentColumnList(int columnid)
{
StringBuilder ColumnList = new StringBuilder();
DataTable dtColumns = BusinessLogic.ReturnDt("select ID,ClassId,Title,Sort from system_Contents where ClassId=" + columnid + " order by Sort asc,ID desc");
if (dtColumns.Rows.Count > 0)
{
for (int m = 0; m < dtColumns.Rows.Count; m++)
{
ColumnList.Append("<div class=\"ma_menu_left_div\">");
ColumnList.Append("<img src=\"../Images/tree_03.gif\" width=\"12px\" height=\"12px\" alt=\"\" /> ");
ColumnList.Append("<a href=\"system_Content.aspx?id=" + Convert.ToString(dtColumns.Rows[m]["ID"]) + "\" target=\"contentList\">" + Convert.ToString(dtColumns.Rows[m]["Title"]) + "</a>");
ColumnList.Append("</div>");
}
}
return ColumnList;
}
public static StringBuilder ContentServiceList(int columnid)
{
StringBuilder ColumnList = new StringBuilder();
DataTable dtColumns = BusinessLogic.ReturnDt("select ID,ClassId,Title,Sort from system_Services where ClassId=" + columnid + " order by Sort asc,ID desc");
if (dtColumns.Rows.Count > 0)
{
for (int m = 0; m < dtColumns.Rows.Count; m++)
{
ColumnList.Append("<div class=\"ma_menu_left_div\">");
ColumnList.Append("<img src=\"../Images/tree_03.gif\" width=\"12px\" height=\"12px\" alt=\"\" /> ");
ColumnList.Append("<a href=\"system_Content.aspx?id=" + Convert.ToString(dtColumns.Rows[m]["ID"]) + "\" target=\"contentList\">" + Convert.ToString(dtColumns.Rows[m]["Title"]) + "</a>");
ColumnList.Append("</div>");
}
}
return ColumnList;
}
/// <summary>
/// 获取类别号称
/// </summary>
/// <param name="id"></param>
/// <returns></returns>
public static string GetPtName(string tablename,int id)
{
string TName = string.Empty;
DataTable dtCourse = BusinessLogic.ReturnDt("select ID,Title,Sort from " + tablename + " where ID=" + id);
if (dtCourse.Rows.Count > 0)
{
TName = Convert.ToString(dtCourse.Rows[0]["Title"]);
}
return TName;
}
}
public sealed class Paper
{
/// <summary>
/// 返回分页数据源
/// </summary>
/// <param name="sql">sql语句</param>
/// <param name="i">每页几多笔纪录</param>
/// <returns></returns>
public static PagedDataSource GetPageDataSource(string sql, int i)
{
PagedDataSource pds = new PagedDataSource();
DataSet ds = DataBaseHepler.GetDataSet(sql);
pds.DataSource = ds.Tables["table1"].DefaultView;
pds.PageSize = i;
pds.AllowPaging = true;
return pds;
}
/// <summary>
/// 返回分页工具条
/// </summary>
/// <param name="pds">PagedDataSource对象</param>
/// <param name="url">获取当前地址可使用Request.Url.ToString()</param>
/// <returns></returns>
public static string GetPagination(PagedDataSource pds, string url)
{
string str, str1, str2, str3, str4;
if (url.IndexOf("?") == -1)
{
url = url + "?page=";
}
else
{
if (url.IndexOf("page=") == -1)
{
url = url + "&page=";
}
else
{
url = url.Substring(0, url.IndexOf("page=") + 5);
}
}
str1 = "页次:" + Convert.ToString(pds.CurrentPageIndex + 1) + "/" + pds.PageCount.ToString();
str2 = " 每页" + pds.PageSize.ToString() + "条 共" + pds.DataSourceCount.ToString() + "条";
if (!pds.IsFirstPage)
{
str3 = " <a href='" + url + "1" + "'>首页</a> <a href='" + url + pds.CurrentPageIndex.ToString() + "'>上一页</a>";
}
else
{
str3 = " ";
}
if (!pds.IsLastPage)
{
str4 = " <a href='" + url + Convert.ToString(pds.CurrentPageIndex + 2) + "'>下一页</a> <a href='" + url + pds.PageCount.ToString() + "'>末页</a>";
}
else
{
str4 = " ";
}
str = str1 + str2 + str3 + str4;
return str;
}
/// <summary>
/// 读取配置文件
/// </summary>
/// <param name="configFilePath"></param>
/// <returns></returns>
public static WebSet loadConfig(string configFilePath)
{
return (WebSet)Load(typeof(WebSet), configFilePath);
}
private static object lockHelper = new object();
public static WebSet saveConifg(WebSet mode, string configFilePath)
{
lock (lockHelper)
{
Save(mode, configFilePath);
}
return mode;
}
/// <summary>
/// 读取邮件配置文件
/// </summary>
/// <param name="configFilePath"></param>
/// <returns></returns>
public static EmailSet loadConfigEmail(string configFilePath)
{
return (EmailSet)Load(typeof(EmailSet), configFilePath);
}
private static object lockHelperEmail = new object();
public static EmailSet saveConifgEmail(EmailSet mode, string configFilePath)
{
lock (lockHelperEmail)
{
Save(mode, configFilePath);
}
return mode;
}
/// <summary>
/// 读取配置文件
/// </summary>
/// <param name="configFilePath"></param>
/// <returns></returns>
public static FuctionConfig loadConfigFuction(string configFilePath)
{
return (FuctionConfig)Load(typeof(FuctionConfig), configFilePath);
}
private static object lockHelperFuction = new object();
/// <summary>
/// 写入站点配置文件
/// </summary>
public static FuctionConfig saveConifgFuction(FuctionConfig mode, string configFilePath)
{
lock (lockHelperFuction)
{
Save(mode, configFilePath);
}
return mode;
}
/// <summary>
/// 读取配置文件
/// </summary>
/// <param name="configFilePath"></param>
/// <returns></returns>
public static UploadConfig loadConfigUpload(string configFilePath)
{
return (UploadConfig)Load(typeof(UploadConfig), configFilePath);
}
private static object lockHelperUpload = new object();
/// <summary>
/// 写入站点配置文件
/// </summary>
public static UploadConfig saveConifgUpload(UploadConfig mode, string configFilePath)
{
lock (lockHelperUpload)
{
Save(mode, configFilePath);
}
return mode;
}
/// <summary>
/// 反序列化
/// </summary>
/// <param name="type">对象类型</param>
/// <param name="filename">文件蹊径</param>
/// <returns></returns>
public static object Load(Type type, string filename)
{
FileStream fs = null;
try
{
fs = new FileStream(filename, FileMode.Open, FileAccess.Read, FileShare.ReadWrite);
XmlSerializer serializer = new XmlSerializer(type);
return serializer.Deserialize(fs);
}
catch (Exception ex)
{
throw ex;
}
finally
{
if (fs != null)
fs.Close();
}
}
/// <summary>
/// 序列化
/// </summary>
/// <param name="obj">对象</param>
/// <param name="filename">文件蹊径</param>
public static void Save(object obj, string filename)
{
FileStream fs = null;
try
{
fs = new FileStream(filename, FileMode.Create, FileAccess.Write, FileShare.ReadWrite);
XmlSerializer serializer = new XmlSerializer(obj.GetType());
serializer.Serialize(fs, obj);
}
catch (Exception ex)
{
throw ex;
}
finally
{
if (fs != null)
fs.Close();
}
}
}
#line default
#line hidden