Ejemplo n.º 1
0
        public ActionResult Add(hx_td_adminuser t)
        {
            var userpass = t.userpass;

            t = (hx_td_adminuser)Utils.ValidateModelClass(t);

            //  t.userpass = DESEncrypt.Encrypt(userpass.Trim(), ConfigurationManager.AppSettings["KEYS"].ToString());

            t.userpass      = Utils.MD5(userpass.Trim());
            t.province      = "0";
            t.city          = "0";
            t.email         = "";
            t.datetime      = DateTime.Now;
            t.lastLoginTime = DateTime.Now;
            t.loginTimes    = 0;
            t.area_id       = 0;

            ef.hx_td_adminuser.Add(t);

            int id = ef.SaveChanges();

            if (id > 0)
            {
                return(Content(StringAlert.Alert("操作成功", "/admin/AdminUser/index"), "text/html"));
            }
            else
            {
                return(Content(StringAlert.Alert("操作失败"), "text/html"));
            }
        }
Ejemplo n.º 2
0
        public ActionResult Editor(hx_td_adminuser p)
        {
            string[] proNames;
            if (string.IsNullOrEmpty(p.userpass))
            {
                proNames = new string[] { "trueName", "worknum", "sex", "tel", "phone_number", "department_id", "state" };
            }
            else
            {
                p.userpass = Utils.MD5(p.userpass);
                proNames   = new string[] { "trueName", "worknum", "sex", "tel", "phone_number", "department_id", "state", "userpass" };
            }
            p = (hx_td_adminuser)Utils.ValidateModelClass(p);


            DbEntityEntry entry = ef.Entry <hx_td_adminuser>(p);

            entry.State = EntityState.Unchanged;

            foreach (string ProName in proNames)
            {
                entry.Property(ProName).IsModified = true;
            }
            int i = ef.SaveChanges();

            if (i > 0)
            {
                return(Content(StringAlert.Alert("操作成功", "/admin/AdminUser/index"), "text/html"));
            }
            else
            {
                return(Content(StringAlert.Alert("操作失败"), "text/html"));
            }
        }
Ejemplo n.º 3
0
        public ActionResult Editor(int id)
        {
            hx_td_adminuser model = (from a in ef.hx_td_adminuser where a.adminuserid == id select a).SingleOrDefault();

            ViewBag.department = new SelectListByEF().GetDepartmentDropDownList(0, "0", "请选择");
            ViewBag.id         = id;

            return(View(model));
        }
Ejemplo n.º 4
0
        public ActionResult UserLimit(int userid)
        {
            Dictionary <int, List <hx_AdminLimitInfo> > dic = new Dictionary <int, List <hx_AdminLimitInfo> >();
            hx_td_adminuser user = (from u in ef.hx_td_adminuser where u.adminuserid == userid select u).SingleOrDefault();

            if (user == null || user.adminuserid < 1)
            {
                return(Content(StringAlert.Alert("没有找到相关的用户信息!"), "text/html"));
            }
            ////var sql = string.Format("", user.department_id);
            //StringBuilder sql = new StringBuilder();
            //sql.Append("WITH treeTB(id) as(");
            //sql.AppendFormat("select limitId from hx_DepUserLimit where departmentId='{0}' ", user.department_id);
            //sql.Append(" union all ");
            //sql.Append("select ParentId from hx_AdminLimitInfo inner join treeTB ON hx_AdminLimitInfo.id=treeTB.id)");
            //sql.Append("select * from treeTB;");
            //DataTable dt = DbHelperSQL.GET_DataTable_List(sql.ToString());

            //if (dt != null && dt.Rows.Count > 0)
            //{
            //    string ids = "";
            //    foreach (DataRow dr in dt.Rows)
            //    {
            //        if (ids.Length>0)
            //        {
            //            ids = ids + ",";
            //        }
            //        ids = ids + dr["id"].ToString();
            //    }

            //    List<IGrouping<int, hx_AdminLimitInfo>> groupList = ef.hx_AdminLimitInfo.Where(a => a.isDel == 0 && ids.Contains(a.id.ToString())).GroupBy(m => m.ParentId).ToList();
            //    dic = new Dictionary<int, List<hx_AdminLimitInfo>>();


            //    if (groupList != null && groupList.Count() > 0)
            //    {
            //        foreach (var item in groupList)
            //        {
            //            dic.Add(item.Key, item.ToList());
            //        }
            //    }
            //}
            dic = new ChuanglitouP2P.BLL.EF.UserLimitByEF().GetDepartmentLimit((int)user.department_id);


            ViewBag.userid        = userid;
            ViewBag.department_id = user.department_id;

            return(View(dic));
        }
Ejemplo n.º 5
0
        public ActionResult GetUserLeftLimit()
        {
            var userid = Utils.GetAdmUserID();
            Dictionary <int, List <hx_AdminLimitInfo> > dic = new Dictionary <int, List <hx_AdminLimitInfo> >();
            hx_td_adminuser user = (from u in ef.hx_td_adminuser where u.adminuserid == userid select u).SingleOrDefault();

            //var sql = string.Format("", user.department_id);
            StringBuilder sql = new StringBuilder();

            sql.Append("WITH treeTB(id) as(");
            sql.AppendFormat("select limitId from hx_DepUserLimit where departmentId='{0}' ", user.department_id);
            sql.Append(" union all ");
            sql.Append("select ParentId from hx_AdminLimitInfo inner join treeTB ON hx_AdminLimitInfo.id=treeTB.id)");
            sql.Append("select * from treeTB;");
            DataTable dt = DbHelperSQL.GET_DataTable_List(sql.ToString());

            if (dt != null && dt.Rows.Count > 0)
            {
                string ids = "";
                foreach (DataRow dr in dt.Rows)
                {
                    if (ids.Length > 0)
                    {
                        ids = ids + ",";
                    }
                    ids = ids + dr["id"].ToString();
                }

                List <IGrouping <int, hx_AdminLimitInfo> > groupList = ef.hx_AdminLimitInfo.Where(a => a.isDel == 0 && ids.Contains(a.id.ToString()) && a.level < 4).GroupBy(m => m.ParentId).ToList();
                dic = new Dictionary <int, List <hx_AdminLimitInfo> >();


                if (groupList != null && groupList.Count() > 0)
                {
                    foreach (var item in groupList)
                    {
                        dic.Add(item.Key, item.ToList());
                    }
                }
            }

            return(View(dic));
        }