Ejemplo n.º 1
0
        public JsonResult Create(UserInfo userInfo) //判断信息填写
        {
            String msg    = "fail";
            Regex  regex1 = new Regex(@"^[0-9]{6,12}$");

            if (regex1.IsMatch(userInfo.UserInfoLoginId))
            {
                return(Json(new { msg = "fail" }, JsonRequestBehavior.AllowGet));
            }
            if (!ValidateName(userInfo.UserInfoLoginId))
            {
                return(Json(new { msg = "exist" }, JsonRequestBehavior.AllowGet));
            }
            if (ModelState.IsValid)
            {
                string pwd = "000000"; //初始密码
                userInfo.UserInfoPwd = Common.Encryption.MD5Helper.Get_MD5(pwd);
                userInfo.Status      = delNormal;

                if (UserInfoService.AddUser(userInfo))
                {
                    msg = "success";
                }
                else
                {
                    msg = "fail";
                }
            }
            return(Json(new { msg }, JsonRequestBehavior.AllowGet));
        }
Ejemplo n.º 2
0
        public ActionResult UserRegister(string loginname, string pwd, string nickname, string phone, string OrganizeInfoList, string PoliticalList)
        {
            if (!ValidateName(loginname))
            {
                return(Content("exist"));
            }
            Regex regex  = new Regex(@"^[A-Za-z0-9]{6,12}$");
            Regex regex1 = new Regex(@"^[0-9]{6,12}$");

            if (!regex.IsMatch(loginname) || regex1.IsMatch(loginname))
            {
                return(Content("fail"));
            }
            //密码
            regex = new Regex(@"^[A-Za-z0-9]{6,12}$");
            if (!regex.IsMatch(pwd))
            {
                return(Content("fail"));
            }
            //昵称
            regex = new Regex(@"^[\u4e00-\u9fa5]{2,15}$");
            if (!regex.IsMatch(nickname))
            {
                return(Content("fail"));
            }
            //电话号码
            regex = new Regex(@"^\d{11}$");
            if (!regex.IsMatch(phone))
            {
                return(Content("fail"));
            }
            UserInfo userInfo = new UserInfo
            {
                UserInfoLoginId   = loginname,
                UserInfoPwd       = Common.Encryption.MD5Helper.Get_MD5(pwd),
                UserInfoShowName  = nickname,
                UserInfoPhone     = phone,
                OrganizeInfoID    = Convert.ToInt32(OrganizeInfoList),
                UpdatePoliticalID = Convert.ToInt32(PoliticalList),
                //默认为群众
                PoliticalID  = 24,
                Status       = delAuditing,
                UserInfoIcon = System.Configuration.ConfigurationManager.AppSettings["DefaultIconPath"],
            };

            if (UserInfoService.AddUser(userInfo))
            {
                return(Content("user"));
            }
            else
            {
                return(Content("fail"));
            }
        }