123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325 |
-
- using System;
- using System.Data;
- using System.Text;
- using System.Data.SqlClient;
- using iNethinkCMS.Helper;
- namespace iNethinkCMS.DAL
- {
-
-
-
- public partial class DAL_iNethinkCMS_Dict
- {
- public DAL_iNethinkCMS_Dict()
- { }
-
-
-
- public bool Exists(int ID)
- {
- StringBuilder strSql = new StringBuilder();
- strSql.Append("select count(1) from iNethinkCMS_Dict");
- strSql.Append(" where ID=@ID");
- SqlParameter[] parameters = {
- new SqlParameter("@ID", SqlDbType.Int,4)
- };
- parameters[0].Value = ID;
- return SQLHelper.Exists(strSql.ToString(), parameters);
- }
-
-
-
- public int Add(iNethinkCMS.Model.Model_iNethinkCMS_Dict model)
- {
- StringBuilder strSql = new StringBuilder();
- strSql.Append("insert into iNethinkCMS_Dict(");
- strSql.Append("DictType,DictName,Display,OrderNum)");
- strSql.Append(" values (");
- strSql.Append("@DictType,@DictName,@Display,@OrderNum)");
- strSql.Append(";select @@IDENTITY");
- SqlParameter[] parameters = {
- new SqlParameter("@DictType", SqlDbType.SmallInt,2),
- new SqlParameter("@DictName", SqlDbType.NVarChar,200),
- new SqlParameter("@Display", SqlDbType.SmallInt,2),
- new SqlParameter("@OrderNum", SqlDbType.Int,4)};
- parameters[0].Value = model.DictType;
- parameters[1].Value = model.DictName;
- parameters[2].Value = model.Display;
- parameters[3].Value = model.OrderNum;
- object obj = SQLHelper.GetSingle(strSql.ToString(), parameters);
- if (obj == null)
- {
- return 0;
- }
- else
- {
- return Convert.ToInt32(obj);
- }
- }
-
-
-
- public bool Update(iNethinkCMS.Model.Model_iNethinkCMS_Dict model)
- {
- StringBuilder strSql = new StringBuilder();
- strSql.Append("update iNethinkCMS_Dict set ");
- strSql.Append("DictType=@DictType,");
- strSql.Append("DictName=@DictName,");
- strSql.Append("Display=@Display,");
- strSql.Append("OrderNum=@OrderNum");
- strSql.Append(" where ID=@ID");
- SqlParameter[] parameters = {
- new SqlParameter("@DictType", SqlDbType.SmallInt,2),
- new SqlParameter("@DictName", SqlDbType.NVarChar,200),
- new SqlParameter("@Display", SqlDbType.SmallInt,2),
- new SqlParameter("@OrderNum", SqlDbType.Int,4),
- new SqlParameter("@ID", SqlDbType.Int,4)};
- parameters[0].Value = model.DictType;
- parameters[1].Value = model.DictName;
- parameters[2].Value = model.Display;
- parameters[3].Value = model.OrderNum;
- parameters[4].Value = model.ID;
- int rows = SQLHelper.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 iNethinkCMS_Dict ");
- strSql.Append(" where ID=@ID");
- SqlParameter[] parameters = {
- new SqlParameter("@ID", SqlDbType.Int,4)
- };
- parameters[0].Value = ID;
- int rows = SQLHelper.ExecuteSql(strSql.ToString(), parameters);
- if (rows > 0)
- {
- return true;
- }
- else
- {
- return false;
- }
- }
-
-
-
- public string GetDictName(int ID)
- {
- string vDictName = "";
- StringBuilder strSql = new StringBuilder();
- strSql.Append("select top 1 DictName from iNethinkCMS_Dict ");
- strSql.Append(" where ID=@ID");
- SqlParameter[] parameters = {
- new SqlParameter("@ID", SqlDbType.Int,4)
- };
- parameters[0].Value = ID;
- SqlDataReader sr = Helper.SQLHelper.ExecuteReader(strSql.ToString(), parameters);
- if (sr.Read())
- {
- vDictName = sr[0].ToString();
- }
- sr.Close();
- return vDictName;
- }
-
-
-
- public bool DeleteList(string IDlist)
- {
- StringBuilder strSql = new StringBuilder();
- strSql.Append("delete from iNethinkCMS_Dict ");
- strSql.Append(" where ID in (" + IDlist + ") ");
- int rows = SQLHelper.ExecuteSql(strSql.ToString());
- if (rows > 0)
- {
- return true;
- }
- else
- {
- return false;
- }
- }
-
-
-
- public iNethinkCMS.Model.Model_iNethinkCMS_Dict GetModel(int ID)
- {
- StringBuilder strSql = new StringBuilder();
- strSql.Append("select top 1 ID,DictType,DictName,Display,OrderNum from iNethinkCMS_Dict ");
- strSql.Append(" where ID=@ID");
- SqlParameter[] parameters = {
- new SqlParameter("@ID", SqlDbType.Int,4)
- };
- parameters[0].Value = ID;
- iNethinkCMS.Model.Model_iNethinkCMS_Dict model = new iNethinkCMS.Model.Model_iNethinkCMS_Dict();
- DataSet ds = SQLHelper.Query(strSql.ToString(), parameters);
- if (ds.Tables[0].Rows.Count > 0)
- {
- return DataRowToModel(ds.Tables[0].Rows[0]);
- }
- else
- {
- return null;
- }
- }
-
-
-
- public iNethinkCMS.Model.Model_iNethinkCMS_Dict DataRowToModel(DataRow row)
- {
- iNethinkCMS.Model.Model_iNethinkCMS_Dict model = new iNethinkCMS.Model.Model_iNethinkCMS_Dict();
- if (row != null)
- {
- if (row["ID"] != null && row["ID"].ToString() != "")
- {
- model.ID = int.Parse(row["ID"].ToString());
- }
- if (row["DictType"] != null && row["DictType"].ToString() != "")
- {
- model.DictType = int.Parse(row["DictType"].ToString());
- }
- if (row["DictName"] != null)
- {
- model.DictName = row["DictName"].ToString();
- }
- if (row["Display"] != null && row["Display"].ToString() != "")
- {
- model.Display = int.Parse(row["Display"].ToString());
- }
- if (row["OrderNum"] != null && row["OrderNum"].ToString() != "")
- {
- model.OrderNum = int.Parse(row["OrderNum"].ToString());
- }
- }
- return model;
- }
-
-
-
- public DataSet GetList(string strWhere)
- {
- StringBuilder strSql = new StringBuilder();
- strSql.Append("select ID,DictType,DictName,Display,OrderNum ");
- strSql.Append(" FROM iNethinkCMS_Dict ");
- if (strWhere.Trim() != "")
- {
- strSql.Append(" where " + strWhere);
- }
- return SQLHelper.Query(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,DictType,DictName,Display,OrderNum ");
- strSql.Append(" FROM iNethinkCMS_Dict ");
- if (strWhere.Trim() != "")
- {
- strSql.Append(" where " + strWhere);
- }
- strSql.Append(" order by " + filedOrder);
- return SQLHelper.Query(strSql.ToString());
- }
-
-
-
- public int GetRecordCount(string strWhere)
- {
- StringBuilder strSql = new StringBuilder();
- strSql.Append("select count(1) FROM iNethinkCMS_Dict ");
- if (strWhere.Trim() != "")
- {
- strSql.Append(" where " + strWhere);
- }
- object obj = SQLHelper.GetSingle(strSql.ToString());
- if (obj == null)
- {
- return 0;
- }
- else
- {
- return Convert.ToInt32(obj);
- }
- }
-
-
-
- public DataSet GetListByPage(string strWhere, string orderby, int startIndex, int endIndex)
- {
- if (!string.IsNullOrEmpty(strWhere.Trim()))
- {
- strWhere = " Where " + strWhere;
- }
- if (!string.IsNullOrEmpty(orderby.Trim()))
- {
- orderby = " Order By " + orderby;
- }
-
- StringBuilder strSql = new StringBuilder();
- strSql.Append("SELECT * FROM iNethinkCMS_Dict Where ID Not IN ");
- strSql.Append("(Select Top " + startIndex + " ID From iNethinkCMS_Dict" + strWhere + orderby + ")");
- strSql.Append(" And ID In ");
- strSql.Append("(Select Top " + endIndex + " ID From iNethinkCMS_Dict" + strWhere + orderby + ")");
- strSql.Append(orderby);
- return SQLHelper.Query(strSql.ToString());
- }
- }
- }
|