コード例 #1
0
        public override void OnOperationRequest(OperationRequest operationRequest, SendParameters sendParameters, ClientPeer peer)
        {
            string username = DicTool.GetValue <byte, object>(operationRequest.Parameters, (byte)ParameterCode.UserName) as string;
            string password = DicTool.GetValue <byte, object>(operationRequest.Parameters, (byte)ParameterCode.PassWord) as string;

            UserManage userManage = new UserManage();
            Runoob_tbl user       = userManage.GetByUserName(username);

            OperationResponse response = new OperationResponse(operationRequest.OperationCode);

            if (user == null) //没有用户才注册
            {
                user = new Runoob_tbl()
                {
                    Username = username, Password = password, RegisterDate = DateTime.Now
                };
                userManage.Add(user);
                response.ReturnCode = (short)ReturnCode.Success;
            }
            else
            {
                response.ReturnCode = (short)ReturnCode.Failed;
            }

            peer.SendOperationResponse(response, sendParameters);
        }
コード例 #2
0
        public static string Insert(string temp)
        {
            JObject jo = (JObject)JsonConvert.DeserializeObject(temp);
            string  msg;
            string  password = LoginManage.GenerateMD5(jo["password"].ToString());
            int     apartID  = apartment[jo["apartID"].ToString()];
            int     roleID   = roles[jo["roleID"].ToString()];

            Models.User user = new Models.User((int)jo["id"], jo["userName"].ToString(), password, apartID, jo["job"].ToString(), roleID, jo["num"].ToString(), jo["name"].ToString());
            return(UserManage.Add(user, out msg) ? JsonConvert.SerializeObject(new Packet(200, "插入成功")) : JsonConvert.SerializeObject(new Packet(203, msg)));
        }
コード例 #3
0
        public ActionResult Add(AddUserViewModel userViewModel)
        {
            if (UserManage.HasUsername(userViewModel.Username))
            {
                ModelState.AddModelError("Username", "用户名已存在");
            }
            if (UserManage.HasEmail(userViewModel.Email))
            {
                ModelState.AddModelError("Email", "Email已存在");
            }
            if (ModelState.IsValid)
            {
                User _user = new User();
                _user.RoleID   = userViewModel.RoleID;
                _user.Username = userViewModel.Username;
                _user.Name     = userViewModel.Name;
                _user.Sex      = userViewModel.Sex;
                _user.Password = Core.General.Security.Sha256(userViewModel.Password);
                _user.Email    = userViewModel.Email;
                _user.RegTime  = System.DateTime.Now;
                var _response = UserManage.Add(_user);
                if (_response.Code == 1)
                {
                    return(View("Prompt", new Prompt()
                    {
                        Title = "添加用户成功",
                        Message = "您已添加了用户【" + _response.Data.Username + "(" + _response.Data.Name + ")" + "】",
                        Buttons = new List <string> ()
                        {
                            "<a href=\"" + Url.Action("Index", "User") + "\" class=\"bth bth-default\">用户管理</a>",
                            "<a href=\"" + Url.Action("Details", "User", new { id = _response.Data.UserID }) + "\" class=\"bth bth-default\">查看用户</a>",
                            "<a href=\"" + Url.Action("Add", "User") + "\" class=\"btn btn-default\">继续添加</a>"
                        }
                    }));
                }
                else
                {
                    ModelState.AddModelError("", _response.Message);
                }
            }
            var _roles = new RoleManager().FindList();
            List <SelectListItem> _listitems = new List <SelectListItem>(_roles.Count());

            foreach (var _role in _roles)
            {
                _listitems.Add(new SelectListItem()
                {
                    Text = _role.Name, Value = _role.RoleID.ToString()
                });
            }
            ViewBag.Roles = _listitems;
            return(View(userViewModel));
        }
コード例 #4
0
ファイル: UserService.cs プロジェクト: xbf321/MTD
 public static UserInfo Create(UserInfo model)
 {
     if (model.Id == 0)
     {
         model.Id = UserManage.Add(model);
     }
     else
     {
         UserManage.Update(model);
     }
     return(model);
 }
コード例 #5
0
        public ActionResult Index(UserDto dto)
        {
            User user = new User();

            user.Account  = dto.Account;
            user.Password = dto.Password;
            string msg;
            Result result = new Result {
                Status = UserManage.Add(user, out msg), Message = msg
            };

            return(Json(result, JsonRequestBehavior.AllowGet));
        }
コード例 #6
0
ファイル: UserService.cs プロジェクト: xbf321/Hite
 public static UserInfo Update(UserInfo model)
 {
     if (model.Id == 0)
     {
         int id = UserManage.Add(model);
         model.Id = id;
     }
     else
     {
         UserManage.Update(model);
     }
     return(model);
 }
コード例 #7
0
 public ActionResult Register(RegisterViewModel registerViewModel)
 {
     if (userManage.HasUserName(registerViewModel.Username))
     {
         ModelState.AddModelError("Username", "用户名已存在");
     }
     if (userManage.HasUserEmail(registerViewModel.EmailAdress))
     {
         ModelState.AddModelError("EmailAdress", "邮箱已存在");
     }
     if (ModelState.IsValid)
     {
         if (Session["EmailCode"] == null)
         {
             ModelState.AddModelError("Code", "请获取验证码");
         }
         else if (registerViewModel.Code == Session["EmailCode"].ToString())
         {
             if (Security.Sha256(registerViewModel.Password) == Security.Sha256(registerViewModel.ConfirmPassword))
             {
                 User _user = new User();
                 _user.Username      = registerViewModel.Username;
                 _user.EmailAdress   = registerViewModel.EmailAdress;
                 _user.Role          = DAL.Models.User.Roles.普通用户; //默认用户身份
                 _user.Password      = Security.Sha256(registerViewModel.Password);
                 _user.DefaultImgUrl = "/DefaultImg/Default.jpg";
                 _user.SweetScore    = 40;
                 _user.Userstatus    = DAL.Models.User.UserStatus.启用;
                 var _resp = userManage.Add(_user);
                 if (_resp.Code == 1)
                 {
                     return(RedirectToAction("Login"));
                 }
                 else
                 {
                     ModelState.AddModelError("", _resp.Message);
                 }
             }
         }
         else
         {
             ModelState.AddModelError("Code", "验证码不正确");
         }
     }
     else
     {
         return(View(registerViewModel));
     }
     return(View(registerViewModel));
 }
コード例 #8
0
 public ActionResult Add(AddUserViewModel addUderViewModel)
 {
     if (userManage.HasUserName(addUderViewModel.Username))
     {
         ModelState.AddModelError("Username", "用户名已存在");
     }
     if (userManage.HasUserEmail(addUderViewModel.EmailAdress))
     {
         ModelState.AddModelError("EmailAdress", "邮箱已存在");
     }
     if (ModelState.IsValid)
     {
         if (Security.Sha256(addUderViewModel.Password) == Security.Sha256(addUderViewModel.ConfirmPassword))
         {
             User _user = new User();
             _user.Role          = (User.Roles)addUderViewModel.Role;
             _user.Username      = addUderViewModel.Username;
             _user.Password      = Security.Sha256(addUderViewModel.Password);
             _user.Name          = addUderViewModel.Name;
             _user.EmailAdress   = addUderViewModel.EmailAdress;
             _user.Userstatus    = (User.UserStatus)addUderViewModel.Userstatus;
             _user.DefaultImgUrl = "/DefaultImg/Default.jpg";
             _user.SweetScore    = addUderViewModel.SweetScore;
             var _resp = userManage.Add(_user);
             if (_resp.Code == 1)
             {
                 return(View("Prompt", new Prompt()
                 {
                     Title = "添加用户成功",
                     Message = "您已添加了用户【" + _resp.Data.Username + "】",
                     Buttons = new List <string>()
                     {
                         "<a href=\"" + Url.Action("Index", "User") + "\" class=\"btn btn-default\">用户管理</a>",
                         "<a href=\"" + Url.Action("Add", "User") + "\" class=\"btn btn-default\">继续添加</a>"
                     }
                 }
                             ));
             }
             else
             {
                 ModelState.AddModelError("", _resp.Message);
             }
         }
     }
     else
     {
         return(View(addUderViewModel));
     }
     return(View(addUderViewModel));
 }
コード例 #9
0
        protected void Button1_Click(object sender, EventArgs e)
        {
            string uname = unmbox.Text.Trim();
            string pwd   = CreatMd5.GetMD5(pwdboxy.Text.Trim());
            users  regu  = new users();

            regu.user_name     = uname;
            regu.user_password = pwd;

            if (UserManage.Add(regu) == 1)
            {
                Response.Write("<script>alert('注册成功');</script>");
                Response.Redirect("index.aspx");
            }
            else
            {
                Response.Write("<script>alert('注册shibai');</script>");
            }
        }
コード例 #10
0
ファイル: Detail.cs プロジェクト: pronebel/hotelManager
        private void btnSave_Click(object sender, EventArgs e)
        {
            if (txtUserName.Text.Trim() == "")
            {
                MessageBox.Show("请输入用户名称!", "操作提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                return;
            }


            if (txtEmail.Text.Trim() == "")
            {
                MessageBox.Show("请输入Email!", "操作提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                return;
            }

            if (txtMobile.Text.Trim() == "")
            {
                MessageBox.Show("请输入手机号!", "操作提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                return;
            }
            if (txtPassword.Text.Trim() == "")
            {
                MessageBox.Show("请输入Email!", "操作提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                return;
            }



            string strAlert;

            if (username != string.Empty)
            {
                strAlert = "确定更新该项?";
            }
            else
            {
                strAlert = "确定新增该项?";
            }

            if (MessageBox.Show(strAlert, "操作提示", MessageBoxButtons.OKCancel, MessageBoxIcon.Question) == DialogResult.OK)
            {
                if (username != string.Empty)
                {
                    // message = rm.UpdateRoom(room);
                    // MessageBox.Show(message, "操作提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                }
                else
                {
                    User userM = new User(0, txtUserName.Text.Trim(), txtMobile.Text.Trim(), txtEmail.Text.Trim(), txtPassword.Text.Trim());

                    int retNum = userManage.Add(userM);
                    if (retNum > 0)
                    {
                        MessageBox.Show("添加成功", "操作提示", MessageBoxButtons.OK, MessageBoxIcon.Information);


                        this.Close();
                        this.Dispose();
                    }
                    else if (retNum == -1)
                    {
                        MessageBox.Show("已经存在相同昵称的用户", "操作提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    }
                    else
                    {
                        MessageBox.Show("操作失败", "操作提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    }
                }
            }
        }