示例#1
0
        public JsonResult EditUser(int id, string txt_user_name, string txt_mobile, string txt_email, string txt_nick_name, string txt_password)
        {
            HibernatingRhinos.Profiler.Appender.NHibernate.NHibernateProfiler.Initialize();
            Common.Json     json   = new Common.Json();
            DAO.BLL.B_Users b_user = new DAO.BLL.B_Users();
            var             m_user = b_user.GetUser(id);

            if (m_user.user_name != txt_user_name)
            {
                List <SearchTemplate> st = new List <SearchTemplate>()
                {
                    new SearchTemplate()
                    {
                        key = "user_name", value = txt_user_name, searchType = Common.EnumBase.SearchType.Eq
                    },
                };
                var res = b_user.GetCount(st);
                if (res > 0)
                {
                    json.status  = -1;
                    json.msg     = "用户名已存在!";
                    json.pitchId = "txt_user_name";
                    return(Json(json));
                }
            }
            if (m_user.mobile != txt_mobile)
            {
                List <SearchTemplate> st = new List <SearchTemplate>()
                {
                    new SearchTemplate()
                    {
                        key = "mobile", value = txt_mobile, searchType = Common.EnumBase.SearchType.Eq
                    },
                };
                var res = b_user.GetCount(st);
                if (res > 0)
                {
                    json.status  = -1;
                    json.msg     = "手机号已存在!";
                    json.pitchId = "txt_mobile";
                    return(Json(json));
                }
            }
            m_user.user_name = txt_user_name;
            m_user.mobile    = txt_mobile;
            if (m_user.password != txt_password)
            {
                m_user.password = Common.Encrypt.md5(txt_password);
            }
            m_user.email     = txt_email;
            m_user.nick_name = txt_nick_name;
            b_user.Update(m_user);
            json.msg = "修改成功!";
            return(Json(json));
        }
示例#2
0
 public JsonResult DelUser(string ids)
 {
     Common.Json     json   = new Common.Json();
     DAO.BLL.B_Users b_user = new DAO.BLL.B_Users();
     foreach (var id in ids.Split(new char[] { ',' }))
     {
         b_user.Delete(Convert.ToInt32(id));
     }
     json.msg = "成功删除" + ids.Split(new char[] { ',' }).Length + "条记录!";
     return(Json(json));
 }
示例#3
0
        public JsonResult AddUser(string txt_user_name, string txt_mobile, string txt_email, string txt_nick_name, string txt_password)
        {
            Common.Json           json   = new Common.Json();
            DAO.BLL.B_Users       b_user = new DAO.BLL.B_Users();
            List <SearchTemplate> st     = new List <SearchTemplate>()
            {
                new SearchTemplate()
                {
                    key = "user_name", value = txt_user_name, searchType = Common.EnumBase.SearchType.Eq
                },
            };
            var res = b_user.GetCount(st);

            if (res > 0)
            {
                json.status  = -1;
                json.msg     = "用户名已存在!";
                json.pitchId = "txt_user_name";
                return(Json(json));
            }
            st = new List <SearchTemplate>()
            {
                new SearchTemplate()
                {
                    key = "mobile", value = txt_mobile, searchType = Common.EnumBase.SearchType.Eq
                },
            };
            res = b_user.GetCount(st);
            if (res > 0)
            {
                json.status  = -1;
                json.msg     = "手机号已存在!";
                json.pitchId = "txt_mobile";
                return(Json(json));
            }
            Domain.Users m_user = new Domain.Users();
            m_user.user_name = txt_user_name;
            m_user.mobile    = txt_mobile;
            m_user.password  = Common.Encrypt.md5(txt_password);
            m_user.email     = txt_email;
            m_user.nick_name = txt_nick_name;
            res = b_user.Save(m_user);
            if (res <= 0)
            {
                json.status = -1;
                json.msg    = "添加失败!";
                return(Json(json));
            }
            json.msg = "添加成功!";
            return(Json(json));
        }