Esempio n. 1
0
        /// <summary>
        /// 更新一条数据
        /// </summary>
        public void Update(Lebi_User_Answer model)
        {
            StringBuilder strSql = new StringBuilder();

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

            if (("," + model.UpdateCols + ",").IndexOf(",Answer,") > -1 || model.UpdateCols == "")
            {
                cols.Add(LB.DataAccess.DB.BaseUtilsInstance.ColName("Answer") + "= @Answer");
            }
            if (("," + model.UpdateCols + ",").IndexOf(",User_id,") > -1 || model.UpdateCols == "")
            {
                cols.Add(LB.DataAccess.DB.BaseUtilsInstance.ColName("User_id") + "= @User_id");
            }
            if (("," + model.UpdateCols + ",").IndexOf(",User_Question_id,") > -1 || model.UpdateCols == "")
            {
                cols.Add(LB.DataAccess.DB.BaseUtilsInstance.ColName("User_Question_id") + "= @User_Question_id");
            }
            strSql.Append(string.Join(",", cols));
            strSql.Append(" where id=@id");
            SqlParameter[] parameters =
            {
                new SqlParameter("@id",               model.id),
                new SqlParameter("@Answer",           model.Answer),
                new SqlParameter("@User_id",          model.User_id),
                new SqlParameter("@User_Question_id", model.User_Question_id)
            };
            LB.DataAccess.DB.Instance.TextExecuteNonQuery(strSql.ToString().Replace(", where id=@id", " where id=@id"), parameters);
        }
Esempio n. 2
0
        /// <summary>
        /// 增加一条数据
        /// </summary>
        public int Add(Lebi_User_Answer model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("insert into " + TableName + " (");
            strSql.Append(LB.DataAccess.DB.BaseUtilsInstance.ColName("Answer") + "," + LB.DataAccess.DB.BaseUtilsInstance.ColName("User_id") + "," + LB.DataAccess.DB.BaseUtilsInstance.ColName("User_Question_id") + ")");
            strSql.Append(" values (");
            strSql.Append("@Answer,@User_id,@User_Question_id);select @@identity;");
            SqlParameter[] parameters =
            {
                new SqlParameter("@Answer",           model.Answer),
                new SqlParameter("@User_id",          model.User_id),
                new SqlParameter("@User_Question_id", model.User_Question_id)
            };

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

            if (obj == null)
            {
                return(1);
            }
            else
            {
                return(Convert.ToInt32(obj));
            }
        }
Esempio n. 3
0
 /// <summary>
 /// 安全方式绑定对象表单
 /// </summary>
 public Lebi_User_Answer SafeBindForm(Lebi_User_Answer model)
 {
     if (HttpContext.Current.Request["Answer"] != null)
     {
         model.Answer = LB.Tools.RequestTool.RequestSafeString("Answer");
     }
     if (HttpContext.Current.Request["User_id"] != null)
     {
         model.User_id = LB.Tools.RequestTool.RequestInt("User_id", 0);
     }
     if (HttpContext.Current.Request["User_Question_id"] != null)
     {
         model.User_Question_id = LB.Tools.RequestTool.RequestInt("User_Question_id", 0);
     }
     return(model);
 }
Esempio n. 4
0
        /// <summary>
        /// 得到一个对象实体 by where条件
        /// </summary>
        public Lebi_User_Answer 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_User_Answer);
                }
            }
            Lebi_User_Answer 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_User_Answer", model.id, cachestr, seconds);
                    }
                    return(model);
                }
            }
            return(null);
        }
Esempio n. 5
0
        /// <summary>
        /// 对象实体绑定数据
        /// </summary>
        public Lebi_User_Answer ReaderBind(IDataReader dataReader)
        {
            Lebi_User_Answer model = new Lebi_User_Answer();
            object           ojb;

            ojb = dataReader["id"];
            if (ojb != null && ojb != DBNull.Value)
            {
                model.id = Convert.ToInt32(ojb);
            }
            model.Answer = dataReader["Answer"].ToString();
            ojb          = dataReader["User_id"];
            if (ojb != null && ojb != DBNull.Value)
            {
                model.User_id = Convert.ToInt32(ojb);
            }
            ojb = dataReader["User_Question_id"];
            if (ojb != null && ojb != DBNull.Value)
            {
                model.User_Question_id = Convert.ToInt32(ojb);
            }
            return(model);
        }
Esempio n. 6
0
 /// <summary>
 /// 更新一条数据
 /// </summary>
 public static void Update(Lebi_User_Answer model)
 {
     D_Lebi_User_Answer.Instance.Update(model);
 }
Esempio n. 7
0
 /// <summary>
 /// 增加一条数据
 /// </summary>
 public static int Add(Lebi_User_Answer model)
 {
     return(D_Lebi_User_Answer.Instance.Add(model));
 }
Esempio n. 8
0
 /// <summary>
 /// 安全方式绑定表单数据
 /// </summary>
 public static Lebi_User_Answer SafeBindForm(Lebi_User_Answer model)
 {
     return(D_Lebi_User_Answer.Instance.SafeBindForm(model));
 }