public Dictionary <string, object> CreateUser(BaseUser model)
        {
            if (model.UserId == 0)
            {
                model.CreateUserId   = ManageProvider.Provider.Current().UserId;
                model.CreateUserName = ManageProvider.Provider.Current().Account;
                model.Enabled        = 1;
                model.CreateTime     = DateTime.Now;
                model.UserPassword   = model.Mobile.Substring(5);
                model.UserPassword   = Md5Helper.MD5(DESEncrypt.Encrypt(model.UserPassword.ToLower(), "qwertyui"));

                return(UserBll.AddUser(model));
            }
            else
            {
                var model1 = UserBll.GetModel(model.UserId);
                model1.ModifyUserId   = ManageProvider.Provider.Current().UserId;
                model1.ModifyUserName = ManageProvider.Provider.Current().Account;
                model1.Account        = model.Account;
                model1.Telephone      = model1.Telephone;
                model1.Email          = model.Email;
                model1.Remark         = model.Remark;
                model.ModifyDate      = DateTime.Now;
                return(UserBll.EditUser(model1));
            }
        }
Ejemplo n.º 2
0
        public async Task <IActionResult> SaveUser()
        {
            UserInfo user = new UserInfo();

            user.UserName = Request.Form["UserName"].TryToString();
            string Password = Request.Form["Password"].TryToString();

            user.CreateTime = DateTime.Now;
            user.Name       = Request.Form["Name"].TryToString();
            user.TelPhone   = Request.Form["TelPhone"].TryToString();
            user.RoleID     = Request.Form["RoleID"].TryToInt();
            user.ID         = Request.Form["ID"].TryToInt();
            UserBll bll = new UserBll();

            if (user.ID > 0)
            {
                bool flag = await bll.Update(user, Password);

                if (flag)
                {
                    return(Json(new { code = 1, msg = "成功" }));
                }
            }
            else
            {
                int id = await bll.AddUser(user, Password);

                if (id > 0)
                {
                    return(Json(new { code = 1, msg = "成功" }));
                }
            }

            return(Json(new { code = 0, msg = "失败" }));
        }
Ejemplo n.º 3
0
        public string AddUser(UserEntity userEntity, string Pwd)
        {
            UserBll userBll = new UserBll();

            userEntity.Photo = "/Content/img/photo/photo16.jpg";
            int result = userBll.AddUser(userEntity, Pwd);

            return(result.ToString());
        }
Ejemplo n.º 4
0
        /// <summary>
        /// 注册功能
        /// </summary>
        public JsonResult UserRegist(UserAddRequest userAddRequest)
        {
            var res = bll.AddUser(userAddRequest);

            //GET请求返回
            //return Json(res,JsonRequestBehavior.AllowGet);

            //POST请求返回
            return(Json(res));
        }
Ejemplo n.º 5
0
        //protected void btnSendSMS_OnClick(object sender, EventArgs e)
        //{

        //}
        protected void btnRegister_OnClick(object sender, EventArgs e)
        {
            var user = new Ye_User()
            {
                Address       = tbxAddress.Text.Trim(),
                UserName      = tbxName.Text.Trim(),
                Zip           = tbxZip.Text.Trim(),
                AptSuite      = tbxAptSuite.Text.Trim(),
                Mobile        = tbxPhone.Text.Trim(),
                Password      = DESUtil.Encrypt(tbxPassword.Text.Trim()),
                Email         = tbxEmail.Text.Trim(),
                FaceBookID    = "",
                QQ            = "",
                WxID          = "",
                Status        = 0,
                LastLoginTime = DateTime.Now,
                RegisterTime  = DateTime.Now
            };

            if (UserBll.GetUsers().SingleOrDefault(u => u.UserName == user.UserName) != null)
            {
                WebUtil.Alert("The username is used,please change a new username.");//当前用户已经存在!请使用其他用户名注册!
                return;
            }
            if (UserBll.AddUser(user))
            {
                Session["YeUser"] = UserBll.Login(user.UserName, user.Password);
                if (Request.Cookies["location"] == null)
                {
                    var cookie = new HttpCookie("location", user.Address);
                    cookie.Expires = DateTime.MaxValue;
                    Response.Cookies.Add(cookie);
                }
                else
                {
                    Response.Cookies["location"].Value = user.Address;
                }
                if (Request.Cookies["username"] == null)
                {
                    var cookie = new HttpCookie("username", user.UserName);
                    cookie.Expires = DateTime.MaxValue;
                    Response.Cookies.Add(cookie);
                }
                else
                {
                    Request.Cookies["username"].Value = user.UserName;
                }
                WebUtil.AlertAndRedirect("Register successfully", "Home.aspx");
            }
            else
            {
                WebUtil.Alert("Failed to register.");
            }
        }
Ejemplo n.º 6
0
        public ActionResult Add(UserModel user, string BtnSubmit)
        {
            UserDTO userDTO = new UserDTO()
            {
                Age = user.Age, Name = user.Name, Password = user.Password
            };

            if (BtnSubmit == "AddNew")
            {
                userBll.AddUser(userDTO);
            }
            else if (BtnSubmit == "Cancel")
            {
            }
            return(Redirect("~/User/List"));
        }
Ejemplo n.º 7
0
 public IActionResult Register(RegisterViewModel model)
 {
     if (ModelState.IsValid)
     {
         new PasswordHasher <string>().HashPassword(null, model.Password);
         var user = new User
         {
             UserName     = model.Id,
             PasswordHash = new PasswordHasher <string>().HashPassword(null, model.Password),
             Email        = model.Email
         };
         if (_userBll.AddUser(user))
         {
             RedirectToAction("Index", "Home");
         }
     }
     return(View(model));
 }
Ejemplo n.º 8
0
        /// <summary>
        /// 添加
        /// 修改
        /// ui - bll -dal
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void Button_Add_Click(object sender, EventArgs e)
        {
            UserModel model = new UserModel();

            model.UserName    = TextBox_UserName.Text;
            model.Account     = TextBox_Account.Text;
            model.CheckInTime = Convert.ToDateTime(TextBox_Born.Text);
            model.AlertTime   = DateTime.Now;
            model.PassWord    = TextBox_Password.Text;
            model.Phone       = TextBox_Phone.Text;
            model.Email       = TextBox_Email.Text;
            model.RoleId      = 1;
            model.IsDelete    = 0;
            //获取性别的值
            model.Sex = Convert.ToInt32(radlSex.SelectedItem.Value);
            UserBll bll    = new UserBll();
            int     result = 0;

            //与数据库进行交互
            if (Request.QueryString["id"] == null)
            {
                result = bll.AddUser(model);
            }
            else
            {
                //获取浏览器地址上的id
                model.UserID = Convert.ToInt32(Request.QueryString["id"]);
                //然后调用更新方法,更新model
                result = bll.UpdateUser(model);
            }
            if (result > 0)
            {
                if (result == 100)
                {
                    ClientScript.RegisterStartupScript(GetType(), "", "alert('添加的用户已经存在!')", true);
                    return;
                }
                ClientScript.RegisterStartupScript(GetType(), "", "alert('保存成功!');window.location = 'UserList.aspx';", true);
            }
            else
            {
                ClientScript.RegisterStartupScript(GetType(), "", "alert('保存失败!');", true);
            }
        }
Ejemplo n.º 9
0
        public ActionResult Create(FormCollection collection)
        {
            var model = new sysuser();

            this.TryUpdateModel <sysuser>(model);
            var bll = new UserBll();

            try
            {
                bll.AddUser(model);
            }
            catch (ValidException ex)
            {
                this.ModelState.AddModelError(ex.Name, ex.Message);
                return(View(model));
            }

            return(this.RefreshParent());
        }
Ejemplo n.º 10
0
        protected void imgBtn_OnClick(object sender, ImageClickEventArgs e)
        {
            var user = new Ye_User()
            {
                Address  = tbxAddress.Text.Trim(),
                UserName = tbxFirstName.Text.Trim() + " " + tbxLastName.Text.Trim(),
                //Zip =  tbxZip.Text.Trim(),
                //Aptsuite = tbxAptSuite.Text.Trim(),
                Mobile        = tbxMobile.Text.Trim(),
                Password      = DESUtil.Encrypt(tbxPwd1.Text.Trim()),
                Email         = tbxEmail.Text.Trim(),
                FaceBookID    = "",
                QQ            = "",
                WxID          = "",
                Status        = 0,
                Zip           = "",
                AptSuite      = "",
                LastLoginTime = DateTime.Now,
                RegisterTime  = DateTime.Now
            };

            if (UserBll.GetUsers().SingleOrDefault(u => u.UserName == user.UserName) != null)
            {
                WebUtil.Alert("当前用户已经存在!请使用其他用户名注册!");
                return;
            }
            if (UserBll.AddUser(user))
            {
                Session["YeUser"] = UserBll.Login(user.UserName, user.Password);
                Response.Redirect("Home.aspx");
            }
            else
            {
                WebUtil.Alert("注册失败!");
            }
        }
Ejemplo n.º 11
0
        /// <summary>
        /// 用户注册
        /// </summary>

        public JsonResult AddUser(UserRequest userRequest)
        {
            return(Json(userBll.AddUser(userRequest)));
        }
Ejemplo n.º 12
0
        protected void Button_Add_Click(object sender, EventArgs e)
        {
            UserModel model = new UserModel();

            model.UserName    = TextBox_UserName.Text;
            model.Account     = TextBox_Account.Text;
            model.CheckInTime = Convert.ToDateTime(TextBox_Born.Text);
            model.AlertTime   = DateTime.Now;
            model.PassWord    = TextBox_Password.Text;
            model.Phone       = TextBox_Phone.Text;
            model.Email       = TextBox_Email.Text;
            model.RoleId      = 1;
            model.IsDelete    = 0;
            model.Sex         = Convert.ToInt32(radlSex.SelectedItem.Value);
            UserBll bll = new UserBll();

            //上传用户头像
            if (FileUpload_Image.PostedFile.FileName.Trim().Length != 0)
            {
                string savePath;
                string fileName = DateTime.Now.ToString("yyyyMMddHHmmssms");
                if (FileUpload_Image.HasFile && FileUpload_Image.PostedFile.FileName.Contains(".jpg"))
                {
                    //指定上传文件在服务器上的保存路径
                    savePath = Server.MapPath("~/Upload/");
                    //检查服务器上是否存在这个物理路径,如果不存在则创建
                    if (!System.IO.Directory.Exists(savePath))
                    {
                        System.IO.Directory.CreateDirectory(savePath);
                    }
                    savePath = savePath + fileName + ".jpg";
                    FileUpload_Image.SaveAs(savePath);
                    //model.ImagePath = "/Upload/" + fileName + ".jpg";
                    model.ImagePath = fileName + ".jpg";
                }
                else
                {
                    ClientScript.RegisterStartupScript(GetType(), "", "alert('请选择JPG图片文件!');", true);
                    return;
                }
            }
            int result = 0;

            if (Request.QueryString["id"] != null)
            {
                model.UserID = Convert.ToInt32(Request.QueryString["id"]);
                result       = bll.UpdateUser(model);
            }
            else
            {
                result = bll.AddUser(model);
            }
            if (result > 0)
            {
                ClientScript.RegisterStartupScript(GetType(), "", "alert('保存成功!');window.location = 'UserList.aspx';", true);
            }
            else
            {
                ClientScript.RegisterStartupScript(GetType(), "", "alert('保存失败!');", true);
            }
        }
Ejemplo n.º 13
0
        /// <summary>
        /// 用户注册
        /// </summary>
        public void UerRegist()
        {
            UserAddRequest userAddRequest = new UserAddRequest();

            userBll.AddUser(userAddRequest);
        }