예제 #1
0
 /// <summary>
 /// 安全方式绑定对象表单
 /// </summary>
 public Lebi_Agent_Area SafeBindForm(Lebi_Agent_Area model)
 {
     if (HttpContext.Current.Request["Admin_id"] != null)
     {
         model.Admin_id = LB.Tools.RequestTool.RequestInt("Admin_id", 0);
     }
     if (HttpContext.Current.Request["Admin_UserName"] != null)
     {
         model.Admin_UserName = LB.Tools.RequestTool.RequestSafeString("Admin_UserName");
     }
     if (HttpContext.Current.Request["Area_id"] != null)
     {
         model.Area_id = LB.Tools.RequestTool.RequestInt("Area_id", 0);
     }
     if (HttpContext.Current.Request["CardOrder_id"] != null)
     {
         model.CardOrder_id = LB.Tools.RequestTool.RequestInt("CardOrder_id", 0);
     }
     if (HttpContext.Current.Request["Commission_1"] != null)
     {
         model.Commission_1 = LB.Tools.RequestTool.RequestDecimal("Commission_1", 0);
     }
     if (HttpContext.Current.Request["Commission_2"] != null)
     {
         model.Commission_2 = LB.Tools.RequestTool.RequestDecimal("Commission_2", 0);
     }
     if (HttpContext.Current.Request["IsFailure"] != null)
     {
         model.IsFailure = LB.Tools.RequestTool.RequestInt("IsFailure", 0);
     }
     if (HttpContext.Current.Request["Price"] != null)
     {
         model.Price = LB.Tools.RequestTool.RequestDecimal("Price", 0);
     }
     if (HttpContext.Current.Request["Remark"] != null)
     {
         model.Remark = LB.Tools.RequestTool.RequestSafeString("Remark");
     }
     if (HttpContext.Current.Request["Time_add"] != null)
     {
         model.Time_add = LB.Tools.RequestTool.RequestTime("Time_add", System.DateTime.Now);
     }
     if (HttpContext.Current.Request["Time_end"] != null)
     {
         model.Time_end = LB.Tools.RequestTool.RequestTime("Time_end", System.DateTime.Now);
     }
     if (HttpContext.Current.Request["User_id"] != null)
     {
         model.User_id = LB.Tools.RequestTool.RequestInt("User_id", 0);
     }
     if (HttpContext.Current.Request["User_UserName"] != null)
     {
         model.User_UserName = LB.Tools.RequestTool.RequestSafeString("User_UserName");
     }
     return(model);
 }
예제 #2
0
        /// <summary>
        /// 得到一个对象实体 by where条件
        /// </summary>
        public Lebi_Agent_Area 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_Agent_Area);
                }
            }
            Lebi_Agent_Area 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_Agent_Area", model.id, cachestr, seconds);
                    }
                    return(model);
                }
            }
            return(null);
        }
예제 #3
0
        /// <summary>
        /// 增加一条数据
        /// </summary>
        public int Add(Lebi_Agent_Area model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("insert into " + TableName + " (");
            strSql.Append(LB.DataAccess.DB.BaseUtilsInstance.ColName("Admin_id") + "," + LB.DataAccess.DB.BaseUtilsInstance.ColName("Admin_UserName") + "," + LB.DataAccess.DB.BaseUtilsInstance.ColName("Area_id") + "," + LB.DataAccess.DB.BaseUtilsInstance.ColName("CardOrder_id") + "," + LB.DataAccess.DB.BaseUtilsInstance.ColName("Commission_1") + "," + LB.DataAccess.DB.BaseUtilsInstance.ColName("Commission_2") + "," + LB.DataAccess.DB.BaseUtilsInstance.ColName("IsFailure") + "," + LB.DataAccess.DB.BaseUtilsInstance.ColName("Price") + "," + LB.DataAccess.DB.BaseUtilsInstance.ColName("Remark") + "," + LB.DataAccess.DB.BaseUtilsInstance.ColName("Time_add") + "," + LB.DataAccess.DB.BaseUtilsInstance.ColName("Time_end") + "," + LB.DataAccess.DB.BaseUtilsInstance.ColName("User_id") + "," + LB.DataAccess.DB.BaseUtilsInstance.ColName("User_UserName") + ")");
            strSql.Append(" values (");
            strSql.Append("@Admin_id,@Admin_UserName,@Area_id,@CardOrder_id,@Commission_1,@Commission_2,@IsFailure,@Price,@Remark,@Time_add,@Time_end,@User_id,@User_UserName);select @@identity;");
            SqlParameter[] parameters =
            {
                new SqlParameter("@Admin_id",       model.Admin_id),
                new SqlParameter("@Admin_UserName", model.Admin_UserName),
                new SqlParameter("@Area_id",        model.Area_id),
                new SqlParameter("@CardOrder_id",   model.CardOrder_id),
                new SqlParameter("@Commission_1",   model.Commission_1),
                new SqlParameter("@Commission_2",   model.Commission_2),
                new SqlParameter("@IsFailure",      model.IsFailure),
                new SqlParameter("@Price",          model.Price),
                new SqlParameter("@Remark",         model.Remark),
                new SqlParameter("@Time_add",       model.Time_add),
                new SqlParameter("@Time_end",       model.Time_end),
                new SqlParameter("@User_id",        model.User_id),
                new SqlParameter("@User_UserName",  model.User_UserName)
            };

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

            if (obj == null)
            {
                return(1);
            }
            else
            {
                return(Convert.ToInt32(obj));
            }
        }
예제 #4
0
 /// <summary>
 /// 更新一条数据
 /// </summary>
 public static void Update(Lebi_Agent_Area model)
 {
     D_Lebi_Agent_Area.Instance.Update(model);
 }
예제 #5
0
 /// <summary>
 /// 增加一条数据
 /// </summary>
 public static int Add(Lebi_Agent_Area model)
 {
     return(D_Lebi_Agent_Area.Instance.Add(model));
 }
예제 #6
0
 /// <summary>
 /// 安全方式绑定表单数据
 /// </summary>
 public static Lebi_Agent_Area SafeBindForm(Lebi_Agent_Area model)
 {
     return(D_Lebi_Agent_Area.Instance.SafeBindForm(model));
 }
예제 #7
0
        /// <summary>
        /// 对象实体绑定数据
        /// </summary>
        public Lebi_Agent_Area ReaderBind(IDataReader dataReader)
        {
            Lebi_Agent_Area model = new Lebi_Agent_Area();
            object          ojb;

            ojb = dataReader["id"];
            if (ojb != null && ojb != DBNull.Value)
            {
                model.id = Convert.ToInt32(ojb);
            }
            ojb = dataReader["Admin_id"];
            if (ojb != null && ojb != DBNull.Value)
            {
                model.Admin_id = Convert.ToInt32(ojb);
            }
            model.Admin_UserName = dataReader["Admin_UserName"].ToString();
            ojb = dataReader["Area_id"];
            if (ojb != null && ojb != DBNull.Value)
            {
                model.Area_id = Convert.ToInt32(ojb);
            }
            ojb = dataReader["CardOrder_id"];
            if (ojb != null && ojb != DBNull.Value)
            {
                model.CardOrder_id = Convert.ToInt32(ojb);
            }
            ojb = dataReader["Commission_1"];
            if (ojb != null && ojb != DBNull.Value)
            {
                model.Commission_1 = (decimal)ojb;
            }
            ojb = dataReader["Commission_2"];
            if (ojb != null && ojb != DBNull.Value)
            {
                model.Commission_2 = (decimal)ojb;
            }
            ojb = dataReader["IsFailure"];
            if (ojb != null && ojb != DBNull.Value)
            {
                model.IsFailure = Convert.ToInt32(ojb);
            }
            ojb = dataReader["Price"];
            if (ojb != null && ojb != DBNull.Value)
            {
                model.Price = (decimal)ojb;
            }
            model.Remark = dataReader["Remark"].ToString();
            ojb          = dataReader["Time_add"];
            if (ojb != null && ojb != DBNull.Value)
            {
                model.Time_add = (DateTime)ojb;
            }
            ojb = dataReader["Time_end"];
            if (ojb != null && ojb != DBNull.Value)
            {
                model.Time_end = (DateTime)ojb;
            }
            ojb = dataReader["User_id"];
            if (ojb != null && ojb != DBNull.Value)
            {
                model.User_id = Convert.ToInt32(ojb);
            }
            model.User_UserName = dataReader["User_UserName"].ToString();
            return(model);
        }
예제 #8
0
        /// <summary>
        /// 更新一条数据
        /// </summary>
        public void Update(Lebi_Agent_Area model)
        {
            StringBuilder strSql = new StringBuilder();

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

            if (("," + model.UpdateCols + ",").IndexOf(",Admin_id,") > -1 || model.UpdateCols == "")
            {
                cols.Add(LB.DataAccess.DB.BaseUtilsInstance.ColName("Admin_id") + "= @Admin_id");
            }
            if (("," + model.UpdateCols + ",").IndexOf(",Admin_UserName,") > -1 || model.UpdateCols == "")
            {
                cols.Add(LB.DataAccess.DB.BaseUtilsInstance.ColName("Admin_UserName") + "= @Admin_UserName");
            }
            if (("," + model.UpdateCols + ",").IndexOf(",Area_id,") > -1 || model.UpdateCols == "")
            {
                cols.Add(LB.DataAccess.DB.BaseUtilsInstance.ColName("Area_id") + "= @Area_id");
            }
            if (("," + model.UpdateCols + ",").IndexOf(",CardOrder_id,") > -1 || model.UpdateCols == "")
            {
                cols.Add(LB.DataAccess.DB.BaseUtilsInstance.ColName("CardOrder_id") + "= @CardOrder_id");
            }
            if (("," + model.UpdateCols + ",").IndexOf(",Commission_1,") > -1 || model.UpdateCols == "")
            {
                cols.Add(LB.DataAccess.DB.BaseUtilsInstance.ColName("Commission_1") + "= @Commission_1");
            }
            if (("," + model.UpdateCols + ",").IndexOf(",Commission_2,") > -1 || model.UpdateCols == "")
            {
                cols.Add(LB.DataAccess.DB.BaseUtilsInstance.ColName("Commission_2") + "= @Commission_2");
            }
            if (("," + model.UpdateCols + ",").IndexOf(",IsFailure,") > -1 || model.UpdateCols == "")
            {
                cols.Add(LB.DataAccess.DB.BaseUtilsInstance.ColName("IsFailure") + "= @IsFailure");
            }
            if (("," + model.UpdateCols + ",").IndexOf(",Price,") > -1 || model.UpdateCols == "")
            {
                cols.Add(LB.DataAccess.DB.BaseUtilsInstance.ColName("Price") + "= @Price");
            }
            if (("," + model.UpdateCols + ",").IndexOf(",Remark,") > -1 || model.UpdateCols == "")
            {
                cols.Add(LB.DataAccess.DB.BaseUtilsInstance.ColName("Remark") + "= @Remark");
            }
            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_end,") > -1 || model.UpdateCols == "")
            {
                cols.Add(LB.DataAccess.DB.BaseUtilsInstance.ColName("Time_end") + "= @Time_end");
            }
            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_UserName,") > -1 || model.UpdateCols == "")
            {
                cols.Add(LB.DataAccess.DB.BaseUtilsInstance.ColName("User_UserName") + "= @User_UserName");
            }
            strSql.Append(string.Join(",", cols));
            strSql.Append(" where id=@id");
            SqlParameter[] parameters =
            {
                new SqlParameter("@id",             model.id),
                new SqlParameter("@Admin_id",       model.Admin_id),
                new SqlParameter("@Admin_UserName", model.Admin_UserName),
                new SqlParameter("@Area_id",        model.Area_id),
                new SqlParameter("@CardOrder_id",   model.CardOrder_id),
                new SqlParameter("@Commission_1",   model.Commission_1),
                new SqlParameter("@Commission_2",   model.Commission_2),
                new SqlParameter("@IsFailure",      model.IsFailure),
                new SqlParameter("@Price",          model.Price),
                new SqlParameter("@Remark",         model.Remark),
                new SqlParameter("@Time_add",       model.Time_add),
                new SqlParameter("@Time_end",       model.Time_end),
                new SqlParameter("@User_id",        model.User_id),
                new SqlParameter("@User_UserName",  model.User_UserName)
            };
            LB.DataAccess.DB.Instance.TextExecuteNonQuery(strSql.ToString().Replace(", where id=@id", " where id=@id"), parameters);
        }