diff --git a/App.code/DAL/about.cs b/App.code/DAL/about.cs
new file mode 100644
index 0000000..6f01e27
--- /dev/null
+++ b/App.code/DAL/about.cs
@@ -0,0 +1,291 @@
+using System;
+using System.Data;
+using System.Text;
+using System.Data.SqlClient;
+
+namespace Basic.DAL
+{
+ ///
+ /// 最终内容
+ ///
+ public partial class about
+ {
+ ///
+ /// 增加一条数据
+ ///
+ public int Add(Basic.Model.about model)
+ {
+ StringBuilder strSql = new StringBuilder();
+ strSql.Append("insert into tb_about(");
+ strSql.Append("class_id,parent_id,guid,title,url,path,fujian,seo_title,seo_keywords,seo_description,content,paixu,hits,status,user_id,add_time)");
+ strSql.Append(" values (");
+ strSql.Append("@class_id,@parent_id,@guid,@title,@url,@path,@fujian,@seo_title,@seo_keywords,@seo_description,@content,@paixu,@hits,@status,@user_id,@add_time)");
+ strSql.Append(";select @@IDENTITY");
+
+ SqlParameter[] parameters = {
+ new SqlParameter("@class_id", SqlDbType.Int,10),
+ new SqlParameter("@parent_id", SqlDbType.Int,10),
+ new SqlParameter("@guid", SqlDbType.NVarChar,50),
+ new SqlParameter("@title", SqlDbType.NVarChar,100),
+ new SqlParameter("@url", SqlDbType.NVarChar,255),
+ new SqlParameter("@path", SqlDbType.NVarChar,255),
+ new SqlParameter("@fujian", SqlDbType.NVarChar,255),
+ new SqlParameter("@seo_title", SqlDbType.NVarChar,255),
+ new SqlParameter("@seo_keywords", SqlDbType.NVarChar,255),
+ new SqlParameter("@seo_description", SqlDbType.NVarChar,255),
+ new SqlParameter("@content", SqlDbType.NText,1073741823),
+ new SqlParameter("@paixu", SqlDbType.Int,10),
+ new SqlParameter("@hits", SqlDbType.Int,10),
+ new SqlParameter("@status", SqlDbType.Int,10),
+ new SqlParameter("@user_id", SqlDbType.Int,10),
+ new SqlParameter("@add_time", SqlDbType.DateTime,23)};
+ parameters[0].Value = model.class_id;
+ parameters[1].Value = model.parent_id;
+ parameters[2].Value = model.guid;
+ parameters[3].Value = model.title;
+ parameters[4].Value = model.url;
+ parameters[5].Value = model.path;
+ parameters[6].Value = model.fujian;
+ parameters[7].Value = model.seo_title;
+ parameters[8].Value = model.seo_keywords;
+ parameters[9].Value = model.seo_description;
+ parameters[10].Value = model.content;
+ parameters[11].Value = model.paixu;
+ parameters[12].Value = model.hits;
+ parameters[13].Value = model.status;
+ parameters[14].Value = model.user_id;
+ parameters[15].Value = model.add_time;
+
+ object obj = DbHelperSQL.GetSingle(strSql.ToString(), parameters);
+ if (obj == null)
+ {
+ return 0;
+ }
+ else
+ {
+ return Convert.ToInt32(obj);
+ }
+ }
+
+ ///
+ /// 更新一条数据
+ ///
+ public bool Update(Basic.Model.about model)
+ {
+ StringBuilder strSql = new StringBuilder();
+ strSql.Append("update tb_about set ");
+ strSql.Append("class_id=@class_id,");
+ strSql.Append("parent_id=@parent_id,");
+ strSql.Append("guid=@guid,");
+ strSql.Append("title=@title,");
+ strSql.Append("url=@url,");
+ strSql.Append("path=@path,");
+ strSql.Append("fujian=@fujian,");
+ strSql.Append("seo_title=@seo_title,");
+ strSql.Append("seo_keywords=@seo_keywords,");
+ strSql.Append("seo_description=@seo_description,");
+ strSql.Append("content=@content,");
+ strSql.Append("paixu=@paixu,");
+ strSql.Append("hits=@hits,");
+ strSql.Append("status=@status,");
+ strSql.Append("user_id=@user_id,");
+ strSql.Append("add_time=@add_time");
+ strSql.Append(" where class_id=@class_id");
+ SqlParameter[] parameters = {
+ new SqlParameter("@class_id", SqlDbType.Int,10),
+ new SqlParameter("@parent_id", SqlDbType.Int,10),
+ new SqlParameter("@guid", SqlDbType.NVarChar,50),
+ new SqlParameter("@title", SqlDbType.NVarChar,100),
+ new SqlParameter("@url", SqlDbType.NVarChar,255),
+ new SqlParameter("@path", SqlDbType.NVarChar,255),
+ new SqlParameter("@fujian", SqlDbType.NVarChar,255),
+ new SqlParameter("@seo_title", SqlDbType.NVarChar,255),
+ new SqlParameter("@seo_keywords", SqlDbType.NVarChar,255),
+ new SqlParameter("@seo_description", SqlDbType.NVarChar,255),
+ new SqlParameter("@content", SqlDbType.NText,1073741823),
+ new SqlParameter("@paixu", SqlDbType.Int,10),
+ new SqlParameter("@hits", SqlDbType.Int,10),
+ new SqlParameter("@status", SqlDbType.Int,10),
+ new SqlParameter("@user_id", SqlDbType.Int,10),
+ new SqlParameter("@add_time", SqlDbType.DateTime,23),
+ new SqlParameter("@id", SqlDbType.Int,4)};
+ parameters[0].Value = model.class_id;
+ parameters[1].Value = model.parent_id;
+ parameters[2].Value = model.guid;
+ parameters[3].Value = model.title;
+ parameters[4].Value = model.url;
+ parameters[5].Value = model.path;
+ parameters[6].Value = model.fujian;
+ parameters[7].Value = model.seo_title;
+ parameters[8].Value = model.seo_keywords;
+ parameters[9].Value = model.seo_description;
+ parameters[10].Value = model.content;
+ parameters[11].Value = model.paixu;
+ parameters[12].Value = model.hits;
+ parameters[13].Value = model.status;
+ parameters[14].Value = model.user_id;
+ parameters[15].Value = model.add_time;
+ parameters[16].Value = model.id;
+ int rows = DbHelperSQL.ExecuteSql(strSql.ToString(), parameters);
+ if (rows > 0)
+ {
+ return true;
+ }
+ else
+ {
+ return false;
+ }
+ }
+
+ ///
+ /// 删除一条数据
+ ///
+ public bool Delete(int id)
+ {
+ StringBuilder strSql = new StringBuilder();
+ strSql.Append("delete from tb_about");
+ strSql.Append(" where id=@id");
+ SqlParameter[] parameters = {
+ new SqlParameter("@id", SqlDbType.Int,4)};
+ parameters[0].Value = id;
+ int rows = DbHelperSQL.ExecuteSql(strSql.ToString(), parameters);
+ if (rows > 0)
+ {
+ return true;
+ }
+ else
+ {
+ return false;
+ }
+ }
+
+ ///
+ /// 得到一个对象实体
+ ///
+ public Basic.Model.about GetModel(int class_id)
+ {
+ StringBuilder strSql = new StringBuilder();
+ strSql.Append("select top 1 id,class_id,parent_id,guid,title,url,path,fujian,seo_title,seo_keywords,seo_description,content,paixu,hits,status,user_id,add_time from tb_about");
+ strSql.Append(" where class_id=@class_id");
+ SqlParameter[] parameters = {
+ new SqlParameter("@class_id", SqlDbType.Int,4)};
+ parameters[0].Value = class_id;
+ Basic.Model.about model = new Basic.Model.about();
+ DataSet ds = DbHelperSQL.Query(strSql.ToString(), parameters);
+ if (ds.Tables[0].Rows.Count > 0)
+ {
+ if (!string.IsNullOrEmpty(ds.Tables[0].Rows[0]["id"].ToString()))
+ {
+ model.id = int.Parse(ds.Tables[0].Rows[0]["id"].ToString());
+ }
+ if (!string.IsNullOrEmpty(ds.Tables[0].Rows[0]["class_id"].ToString()))
+ {
+ model.class_id = int.Parse(ds.Tables[0].Rows[0]["class_id"].ToString());
+ }
+ if (!string.IsNullOrEmpty(ds.Tables[0].Rows[0]["parent_id"].ToString()))
+ {
+ model.parent_id = int.Parse(ds.Tables[0].Rows[0]["parent_id"].ToString());
+ }
+ if (!string.IsNullOrEmpty(ds.Tables[0].Rows[0]["guid"].ToString()))
+ {
+ model.guid = ds.Tables[0].Rows[0]["guid"].ToString();
+ }
+ if (!string.IsNullOrEmpty(ds.Tables[0].Rows[0]["title"].ToString()))
+ {
+ model.title = ds.Tables[0].Rows[0]["title"].ToString();
+ }
+ if (!string.IsNullOrEmpty(ds.Tables[0].Rows[0]["url"].ToString()))
+ {
+ model.url = ds.Tables[0].Rows[0]["url"].ToString();
+ }
+ if (!string.IsNullOrEmpty(ds.Tables[0].Rows[0]["path"].ToString()))
+ {
+ model.path = ds.Tables[0].Rows[0]["path"].ToString();
+ }
+ if (!string.IsNullOrEmpty(ds.Tables[0].Rows[0]["fujian"].ToString()))
+ {
+ model.fujian = ds.Tables[0].Rows[0]["fujian"].ToString();
+ }
+ if (!string.IsNullOrEmpty(ds.Tables[0].Rows[0]["seo_title"].ToString()))
+ {
+ model.seo_title = ds.Tables[0].Rows[0]["seo_title"].ToString();
+ }
+ if (!string.IsNullOrEmpty(ds.Tables[0].Rows[0]["seo_keywords"].ToString()))
+ {
+ model.seo_keywords = ds.Tables[0].Rows[0]["seo_keywords"].ToString();
+ }
+ if (!string.IsNullOrEmpty(ds.Tables[0].Rows[0]["seo_description"].ToString()))
+ {
+ model.seo_description = ds.Tables[0].Rows[0]["seo_description"].ToString();
+ }
+ if (!string.IsNullOrEmpty(ds.Tables[0].Rows[0]["content"].ToString()))
+ {
+ model.content = ds.Tables[0].Rows[0]["content"].ToString();
+ }
+ if (!string.IsNullOrEmpty(ds.Tables[0].Rows[0]["paixu"].ToString()))
+ {
+ model.paixu = int.Parse(ds.Tables[0].Rows[0]["paixu"].ToString());
+ }
+ if (!string.IsNullOrEmpty(ds.Tables[0].Rows[0]["hits"].ToString()))
+ {
+ model.hits = int.Parse(ds.Tables[0].Rows[0]["hits"].ToString());
+ }
+ if (!string.IsNullOrEmpty(ds.Tables[0].Rows[0]["status"].ToString()))
+ {
+ model.status = int.Parse(ds.Tables[0].Rows[0]["status"].ToString());
+ }
+ if (!string.IsNullOrEmpty(ds.Tables[0].Rows[0]["user_id"].ToString()))
+ {
+ model.user_id = int.Parse(ds.Tables[0].Rows[0]["user_id"].ToString());
+ }
+ if (!string.IsNullOrEmpty(ds.Tables[0].Rows[0]["add_time"].ToString()))
+ {
+ model.add_time = DateTime.Parse(ds.Tables[0].Rows[0]["add_time"].ToString());
+ }
+ return model;
+ }
+ else
+ {
+ return null;
+ }
+ }
+
+ ///
+ /// 获得前几行数据
+ ///
+ public DataSet GetList(int Top, string strWhere, string filedOrder)
+ {
+ StringBuilder strSql = new StringBuilder();
+ strSql.Append("select ");
+ if (Top > 0)
+ {
+ strSql.Append(" top " + Top.ToString());
+ }
+ strSql.Append("id,class_id,parent_id,guid,title,url,path,fujian,seo_title,seo_keywords,seo_description,content,paixu,hits,status,user_id,add_time");
+ strSql.Append(" from tb_about");
+ if (strWhere.Trim() != "")
+ {
+ strSql.Append(" where " + strWhere);
+ }
+ strSql.Append(" order by " + filedOrder);
+ return DbHelperSQL.Query(strSql.ToString());
+ }
+
+ ///
+ /// 是否存在该记录
+ ///
+ public bool Exists(int class_id)
+ {
+ StringBuilder strSql = new StringBuilder();
+ strSql.Append("select count(1) from tb_about");
+ strSql.Append(" where class_id=@class_id");
+ SqlParameter[] parameters = {
+ new SqlParameter("@class_id", SqlDbType.Int,4)};
+ parameters[0].Value = class_id;
+
+ return DbHelperSQL.Exists(strSql.ToString(), parameters);
+ }
+
+ }
+}
+
diff --git a/App.code/DAL/address.cs b/App.code/DAL/address.cs
new file mode 100644
index 0000000..753192e
--- /dev/null
+++ b/App.code/DAL/address.cs
@@ -0,0 +1,665 @@
+using System;
+using System.Data;
+using System.Text;
+using System.Data.SqlClient;
+
+namespace Basic.DAL
+{
+ ///
+ /// 数据访问层address
+ ///
+ public partial class address
+ {
+ ///
+ /// 增加一条数据
+ ///
+ public int Add(Basic.Model.address model)
+ {
+ StringBuilder strSql = new StringBuilder();
+ strSql.Append("insert into tb_address(");
+ strSql.Append("user_id,name,sheng,shi,xian,ssx,xaddress,mobile,phone,email,status,dname,dxaddress,dmobile)");
+ strSql.Append(" values (");
+ strSql.Append("@user_id,@name,@sheng,@shi,@xian,@ssx,@xaddress,@mobile,@phone,@email,@status,@dname,@dxaddress,@dmobile)");
+ strSql.Append(";select @@IDENTITY");
+
+ SqlParameter[] parameters = {
+ new SqlParameter("@user_id", SqlDbType.Int,10),
+ new SqlParameter("@name", SqlDbType.NVarChar,50),
+ new SqlParameter("@sheng", SqlDbType.NVarChar,50),
+ new SqlParameter("@shi", SqlDbType.NVarChar,50),
+ new SqlParameter("@xian", SqlDbType.NVarChar,50),
+ new SqlParameter("@ssx", SqlDbType.NVarChar,255),
+ new SqlParameter("@xaddress", SqlDbType.NVarChar,255),
+ new SqlParameter("@mobile", SqlDbType.NVarChar,50),
+ new SqlParameter("@phone", SqlDbType.NVarChar,50),
+ new SqlParameter("@email", SqlDbType.NVarChar,100),
+ new SqlParameter("@status", SqlDbType.Int,10),
+ new SqlParameter("@dname", SqlDbType.NVarChar,50),
+ new SqlParameter("@dxaddress", SqlDbType.NVarChar,255),
+ new SqlParameter("@dmobile", SqlDbType.NVarChar,50)};
+ parameters[0].Value = model.user_id;
+ parameters[1].Value = model.name;
+ parameters[2].Value = model.sheng;
+ parameters[3].Value = model.shi;
+ parameters[4].Value = model.xian;
+ parameters[5].Value = model.ssx;
+ parameters[6].Value = model.xaddress;
+ parameters[7].Value = model.mobile;
+ parameters[8].Value = model.phone;
+ parameters[9].Value = model.email;
+ parameters[10].Value = model.status;
+ parameters[11].Value = model.dname;
+ parameters[12].Value = model.dxaddress;
+ parameters[13].Value = model.dmobile;
+
+
+ object obj = DbHelperSQL.GetSingle(strSql.ToString(), parameters);
+ if (obj == null)
+ {
+ return 0;
+ }
+ else
+ {
+ return Convert.ToInt32(obj);
+ }
+ }
+
+ ///
+ /// 更新一条数据
+ ///
+ public bool Update(Basic.Model.address model)
+ {
+ StringBuilder strSql = new StringBuilder();
+ strSql.Append("update tb_address set ");
+ strSql.Append("user_id=@user_id,");
+ strSql.Append("name=@name,");
+ strSql.Append("sheng=@sheng,");
+ strSql.Append("shi=@shi,");
+ strSql.Append("xian=@xian,");
+ strSql.Append("ssx=@ssx,");
+ strSql.Append("xaddress=@xaddress,");
+ strSql.Append("mobile=@mobile,");
+ strSql.Append("phone=@phone,");
+ strSql.Append("email=@email,");
+ strSql.Append("status=@status,");
+ strSql.Append("dname=@dname,");
+ strSql.Append("dxaddress=@dxaddress,");
+ strSql.Append("dmobile=@dmobile");
+ strSql.Append(" where id=@id");
+ SqlParameter[] parameters = {
+ new SqlParameter("@user_id", SqlDbType.Int,10),
+ new SqlParameter("@name", SqlDbType.NVarChar,50),
+ new SqlParameter("@sheng", SqlDbType.NVarChar,50),
+ new SqlParameter("@shi", SqlDbType.NVarChar,50),
+ new SqlParameter("@xian", SqlDbType.NVarChar,50),
+ new SqlParameter("@ssx", SqlDbType.NVarChar,255),
+ new SqlParameter("@xaddress", SqlDbType.NVarChar,255),
+ new SqlParameter("@mobile", SqlDbType.NVarChar,50),
+ new SqlParameter("@phone", SqlDbType.NVarChar,50),
+ new SqlParameter("@email", SqlDbType.NVarChar,100),
+ new SqlParameter("@status", SqlDbType.Int,10),
+ new SqlParameter("@dname", SqlDbType.NVarChar,50),
+ new SqlParameter("@dxaddress", SqlDbType.NVarChar,255),
+ new SqlParameter("@dmobile", SqlDbType.NVarChar,50),
+ new SqlParameter("@id", SqlDbType.Int,4)};
+ parameters[0].Value = model.user_id;
+ parameters[1].Value = model.name;
+ parameters[2].Value = model.sheng;
+ parameters[3].Value = model.shi;
+ parameters[4].Value = model.xian;
+ parameters[5].Value = model.ssx;
+ parameters[6].Value = model.xaddress;
+ parameters[7].Value = model.mobile;
+ parameters[8].Value = model.phone;
+ parameters[9].Value = model.email;
+ parameters[10].Value = model.status;
+ parameters[11].Value = model.dname;
+ parameters[12].Value = model.dxaddress;
+ parameters[13].Value = model.dmobile;
+ parameters[14].Value = model.id;
+ int rows = DbHelperSQL.ExecuteSql(strSql.ToString(), parameters);
+ if (rows > 0)
+ {
+ return true;
+ }
+ else
+ {
+ return false;
+ }
+ }
+
+ ///
+ /// 删除一条数据
+ ///
+ public bool Delete(int id)
+ {
+ StringBuilder strSql = new StringBuilder();
+ strSql.Append("delete from tb_address");
+ strSql.Append(" where id=@id");
+ SqlParameter[] parameters = {
+ new SqlParameter("@id", SqlDbType.Int,4)};
+ parameters[0].Value = id;
+ int rows = DbHelperSQL.ExecuteSql(strSql.ToString(), parameters);
+ if (rows > 0)
+ {
+ return true;
+ }
+ else
+ {
+ return false;
+ }
+ }
+
+ ///
+ /// 得到一个对象实体
+ ///
+ public Basic.Model.address GetModel(int id)
+ {
+ StringBuilder strSql = new StringBuilder();
+ strSql.Append("select top 1 id,user_id,name,sheng,shi,xian,ssx,xaddress,mobile,phone,email,status,dname,dxaddress,dmobile from tb_address");
+ strSql.Append(" where id=@id");
+ SqlParameter[] parameters = {
+ new SqlParameter("@id", SqlDbType.Int,4)};
+ parameters[0].Value = id;
+ Basic.Model.address model = new Basic.Model.address();
+ DataSet ds = DbHelperSQL.Query(strSql.ToString(), parameters);
+ if (ds.Tables[0].Rows.Count > 0)
+ {
+ if (!string.IsNullOrEmpty(ds.Tables[0].Rows[0]["id"].ToString()))
+ {
+ model.id = int.Parse(ds.Tables[0].Rows[0]["id"].ToString());
+ }
+ if (!string.IsNullOrEmpty(ds.Tables[0].Rows[0]["user_id"].ToString()))
+ {
+ model.user_id = int.Parse(ds.Tables[0].Rows[0]["user_id"].ToString());
+ }
+ if (!string.IsNullOrEmpty(ds.Tables[0].Rows[0]["name"].ToString()))
+ {
+ model.name = ds.Tables[0].Rows[0]["name"].ToString();
+ }
+ if (!string.IsNullOrEmpty(ds.Tables[0].Rows[0]["sheng"].ToString()))
+ {
+ model.sheng = ds.Tables[0].Rows[0]["sheng"].ToString();
+ }
+ if (!string.IsNullOrEmpty(ds.Tables[0].Rows[0]["shi"].ToString()))
+ {
+ model.shi = ds.Tables[0].Rows[0]["shi"].ToString();
+ }
+ if (!string.IsNullOrEmpty(ds.Tables[0].Rows[0]["xian"].ToString()))
+ {
+ model.xian = ds.Tables[0].Rows[0]["xian"].ToString();
+ }
+ if (!string.IsNullOrEmpty(ds.Tables[0].Rows[0]["ssx"].ToString()))
+ {
+ model.ssx = ds.Tables[0].Rows[0]["ssx"].ToString();
+ }
+ if (!string.IsNullOrEmpty(ds.Tables[0].Rows[0]["xaddress"].ToString()))
+ {
+ model.xaddress = ds.Tables[0].Rows[0]["xaddress"].ToString();
+ }
+ if (!string.IsNullOrEmpty(ds.Tables[0].Rows[0]["mobile"].ToString()))
+ {
+ model.mobile = ds.Tables[0].Rows[0]["mobile"].ToString();
+ }
+ if (!string.IsNullOrEmpty(ds.Tables[0].Rows[0]["phone"].ToString()))
+ {
+ model.phone = ds.Tables[0].Rows[0]["phone"].ToString();
+ }
+ if (!string.IsNullOrEmpty(ds.Tables[0].Rows[0]["email"].ToString()))
+ {
+ model.email = ds.Tables[0].Rows[0]["email"].ToString();
+ }
+ if (!string.IsNullOrEmpty(ds.Tables[0].Rows[0]["status"].ToString()))
+ {
+ model.status = int.Parse(ds.Tables[0].Rows[0]["status"].ToString());
+ }
+ //订货人
+ if (!string.IsNullOrEmpty(ds.Tables[0].Rows[0]["dname"].ToString()))
+ {
+ model.dname = ds.Tables[0].Rows[0]["dname"].ToString();
+ }
+
+ if (!string.IsNullOrEmpty(ds.Tables[0].Rows[0]["dxaddress"].ToString()))
+ {
+ model.dxaddress = ds.Tables[0].Rows[0]["dxaddress"].ToString();
+ }
+ if (!string.IsNullOrEmpty(ds.Tables[0].Rows[0]["dmobile"].ToString()))
+ {
+ model.dmobile = ds.Tables[0].Rows[0]["dmobile"].ToString();
+ }
+
+ return model;
+ }
+ else
+ {
+ return null;
+ }
+ }
+
+ ///
+ /// 得到一个对象实体
+ ///
+ public Basic.Model.address GetModel(string strUserName)
+ {
+ StringBuilder strSql = new StringBuilder();
+ strSql.Append("select top 1 id,user_id,name,sheng,shi,xian,ssx,xaddress,mobile,phone,email,status,dname,dxaddress,dmobile from tb_address");
+ strSql.Append(" where user_id=(select top 1 id from tb_user where name=@name) and status=1 order by id desc");
+ SqlParameter[] parameters = {
+ new SqlParameter("@name", SqlDbType.VarChar,50)};
+ parameters[0].Value = strUserName;
+ Basic.Model.address model = new Basic.Model.address();
+ DataSet ds = DbHelperSQL.Query(strSql.ToString(), parameters);
+ if (ds.Tables[0].Rows.Count > 0)
+ {
+ if (!string.IsNullOrEmpty(ds.Tables[0].Rows[0]["id"].ToString()))
+ {
+ model.id = int.Parse(ds.Tables[0].Rows[0]["id"].ToString());
+ }
+ if (!string.IsNullOrEmpty(ds.Tables[0].Rows[0]["user_id"].ToString()))
+ {
+ model.user_id = int.Parse(ds.Tables[0].Rows[0]["user_id"].ToString());
+ }
+ if (!string.IsNullOrEmpty(ds.Tables[0].Rows[0]["name"].ToString()))
+ {
+ model.name = ds.Tables[0].Rows[0]["name"].ToString();
+ }
+ if (!string.IsNullOrEmpty(ds.Tables[0].Rows[0]["sheng"].ToString()))
+ {
+ model.sheng = ds.Tables[0].Rows[0]["sheng"].ToString();
+ }
+ if (!string.IsNullOrEmpty(ds.Tables[0].Rows[0]["shi"].ToString()))
+ {
+ model.shi = ds.Tables[0].Rows[0]["shi"].ToString();
+ }
+ if (!string.IsNullOrEmpty(ds.Tables[0].Rows[0]["xian"].ToString()))
+ {
+ model.xian = ds.Tables[0].Rows[0]["xian"].ToString();
+ }
+ if (!string.IsNullOrEmpty(ds.Tables[0].Rows[0]["ssx"].ToString()))
+ {
+ model.ssx = ds.Tables[0].Rows[0]["ssx"].ToString();
+ }
+ if (!string.IsNullOrEmpty(ds.Tables[0].Rows[0]["xaddress"].ToString()))
+ {
+ model.xaddress = ds.Tables[0].Rows[0]["xaddress"].ToString();
+ }
+ if (!string.IsNullOrEmpty(ds.Tables[0].Rows[0]["mobile"].ToString()))
+ {
+ model.mobile = ds.Tables[0].Rows[0]["mobile"].ToString();
+ }
+ if (!string.IsNullOrEmpty(ds.Tables[0].Rows[0]["phone"].ToString()))
+ {
+ model.phone = ds.Tables[0].Rows[0]["phone"].ToString();
+ }
+ if (!string.IsNullOrEmpty(ds.Tables[0].Rows[0]["email"].ToString()))
+ {
+ model.email = ds.Tables[0].Rows[0]["email"].ToString();
+ }
+ if (!string.IsNullOrEmpty(ds.Tables[0].Rows[0]["status"].ToString()))
+ {
+ model.status = int.Parse(ds.Tables[0].Rows[0]["status"].ToString());
+ }
+ //订货人
+ if (!string.IsNullOrEmpty(ds.Tables[0].Rows[0]["dname"].ToString()))
+ {
+ model.dname = ds.Tables[0].Rows[0]["dname"].ToString();
+ }
+
+ if (!string.IsNullOrEmpty(ds.Tables[0].Rows[0]["dxaddress"].ToString()))
+ {
+ model.dxaddress = ds.Tables[0].Rows[0]["dxaddress"].ToString();
+ }
+ if (!string.IsNullOrEmpty(ds.Tables[0].Rows[0]["dmobile"].ToString()))
+ {
+ model.dmobile = ds.Tables[0].Rows[0]["dmobile"].ToString();
+ }
+
+ return model;
+ }
+ else
+ {
+ return null;
+ }
+ }
+ ///
+ /// 得到一个对象实体
+ ///
+ public Basic.Model.address GetModelByUserId(int user_id)
+ {
+ StringBuilder strSql = new StringBuilder();
+ strSql.Append("select top 1 id,user_id,name,sheng,shi,xian,ssx,xaddress,mobile,phone,email,status,dname,dxaddress,dmobile from tb_address");
+ strSql.Append(" where user_id=@user_id order by status desc,id desc");
+ SqlParameter[] parameters = {
+ new SqlParameter("@user_id", SqlDbType.Int,4)};
+ parameters[0].Value = user_id;
+ Basic.Model.address model = new Basic.Model.address();
+ DataSet ds = DbHelperSQL.Query(strSql.ToString(), parameters);
+ if (ds.Tables[0].Rows.Count > 0)
+ {
+ if (!string.IsNullOrEmpty(ds.Tables[0].Rows[0]["id"].ToString()))
+ {
+ model.id = int.Parse(ds.Tables[0].Rows[0]["id"].ToString());
+ }
+ if (!string.IsNullOrEmpty(ds.Tables[0].Rows[0]["user_id"].ToString()))
+ {
+ model.user_id = int.Parse(ds.Tables[0].Rows[0]["user_id"].ToString());
+ }
+ if (!string.IsNullOrEmpty(ds.Tables[0].Rows[0]["name"].ToString()))
+ {
+ model.name = ds.Tables[0].Rows[0]["name"].ToString();
+ }
+ if (!string.IsNullOrEmpty(ds.Tables[0].Rows[0]["sheng"].ToString()))
+ {
+ model.sheng = ds.Tables[0].Rows[0]["sheng"].ToString();
+ }
+ if (!string.IsNullOrEmpty(ds.Tables[0].Rows[0]["shi"].ToString()))
+ {
+ model.shi = ds.Tables[0].Rows[0]["shi"].ToString();
+ }
+ if (!string.IsNullOrEmpty(ds.Tables[0].Rows[0]["xian"].ToString()))
+ {
+ model.xian = ds.Tables[0].Rows[0]["xian"].ToString();
+ }
+ if (!string.IsNullOrEmpty(ds.Tables[0].Rows[0]["ssx"].ToString()))
+ {
+ model.ssx = ds.Tables[0].Rows[0]["ssx"].ToString();
+ }
+ if (!string.IsNullOrEmpty(ds.Tables[0].Rows[0]["xaddress"].ToString()))
+ {
+ model.xaddress = ds.Tables[0].Rows[0]["xaddress"].ToString();
+ }
+ if (!string.IsNullOrEmpty(ds.Tables[0].Rows[0]["mobile"].ToString()))
+ {
+ model.mobile = ds.Tables[0].Rows[0]["mobile"].ToString();
+ }
+ if (!string.IsNullOrEmpty(ds.Tables[0].Rows[0]["phone"].ToString()))
+ {
+ model.phone = ds.Tables[0].Rows[0]["phone"].ToString();
+ }
+ if (!string.IsNullOrEmpty(ds.Tables[0].Rows[0]["email"].ToString()))
+ {
+ model.email = ds.Tables[0].Rows[0]["email"].ToString();
+ }
+ if (!string.IsNullOrEmpty(ds.Tables[0].Rows[0]["status"].ToString()))
+ {
+ model.status = int.Parse(ds.Tables[0].Rows[0]["status"].ToString());
+ }
+ //订货人
+ if (!string.IsNullOrEmpty(ds.Tables[0].Rows[0]["dname"].ToString()))
+ {
+ model.dname = ds.Tables[0].Rows[0]["dname"].ToString();
+ }
+
+ if (!string.IsNullOrEmpty(ds.Tables[0].Rows[0]["dxaddress"].ToString()))
+ {
+ model.dxaddress = ds.Tables[0].Rows[0]["dxaddress"].ToString();
+ }
+ if (!string.IsNullOrEmpty(ds.Tables[0].Rows[0]["dmobile"].ToString()))
+ {
+ model.dmobile = ds.Tables[0].Rows[0]["dmobile"].ToString();
+ }
+
+ return model;
+ }
+ else
+ {
+ return null;
+ }
+ }
+
+ ///
+ /// 获得前几行数据
+ ///
+ public DataSet GetList(int Top, string strWhere, string filedOrder)
+ {
+ StringBuilder strSql = new StringBuilder();
+ strSql.Append("select ");
+ if (Top > 0)
+ {
+ strSql.Append(" top " + Top.ToString());
+ }
+ strSql.Append("id,user_id,name,sheng,shi,xian,ssx,xaddress,mobile,phone,email,status,dname,dxaddress,dmobile");
+ strSql.Append(" from tb_address");
+ if (strWhere.Trim() != "")
+ {
+ strSql.Append(" where " + strWhere);
+ }
+ strSql.Append(" order by " + filedOrder);
+ return DbHelperSQL.Query(strSql.ToString());
+ }
+
+ ///
+ /// 是否存在该记录
+ ///
+ public bool Exists(int id)
+ {
+ StringBuilder strSql = new StringBuilder();
+ strSql.Append("select count(1) from tb_address");
+ strSql.Append(" where id=@id");
+ SqlParameter[] parameters = {
+ new SqlParameter("@id", SqlDbType.Int,4)};
+ parameters[0].Value = id;
+
+ return DbHelperSQL.Exists(strSql.ToString(), parameters);
+ }
+ ///
+ /// 修改一列数据
+ ///
+ public void UpdateField(int id, string strValue)
+ {
+ StringBuilder strSql = new StringBuilder();
+ strSql.Append("update tb_address set " + strValue);
+ strSql.Append(" where id=" + id);
+ DbHelperSQL.ExecuteSql(strSql.ToString());
+ }
+
+ //后添加的======================================================================================================================================
+
+ ///
+ /// 修改默认地址
+ ///
+ public void UpdateStatus(int id, int _UserID)
+ {
+ StringBuilder strSql = new StringBuilder();
+ strSql.Append("update tb_address set status=0");
+ strSql.Append(" where user_id=" + _UserID);
+ strSql.Append(" update tb_address set status=1");
+ strSql.Append(" where id=" + id);
+ DbHelperSQL.ExecuteSql(strSql.ToString());
+ }
+ ///
+ /// 得到一个对象实体
+ ///
+ public Basic.Model.address GetModel(int id, int user_id)
+ {
+ StringBuilder strSql = new StringBuilder();
+ strSql.Append("select top 1 id,user_id,name,sheng,shi,xian,ssx,xaddress,mobile,phone,email,status,dname,dxaddress,dmobile from tb_address");
+ strSql.Append(" where id=@id and user_id=@user_id");
+ SqlParameter[] parameters = {
+ new SqlParameter("@id", SqlDbType.Int,4),
+ new SqlParameter("@user_id", SqlDbType.Int,4)};
+ parameters[0].Value = id;
+ parameters[1].Value = user_id;
+ Basic.Model.address model = new Basic.Model.address();
+ DataSet ds = DbHelperSQL.Query(strSql.ToString(), parameters);
+ if (ds.Tables[0].Rows.Count > 0)
+ {
+ if (!string.IsNullOrEmpty(ds.Tables[0].Rows[0]["id"].ToString()))
+ {
+ model.id = int.Parse(ds.Tables[0].Rows[0]["id"].ToString());
+ }
+ if (!string.IsNullOrEmpty(ds.Tables[0].Rows[0]["user_id"].ToString()))
+ {
+ model.user_id = int.Parse(ds.Tables[0].Rows[0]["user_id"].ToString());
+ }
+ if (!string.IsNullOrEmpty(ds.Tables[0].Rows[0]["name"].ToString()))
+ {
+ model.name = ds.Tables[0].Rows[0]["name"].ToString();
+ }
+ if (!string.IsNullOrEmpty(ds.Tables[0].Rows[0]["sheng"].ToString()))
+ {
+ model.sheng = ds.Tables[0].Rows[0]["sheng"].ToString();
+ }
+ if (!string.IsNullOrEmpty(ds.Tables[0].Rows[0]["shi"].ToString()))
+ {
+ model.shi = ds.Tables[0].Rows[0]["shi"].ToString();
+ }
+ if (!string.IsNullOrEmpty(ds.Tables[0].Rows[0]["xian"].ToString()))
+ {
+ model.xian = ds.Tables[0].Rows[0]["xian"].ToString();
+ }
+ if (!string.IsNullOrEmpty(ds.Tables[0].Rows[0]["ssx"].ToString()))
+ {
+ model.ssx = ds.Tables[0].Rows[0]["ssx"].ToString();
+ }
+ if (!string.IsNullOrEmpty(ds.Tables[0].Rows[0]["xaddress"].ToString()))
+ {
+ model.xaddress = ds.Tables[0].Rows[0]["xaddress"].ToString();
+ }
+ if (!string.IsNullOrEmpty(ds.Tables[0].Rows[0]["mobile"].ToString()))
+ {
+ model.mobile = ds.Tables[0].Rows[0]["mobile"].ToString();
+ }
+ if (!string.IsNullOrEmpty(ds.Tables[0].Rows[0]["phone"].ToString()))
+ {
+ model.phone = ds.Tables[0].Rows[0]["phone"].ToString();
+ }
+ if (!string.IsNullOrEmpty(ds.Tables[0].Rows[0]["email"].ToString()))
+ {
+ model.email = ds.Tables[0].Rows[0]["email"].ToString();
+ }
+ if (!string.IsNullOrEmpty(ds.Tables[0].Rows[0]["status"].ToString()))
+ {
+ model.status = int.Parse(ds.Tables[0].Rows[0]["status"].ToString());
+ }
+ //订货人
+ if (!string.IsNullOrEmpty(ds.Tables[0].Rows[0]["dname"].ToString()))
+ {
+ model.dname = ds.Tables[0].Rows[0]["dname"].ToString();
+ }
+ if (!string.IsNullOrEmpty(ds.Tables[0].Rows[0]["dxaddress"].ToString()))
+ {
+ model.dxaddress = ds.Tables[0].Rows[0]["dxaddress"].ToString();
+ }
+ if (!string.IsNullOrEmpty(ds.Tables[0].Rows[0]["dmobile"].ToString()))
+ {
+ model.dmobile = ds.Tables[0].Rows[0]["dmobile"].ToString();
+ }
+ return model;
+ }
+ else
+ {
+ return null;
+ }
+ }
+ ///
+ /// 得到一个对象实体
+ ///
+ public Basic.Model.address GetModel(int user_id, string status)
+ {
+ StringBuilder strSql = new StringBuilder();
+ strSql.Append("select top 1 id,user_id,name,sheng,shi,xian,ssx,xaddress,mobile,phone,email,status,dname,dxaddress,dmobile from tb_address");
+ strSql.Append(" where status=@status and user_id=@user_id");
+ SqlParameter[] parameters = {
+ new SqlParameter("@status", SqlDbType.Int,4),
+ new SqlParameter("@user_id", SqlDbType.Int,4)};
+ parameters[0].Value = status;
+ parameters[1].Value = user_id;
+ Basic.Model.address model = new Basic.Model.address();
+ DataSet ds = DbHelperSQL.Query(strSql.ToString(), parameters);
+ if (ds.Tables[0].Rows.Count > 0)
+ {
+ if (!string.IsNullOrEmpty(ds.Tables[0].Rows[0]["id"].ToString()))
+ {
+ model.id = int.Parse(ds.Tables[0].Rows[0]["id"].ToString());
+ }
+ if (!string.IsNullOrEmpty(ds.Tables[0].Rows[0]["user_id"].ToString()))
+ {
+ model.user_id = int.Parse(ds.Tables[0].Rows[0]["user_id"].ToString());
+ }
+ if (!string.IsNullOrEmpty(ds.Tables[0].Rows[0]["name"].ToString()))
+ {
+ model.name = ds.Tables[0].Rows[0]["name"].ToString();
+ }
+ if (!string.IsNullOrEmpty(ds.Tables[0].Rows[0]["sheng"].ToString()))
+ {
+ model.sheng = ds.Tables[0].Rows[0]["sheng"].ToString();
+ }
+ if (!string.IsNullOrEmpty(ds.Tables[0].Rows[0]["shi"].ToString()))
+ {
+ model.shi = ds.Tables[0].Rows[0]["shi"].ToString();
+ }
+ if (!string.IsNullOrEmpty(ds.Tables[0].Rows[0]["xian"].ToString()))
+ {
+ model.xian = ds.Tables[0].Rows[0]["xian"].ToString();
+ }
+ if (!string.IsNullOrEmpty(ds.Tables[0].Rows[0]["ssx"].ToString()))
+ {
+ model.ssx = ds.Tables[0].Rows[0]["ssx"].ToString();
+ }
+ if (!string.IsNullOrEmpty(ds.Tables[0].Rows[0]["xaddress"].ToString()))
+ {
+ model.xaddress = ds.Tables[0].Rows[0]["xaddress"].ToString();
+ }
+ if (!string.IsNullOrEmpty(ds.Tables[0].Rows[0]["mobile"].ToString()))
+ {
+ model.mobile = ds.Tables[0].Rows[0]["mobile"].ToString();
+ }
+ if (!string.IsNullOrEmpty(ds.Tables[0].Rows[0]["phone"].ToString()))
+ {
+ model.phone = ds.Tables[0].Rows[0]["phone"].ToString();
+ }
+ if (!string.IsNullOrEmpty(ds.Tables[0].Rows[0]["email"].ToString()))
+ {
+ model.email = ds.Tables[0].Rows[0]["email"].ToString();
+ }
+ if (!string.IsNullOrEmpty(ds.Tables[0].Rows[0]["status"].ToString()))
+ {
+ model.status = int.Parse(ds.Tables[0].Rows[0]["status"].ToString());
+ }
+ //订货人
+ if (!string.IsNullOrEmpty(ds.Tables[0].Rows[0]["dname"].ToString()))
+ {
+ model.dname = ds.Tables[0].Rows[0]["dname"].ToString();
+ }
+ if (!string.IsNullOrEmpty(ds.Tables[0].Rows[0]["dxaddress"].ToString()))
+ {
+ model.dxaddress = ds.Tables[0].Rows[0]["dxaddress"].ToString();
+ }
+ if (!string.IsNullOrEmpty(ds.Tables[0].Rows[0]["dmobile"].ToString()))
+ {
+ model.dmobile = ds.Tables[0].Rows[0]["dmobile"].ToString();
+ }
+ return model;
+ }
+ else
+ {
+ return null;
+ }
+ }
+ ///
+ /// 删除一条数据
+ ///
+ public bool Delete(int id, int user_id)
+ {
+ StringBuilder strSql = new StringBuilder();
+ strSql.Append("delete from tb_address");
+ strSql.Append(" where id=@id and user_id=@user_id");
+ SqlParameter[] parameters = {
+ new SqlParameter("@id", SqlDbType.Int,4),
+ new SqlParameter("@user_id", SqlDbType.Int,4)};
+ parameters[0].Value = id;
+ parameters[1].Value = user_id;
+ int rows = DbHelperSQL.ExecuteSql(strSql.ToString(), parameters);
+ if (rows > 0)
+ {
+ return true;
+ }
+ else
+ {
+ return false;
+ }
+ }
+ }
+}
+
diff --git a/App.code/DAL/albums.cs b/App.code/DAL/albums.cs
new file mode 100644
index 0000000..633cdca
--- /dev/null
+++ b/App.code/DAL/albums.cs
@@ -0,0 +1,263 @@
+using System;
+using System.Data;
+using System.Text;
+using System.Data.SqlClient;
+using System.Collections.Generic;
+
+namespace Basic.DAL
+{
+ ///
+ /// 相册
+ ///
+ public partial class albums
+ {
+
+ ///
+ /// 增加一条数据
+ ///
+ public int Add(Basic.Model.albums model)
+ {
+ StringBuilder strSql = new StringBuilder();
+ strSql.Append("insert into tb_albums(");
+ strSql.Append("paixu,guid,big_img,small_img,remark)");
+ strSql.Append(" values (");
+ strSql.Append("@paixu,@guid,@big_img,@small_img,@remark)");
+ strSql.Append(";select @@IDENTITY");
+
+ SqlParameter[] parameters = {
+ new SqlParameter("@paixu", SqlDbType.Int,10),
+ new SqlParameter("@guid", SqlDbType.NVarChar,50),
+ new SqlParameter("@big_img", SqlDbType.NVarChar,255),
+ new SqlParameter("@small_img", SqlDbType.NVarChar,255),
+ new SqlParameter("@remark", SqlDbType.NVarChar,500)};
+ parameters[0].Value = model.paixu;
+ parameters[1].Value = model.guid;
+ parameters[2].Value = model.big_img;
+ parameters[3].Value = model.small_img;
+ parameters[4].Value = model.remark;
+
+ object obj = DbHelperSQL.GetSingle(strSql.ToString(), parameters);
+ if (obj == null)
+ {
+ return 0;
+ }
+ else
+ {
+ return Convert.ToInt32(obj);
+ }
+ }
+
+ ///
+ /// 更新一条数据
+ ///
+ public bool Update(Basic.Model.albums model)
+ {
+ StringBuilder strSql = new StringBuilder();
+ strSql.Append("update tb_albums set ");
+ strSql.Append("paixu=@paixu,");
+ strSql.Append("guid=@guid,");
+ strSql.Append("big_img=@big_img,");
+ strSql.Append("small_img=@small_img,");
+ strSql.Append("remark=@remark");
+ strSql.Append(" where id=@id");
+ SqlParameter[] parameters = {
+ new SqlParameter("@paixu", SqlDbType.Int,10),
+ new SqlParameter("@guid", SqlDbType.NVarChar,50),
+ new SqlParameter("@big_img", SqlDbType.NVarChar,255),
+ new SqlParameter("@small_img", SqlDbType.NVarChar,255),
+ new SqlParameter("@remark", SqlDbType.NVarChar,500),
+ new SqlParameter("@id", SqlDbType.Int,4)};
+ parameters[0].Value = model.paixu;
+ parameters[1].Value = model.guid;
+ parameters[2].Value = model.big_img;
+ parameters[3].Value = model.small_img;
+ parameters[4].Value = model.remark;
+ parameters[5].Value = model.id;
+ int rows = DbHelperSQL.ExecuteSql(strSql.ToString(), parameters);
+ if (rows > 0)
+ {
+ return true;
+ }
+ else
+ {
+ return false;
+ }
+ }
+
+ ///
+ /// 删除一条数据
+ ///
+ public bool Delete(int id)
+ {
+ StringBuilder strSql = new StringBuilder();
+ strSql.Append("delete from tb_albums");
+ strSql.Append(" where id=@id");
+ SqlParameter[] parameters = {
+ new SqlParameter("@id", SqlDbType.Int,4)};
+ parameters[0].Value = id;
+ int rows = DbHelperSQL.ExecuteSql(strSql.ToString(), parameters);
+ if (rows > 0)
+ {
+ return true;
+ }
+ else
+ {
+ return false;
+ }
+ }
+
+ ///
+ /// 得到一个对象实体
+ ///
+ public Basic.Model.albums GetModel(int id)
+ {
+ StringBuilder strSql = new StringBuilder();
+ strSql.Append("select top 1 id,paixu,guid,big_img,small_img,remark from tb_albums");
+ strSql.Append(" where id=@id");
+ SqlParameter[] parameters = {
+ new SqlParameter("@id", SqlDbType.Int,4)};
+ parameters[0].Value = id;
+ Basic.Model.albums model = new Basic.Model.albums();
+ DataSet ds = DbHelperSQL.Query(strSql.ToString(), parameters);
+ if (ds.Tables[0].Rows.Count > 0)
+ {
+ if (!string.IsNullOrEmpty(ds.Tables[0].Rows[0]["id"].ToString()))
+ {
+ model.id = int.Parse(ds.Tables[0].Rows[0]["id"].ToString());
+ }
+ if (!string.IsNullOrEmpty(ds.Tables[0].Rows[0]["paixu"].ToString()))
+ {
+ model.paixu = int.Parse(ds.Tables[0].Rows[0]["paixu"].ToString());
+ }
+ if (!string.IsNullOrEmpty(ds.Tables[0].Rows[0]["guid"].ToString()))
+ {
+ model.guid = ds.Tables[0].Rows[0]["guid"].ToString();
+ }
+ if (!string.IsNullOrEmpty(ds.Tables[0].Rows[0]["big_img"].ToString()))
+ {
+ model.big_img = ds.Tables[0].Rows[0]["big_img"].ToString();
+ }
+ if (!string.IsNullOrEmpty(ds.Tables[0].Rows[0]["small_img"].ToString()))
+ {
+ model.small_img = ds.Tables[0].Rows[0]["small_img"].ToString();
+ }
+ if (!string.IsNullOrEmpty(ds.Tables[0].Rows[0]["remark"].ToString()))
+ {
+ model.remark = ds.Tables[0].Rows[0]["remark"].ToString();
+ }
+ return model;
+ }
+ else
+ {
+ return null;
+ }
+ }
+
+ ///
+ /// 获得数据列表
+ ///
+ public List GetList(string _guid)
+ {
+ List modelList = new List();
+
+ StringBuilder strSql = new StringBuilder();
+ strSql.Append("select * ");
+ strSql.Append(" from tb_albums ");
+ strSql.Append(" where guid='" + _guid + "'");
+ DataTable dt = DbHelperSQL.Query(strSql.ToString()).Tables[0];
+
+ int rowsCount = dt.Rows.Count;
+ if (rowsCount > 0)
+ {
+ Basic.Model.albums model;
+ for (int n = 0; n < rowsCount; n++)
+ {
+ model = new Basic.Model.albums();
+ if (dt.Rows[n]["id"] != null && dt.Rows[n]["id"].ToString() != "")
+ {
+ model.id = int.Parse(dt.Rows[n]["id"].ToString());
+ }
+ if (dt.Rows[n]["paixu"] != null && dt.Rows[n]["paixu"].ToString() != "")
+ {
+ model.paixu = int.Parse(dt.Rows[n]["paixu"].ToString());
+ }
+ if (dt.Rows[n]["guid"] != null && dt.Rows[n]["guid"].ToString() != "")
+ {
+ model.guid = dt.Rows[n]["guid"].ToString();
+ }
+ if (dt.Rows[n]["big_img"] != null && dt.Rows[n]["big_img"].ToString() != "")
+ {
+ model.big_img = dt.Rows[n]["big_img"].ToString();
+ }
+ if (dt.Rows[n]["small_img"] != null && dt.Rows[n]["small_img"].ToString() != "")
+ {
+ model.small_img = dt.Rows[n]["small_img"].ToString();
+ }
+ if (dt.Rows[n]["remark"] != null && dt.Rows[n]["remark"].ToString() != "")
+ {
+ model.remark = dt.Rows[n]["remark"].ToString();
+ }
+ modelList.Add(model);
+ }
+ }
+ return modelList;
+ }
+
+ ///
+ /// 查找不存在的图片并删除已删除的图片及数据
+ ///
+ public void DeleteList(List models, string _guid)
+ {
+ StringBuilder idList = new StringBuilder();
+ if (models != null)
+ {
+ foreach (Basic.Model.albums modelt in models)
+ {
+ if (modelt.id > 0)
+ {
+ idList.Append(modelt.id + ",");
+ }
+ }
+ }
+ string id_list = Basic.Tools.Utils.DelLastChar(idList.ToString(), ",");
+ StringBuilder strSql = new StringBuilder();
+ strSql.Append("select id,big_img,small_img from tb_albums where guid='" + _guid + "'");
+ if (!string.IsNullOrEmpty(id_list))
+ {
+ strSql.Append(" and id not in(" + id_list + ")");
+ }
+ Basic.BasicPage bp = new BasicPage();
+ DataSet ds = bp.SelectDataBase("tb_albums", strSql.ToString());
+ foreach (DataRow dr in ds.Tables[0].Rows)
+ {
+ bool result = Delete(int.Parse(dr["id"].ToString()));//删除数据
+ if (result)
+ {
+ Basic.Tools.Utils.DeleteFile("../.." + dr["big_img"].ToString()); //删除原图
+ Basic.Tools.Utils.DeleteFile("../.." + dr["small_img"].ToString()); //删除缩略图
+ }
+ }
+ }
+ ///
+ /// 删除数据和图片
+ ///
+ public void Delete(string _guid)
+ {
+ StringBuilder strSql = new StringBuilder();
+ strSql.Append("select id,big_img,small_img from tb_albums where guid='" + _guid + "'");
+
+ Basic.BasicPage bp = new BasicPage();
+ DataSet ds = bp.SelectDataBase("tb_albums", strSql.ToString());
+ foreach (DataRow dr in ds.Tables[0].Rows)
+ {
+ bool result = Delete(int.Parse(dr["id"].ToString()));//删除数据
+ if (result)
+ {
+ Basic.Tools.Utils.DeleteFile("../../" + dr["big_img"].ToString()); //删除原图
+ Basic.Tools.Utils.DeleteFile("../../" + dr["small_img"].ToString()); //删除缩略图
+ }
+ }
+ }
+ }
+}
+
diff --git a/App.code/DAL/attribute.cs b/App.code/DAL/attribute.cs
new file mode 100644
index 0000000..9352b91
--- /dev/null
+++ b/App.code/DAL/attribute.cs
@@ -0,0 +1,282 @@
+using System;
+using System.Data;
+using System.Text;
+using System.Data.SqlClient;
+
+namespace Basic.DAL
+{
+ ///
+ /// 属性列别
+ ///
+ public partial class attribute
+ {
+ ///
+ /// 增加一条数据
+ ///
+ public int Add(Basic.Model.attribute model)
+ {
+ StringBuilder strSql = new StringBuilder();
+ strSql.Append("insert into tb_attribute(");
+ strSql.Append("class_id,title,guid,parent_id,class_list,class_layer,paixu,url,path,content)");
+ strSql.Append(" values (");
+ strSql.Append("@class_id,@title,@guid,@parent_id,@class_list,@class_layer,@paixu,@url,@path,@content)");
+ strSql.Append(";select @@IDENTITY");
+
+ SqlParameter[] parameters = {
+ new SqlParameter("@class_id", SqlDbType.Int,10),
+ new SqlParameter("@title", SqlDbType.NVarChar,100),
+ new SqlParameter("@guid", SqlDbType.NVarChar,50),
+ new SqlParameter("@parent_id", SqlDbType.Int,10),
+ new SqlParameter("@class_list", SqlDbType.NVarChar,500),
+ new SqlParameter("@class_layer", SqlDbType.Int,10),
+ new SqlParameter("@paixu", SqlDbType.Int,10),
+ new SqlParameter("@url", SqlDbType.NVarChar,255),
+ new SqlParameter("@path", SqlDbType.NVarChar,255),
+ new SqlParameter("@content", SqlDbType.NVarChar,500)};
+ parameters[0].Value = model.class_id;
+ parameters[1].Value = model.title;
+ parameters[2].Value = model.guid;
+ parameters[3].Value = model.parent_id;
+ parameters[4].Value = model.class_list;
+ parameters[5].Value = model.class_layer;
+ parameters[6].Value = model.paixu;
+ parameters[7].Value = model.url;
+ parameters[8].Value = model.path;
+ parameters[9].Value = model.content;
+
+ object obj = DbHelperSQL.GetSingle(strSql.ToString(), parameters);
+ if (obj == null)
+ {
+ return 0;
+ }
+ else
+ {
+ return Convert.ToInt32(obj);
+ }
+ }
+
+ ///
+ /// 更新一条数据
+ ///
+ public bool Update(Basic.Model.attribute model)
+ {
+ StringBuilder strSql = new StringBuilder();
+ strSql.Append("update tb_attribute set ");
+ strSql.Append("class_id=@class_id,");
+ strSql.Append("title=@title,");
+ strSql.Append("guid=@guid,");
+ strSql.Append("parent_id=@parent_id,");
+ strSql.Append("class_list=@class_list,");
+ strSql.Append("class_layer=@class_layer,");
+ strSql.Append("paixu=@paixu,");
+ strSql.Append("url=@url,");
+ strSql.Append("path=@path,");
+ strSql.Append("content=@content");
+ strSql.Append(" where id=@id");
+ SqlParameter[] parameters = {
+ new SqlParameter("@class_id", SqlDbType.Int,10),
+ new SqlParameter("@title", SqlDbType.NVarChar,100),
+ new SqlParameter("@guid", SqlDbType.NVarChar,50),
+ new SqlParameter("@parent_id", SqlDbType.Int,10),
+ new SqlParameter("@class_list", SqlDbType.NVarChar,500),
+ new SqlParameter("@class_layer", SqlDbType.Int,10),
+ new SqlParameter("@paixu", SqlDbType.Int,10),
+ new SqlParameter("@url", SqlDbType.NVarChar,255),
+ new SqlParameter("@path", SqlDbType.NVarChar,255),
+ new SqlParameter("@content", SqlDbType.NVarChar,500),
+ new SqlParameter("@id", SqlDbType.Int,4)};
+ parameters[0].Value = model.class_id;
+ parameters[1].Value = model.title;
+ parameters[2].Value = model.guid;
+ parameters[3].Value = model.parent_id;
+ parameters[4].Value = model.class_list;
+ parameters[5].Value = model.class_layer;
+ parameters[6].Value = model.paixu;
+ parameters[7].Value = model.url;
+ parameters[8].Value = model.path;
+ parameters[9].Value = model.content;
+ parameters[10].Value = model.id;
+ int rows = DbHelperSQL.ExecuteSql(strSql.ToString(), parameters);
+ if (rows > 0)
+ {
+ return true;
+ }
+ else
+ {
+ return false;
+ }
+ }
+
+ ///
+ /// 删除一条数据
+ ///
+ public bool Delete(int id)
+ {
+ StringBuilder strSql = new StringBuilder();
+ strSql.Append("delete from tb_attribute");
+ strSql.Append(" where id=@id");
+ SqlParameter[] parameters = {
+ new SqlParameter("@id", SqlDbType.Int,4)};
+ parameters[0].Value = id;
+ int rows = DbHelperSQL.ExecuteSql(strSql.ToString(), parameters);
+ if (rows > 0)
+ {
+ return true;
+ }
+ else
+ {
+ return false;
+ }
+ }
+
+ ///
+ /// 得到一个对象实体
+ ///
+ public Basic.Model.attribute GetModel(int id)
+ {
+ StringBuilder strSql = new StringBuilder();
+ strSql.Append("select top 1 id,class_id,title,guid,parent_id,class_list,class_layer,paixu,url,path,content from tb_attribute");
+ strSql.Append(" where id=@id");
+ SqlParameter[] parameters = {
+ new SqlParameter("@id", SqlDbType.Int,4)};
+ parameters[0].Value = id;
+ Basic.Model.attribute model = new Basic.Model.attribute();
+ DataSet ds = DbHelperSQL.Query(strSql.ToString(), parameters);
+ if (ds.Tables[0].Rows.Count > 0)
+ {
+ if (!string.IsNullOrEmpty(ds.Tables[0].Rows[0]["id"].ToString()))
+ {
+ model.id = int.Parse(ds.Tables[0].Rows[0]["id"].ToString());
+ }
+ if (!string.IsNullOrEmpty(ds.Tables[0].Rows[0]["class_id"].ToString()))
+ {
+ model.class_id = int.Parse(ds.Tables[0].Rows[0]["class_id"].ToString());
+ }
+ if (!string.IsNullOrEmpty(ds.Tables[0].Rows[0]["title"].ToString()))
+ {
+ model.title = ds.Tables[0].Rows[0]["title"].ToString();
+ }
+ if (!string.IsNullOrEmpty(ds.Tables[0].Rows[0]["guid"].ToString()))
+ {
+ model.guid = ds.Tables[0].Rows[0]["guid"].ToString();
+ }
+ if (!string.IsNullOrEmpty(ds.Tables[0].Rows[0]["parent_id"].ToString()))
+ {
+ model.parent_id = int.Parse(ds.Tables[0].Rows[0]["parent_id"].ToString());
+ }
+ if (!string.IsNullOrEmpty(ds.Tables[0].Rows[0]["class_list"].ToString()))
+ {
+ model.class_list = ds.Tables[0].Rows[0]["class_list"].ToString();
+ }
+ if (!string.IsNullOrEmpty(ds.Tables[0].Rows[0]["class_layer"].ToString()))
+ {
+ model.class_layer = int.Parse(ds.Tables[0].Rows[0]["class_layer"].ToString());
+ }
+ if (!string.IsNullOrEmpty(ds.Tables[0].Rows[0]["paixu"].ToString()))
+ {
+ model.paixu = int.Parse(ds.Tables[0].Rows[0]["paixu"].ToString());
+ }
+ if (!string.IsNullOrEmpty(ds.Tables[0].Rows[0]["url"].ToString()))
+ {
+ model.url = ds.Tables[0].Rows[0]["url"].ToString();
+ }
+ if (!string.IsNullOrEmpty(ds.Tables[0].Rows[0]["path"].ToString()))
+ {
+ model.path = ds.Tables[0].Rows[0]["path"].ToString();
+ }
+ if (!string.IsNullOrEmpty(ds.Tables[0].Rows[0]["content"].ToString()))
+ {
+ model.content = ds.Tables[0].Rows[0]["content"].ToString();
+ }
+ return model;
+ }
+ else
+ {
+ return null;
+ }
+ }
+ ///
+ /// 取得所有类别列表
+ ///
+ /// 父ID
+ /// 分类ID
+ ///
+ public DataTable GetList(int parent_id, int class_id)
+ {
+ StringBuilder strSql = new StringBuilder();
+ strSql.Append("select * from tb_attribute");
+ strSql.Append(" where class_id=" + class_id + " order by paixu desc,id asc");
+ DataSet ds = DbHelperSQL.Query(strSql.ToString());
+ DataTable oldData = ds.Tables[0] as DataTable;
+ if (oldData == null)
+ {
+ return null;
+ }
+ //复制结构
+ DataTable newData = oldData.Clone();
+ //调用迭代组合成DAGATABLE
+ GetChilds(oldData, newData, parent_id, class_id);
+ return newData;
+ }
+
+ ///
+ /// 从内存中取得所有下级类别列表(自身迭代)
+ ///
+ private void GetChilds(DataTable oldData, DataTable newData, int parent_id, int pro_class_id)
+ {
+ DataRow[] dr = oldData.Select("parent_id=" + parent_id);
+ for (int i = 0; i < dr.Length; i++)
+ {
+ //添加一行数据
+ DataRow row = newData.NewRow();
+ row["id"] = int.Parse(dr[i]["id"].ToString());
+ row["class_id"] = int.Parse(dr[i]["class_id"].ToString());
+ row["title"] = dr[i]["title"].ToString();
+ row["guid"] = dr[i]["guid"].ToString();
+ row["parent_id"] = int.Parse(dr[i]["parent_id"].ToString());
+ row["class_list"] = dr[i]["class_list"].ToString();
+ row["class_layer"] = int.Parse(dr[i]["class_layer"].ToString());
+ row["paixu"] = int.Parse(dr[i]["paixu"].ToString());
+ row["url"] = dr[i]["url"].ToString();
+ row["path"] = dr[i]["path"].ToString();
+ row["content"] = dr[i]["content"].ToString();
+ newData.Rows.Add(row);
+ //调用自身迭代
+ this.GetChilds(oldData, newData, int.Parse(dr[i]["id"].ToString()), pro_class_id);
+ }
+ }
+
+ ///
+ /// 修改一列数据
+ ///
+ public void UpdateField(int id, string strValue)
+ {
+ StringBuilder strSql = new StringBuilder();
+ strSql.Append("update tb_attribute set " + strValue);
+ strSql.Append(" where id=" + id);
+ DbHelperSQL.ExecuteSql(strSql.ToString());
+ }
+ ///
+ /// 获得前几行数据
+ ///
+ public DataSet GetList(int Top, string strWhere, string filedOrder)
+ {
+ StringBuilder strSql = new StringBuilder();
+ strSql.Append("select ");
+ if (Top > 0)
+ {
+ strSql.Append(" top " + Top.ToString());
+ }
+ strSql.Append("id,class_id,title,guid,parent_id,class_list,class_layer,paixu,url,path,content");
+ strSql.Append(" from tb_attribute");
+ if (strWhere.Trim() != "")
+ {
+ strSql.Append(" where " + strWhere);
+ }
+ strSql.Append(" order by " + filedOrder);
+ return DbHelperSQL.Query(strSql.ToString());
+ }
+
+ }
+}
+
diff --git a/App.code/DAL/attribute_value.cs b/App.code/DAL/attribute_value.cs
new file mode 100644
index 0000000..ae3441c
--- /dev/null
+++ b/App.code/DAL/attribute_value.cs
@@ -0,0 +1,300 @@
+using System;
+using System.Data;
+using System.Text;
+using System.Data.SqlClient;
+
+namespace Basic.DAL
+{
+ ///
+ /// 属性值
+ ///
+ public partial class attribute_value
+ {
+ ///
+ /// 增加一条数据
+ ///
+ public int Add(Basic.Model.attribute_value model)
+ {
+ StringBuilder strSql = new StringBuilder();
+ strSql.Append("insert into tb_attribute_value(");
+ strSql.Append("class_id,parent_id,guid,title,path,content,paixu,status)");
+ strSql.Append(" values (");
+ strSql.Append("@class_id,@parent_id,@guid,@title,@path,@content,@paixu,@status)");
+ strSql.Append(";select @@IDENTITY");
+
+ SqlParameter[] parameters = {
+ new SqlParameter("@class_id", SqlDbType.Int,10),
+ new SqlParameter("@parent_id", SqlDbType.Int,10),
+ new SqlParameter("@guid", SqlDbType.NVarChar,50),
+ new SqlParameter("@title", SqlDbType.NVarChar,100),
+ new SqlParameter("@path", SqlDbType.NVarChar,255),
+ new SqlParameter("@content", SqlDbType.NVarChar,255),
+ new SqlParameter("@paixu", SqlDbType.Int,10),
+ new SqlParameter("@status", SqlDbType.Int,10)};
+ parameters[0].Value = model.class_id;
+ parameters[1].Value = model.parent_id;
+ parameters[2].Value = model.guid;
+ parameters[3].Value = model.title;
+ parameters[4].Value = model.path;
+ parameters[5].Value = model.content;
+ parameters[6].Value = model.paixu;
+ parameters[7].Value = model.status;
+
+ object obj = DbHelperSQL.GetSingle(strSql.ToString(), parameters);
+ if (obj == null)
+ {
+ return 0;
+ }
+ else
+ {
+ return Convert.ToInt32(obj);
+ }
+ }
+
+ ///
+ /// 更新一条数据
+ ///
+ public bool Update(Basic.Model.attribute_value model)
+ {
+ StringBuilder strSql = new StringBuilder();
+ strSql.Append("update tb_attribute_value set ");
+ strSql.Append("class_id=@class_id,");
+ strSql.Append("parent_id=@parent_id,");
+ strSql.Append("guid=@guid,");
+ strSql.Append("title=@title,");
+ strSql.Append("path=@path,");
+ strSql.Append("content=@content,");
+ strSql.Append("paixu=@paixu,");
+ strSql.Append("status=@status");
+ strSql.Append(" where id=@id");
+ SqlParameter[] parameters = {
+ new SqlParameter("@class_id", SqlDbType.Int,10),
+ new SqlParameter("@parent_id", SqlDbType.Int,10),
+ new SqlParameter("@guid", SqlDbType.NVarChar,50),
+ new SqlParameter("@title", SqlDbType.NVarChar,100),
+ new SqlParameter("@path", SqlDbType.NVarChar,255),
+ new SqlParameter("@content", SqlDbType.NVarChar,255),
+ new SqlParameter("@paixu", SqlDbType.Int,10),
+ new SqlParameter("@status", SqlDbType.Int,10),
+ new SqlParameter("@id", SqlDbType.Int,4)};
+ parameters[0].Value = model.class_id;
+ parameters[1].Value = model.parent_id;
+ parameters[2].Value = model.guid;
+ parameters[3].Value = model.title;
+ parameters[4].Value = model.path;
+ parameters[5].Value = model.content;
+ parameters[6].Value = model.paixu;
+ parameters[7].Value = model.status;
+ parameters[8].Value = model.id;
+ int rows = DbHelperSQL.ExecuteSql(strSql.ToString(), parameters);
+ if (rows > 0)
+ {
+ return true;
+ }
+ else
+ {
+ return false;
+ }
+ }
+
+ ///
+ /// 删除一条数据
+ ///
+ public bool Delete(int id)
+ {
+ StringBuilder strSql = new StringBuilder();
+ strSql.Append("delete from tb_attribute_value");
+ strSql.Append(" where id=@id");
+ SqlParameter[] parameters = {
+ new SqlParameter("@id", SqlDbType.Int,4)};
+ parameters[0].Value = id;
+ int rows = DbHelperSQL.ExecuteSql(strSql.ToString(), parameters);
+ if (rows > 0)
+ {
+ return true;
+ }
+ else
+ {
+ return false;
+ }
+ }
+ ///
+ /// 删除一条数据
+ ///
+ public bool DeleteByClassId(int class_id)
+ {
+ StringBuilder strSql = new StringBuilder();
+ strSql.Append("delete from tb_attribute_value");
+ strSql.Append(" where class_id=@class_id");
+ SqlParameter[] parameters = {
+ new SqlParameter("@class_id", SqlDbType.Int,4)};
+ parameters[0].Value = class_id;
+ int rows = DbHelperSQL.ExecuteSql(strSql.ToString(), parameters);
+ if (rows > 0)
+ {
+ return true;
+ }
+ else
+ {
+ return false;
+ }
+ }
+ ///
+ /// 得到一个对象实体
+ ///
+ public Basic.Model.attribute_value GetModel(int id)
+ {
+ StringBuilder strSql = new StringBuilder();
+ strSql.Append("select top 1 id,class_id,parent_id,guid,title,path,content,paixu,status from tb_attribute_value");
+ strSql.Append(" where id=@id");
+ SqlParameter[] parameters = {
+ new SqlParameter("@id", SqlDbType.Int,4)};
+ parameters[0].Value = id;
+ Basic.Model.attribute_value model = new Basic.Model.attribute_value();
+ DataSet ds = DbHelperSQL.Query(strSql.ToString(), parameters);
+ if (ds.Tables[0].Rows.Count > 0)
+ {
+ if (!string.IsNullOrEmpty(ds.Tables[0].Rows[0]["id"].ToString()))
+ {
+ model.id = int.Parse(ds.Tables[0].Rows[0]["id"].ToString());
+ }
+ if (!string.IsNullOrEmpty(ds.Tables[0].Rows[0]["class_id"].ToString()))
+ {
+ model.class_id = int.Parse(ds.Tables[0].Rows[0]["class_id"].ToString());
+ }
+ if (!string.IsNullOrEmpty(ds.Tables[0].Rows[0]["parent_id"].ToString()))
+ {
+ model.parent_id = int.Parse(ds.Tables[0].Rows[0]["parent_id"].ToString());
+ }
+ if (!string.IsNullOrEmpty(ds.Tables[0].Rows[0]["guid"].ToString()))
+ {
+ model.guid = ds.Tables[0].Rows[0]["guid"].ToString();
+ }
+ if (!string.IsNullOrEmpty(ds.Tables[0].Rows[0]["title"].ToString()))
+ {
+ model.title = ds.Tables[0].Rows[0]["title"].ToString();
+ }
+ if (!string.IsNullOrEmpty(ds.Tables[0].Rows[0]["path"].ToString()))
+ {
+ model.path = ds.Tables[0].Rows[0]["path"].ToString();
+ }
+ if (!string.IsNullOrEmpty(ds.Tables[0].Rows[0]["content"].ToString()))
+ {
+ model.content = ds.Tables[0].Rows[0]["content"].ToString();
+ }
+ if (!string.IsNullOrEmpty(ds.Tables[0].Rows[0]["paixu"].ToString()))
+ {
+ model.paixu = int.Parse(ds.Tables[0].Rows[0]["paixu"].ToString());
+ }
+ if (!string.IsNullOrEmpty(ds.Tables[0].Rows[0]["status"].ToString()))
+ {
+ model.status = int.Parse(ds.Tables[0].Rows[0]["status"].ToString());
+ }
+ return model;
+ }
+ else
+ {
+ return null;
+ }
+ }
+
+ ///
+ /// 是否存在该记录
+ ///
+ public bool Exists(int id)
+ {
+ StringBuilder strSql = new StringBuilder();
+ strSql.Append("select count(1) from tb_attribute_value");
+ strSql.Append(" where id=@id");
+ SqlParameter[] parameters = {
+ new SqlParameter("@id", SqlDbType.Int,4)};
+ parameters[0].Value = id;
+
+ return DbHelperSQL.Exists(strSql.ToString(), parameters);
+ }
+ ///
+ /// 获得查询分页数据
+ ///
+ public DataSet GetList(string _strWhere, string _orderby, int _pageSize, int _page, out int recordCount)
+ {
+ BasicPage bp = new BasicPage();
+ StringBuilder str_Sql = new StringBuilder();
+ str_Sql.Append("select top " + _pageSize + " * from tb_attribute_value");
+ str_Sql.Append(" where ");
+ str_Sql.Append(_strWhere);
+ str_Sql.Append(" and id not in ");
+ str_Sql.Append(" ( ");
+ str_Sql.Append(" select top " + (_page - 1) * _pageSize + " id from tb_attribute_value ");
+ str_Sql.Append(" where ");
+ str_Sql.Append(_strWhere);
+ str_Sql.Append(" order by ");
+ str_Sql.Append(_orderby);
+ str_Sql.Append(" ) ");
+ str_Sql.Append(" order by ");
+ str_Sql.Append(_orderby);
+ DataSet dst = bp.SelectDataBase("tb_attribute_value", str_Sql.ToString());
+ //
+ recordCount = totlePage(showTotal(_strWhere), _pageSize);
+ return dst;
+ }
+
+ //总页数
+ public int totlePage(int Total, int PageSize)
+ {
+ if (Total % PageSize == 0)
+ {
+ return Total / PageSize;
+ }
+ else
+ {
+ return Total / PageSize + 1;
+ }
+ }
+
+ //总条数
+ protected int showTotal(string strSql)
+ {
+ BasicPage bp = new BasicPage();
+ int intTotal = 0;
+ SqlDataReader myread = bp.getRead("select count(id) as CountId from tb_attribute_value where " + strSql);
+ if (myread.Read())
+ {
+ intTotal = Convert.ToInt32(myread["CountId"].ToString());
+ }
+ myread.Close();
+ return intTotal;
+ }
+ ///
+ /// 修改一列数据
+ ///
+ public void UpdateField(int id, string strValue)
+ {
+ StringBuilder strSql = new StringBuilder();
+ strSql.Append("update tb_attribute_value set " + strValue);
+ strSql.Append(" where id=" + id);
+ DbHelperSQL.ExecuteSql(strSql.ToString());
+ }
+ ///
+ /// 获得前几行数据
+ ///
+ public DataSet GetList(int Top, string strWhere, string filedOrder)
+ {
+ StringBuilder strSql = new StringBuilder();
+ strSql.Append("select ");
+ if (Top > 0)
+ {
+ strSql.Append(" top " + Top.ToString());
+ }
+ strSql.Append("id,class_id,parent_id,guid,title,path,content,paixu,status");
+ strSql.Append(" from tb_attribute_value");
+ if (strWhere.Trim() != "")
+ {
+ strSql.Append(" where " + strWhere);
+ }
+ strSql.Append(" order by " + filedOrder);
+ return DbHelperSQL.Query(strSql.ToString());
+ }
+
+ }
+}
+
diff --git a/App.code/DAL/bed_class.cs b/App.code/DAL/bed_class.cs
new file mode 100644
index 0000000..87cf820
--- /dev/null
+++ b/App.code/DAL/bed_class.cs
@@ -0,0 +1,258 @@
+using System;
+using System.Data;
+using System.Text;
+using System.Data.SqlClient;
+
+namespace Basic.DAL
+{
+ ///
+ /// 数据访问层bed_class
+ ///
+ public partial class bed_class
+ {
+ #region 原始的
+ ///
+ /// 增加一条数据
+ ///
+ public int Add(Basic.Model.bed_class model)
+ {
+ StringBuilder strSql = new StringBuilder();
+ strSql.Append("insert into tb_bed_class(");
+ strSql.Append("paixu,title,state,yongliao,gongfei)");
+ strSql.Append(" values (");
+ strSql.Append("@paixu,@title,@state,@yongliao,@gongfei)");
+ strSql.Append(";select @@IDENTITY");
+
+ SqlParameter[] parameters = {
+ new SqlParameter("@paixu", SqlDbType.Int,10),
+ new SqlParameter("@title", SqlDbType.NVarChar,255),
+ new SqlParameter("@state", SqlDbType.Int,10),
+ new SqlParameter("@yongliao", SqlDbType.Decimal,18),
+ new SqlParameter("@gongfei", SqlDbType.Decimal,18)};
+ parameters[0].Value = model.paixu;
+ parameters[1].Value = model.title;
+ parameters[2].Value = model.state;
+ parameters[3].Value = model.yongliao;
+ parameters[4].Value = model.gongfei;
+
+ object obj = DbHelperSQL.GetSingle(strSql.ToString(), parameters);
+ if (obj == null)
+ {
+ return 0;
+ }
+ else
+ {
+ return Convert.ToInt32(obj);
+ }
+ }
+
+ ///
+ /// 更新一条数据
+ ///
+ public bool Update(Basic.Model.bed_class model)
+ {
+ StringBuilder strSql = new StringBuilder();
+ strSql.Append("update tb_bed_class set ");
+ strSql.Append("paixu=@paixu,");
+ strSql.Append("title=@title,");
+ strSql.Append("state=@state,");
+ strSql.Append("yongliao=@yongliao,");
+ strSql.Append("gongfei=@gongfei");
+ strSql.Append(" where id=@id");
+ SqlParameter[] parameters = {
+ new SqlParameter("@paixu", SqlDbType.Int,10),
+ new SqlParameter("@title", SqlDbType.NVarChar,255),
+ new SqlParameter("@state", SqlDbType.Int,10),
+ new SqlParameter("@yongliao", SqlDbType.Decimal,18),
+ new SqlParameter("@gongfei", SqlDbType.Decimal,18),
+ new SqlParameter("@id", SqlDbType.Int,4)};
+ parameters[0].Value = model.paixu;
+ parameters[1].Value = model.title;
+ parameters[2].Value = model.state;
+ parameters[3].Value = model.yongliao;
+ parameters[4].Value = model.gongfei;
+ parameters[5].Value = model.id;
+ int rows = DbHelperSQL.ExecuteSql(strSql.ToString(), parameters);
+ if (rows > 0)
+ {
+ return true;
+ }
+ else
+ {
+ return false;
+ }
+ }
+
+ ///
+ /// 删除一条数据
+ ///
+ public bool Delete(int id)
+ {
+ StringBuilder strSql = new StringBuilder();
+ strSql.Append("delete from tb_bed_class");
+ strSql.Append(" where id=@id");
+ SqlParameter[] parameters = {
+ new SqlParameter("@id", SqlDbType.Int,4)};
+ parameters[0].Value = id;
+ int rows = DbHelperSQL.ExecuteSql(strSql.ToString(), parameters);
+ if (rows > 0)
+ {
+ return true;
+ }
+ else
+ {
+ return false;
+ }
+ }
+
+ ///
+ /// 得到一个对象实体
+ ///
+ public Basic.Model.bed_class GetModel(int id)
+ {
+ StringBuilder strSql = new StringBuilder();
+ strSql.Append("select top 1 id,paixu,title,state,yongliao,gongfei from tb_bed_class");
+ strSql.Append(" where id=@id");
+ SqlParameter[] parameters = {
+ new SqlParameter("@id", SqlDbType.Int,4)};
+ parameters[0].Value = id;
+ Basic.Model.bed_class model = new Basic.Model.bed_class();
+ DataSet ds = DbHelperSQL.Query(strSql.ToString(), parameters);
+ if (ds.Tables[0].Rows.Count > 0)
+ {
+ if (!string.IsNullOrEmpty(ds.Tables[0].Rows[0]["id"].ToString()))
+ {
+ model.id = int.Parse(ds.Tables[0].Rows[0]["id"].ToString());
+ }
+ if (!string.IsNullOrEmpty(ds.Tables[0].Rows[0]["paixu"].ToString()))
+ {
+ model.paixu = int.Parse(ds.Tables[0].Rows[0]["paixu"].ToString());
+ }
+ if (!string.IsNullOrEmpty(ds.Tables[0].Rows[0]["title"].ToString()))
+ {
+ model.title = ds.Tables[0].Rows[0]["title"].ToString();
+ }
+ if (!string.IsNullOrEmpty(ds.Tables[0].Rows[0]["state"].ToString()))
+ {
+ model.state = int.Parse(ds.Tables[0].Rows[0]["state"].ToString());
+ }
+ if (!string.IsNullOrEmpty(ds.Tables[0].Rows[0]["yongliao"].ToString()))
+ {
+ model.yongliao = decimal.Parse(ds.Tables[0].Rows[0]["yongliao"].ToString());
+ }
+ if (!string.IsNullOrEmpty(ds.Tables[0].Rows[0]["gongfei"].ToString()))
+ {
+ model.gongfei = decimal.Parse(ds.Tables[0].Rows[0]["gongfei"].ToString());
+ }
+ return model;
+ }
+ else
+ {
+ return null;
+ }
+ }
+
+ ///
+ /// 获得前几行数据
+ ///
+ public DataSet GetList(int Top, string strWhere, string filedOrder)
+ {
+ StringBuilder strSql = new StringBuilder();
+ strSql.Append("select ");
+ if (Top > 0)
+ {
+ strSql.Append(" top " + Top.ToString());
+ }
+ strSql.Append("id,paixu,title,state,yongliao,gongfei");
+ strSql.Append(" from tb_bed_class");
+ if (strWhere.Trim() != "")
+ {
+ strSql.Append(" where " + strWhere);
+ }
+ strSql.Append(" order by " + filedOrder);
+ return DbHelperSQL.Query(strSql.ToString());
+ }
+
+ ///
+ /// 是否存在该记录
+ ///
+ public bool Exists(int id)
+ {
+ StringBuilder strSql = new StringBuilder();
+ strSql.Append("select count(1) from tb_bed_class");
+ strSql.Append(" where id=@id");
+ SqlParameter[] parameters = {
+ new SqlParameter("@id", SqlDbType.Int,4)};
+ parameters[0].Value = id;
+
+ return DbHelperSQL.Exists(strSql.ToString(), parameters);
+ }
+ #endregion
+
+ //后加的==============================================================================================================================
+ ///
+ /// 获得查询分页数据
+ ///
+ public DataSet GetList(string _strWhere, string _orderby, int _pageSize, int _page, out int recordCount)
+ {
+ BasicPage bp = new BasicPage();
+ StringBuilder str_Sql = new StringBuilder();
+ str_Sql.Append("select top " + _pageSize + " * from tb_bed_class");
+ str_Sql.Append(" where ");
+ str_Sql.Append(_strWhere);
+ str_Sql.Append(" and id not in ");
+ str_Sql.Append(" ( ");
+ str_Sql.Append(" select top " + (_page - 1) * _pageSize + " id from tb_bed_class ");
+ str_Sql.Append(" where ");
+ str_Sql.Append(_strWhere);
+ str_Sql.Append(" order by ");
+ str_Sql.Append(_orderby);
+ str_Sql.Append(" ) ");
+ str_Sql.Append(" order by ");
+ str_Sql.Append(_orderby);
+ DataSet dst = bp.SelectDataBase("tb_bed_class", str_Sql.ToString());
+ //
+ recordCount = totlePage(showTotal(_strWhere), _pageSize);
+ return dst;
+ }
+
+ //总页数
+ public int totlePage(int Total, int PageSize)
+ {
+ if (Total % PageSize == 0)
+ {
+ return Total / PageSize;
+ }
+ else
+ {
+ return Total / PageSize + 1;
+ }
+ }
+
+ //总条数
+ protected int showTotal(string strSql)
+ {
+ BasicPage bp = new BasicPage();
+ int intTotal = 0;
+ SqlDataReader myread = bp.getRead("select count(id) as CountId from tb_bed_class where " + strSql);
+ if (myread.Read())
+ {
+ intTotal = Convert.ToInt32(myread["CountId"].ToString());
+ }
+ myread.Close();
+ return intTotal;
+ }
+
+ ///
+ /// 修改一列数据
+ ///
+ public void UpdateField(int id, string strValue)
+ {
+ StringBuilder strSql = new StringBuilder();
+ strSql.Append("update tb_bed_class set " + strValue);
+ strSql.Append(" where id=" + id);
+ DbHelperSQL.ExecuteSql(strSql.ToString());
+ }
+ }
+}
+
diff --git a/App.code/DAL/bianliang.cs b/App.code/DAL/bianliang.cs
new file mode 100644
index 0000000..c6b8e9d
--- /dev/null
+++ b/App.code/DAL/bianliang.cs
@@ -0,0 +1,268 @@
+using System;
+using System.Data;
+using System.Text;
+using System.Data.SqlClient;
+
+namespace Basic.DAL
+{
+ ///
+ /// 数据访问层
+ ///
+ public partial class bianliang
+ {
+ #region 此代码由工具生成
+
+ ///
+ /// 增加一条数据
+ ///
+ public int Add(Basic.Model.bianliang model)
+ {
+ StringBuilder strSql = new StringBuilder();
+ strSql.Append("insert into tb_bianliang(");
+ strSql.Append("paixu,keyid,zhi,beizhu,status,add_time)");
+ strSql.Append(" values (");
+ strSql.Append("@paixu,@keyid,@zhi,@beizhu,@status,@add_time)");
+ strSql.Append(";select @@IDENTITY");
+
+ SqlParameter[] parameters = {
+ new SqlParameter("@paixu", SqlDbType.Int,10),
+ new SqlParameter("@keyid", SqlDbType.NVarChar,255),
+ new SqlParameter("@zhi", SqlDbType.NText,1073741823),
+ new SqlParameter("@beizhu", SqlDbType.NText,1073741823),
+ new SqlParameter("@status", SqlDbType.Int,10),
+ new SqlParameter("@add_time", SqlDbType.DateTime,23)};
+ parameters[0].Value = model.paixu;
+ parameters[1].Value = model.keyid;
+ parameters[2].Value = model.zhi;
+ parameters[3].Value = model.beizhu;
+ parameters[4].Value = model.status;
+ parameters[5].Value = model.add_time;
+
+ object obj = DbHelperSQL.GetSingle(strSql.ToString(), parameters);
+ if (obj == null)
+ {
+ return 0;
+ }
+ else
+ {
+ return Convert.ToInt32(obj);
+ }
+ }
+
+ ///
+ /// 更新一条数据
+ ///
+ public bool Update(Basic.Model.bianliang model)
+ {
+ StringBuilder strSql = new StringBuilder();
+ strSql.Append("update tb_bianliang set ");
+ strSql.Append("paixu=@paixu,");
+ strSql.Append("keyid=@keyid,");
+ strSql.Append("zhi=@zhi,");
+ strSql.Append("beizhu=@beizhu,");
+ strSql.Append("status=@status,");
+ strSql.Append("add_time=@add_time");
+ strSql.Append(" where id=@id");
+ SqlParameter[] parameters = {
+ new SqlParameter("@paixu", SqlDbType.Int,10),
+ new SqlParameter("@keyid", SqlDbType.NVarChar,255),
+ new SqlParameter("@zhi", SqlDbType.NText,1073741823),
+ new SqlParameter("@beizhu", SqlDbType.NText,1073741823),
+ new SqlParameter("@status", SqlDbType.Int,10),
+ new SqlParameter("@add_time", SqlDbType.DateTime,23),
+ new SqlParameter("@id", SqlDbType.Int,4)};
+ parameters[0].Value = model.paixu;
+ parameters[1].Value = model.keyid;
+ parameters[2].Value = model.zhi;
+ parameters[3].Value = model.beizhu;
+ parameters[4].Value = model.status;
+ parameters[5].Value = model.add_time;
+ parameters[6].Value = model.id;
+ int rows = DbHelperSQL.ExecuteSql(strSql.ToString(), parameters);
+ if (rows > 0)
+ {
+ return true;
+ }
+ else
+ {
+ return false;
+ }
+ }
+
+ ///
+ /// 删除一条数据
+ ///
+ public bool Delete(int id)
+ {
+ StringBuilder strSql = new StringBuilder();
+ strSql.Append("delete from tb_bianliang");
+ strSql.Append(" where id=@id");
+ SqlParameter[] parameters = {
+ new SqlParameter("@id", SqlDbType.Int,4)};
+ parameters[0].Value = id;
+ int rows = DbHelperSQL.ExecuteSql(strSql.ToString(), parameters);
+ if (rows > 0)
+ {
+ return true;
+ }
+ else
+ {
+ return false;
+ }
+ }
+
+ ///
+ /// 得到一个对象实体
+ ///
+ public Basic.Model.bianliang GetModel(int id)
+ {
+ StringBuilder strSql=new StringBuilder();
+ strSql.Append("select top 1 id,paixu,keyid,zhi,beizhu,status,add_time from tb_bianliang");
+ strSql.Append(" where id=@id");
+ SqlParameter[] parameters = {
+ new SqlParameter("@id", SqlDbType.Int,4)};
+ parameters[0].Value = id;
+ Basic.Model.bianliang model = new Basic.Model.bianliang();
+ DataSet ds = DbHelperSQL.Query(strSql.ToString(), parameters);
+ if (ds.Tables[0].Rows.Count > 0)
+ {
+ if (!string.IsNullOrEmpty(ds.Tables[0].Rows[0]["id"].ToString()))
+ {
+ model.id = int.Parse(ds.Tables[0].Rows[0]["id"].ToString());
+ }
+ if (!string.IsNullOrEmpty(ds.Tables[0].Rows[0]["paixu"].ToString()))
+ {
+ model.paixu = int.Parse(ds.Tables[0].Rows[0]["paixu"].ToString());
+ }
+ if (!string.IsNullOrEmpty(ds.Tables[0].Rows[0]["keyid"].ToString()))
+ {
+ model.keyid = ds.Tables[0].Rows[0]["keyid"].ToString();
+ }
+ if (!string.IsNullOrEmpty(ds.Tables[0].Rows[0]["zhi"].ToString()))
+ {
+ model.zhi = ds.Tables[0].Rows[0]["zhi"].ToString();
+ }
+ if (!string.IsNullOrEmpty(ds.Tables[0].Rows[0]["beizhu"].ToString()))
+ {
+ model.beizhu = ds.Tables[0].Rows[0]["beizhu"].ToString();
+ }
+ if (!string.IsNullOrEmpty(ds.Tables[0].Rows[0]["status"].ToString()))
+ {
+ model.status = int.Parse(ds.Tables[0].Rows[0]["status"].ToString());
+ }
+ if (!string.IsNullOrEmpty(ds.Tables[0].Rows[0]["add_time"].ToString()))
+ {
+ model.add_time = DateTime.Parse(ds.Tables[0].Rows[0]["add_time"].ToString());
+ }
+ return model;
+ }
+ else
+ {
+ return null;
+ }
+ }
+
+ ///
+ /// 获得前几行数据
+ ///
+ public DataSet GetList(int Top, string strWhere, string filedOrder)
+ {
+ StringBuilder strSql = new StringBuilder();
+ strSql.Append("select ");
+ if (Top > 0)
+ {
+ strSql.Append(" top " + Top.ToString());
+ }
+ strSql.Append("id,paixu,keyid,zhi,beizhu,status,add_time");
+ strSql.Append(" from tb_bianliang");
+ if (strWhere.Trim() != "")
+ {
+ strSql.Append(" where " + strWhere);
+ }
+ strSql.Append(" order by " + filedOrder);
+ return DbHelperSQL.Query(strSql.ToString());
+ }
+
+ ///
+ /// 获得查询分页数据
+ ///
+ public DataSet GetList(string _strWhere, string _orderby, int _pageSize, int _page, out int recordCount)
+ {
+ BasicPage bp = new BasicPage();
+ StringBuilder str_Sql = new StringBuilder();
+ str_Sql.Append("select top " + _pageSize + " id,paixu,keyid,zhi,beizhu,status,add_time from tb_bianliang");
+ str_Sql.Append(" where ");
+ str_Sql.Append(_strWhere);
+ str_Sql.Append(" and id not in ");
+ str_Sql.Append(" ( ");
+ str_Sql.Append(" select top " + (_page - 1) * _pageSize + " id from tb_bianliang ");
+ str_Sql.Append(" where ");
+ str_Sql.Append(_strWhere);
+ str_Sql.Append(" order by ");
+ str_Sql.Append(_orderby);
+ str_Sql.Append(" ) ");
+ str_Sql.Append(" order by ");
+ str_Sql.Append(_orderby);
+ DataSet dst = bp.SelectDataBase("tb_bianliang", str_Sql.ToString());
+ //
+ recordCount = totlePage(showTotal(_strWhere), _pageSize);
+ return dst;
+ }
+
+ //总页数
+ public int totlePage(int Total, int PageSize)
+ {
+ if (Total % PageSize == 0)
+ {
+ return Total / PageSize;
+ }
+ else
+ {
+ return Total / PageSize + 1;
+ }
+ }
+
+ //总条数
+ protected int showTotal(string strSql)
+ {
+ BasicPage bp = new BasicPage();
+ int intTotal = 0;
+ SqlDataReader myread = bp.getRead("select count(id) as CountId from tb_bianliang where " + strSql);
+ if (myread.Read())
+ {
+ intTotal = Convert.ToInt32(myread["CountId"].ToString());
+ }
+ myread.Close();
+ return intTotal;
+ }
+
+ ///
+ /// 是否存在该记录
+ ///
+ public bool Exists(int id)
+ {
+ StringBuilder strSql = new StringBuilder();
+ strSql.Append("select count(1) from tb_bianliang");
+ strSql.Append(" where id=@id");
+ SqlParameter[] parameters = {
+ new SqlParameter("@id", SqlDbType.Int,4)};
+ parameters[0].Value = id;
+
+ return DbHelperSQL.Exists(strSql.ToString(), parameters);
+ }
+
+ ///
+ /// 修改一列数据
+ ///
+ public void UpdateField(int id, string strValue)
+ {
+ StringBuilder strSql = new StringBuilder();
+ strSql.Append("update tb_bianliang set " + strValue);
+ strSql.Append(" where id=" + id);
+ DbHelperSQL.ExecuteSql(strSql.ToString());
+ }
+
+ #endregion
+ }
+}
+
diff --git a/App.code/DAL/channel.cs b/App.code/DAL/channel.cs
new file mode 100644
index 0000000..ad334bf
--- /dev/null
+++ b/App.code/DAL/channel.cs
@@ -0,0 +1,291 @@
+using System;
+using System.Data;
+using System.Text;
+using System.Data.SqlClient;
+
+namespace Basic.DAL
+{
+ ///
+ /// 频道
+ ///
+ public partial class channel
+ {
+ ///
+ /// 增加一条数据
+ ///
+ public int Add(Basic.Model.channel model)
+ {
+ StringBuilder strSql = new StringBuilder();
+ strSql.Append("insert into tb_channel(");
+ strSql.Append("class_id,title,guid,parent_id,class_list,class_layer,paixu,url,path,content,seo_title,seo_keywords,seo_description)");
+ strSql.Append(" values (");
+ strSql.Append("@class_id,@title,@guid,@parent_id,@class_list,@class_layer,@paixu,@url,@path,@content,@seo_title,@seo_keywords,@seo_description)");
+ strSql.Append(";select @@IDENTITY");
+
+ SqlParameter[] parameters = {
+ new SqlParameter("@class_id", SqlDbType.Int,10),
+ new SqlParameter("@title", SqlDbType.NVarChar,100),
+ new SqlParameter("@guid", SqlDbType.NVarChar,50),
+ new SqlParameter("@parent_id", SqlDbType.Int,10),
+ new SqlParameter("@class_list", SqlDbType.NVarChar,500),
+ new SqlParameter("@class_layer", SqlDbType.Int,10),
+ new SqlParameter("@paixu", SqlDbType.Int,10),
+ new SqlParameter("@url", SqlDbType.NVarChar,255),
+ new SqlParameter("@path", SqlDbType.NVarChar,255),
+ new SqlParameter("@content", SqlDbType.NText,1073741823),
+ new SqlParameter("@seo_title", SqlDbType.NVarChar,255),
+ new SqlParameter("@seo_keywords", SqlDbType.NVarChar,255),
+ new SqlParameter("@seo_description", SqlDbType.NVarChar,255)};
+ parameters[0].Value = model.class_id;
+ parameters[1].Value = model.title;
+ parameters[2].Value = model.guid;
+ parameters[3].Value = model.parent_id;
+ parameters[4].Value = model.class_list;
+ parameters[5].Value = model.class_layer;
+ parameters[6].Value = model.paixu;
+ parameters[7].Value = model.url;
+ parameters[8].Value = model.path;
+ parameters[9].Value = model.content;
+ parameters[10].Value = model.seo_title;
+ parameters[11].Value = model.seo_keywords;
+ parameters[12].Value = model.seo_description;
+
+ object obj = DbHelperSQL.GetSingle(strSql.ToString(), parameters);
+ if (obj == null)
+ {
+ return 0;
+ }
+ else
+ {
+ return Convert.ToInt32(obj);
+ }
+ }
+
+ ///
+ /// 更新一条数据
+ ///
+ public bool Update(Basic.Model.channel model)
+ {
+ StringBuilder strSql = new StringBuilder();
+ strSql.Append("update tb_channel set ");
+ strSql.Append("class_id=@class_id,");
+ strSql.Append("title=@title,");
+ strSql.Append("guid=@guid,");
+ strSql.Append("parent_id=@parent_id,");
+ strSql.Append("class_list=@class_list,");
+ strSql.Append("class_layer=@class_layer,");
+ strSql.Append("paixu=@paixu,");
+ strSql.Append("url=@url,");
+ strSql.Append("path=@path,");
+ strSql.Append("content=@content,");
+ strSql.Append("seo_title=@seo_title,");
+ strSql.Append("seo_keywords=@seo_keywords,");
+ strSql.Append("seo_description=@seo_description");
+ strSql.Append(" where id=@id");
+ SqlParameter[] parameters = {
+ new SqlParameter("@class_id", SqlDbType.Int,10),
+ new SqlParameter("@title", SqlDbType.NVarChar,100),
+ new SqlParameter("@guid", SqlDbType.NVarChar,50),
+ new SqlParameter("@parent_id", SqlDbType.Int,10),
+ new SqlParameter("@class_list", SqlDbType.NVarChar,500),
+ new SqlParameter("@class_layer", SqlDbType.Int,10),
+ new SqlParameter("@paixu", SqlDbType.Int,10),
+ new SqlParameter("@url", SqlDbType.NVarChar,255),
+ new SqlParameter("@path", SqlDbType.NVarChar,255),
+ new SqlParameter("@content", SqlDbType.NText,1073741823),
+ new SqlParameter("@seo_title", SqlDbType.NVarChar,255),
+ new SqlParameter("@seo_keywords", SqlDbType.NVarChar,255),
+ new SqlParameter("@seo_description", SqlDbType.NVarChar,255),
+ new SqlParameter("@id", SqlDbType.Int,4)};
+ parameters[0].Value = model.class_id;
+ parameters[1].Value = model.title;
+ parameters[2].Value = model.guid;
+ parameters[3].Value = model.parent_id;
+ parameters[4].Value = model.class_list;
+ parameters[5].Value = model.class_layer;
+ parameters[6].Value = model.paixu;
+ parameters[7].Value = model.url;
+ parameters[8].Value = model.path;
+ parameters[9].Value = model.content;
+ parameters[10].Value = model.seo_title;
+ parameters[11].Value = model.seo_keywords;
+ parameters[12].Value = model.seo_description;
+ parameters[13].Value = model.id;
+ int rows = DbHelperSQL.ExecuteSql(strSql.ToString(), parameters);
+ if (rows > 0)
+ {
+ return true;
+ }
+ else
+ {
+ return false;
+ }
+ }
+
+ ///
+ /// 删除一条数据
+ ///
+ public bool Delete(int id)
+ {
+ StringBuilder strSql = new StringBuilder();
+ strSql.Append("delete from tb_channel");
+ strSql.Append(" where id=@id");
+ SqlParameter[] parameters = {
+ new SqlParameter("@id", SqlDbType.Int,4)};
+ parameters[0].Value = id;
+ int rows = DbHelperSQL.ExecuteSql(strSql.ToString(), parameters);
+ if (rows > 0)
+ {
+ return true;
+ }
+ else
+ {
+ return false;
+ }
+ }
+
+ ///
+ /// 得到一个对象实体
+ ///
+ public Basic.Model.channel GetModel(int id)
+ {
+ StringBuilder strSql = new StringBuilder();
+ strSql.Append("select top 1 id,class_id,title,guid,parent_id,class_list,class_layer,paixu,url,path,content,seo_title,seo_keywords,seo_description from tb_channel");
+ strSql.Append(" where id=@id");
+ SqlParameter[] parameters = {
+ new SqlParameter("@id", SqlDbType.Int,4)};
+ parameters[0].Value = id;
+ Basic.Model.channel model = new Basic.Model.channel();
+ DataSet ds = DbHelperSQL.Query(strSql.ToString(), parameters);
+ if (ds.Tables[0].Rows.Count > 0)
+ {
+ if (!string.IsNullOrEmpty(ds.Tables[0].Rows[0]["id"].ToString()))
+ {
+ model.id = int.Parse(ds.Tables[0].Rows[0]["id"].ToString());
+ }
+ if (!string.IsNullOrEmpty(ds.Tables[0].Rows[0]["class_id"].ToString()))
+ {
+ model.class_id = int.Parse(ds.Tables[0].Rows[0]["class_id"].ToString());
+ }
+ if (!string.IsNullOrEmpty(ds.Tables[0].Rows[0]["title"].ToString()))
+ {
+ model.title = ds.Tables[0].Rows[0]["title"].ToString();
+ }
+ if (!string.IsNullOrEmpty(ds.Tables[0].Rows[0]["guid"].ToString()))
+ {
+ model.guid = ds.Tables[0].Rows[0]["guid"].ToString();
+ }
+ if (!string.IsNullOrEmpty(ds.Tables[0].Rows[0]["parent_id"].ToString()))
+ {
+ model.parent_id = int.Parse(ds.Tables[0].Rows[0]["parent_id"].ToString());
+ }
+ if (!string.IsNullOrEmpty(ds.Tables[0].Rows[0]["class_list"].ToString()))
+ {
+ model.class_list = ds.Tables[0].Rows[0]["class_list"].ToString();
+ }
+ if (!string.IsNullOrEmpty(ds.Tables[0].Rows[0]["class_layer"].ToString()))
+ {
+ model.class_layer = int.Parse(ds.Tables[0].Rows[0]["class_layer"].ToString());
+ }
+ if (!string.IsNullOrEmpty(ds.Tables[0].Rows[0]["paixu"].ToString()))
+ {
+ model.paixu = int.Parse(ds.Tables[0].Rows[0]["paixu"].ToString());
+ }
+ if (!string.IsNullOrEmpty(ds.Tables[0].Rows[0]["url"].ToString()))
+ {
+ model.url = ds.Tables[0].Rows[0]["url"].ToString();
+ }
+ if (!string.IsNullOrEmpty(ds.Tables[0].Rows[0]["path"].ToString()))
+ {
+ model.path = ds.Tables[0].Rows[0]["path"].ToString();
+ }
+ if (!string.IsNullOrEmpty(ds.Tables[0].Rows[0]["content"].ToString()))
+ {
+ model.content = ds.Tables[0].Rows[0]["content"].ToString();
+ }
+ if (!string.IsNullOrEmpty(ds.Tables[0].Rows[0]["seo_title"].ToString()))
+ {
+ model.seo_title = ds.Tables[0].Rows[0]["seo_title"].ToString();
+ }
+ if (!string.IsNullOrEmpty(ds.Tables[0].Rows[0]["seo_keywords"].ToString()))
+ {
+ model.seo_keywords = ds.Tables[0].Rows[0]["seo_keywords"].ToString();
+ }
+ if (!string.IsNullOrEmpty(ds.Tables[0].Rows[0]["seo_description"].ToString()))
+ {
+ model.seo_description = ds.Tables[0].Rows[0]["seo_description"].ToString();
+ }
+ return model;
+ }
+ else
+ {
+ return null;
+ }
+ }
+
+ ///
+ /// 取得所有类别列表
+ ///
+ /// 父ID
+ /// 分类ID
+ ///
+ public DataTable GetList(int parent_id, int class_id)
+ {
+ StringBuilder strSql = new StringBuilder();
+ strSql.Append("select * from tb_channel");
+ strSql.Append(" where class_id=" + class_id + " order by paixu desc,id asc");
+ DataSet ds = DbHelperSQL.Query(strSql.ToString());
+ DataTable oldData = ds.Tables[0] as DataTable;
+ if (oldData == null)
+ {
+ return null;
+ }
+ //复制结构
+ DataTable newData = oldData.Clone();
+ //调用迭代组合成DAGATABLE
+ GetChilds(oldData, newData, parent_id, class_id);
+ return newData;
+ }
+
+ ///
+ /// 从内存中取得所有下级类别列表(自身迭代)
+ ///
+ private void GetChilds(DataTable oldData, DataTable newData, int parent_id, int channel_id)
+ {
+ DataRow[] dr = oldData.Select("parent_id=" + parent_id);
+ for (int i = 0; i < dr.Length; i++)
+ {
+ //添加一行数据
+ DataRow row = newData.NewRow();
+ row["id"] = int.Parse(dr[i]["id"].ToString());
+ row["class_id"] = int.Parse(dr[i]["class_id"].ToString());
+ row["title"] = dr[i]["title"].ToString();
+ row["guid"] = dr[i]["guid"].ToString();
+ row["parent_id"] = int.Parse(dr[i]["parent_id"].ToString());
+ row["class_list"] = dr[i]["class_list"].ToString();
+ row["class_layer"] = int.Parse(dr[i]["class_layer"].ToString());
+ row["paixu"] = int.Parse(dr[i]["paixu"].ToString());
+ row["url"] = dr[i]["url"].ToString();
+ row["path"] = dr[i]["path"].ToString();
+ row["content"] = dr[i]["content"].ToString();
+ row["seo_title"] = dr[i]["seo_title"].ToString();
+ row["seo_keywords"] = dr[i]["seo_keywords"].ToString();
+ row["seo_description"] = dr[i]["seo_description"].ToString();
+ newData.Rows.Add(row);
+ //调用自身迭代
+ this.GetChilds(oldData, newData, int.Parse(dr[i]["id"].ToString()), channel_id);
+ }
+ }
+ ///
+ /// 修改一列数据
+ ///
+ public void UpdateField(int id, string strValue)
+ {
+ StringBuilder strSql = new StringBuilder();
+ strSql.Append("update tb_channel set " + strValue);
+ strSql.Append(" where id=" + id);
+ DbHelperSQL.ExecuteSql(strSql.ToString());
+ }
+ }
+}
+
diff --git a/App.code/DAL/comment.cs b/App.code/DAL/comment.cs
new file mode 100644
index 0000000..f1484a0
--- /dev/null
+++ b/App.code/DAL/comment.cs
@@ -0,0 +1,294 @@
+using System;
+using System.Data;
+using System.Text;
+using System.Data.SqlClient;
+
+namespace Basic.DAL
+{
+ ///
+ /// 数据访问层comment
+ ///
+ public partial class comment
+ {
+ #region 原始的
+ ///
+ /// 增加一条数据
+ ///
+ public int Add(Basic.Model.comment model)
+ {
+ StringBuilder strSql = new StringBuilder();
+ strSql.Append("insert into tb_comment(");
+ strSql.Append("name,user_id,product_id,attribute_id,product_name,product_path,content,review,status,add_time)");
+ strSql.Append(" values (");
+ strSql.Append("@name,@user_id,@product_id,@attribute_id,@product_name,@product_path,@content,@review,@status,@add_time)");
+ strSql.Append(";select @@IDENTITY");
+
+ SqlParameter[] parameters = {
+ new SqlParameter("@name", SqlDbType.NVarChar,50),
+ new SqlParameter("@user_id", SqlDbType.Int,10),
+ new SqlParameter("@product_id", SqlDbType.Int,10),
+ new SqlParameter("@attribute_id", SqlDbType.NVarChar,255),
+ new SqlParameter("@product_name", SqlDbType.NVarChar,255),
+ new SqlParameter("@product_path", SqlDbType.NVarChar,255),
+ new SqlParameter("@content", SqlDbType.NVarChar,255),
+ new SqlParameter("@review", SqlDbType.NVarChar,255),
+ new SqlParameter("@status", SqlDbType.Int,10),
+ new SqlParameter("@add_time", SqlDbType.DateTime,23)};
+ parameters[0].Value = model.name;
+ parameters[1].Value = model.user_id;
+ parameters[2].Value = model.product_id;
+ parameters[3].Value = model.attribute_id;
+ parameters[4].Value = model.product_name;
+ parameters[5].Value = model.product_path;
+ parameters[6].Value = model.content;
+ parameters[7].Value = model.review;
+ parameters[8].Value = model.status;
+ parameters[9].Value = model.add_time;
+
+ object obj = DbHelperSQL.GetSingle(strSql.ToString(), parameters);
+ if (obj == null)
+ {
+ return 0;
+ }
+ else
+ {
+ return Convert.ToInt32(obj);
+ }
+ }
+
+ ///
+ /// 更新一条数据
+ ///
+ public bool Update(Basic.Model.comment model)
+ {
+ StringBuilder strSql = new StringBuilder();
+ strSql.Append("update tb_comment set ");
+ strSql.Append("name=@name,");
+ strSql.Append("user_id=@user_id,");
+ strSql.Append("product_id=@product_id,");
+ strSql.Append("attribute_id=@attribute_id,");
+ strSql.Append("product_name=@product_name,");
+ strSql.Append("product_path=@product_path,");
+ strSql.Append("content=@content,");
+ strSql.Append("review=@review,");
+ strSql.Append("status=@status,");
+ strSql.Append("add_time=@add_time");
+ strSql.Append(" where id=@id");
+ SqlParameter[] parameters = {
+ new SqlParameter("@name", SqlDbType.NVarChar,50),
+ new SqlParameter("@user_id", SqlDbType.Int,10),
+ new SqlParameter("@product_id", SqlDbType.Int,10),
+ new SqlParameter("@attribute_id", SqlDbType.NVarChar,255),
+ new SqlParameter("@product_name", SqlDbType.NVarChar,255),
+ new SqlParameter("@product_path", SqlDbType.NVarChar,255),
+ new SqlParameter("@content", SqlDbType.NVarChar,255),
+ new SqlParameter("@review", SqlDbType.NVarChar,255),
+ new SqlParameter("@status", SqlDbType.Int,10),
+ new SqlParameter("@add_time", SqlDbType.DateTime,23),
+ new SqlParameter("@id", SqlDbType.Int,4)};
+ parameters[0].Value = model.name;
+ parameters[1].Value = model.user_id;
+ parameters[2].Value = model.product_id;
+ parameters[3].Value = model.attribute_id;
+ parameters[4].Value = model.product_name;
+ parameters[5].Value = model.product_path;
+ parameters[6].Value = model.content;
+ parameters[7].Value = model.review;
+ parameters[8].Value = model.status;
+ parameters[9].Value = model.add_time;
+ parameters[10].Value = model.id;
+ int rows = DbHelperSQL.ExecuteSql(strSql.ToString(), parameters);
+ if (rows > 0)
+ {
+ return true;
+ }
+ else
+ {
+ return false;
+ }
+ }
+
+ ///
+ /// 删除一条数据
+ ///
+ public bool Delete(int id)
+ {
+ StringBuilder strSql = new StringBuilder();
+ strSql.Append("delete from tb_comment");
+ strSql.Append(" where id=@id");
+ SqlParameter[] parameters = {
+ new SqlParameter("@id", SqlDbType.Int,4)};
+ parameters[0].Value = id;
+ int rows = DbHelperSQL.ExecuteSql(strSql.ToString(), parameters);
+ if (rows > 0)
+ {
+ return true;
+ }
+ else
+ {
+ return false;
+ }
+ }
+
+ ///
+ /// 得到一个对象实体
+ ///
+ public Basic.Model.comment GetModel(int id)
+ {
+ StringBuilder strSql = new StringBuilder();
+ strSql.Append("select top 1 id,name,user_id,product_id,attribute_id,product_name,product_path,content,review,status,add_time from tb_comment");
+ strSql.Append(" where id=@id");
+ SqlParameter[] parameters = {
+ new SqlParameter("@id", SqlDbType.Int,4)};
+ parameters[0].Value = id;
+ Basic.Model.comment model = new Basic.Model.comment();
+ DataSet ds = DbHelperSQL.Query(strSql.ToString(), parameters);
+ if (ds.Tables[0].Rows.Count > 0)
+ {
+ if (!string.IsNullOrEmpty(ds.Tables[0].Rows[0]["id"].ToString()))
+ {
+ model.id = int.Parse(ds.Tables[0].Rows[0]["id"].ToString());
+ }
+ if (!string.IsNullOrEmpty(ds.Tables[0].Rows[0]["name"].ToString()))
+ {
+ model.name = ds.Tables[0].Rows[0]["name"].ToString();
+ }
+ if (!string.IsNullOrEmpty(ds.Tables[0].Rows[0]["user_id"].ToString()))
+ {
+ model.user_id = int.Parse(ds.Tables[0].Rows[0]["user_id"].ToString());
+ }
+ if (!string.IsNullOrEmpty(ds.Tables[0].Rows[0]["product_id"].ToString()))
+ {
+ model.product_id = int.Parse(ds.Tables[0].Rows[0]["product_id"].ToString());
+ }
+ if (!string.IsNullOrEmpty(ds.Tables[0].Rows[0]["attribute_id"].ToString()))
+ {
+ model.attribute_id = ds.Tables[0].Rows[0]["attribute_id"].ToString();
+ }
+ if (!string.IsNullOrEmpty(ds.Tables[0].Rows[0]["product_name"].ToString()))
+ {
+ model.product_name = ds.Tables[0].Rows[0]["product_name"].ToString();
+ }
+ if (!string.IsNullOrEmpty(ds.Tables[0].Rows[0]["product_path"].ToString()))
+ {
+ model.product_path = ds.Tables[0].Rows[0]["product_path"].ToString();
+ }
+ if (!string.IsNullOrEmpty(ds.Tables[0].Rows[0]["content"].ToString()))
+ {
+ model.content = ds.Tables[0].Rows[0]["content"].ToString();
+ }
+ if (!string.IsNullOrEmpty(ds.Tables[0].Rows[0]["review"].ToString()))
+ {
+ model.review = ds.Tables[0].Rows[0]["review"].ToString();
+ }
+ if (!string.IsNullOrEmpty(ds.Tables[0].Rows[0]["status"].ToString()))
+ {
+ model.status = int.Parse(ds.Tables[0].Rows[0]["status"].ToString());
+ }
+ if (!string.IsNullOrEmpty(ds.Tables[0].Rows[0]["add_time"].ToString()))
+ {
+ model.add_time = DateTime.Parse(ds.Tables[0].Rows[0]["add_time"].ToString());
+ }
+ return model;
+ }
+ else
+ {
+ return null;
+ }
+ }
+
+ ///
+ /// 获得前几行数据
+ ///
+ public DataSet GetList(int Top, string strWhere, string filedOrder)
+ {
+ StringBuilder strSql = new StringBuilder();
+ strSql.Append("select ");
+ if (Top > 0)
+ {
+ strSql.Append(" top " + Top.ToString());
+ }
+ strSql.Append("id,name,user_id,product_id,attribute_id,product_name,product_path,content,review,status,add_time");
+ strSql.Append(" from tb_comment");
+ if (strWhere.Trim() != "")
+ {
+ strSql.Append(" where " + strWhere);
+ }
+ strSql.Append(" order by " + filedOrder);
+ return DbHelperSQL.Query(strSql.ToString());
+ }
+
+ ///
+ /// 是否存在该记录
+ ///
+ public bool Exists(int id)
+ {
+ StringBuilder strSql = new StringBuilder();
+ strSql.Append("select count(1) from tb_comment");
+ strSql.Append(" where id=@id");
+ SqlParameter[] parameters = {
+ new SqlParameter("@id", SqlDbType.Int,4)};
+ parameters[0].Value = id;
+
+ return DbHelperSQL.Exists(strSql.ToString(), parameters);
+ }
+
+ #endregion
+
+ //=======================================================================================================后加的
+ ///
+ /// 获得查询分页数据
+ ///
+ public DataSet GetList(string _strWhere, string _orderby, int _pageSize, int _page, out int recordCount)
+ {
+ BasicPage bp = new BasicPage();
+ StringBuilder str_Sql = new StringBuilder();
+ str_Sql.Append("select top " + _pageSize + " * from tb_comment");
+ str_Sql.Append(" where ");
+ str_Sql.Append(_strWhere);
+ str_Sql.Append(" and id not in ");
+ str_Sql.Append(" ( ");
+ str_Sql.Append(" select top " + (_page - 1) * _pageSize + " id from tb_comment ");
+ str_Sql.Append(" where ");
+ str_Sql.Append(_strWhere);
+ str_Sql.Append(" order by ");
+ str_Sql.Append(_orderby);
+ str_Sql.Append(" ) ");
+ str_Sql.Append(" order by ");
+ str_Sql.Append(_orderby);
+ DataSet dst = bp.SelectDataBase("tb_comment", str_Sql.ToString());
+ //
+ recordCount = totlePage(showTotal(_strWhere), _pageSize);
+ return dst;
+ }
+
+ //总页数
+ public int totlePage(int Total, int PageSize)
+ {
+ if (Total % PageSize == 0)
+ {
+ return Total / PageSize;
+ }
+ else
+ {
+ return Total / PageSize + 1;
+ }
+ }
+
+ //总条数
+ protected int showTotal(string strSql)
+ {
+ BasicPage bp = new BasicPage();
+ int intTotal = 0;
+ SqlDataReader myread = bp.getRead("select count(id) as CountId from tb_comment where " + strSql);
+ if (myread.Read())
+ {
+ intTotal = Convert.ToInt32(myread["CountId"].ToString());
+ }
+ myread.Close();
+ return intTotal;
+ }
+
+ }
+}
+
diff --git a/App.code/DAL/coupon.cs b/App.code/DAL/coupon.cs
new file mode 100644
index 0000000..3c5a6ed
--- /dev/null
+++ b/App.code/DAL/coupon.cs
@@ -0,0 +1,295 @@
+using System;
+using System.Data;
+using System.Text;
+using System.Data.SqlClient;
+
+namespace Basic.DAL
+{
+ ///
+ /// 数据访问层
+ ///
+ public partial class coupon
+ {
+ #region 此代码由工具生成
+
+ ///
+ /// 增加一条数据
+ ///
+ public int Add(Basic.Model.coupon model)
+ {
+ StringBuilder strSql = new StringBuilder();
+ strSql.Append("insert into tb_coupon(");
+ strSql.Append("paixu,name,start_time,end_time,number,purchase_amount,coupon_amount,status,add_time)");
+ strSql.Append(" values (");
+ strSql.Append("@paixu,@name,@start_time,@end_time,@number,@purchase_amount,@coupon_amount,@status,@add_time)");
+ strSql.Append(";select @@IDENTITY");
+
+ SqlParameter[] parameters = {
+ new SqlParameter("@paixu", SqlDbType.Int,10),
+ new SqlParameter("@name", SqlDbType.NVarChar,255),
+ new SqlParameter("@start_time", SqlDbType.DateTime,23),
+ new SqlParameter("@end_time", SqlDbType.DateTime,23),
+ new SqlParameter("@number", SqlDbType.Int,10),
+ new SqlParameter("@purchase_amount", SqlDbType.Decimal,18),
+ new SqlParameter("@coupon_amount", SqlDbType.Decimal,18),
+ new SqlParameter("@status", SqlDbType.Int,10),
+ new SqlParameter("@add_time", SqlDbType.DateTime,23)};
+ parameters[0].Value = model.paixu;
+ parameters[1].Value = model.name;
+ parameters[2].Value = model.start_time;
+ parameters[3].Value = model.end_time;
+ parameters[4].Value = model.number;
+ parameters[5].Value = model.purchase_amount;
+ parameters[6].Value = model.coupon_amount;
+ parameters[7].Value = model.status;
+ parameters[8].Value = model.add_time;
+
+ object obj = DbHelperSQL.GetSingle(strSql.ToString(), parameters);
+ if (obj == null)
+ {
+ return 0;
+ }
+ else
+ {
+ return Convert.ToInt32(obj);
+ }
+ }
+
+ ///
+ /// 更新一条数据
+ ///
+ public bool Update(Basic.Model.coupon model)
+ {
+ StringBuilder strSql = new StringBuilder();
+ strSql.Append("update tb_coupon set ");
+ strSql.Append("paixu=@paixu,");
+ strSql.Append("name=@name,");
+ strSql.Append("start_time=@start_time,");
+ strSql.Append("end_time=@end_time,");
+ strSql.Append("number=@number,");
+ strSql.Append("purchase_amount=@purchase_amount,");
+ strSql.Append("coupon_amount=@coupon_amount,");
+ strSql.Append("status=@status,");
+ strSql.Append("add_time=@add_time");
+ strSql.Append(" where id=@id");
+ SqlParameter[] parameters = {
+ new SqlParameter("@paixu", SqlDbType.Int,10),
+ new SqlParameter("@name", SqlDbType.NVarChar,255),
+ new SqlParameter("@start_time", SqlDbType.DateTime,23),
+ new SqlParameter("@end_time", SqlDbType.DateTime,23),
+ new SqlParameter("@number", SqlDbType.Int,10),
+ new SqlParameter("@purchase_amount", SqlDbType.Decimal,18),
+ new SqlParameter("@coupon_amount", SqlDbType.Decimal,18),
+ new SqlParameter("@status", SqlDbType.Int,10),
+ new SqlParameter("@add_time", SqlDbType.DateTime,23),
+ new SqlParameter("@id", SqlDbType.Int,4)};
+ parameters[0].Value = model.paixu;
+ parameters[1].Value = model.name;
+ parameters[2].Value = model.start_time;
+ parameters[3].Value = model.end_time;
+ parameters[4].Value = model.number;
+ parameters[5].Value = model.purchase_amount;
+ parameters[6].Value = model.coupon_amount;
+ parameters[7].Value = model.status;
+ parameters[8].Value = model.add_time;
+ parameters[9].Value = model.id;
+ int rows = DbHelperSQL.ExecuteSql(strSql.ToString(), parameters);
+ if (rows > 0)
+ {
+ return true;
+ }
+ else
+ {
+ return false;
+ }
+ }
+
+ ///
+ /// 删除一条数据
+ ///
+ public bool Delete(int id)
+ {
+ StringBuilder strSql = new StringBuilder();
+ strSql.Append("delete from tb_coupon");
+ strSql.Append(" where id=@id");
+ SqlParameter[] parameters = {
+ new SqlParameter("@id", SqlDbType.Int,4)};
+ parameters[0].Value = id;
+ int rows = DbHelperSQL.ExecuteSql(strSql.ToString(), parameters);
+ if (rows > 0)
+ {
+ return true;
+ }
+ else
+ {
+ return false;
+ }
+ }
+
+ ///
+ /// 得到一个对象实体
+ ///
+ public Basic.Model.coupon GetModel(int id)
+ {
+ StringBuilder strSql=new StringBuilder();
+ strSql.Append("select top 1 id,paixu,name,start_time,end_time,number,purchase_amount,coupon_amount,status,add_time from tb_coupon");
+ strSql.Append(" where id=@id");
+ SqlParameter[] parameters = {
+ new SqlParameter("@id", SqlDbType.Int,4)};
+ parameters[0].Value = id;
+ Basic.Model.coupon model = new Basic.Model.coupon();
+ DataSet ds = DbHelperSQL.Query(strSql.ToString(), parameters);
+ if (ds.Tables[0].Rows.Count > 0)
+ {
+ if (!string.IsNullOrEmpty(ds.Tables[0].Rows[0]["id"].ToString()))
+ {
+ model.id = int.Parse(ds.Tables[0].Rows[0]["id"].ToString());
+ }
+ if (!string.IsNullOrEmpty(ds.Tables[0].Rows[0]["paixu"].ToString()))
+ {
+ model.paixu = int.Parse(ds.Tables[0].Rows[0]["paixu"].ToString());
+ }
+ if (!string.IsNullOrEmpty(ds.Tables[0].Rows[0]["name"].ToString()))
+ {
+ model.name = ds.Tables[0].Rows[0]["name"].ToString();
+ }
+ if (!string.IsNullOrEmpty(ds.Tables[0].Rows[0]["start_time"].ToString()))
+ {
+ model.start_time = DateTime.Parse(ds.Tables[0].Rows[0]["start_time"].ToString());
+ }
+ if (!string.IsNullOrEmpty(ds.Tables[0].Rows[0]["end_time"].ToString()))
+ {
+ model.end_time = DateTime.Parse(ds.Tables[0].Rows[0]["end_time"].ToString());
+ }
+ if (!string.IsNullOrEmpty(ds.Tables[0].Rows[0]["number"].ToString()))
+ {
+ model.number = int.Parse(ds.Tables[0].Rows[0]["number"].ToString());
+ }
+ if (!string.IsNullOrEmpty(ds.Tables[0].Rows[0]["purchase_amount"].ToString()))
+ {
+ model.purchase_amount = decimal.Parse(ds.Tables[0].Rows[0]["purchase_amount"].ToString());
+ }
+ if (!string.IsNullOrEmpty(ds.Tables[0].Rows[0]["coupon_amount"].ToString()))
+ {
+ model.coupon_amount = decimal.Parse(ds.Tables[0].Rows[0]["coupon_amount"].ToString());
+ }
+ if (!string.IsNullOrEmpty(ds.Tables[0].Rows[0]["status"].ToString()))
+ {
+ model.status = int.Parse(ds.Tables[0].Rows[0]["status"].ToString());
+ }
+ if (!string.IsNullOrEmpty(ds.Tables[0].Rows[0]["add_time"].ToString()))
+ {
+ model.add_time = DateTime.Parse(ds.Tables[0].Rows[0]["add_time"].ToString());
+ }
+ return model;
+ }
+ else
+ {
+ return null;
+ }
+ }
+
+ ///
+ /// 获得前几行数据
+ ///
+ public DataSet GetList(int Top, string strWhere, string filedOrder)
+ {
+ StringBuilder strSql = new StringBuilder();
+ strSql.Append("select ");
+ if (Top > 0)
+ {
+ strSql.Append(" top " + Top.ToString());
+ }
+ strSql.Append("id,paixu,name,start_time,end_time,number,purchase_amount,coupon_amount,status,add_time");
+ strSql.Append(" from tb_coupon");
+ if (strWhere.Trim() != "")
+ {
+ strSql.Append(" where " + strWhere);
+ }
+ strSql.Append(" order by " + filedOrder);
+ return DbHelperSQL.Query(strSql.ToString());
+ }
+
+ ///
+ /// 获得查询分页数据
+ ///
+ public DataSet GetList(string _strWhere, string _orderby, int _pageSize, int _page, out int recordCount)
+ {
+ BasicPage bp = new BasicPage();
+ StringBuilder str_Sql = new StringBuilder();
+ str_Sql.Append("select top " + _pageSize + " id,paixu,name,start_time,end_time,number,purchase_amount,coupon_amount,status,add_time from tb_coupon");
+ str_Sql.Append(" where ");
+ str_Sql.Append(_strWhere);
+ str_Sql.Append(" and id not in ");
+ str_Sql.Append(" ( ");
+ str_Sql.Append(" select top " + (_page - 1) * _pageSize + " id from tb_coupon ");
+ str_Sql.Append(" where ");
+ str_Sql.Append(_strWhere);
+ str_Sql.Append(" order by ");
+ str_Sql.Append(_orderby);
+ str_Sql.Append(" ) ");
+ str_Sql.Append(" order by ");
+ str_Sql.Append(_orderby);
+ DataSet dst = bp.SelectDataBase("tb_coupon", str_Sql.ToString());
+ //
+ recordCount = totlePage(showTotal(_strWhere), _pageSize);
+ return dst;
+ }
+
+ //总页数
+ public int totlePage(int Total, int PageSize)
+ {
+ if (Total % PageSize == 0)
+ {
+ return Total / PageSize;
+ }
+ else
+ {
+ return Total / PageSize + 1;
+ }
+ }
+
+ //总条数
+ protected int showTotal(string strSql)
+ {
+ BasicPage bp = new BasicPage();
+ int intTotal = 0;
+ SqlDataReader myread = bp.getRead("select count(id) as CountId from tb_coupon where " + strSql);
+ if (myread.Read())
+ {
+ intTotal = Convert.ToInt32(myread["CountId"].ToString());
+ }
+ myread.Close();
+ return intTotal;
+ }
+
+ ///
+ /// 是否存在该记录
+ ///
+ public bool Exists(int id)
+ {
+ StringBuilder strSql = new StringBuilder();
+ strSql.Append("select count(1) from tb_coupon");
+ strSql.Append(" where id=@id");
+ SqlParameter[] parameters = {
+ new SqlParameter("@id", SqlDbType.Int,4)};
+ parameters[0].Value = id;
+
+ return DbHelperSQL.Exists(strSql.ToString(), parameters);
+ }
+
+ ///
+ /// 修改一列数据
+ ///
+ public void UpdateField(int id, string strValue)
+ {
+ StringBuilder strSql = new StringBuilder();
+ strSql.Append("update tb_coupon set " + strValue);
+ strSql.Append(" where id=" + id);
+ DbHelperSQL.ExecuteSql(strSql.ToString());
+ }
+
+ #endregion
+ }
+}
+
diff --git a/App.code/DAL/couponuser.cs b/App.code/DAL/couponuser.cs
new file mode 100644
index 0000000..f8e0952
--- /dev/null
+++ b/App.code/DAL/couponuser.cs
@@ -0,0 +1,259 @@
+using System;
+using System.Data;
+using System.Text;
+using System.Data.SqlClient;
+
+namespace Basic.DAL
+{
+ ///
+ /// 数据访问层
+ ///
+ public partial class couponuser
+ {
+ #region 此代码由工具生成
+
+ ///
+ /// 增加一条数据
+ ///
+ public int Add(Basic.Model.couponuser model)
+ {
+ StringBuilder strSql = new StringBuilder();
+ strSql.Append("insert into tb_couponuser(");
+ strSql.Append("paixu,couponid,name,couponstatus,add_time)");
+ strSql.Append(" values (");
+ strSql.Append("@paixu,@couponid,@name,@couponstatus,@add_time)");
+ strSql.Append(";select @@IDENTITY");
+
+ SqlParameter[] parameters = {
+ new SqlParameter("@paixu", SqlDbType.Int,10),
+ new SqlParameter("@couponid", SqlDbType.Int,10),
+ new SqlParameter("@name", SqlDbType.NVarChar,255),
+ new SqlParameter("@couponstatus", SqlDbType.Int,10),
+ new SqlParameter("@add_time", SqlDbType.DateTime,23)};
+ parameters[0].Value = model.paixu;
+ parameters[1].Value = model.couponid;
+ parameters[2].Value = model.name;
+ parameters[3].Value = model.couponstatus;
+ parameters[4].Value = model.add_time;
+
+ object obj = DbHelperSQL.GetSingle(strSql.ToString(), parameters);
+ if (obj == null)
+ {
+ return 0;
+ }
+ else
+ {
+ return Convert.ToInt32(obj);
+ }
+ }
+
+ ///
+ /// 更新一条数据
+ ///
+ public bool Update(Basic.Model.couponuser model)
+ {
+ StringBuilder strSql = new StringBuilder();
+ strSql.Append("update tb_couponuser set ");
+ strSql.Append("paixu=@paixu,");
+ strSql.Append("couponid=@couponid,");
+ strSql.Append("name=@name,");
+ strSql.Append("couponstatus=@couponstatus,");
+ strSql.Append("add_time=@add_time");
+ strSql.Append(" where id=@id");
+ SqlParameter[] parameters = {
+ new SqlParameter("@paixu", SqlDbType.Int,10),
+ new SqlParameter("@couponid", SqlDbType.Int,10),
+ new SqlParameter("@name", SqlDbType.NVarChar,255),
+ new SqlParameter("@couponstatus", SqlDbType.Int,10),
+ new SqlParameter("@add_time", SqlDbType.DateTime,23),
+ new SqlParameter("@id", SqlDbType.Int,4)};
+ parameters[0].Value = model.paixu;
+ parameters[1].Value = model.couponid;
+ parameters[2].Value = model.name;
+ parameters[3].Value = model.couponstatus;
+ parameters[4].Value = model.add_time;
+ parameters[5].Value = model.id;
+ int rows = DbHelperSQL.ExecuteSql(strSql.ToString(), parameters);
+ if (rows > 0)
+ {
+ return true;
+ }
+ else
+ {
+ return false;
+ }
+ }
+
+ ///
+ /// 删除一条数据
+ ///
+ public bool Delete(int id)
+ {
+ StringBuilder strSql = new StringBuilder();
+ strSql.Append("delete from tb_couponuser");
+ strSql.Append(" where id=@id");
+ SqlParameter[] parameters = {
+ new SqlParameter("@id", SqlDbType.Int,4)};
+ parameters[0].Value = id;
+ int rows = DbHelperSQL.ExecuteSql(strSql.ToString(), parameters);
+ if (rows > 0)
+ {
+ return true;
+ }
+ else
+ {
+ return false;
+ }
+ }
+
+ ///
+ /// 得到一个对象实体
+ ///
+ public Basic.Model.couponuser GetModel(int id)
+ {
+ StringBuilder strSql=new StringBuilder();
+ strSql.Append("select top 1 id,paixu,couponid,name,couponstatus,add_time from tb_couponuser");
+ strSql.Append(" where id=@id");
+ SqlParameter[] parameters = {
+ new SqlParameter("@id", SqlDbType.Int,4)};
+ parameters[0].Value = id;
+ Basic.Model.couponuser model = new Basic.Model.couponuser();
+ DataSet ds = DbHelperSQL.Query(strSql.ToString(), parameters);
+ if (ds.Tables[0].Rows.Count > 0)
+ {
+ if (!string.IsNullOrEmpty(ds.Tables[0].Rows[0]["id"].ToString()))
+ {
+ model.id = int.Parse(ds.Tables[0].Rows[0]["id"].ToString());
+ }
+ if (!string.IsNullOrEmpty(ds.Tables[0].Rows[0]["paixu"].ToString()))
+ {
+ model.paixu = int.Parse(ds.Tables[0].Rows[0]["paixu"].ToString());
+ }
+ if (!string.IsNullOrEmpty(ds.Tables[0].Rows[0]["couponid"].ToString()))
+ {
+ model.couponid = int.Parse(ds.Tables[0].Rows[0]["couponid"].ToString());
+ }
+ if (!string.IsNullOrEmpty(ds.Tables[0].Rows[0]["name"].ToString()))
+ {
+ model.name = ds.Tables[0].Rows[0]["name"].ToString();
+ }
+ if (!string.IsNullOrEmpty(ds.Tables[0].Rows[0]["couponstatus"].ToString()))
+ {
+ model.couponstatus = int.Parse(ds.Tables[0].Rows[0]["couponstatus"].ToString());
+ }
+ if (!string.IsNullOrEmpty(ds.Tables[0].Rows[0]["add_time"].ToString()))
+ {
+ model.add_time = DateTime.Parse(ds.Tables[0].Rows[0]["add_time"].ToString());
+ }
+ return model;
+ }
+ else
+ {
+ return null;
+ }
+ }
+
+ ///
+ /// 获得前几行数据
+ ///
+ public DataSet GetList(int Top, string strWhere, string filedOrder)
+ {
+ StringBuilder strSql = new StringBuilder();
+ strSql.Append("select ");
+ if (Top > 0)
+ {
+ strSql.Append(" top " + Top.ToString());
+ }
+ strSql.Append("id,paixu,couponid,name,couponstatus,add_time");
+ strSql.Append(" from tb_couponuser");
+ if (strWhere.Trim() != "")
+ {
+ strSql.Append(" where " + strWhere);
+ }
+ strSql.Append(" order by " + filedOrder);
+ return DbHelperSQL.Query(strSql.ToString());
+ }
+
+ ///
+ /// 获得查询分页数据
+ ///
+ public DataSet GetList(string _strWhere, string _orderby, int _pageSize, int _page, out int recordCount)
+ {
+ BasicPage bp = new BasicPage();
+ StringBuilder str_Sql = new StringBuilder();
+ str_Sql.Append("select top " + _pageSize + " id,paixu,couponid,name,couponstatus,add_time from tb_couponuser");
+ str_Sql.Append(" where ");
+ str_Sql.Append(_strWhere);
+ str_Sql.Append(" and id not in ");
+ str_Sql.Append(" ( ");
+ str_Sql.Append(" select top " + (_page - 1) * _pageSize + " id from tb_couponuser ");
+ str_Sql.Append(" where ");
+ str_Sql.Append(_strWhere);
+ str_Sql.Append(" order by ");
+ str_Sql.Append(_orderby);
+ str_Sql.Append(" ) ");
+ str_Sql.Append(" order by ");
+ str_Sql.Append(_orderby);
+ DataSet dst = bp.SelectDataBase("tb_couponuser", str_Sql.ToString());
+ //
+ recordCount = totlePage(showTotal(_strWhere), _pageSize);
+ return dst;
+ }
+
+ //总页数
+ public int totlePage(int Total, int PageSize)
+ {
+ if (Total % PageSize == 0)
+ {
+ return Total / PageSize;
+ }
+ else
+ {
+ return Total / PageSize + 1;
+ }
+ }
+
+ //总条数
+ protected int showTotal(string strSql)
+ {
+ BasicPage bp = new BasicPage();
+ int intTotal = 0;
+ SqlDataReader myread = bp.getRead("select count(id) as CountId from tb_couponuser where " + strSql);
+ if (myread.Read())
+ {
+ intTotal = Convert.ToInt32(myread["CountId"].ToString());
+ }
+ myread.Close();
+ return intTotal;
+ }
+
+ ///
+ /// 是否存在该记录
+ ///
+ public bool Exists(int id)
+ {
+ StringBuilder strSql = new StringBuilder();
+ strSql.Append("select count(1) from tb_couponuser");
+ strSql.Append(" where id=@id");
+ SqlParameter[] parameters = {
+ new SqlParameter("@id", SqlDbType.Int,4)};
+ parameters[0].Value = id;
+
+ return DbHelperSQL.Exists(strSql.ToString(), parameters);
+ }
+
+ ///
+ /// 修改一列数据
+ ///
+ public void UpdateField(int id, string strValue)
+ {
+ StringBuilder strSql = new StringBuilder();
+ strSql.Append("update tb_couponuser set " + strValue);
+ strSql.Append(" where id=" + id);
+ DbHelperSQL.ExecuteSql(strSql.ToString());
+ }
+
+ #endregion
+ }
+}
+
diff --git a/App.code/DAL/databackup.cs b/App.code/DAL/databackup.cs
new file mode 100644
index 0000000..178e36f
--- /dev/null
+++ b/App.code/DAL/databackup.cs
@@ -0,0 +1,256 @@
+using System;
+using System.Data;
+using System.Text;
+using System.Data.SqlClient;
+
+namespace Basic.DAL
+{
+ ///
+ /// 数据访问层databackup
+ ///
+ public partial class databackup
+ {
+ ///
+ /// 增加一条数据
+ ///
+ public int Add(Basic.Model.databackup model)
+ {
+ StringBuilder strSql=new StringBuilder();
+ strSql.Append("insert into tb_databackup(");
+ strSql.Append("title,paixu,storage,user_name,add_time)");
+ strSql.Append(" values (");
+ strSql.Append("@title,@paixu,@storage,@user_name,@add_time)");
+ strSql.Append(";select @@IDENTITY");
+
+ SqlParameter[] parameters = {
+ new SqlParameter("@title", SqlDbType.NVarChar,100),
+ new SqlParameter("@paixu", SqlDbType.Int,10),
+ new SqlParameter("@storage", SqlDbType.NVarChar,100),
+ new SqlParameter("@user_name", SqlDbType.NVarChar,100),
+ new SqlParameter("@add_time", SqlDbType.DateTime,23)};
+ parameters[0].Value = model.title;
+ parameters[1].Value = model.paixu;
+ parameters[2].Value = model.storage;
+ parameters[3].Value = model.user_name;
+ parameters[4].Value = model.add_time;
+
+ object obj = DbHelperSQL.GetSingle(strSql.ToString(), parameters);
+ if (obj == null)
+ {
+ return 0;
+ }
+ else
+ {
+ return Convert.ToInt32(obj);
+ }
+ }
+
+ ///
+ /// 更新一条数据
+ ///
+ public bool Update(Basic.Model.databackup model)
+ {
+ StringBuilder strSql=new StringBuilder();
+ strSql.Append("update tb_databackup set ");
+ strSql.Append("title=@title,");
+ strSql.Append("paixu=@paixu,");
+ strSql.Append("storage=@storage,");
+ strSql.Append("user_name=@user_name,");
+ strSql.Append("add_time=@add_time");
+ strSql.Append(" where id=@id");
+ SqlParameter[] parameters = {
+ new SqlParameter("@title", SqlDbType.NVarChar,100),
+ new SqlParameter("@paixu", SqlDbType.Int,10),
+ new SqlParameter("@storage", SqlDbType.NVarChar,100),
+ new SqlParameter("@user_name", SqlDbType.NVarChar,100),
+ new SqlParameter("@add_time", SqlDbType.DateTime,23),
+ new SqlParameter("@id", SqlDbType.Int,4)};
+ parameters[0].Value = model.title;
+ parameters[1].Value = model.paixu;
+ parameters[2].Value = model.storage;
+ parameters[3].Value = model.user_name;
+ parameters[4].Value = model.add_time;
+ parameters[5].Value = model.id;
+ int rows = DbHelperSQL.ExecuteSql(strSql.ToString(), parameters);
+ if (rows > 0)
+ {
+ return true;
+ }
+ else
+ {
+ return false;
+ }
+ }
+
+ ///
+ /// 删除一条数据
+ ///
+ public bool Delete(int id)
+ {
+ StringBuilder strSql=new StringBuilder();
+ strSql.Append("delete from tb_databackup");
+ strSql.Append(" where id=@id");
+ SqlParameter[] parameters = {
+ new SqlParameter("@id", SqlDbType.Int,4)};
+ parameters[0].Value = id;
+ int rows = DbHelperSQL.ExecuteSql(strSql.ToString(), parameters);
+ if (rows > 0)
+ {
+ return true;
+ }
+ else
+ {
+ return false;
+ }
+ }
+
+ ///
+ /// 得到一个对象实体
+ ///
+ public Basic.Model.databackup GetModel(int id)
+ {
+ StringBuilder strSql=new StringBuilder();
+ strSql.Append("select top 1 id,title,paixu,storage,user_name,add_time from tb_databackup");
+ strSql.Append(" where id=@id");
+ SqlParameter[] parameters = {
+ new SqlParameter("@id", SqlDbType.Int,4)};
+ parameters[0].Value = id;
+ Basic.Model.databackup model = new Basic.Model.databackup();
+ DataSet ds = DbHelperSQL.Query(strSql.ToString(), parameters);
+ if (ds.Tables[0].Rows.Count > 0)
+ {
+ if (!string.IsNullOrEmpty(ds.Tables[0].Rows[0]["id"].ToString()))
+ {
+ model.id = int.Parse(ds.Tables[0].Rows[0]["id"].ToString());
+ }
+ if (!string.IsNullOrEmpty(ds.Tables[0].Rows[0]["title"].ToString()))
+ {
+ model.title = ds.Tables[0].Rows[0]["title"].ToString();
+ }
+ if (!string.IsNullOrEmpty(ds.Tables[0].Rows[0]["paixu"].ToString()))
+ {
+ model.paixu = int.Parse(ds.Tables[0].Rows[0]["paixu"].ToString());
+ }
+ if (!string.IsNullOrEmpty(ds.Tables[0].Rows[0]["storage"].ToString()))
+ {
+ model.storage = ds.Tables[0].Rows[0]["storage"].ToString();
+ }
+ if (!string.IsNullOrEmpty(ds.Tables[0].Rows[0]["user_name"].ToString()))
+ {
+ model.user_name = ds.Tables[0].Rows[0]["user_name"].ToString();
+ }
+ if (!string.IsNullOrEmpty(ds.Tables[0].Rows[0]["add_time"].ToString()))
+ {
+ model.add_time = DateTime.Parse(ds.Tables[0].Rows[0]["add_time"].ToString());
+ }
+ return model;
+ }
+ else
+ {
+ return null;
+ }
+ }
+
+ ///
+ /// 获得前几行数据
+ ///
+ public DataSet GetList(int Top, string strWhere, string filedOrder)
+ {
+ StringBuilder strSql=new StringBuilder();
+ strSql.Append("select ");
+ if (Top > 0)
+ {
+ strSql.Append(" top " + Top.ToString());
+ }
+ strSql.Append("id,title,paixu,storage,user_name,add_time");
+ strSql.Append(" from tb_databackup");
+ if (strWhere.Trim() != "")
+ {
+ strSql.Append(" where " + strWhere);
+ }
+ strSql.Append(" order by " + filedOrder);
+ return DbHelperSQL.Query(strSql.ToString());
+ }
+
+ ///
+ /// 是否存在该记录
+ ///
+ public bool Exists(int id)
+ {
+ StringBuilder strSql=new StringBuilder();
+ strSql.Append("select count(1) from tb_databackup");
+ strSql.Append(" where id=@id");
+ SqlParameter[] parameters = {
+ new SqlParameter("@id", SqlDbType.Int,4)};
+ parameters[0].Value = id;
+
+ return DbHelperSQL.Exists(strSql.ToString(), parameters);
+ }
+
+ //后加的============================================================================================================
+ ///
+ /// 获得查询分页数据
+ ///
+ public DataSet GetList(string _strWhere, string _orderby, int _pageSize, int _page, out int recordCount)
+ {
+ BasicPage bp = new BasicPage();
+ StringBuilder str_Sql = new StringBuilder();
+ str_Sql.Append("select top " + _pageSize + " * from tb_databackup");
+ str_Sql.Append(" where ");
+ str_Sql.Append(_strWhere);
+ str_Sql.Append(" and id not in ");
+ str_Sql.Append(" ( ");
+ str_Sql.Append(" select top " + (_page - 1) * _pageSize + " id from tb_databackup ");
+ str_Sql.Append(" where ");
+ str_Sql.Append(_strWhere);
+ str_Sql.Append(" order by ");
+ str_Sql.Append(_orderby);
+ str_Sql.Append(" ) ");
+ str_Sql.Append(" order by ");
+ str_Sql.Append(_orderby);
+ DataSet dst = bp.SelectDataBase("tb_databackup", str_Sql.ToString());
+ //
+ recordCount = totlePage(showTotal(_strWhere), _pageSize);
+ return dst;
+ }
+
+ //总页数
+ public int totlePage(int Total, int PageSize)
+ {
+ if (Total % PageSize == 0)
+ {
+ return Total / PageSize;
+ }
+ else
+ {
+ return Total / PageSize + 1;
+ }
+ }
+
+ //总条数
+ protected int showTotal(string strSql)
+ {
+ BasicPage bp = new BasicPage();
+ int intTotal = 0;
+ SqlDataReader myread = bp.getRead("select count(id) as CountId from tb_databackup where " + strSql);
+ if (myread.Read())
+ {
+ intTotal = Convert.ToInt32(myread["CountId"].ToString());
+ }
+ myread.Close();
+ return intTotal;
+ }
+
+ ///
+ /// 修改一列数据
+ ///
+ public void UpdateField(int id, string strValue)
+ {
+ StringBuilder strSql = new StringBuilder();
+ strSql.Append("update tb_databackup set " + strValue);
+ strSql.Append(" where id=" + id);
+ DbHelperSQL.ExecuteSql(strSql.ToString());
+ }
+ }
+}
+
diff --git a/App.code/DAL/followproduct.cs b/App.code/DAL/followproduct.cs
new file mode 100644
index 0000000..9f10545
--- /dev/null
+++ b/App.code/DAL/followproduct.cs
@@ -0,0 +1,177 @@
+using System;
+using System.Data;
+using System.Text;
+using System.Data.SqlClient;
+
+namespace Basic.DAL
+{
+ ///
+ /// 数据访问层
+ ///
+ public partial class followproduct
+ {
+ #region 此代码由工具生成
+
+ ///
+ /// 增加一条数据
+ ///
+ public int Add(Basic.Model.followproduct model)
+ {
+ StringBuilder strSql = new StringBuilder();
+ strSql.Append("insert into tb_followproduct(");
+ strSql.Append("product_id,add_time,openid)");
+ strSql.Append(" values (");
+ strSql.Append("@product_id,@add_time,@openid)");
+ strSql.Append(";select @@IDENTITY");
+
+ SqlParameter[] parameters =
+ {
+ new SqlParameter("@product_id", SqlDbType.Int,10),
+ new SqlParameter("@add_time", SqlDbType.DateTime,23),
+ new SqlParameter("@openid", SqlDbType.NVarChar,255)
+ };
+ parameters[0].Value = model.product_id;
+ parameters[1].Value = model.add_time;
+ parameters[2].Value = model.openid;
+
+ object obj = DbHelperSQL.GetSingle(strSql.ToString(), parameters);
+ if (obj == null)
+ {
+ return 0;
+ }
+ else
+ {
+ return Convert.ToInt32(obj);
+ }
+ }
+
+
+
+ ///
+ /// 删除一条数据
+ ///
+ public bool Delete(int id)
+ {
+ StringBuilder strSql = new StringBuilder();
+ strSql.Append("delete from tb_followproduct");
+ strSql.Append(" where id=@id");
+ SqlParameter[] parameters = {
+ new SqlParameter("@id", SqlDbType.Int,4)};
+ parameters[0].Value = id;
+ int rows = DbHelperSQL.ExecuteSql(strSql.ToString(), parameters);
+ if (rows > 0)
+ {
+ return true;
+ }
+ else
+ {
+ return false;
+ }
+ }
+ ///
+ /// 获得前几行数据
+ ///
+ public DataSet GetList(int Top, string strWhere, string filedOrder)
+ {
+ StringBuilder strSql = new StringBuilder();
+ strSql.Append("select ");
+ if (Top > 0)
+ {
+ strSql.Append(" top " + Top.ToString());
+ }
+ strSql.Append("product_id,add_time,openid from tb_followproduct");
+ strSql.Append(" from tb_followproduct");
+ if (strWhere.Trim() != "")
+ {
+ strSql.Append(" where " + strWhere);
+ }
+ strSql.Append(" order by " + filedOrder);
+ return DbHelperSQL.Query(strSql.ToString());
+ }
+
+ ///
+ /// 获得查询分页数据
+ ///
+ public DataSet GetList(string _strWhere, string _orderby, int _pageSize, int _page, out int recordCount)
+ {
+ BasicPage bp = new BasicPage();
+ StringBuilder str_Sql = new StringBuilder();
+ str_Sql.Append("select top " + _pageSize + " product_id,add_time,openid from tb_followproduct");
+ str_Sql.Append(" where ");
+ str_Sql.Append(_strWhere);
+ str_Sql.Append(" and id not in ");
+ str_Sql.Append(" ( ");
+ str_Sql.Append(" select top " + (_page - 1) * _pageSize + " id from tb_followproduct ");
+ str_Sql.Append(" where ");
+ str_Sql.Append(_strWhere);
+ str_Sql.Append(" order by ");
+ str_Sql.Append(_orderby);
+ str_Sql.Append(" ) ");
+ str_Sql.Append(" order by ");
+ str_Sql.Append(_orderby);
+ DataSet dst = bp.SelectDataBase("tb_followproduct", str_Sql.ToString());
+ //
+ recordCount = totlePage(showTotal(_strWhere), _pageSize);
+ return dst;
+ }
+
+ //总页数
+ public int totlePage(int Total, int PageSize)
+ {
+ if (Total % PageSize == 0)
+ {
+ return Total / PageSize;
+ }
+ else
+ {
+ return Total / PageSize + 1;
+ }
+ }
+
+ //总条数
+ public int showTotal(string strSql)
+ {
+ BasicPage bp = new BasicPage();
+ int intTotal = 0;
+ SqlDataReader myread = bp.getRead("select count(id) as CountId from tb_shopcart where " + strSql);
+ if (myread.Read())
+ {
+ intTotal = Convert.ToInt32(myread["CountId"].ToString());
+ }
+ myread.Close();
+ return intTotal;
+ }
+
+ ///
+ /// 是否存在该记录
+ ///
+ public bool Exists(int id)
+ {
+ StringBuilder strSql = new StringBuilder();
+ strSql.Append("select count(1) from tb_followproduct");
+ strSql.Append(" where product_id=@product_id");
+ SqlParameter[] parameters =
+ {
+ new SqlParameter("@product_id", SqlDbType.Int,10)
+ };
+ parameters[0].Value = id;
+
+ return DbHelperSQL.Exists(strSql.ToString(), parameters);
+ }
+
+ ///
+ /// 修改一列数据
+ ///
+ public void UpdateField(int id, string strValue)
+ {
+ StringBuilder strSql = new StringBuilder();
+ strSql.Append("update tb_followproduct set " + strValue);
+ strSql.Append(" where id=" + id);
+ DbHelperSQL.ExecuteSql(strSql.ToString());
+ }
+
+
+ #endregion
+ }
+}
+
diff --git a/App.code/DAL/freight.cs b/App.code/DAL/freight.cs
new file mode 100644
index 0000000..66eb6b6
--- /dev/null
+++ b/App.code/DAL/freight.cs
@@ -0,0 +1,373 @@
+using System;
+using System.Data;
+using System.Text;
+using System.Data.SqlClient;
+
+namespace Basic.DAL
+{
+ ///
+ /// 数据访问层
+ ///
+ public partial class freight
+ {
+ #region 此代码由工具生成
+
+ ///
+ /// 增加一条数据
+ ///
+ public int Add(Basic.Model.freight model)
+ {
+ StringBuilder strSql = new StringBuilder();
+ strSql.Append("insert into tb_freight(");
+ strSql.Append("title,gudingyf,yuanmian,yuanjifei,jianmian,jianjifei,content,paixu,state,add_time)");
+ strSql.Append(" values (");
+ strSql.Append("@title,@gudingyf,@yuanmian,@yuanjifei,@jianmian,@jianjifei,@content,@paixu,@state,@add_time)");
+ strSql.Append(";select @@IDENTITY");
+
+ SqlParameter[] parameters = {
+ new SqlParameter("@title", SqlDbType.NVarChar,100),
+ new SqlParameter("@gudingyf", SqlDbType.NVarChar,255),
+ new SqlParameter("@yuanmian", SqlDbType.NVarChar,255),
+ new SqlParameter("@yuanjifei", SqlDbType.NVarChar,255),
+ new SqlParameter("@jianmian", SqlDbType.NVarChar,255),
+ new SqlParameter("@jianjifei", SqlDbType.NVarChar,255),
+ new SqlParameter("@content", SqlDbType.NVarChar,255),
+ new SqlParameter("@paixu", SqlDbType.Int,10),
+ new SqlParameter("@state", SqlDbType.Int,10),
+ new SqlParameter("@add_time", SqlDbType.DateTime,23)};
+ parameters[0].Value = model.title;
+ parameters[1].Value = model.gudingyf;
+ parameters[2].Value = model.yuanmian;
+ parameters[3].Value = model.yuanjifei;
+ parameters[4].Value = model.jianmian;
+ parameters[5].Value = model.jianjifei;
+ parameters[6].Value = model.content;
+ parameters[7].Value = model.paixu;
+ parameters[8].Value = model.state;
+ parameters[9].Value = model.add_time;
+
+ object obj = DbHelperSQL.GetSingle(strSql.ToString(), parameters);
+ if (obj == null)
+ {
+ return 0;
+ }
+ else
+ {
+ return Convert.ToInt32(obj);
+ }
+ }
+
+ ///
+ /// 更新一条数据
+ ///
+ public bool Update(Basic.Model.freight model)
+ {
+ StringBuilder strSql = new StringBuilder();
+ strSql.Append("update tb_freight set ");
+ strSql.Append("title=@title,");
+ strSql.Append("gudingyf=@gudingyf,");
+ strSql.Append("yuanmian=@yuanmian,");
+ strSql.Append("yuanjifei=@yuanjifei,");
+ strSql.Append("jianmian=@jianmian,");
+ strSql.Append("jianjifei=@jianjifei,");
+ strSql.Append("content=@content,");
+ strSql.Append("paixu=@paixu,");
+ strSql.Append("state=@state,");
+ strSql.Append("add_time=@add_time");
+ strSql.Append(" where id=@id");
+ SqlParameter[] parameters = {
+ new SqlParameter("@title", SqlDbType.NVarChar,100),
+ new SqlParameter("@gudingyf", SqlDbType.NVarChar,255),
+ new SqlParameter("@yuanmian", SqlDbType.NVarChar,255),
+ new SqlParameter("@yuanjifei", SqlDbType.NVarChar,255),
+ new SqlParameter("@jianmian", SqlDbType.NVarChar,255),
+ new SqlParameter("@jianjifei", SqlDbType.NVarChar,255),
+ new SqlParameter("@content", SqlDbType.NVarChar,255),
+ new SqlParameter("@paixu", SqlDbType.Int,10),
+ new SqlParameter("@state", SqlDbType.Int,10),
+ new SqlParameter("@add_time", SqlDbType.DateTime,23),
+ new SqlParameter("@id", SqlDbType.Int,4)};
+ parameters[0].Value = model.title;
+ parameters[1].Value = model.gudingyf;
+ parameters[2].Value = model.yuanmian;
+ parameters[3].Value = model.yuanjifei;
+ parameters[4].Value = model.jianmian;
+ parameters[5].Value = model.jianjifei;
+ parameters[6].Value = model.content;
+ parameters[7].Value = model.paixu;
+ parameters[8].Value = model.state;
+ parameters[9].Value = model.add_time;
+ parameters[10].Value = model.id;
+ int rows = DbHelperSQL.ExecuteSql(strSql.ToString(), parameters);
+ if (rows > 0)
+ {
+ return true;
+ }
+ else
+ {
+ return false;
+ }
+ }
+
+ ///
+ /// 删除一条数据
+ ///
+ public bool Delete(int id)
+ {
+ StringBuilder strSql = new StringBuilder();
+ strSql.Append("delete from tb_freight");
+ strSql.Append(" where id=@id");
+ SqlParameter[] parameters = {
+ new SqlParameter("@id", SqlDbType.Int,4)};
+ parameters[0].Value = id;
+ int rows = DbHelperSQL.ExecuteSql(strSql.ToString(), parameters);
+ if (rows > 0)
+ {
+ return true;
+ }
+ else
+ {
+ return false;
+ }
+ }
+
+ ///
+ /// 得到一个对象实体
+ ///
+ public Basic.Model.freight GetModel(int id)
+ {
+ StringBuilder strSql=new StringBuilder();
+ strSql.Append("select top 1 id,title,gudingyf,yuanmian,yuanjifei,jianmian,jianjifei,content,paixu,state,add_time from tb_freight");
+ strSql.Append(" where id=@id");
+ SqlParameter[] parameters = {
+ new SqlParameter("@id", SqlDbType.Int,4)};
+ parameters[0].Value = id;
+ Basic.Model.freight model = new Basic.Model.freight();
+ DataSet ds = DbHelperSQL.Query(strSql.ToString(), parameters);
+ if (ds.Tables[0].Rows.Count > 0)
+ {
+ if (!string.IsNullOrEmpty(ds.Tables[0].Rows[0]["id"].ToString()))
+ {
+ model.id = int.Parse(ds.Tables[0].Rows[0]["id"].ToString());
+ }
+ if (!string.IsNullOrEmpty(ds.Tables[0].Rows[0]["title"].ToString()))
+ {
+ model.title = ds.Tables[0].Rows[0]["title"].ToString();
+ }
+ if (!string.IsNullOrEmpty(ds.Tables[0].Rows[0]["gudingyf"].ToString()))
+ {
+ model.gudingyf = ds.Tables[0].Rows[0]["gudingyf"].ToString();
+ }
+ if (!string.IsNullOrEmpty(ds.Tables[0].Rows[0]["yuanmian"].ToString()))
+ {
+ model.yuanmian = ds.Tables[0].Rows[0]["yuanmian"].ToString();
+ }
+ if (!string.IsNullOrEmpty(ds.Tables[0].Rows[0]["yuanjifei"].ToString()))
+ {
+ model.yuanjifei = ds.Tables[0].Rows[0]["yuanjifei"].ToString();
+ }
+ if (!string.IsNullOrEmpty(ds.Tables[0].Rows[0]["jianmian"].ToString()))
+ {
+ model.jianmian = ds.Tables[0].Rows[0]["jianmian"].ToString();
+ }
+ if (!string.IsNullOrEmpty(ds.Tables[0].Rows[0]["jianjifei"].ToString()))
+ {
+ model.jianjifei = ds.Tables[0].Rows[0]["jianjifei"].ToString();
+ }
+ if (!string.IsNullOrEmpty(ds.Tables[0].Rows[0]["content"].ToString()))
+ {
+ model.content = ds.Tables[0].Rows[0]["content"].ToString();
+ }
+ if (!string.IsNullOrEmpty(ds.Tables[0].Rows[0]["paixu"].ToString()))
+ {
+ model.paixu = int.Parse(ds.Tables[0].Rows[0]["paixu"].ToString());
+ }
+ if (!string.IsNullOrEmpty(ds.Tables[0].Rows[0]["state"].ToString()))
+ {
+ model.state = int.Parse(ds.Tables[0].Rows[0]["state"].ToString());
+ }
+ if (!string.IsNullOrEmpty(ds.Tables[0].Rows[0]["add_time"].ToString()))
+ {
+ model.add_time = DateTime.Parse(ds.Tables[0].Rows[0]["add_time"].ToString());
+ }
+ return model;
+ }
+ else
+ {
+ return null;
+ }
+ }
+
+ ///
+ /// 得到一个对象实体
+ ///
+ public Basic.Model.freight GetModelByState()
+ {
+ StringBuilder strSql=new StringBuilder();
+ strSql.Append("select top 1 id,title,gudingyf,yuanmian,yuanjifei,jianmian,jianjifei,content,paixu,state,add_time from tb_freight");
+ strSql.Append(" where state=@state");
+ SqlParameter[] parameters =
+ {
+ new SqlParameter("@state", SqlDbType.Int,4)};
+ parameters[0].Value = 0;
+ Basic.Model.freight model = new Basic.Model.freight();
+ DataSet ds = DbHelperSQL.Query(strSql.ToString(), parameters);
+ if (ds.Tables[0].Rows.Count > 0)
+ {
+ if (!string.IsNullOrEmpty(ds.Tables[0].Rows[0]["id"].ToString()))
+ {
+ model.id = int.Parse(ds.Tables[0].Rows[0]["id"].ToString());
+ }
+ if (!string.IsNullOrEmpty(ds.Tables[0].Rows[0]["title"].ToString()))
+ {
+ model.title = ds.Tables[0].Rows[0]["title"].ToString();
+ }
+ if (!string.IsNullOrEmpty(ds.Tables[0].Rows[0]["gudingyf"].ToString()))
+ {
+ model.gudingyf = ds.Tables[0].Rows[0]["gudingyf"].ToString();
+ }
+ if (!string.IsNullOrEmpty(ds.Tables[0].Rows[0]["yuanmian"].ToString()))
+ {
+ model.yuanmian = ds.Tables[0].Rows[0]["yuanmian"].ToString();
+ }
+ if (!string.IsNullOrEmpty(ds.Tables[0].Rows[0]["yuanjifei"].ToString()))
+ {
+ model.yuanjifei = ds.Tables[0].Rows[0]["yuanjifei"].ToString();
+ }
+ if (!string.IsNullOrEmpty(ds.Tables[0].Rows[0]["jianmian"].ToString()))
+ {
+ model.jianmian = ds.Tables[0].Rows[0]["jianmian"].ToString();
+ }
+ if (!string.IsNullOrEmpty(ds.Tables[0].Rows[0]["jianjifei"].ToString()))
+ {
+ model.jianjifei = ds.Tables[0].Rows[0]["jianjifei"].ToString();
+ }
+ if (!string.IsNullOrEmpty(ds.Tables[0].Rows[0]["content"].ToString()))
+ {
+ model.content = ds.Tables[0].Rows[0]["content"].ToString();
+ }
+ if (!string.IsNullOrEmpty(ds.Tables[0].Rows[0]["paixu"].ToString()))
+ {
+ model.paixu = int.Parse(ds.Tables[0].Rows[0]["paixu"].ToString());
+ }
+ if (!string.IsNullOrEmpty(ds.Tables[0].Rows[0]["state"].ToString()))
+ {
+ model.state = int.Parse(ds.Tables[0].Rows[0]["state"].ToString());
+ }
+ if (!string.IsNullOrEmpty(ds.Tables[0].Rows[0]["add_time"].ToString()))
+ {
+ model.add_time = DateTime.Parse(ds.Tables[0].Rows[0]["add_time"].ToString());
+ }
+ return model;
+ }
+ else
+ {
+ return null;
+ }
+ }
+
+ ///
+ /// 获得前几行数据
+ ///
+ public DataSet GetList(int Top, string strWhere, string filedOrder)
+ {
+ StringBuilder strSql = new StringBuilder();
+ strSql.Append("select ");
+ if (Top > 0)
+ {
+ strSql.Append(" top " + Top.ToString());
+ }
+ strSql.Append("id,title,gudingyf,yuanmian,yuanjifei,jianmian,jianjifei,content,paixu,state,add_time");
+ strSql.Append(" from tb_freight");
+ if (strWhere.Trim() != "")
+ {
+ strSql.Append(" where " + strWhere);
+ }
+ strSql.Append(" order by " + filedOrder);
+ return DbHelperSQL.Query(strSql.ToString());
+ }
+
+
+ ///
+ /// 获得查询分页数据
+ ///
+ public DataSet GetList(string _strWhere, string _orderby, int _pageSize, int _page, out int recordCount)
+ {
+ BasicPage bp = new BasicPage();
+ StringBuilder str_Sql = new StringBuilder();
+ str_Sql.Append("select top " + _pageSize + " id,title,gudingyf,yuanmian,yuanjifei,jianmian,jianjifei,content,paixu,state,add_time from tb_freight");
+ str_Sql.Append(" where ");
+ str_Sql.Append(_strWhere);
+ str_Sql.Append(" and id not in ");
+ str_Sql.Append(" ( ");
+ str_Sql.Append(" select top " + (_page - 1) * _pageSize + " id from tb_freight ");
+ str_Sql.Append(" where ");
+ str_Sql.Append(_strWhere);
+ str_Sql.Append(" order by ");
+ str_Sql.Append(_orderby);
+ str_Sql.Append(" ) ");
+ str_Sql.Append(" order by ");
+ str_Sql.Append(_orderby);
+ DataSet dst = bp.SelectDataBase("tb_freight", str_Sql.ToString());
+ //
+ recordCount = totlePage(showTotal(_strWhere), _pageSize);
+ return dst;
+ }
+
+ //总页数
+ public int totlePage(int Total, int PageSize)
+ {
+ if (Total % PageSize == 0)
+ {
+ return Total / PageSize;
+ }
+ else
+ {
+ return Total / PageSize + 1;
+ }
+ }
+
+ //总条数
+ protected int showTotal(string strSql)
+ {
+ BasicPage bp = new BasicPage();
+ int intTotal = 0;
+ SqlDataReader myread = bp.getRead("select count(id) as CountId from tb_freight where " + strSql);
+ if (myread.Read())
+ {
+ intTotal = Convert.ToInt32(myread["CountId"].ToString());
+ }
+ myread.Close();
+ return intTotal;
+ }
+
+ ///
+ /// 是否存在该记录
+ ///
+ public bool Exists(int id)
+ {
+ StringBuilder strSql = new StringBuilder();
+ strSql.Append("select count(1) from tb_freight");
+ strSql.Append(" where id=@id");
+ SqlParameter[] parameters = {
+ new SqlParameter("@id", SqlDbType.Int,4)};
+ parameters[0].Value = id;
+
+ return DbHelperSQL.Exists(strSql.ToString(), parameters);
+ }
+
+ ///
+ /// 修改一列数据
+ ///
+ public void UpdateField(int id, string strValue)
+ {
+ StringBuilder strSql = new StringBuilder();
+ strSql.Append("update tb_freight set " + strValue);
+ strSql.Append(" where id=" + id);
+ DbHelperSQL.ExecuteSql(strSql.ToString());
+ }
+
+ #endregion
+ }
+}
+
diff --git a/App.code/DAL/link.cs b/App.code/DAL/link.cs
new file mode 100644
index 0000000..2164ce9
--- /dev/null
+++ b/App.code/DAL/link.cs
@@ -0,0 +1,201 @@
+using System;
+using System.Data;
+using System.Text;
+using System.Data.SqlClient;
+
+namespace Basic.DAL
+{
+ ///
+ /// 友情链接
+ ///
+ public partial class link
+ {
+ ///
+ /// 增加一条数据
+ ///
+ public int Add(Basic.Model.link model)
+ {
+ StringBuilder strSql = new StringBuilder();
+ strSql.Append("insert into tb_link(");
+ strSql.Append("paixu,title,class_id,path,url,target,state,remark,add_time)");
+ strSql.Append(" values (");
+ strSql.Append("@paixu,@title,@class_id,@path,@url,@target,@state,@remark,@add_time)");
+ strSql.Append(";select @@IDENTITY");
+
+ SqlParameter[] parameters = {
+ new SqlParameter("@paixu", SqlDbType.Int,10),
+ new SqlParameter("@title", SqlDbType.NVarChar,255),
+ new SqlParameter("@class_id", SqlDbType.Int,10),
+ new SqlParameter("@path", SqlDbType.NVarChar,255),
+ new SqlParameter("@url", SqlDbType.NVarChar,255),
+ new SqlParameter("@target", SqlDbType.Int,10),
+ new SqlParameter("@state", SqlDbType.Int,10),
+ new SqlParameter("@remark", SqlDbType.NVarChar,500),
+ new SqlParameter("@add_time", SqlDbType.DateTime,23)};
+ parameters[0].Value = model.paixu;
+ parameters[1].Value = model.title;
+ parameters[2].Value = model.class_id;
+ parameters[3].Value = model.path;
+ parameters[4].Value = model.url;
+ parameters[5].Value = model.target;
+ parameters[6].Value = model.state;
+ parameters[7].Value = model.remark;
+ parameters[8].Value = model.add_time;
+
+ object obj = DbHelperSQL.GetSingle(strSql.ToString(), parameters);
+ if (obj == null)
+ {
+ return 0;
+ }
+ else
+ {
+ return Convert.ToInt32(obj);
+ }
+ }
+
+ ///
+ /// 更新一条数据
+ ///
+ public bool Update(Basic.Model.link model)
+ {
+ StringBuilder strSql = new StringBuilder();
+ strSql.Append("update tb_link set ");
+ strSql.Append("paixu=@paixu,");
+ strSql.Append("title=@title,");
+ strSql.Append("class_id=@class_id,");
+ strSql.Append("path=@path,");
+ strSql.Append("url=@url,");
+ strSql.Append("target=@target,");
+ strSql.Append("state=@state,");
+ strSql.Append("remark=@remark,");
+ strSql.Append("add_time=@add_time");
+ strSql.Append(" where id=@id");
+ SqlParameter[] parameters = {
+ new SqlParameter("@paixu", SqlDbType.Int,10),
+ new SqlParameter("@title", SqlDbType.NVarChar,255),
+ new SqlParameter("@class_id", SqlDbType.Int,10),
+ new SqlParameter("@path", SqlDbType.NVarChar,255),
+ new SqlParameter("@url", SqlDbType.NVarChar,255),
+ new SqlParameter("@target", SqlDbType.Int,10),
+ new SqlParameter("@state", SqlDbType.Int,10),
+ new SqlParameter("@remark", SqlDbType.NVarChar,500),
+ new SqlParameter("@add_time", SqlDbType.DateTime,23),
+ new SqlParameter("@id", SqlDbType.Int,4)};
+ parameters[0].Value = model.paixu;
+ parameters[1].Value = model.title;
+ parameters[2].Value = model.class_id;
+ parameters[3].Value = model.path;
+ parameters[4].Value = model.url;
+ parameters[5].Value = model.target;
+ parameters[6].Value = model.state;
+ parameters[7].Value = model.remark;
+ parameters[8].Value = model.add_time;
+ parameters[9].Value = model.id;
+ int rows = DbHelperSQL.ExecuteSql(strSql.ToString(), parameters);
+ if (rows > 0)
+ {
+ return true;
+ }
+ else
+ {
+ return false;
+ }
+ }
+
+ ///
+ /// 删除一条数据
+ ///
+ public bool Delete(int id)
+ {
+ StringBuilder strSql = new StringBuilder();
+ strSql.Append("delete from tb_link");
+ strSql.Append(" where id=@id");
+ SqlParameter[] parameters = {
+ new SqlParameter("@id", SqlDbType.Int,4)};
+ parameters[0].Value = id;
+ int rows = DbHelperSQL.ExecuteSql(strSql.ToString(), parameters);
+ if (rows > 0)
+ {
+ return true;
+ }
+ else
+ {
+ return false;
+ }
+ }
+
+ ///
+ /// 得到一个对象实体
+ ///
+ public Basic.Model.link GetModel(int id)
+ {
+ StringBuilder strSql = new StringBuilder();
+ strSql.Append("select top 1 id,paixu,title,class_id,path,url,target,state,remark,add_time from tb_link");
+ strSql.Append(" where id=@id");
+ SqlParameter[] parameters = {
+ new SqlParameter("@id", SqlDbType.Int,4)};
+ parameters[0].Value = id;
+ Basic.Model.link model = new Basic.Model.link();
+ DataSet ds = DbHelperSQL.Query(strSql.ToString(), parameters);
+ if (ds.Tables[0].Rows.Count > 0)
+ {
+ if (!string.IsNullOrEmpty(ds.Tables[0].Rows[0]["id"].ToString()))
+ {
+ model.id = int.Parse(ds.Tables[0].Rows[0]["id"].ToString());
+ }
+ if (!string.IsNullOrEmpty(ds.Tables[0].Rows[0]["paixu"].ToString()))
+ {
+ model.paixu = int.Parse(ds.Tables[0].Rows[0]["paixu"].ToString());
+ }
+ if (!string.IsNullOrEmpty(ds.Tables[0].Rows[0]["title"].ToString()))
+ {
+ model.title = ds.Tables[0].Rows[0]["title"].ToString();
+ }
+ if (!string.IsNullOrEmpty(ds.Tables[0].Rows[0]["class_id"].ToString()))
+ {
+ model.class_id = int.Parse(ds.Tables[0].Rows[0]["class_id"].ToString());
+ }
+ if (!string.IsNullOrEmpty(ds.Tables[0].Rows[0]["path"].ToString()))
+ {
+ model.path = ds.Tables[0].Rows[0]["path"].ToString();
+ }
+ if (!string.IsNullOrEmpty(ds.Tables[0].Rows[0]["url"].ToString()))
+ {
+ model.url = ds.Tables[0].Rows[0]["url"].ToString();
+ }
+ if (!string.IsNullOrEmpty(ds.Tables[0].Rows[0]["target"].ToString()))
+ {
+ model.target = int.Parse(ds.Tables[0].Rows[0]["target"].ToString());
+ }
+ if (!string.IsNullOrEmpty(ds.Tables[0].Rows[0]["state"].ToString()))
+ {
+ model.state = int.Parse(ds.Tables[0].Rows[0]["state"].ToString());
+ }
+ if (!string.IsNullOrEmpty(ds.Tables[0].Rows[0]["remark"].ToString()))
+ {
+ model.remark = ds.Tables[0].Rows[0]["remark"].ToString();
+ }
+ if (!string.IsNullOrEmpty(ds.Tables[0].Rows[0]["add_time"].ToString()))
+ {
+ model.add_time = DateTime.Parse(ds.Tables[0].Rows[0]["add_time"].ToString());
+ }
+ return model;
+ }
+ else
+ {
+ return null;
+ }
+ }
+ ///
+ /// 修改一列数据
+ ///
+ public void UpdateField(int id, string strValue)
+ {
+ StringBuilder strSql = new StringBuilder();
+ strSql.Append("update tb_link set " + strValue);
+ strSql.Append(" where id=" + id);
+ DbHelperSQL.ExecuteSql(strSql.ToString());
+ }
+ }
+}
+
diff --git a/App.code/DAL/manager.cs b/App.code/DAL/manager.cs
new file mode 100644
index 0000000..f49ceda
--- /dev/null
+++ b/App.code/DAL/manager.cs
@@ -0,0 +1,388 @@
+锘縰sing System;
+using System.Collections.Generic;
+using System.Data;
+using System.Text;
+using System.Data.SqlClient;
+
+///
+/// 绠$悊鍛
+///
+namespace Basic.DAL
+{
+ public class manager
+ {
+
+ ///
+ /// 鑾峰緱鏌ヨ鍒嗛〉鏁版嵁
+ ///
+ public DataSet GetList(int pageSize, int pageIndex, string strWhere, string filedOrder, out int recordCount)
+ {
+ StringBuilder strSql = new StringBuilder();
+ strSql.Append("select * from tb_manager");
+ if (strWhere.Trim() != "")
+ {
+ strSql.Append(" where " + strWhere);
+ }
+ recordCount = Convert.ToInt32(DbHelperSQL.GetSingle(PagingHelper.CreateCountingSql(strSql.ToString())));
+ return DbHelperSQL.Query(PagingHelper.CreatePagingSql(recordCount, pageSize, pageIndex, strSql.ToString(), filedOrder));
+ }
+
+ ///
+ /// 澧炲姞涓鏉℃暟鎹
+ ///
+ public int Add(Model.manager model)
+ {
+ StringBuilder strSql = new StringBuilder();
+ strSql.Append("insert into tb_manager(");
+ strSql.Append("role_id,role_type,shop_id,user_name,user_pwd,real_name,telephone,email,is_lock,add_time)");
+ strSql.Append(" values (");
+ strSql.Append("@role_id,@role_type,@shop_id,@user_name,@user_pwd,@real_name,@telephone,@email,@is_lock,@add_time)");
+ strSql.Append(";select @@IDENTITY");
+
+ SqlParameter[] parameters = {
+ new SqlParameter("@role_id", SqlDbType.Int,10),
+ new SqlParameter("@role_type", SqlDbType.Int,10),
+ new SqlParameter("@shop_id", SqlDbType.Int,10),
+ new SqlParameter("@user_name", SqlDbType.NVarChar,100),
+ new SqlParameter("@user_pwd", SqlDbType.NVarChar,100),
+ new SqlParameter("@real_name", SqlDbType.NVarChar,50),
+ new SqlParameter("@telephone", SqlDbType.NVarChar,30),
+ new SqlParameter("@email", SqlDbType.NVarChar,30),
+ new SqlParameter("@is_lock", SqlDbType.Int,10),
+ new SqlParameter("@add_time", SqlDbType.DateTime,23)};
+ parameters[0].Value = model.role_id;
+ parameters[1].Value = model.role_type;
+ parameters[2].Value = model.shop_id;
+ parameters[3].Value = model.user_name;
+ parameters[4].Value = model.user_pwd;
+ parameters[5].Value = model.real_name;
+ parameters[6].Value = model.telephone;
+ parameters[7].Value = model.email;
+ parameters[8].Value = model.is_lock;
+ parameters[9].Value = model.add_time;
+
+ object obj = DbHelperSQL.GetSingle(strSql.ToString(), parameters);
+ if (obj == null)
+ {
+ return 0;
+ }
+ else
+ {
+ return Convert.ToInt32(obj);
+ }
+ }
+
+ ///
+ /// 寰楀埌涓涓璞″疄浣
+ ///
+ public Model.manager GetModel(int id)
+ {
+ StringBuilder strSql = new StringBuilder();
+ strSql.Append("select top 1 id,role_id,role_type,shop_id,user_name,user_pwd,real_name,telephone,email,is_lock,add_time from tb_manager");
+ strSql.Append(" where id=@id");
+ SqlParameter[] parameters = {
+ new SqlParameter("@id", SqlDbType.Int,4)};
+ parameters[0].Value = id;
+ Model.manager model = new Model.manager();
+ DataSet ds = DbHelperSQL.Query(strSql.ToString(), parameters);
+ if (ds.Tables[0].Rows.Count > 0)
+ {
+ if (!string.IsNullOrEmpty(ds.Tables[0].Rows[0]["id"].ToString()))
+ {
+ model.id = int.Parse(ds.Tables[0].Rows[0]["id"].ToString());
+ }
+ if (!string.IsNullOrEmpty(ds.Tables[0].Rows[0]["role_id"].ToString()))
+ {
+ model.role_id = int.Parse(ds.Tables[0].Rows[0]["role_id"].ToString());
+ }
+ if (!string.IsNullOrEmpty(ds.Tables[0].Rows[0]["role_type"].ToString()))
+ {
+ model.role_type = int.Parse(ds.Tables[0].Rows[0]["role_type"].ToString());
+ }
+ if (!string.IsNullOrEmpty(ds.Tables[0].Rows[0]["shop_id"].ToString()))
+ {
+ model.shop_id = int.Parse(ds.Tables[0].Rows[0]["shop_id"].ToString());
+ }
+ if (!string.IsNullOrEmpty(ds.Tables[0].Rows[0]["user_name"].ToString()))
+ {
+ model.user_name = ds.Tables[0].Rows[0]["user_name"].ToString();
+ }
+ if (!string.IsNullOrEmpty(ds.Tables[0].Rows[0]["user_pwd"].ToString()))
+ {
+ model.user_pwd = ds.Tables[0].Rows[0]["user_pwd"].ToString();
+ }
+ if (!string.IsNullOrEmpty(ds.Tables[0].Rows[0]["real_name"].ToString()))
+ {
+ model.real_name = ds.Tables[0].Rows[0]["real_name"].ToString();
+ }
+ if (!string.IsNullOrEmpty(ds.Tables[0].Rows[0]["telephone"].ToString()))
+ {
+ model.telephone = ds.Tables[0].Rows[0]["telephone"].ToString();
+ }
+ if (!string.IsNullOrEmpty(ds.Tables[0].Rows[0]["email"].ToString()))
+ {
+ model.email = ds.Tables[0].Rows[0]["email"].ToString();
+ }
+ if (!string.IsNullOrEmpty(ds.Tables[0].Rows[0]["is_lock"].ToString()))
+ {
+ model.is_lock = int.Parse(ds.Tables[0].Rows[0]["is_lock"].ToString());
+ }
+ if (!string.IsNullOrEmpty(ds.Tables[0].Rows[0]["add_time"].ToString()))
+ {
+ model.add_time = DateTime.Parse(ds.Tables[0].Rows[0]["add_time"].ToString());
+ }
+ return model;
+ }
+ else
+ {
+ return null;
+ }
+ }
+
+ ///
+ /// 鏄惁瀛樺湪璇ヨ褰
+ ///
+ public bool Exists(int id)
+ {
+ StringBuilder strSql = new StringBuilder();
+ strSql.Append("select count(1) from tb_manager");
+ strSql.Append(" where id=@id ");
+ SqlParameter[] parameters = {
+ new SqlParameter("@id", SqlDbType.Int,4)};
+ parameters[0].Value = id;
+ return DbHelperSQL.Exists(strSql.ToString(), parameters);
+ }
+
+ ///
+ /// 鏇存柊涓鏉℃暟鎹
+ ///
+ public bool Update(Model.manager model)
+ {
+ StringBuilder strSql = new StringBuilder();
+ strSql.Append("update tb_manager set ");
+ strSql.Append("role_id=@role_id,");
+ strSql.Append("role_type=@role_type,");
+ strSql.Append("shop_id=@shop_id,");
+ strSql.Append("user_name=@user_name,");
+ strSql.Append("user_pwd=@user_pwd,");
+ strSql.Append("real_name=@real_name,");
+ strSql.Append("telephone=@telephone,");
+ strSql.Append("email=@email,");
+ strSql.Append("is_lock=@is_lock,");
+ strSql.Append("add_time=@add_time");
+ strSql.Append(" where id=@id");
+ SqlParameter[] parameters = {
+ new SqlParameter("@role_id", SqlDbType.Int,10),
+ new SqlParameter("@role_type", SqlDbType.Int,10),
+ new SqlParameter("@shop_id", SqlDbType.Int,10),
+ new SqlParameter("@user_name", SqlDbType.NVarChar,100),
+ new SqlParameter("@user_pwd", SqlDbType.NVarChar,100),
+ new SqlParameter("@real_name", SqlDbType.NVarChar,50),
+ new SqlParameter("@telephone", SqlDbType.NVarChar,30),
+ new SqlParameter("@email", SqlDbType.NVarChar,30),
+ new SqlParameter("@is_lock", SqlDbType.Int,10),
+ new SqlParameter("@add_time", SqlDbType.DateTime,23),
+ new SqlParameter("@id", SqlDbType.Int,4)};
+ parameters[0].Value = model.role_id;
+ parameters[1].Value = model.role_type;
+ parameters[2].Value = model.shop_id;
+ parameters[3].Value = model.user_name;
+ parameters[4].Value = model.user_pwd;
+ parameters[5].Value = model.real_name;
+ parameters[6].Value = model.telephone;
+ parameters[7].Value = model.email;
+ parameters[8].Value = model.is_lock;
+ parameters[9].Value = model.add_time;
+ parameters[10].Value = model.id;
+ int rows = DbHelperSQL.ExecuteSql(strSql.ToString(), parameters);
+ if (rows > 0)
+ {
+ return true;
+ }
+ else
+ {
+ return false;
+ }
+ }
+
+ ///
+ /// 鍒犻櫎涓鏉℃暟鎹
+ ///
+ public bool Delete(int id)
+ {
+ List sqllist = new List();
+
+ StringBuilder strSql = new StringBuilder();
+ strSql.Append("delete from tb_manager_log ");
+ strSql.Append(" where user_id=@id");
+ SqlParameter[] parameters = {
+ new SqlParameter("@id", SqlDbType.Int,4)};
+ parameters[0].Value = id;
+ CommandInfo cmd = new CommandInfo(strSql.ToString(), parameters);
+ sqllist.Add(cmd);
+
+ StringBuilder strSql1 = new StringBuilder();
+ strSql1.Append("delete from tb_manager ");
+ strSql1.Append(" where id=@id");
+ SqlParameter[] parameters1 = {
+ new SqlParameter("@id", SqlDbType.Int,4)};
+ parameters1[0].Value = id;
+ cmd = new CommandInfo(strSql1.ToString(), parameters1);
+ sqllist.Add(cmd);
+
+ int rowsAffected = DbHelperSQL.ExecuteSqlTran(sqllist);
+ if (rowsAffected > 0)
+ {
+ return true;
+ }
+ else
+ {
+ return false;
+ }
+ }
+
+ ///
+ /// 鏍规嵁鐢ㄦ埛鍚嶅瘑鐮佽繑鍥炰竴涓疄浣
+ ///
+ public Model.manager GetModel(string user_name, string user_pwd)
+ {
+ StringBuilder strSql = new StringBuilder();
+ strSql.Append("select id from tb_manager");
+ strSql.Append(" where user_name=@user_name and user_pwd=@user_pwd and is_lock=0");
+ SqlParameter[] parameters = {
+ new SqlParameter("@user_name", SqlDbType.NVarChar,100),
+ new SqlParameter("@user_pwd", SqlDbType.NVarChar,100)};
+ parameters[0].Value = user_name;
+ parameters[1].Value = user_pwd;
+
+ object obj = DbHelperSQL.GetSingle(strSql.ToString(), parameters);
+ if (obj != null)
+ {
+ return GetModel(Convert.ToInt32(obj));
+ }
+ return null;
+ }
+
+ ///
+ /// 寰楀埌涓涓璞″疄浣
+ ///
+ public Model.manager GetModel(string username)
+ {
+ StringBuilder strSql = new StringBuilder();
+ strSql.Append("select top 1 id,role_id,role_type,shop_id,user_name,user_pwd,real_name,telephone,email,is_lock,add_time from tb_manager");
+ strSql.Append(" where user_name=@user_name");
+ SqlParameter[] parameters = {
+ new SqlParameter("@user_name", SqlDbType.NVarChar,255)};
+ parameters[0].Value = username;
+ Model.manager model = new Model.manager();
+ DataSet ds = DbHelperSQL.Query(strSql.ToString(), parameters);
+ if (ds.Tables[0].Rows.Count > 0)
+ {
+ if (!string.IsNullOrEmpty(ds.Tables[0].Rows[0]["id"].ToString()))
+ {
+ model.id = int.Parse(ds.Tables[0].Rows[0]["id"].ToString());
+ }
+ if (!string.IsNullOrEmpty(ds.Tables[0].Rows[0]["role_id"].ToString()))
+ {
+ model.role_id = int.Parse(ds.Tables[0].Rows[0]["role_id"].ToString());
+ }
+ if (!string.IsNullOrEmpty(ds.Tables[0].Rows[0]["role_type"].ToString()))
+ {
+ model.role_type = int.Parse(ds.Tables[0].Rows[0]["role_type"].ToString());
+ }
+ if (!string.IsNullOrEmpty(ds.Tables[0].Rows[0]["shop_id"].ToString()))
+ {
+ model.shop_id = int.Parse(ds.Tables[0].Rows[0]["shop_id"].ToString());
+ }
+ if (!string.IsNullOrEmpty(ds.Tables[0].Rows[0]["user_name"].ToString()))
+ {
+ model.user_name = ds.Tables[0].Rows[0]["user_name"].ToString();
+ }
+ if (!string.IsNullOrEmpty(ds.Tables[0].Rows[0]["user_pwd"].ToString()))
+ {
+ model.user_pwd = ds.Tables[0].Rows[0]["user_pwd"].ToString();
+ }
+ if (!string.IsNullOrEmpty(ds.Tables[0].Rows[0]["real_name"].ToString()))
+ {
+ model.real_name = ds.Tables[0].Rows[0]["real_name"].ToString();
+ }
+ if (!string.IsNullOrEmpty(ds.Tables[0].Rows[0]["telephone"].ToString()))
+ {
+ model.telephone = ds.Tables[0].Rows[0]["telephone"].ToString();
+ }
+ if (!string.IsNullOrEmpty(ds.Tables[0].Rows[0]["email"].ToString()))
+ {
+ model.email = ds.Tables[0].Rows[0]["email"].ToString();
+ }
+ if (!string.IsNullOrEmpty(ds.Tables[0].Rows[0]["is_lock"].ToString()))
+ {
+ model.is_lock = int.Parse(ds.Tables[0].Rows[0]["is_lock"].ToString());
+ }
+ if (!string.IsNullOrEmpty(ds.Tables[0].Rows[0]["add_time"].ToString()))
+ {
+ model.add_time = DateTime.Parse(ds.Tables[0].Rows[0]["add_time"].ToString());
+ }
+ return model;
+ }
+ else
+ {
+ return null;
+ }
+ }
+
+ #region
+ ///
+ /// 鑾峰緱鏌ヨ鍒嗛〉鏁版嵁
+ ///
+ public DataSet GetList(string _strWhere, string _orderby, int _pageSize, int _page, out int recordCount)
+ {
+ BasicPage bp = new BasicPage();
+ StringBuilder str_Sql = new StringBuilder();
+ str_Sql.Append("select top " + _pageSize + " id,user_name,role_id,real_name,shop_id,telephone,email,add_time,is_lock from tb_manager");
+ str_Sql.Append(" where ");
+ str_Sql.Append(_strWhere);
+ str_Sql.Append(" and id not in ");
+ str_Sql.Append(" ( ");
+ str_Sql.Append(" select top " + (_page - 1) * _pageSize + " id from tb_manager ");
+ str_Sql.Append(" where ");
+ str_Sql.Append(_strWhere);
+ str_Sql.Append(" order by ");
+ str_Sql.Append(_orderby);
+ str_Sql.Append(" ) ");
+ str_Sql.Append(" order by ");
+ str_Sql.Append(_orderby);
+ DataSet dst = bp.SelectDataBase("tb_manager", str_Sql.ToString());
+ //
+ recordCount = totlePage(showTotal(_strWhere), _pageSize);
+ return dst;
+ }
+
+ //鎬婚〉鏁
+ public int totlePage(int Total, int PageSize)
+ {
+ if (Total % PageSize == 0)
+ {
+ return Total / PageSize;
+ }
+ else
+ {
+ return Total / PageSize + 1;
+ }
+ }
+
+ //鎬绘潯鏁
+ protected int showTotal(string strSql)
+ {
+ BasicPage bp = new BasicPage();
+ int intTotal = 0;
+ SqlDataReader myread = bp.getRead("select count(id) as CountId from tb_manager where " + strSql);
+ if (myread.Read())
+ {
+ intTotal = Convert.ToInt32(myread["CountId"].ToString());
+ }
+ myread.Close();
+ return intTotal;
+ }
+ #endregion
+ }
+}
\ No newline at end of file
diff --git a/App.code/DAL/manager_log.cs b/App.code/DAL/manager_log.cs
new file mode 100644
index 0000000..8f181f5
--- /dev/null
+++ b/App.code/DAL/manager_log.cs
@@ -0,0 +1,225 @@
+锘縰sing System;
+using System.Collections.Generic;
+using System.Web;
+using System.Data;
+using System.Data.SqlClient;
+using System.Text;
+
+///
+/// 鐧诲綍鏃ュ織
+///
+namespace Basic.DAL
+{
+ public class manager_log
+ {
+ ///
+ /// 澧炲姞涓鏉℃暟鎹
+ ///
+ public int Add(Model.manager_log model)
+ {
+ StringBuilder strSql = new StringBuilder();
+ strSql.Append("insert into tb_manager_log(");
+ strSql.Append("user_id,user_name,action_type,note,login_ip,login_time)");
+ strSql.Append(" values (");
+ strSql.Append("@user_id,@user_name,@action_type,@note,@login_ip,@login_time)");
+ strSql.Append(";select @@IDENTITY");
+
+ SqlParameter user_id = new SqlParameter("@user_id", model.user_id);
+ SqlParameter user_name = new SqlParameter("@user_name", model.user_name);
+ SqlParameter action_type = new SqlParameter("@action_type", model.action_type);
+ SqlParameter note = new SqlParameter("@note", model.note);
+ SqlParameter login_ip = new SqlParameter("@login_ip", model.login_ip);
+ SqlParameter login_time = new SqlParameter("@login_time", model.login_time);
+
+ SqlParameter[] parameters = new SqlParameter[6]
+ {
+ user_id,user_name,action_type,note,login_ip,login_time
+ };
+ object obj = DbHelperSQL.GetSingle(strSql.ToString(), parameters);
+ if (obj == null)
+ {
+ return 0;
+ }
+ else
+ {
+ return Convert.ToInt32(obj);
+ }
+ }
+
+ ///
+ /// 鑾峰緱鏌ヨ鍒嗛〉鏁版嵁
+ ///
+ public DataSet GetList(int pageSize, int pageIndex, string strWhere, string filedOrder, out int recordCount)
+ {
+ StringBuilder strSql = new StringBuilder();
+ strSql.Append("select * FROM tb_manager_log");
+ if (strWhere.Trim() != "")
+ {
+ strSql.Append(" where " + strWhere);
+ }
+ recordCount = Convert.ToInt32(DbHelperSQL.GetSingle(PagingHelper.CreateCountingSql(strSql.ToString())));
+ return DbHelperSQL.Query(PagingHelper.CreatePagingSql(recordCount, pageSize, pageIndex, strSql.ToString(), filedOrder));
+ }
+
+ ///
+ /// 鍒犻櫎涓鏉℃暟鎹
+ ///
+ public bool Delete(int id)
+ {
+ StringBuilder strSql = new StringBuilder();
+ strSql.Append("delete from tb_manager_log ");
+ strSql.Append(" where id=@id");
+ SqlParameter[] parameters = {
+ new SqlParameter("@id", SqlDbType.Int,4)};
+ parameters[0].Value = id;
+
+ int rows = DbHelperSQL.ExecuteSql(strSql.ToString(), parameters);
+ if (rows > 0)
+ {
+ return true;
+ }
+ else
+ {
+ return false;
+ }
+ }
+
+ ///
+ /// 鏍规嵁鐢ㄦ埛鍚嶈繑鍥炰笂涓娆$櫥褰曡褰
+ ///
+ public Model.manager_log GetModel(string user_name, int top_num, string action_type)
+ {
+ int rows = GetCount("user_name='" + user_name + "'");
+ if (top_num == 1)
+ {
+ rows = 2;
+ }
+ if (rows > 1)
+ {
+ StringBuilder strSql = new StringBuilder();
+ strSql.Append("select top 1 id from (select top " + top_num + " id from tb_manager_log where user_name=@user_name and action_type=@action_type order by id desc) as T ");
+ strSql.Append(" order by id asc");
+ SqlParameter[] parameters = {
+ new SqlParameter("@user_name", SqlDbType.NVarChar,100),
+ new SqlParameter("@action_type", SqlDbType.NVarChar,100)};
+ parameters[0].Value = user_name;
+ parameters[1].Value = action_type;
+
+ object obj = DbHelperSQL.GetSingle(strSql.ToString(), parameters);
+ if (obj != null)
+ {
+ return GetModel(Convert.ToInt32(obj));
+ }
+ }
+ return null;
+ }
+
+ ///
+ /// 杩斿洖鏁版嵁鏁
+ ///
+ public int GetCount(string strWhere)
+ {
+ StringBuilder strSql = new StringBuilder();
+ strSql.Append("select count(*) as H ");
+ strSql.Append(" from tb_manager_log ");
+ if (strWhere.Trim() != "")
+ {
+ strSql.Append(" where " + strWhere);
+ }
+ return Convert.ToInt32(DbHelperSQL.GetSingle(strSql.ToString()));
+ }
+
+ ///
+ /// 寰楀埌涓涓璞″疄浣
+ ///
+ public Model.manager_log GetModel(int id)
+ {
+ StringBuilder strSql = new StringBuilder();
+ strSql.Append("select top 1 id,user_id,user_name,action_type,note,login_ip,login_time from tb_manager_log ");
+ strSql.Append(" where id=@id");
+ SqlParameter[] parameters = {
+ new SqlParameter("@id", SqlDbType.Int,4)};
+ parameters[0].Value = id;
+
+ Model.manager_log model = new Model.manager_log();
+ DataSet ds = DbHelperSQL.Query(strSql.ToString(), parameters);
+ if (ds.Tables[0].Rows.Count > 0)
+ {
+ if (ds.Tables[0].Rows[0]["id"].ToString() != "")
+ {
+ model.id = int.Parse(ds.Tables[0].Rows[0]["id"].ToString());
+ }
+ if (ds.Tables[0].Rows[0]["user_id"].ToString() != "")
+ {
+ model.user_id = int.Parse(ds.Tables[0].Rows[0]["user_id"].ToString());
+ }
+ model.user_name = ds.Tables[0].Rows[0]["user_name"].ToString();
+ model.action_type = ds.Tables[0].Rows[0]["action_type"].ToString();
+ model.note = ds.Tables[0].Rows[0]["note"].ToString();
+ model.login_ip = ds.Tables[0].Rows[0]["login_ip"].ToString();
+ if (ds.Tables[0].Rows[0]["login_time"].ToString() != "")
+ {
+ model.login_time = DateTime.Parse(ds.Tables[0].Rows[0]["login_time"].ToString());
+ }
+ return model;
+ }
+ else
+ {
+ return null;
+ }
+ }
+
+ ///
+ /// 鑾峰緱鏌ヨ鍒嗛〉鏁版嵁
+ ///
+ public DataSet GetList(string _strWhere, string _orderby, int _pageSize, int _page, out int recordCount)
+ {
+ BasicPage bp = new BasicPage();
+ StringBuilder str_Sql = new StringBuilder();
+ str_Sql.Append("select top " + _pageSize + " id,user_name,note,login_ip,login_time from tb_manager_log");
+ str_Sql.Append(" where ");
+ str_Sql.Append(_strWhere);
+ str_Sql.Append(" and id not in ");
+ str_Sql.Append(" ( ");
+ str_Sql.Append(" select top " + (_page - 1) * _pageSize + " id from tb_manager_log ");
+ str_Sql.Append(" where ");
+ str_Sql.Append(_strWhere);
+ str_Sql.Append(" order by ");
+ str_Sql.Append(_orderby);
+ str_Sql.Append(" ) ");
+ str_Sql.Append(" order by ");
+ str_Sql.Append(_orderby);
+ DataSet dst = bp.SelectDataBase("tb_manager_log", str_Sql.ToString());
+ //
+ recordCount = totlePage(showTotal(_strWhere), _pageSize);
+ return dst;
+ }
+
+ //鎬婚〉鏁
+ public int totlePage(int Total, int PageSize)
+ {
+ if (Total % PageSize == 0)
+ {
+ return Total / PageSize;
+ }
+ else
+ {
+ return Total / PageSize + 1;
+ }
+ }
+
+ //鎬绘潯鏁
+ protected int showTotal(string strSql)
+ {
+ BasicPage bp = new BasicPage();
+ int intTotal = 0;
+ SqlDataReader myread = bp.getRead("select count(id) as CountId from tb_manager_log where " + strSql);
+ if (myread.Read())
+ {
+ intTotal = Convert.ToInt32(myread["CountId"].ToString());
+ }
+ myread.Close();
+ return intTotal;
+ }
+ }
+}
\ No newline at end of file
diff --git a/App.code/DAL/manager_role.cs b/App.code/DAL/manager_role.cs
new file mode 100644
index 0000000..4dc4b1c
--- /dev/null
+++ b/App.code/DAL/manager_role.cs
@@ -0,0 +1,322 @@
+锘縰sing System;
+using System.Collections.Generic;
+using System.Data.SqlClient;
+using System.Web;
+using System.Data;
+using System.Text;
+
+///
+/// 绠$悊鍛 瑙掕壊
+///
+namespace Basic.DAL
+{
+ public class manager_role
+ {
+ ///
+ /// 鑾峰緱鏁版嵁鍒楄〃
+ ///
+ public DataSet GetList(string strWhere)
+ {
+ StringBuilder strSql = new StringBuilder();
+ strSql.Append("select id,role_name,role_type ");
+ strSql.Append(" from tb_manager_role ");
+ if (strWhere.Trim() != "")
+ {
+ strSql.Append(" where " + strWhere);
+ }
+ return DbHelperSQL.Query(strSql.ToString());
+ }
+
+ ///
+ /// 澧炲姞涓鏉℃暟鎹,鍙婂叾瀛愯〃鏁版嵁
+ ///
+ public int Add(Model.manager_role model)
+ {
+ StringBuilder strSql = new StringBuilder();
+ strSql.Append("insert into tb_manager_role(");
+ strSql.Append("role_name,role_type)");
+ strSql.Append(" values (");
+ strSql.Append("@role_name,@role_type)");
+ strSql.Append(";set @ReturnValue= @@IDENTITY");
+ SqlParameter[] parameters = {
+ new SqlParameter("@role_name", SqlDbType.NVarChar,100),
+ new SqlParameter("@role_type", SqlDbType.TinyInt,1),
+ new SqlParameter("@ReturnValue",SqlDbType.Int)};
+ parameters[0].Value = model.role_name;
+ parameters[1].Value = model.role_type;
+ parameters[2].Direction = ParameterDirection.Output;
+
+ List sqllist = new List();
+ CommandInfo cmd = new CommandInfo(strSql.ToString(), parameters);
+ sqllist.Add(cmd);
+ StringBuilder strSql2;
+ foreach (Model.manager_role_value models in model.manager_role_values)
+ {
+ strSql2 = new StringBuilder();
+ strSql2.Append("insert into tb_manager_role_value(");
+ strSql2.Append("role_id,channel_name,channel_id,action_type)");
+ strSql2.Append(" values (");
+ strSql2.Append("@role_id,@channel_name,@channel_id,@action_type)");
+ SqlParameter[] parameters2 = {
+ new SqlParameter("@role_id", SqlDbType.Int,4),
+ new SqlParameter("@channel_name", SqlDbType.NVarChar,255),
+ new SqlParameter("@channel_id", SqlDbType.Int,4),
+ new SqlParameter("@action_type", SqlDbType.NVarChar,100)};
+ parameters2[0].Direction = ParameterDirection.InputOutput;
+ parameters2[1].Value = models.channel_name;
+ parameters2[2].Value = models.channel_id;
+ parameters2[3].Value = models.action_type;
+
+ cmd = new CommandInfo(strSql2.ToString(), parameters2);
+ sqllist.Add(cmd);
+ }
+ DbHelperSQL.ExecuteSqlTranWithIndentity(sqllist);
+ return (int)parameters[2].Value;
+ }
+
+ ///
+ /// 鏄惁瀛樺湪璇ヨ褰
+ ///
+ public bool Exists(int id)
+ {
+ StringBuilder strSql = new StringBuilder();
+ strSql.Append("select count(1) from tb_manager_role");
+ strSql.Append(" where id=@id ");
+ SqlParameter[] parameters = {
+ new SqlParameter("@id", SqlDbType.Int,4)};
+ parameters[0].Value = id;
+ return DbHelperSQL.Exists(strSql.ToString(), parameters);
+ }
+
+ ///
+ /// 寰楀埌涓涓璞″疄浣
+ ///
+ public Model.manager_role GetModel(int id)
+ {
+ StringBuilder strSql = new StringBuilder();
+ strSql.Append("select id,role_name,role_type from tb_manager_role ");
+ strSql.Append(" where id=@id ");
+ SqlParameter[] parameters = {
+ new SqlParameter("@id", SqlDbType.Int,4)};
+ parameters[0].Value = id;
+
+ Model.manager_role model = new Model.manager_role();
+ DataSet ds = DbHelperSQL.Query(strSql.ToString(), parameters);
+ if (ds.Tables[0].Rows.Count > 0)
+ {
+ #region 鐖惰〃淇℃伅
+ if (ds.Tables[0].Rows[0]["id"].ToString() != "")
+ {
+ model.id = int.Parse(ds.Tables[0].Rows[0]["id"].ToString());
+ }
+ model.role_name = ds.Tables[0].Rows[0]["role_name"].ToString();
+ if (ds.Tables[0].Rows[0]["role_type"].ToString() != "")
+ {
+ model.role_type = int.Parse(ds.Tables[0].Rows[0]["role_type"].ToString());
+ }
+ #endregion 鐖惰〃淇℃伅end
+
+ #region 瀛愯〃淇℃伅
+ StringBuilder strSql2 = new StringBuilder();
+ strSql2.Append("select id,role_id,channel_name,channel_id,action_type from tb_manager_role_value ");
+ strSql2.Append(" where role_id=@role_id ");
+ SqlParameter[] parameters2 = {
+ new SqlParameter("@role_id", SqlDbType.Int,4)};
+ parameters2[0].Value = id;
+
+ DataSet ds2 = DbHelperSQL.Query(strSql2.ToString(), parameters2);
+ if (ds2.Tables[0].Rows.Count > 0)
+ {
+ #region 瀛愯〃瀛楁淇℃伅
+ int i = ds2.Tables[0].Rows.Count;
+ List models = new List();
+ Model.manager_role_value modelt;
+ for (int n = 0; n < i; n++)
+ {
+ modelt = new Model.manager_role_value();
+ if (ds2.Tables[0].Rows[n]["id"].ToString() != "")
+ {
+ modelt.id = int.Parse(ds2.Tables[0].Rows[n]["id"].ToString());
+ }
+ if (ds2.Tables[0].Rows[n]["role_id"].ToString() != "")
+ {
+ modelt.role_id = int.Parse(ds2.Tables[0].Rows[n]["role_id"].ToString());
+ }
+ modelt.channel_name = ds2.Tables[0].Rows[n]["channel_name"].ToString();
+ if (ds2.Tables[0].Rows[n]["channel_id"].ToString() != "")
+ {
+ modelt.channel_id = int.Parse(ds2.Tables[0].Rows[n]["channel_id"].ToString());
+ }
+ modelt.action_type = ds2.Tables[0].Rows[n]["action_type"].ToString();
+ models.Add(modelt);
+ }
+ model.manager_role_values = models;
+ #endregion 瀛愯〃瀛楁淇℃伅end
+ }
+ #endregion 瀛愯〃淇℃伅end
+
+ return model;
+ }
+ else
+ {
+ return null;
+ }
+ }
+
+ ///
+ /// 鏇存柊涓鏉℃暟鎹強鍏跺瓙琛
+ ///
+ public bool Update(Model.manager_role model)
+ {
+ StringBuilder strSql = new StringBuilder();
+ strSql.Append("update tb_manager_role set ");
+ strSql.Append("role_name=@role_name,");
+ strSql.Append("role_type=@role_type");
+ strSql.Append(" where id=@id ");
+ SqlParameter[] parameters = {
+ new SqlParameter("@id", SqlDbType.Int,4),
+ new SqlParameter("@role_name", SqlDbType.NVarChar,100),
+ new SqlParameter("@role_type", SqlDbType.TinyInt,1)};
+ parameters[0].Value = model.id;
+ parameters[1].Value = model.role_name;
+ parameters[2].Value = model.role_type;
+
+ List sqllist = new List();
+ CommandInfo cmd = new CommandInfo(strSql.ToString(), parameters);
+ sqllist.Add(cmd);
+
+ //鍒犻櫎鏉冮檺
+ StringBuilder strSql2 = new StringBuilder();
+ strSql2.Append("delete from tb_manager_role_value where role_id=@role_id ");
+ StringBuilder idList = new StringBuilder();
+ if (model.manager_role_values != null)
+ {
+ foreach (Model.manager_role_value models in model.manager_role_values)
+ {
+ if (models.id > 0)
+ {
+ idList.Append(models.id + ",");
+ }
+ }
+ string id_list = Basic.Tools.Utils.DelLastChar(idList.ToString(), ",");
+ if (!string.IsNullOrEmpty(id_list))
+ {
+ strSql2.Append(" and id not in(" + id_list + ")");
+ }
+ }
+ SqlParameter[] parameters2 = {
+ new SqlParameter("@role_id", SqlDbType.Int,4)};
+ parameters2[0].Value = model.id;
+
+ cmd = new CommandInfo(strSql2.ToString(), parameters2);
+ sqllist.Add(cmd);
+
+ //娣诲姞鏉冮檺
+ if (model.manager_role_values != null)
+ {
+ StringBuilder strSql3;
+ foreach (Model.manager_role_value models in model.manager_role_values)
+ {
+ strSql3 = new StringBuilder();
+ if (models.id == 0)
+ {
+ strSql3.Append("insert into tb_manager_role_value(");
+ strSql3.Append("role_id,channel_name,channel_id,action_type)");
+ strSql3.Append(" values (");
+ strSql3.Append("@role_id,@channel_name,@channel_id,@action_type)");
+ SqlParameter[] parameters3 = {
+ new SqlParameter("@role_id", SqlDbType.Int,4),
+ new SqlParameter("@channel_name", SqlDbType.NVarChar,255),
+ new SqlParameter("@channel_id", SqlDbType.Int,4),
+ new SqlParameter("@action_type", SqlDbType.NVarChar,100)};
+ parameters3[0].Value = model.id;
+ parameters3[1].Value = models.channel_name;
+ parameters3[2].Value = models.channel_id;
+ parameters3[3].Value = models.action_type;
+
+ cmd = new CommandInfo(strSql3.ToString(), parameters3);
+ sqllist.Add(cmd);
+ }
+ }
+ }
+
+ int rowsAffected = DbHelperSQL.ExecuteSqlTran(sqllist);
+ if (rowsAffected > 0)
+ {
+ return true;
+ }
+ else
+ {
+ return false;
+ }
+ }
+
+ ///
+ /// 杩斿洖瑙掕壊鍚嶇О
+ ///
+ public string GetTitle(int id)
+ {
+ StringBuilder strSql = new StringBuilder();
+ strSql.Append("select top 1 role_name from tb_manager_role");
+ strSql.Append(" where id=" + id);
+ string title = Convert.ToString(DbHelperSQL.GetSingle(strSql.ToString()));
+ if (string.IsNullOrEmpty(title))
+ {
+ return "";
+ }
+ return title;
+ }
+
+ ///
+ /// 鍒犻櫎涓鏉℃暟鎹紝鍙婂瓙琛ㄦ墍鏈夌浉鍏虫暟鎹
+ ///
+ public bool Delete(int id)
+ {
+ List sqllist = new List();
+ StringBuilder strSql = new StringBuilder();
+ strSql.Append("delete from tb_manager_role ");
+ strSql.Append(" where id=@id ");
+ SqlParameter[] parameters = {
+ new SqlParameter("@id", SqlDbType.Int,4)};
+ parameters[0].Value = id;
+
+ CommandInfo cmd = new CommandInfo(strSql.ToString(), parameters);
+ sqllist.Add(cmd);
+ StringBuilder strSql2 = new StringBuilder();
+ strSql2.Append("delete from tb_manager_role_value ");
+ strSql2.Append(" where role_id=@role_id ");
+ SqlParameter[] parameters2 = {
+ new SqlParameter("@role_id", SqlDbType.Int,4)};
+ parameters2[0].Value = id;
+
+ cmd = new CommandInfo(strSql2.ToString(), parameters2);
+ sqllist.Add(cmd);
+ int rowsAffected = DbHelperSQL.ExecuteSqlTran(sqllist);
+ if (rowsAffected > 0)
+ {
+ return true;
+ }
+ else
+ {
+ return false;
+ }
+ }
+
+ ///
+ /// 鑾峰彇Role_Type
+ ///
+ ///
+ public int GetRole_Type(int id)
+ {
+ int intRole_Type = 0;
+ BasicPage bp = new BasicPage();
+ SqlDataReader myread = bp.getRead("select * from tb_manager_role where id=" + id);
+ if (myread.Read())
+ {
+ intRole_Type = int.Parse(myread["role_type"].ToString());
+ }
+ myread.Close();
+ return intRole_Type;
+ }
+ }
+}
\ No newline at end of file
diff --git a/App.code/DAL/nav.cs b/App.code/DAL/nav.cs
new file mode 100644
index 0000000..13259ce
--- /dev/null
+++ b/App.code/DAL/nav.cs
@@ -0,0 +1,384 @@
+using System;
+using System.Data;
+using System.Text;
+using System.Data.SqlClient;
+
+namespace Basic.DAL
+{
+ ///
+ /// 数据访问层nav
+ ///
+ public partial class nav
+ {
+ ///
+ /// 增加一条数据
+ ///
+ public int Add(Basic.Model.nav model)
+ {
+ StringBuilder strSql = new StringBuilder();
+ strSql.Append("insert into tb_nav(");
+ strSql.Append("paixu,title,class_id,parent_id,class_list,class_layer,path,url,target,state,remark,seo_title,seo_keywords,seo_description,add_time)");
+ strSql.Append(" values (");
+ strSql.Append("@paixu,@title,@class_id,@parent_id,@class_list,@class_layer,@path,@url,@target,@state,@remark,@seo_title,@seo_keywords,@seo_description,@add_time)");
+ strSql.Append(";select @@IDENTITY");
+
+ SqlParameter[] parameters = {
+ new SqlParameter("@paixu", SqlDbType.Int,10),
+ new SqlParameter("@title", SqlDbType.NVarChar,255),
+ new SqlParameter("@class_id", SqlDbType.Int,10),
+ new SqlParameter("@parent_id", SqlDbType.Int,10),
+ new SqlParameter("@class_list", SqlDbType.NVarChar,500),
+ new SqlParameter("@class_layer", SqlDbType.Int,10),
+ new SqlParameter("@path", SqlDbType.NVarChar,255),
+ new SqlParameter("@url", SqlDbType.NVarChar,255),
+ new SqlParameter("@target", SqlDbType.Int,10),
+ new SqlParameter("@state", SqlDbType.Int,10),
+ new SqlParameter("@remark", SqlDbType.NVarChar,500),
+ new SqlParameter("@seo_title", SqlDbType.NVarChar,255),
+ new SqlParameter("@seo_keywords", SqlDbType.NVarChar,255),
+ new SqlParameter("@seo_description", SqlDbType.NVarChar,255),
+ new SqlParameter("@add_time", SqlDbType.DateTime,23)};
+ parameters[0].Value = model.paixu;
+ parameters[1].Value = model.title;
+ parameters[2].Value = model.class_id;
+ parameters[3].Value = model.parent_id;
+ parameters[4].Value = model.class_list;
+ parameters[5].Value = model.class_layer;
+ parameters[6].Value = model.path;
+ parameters[7].Value = model.url;
+ parameters[8].Value = model.target;
+ parameters[9].Value = model.state;
+ parameters[10].Value = model.remark;
+ parameters[11].Value = model.seo_title;
+ parameters[12].Value = model.seo_keywords;
+ parameters[13].Value = model.seo_description;
+ parameters[14].Value = model.add_time;
+
+ object obj = DbHelperSQL.GetSingle(strSql.ToString(), parameters);
+ if (obj == null)
+ {
+ return 0;
+ }
+ else
+ {
+ return Convert.ToInt32(obj);
+ }
+ }
+
+ ///
+ /// 更新一条数据
+ ///
+ public bool Update(Basic.Model.nav model)
+ {
+ StringBuilder strSql = new StringBuilder();
+ strSql.Append("update tb_nav set ");
+ strSql.Append("paixu=@paixu,");
+ strSql.Append("title=@title,");
+ strSql.Append("class_id=@class_id,");
+ strSql.Append("parent_id=@parent_id,");
+ strSql.Append("class_list=@class_list,");
+ strSql.Append("class_layer=@class_layer,");
+ strSql.Append("path=@path,");
+ strSql.Append("url=@url,");
+ strSql.Append("target=@target,");
+ strSql.Append("state=@state,");
+ strSql.Append("remark=@remark,");
+ strSql.Append("seo_title=@seo_title,");
+ strSql.Append("seo_keywords=@seo_keywords,");
+ strSql.Append("seo_description=@seo_description,");
+ strSql.Append("add_time=@add_time");
+ strSql.Append(" where id=@id");
+ SqlParameter[] parameters = {
+ new SqlParameter("@paixu", SqlDbType.Int,10),
+ new SqlParameter("@title", SqlDbType.NVarChar,255),
+ new SqlParameter("@class_id", SqlDbType.Int,10),
+ new SqlParameter("@parent_id", SqlDbType.Int,10),
+ new SqlParameter("@class_list", SqlDbType.NVarChar,500),
+ new SqlParameter("@class_layer", SqlDbType.Int,10),
+ new SqlParameter("@path", SqlDbType.NVarChar,255),
+ new SqlParameter("@url", SqlDbType.NVarChar,255),
+ new SqlParameter("@target", SqlDbType.Int,10),
+ new SqlParameter("@state", SqlDbType.Int,10),
+ new SqlParameter("@remark", SqlDbType.NVarChar,500),
+ new SqlParameter("@seo_title", SqlDbType.NVarChar,255),
+ new SqlParameter("@seo_keywords", SqlDbType.NVarChar,255),
+ new SqlParameter("@seo_description", SqlDbType.NVarChar,255),
+ new SqlParameter("@add_time", SqlDbType.DateTime,23),
+ new SqlParameter("@id", SqlDbType.Int,4)};
+ parameters[0].Value = model.paixu;
+ parameters[1].Value = model.title;
+ parameters[2].Value = model.class_id;
+ parameters[3].Value = model.parent_id;
+ parameters[4].Value = model.class_list;
+ parameters[5].Value = model.class_layer;
+ parameters[6].Value = model.path;
+ parameters[7].Value = model.url;
+ parameters[8].Value = model.target;
+ parameters[9].Value = model.state;
+ parameters[10].Value = model.remark;
+ parameters[11].Value = model.seo_title;
+ parameters[12].Value = model.seo_keywords;
+ parameters[13].Value = model.seo_description;
+ parameters[14].Value = model.add_time;
+ parameters[15].Value = model.id;
+ int rows = DbHelperSQL.ExecuteSql(strSql.ToString(), parameters);
+ if (rows > 0)
+ {
+ return true;
+ }
+ else
+ {
+ return false;
+ }
+ }
+
+ ///
+ /// 删除一条数据
+ ///
+ public bool Delete(int id)
+ {
+ StringBuilder strSql = new StringBuilder();
+ strSql.Append("delete from tb_nav");
+ strSql.Append(" where id=@id");
+ SqlParameter[] parameters = {
+ new SqlParameter("@id", SqlDbType.Int,4)};
+ parameters[0].Value = id;
+ int rows = DbHelperSQL.ExecuteSql(strSql.ToString(), parameters);
+ if (rows > 0)
+ {
+ return true;
+ }
+ else
+ {
+ return false;
+ }
+ }
+
+ ///
+ /// 得到一个对象实体
+ ///
+ public Basic.Model.nav GetModel(int id)
+ {
+ StringBuilder strSql = new StringBuilder();
+ strSql.Append("select top 1 id,paixu,title,class_id,parent_id,class_list,class_layer,path,url,target,state,remark,seo_title,seo_keywords,seo_description,add_time from tb_nav");
+ strSql.Append(" where id=@id");
+ SqlParameter[] parameters = {
+ new SqlParameter("@id", SqlDbType.Int,4)};
+ parameters[0].Value = id;
+ Basic.Model.nav model = new Basic.Model.nav();
+ DataSet ds = DbHelperSQL.Query(strSql.ToString(), parameters);
+ if (ds.Tables[0].Rows.Count > 0)
+ {
+ if (!string.IsNullOrEmpty(ds.Tables[0].Rows[0]["id"].ToString()))
+ {
+ model.id = int.Parse(ds.Tables[0].Rows[0]["id"].ToString());
+ }
+ if (!string.IsNullOrEmpty(ds.Tables[0].Rows[0]["paixu"].ToString()))
+ {
+ model.paixu = int.Parse(ds.Tables[0].Rows[0]["paixu"].ToString());
+ }
+ if (!string.IsNullOrEmpty(ds.Tables[0].Rows[0]["title"].ToString()))
+ {
+ model.title = ds.Tables[0].Rows[0]["title"].ToString();
+ }
+ if (!string.IsNullOrEmpty(ds.Tables[0].Rows[0]["class_id"].ToString()))
+ {
+ model.class_id = int.Parse(ds.Tables[0].Rows[0]["class_id"].ToString());
+ }
+ if (!string.IsNullOrEmpty(ds.Tables[0].Rows[0]["parent_id"].ToString()))
+ {
+ model.parent_id = int.Parse(ds.Tables[0].Rows[0]["parent_id"].ToString());
+ }
+ if (!string.IsNullOrEmpty(ds.Tables[0].Rows[0]["class_list"].ToString()))
+ {
+ model.class_list = ds.Tables[0].Rows[0]["class_list"].ToString();
+ }
+ if (!string.IsNullOrEmpty(ds.Tables[0].Rows[0]["class_layer"].ToString()))
+ {
+ model.class_layer = int.Parse(ds.Tables[0].Rows[0]["class_layer"].ToString());
+ }
+ if (!string.IsNullOrEmpty(ds.Tables[0].Rows[0]["path"].ToString()))
+ {
+ model.path = ds.Tables[0].Rows[0]["path"].ToString();
+ }
+ if (!string.IsNullOrEmpty(ds.Tables[0].Rows[0]["url"].ToString()))
+ {
+ model.url = ds.Tables[0].Rows[0]["url"].ToString();
+ }
+ if (!string.IsNullOrEmpty(ds.Tables[0].Rows[0]["target"].ToString()))
+ {
+ model.target = int.Parse(ds.Tables[0].Rows[0]["target"].ToString());
+ }
+ if (!string.IsNullOrEmpty(ds.Tables[0].Rows[0]["state"].ToString()))
+ {
+ model.state = int.Parse(ds.Tables[0].Rows[0]["state"].ToString());
+ }
+ if (!string.IsNullOrEmpty(ds.Tables[0].Rows[0]["remark"].ToString()))
+ {
+ model.remark = ds.Tables[0].Rows[0]["remark"].ToString();
+ }
+ if (!string.IsNullOrEmpty(ds.Tables[0].Rows[0]["seo_title"].ToString()))
+ {
+ model.seo_title = ds.Tables[0].Rows[0]["seo_title"].ToString();
+ }
+ if (!string.IsNullOrEmpty(ds.Tables[0].Rows[0]["seo_keywords"].ToString()))
+ {
+ model.seo_keywords = ds.Tables[0].Rows[0]["seo_keywords"].ToString();
+ }
+ if (!string.IsNullOrEmpty(ds.Tables[0].Rows[0]["seo_description"].ToString()))
+ {
+ model.seo_description = ds.Tables[0].Rows[0]["seo_description"].ToString();
+ }
+ if (!string.IsNullOrEmpty(ds.Tables[0].Rows[0]["add_time"].ToString()))
+ {
+ model.add_time = DateTime.Parse(ds.Tables[0].Rows[0]["add_time"].ToString());
+ }
+ return model;
+ }
+ else
+ {
+ return null;
+ }
+ }
+
+ ///
+ /// 获得前几行数据
+ ///
+ public DataSet GetList(int Top, string strWhere, string filedOrder)
+ {
+ StringBuilder strSql = new StringBuilder();
+ strSql.Append("select ");
+ if (Top > 0)
+ {
+ strSql.Append(" top " + Top.ToString());
+ }
+ strSql.Append("id,paixu,title,class_id,parent_id,class_list,class_layer,path,url,target,state,remark,seo_title,seo_keywords,seo_description,add_time");
+ strSql.Append(" from tb_nav");
+ if (strWhere.Trim() != "")
+ {
+ strSql.Append(" where " + strWhere);
+ }
+ strSql.Append(" order by " + filedOrder);
+ return DbHelperSQL.Query(strSql.ToString());
+ }
+
+ ///
+ /// 是否存在该记录
+ ///
+ public bool Exists(int id)
+ {
+ StringBuilder strSql = new StringBuilder();
+ strSql.Append("select count(1) from tb_nav");
+ strSql.Append(" where id=@id");
+ SqlParameter[] parameters = {
+ new SqlParameter("@id", SqlDbType.Int,4)};
+ parameters[0].Value = id;
+
+ return DbHelperSQL.Exists(strSql.ToString(), parameters);
+ }
+
+ ///
+ /// 修改一列数据
+ ///
+ public void UpdateField(int id, string strValue)
+ {
+ StringBuilder strSql = new StringBuilder();
+ strSql.Append("update tb_nav set " + strValue);
+ strSql.Append(" where id=" + id);
+ DbHelperSQL.ExecuteSql(strSql.ToString());
+ }
+
+ ///
+ /// 取得所有类别列表
+ ///
+ /// 父ID
+ /// 分类ID
+ ///
+ public DataTable GetList(int parent_id, int class_id)
+ {
+ StringBuilder strSql = new StringBuilder();
+ strSql.Append("select * from tb_nav");
+ if (class_id > 0)
+ {
+ strSql.Append(" where class_id=" + class_id);
+
+ }
+ strSql.Append(" order by paixu desc,id asc");
+ DataSet ds = DbHelperSQL.Query(strSql.ToString());
+ DataTable oldData = ds.Tables[0] as DataTable;
+ if (oldData == null)
+ {
+ return null;
+ }
+ //复制结构
+ DataTable newData = oldData.Clone();
+ //调用迭代组合成DAGATABLE
+ GetChilds(oldData, newData, parent_id, class_id);
+ return newData;
+ }
+
+ ///
+ /// 从内存中取得所有下级类别列表(自身迭代)
+ ///
+ private void GetChilds(DataTable oldData, DataTable newData, int parent_id, int channel_id)
+ {
+ DataRow[] dr = oldData.Select("parent_id=" + parent_id);
+ for (int i = 0; i < dr.Length; i++)
+ {
+ //添加一行数据
+ DataRow row = newData.NewRow();
+ row["id"] = int.Parse(dr[i]["id"].ToString());
+ row["paixu"] = int.Parse(dr[i]["paixu"].ToString());
+ row["title"] = dr[i]["title"].ToString();
+ row["class_id"] = int.Parse(dr[i]["class_id"].ToString());
+ row["parent_id"] = int.Parse(dr[i]["parent_id"].ToString());
+ row["class_layer"] = int.Parse(dr[i]["class_layer"].ToString());
+ row["class_list"] = dr[i]["class_list"].ToString();
+ row["path"] = dr[i]["path"].ToString();
+ row["url"] = dr[i]["url"].ToString();
+ row["target"] = int.Parse(dr[i]["target"].ToString());
+ row["state"] = int.Parse(dr[i]["state"].ToString());
+ row["remark"] = dr[i]["remark"].ToString();
+ row["seo_title"] = dr[i]["seo_title"].ToString();
+ row["seo_keywords"] = dr[i]["seo_keywords"].ToString();
+ row["seo_description"] = dr[i]["seo_description"].ToString();
+ row["add_time"] = DateTime.Parse(dr[i]["add_time"].ToString());
+ newData.Rows.Add(row);
+ //调用自身迭代
+ this.GetChilds(oldData, newData, int.Parse(dr[i]["id"].ToString()), channel_id);
+ }
+ }
+ ///
+ /// 返回第一个class_id
+ ///
+ public int GetClass_Id()
+ {
+ int class_id = 0;
+ BasicPage bp = new BasicPage();
+ SqlDataReader myread = bp.getRead("select top 1 class_id from tb_nav");
+ if (myread.Read())
+ {
+ class_id = int.Parse(myread[0].ToString());
+ }
+ myread.Close();
+ return class_id;
+ }
+
+ ///
+ /// 返回导航链接
+ ///
+ //public string GetNav(int _id)
+ //{
+ // int class_id = 0;
+ // BasicPage bp = new BasicPage();
+ // SqlDataReader myread = bp.getRead("select top 1 class_id from tb_nav");
+ // if (myread.Read())
+ // {
+ // class_id = int.Parse(myread[0].ToString());
+ // }
+ // myread.Close();
+ // return class_id;
+ //}
+ }
+}
+
diff --git a/App.code/DAL/news.cs b/App.code/DAL/news.cs
new file mode 100644
index 0000000..d069cf4
--- /dev/null
+++ b/App.code/DAL/news.cs
@@ -0,0 +1,307 @@
+using System;
+using System.Data;
+using System.Text;
+using System.Data.SqlClient;
+
+namespace Basic.DAL
+{
+ ///
+ /// 新闻
+ ///
+ public partial class news
+ {
+ ///
+ /// 增加一条数据
+ ///
+ public int Add(Basic.Model.news model)
+ {
+ StringBuilder strSql = new StringBuilder();
+ strSql.Append("insert into tb_news(");
+ strSql.Append("class_id,parent_id,guid,title,url,path,seo_title,seo_keywords,seo_description,content,paixu,hits,status,user_id,add_time)");
+ strSql.Append(" values (");
+ strSql.Append("@class_id,@parent_id,@guid,@title,@url,@path,@seo_title,@seo_keywords,@seo_description,@content,@paixu,@hits,@status,@user_id,@add_time)");
+ strSql.Append(";select @@IDENTITY");
+
+ SqlParameter[] parameters = {
+ new SqlParameter("@class_id", SqlDbType.Int,10),
+ new SqlParameter("@parent_id", SqlDbType.Int,10),
+ new SqlParameter("@guid", SqlDbType.NVarChar,50),
+ new SqlParameter("@title", SqlDbType.NVarChar,100),
+ new SqlParameter("@url", SqlDbType.NVarChar,255),
+ new SqlParameter("@path", SqlDbType.NVarChar,255),
+ new SqlParameter("@seo_title", SqlDbType.NVarChar,255),
+ new SqlParameter("@seo_keywords", SqlDbType.NVarChar,255),
+ new SqlParameter("@seo_description", SqlDbType.NVarChar,255),
+ new SqlParameter("@content", SqlDbType.NText,1073741823),
+ new SqlParameter("@paixu", SqlDbType.Int,10),
+ new SqlParameter("@hits", SqlDbType.Int,10),
+ new SqlParameter("@status", SqlDbType.Int,10),
+ new SqlParameter("@user_id", SqlDbType.Int,10),
+ new SqlParameter("@add_time", SqlDbType.DateTime,23)};
+ parameters[0].Value = model.class_id;
+ parameters[1].Value = model.parent_id;
+ parameters[2].Value = model.guid;
+ parameters[3].Value = model.title;
+ parameters[4].Value = model.url;
+ parameters[5].Value = model.path;
+ parameters[6].Value = model.seo_title;
+ parameters[7].Value = model.seo_keywords;
+ parameters[8].Value = model.seo_description;
+ parameters[9].Value = model.content;
+ parameters[10].Value = model.paixu;
+ parameters[11].Value = model.hits;
+ parameters[12].Value = model.status;
+ parameters[13].Value = model.user_id;
+ parameters[14].Value = model.add_time;
+
+ object obj = DbHelperSQL.GetSingle(strSql.ToString(), parameters);
+ if (obj == null)
+ {
+ return 0;
+ }
+ else
+ {
+ return Convert.ToInt32(obj);
+ }
+ }
+
+ ///
+ /// 更新一条数据
+ ///
+ public bool Update(Basic.Model.news model)
+ {
+ StringBuilder strSql = new StringBuilder();
+ strSql.Append("update tb_news set ");
+ strSql.Append("class_id=@class_id,");
+ strSql.Append("parent_id=@parent_id,");
+ strSql.Append("guid=@guid,");
+ strSql.Append("title=@title,");
+ strSql.Append("url=@url,");
+ strSql.Append("path=@path,");
+ strSql.Append("seo_title=@seo_title,");
+ strSql.Append("seo_keywords=@seo_keywords,");
+ strSql.Append("seo_description=@seo_description,");
+ strSql.Append("content=@content,");
+ strSql.Append("paixu=@paixu,");
+ strSql.Append("hits=@hits,");
+ strSql.Append("status=@status,");
+ strSql.Append("user_id=@user_id,");
+ strSql.Append("add_time=@add_time");
+ strSql.Append(" where id=@id");
+ SqlParameter[] parameters = {
+ new SqlParameter("@class_id", SqlDbType.Int,10),
+ new SqlParameter("@parent_id", SqlDbType.Int,10),
+ new SqlParameter("@guid", SqlDbType.NVarChar,50),
+ new SqlParameter("@title", SqlDbType.NVarChar,100),
+ new SqlParameter("@url", SqlDbType.NVarChar,255),
+ new SqlParameter("@path", SqlDbType.NVarChar,255),
+ new SqlParameter("@seo_title", SqlDbType.NVarChar,255),
+ new SqlParameter("@seo_keywords", SqlDbType.NVarChar,255),
+ new SqlParameter("@seo_description", SqlDbType.NVarChar,255),
+ new SqlParameter("@content", SqlDbType.NText,1073741823),
+ new SqlParameter("@paixu", SqlDbType.Int,10),
+ new SqlParameter("@hits", SqlDbType.Int,10),
+ new SqlParameter("@status", SqlDbType.Int,10),
+ new SqlParameter("@user_id", SqlDbType.Int,10),
+ new SqlParameter("@add_time", SqlDbType.DateTime,23),
+ new SqlParameter("@id", SqlDbType.Int,4)};
+ parameters[0].Value = model.class_id;
+ parameters[1].Value = model.parent_id;
+ parameters[2].Value = model.guid;
+ parameters[3].Value = model.title;
+ parameters[4].Value = model.url;
+ parameters[5].Value = model.path;
+ parameters[6].Value = model.seo_title;
+ parameters[7].Value = model.seo_keywords;
+ parameters[8].Value = model.seo_description;
+ parameters[9].Value = model.content;
+ parameters[10].Value = model.paixu;
+ parameters[11].Value = model.hits;
+ parameters[12].Value = model.status;
+ parameters[13].Value = model.user_id;
+ parameters[14].Value = model.add_time;
+ parameters[15].Value = model.id;
+ int rows = DbHelperSQL.ExecuteSql(strSql.ToString(), parameters);
+ if (rows > 0)
+ {
+ return true;
+ }
+ else
+ {
+ return false;
+ }
+ }
+
+ ///
+ /// 删除一条数据
+ ///
+ public bool Delete(int id)
+ {
+ StringBuilder strSql = new StringBuilder();
+ strSql.Append("delete from tb_news");
+ strSql.Append(" where id=@id");
+ SqlParameter[] parameters = {
+ new SqlParameter("@id", SqlDbType.Int,4)};
+ parameters[0].Value = id;
+ int rows = DbHelperSQL.ExecuteSql(strSql.ToString(), parameters);
+ if (rows > 0)
+ {
+ return true;
+ }
+ else
+ {
+ return false;
+ }
+ }
+
+ ///
+ /// 得到一个对象实体
+ ///
+ public Basic.Model.news GetModel(int id)
+ {
+ StringBuilder strSql = new StringBuilder();
+ strSql.Append("select top 1 id,class_id,parent_id,guid,title,url,path,seo_title,seo_keywords,seo_description,content,paixu,hits,status,user_id,add_time from tb_news");
+ strSql.Append(" where id=@id");
+ SqlParameter[] parameters = {
+ new SqlParameter("@id", SqlDbType.Int,4)};
+ parameters[0].Value = id;
+ Basic.Model.news model = new Basic.Model.news();
+ DataSet ds = DbHelperSQL.Query(strSql.ToString(), parameters);
+ if (ds.Tables[0].Rows.Count > 0)
+ {
+ if (!string.IsNullOrEmpty(ds.Tables[0].Rows[0]["id"].ToString()))
+ {
+ model.id = int.Parse(ds.Tables[0].Rows[0]["id"].ToString());
+ }
+ if (!string.IsNullOrEmpty(ds.Tables[0].Rows[0]["class_id"].ToString()))
+ {
+ model.class_id = int.Parse(ds.Tables[0].Rows[0]["class_id"].ToString());
+ }
+ if (!string.IsNullOrEmpty(ds.Tables[0].Rows[0]["parent_id"].ToString()))
+ {
+ model.parent_id = int.Parse(ds.Tables[0].Rows[0]["parent_id"].ToString());
+ }
+ if (!string.IsNullOrEmpty(ds.Tables[0].Rows[0]["guid"].ToString()))
+ {
+ model.guid = ds.Tables[0].Rows[0]["guid"].ToString();
+ }
+ if (!string.IsNullOrEmpty(ds.Tables[0].Rows[0]["title"].ToString()))
+ {
+ model.title = ds.Tables[0].Rows[0]["title"].ToString();
+ }
+ if (!string.IsNullOrEmpty(ds.Tables[0].Rows[0]["url"].ToString()))
+ {
+ model.url = ds.Tables[0].Rows[0]["url"].ToString();
+ }
+ if (!string.IsNullOrEmpty(ds.Tables[0].Rows[0]["path"].ToString()))
+ {
+ model.path = ds.Tables[0].Rows[0]["path"].ToString();
+ }
+ if (!string.IsNullOrEmpty(ds.Tables[0].Rows[0]["seo_title"].ToString()))
+ {
+ model.seo_title = ds.Tables[0].Rows[0]["seo_title"].ToString();
+ }
+ if (!string.IsNullOrEmpty(ds.Tables[0].Rows[0]["seo_keywords"].ToString()))
+ {
+ model.seo_keywords = ds.Tables[0].Rows[0]["seo_keywords"].ToString();
+ }
+ if (!string.IsNullOrEmpty(ds.Tables[0].Rows[0]["seo_description"].ToString()))
+ {
+ model.seo_description = ds.Tables[0].Rows[0]["seo_description"].ToString();
+ }
+ if (!string.IsNullOrEmpty(ds.Tables[0].Rows[0]["content"].ToString()))
+ {
+ model.content = ds.Tables[0].Rows[0]["content"].ToString();
+ }
+ if (!string.IsNullOrEmpty(ds.Tables[0].Rows[0]["paixu"].ToString()))
+ {
+ model.paixu = int.Parse(ds.Tables[0].Rows[0]["paixu"].ToString());
+ }
+ if (!string.IsNullOrEmpty(ds.Tables[0].Rows[0]["hits"].ToString()))
+ {
+ model.hits = int.Parse(ds.Tables[0].Rows[0]["hits"].ToString());
+ }
+ if (!string.IsNullOrEmpty(ds.Tables[0].Rows[0]["status"].ToString()))
+ {
+ model.status = int.Parse(ds.Tables[0].Rows[0]["status"].ToString());
+ }
+ if (!string.IsNullOrEmpty(ds.Tables[0].Rows[0]["user_id"].ToString()))
+ {
+ model.user_id = int.Parse(ds.Tables[0].Rows[0]["user_id"].ToString());
+ }
+ if (!string.IsNullOrEmpty(ds.Tables[0].Rows[0]["add_time"].ToString()))
+ {
+ model.add_time = DateTime.Parse(ds.Tables[0].Rows[0]["add_time"].ToString());
+ }
+ return model;
+ }
+ else
+ {
+ return null;
+ }
+ }
+ ///
+ /// 获得查询分页数据
+ ///
+ public DataSet GetList(string _strWhere, string _orderby, int _pageSize, int _page, out int recordCount)
+ {
+ BasicPage bp = new BasicPage();
+ StringBuilder str_Sql = new StringBuilder();
+ str_Sql.Append("select top " + _pageSize + " * from tb_news");
+ str_Sql.Append(" where ");
+ str_Sql.Append(_strWhere);
+ str_Sql.Append(" and id not in ");
+ str_Sql.Append(" ( ");
+ str_Sql.Append(" select top " + (_page - 1) * _pageSize + " id from tb_news ");
+ str_Sql.Append(" where ");
+ str_Sql.Append(_strWhere);
+ str_Sql.Append(" order by ");
+ str_Sql.Append(_orderby);
+ str_Sql.Append(" ) ");
+ str_Sql.Append(" order by ");
+ str_Sql.Append(_orderby);
+ DataSet dst = bp.SelectDataBase("tb_news", str_Sql.ToString());
+ //
+ recordCount = totlePage(showTotal(_strWhere), _pageSize);
+ return dst;
+ }
+
+ //总页数
+ public int totlePage(int Total, int PageSize)
+ {
+ if (Total % PageSize == 0)
+ {
+ return Total / PageSize;
+ }
+ else
+ {
+ return Total / PageSize + 1;
+ }
+ }
+
+ //总条数
+ protected int showTotal(string strSql)
+ {
+ BasicPage bp = new BasicPage();
+ int intTotal = 0;
+ SqlDataReader myread = bp.getRead("select count(id) as CountId from tb_news where " + strSql);
+ if (myread.Read())
+ {
+ intTotal = Convert.ToInt32(myread["CountId"].ToString());
+ }
+ myread.Close();
+ return intTotal;
+ }
+ ///
+ /// 修改一列数据
+ ///
+ public void UpdateField(int id, string strValue)
+ {
+ StringBuilder strSql = new StringBuilder();
+ strSql.Append("update tb_news set " + strValue);
+ strSql.Append(" where id=" + id);
+ DbHelperSQL.ExecuteSql(strSql.ToString());
+ }
+ }
+}
+