Beispiel #1
0
        /// <summary>
        /// 对象实体绑定数据
        /// </summary>
        public Lebi_Inquiry ReaderBind(IDataReader dataReader)
        {
            Lebi_Inquiry model = new Lebi_Inquiry();
            object       ojb;

            ojb = dataReader["id"];
            if (ojb != null && ojb != DBNull.Value)
            {
                model.id = Convert.ToInt32(ojb);
            }
            model.Content  = dataReader["Content"].ToString();
            model.Email    = dataReader["Email"].ToString();
            model.Language = dataReader["Language"].ToString();
            model.Phone    = dataReader["Phone"].ToString();
            model.Subject  = dataReader["Subject"].ToString();
            ojb            = dataReader["Time_Add"];
            if (ojb != null && ojb != DBNull.Value)
            {
                model.Time_Add = (DateTime)ojb;
            }
            ojb = dataReader["Time_Update"];
            if (ojb != null && ojb != DBNull.Value)
            {
                model.Time_Update = (DateTime)ojb;
            }
            ojb = dataReader["Type_id_InquiryStatus"];
            if (ojb != null && ojb != DBNull.Value)
            {
                model.Type_id_InquiryStatus = Convert.ToInt32(ojb);
            }
            model.UserName = dataReader["UserName"].ToString();
            return(model);
        }
Beispiel #2
0
        /// <summary>
        /// 更新一条数据
        /// </summary>
        public void Update(Lebi_Inquiry model)
        {
            StringBuilder strSql = new StringBuilder();

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

            if (("," + model.UpdateCols + ",").IndexOf(",Content,") > -1 || model.UpdateCols == "")
            {
                cols.Add(LB.DataAccess.DB.BaseUtilsInstance.ColName("Content") + "= @Content");
            }
            if (("," + model.UpdateCols + ",").IndexOf(",Email,") > -1 || model.UpdateCols == "")
            {
                cols.Add(LB.DataAccess.DB.BaseUtilsInstance.ColName("Email") + "= @Email");
            }
            if (("," + model.UpdateCols + ",").IndexOf(",Language,") > -1 || model.UpdateCols == "")
            {
                cols.Add(LB.DataAccess.DB.BaseUtilsInstance.ColName("Language") + "= @Language");
            }
            if (("," + model.UpdateCols + ",").IndexOf(",Phone,") > -1 || model.UpdateCols == "")
            {
                cols.Add(LB.DataAccess.DB.BaseUtilsInstance.ColName("Phone") + "= @Phone");
            }
            if (("," + model.UpdateCols + ",").IndexOf(",Subject,") > -1 || model.UpdateCols == "")
            {
                cols.Add(LB.DataAccess.DB.BaseUtilsInstance.ColName("Subject") + "= @Subject");
            }
            if (("," + model.UpdateCols + ",").IndexOf(",Time_Add,") > -1 || model.UpdateCols == "")
            {
                cols.Add(LB.DataAccess.DB.BaseUtilsInstance.ColName("Time_Add") + "= @Time_Add");
            }
            if (("," + model.UpdateCols + ",").IndexOf(",Time_Update,") > -1 || model.UpdateCols == "")
            {
                cols.Add(LB.DataAccess.DB.BaseUtilsInstance.ColName("Time_Update") + "= @Time_Update");
            }
            if (("," + model.UpdateCols + ",").IndexOf(",Type_id_InquiryStatus,") > -1 || model.UpdateCols == "")
            {
                cols.Add(LB.DataAccess.DB.BaseUtilsInstance.ColName("Type_id_InquiryStatus") + "= @Type_id_InquiryStatus");
            }
            if (("," + model.UpdateCols + ",").IndexOf(",UserName,") > -1 || model.UpdateCols == "")
            {
                cols.Add(LB.DataAccess.DB.BaseUtilsInstance.ColName("UserName") + "= @UserName");
            }
            strSql.Append(string.Join(",", cols));
            strSql.Append(" where id=@id");
            SqlParameter[] parameters =
            {
                new SqlParameter("@id",                    model.id),
                new SqlParameter("@Content",               model.Content),
                new SqlParameter("@Email",                 model.Email),
                new SqlParameter("@Language",              model.Language),
                new SqlParameter("@Phone",                 model.Phone),
                new SqlParameter("@Subject",               model.Subject),
                new SqlParameter("@Time_Add",              model.Time_Add),
                new SqlParameter("@Time_Update",           model.Time_Update),
                new SqlParameter("@Type_id_InquiryStatus", model.Type_id_InquiryStatus),
                new SqlParameter("@UserName",              model.UserName)
            };
            LB.DataAccess.DB.Instance.TextExecuteNonQuery(strSql.ToString().Replace(", where id=@id", " where id=@id"), parameters);
        }
Beispiel #3
0
        /// <summary>
        /// 增加一条数据
        /// </summary>
        public int Add(Lebi_Inquiry model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("insert into " + TableName + " (");
            strSql.Append(LB.DataAccess.DB.BaseUtilsInstance.ColName("Content") + "," + LB.DataAccess.DB.BaseUtilsInstance.ColName("Email") + "," + LB.DataAccess.DB.BaseUtilsInstance.ColName("Language") + "," + LB.DataAccess.DB.BaseUtilsInstance.ColName("Phone") + "," + LB.DataAccess.DB.BaseUtilsInstance.ColName("Subject") + "," + LB.DataAccess.DB.BaseUtilsInstance.ColName("Time_Add") + "," + LB.DataAccess.DB.BaseUtilsInstance.ColName("Time_Update") + "," + LB.DataAccess.DB.BaseUtilsInstance.ColName("Type_id_InquiryStatus") + "," + LB.DataAccess.DB.BaseUtilsInstance.ColName("UserName") + ")");
            strSql.Append(" values (");
            strSql.Append("@Content,@Email,@Language,@Phone,@Subject,@Time_Add,@Time_Update,@Type_id_InquiryStatus,@UserName);select @@identity;");
            SqlParameter[] parameters =
            {
                new SqlParameter("@Content",               model.Content),
                new SqlParameter("@Email",                 model.Email),
                new SqlParameter("@Language",              model.Language),
                new SqlParameter("@Phone",                 model.Phone),
                new SqlParameter("@Subject",               model.Subject),
                new SqlParameter("@Time_Add",              model.Time_Add),
                new SqlParameter("@Time_Update",           model.Time_Update),
                new SqlParameter("@Type_id_InquiryStatus", model.Type_id_InquiryStatus),
                new SqlParameter("@UserName",              model.UserName)
            };

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

            if (obj == null)
            {
                return(1);
            }
            else
            {
                return(Convert.ToInt32(obj));
            }
        }
Beispiel #4
0
        /// <summary>
        /// 得到一个对象实体 by where条件
        /// </summary>
        public Lebi_Inquiry 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_Inquiry);
                }
            }
            Lebi_Inquiry 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_Inquiry", model.id, cachestr, seconds);
                    }
                    return(model);
                }
            }
            return(null);
        }
Beispiel #5
0
 /// <summary>
 /// 安全方式绑定对象表单
 /// </summary>
 public Lebi_Inquiry SafeBindForm(Lebi_Inquiry model)
 {
     if (HttpContext.Current.Request["Content"] != null)
     {
         model.Content = LB.Tools.RequestTool.RequestSafeString("Content");
     }
     if (HttpContext.Current.Request["Email"] != null)
     {
         model.Email = LB.Tools.RequestTool.RequestSafeString("Email");
     }
     if (HttpContext.Current.Request["Language"] != null)
     {
         model.Language = LB.Tools.RequestTool.RequestSafeString("Language");
     }
     if (HttpContext.Current.Request["Phone"] != null)
     {
         model.Phone = LB.Tools.RequestTool.RequestSafeString("Phone");
     }
     if (HttpContext.Current.Request["Subject"] != null)
     {
         model.Subject = LB.Tools.RequestTool.RequestSafeString("Subject");
     }
     if (HttpContext.Current.Request["Time_Add"] != null)
     {
         model.Time_Add = LB.Tools.RequestTool.RequestTime("Time_Add", System.DateTime.Now);
     }
     if (HttpContext.Current.Request["Time_Update"] != null)
     {
         model.Time_Update = LB.Tools.RequestTool.RequestTime("Time_Update", System.DateTime.Now);
     }
     if (HttpContext.Current.Request["Type_id_InquiryStatus"] != null)
     {
         model.Type_id_InquiryStatus = LB.Tools.RequestTool.RequestInt("Type_id_InquiryStatus", 0);
     }
     if (HttpContext.Current.Request["UserName"] != null)
     {
         model.UserName = LB.Tools.RequestTool.RequestSafeString("UserName");
     }
     return(model);
 }
Beispiel #6
0
 /// <summary>
 /// 更新一条数据
 /// </summary>
 public static void Update(Lebi_Inquiry model)
 {
     D_Lebi_Inquiry.Instance.Update(model);
 }
Beispiel #7
0
 /// <summary>
 /// 增加一条数据
 /// </summary>
 public static int Add(Lebi_Inquiry model)
 {
     return(D_Lebi_Inquiry.Instance.Add(model));
 }
Beispiel #8
0
 /// <summary>
 /// 安全方式绑定表单数据
 /// </summary>
 public static Lebi_Inquiry SafeBindForm(Lebi_Inquiry model)
 {
     return(D_Lebi_Inquiry.Instance.SafeBindForm(model));
 }