private void CheckUserName(HttpContext context) { string userName = Globals.StripAllTags(context.Request["UserName"]); string empty = string.Empty; empty = ((ManagerHelper.FindManagerByUsername(userName) == null) ? "{\"success\":\"true\",\"msg\":\"\"}" : "{\"success\":\"false\",\"msg\":\"用户名已存在,请重新输入!\"}"); this.ResponseEnd(empty); }
private void btnCreate_Click(object sender, EventArgs e) { ManagerInfo managerInfo = null; if (string.Compare(this.txtPassword.Text, this.txtPasswordagain.Text) != 0) { this.ShowMsg("请确保两次输入的密码相同", false); } else { managerInfo = ManagerHelper.FindManagerByUsername(this.txtUserName.Text.Trim()); if (managerInfo != null) { this.ShowMsg("输入的管理员账户已存在,请重新输入!", false); } else { managerInfo = new ManagerInfo(); managerInfo.Password = this.txtPassword.Text.Trim(); managerInfo.RoleId = this.dropRole.SelectedValue; managerInfo.UserName = this.txtUserName.Text.Trim(); string pass = this.txtPassword.Text.Trim(); managerInfo.CreateDate = DateTime.Now; string text = Globals.RndStr(128, true); pass = (managerInfo.Password = Users.EncodePassword(pass, text)); managerInfo.PasswordSalt = text; if (ManagerHelper.Create(managerInfo) > 0) { this.txtUserName.Text = string.Empty; this.ShowMsg("成功添加了一个管理员", true); } else { this.ShowMsg("添加了一个管理员失败", false); } } } }
private void SaveSupplier(out int userId) { userId = 0; SupplierInfo supplierInfo = new SupplierInfo(); string userName = DataHelper.CleanSearchString(this.txtUserName.Text.Trim()); string supplierName = Globals.StripAllTags(this.txtSupplierName.Text.Trim()); string address = Globals.StripAllTags(this.txtAddress.Text); string text = this.txtTel.Text; string text2 = Globals.StripAllTags(this.txtContactMan.Text); if (SupplierHelper.ExistSupplierName(0, supplierName)) { this.ShowMsg("供应商名称已经存在,请重新输入!", false); } else if (!this.dropRegion.GetSelectedRegionId().HasValue) { this.ShowMsg("请选择供应商所在区域!", false); } else if (text2.Length > 8 || text2.Length < 2) { this.ShowMsg("请输入联系人,联系人长度必须是2-8位!", false); } else if (address.Length > 50 || address.Length < 2) { this.ShowMsg("请输入地址,长度必须为2-50个字符!", false); } else if (text == "" || !DataHelper.IsTel(text)) { this.ShowMsg("请输入正确的联系电话(手机或者固定电话)!", false); } else if (ManagerHelper.FindManagerByUsername(userName) != null) { this.ShowMsg("用户名已经存在,请重新输入!", false); } else if (this.txtUserPwd.Text.Length < 6 || this.txtUserPwd.Text.Length > 20) { this.ShowMsg("密码不能为空,用户密码长度必须为6-20个字符!", false); } else if (string.Compare(this.txtUserPwd.Text, this.txtUserRePwd.Text) != 0) { this.ShowMsg("请确保两次输入的密码相同", false); } else { supplierInfo.Introduce = this.editDescription.Text; supplierInfo.SupplierName = supplierName; supplierInfo.Picture = this.UploadImage(); supplierInfo.Status = 1; supplierInfo.RegionId = this.dropRegion.GetSelectedRegionId().Value; supplierInfo.Tel = text; List <string> list = RegionHelper.GetFullRegion(this.dropRegion.GetSelectedRegionId().Value, ",", true, 0).Split(',').Take(3) .ToList(); list.ForEach(delegate(string c) { address = address.Replace(c, string.Empty); }); supplierInfo.Address = address; supplierInfo.ContactMan = text2; supplierInfo.FullRegionPath = RegionHelper.GetFullPath(supplierInfo.RegionId, true); int num = SupplierHelper.AddSupplier(supplierInfo); if (num > 0) { ManagerInfo managerInfo = new ManagerInfo(); managerInfo.RoleId = -2; managerInfo.UserName = this.txtUserName.Text.Trim(); string text3 = this.txtUserPwd.Text; managerInfo.CreateDate = DateTime.Now; string text4 = Globals.RndStr(128, true); text3 = (managerInfo.Password = Users.EncodePassword(text3, text4)); managerInfo.PasswordSalt = text4; managerInfo.StoreId = num; userId = ManagerHelper.Create(managerInfo); } } }