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

            ojb = dataReader["id"];
            if (ojb != null && ojb != DBNull.Value)
            {
                model.id = Convert.ToInt32(ojb);
            }
            model.Address = dataReader["Address"].ToString();
            ojb           = dataReader["Area_id"];
            if (ojb != null && ojb != DBNull.Value)
            {
                model.Area_id = Convert.ToInt32(ojb);
            }
            model.Email       = dataReader["Email"].ToString();
            model.MobilePhone = dataReader["MobilePhone"].ToString();
            model.Name        = dataReader["Name"].ToString();
            model.Phone       = dataReader["Phone"].ToString();
            model.Postalcode  = dataReader["Postalcode"].ToString();
            model.Say         = dataReader["Say"].ToString();
            ojb = dataReader["User_id"];
            if (ojb != null && ojb != DBNull.Value)
            {
                model.User_id = Convert.ToInt32(ojb);
            }
            return(model);
        }
Exemplo n.º 2
0
        /// <summary>
        /// 更新一条数据
        /// </summary>
        public void Update(Lebi_User_Address model)
        {
            StringBuilder strSql = new StringBuilder();

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

            if (("," + model.UpdateCols + ",").IndexOf(",Address,") > -1 || model.UpdateCols == "")
            {
                cols.Add(LB.DataAccess.DB.BaseUtilsInstance.ColName("Address") + "= @Address");
            }
            if (("," + model.UpdateCols + ",").IndexOf(",Area_id,") > -1 || model.UpdateCols == "")
            {
                cols.Add(LB.DataAccess.DB.BaseUtilsInstance.ColName("Area_id") + "= @Area_id");
            }
            if (("," + model.UpdateCols + ",").IndexOf(",Email,") > -1 || model.UpdateCols == "")
            {
                cols.Add(LB.DataAccess.DB.BaseUtilsInstance.ColName("Email") + "= @Email");
            }
            if (("," + model.UpdateCols + ",").IndexOf(",MobilePhone,") > -1 || model.UpdateCols == "")
            {
                cols.Add(LB.DataAccess.DB.BaseUtilsInstance.ColName("MobilePhone") + "= @MobilePhone");
            }
            if (("," + model.UpdateCols + ",").IndexOf(",Name,") > -1 || model.UpdateCols == "")
            {
                cols.Add(LB.DataAccess.DB.BaseUtilsInstance.ColName("Name") + "= @Name");
            }
            if (("," + model.UpdateCols + ",").IndexOf(",Phone,") > -1 || model.UpdateCols == "")
            {
                cols.Add(LB.DataAccess.DB.BaseUtilsInstance.ColName("Phone") + "= @Phone");
            }
            if (("," + model.UpdateCols + ",").IndexOf(",Postalcode,") > -1 || model.UpdateCols == "")
            {
                cols.Add(LB.DataAccess.DB.BaseUtilsInstance.ColName("Postalcode") + "= @Postalcode");
            }
            if (("," + model.UpdateCols + ",").IndexOf(",Say,") > -1 || model.UpdateCols == "")
            {
                cols.Add(LB.DataAccess.DB.BaseUtilsInstance.ColName("Say") + "= @Say");
            }
            if (("," + model.UpdateCols + ",").IndexOf(",User_id,") > -1 || model.UpdateCols == "")
            {
                cols.Add(LB.DataAccess.DB.BaseUtilsInstance.ColName("User_id") + "= @User_id");
            }
            strSql.Append(string.Join(",", cols));
            strSql.Append(" where id=@id");
            SqlParameter[] parameters =
            {
                new SqlParameter("@id",          model.id),
                new SqlParameter("@Address",     model.Address),
                new SqlParameter("@Area_id",     model.Area_id),
                new SqlParameter("@Email",       model.Email),
                new SqlParameter("@MobilePhone", model.MobilePhone),
                new SqlParameter("@Name",        model.Name),
                new SqlParameter("@Phone",       model.Phone),
                new SqlParameter("@Postalcode",  model.Postalcode),
                new SqlParameter("@Say",         model.Say),
                new SqlParameter("@User_id",     model.User_id)
            };
            LB.DataAccess.DB.Instance.TextExecuteNonQuery(strSql.ToString().Replace(", where id=@id", " where id=@id"), parameters);
        }
Exemplo n.º 3
0
        /// <summary>
        /// 增加一条数据
        /// </summary>
        public int Add(Lebi_User_Address model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("insert into " + TableName + " (");
            strSql.Append(LB.DataAccess.DB.BaseUtilsInstance.ColName("Address") + "," + LB.DataAccess.DB.BaseUtilsInstance.ColName("Area_id") + "," + LB.DataAccess.DB.BaseUtilsInstance.ColName("Email") + "," + LB.DataAccess.DB.BaseUtilsInstance.ColName("MobilePhone") + "," + LB.DataAccess.DB.BaseUtilsInstance.ColName("Name") + "," + LB.DataAccess.DB.BaseUtilsInstance.ColName("Phone") + "," + LB.DataAccess.DB.BaseUtilsInstance.ColName("Postalcode") + "," + LB.DataAccess.DB.BaseUtilsInstance.ColName("Say") + "," + LB.DataAccess.DB.BaseUtilsInstance.ColName("User_id") + ")");
            strSql.Append(" values (");
            strSql.Append("@Address,@Area_id,@Email,@MobilePhone,@Name,@Phone,@Postalcode,@Say,@User_id);select @@identity;");
            SqlParameter[] parameters =
            {
                new SqlParameter("@Address",     model.Address),
                new SqlParameter("@Area_id",     model.Area_id),
                new SqlParameter("@Email",       model.Email),
                new SqlParameter("@MobilePhone", model.MobilePhone),
                new SqlParameter("@Name",        model.Name),
                new SqlParameter("@Phone",       model.Phone),
                new SqlParameter("@Postalcode",  model.Postalcode),
                new SqlParameter("@Say",         model.Say),
                new SqlParameter("@User_id",     model.User_id)
            };

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

            if (obj == null)
            {
                return(1);
            }
            else
            {
                return(Convert.ToInt32(obj));
            }
        }
Exemplo n.º 4
0
        /// <summary>
        /// 得到一个对象实体 by where条件
        /// </summary>
        public Lebi_User_Address 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_Address);
                }
            }
            Lebi_User_Address 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_Address", model.id, cachestr, seconds);
                    }
                    return(model);
                }
            }
            return(null);
        }
Exemplo n.º 5
0
 /// <summary>
 /// 安全方式绑定对象表单
 /// </summary>
 public Lebi_User_Address SafeBindForm(Lebi_User_Address model)
 {
     if (HttpContext.Current.Request["Address"] != null)
     {
         model.Address = LB.Tools.RequestTool.RequestSafeString("Address");
     }
     if (HttpContext.Current.Request["Area_id"] != null)
     {
         model.Area_id = LB.Tools.RequestTool.RequestInt("Area_id", 0);
     }
     if (HttpContext.Current.Request["Email"] != null)
     {
         model.Email = LB.Tools.RequestTool.RequestSafeString("Email");
     }
     if (HttpContext.Current.Request["MobilePhone"] != null)
     {
         model.MobilePhone = LB.Tools.RequestTool.RequestSafeString("MobilePhone");
     }
     if (HttpContext.Current.Request["Name"] != null)
     {
         model.Name = LB.Tools.RequestTool.RequestSafeString("Name");
     }
     if (HttpContext.Current.Request["Phone"] != null)
     {
         model.Phone = LB.Tools.RequestTool.RequestSafeString("Phone");
     }
     if (HttpContext.Current.Request["Postalcode"] != null)
     {
         model.Postalcode = LB.Tools.RequestTool.RequestSafeString("Postalcode");
     }
     if (HttpContext.Current.Request["Say"] != null)
     {
         model.Say = LB.Tools.RequestTool.RequestSafeString("Say");
     }
     if (HttpContext.Current.Request["User_id"] != null)
     {
         model.User_id = LB.Tools.RequestTool.RequestInt("User_id", 0);
     }
     return(model);
 }
Exemplo n.º 6
0
 /// <summary>
 /// 更新一条数据
 /// </summary>
 public static void Update(Lebi_User_Address model)
 {
     D_Lebi_User_Address.Instance.Update(model);
 }
Exemplo n.º 7
0
 /// <summary>
 /// 增加一条数据
 /// </summary>
 public static int Add(Lebi_User_Address model)
 {
     return(D_Lebi_User_Address.Instance.Add(model));
 }
Exemplo n.º 8
0
 /// <summary>
 /// 安全方式绑定表单数据
 /// </summary>
 public static Lebi_User_Address SafeBindForm(Lebi_User_Address model)
 {
     return(D_Lebi_User_Address.Instance.SafeBindForm(model));
 }