示例#1
0
            /// <summary>
            /// 增加一条数据
            /// </summary>
            public int Add(Lebi_Admin_Limit model)
            {
                StringBuilder strSql = new StringBuilder();

                strSql.Append("insert into [Lebi_Admin_Limit](");
                strSql.Append("parentid,Code,Name,Sort)");
                strSql.Append(" values (");
                strSql.Append("@parentid,@Code,@Name,@Sort)");
                strSql.Append(";select @@IDENTITY");
                SqlParameter[] parameters =
                {
                    new SqlParameter("@parentid", model.parentid),
                    new SqlParameter("@Code",     model.Code),
                    new SqlParameter("@Name",     model.Name),
                    new SqlParameter("@Sort",     model.Sort)
                };

                object obj = SqlUtils.SqlUtilsInstance.TextExecuteNonQuery(strSql.ToString(), parameters);

                if (obj == null)
                {
                    return(1);
                }
                else
                {
                    return(Convert.ToInt32(obj));
                }
            }
示例#2
0
            /// <summary>
            /// 得到一个对象实体 by SQLpara
            /// </summary>
            public Lebi_Admin_Limit GetModel(SQLPara para)
            {
                StringBuilder strSql = new StringBuilder();

                strSql.Append("select top 1 * from [Lebi_Admin_Limit] ");
                if (para.Where != "")
                {
                    strSql.Append(" where " + para.Where + "");
                }
                Lebi_Admin_Limit model = new Lebi_Admin_Limit();
                DataSet          ds    = SqlUtils.SqlUtilsInstance.TextExecuteDataset(strSql.ToString(), para.Para);

                if (ds.Tables[0].Rows.Count > 0)
                {
                    if (ds.Tables[0].Rows[0]["id"].ToString() != "")
                    {
                        model.id = int.Parse(ds.Tables[0].Rows[0]["id"].ToString());
                    }
                    if (ds.Tables[0].Rows[0]["parentid"].ToString() != "")
                    {
                        model.parentid = int.Parse(ds.Tables[0].Rows[0]["parentid"].ToString());
                    }
                    model.Code = ds.Tables[0].Rows[0]["Code"].ToString();
                    model.Name = ds.Tables[0].Rows[0]["Name"].ToString();
                    if (ds.Tables[0].Rows[0]["Sort"].ToString() != "")
                    {
                        model.Sort = int.Parse(ds.Tables[0].Rows[0]["Sort"].ToString());
                    }
                    return(model);
                }
                else
                {
                    return(null);
                }
            }
示例#3
0
            /// <summary>
            /// 更新一条数据
            /// </summary>
            public void Update(Lebi_Admin_Limit model)
            {
                StringBuilder strSql = new StringBuilder();

                strSql.Append("update [Lebi_Admin_Limit] set ");
                strSql.Append("parentid= @parentid,");
                strSql.Append("Code= @Code,");
                strSql.Append("Name= @Name,");
                strSql.Append("Sort= @Sort");
                strSql.Append(" where id=@id");
                SqlParameter[] parameters =
                {
                    new SqlParameter("@id",       SqlDbType.Int,        4),
                    new SqlParameter("@parentid", SqlDbType.Int,        4),
                    new SqlParameter("@Code",     SqlDbType.VarChar,   50),
                    new SqlParameter("@Name",     SqlDbType.NVarChar, 500),
                    new SqlParameter("@Sort",     SqlDbType.Int, 4)
                };
                parameters[0].Value = model.id;
                parameters[1].Value = model.parentid;
                parameters[2].Value = model.Code;
                parameters[3].Value = model.Name;
                parameters[4].Value = model.Sort;

                SqlUtils.SqlUtilsInstance.TextExecuteNonQuery(strSql.ToString(), parameters);
            }
示例#4
0
        /// <summary>
        /// 编辑权限
        /// </summary>
        public void Admin_limit_Edit()
        {
            if (!EX_Admin.Power("admin_edit", "编辑系统用户"))
            {
                AjaxNoPower();
                return;
            }
            int id = RequestTool.RequestInt("id", 0);
            Lebi_Admin_Limit model = B_Lebi_Admin_Limit.GetModel(id);

            if (model == null)
            {
                model = new Lebi_Admin_Limit();
                model = B_Lebi_Admin_Limit.BindForm(model);
                B_Lebi_Admin_Limit.Add(model);
                string action      = Tag("添加权限分组");
                string description = Shop.Bussiness.Language.Content(Language.RequestString("Name"), "CN");
                Log.Add(action, "Admin_Limit", model.id.ToString(), CurrentAdmin, description);
            }
            else
            {
                model = B_Lebi_Admin_Limit.BindForm(model);
                B_Lebi_Admin_Limit.Update(model);
                string action      = Tag("编辑权限分组");
                string description = Shop.Bussiness.Language.Content(Language.RequestString("Name"), "CN");
                Log.Add(action, "Admin_Limit", model.id.ToString(), CurrentAdmin, description);
            }
            Response.Write("{\"msg\":\"OK\"}");
        }
示例#5
0
        public static bool Power(string code, string name)
        {
            if (RequestTool.GetConfigKey("DemoSite").Trim() == "1" && CurrentAdmin().AdminType != "super")
            {
                return(false);
            }
            List <Lebi_Admin_Power> ps;

            if (HttpContext.Current.Session["admin_power"] == null)
            {
                ps = new List <Lebi_Admin_Power>();
            }
            else
            {
                ps = (List <Lebi_Admin_Power>)HttpContext.Current.Session["admin_power"];
            }

            Lebi_Admin_Power model = (from m in ps
                                      where m.Admin_Limit_Code == code
                                      select m).ToList().FirstOrDefault();

            if (model != null)
            {
                return(true);
            }
            else
            {
                if (name != "")
                {
                    Lebi_Admin_Limit limit = B_Lebi_Admin_Limit.GetModel("Code='" + code + "'");
                    if (limit == null)
                    {
                        limit = B_Lebi_Admin_Limit.GetModel("Code='default'");
                        if (limit == null)
                        {
                            limit          = new Lebi_Admin_Limit();
                            limit.parentid = 0;
                            limit.id       = 1;
                            limit.Code     = "default";
                            limit.Name     = "未分组";
                            B_Lebi_Admin_Limit.Add(limit);
                            limit.id = B_Lebi_Admin_Limit.GetMaxId();
                        }
                        limit.Code     = code;
                        limit.Name     = name;
                        limit.parentid = limit.id;
                        B_Lebi_Admin_Limit.Add(limit);
                    }
                }
            }
            if (CurrentAdmin().AdminType == "super")
            {
                return(true);
            }
            return(false);
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!EX_Admin.Power("admin_limit_edit", "编辑权限"))
            {
                WindowNoPower();
            }
            int id = RequestTool.RequestInt("id", 0);

            model = B_Lebi_Admin_Limit.GetModel(id);
            if (model == null)
            {
                model = new Lebi_Admin_Limit();
            }
        }
示例#7
0
        /// <summary>
        /// 删除一个权限代码
        /// </summary>
        public void Admin_limit_Del()
        {
            if (!EX_Admin.Power("admin_edit", "编辑系统用户"))
            {
                AjaxNoPower();
                return;
            }
            int id = RequestTool.RequestInt("id", 0);
            Lebi_Admin_Limit model       = B_Lebi_Admin_Limit.GetModel(id);
            string           action      = Tag("删除权限分组");
            string           description = Shop.Bussiness.Language.Content(model.Name, "CN");

            Log.Add(action, "Admin_Limit", id.ToString(), CurrentAdmin, description);
            B_Lebi_Admin_Limit.Delete(id);
            Response.Write("{\"msg\":\"OK\"}");
        }
示例#8
0
            /// <summary>
            /// 增加一条数据
            /// </summary>
            public int Add(Lebi_Admin_Limit model)
            {
                StringBuilder strSql = new StringBuilder();

                strSql.Append("insert into [Lebi_Admin_Limit](");
                strSql.Append("[parentid],[Code],[Name],[Sort])");
                strSql.Append(" values (");
                strSql.Append("@parentid,@Code,@Name,@Sort)");
                OleDbParameter[] parameters =
                {
                    new OleDbParameter("@parentid", model.parentid),
                    new OleDbParameter("@Code",     model.Code),
                    new OleDbParameter("@Name",     model.Name),
                    new OleDbParameter("@Sort",     model.Sort)
                };

                AccessUtils.Instance.TextExecuteNonQuery(strSql.ToString(), parameters);
                return(1);
            }
示例#9
0
            /// <summary>
            /// 更新一条数据
            /// </summary>
            public void Update(Lebi_Admin_Limit model)
            {
                StringBuilder strSql = new StringBuilder();

                strSql.Append("update [Lebi_Admin_Limit] set ");
                strSql.Append("[parentid]=@parentid,");
                strSql.Append("[Code]=@Code,");
                strSql.Append("[Name]=@Name,");
                strSql.Append("[Sort]=@Sort");
                strSql.Append(" where id=" + model.id);
                OleDbParameter[] parameters =
                {
                    new OleDbParameter("@parentid", model.parentid),
                    new OleDbParameter("@Code",     model.Code),
                    new OleDbParameter("@Name",     model.Name),
                    new OleDbParameter("@Sort",     model.Sort)
                };

                AccessUtils.Instance.TextExecuteNonQuery(strSql.ToString(), parameters);
            }
示例#10
0
 /// <summary>
 /// 安全方式绑定对象表单
 /// </summary>
 public Lebi_Admin_Limit SafeBindForm(Lebi_Admin_Limit model)
 {
     if (HttpContext.Current.Request["parentid"] != null)
     {
         model.parentid = Shop.Tools.RequestTool.RequestInt("parentid", 0);
     }
     if (HttpContext.Current.Request["Code"] != null)
     {
         model.Code = Shop.Tools.RequestTool.RequestSafeString("Code");
     }
     if (HttpContext.Current.Request["Name"] != null)
     {
         model.Name = Shop.Tools.RequestTool.RequestSafeString("Name");
     }
     if (HttpContext.Current.Request["Sort"] != null)
     {
         model.Sort = Shop.Tools.RequestTool.RequestInt("Sort", 0);
     }
     return(model);
 }
示例#11
0
            /// <summary>
            /// 得到一个对象实体 by id
            /// </summary>
            public Lebi_Admin_Limit GetModel(int id)
            {
                StringBuilder strSql = new StringBuilder();

                strSql.Append("select  top 1  * from [Lebi_Admin_Limit] ");
                strSql.Append(" where id=@id");
                SqlParameter[] parameters =
                {
                    new SqlParameter("@id", SqlDbType.Int, 4)
                };
                parameters[0].Value = id;

                Lebi_Admin_Limit model = new Lebi_Admin_Limit();
                DataSet          ds    = SqlUtils.SqlUtilsInstance.TextExecuteDataset(strSql.ToString(), parameters);

                if (ds.Tables[0].Rows.Count > 0)
                {
                    if (ds.Tables[0].Rows[0]["id"].ToString() != "")
                    {
                        model.id = int.Parse(ds.Tables[0].Rows[0]["id"].ToString());
                    }
                    if (ds.Tables[0].Rows[0]["parentid"].ToString() != "")
                    {
                        model.parentid = int.Parse(ds.Tables[0].Rows[0]["parentid"].ToString());
                    }
                    model.Code = ds.Tables[0].Rows[0]["Code"].ToString();
                    model.Name = ds.Tables[0].Rows[0]["Name"].ToString();
                    if (ds.Tables[0].Rows[0]["Sort"].ToString() != "")
                    {
                        model.Sort = int.Parse(ds.Tables[0].Rows[0]["Sort"].ToString());
                    }
                    return(model);
                }
                else
                {
                    return(null);
                }
            }
示例#12
0
            /// <summary>
            /// 对象实体绑定数据
            /// </summary>
            public Lebi_Admin_Limit ReaderBind(IDataReader dataReader)
            {
                Lebi_Admin_Limit model = new Lebi_Admin_Limit();
                object           ojb;

                ojb = dataReader["id"];
                if (ojb != null && ojb != DBNull.Value)
                {
                    model.id = (int)ojb;
                }
                ojb = dataReader["parentid"];
                if (ojb != null && ojb != DBNull.Value)
                {
                    model.parentid = (int)ojb;
                }
                model.Code = dataReader["Code"].ToString();
                model.Name = dataReader["Name"].ToString();
                ojb        = dataReader["Sort"];
                if (ojb != null && ojb != DBNull.Value)
                {
                    model.Sort = (int)ojb;
                }
                return(model);
            }
示例#13
0
        /// <summary>
        /// 编辑权限代码
        /// </summary>
        public void AdminLimit_Edit()
        {
            if (!EX_Admin.Power("admin_edit", "编辑系统用户"))
            {
                AjaxNoPower();
                return;
            }
            int id = RequestTool.RequestInt("id", 0);
            Lebi_Admin_Limit model = B_Lebi_Admin_Limit.GetModel(id);

            if (model == null)
            {
                Response.Write("{\"msg\":\"" + Tag("参数错误") + "\"}");
                return;
            }
            model.Name     = RequestTool.RequestString("name");
            model.parentid = RequestTool.RequestInt("parentid", 0);
            B_Lebi_Admin_Limit.Update(model);
            string action      = Tag("编辑系统用户权限");
            string description = RequestTool.RequestString("name");

            Log.Add(action, "Admin_Limit", model.id.ToString(), CurrentAdmin, description);
            Response.Write("{\"msg\":\"OK\"}");
        }
示例#14
0
 /// <summary>
 /// 更新一条数据
 /// </summary>
 public static void Update(Lebi_Admin_Limit model)
 {
     D_Lebi_Admin_Limit.Instance.Update(model);
 }
示例#15
0
 /// <summary>
 /// 增加一条数据
 /// </summary>
 public static int Add(Lebi_Admin_Limit model)
 {
     return(D_Lebi_Admin_Limit.Instance.Add(model));
 }
示例#16
0
 /// <summary>
 /// 安全方式绑定表单数据
 /// </summary>
 public static Lebi_Admin_Limit SafeBindForm(Lebi_Admin_Limit model)
 {
     return(D_Lebi_Admin_Limit.Instance.SafeBindForm(model));
 }