public ActionResult AllotAdmit(int id) { UsersBLL usreBll = new UsersBLL(); string loginName = Request.Form["U_LoginName"]; int S_ID = Convert.ToInt32(Request.Form["S_ID"]); ShopsBLL shopBll = new ShopsBLL(); Shops s = shopBll.SelectWhere(m => m.S_ID == S_ID).FirstOrDefault(); Users u = new Users(); try { using (TransactionScope ts = new TransactionScope()) { u.U_LoginName = loginName; u.U_Password = "******"; u.S_ID = S_ID; u.U_Role = 2; s.S_IsHasSetAdmin = true; shopBll.SaveChanges(); usreBll.Add(u); usreBll.SaveChanges(); ts.Complete(); } return Json(new { result = "ok" }); } catch { return Json(new { result = "error" }); } }
private void btnsave_Click(object sender, EventArgs e) { var var = (Role)cbrole.SelectedItem; var role1 = (Role)cbrole.SelectedItem; usersBLL.Add(new BO.User() { role = var, UserName = txtusername.Text, Password = txtpassword.Text, ExpireDate = dtpdate.Value }); dgwusermanagment.DataSource = usersBLL.GetALl(); }
protected void Add_Click(object sender, EventArgs e) { if (this.TxtName.Text.Trim().Length == 0) { Response.Write("<script lanuage=javascript>alert('用户名不能为空!')</script>"); return; } UsersBLL usersbll = new UsersBLL(); bool jiance = usersbll.Detect(this.TxtName.Text); if (jiance) { Response.Write("<script>alert('对不起,用户名已存在');history.back();</script>"); return; } Users a = new Users(); a.UserName = this.TxtName.Text; a.Password = CJ_DBOperater.CJ.PwdSecurity(this.TxtPassword.Text.Trim()); a.QuePwd = question.Text.Trim(); a.AnsPwd = answer.Text.Trim(); a.Role = this.DropDownList1.SelectedItem.Text; a.Telephone = this.TxtPhone.Text; if (this.RadioButton_Male.Checked == true) { a.UserSex = "男"; } else if (this.RadioButton_Female.Checked == true) { a.UserSex = "女"; } a.Address = this.TxtAddress.Text; a.Email = this.TxtEmail.Text; if (mark.Text.Trim().Length == 0) { a.UserMark = 0; } else { a.UserMark = Convert.ToInt32(mark.Text); } a.LoginTime = Convert.ToDateTime(DateTime.Now.ToString()); a.CreateTime = Convert.ToDateTime(DateTime.Now.ToString()); if (usersbll.Add(a)) { Response.Write("<script>alert('添加成功');window.location.href='UsersMgr.aspx';</script>"); } else { Response.Write("<script>alert('添加失败');history.back();</script>"); } }
public void AddUser(HttpContext context) { string PwdKey = LinkFun.getPwdKey(); int UserID = 0; if (!string.IsNullOrEmpty(context.Request.QueryString["UserID"].ToString())) { UserID = Convert.ToInt32(context.Request.QueryString["UserID"].ToString()); } string objOrder = GetParam("UsersModel", context); Users users = JsonConvert.DeserializeObject <Users>(objOrder); UsersBLL usersbll = new UsersBLL(); int result = 0; //编辑 if (UserID > 0) { if (users.LoginName != "" && users.Password != "") { result = usersbll.Update(users) ? 1 : 0; if (result > 0) { #region 通知风控系统 #endregion } } } else { string pwd = DESEncrypt.Encrypt(PwdKey, users.Password);//加密密码 users.Password = pwd; //添加 if (users.LoginName != "" && users.Password != "") { result = usersbll.Add(users); if (result > 0) { #region 通知风控系统 #endregion } } } context.Response.Write(result); }
public ActionResult Create(Users u) { try { UsersBLL bll = new UsersBLL(); Users user = Session["user"] as Users; u.S_ID = user.S_ID; u.U_Password = u.U_Password ?? "1"; u.U_CanDelete = Request["U_CanDelete"] == "on" ? true : false; bll.Add(u); bll.SaveChanges(); return Json(new { result = "ok" }); } catch { return Json(new { result = "error" }); } }
private void Add(Users model) { if (bll.Exists(model.userName)) { Msg.Show("此用户名已存在!"); } else { int rows = bll.Add(model); if (rows > 0) { Msg.ShowAndRedirect("添加信息成功!", "Default.aspx"); } else { Msg.Show("添加信息失败!"); } } }
public int Add(string UName, string Pwd, string Name, string Sex, int Age, string Phone, string Email, string RolesIds, string RolesNames, int SId, int IsUse) { Users t = new Users { UName = UName, Pwd = Pwd, Name = Name, Sex = Sex, Age = Age, Phone = Phone, Email = Email, RolesIds = RolesIds, RolesNames = RolesNames, SId = SId, IsUse = IsUse }; var result = bll.Add(t); return(result); }
//注册 protected void Btn_Login_Click(object sender, EventArgs e) { if (UserLoginName.Text.Trim().Length == 0) { Response.Write("<script lanuage=javascript>alert('用户名不能为空!')</script>"); return; } if (identify.Text.ToString().ToLower() != Session["check"].ToString().ToLower()) { Response.Write("<script lanuage=javascript>alert('您输入的验证码有误,请重新输入!')</script>"); identify.Text = ""; return; } if (Password.Text.Trim().Length == 0 || AffrimPassword.Text.Trim().Length == 0) { Response.Write("<script lanuage=javascript>alert('密码和确认密码均不能为空!')</script>"); return; } if (txtQuePwd.Text.Trim().Length == 0 || txtAnsPwd.Text.Trim().Length == 0) { Response.Write("<script lanuage=javascript>alert('密码问题和密码答案均不能为空!')</script>"); return; } if (EmailAddress.Text.Trim().Length == 0) { Response.Write("<script lanuage=javascript>alert('邮箱不能为空!')</script>"); return; } UsersBLL usersbll = new UsersBLL(); bool panduan = usersbll.Detect(this.UserLoginName.Text.Trim()); if (panduan) { Response.Write("<script lanuage=javascript>alert('你的用户名已被占用!');</script>"); return; } Users a = new Users(); a.UserName = this.UserLoginName.Text.Trim(); a.Password = CJ_DBOperater.CJ.PwdSecurity(this.Password.Text.Trim()); a.Role = "会员";//注册为一般用户 a.Telephone = this.TelephoneNum.Text.Trim(); if (this.RadioButton_Male.Checked == true) { a.UserSex = "男"; } else if (this.RadioButton_Female.Checked == true) { a.UserSex = "女"; } a.Address = this.Address.Text.Trim(); a.Email = this.EmailAddress.Text.Trim(); a.UserMark = 0; a.QuePwd = this.txtQuePwd.Text.Trim(); a.AnsPwd = this.txtAnsPwd.Text.Trim(); a.LoginTime = DateTime.Now; a.CreateTime = DateTime.Now; if (usersbll.Add(a)) { Response.Write("<script lanuage=javascript>alert('注册用户成功,现在转向登录界面!')</script>"); Response.Write(" <script lanuage=javascript> location.href= './login.aspx' </script> "); } else { Response.Write("<script lanuage=javascript>alert('注册用户时出现错误,请重新注册!')</script>"); Response.Write(" <script lanuage=javascript> location.href= './register.aspx' </script> "); } }
protected void Page_Load(object sender, EventArgs e) { if (IsPostBack) { string telnumber = Request.Form["telnumber"]; string password = Request.Form["password"]; string pwdAgian = Request.Form["pwdAgian"]; string name = Request.Form["name"]; string nickname = Request.Form["nickname"]; string idcard = Request.Form["idcard"]; if (password != pwdAgian) { Response.Write("<script>alert('两次密码不一致')</script>"); return; } UsersBLL usersBll = new UsersBLL(); if (usersBll.GetList("Telnumber = '" + telnumber + "'").Tables[0].Rows.Count == 0) { if (usersBll.GetList("Idcard = '" + idcard + "'").Tables[0].Rows.Count == 0) { } else { Response.Write("<script>alert('已注册的身份证号')</script>"); return; } } else { Response.Write("<script>alert('已注册的手机号')</script>"); return; } // 将密码加密后存入数据库 var bytes = Encoding.UTF8.GetBytes(password); using (var md5 = System.Security.Cryptography.MD5.Create()) { var hash = md5.ComputeHash(bytes); password = Convert.ToBase64String(hash); } Users user = new Users() { TelNumber = telnumber, Pwd = password, Fname = name, Nickname = nickname, Idcard = idcard, CheckinCount = 0, LoginStatus = 0 }; int res = 0; try { res = usersBll.Add(user); } catch (SqlException sqlex) { Response.Write(sqlex.Message); } if (res != 0) { ClientScript.RegisterStartupScript(ClientScript.GetType(), "PopUp", "<script>$(function () {window.pop('注册成功');});</script>"); //Response.Redirect("Sign in.aspx"); } else { Response.Write("<script>alert('注册失败')</script>"); } } }