static void Main(string[] args) { UserManage T = UserManage.GetInstance(); Console.WriteLine(T.AddUser(1, "Hyan", 10000)); Console.WriteLine(T.AddUser(2, "HH", 5000)); Console.ReadKey(); }
protected void btnReg_Click(object sender, EventArgs e) { if (txtName.Text == string.Empty) { Response.Write("<script language=javascript>alert('用户名不能为空!')</script>"); } else { usermanage.UserName = txtName.Text; DataSet ds = usermanage.FindUserByName(usermanage, "tb_User"); if (ds.Tables[0].Rows.Count > 0) { Response.Write("<script language=javascript>alert('该用户已经存在!')</script>"); txtName.Text = string.Empty; txtName.Focus(); } else { usermanage.UserPwd = txtPwd.Text; usermanage.TName = txtTName.Text; if (ddlSex.SelectedIndex == 0) { usermanage.Sex = true; } if (ddlSex.SelectedIndex == 1) { usermanage.Sex = false; } usermanage.Birthday = DateTime.Parse(txtBirthday.Text); usermanage.Tel = txtTel.Text; usermanage.Mobile = txtMobile.Text; if (txtQQ.Text == string.Empty) { usermanage.QQ = 0; } else { usermanage.QQ = Int32.Parse(txtQQ.Text); } imagemanage.PhotoID = ddlPhoto.SelectedValue; usermanage.Photo = imagemanage.FindPhotoByID(imagemanage, "tb_Image").Tables[0].Rows[0][1].ToString(); usermanage.Email = txtEmail.Text; usermanage.FAddress = txtHAddress.Text; usermanage.RAddress = txtRAddress.Text; usermanage.Index = txtIndex.Text; usermanage.AddUser(usermanage); Response.Write("<script language=javascript>alert('用户注册成功!')</script>"); } } }
protected void btnConfrim_Click(object sender, EventArgs e) { if (Page.IsValid) { List <TablePrimary> t = new List <TablePrimary>(); TablePrimary userPrimary = new TablePrimary(); userPrimary.PrimaryName = "JobNo"; userPrimary.PrimaryValue = GetUserInfo().JobNo; t.Add(userPrimary); if (Request.QueryString["Type"] != null && Request.QueryString["Type"].ToString() == "0")//新增状态 { if (Common.IsExsit("User", t)) { ScriptManager.RegisterStartupScript(UpdatePanel1, this.GetType(), "Fail", "alert('用户已经存在,请确认!');", true); } else { if (UserManage.AddUser(GetUserInfo())) { ScriptManager.RegisterStartupScript(UpdatePanel1, this.GetType(), "Sucess", "alert('操作成功!');location.replace('UserList.aspx?Refresh=1');", true); } else { ScriptManager.RegisterStartupScript(UpdatePanel1, this.GetType(), "Fail", "alert('操作失败!');", true); } } } else { if (Common.IsExsit("User", t, GetUserInfo().UserID)) { ScriptManager.RegisterStartupScript(UpdatePanel1, this.GetType(), "Fail", "alert('用户已经存在,请确认!');", true); } else { if (UserManage.UpdateUser(GetUserInfo())) { ScriptManager.RegisterStartupScript(UpdatePanel1, this.GetType(), "Sucess", "alert('操作成功!');location.replace('UserList.aspx?Refresh=1');", true); } else { ScriptManager.RegisterStartupScript(UpdatePanel1, this.GetType(), "Fail", "alert('操作失败!');", true); } } } } }
public ActionResult AddUser() { User user = new User(); user.UserName = Request.Params["userName"]; user.PassWord = Request.Params["userPass"]; user.Email = Request.Params["userEmail"]; user.Role = "5"; if (userManage.AddUser(user) > 0) { return(Content("true")); } else { return(Content("false")); } }
protected void btnAdd_Click(object sender, EventArgs e) { ValidateFun(); usermanage.ID = txtUserID.Text; usermanage.Name = txtUser.Text; if (usermanage.FindUserByName(usermanage, "tb_user").Tables[0].Rows.Count > 0) { Response.Write("<script>alert('该读者已经存在!')</script>"); return; } usermanage.Sex = ddlSex.Text; usermanage.Pwd = txtPwd.Text; usermanage.Birthday = Convert.ToDateTime(txtBirthday.Text); usermanage.Tel = txtTel.Text; usermanage.Email = txtEmail.Text; usermanage.CreateDate = Convert.ToDateTime(txtDate.Text); //usermanage.UploadNum = Convert.ToInt32(txtUpload.Text); usermanage.UploadTimes = 10; usermanage.AddUser(usermanage); Response.Redirect("UserManage.aspx"); }
public ActionResult AddUser(AddUserViewModel Model) { UserManage vUserMange = new UserManage(); UsersEF vUserInfo = vUserMange.GetUserInfo(Model.UserName); if (vUserInfo.ID == null || vUserInfo.ID == 0 || vUserInfo.IsUse == false) { if (vUserMange.AddUser(Model.UserName, Model.Password, Model.Power)) return RedirectToAction("UserList", "Admin"); else { ModelState.AddModelError("", "添加用户失败"); Model.PowerList = createPowerSelectList(); return View(Model); } } else { ModelState.AddModelError("", "用户名重复"); Model.PowerList = createPowerSelectList(); return View(Model); } }
/// <summary> /// 添加、修改数据 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void btnOK_Click(object sender, EventArgs e) { if (Page.IsValid) { #region 验证表单合法性 if (this.CheckForms() == false) { CloseDivImplementation(); return; } #endregion #region 初始化数据 UsersEO usersEO = new UsersEO(); RoleuserEO rluEO = new RoleuserEO(); if (Request.QueryString["State"] == "U") { usersEO = userManage.GetUserByPK(Request.QueryString["Urid"]); if (cbk_password.Checked) { usersEO.UrPass = MdUtil.ToMd5Hash(this.txtPass.Text.Trim());//密码MD5加密 } } usersEO.UrLoginName = this.txtLoginName.Text.Trim(); usersEO.UrName = this.txtName.Text.Trim(); usersEO.UrParent = this.txtParent.Text.Trim(); usersEO.UrPhone = this.txtPhone.Text.Trim(); usersEO.UrZone = this.txtZone.Text.Trim(); usersEO.UrPeople = this.txtContactPeople.Text.Trim(); usersEO.UrContact = this.txtContact.Text.Trim(); usersEO.UrGameId = this.txtGameId.Text.Trim(); usersEO.UrDiamondNum = this.txtDiamondNum.Text.Trim(); usersEO.UrBankName = this.txtBankName.Text.Trim(); usersEO.UrBank = this.txtBank.Text.Trim(); usersEO.UrPercent = this.txtPercent.Text.Trim(); usersEO.UrBankNo = this.txtBankNo.Text.Trim(); usersEO.UrIntroducer = this.txtIntrdouce.Text.Trim(); usersEO.UrName = this.txtName.Text.Trim(); usersEO.UrName = this.txtName.Text.Trim(); usersEO.UrRolestate = this.ddlDepartment.SelectedValue; usersEO.UrDepartment = this.ddlDepartment.SelectedValue; usersEO.UrState = this.rblState.SelectedValue; usersEO.UrLockBindIp = this.txtUserIps.Text.ToString().Trim(); usersEO.UrText1 = this.ddlUserLeave.Text.ToString().Trim(); // 用户级别 #endregion #region 设置用户账号归属管理 //用户角色信息 int itemCount = 0; // 选择的数量 string strAccountManagement = ""; for (int i = 0; i < this.cbAccountManagement.Items.Count; i++) { if (this.cbAccountManagement.Items[i].Selected) { strAccountManagement += this.cbAccountManagement.Items[i].Value; strAccountManagement += ";"; itemCount++; } } usersEO.UrText2 = strAccountManagement; if (itemCount > 5) { this.divAlert.Visible = true; this.lblAlert.Text = "账号管理归属最多选择4个人"; CloseDivImplementation(); return; } #endregion #region 创建用户 if (Request.QueryString["State"] == "A") { //判断用户账号是否存在 if (this.CheckUserLoginName() == false) { //Jswork.Alert("用户账号【" + this.txtLoginName.Text.Trim() + "】已存在", this.Page); this.divAlert.Visible = true; this.lblAlert.Text = Resources.Resource.User_account1 + this.txtLoginName.Text.Trim() + Resources.Resource.Already_exist; CloseDivImplementation(); return; } //用户信息 usersEO.UrId = GetBigGuid(); usersEO.UrPass = MdUtil.ToMd5Hash(this.txtPass.Text.Trim());//密码MD5加密 usersEO.UrDel = "0"; usersEO.UrAddUser = GetUserID(); usersEO.UrAddTime = DateTime.Now; usersEO.UrLockTime = DateTime.Now; //用户角色信息 for (int i = 0; i < this.cblRoles.Items.Count; i++) { if (this.cblRoles.Items[i].Selected) { rluEO.UrId = usersEO.UrId; rluEO.RlId = this.cblRoles.Items[i].Value; rluEO.RuAddUser = GetUserID(); rluEO.RuAddTime = DateTime.Now; rluManage.AddRoleUser(rluEO); } } if (userManage.AddUser(usersEO) > 0) { //插入操作日志 InsertLog(Resources.Resource.Create_user, string.Format("username:{0},id:{1}", usersEO.UrName, usersEO.UrId), 4, GetPlatformIdByValue(1)); CloseDivImplementation(); Jswork.Alert(Resources.Resource.User_information_creation_success, "UsersList.aspx"); } else { //Jswork.Alert("用户信息创建失败", this.Page); this.divAlert.Visible = true; this.lblAlert.Text = Resources.Resource.User_information_creation_failed;//"用户信息创建失败"; } } #endregion #region 修改用户 if (Request.QueryString["State"] == "U") { //修改时判断账号是否存在 if (hfLoginName.Value != this.txtLoginName.Text.Trim()) { //判断用户账号是否存在 if (this.CheckUserLoginName() == false) { //Jswork.Alert("用户账号【" + this.txtLoginName.Text.Trim() + "】已存在", this.Page); this.divAlert.Visible = true; //this.lblAlert.Text = "用户账号【" + this.txtLoginName.Text.Trim() + "】已存在"; this.lblAlert.Text = Resources.Resource.User_account1 + this.txtLoginName.Text.Trim() + Resources.Resource.Already_exist; CloseDivImplementation(); return; } } //用户角色信息 rluManage.RemoveByPK(Request.QueryString["Urid"]); //插入用户角色关系表数据前先删除数据 for (int i = 0; i < this.cblRoles.Items.Count; i++) { if (this.cblRoles.Items[i].Selected) { rluEO.UrId = usersEO.UrId; rluEO.RlId = this.cblRoles.Items[i].Value; rluEO.RuAddUser = GetUserID(); rluEO.RuAddTime = DateTime.Now; rluManage.AddRoleUser(rluEO); } } if (userManage.EditUser(usersEO) > 0) { if (usersEO.UrState == "0") // 启用状态 { UserUnFreeZing(usersEO.UrId, DateTime.Now.AddMonths(-1)); } //插入操作日志 InsertLog(Resources.Resource.Modify_user, string.Format("username:{0},id:{1}", usersEO.UrName, usersEO.UrId), 2, GetPlatformIdByValue(1)); CloseDivImplementation(); Jswork.Alert(Resources.Resource.Success_of_user_information_modification, "UsersList.aspx"); } else { //Jswork.Alert("用户信息修改失败", this.Page); this.divAlert.Visible = true; this.lblAlert.Text = Resources.Resource.User_information_modification_failed;//"用户信息修改失败"; } } #endregion CloseDivImplementation(); } }
/// <summary> /// 添加、修改数据 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void btnOK_Click(object sender, EventArgs e) { if (Page.IsValid) { #region 验证表单合法性 if (this.CheckForms() == false) { CloseDivImplementation(); return; } #endregion //判断用户账号是否存在 if (this.CheckUserLoginName() == false) { ShowCommonDlg("账户名已存在!"); CloseDivImplementation(); return; } #region 初始化数据 UsersEO usersEO = new UsersEO(); RoleuserEO rluEO = new RoleuserEO(); //if (Request.QueryString["State"] == "U") //{ // usersEO = userManage.GetUserByPK(Request.QueryString["Urid"]); // if (cbk_password.Checked) // { // } //} usersEO.UrPass = MdUtil.ToMd5Hash(this.txtPass.Text.Trim());//密码MD5加密 usersEO.UrLoginName = this.txtLoginName.Text.Trim(); usersEO.UrName = this.txtName.Text.Trim(); usersEO.UrParent = this.txtParent.Text.Trim(); usersEO.UrPhone = "";//this.txtPhone.Text.Trim(); usersEO.UrZone = this.txtZone.Text.Trim(); usersEO.UrPeople = this.txtContactPeople.Text.Trim(); usersEO.UrContact = this.txtContact.Text.Trim(); usersEO.UrGameId = this.txtGameId.Text.Trim(); usersEO.UrDiamondNum = "0"; usersEO.UrBankName = ""; //this.txtBankName.Text.Trim(); usersEO.UrBank = ""; //this.txtBank.Text.Trim(); usersEO.UrPercent = "0"; usersEO.UrBankNo = ""; //this.txtBankNo.Text.Trim(); usersEO.UrIntroducer = ""; //this.txtIntrdouce.Text.Trim(); usersEO.UrRolestate = "3"; usersEO.UrDepartment = "3"; usersEO.UrState = "0"; usersEO.UrLockBindIp = ""; usersEO.UrText1 = "0"; // 用户级别 #endregion #region 创建用户 //if (Request.QueryString["State"] == "A") { //用户信息 usersEO.UrId = GetBigGuid(); usersEO.UrPass = MdUtil.ToMd5Hash(this.txtPass.Text.Trim());//密码MD5加密 usersEO.UrDel = "0"; usersEO.UrAddUser = GetUserID(); usersEO.UrAddTime = DateTime.Now; usersEO.UrLockTime = DateTime.Now; //用户角色信息 //for (int i = 0; i < this.cblRoles.Items.Count; i++) { //if (this.cblRoles.Items[i].Selected) { rluEO.UrId = usersEO.UrId; rluEO.RlId = "0468a29f20160413170700";//this.cblRoles.Items[i].Value; rluEO.RuAddUser = GetUserID(); rluEO.RuAddTime = DateTime.Now; rluManage.AddRoleUser(rluEO); } } if (userManage.AddUser(usersEO) > 0) { //插入操作日志 InsertLog(Resources.Resource.Create_user, string.Format("username:{0},id:{1}", usersEO.UrName, usersEO.UrId), 4, GetPlatformIdByValue(1)); CloseDivImplementation(); Jswork.Alert("代理信息创建成功!", "UsersAgentList.aspx"); //ShowCommonDlg("代理信息创建成功!"); } else { //Jswork.Alert("用户信息创建失败", this.Page); //this.divAlert.Visible = true; //this.lblAlert.Text = Resources.Resource.User_information_creation_failed;//"用户信息创建失败"; ShowCommonDlg("代理信息创建失败!"); } } #endregion CloseDivImplementation(); } }