Esempio n. 1
0
        /// <summary>
        /// 对象实体绑定数据
        /// </summary>
        public Lebi_Notice ReaderBind(IDataReader dataReader)
        {
            Lebi_Notice model = new Lebi_Notice();
            object      ojb;

            ojb = dataReader["id"];
            if (ojb != null && ojb != DBNull.Value)
            {
                model.id = Convert.ToInt32(ojb);
            }
            model.NcontentCN = dataReader["NcontentCN"].ToString();
            model.NcontentEN = dataReader["NcontentEN"].ToString();
            ojb = dataReader["Nsort"];
            if (ojb != null && ojb != DBNull.Value)
            {
                model.Nsort = Convert.ToInt32(ojb);
            }
            ojb = dataReader["Nsubmittime"];
            if (ojb != null && ojb != DBNull.Value)
            {
                model.Nsubmittime = (DateTime)ojb;
            }
            model.NtitleCN = dataReader["NtitleCN"].ToString();
            model.NtitleEN = dataReader["NtitleEN"].ToString();
            ojb            = dataReader["Typeid"];
            if (ojb != null && ojb != DBNull.Value)
            {
                model.Typeid = Convert.ToInt32(ojb);
            }
            return(model);
        }
Esempio n. 2
0
 /// <summary>
 /// 安全方式绑定对象表单
 /// </summary>
 public Lebi_Notice SafeBindForm(Lebi_Notice model)
 {
     if (HttpContext.Current.Request["NcontentCN"] != null)
     {
         model.NcontentCN = LB.Tools.RequestTool.RequestSafeString("NcontentCN");
     }
     if (HttpContext.Current.Request["NcontentEN"] != null)
     {
         model.NcontentEN = LB.Tools.RequestTool.RequestSafeString("NcontentEN");
     }
     if (HttpContext.Current.Request["Nsort"] != null)
     {
         model.Nsort = LB.Tools.RequestTool.RequestInt("Nsort", 0);
     }
     if (HttpContext.Current.Request["Nsubmittime"] != null)
     {
         model.Nsubmittime = LB.Tools.RequestTool.RequestTime("Nsubmittime", System.DateTime.Now);
     }
     if (HttpContext.Current.Request["NtitleCN"] != null)
     {
         model.NtitleCN = LB.Tools.RequestTool.RequestSafeString("NtitleCN");
     }
     if (HttpContext.Current.Request["NtitleEN"] != null)
     {
         model.NtitleEN = LB.Tools.RequestTool.RequestSafeString("NtitleEN");
     }
     if (HttpContext.Current.Request["Typeid"] != null)
     {
         model.Typeid = LB.Tools.RequestTool.RequestInt("Typeid", 0);
     }
     return(model);
 }
Esempio n. 3
0
        /// <summary>
        /// 增加一条数据
        /// </summary>
        public int Add(Lebi_Notice model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("insert into " + TableName + " (");
            strSql.Append(LB.DataAccess.DB.BaseUtilsInstance.ColName("NcontentCN") + "," + LB.DataAccess.DB.BaseUtilsInstance.ColName("NcontentEN") + "," + LB.DataAccess.DB.BaseUtilsInstance.ColName("Nsort") + "," + LB.DataAccess.DB.BaseUtilsInstance.ColName("Nsubmittime") + "," + LB.DataAccess.DB.BaseUtilsInstance.ColName("NtitleCN") + "," + LB.DataAccess.DB.BaseUtilsInstance.ColName("NtitleEN") + "," + LB.DataAccess.DB.BaseUtilsInstance.ColName("Typeid") + ")");
            strSql.Append(" values (");
            strSql.Append("@NcontentCN,@NcontentEN,@Nsort,@Nsubmittime,@NtitleCN,@NtitleEN,@Typeid);select @@identity;");
            SqlParameter[] parameters =
            {
                new SqlParameter("@NcontentCN",  model.NcontentCN),
                new SqlParameter("@NcontentEN",  model.NcontentEN),
                new SqlParameter("@Nsort",       model.Nsort),
                new SqlParameter("@Nsubmittime", model.Nsubmittime),
                new SqlParameter("@NtitleCN",    model.NtitleCN),
                new SqlParameter("@NtitleEN",    model.NtitleEN),
                new SqlParameter("@Typeid",      model.Typeid)
            };

            object obj = LB.DataAccess.DB.Instance.TextExecute(strSql.ToString(), parameters);

            if (obj == null)
            {
                return(1);
            }
            else
            {
                return(Convert.ToInt32(obj));
            }
        }
Esempio n. 4
0
        /// <summary>
        /// 更新一条数据
        /// </summary>
        public void Update(Lebi_Notice model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("update " + TableName + " set ");
            List <string> cols = new List <string>();

            if (("," + model.UpdateCols + ",").IndexOf(",NcontentCN,") > -1 || model.UpdateCols == "")
            {
                cols.Add(LB.DataAccess.DB.BaseUtilsInstance.ColName("NcontentCN") + "= @NcontentCN");
            }
            if (("," + model.UpdateCols + ",").IndexOf(",NcontentEN,") > -1 || model.UpdateCols == "")
            {
                cols.Add(LB.DataAccess.DB.BaseUtilsInstance.ColName("NcontentEN") + "= @NcontentEN");
            }
            if (("," + model.UpdateCols + ",").IndexOf(",Nsort,") > -1 || model.UpdateCols == "")
            {
                cols.Add(LB.DataAccess.DB.BaseUtilsInstance.ColName("Nsort") + "= @Nsort");
            }
            if (("," + model.UpdateCols + ",").IndexOf(",Nsubmittime,") > -1 || model.UpdateCols == "")
            {
                cols.Add(LB.DataAccess.DB.BaseUtilsInstance.ColName("Nsubmittime") + "= @Nsubmittime");
            }
            if (("," + model.UpdateCols + ",").IndexOf(",NtitleCN,") > -1 || model.UpdateCols == "")
            {
                cols.Add(LB.DataAccess.DB.BaseUtilsInstance.ColName("NtitleCN") + "= @NtitleCN");
            }
            if (("," + model.UpdateCols + ",").IndexOf(",NtitleEN,") > -1 || model.UpdateCols == "")
            {
                cols.Add(LB.DataAccess.DB.BaseUtilsInstance.ColName("NtitleEN") + "= @NtitleEN");
            }
            if (("," + model.UpdateCols + ",").IndexOf(",Typeid,") > -1 || model.UpdateCols == "")
            {
                cols.Add(LB.DataAccess.DB.BaseUtilsInstance.ColName("Typeid") + "= @Typeid");
            }
            strSql.Append(string.Join(",", cols));
            strSql.Append(" where id=@id");
            SqlParameter[] parameters =
            {
                new SqlParameter("@id",          model.id),
                new SqlParameter("@NcontentCN",  model.NcontentCN),
                new SqlParameter("@NcontentEN",  model.NcontentEN),
                new SqlParameter("@Nsort",       model.Nsort),
                new SqlParameter("@Nsubmittime", model.Nsubmittime),
                new SqlParameter("@NtitleCN",    model.NtitleCN),
                new SqlParameter("@NtitleEN",    model.NtitleEN),
                new SqlParameter("@Typeid",      model.Typeid)
            };
            LB.DataAccess.DB.Instance.TextExecuteNonQuery(strSql.ToString().Replace(", where id=@id", " where id=@id"), parameters);
        }
Esempio n. 5
0
        /// <summary>
        /// 得到一个对象实体 by where条件
        /// </summary>
        public Lebi_Notice GetModel(string strWhere, int seconds = 0)
        {
            if (strWhere.IndexOf("lbsql{") > 0)
            {
                SQLPara para = new SQLPara(strWhere, "", "");
                return(GetModel(para, seconds));
            }
            string strTableName = TableName;
            string strFieldShow = "*";
            string cachekey     = "";
            string cachestr     = "";

            if (BaseUtils.BaseUtilsInstance.MemcacheInstance != null && seconds > 0)
            {
                cachestr = "select * " + TableName + " where " + strWhere + "|" + seconds;
                cachekey = LB.Tools.Utils.MD5(cachestr);
                var obj = LB.DataAccess.DB.Instance.GetMemchche(cachekey);
                if (obj != null)
                {
                    return(obj as Lebi_Notice);
                }
            }
            Lebi_Notice model = null;

            using (IDataReader dataReader = LB.DataAccess.DB.Instance.TextExecuteReaderOne(strTableName, strFieldShow, strWhere, null))
            {
                if (dataReader == null)
                {
                    return(null);
                }
                while (dataReader.Read())
                {
                    model = ReaderBind(dataReader);
                    if (cachekey != "")
                    {
                        LB.DataAccess.DB.Instance.SetMemchche(cachekey, model, "Lebi_Notice", model.id, cachestr, seconds);
                    }
                    return(model);
                }
            }
            return(null);
        }
Esempio n. 6
0
 /// <summary>
 /// 更新一条数据
 /// </summary>
 public static void Update(Lebi_Notice model)
 {
     D_Lebi_Notice.Instance.Update(model);
 }
Esempio n. 7
0
 /// <summary>
 /// 增加一条数据
 /// </summary>
 public static int Add(Lebi_Notice model)
 {
     return(D_Lebi_Notice.Instance.Add(model));
 }
Esempio n. 8
0
 /// <summary>
 /// 安全方式绑定表单数据
 /// </summary>
 public static Lebi_Notice SafeBindForm(Lebi_Notice model)
 {
     return(D_Lebi_Notice.Instance.SafeBindForm(model));
 }