public JsonResult InitSingle() { #region 权限控制 int[] iRangePage = { AddPageNodeId, EditPageNodeId, DetailPageNodeId }; int iCurrentPageNodeId = RequestParameters.Pint("NodeId"); var tempAuth = Utits.IsNodePageAuth(iRangePage, iCurrentPageNodeId); if (tempAuth.ErrorType != 1) { return(Json(tempAuth)); } #endregion #region InitSingle Guid ID = RequestParameters.PGuid("ID"); if (ID != Guid.Empty) { var usersBll = new UsersBll(); var item = usersBll.GetObjectById(ID); var szDetailModel = new ResultDetail(); szDetailModel.Entity = item; szDetailModel.ErrorType = 1; return(Json(szDetailModel)); } else { var sRetrunModel = new ResultMessage(); sRetrunModel.ErrorType = 0; sRetrunModel.MessageContent = "参数错误."; return(Json(sRetrunModel)); } #endregion }
public ActionResult DoLogin(FormCollection form) { string user = form["username"]; string pass = form["password"]; if (ConfigHelper.GetConfig("Debug").Equals("True")) { FormsAuthentication.SetAuthCookie("debuger", true); Session.Add("_User", user); return(Redirect("/Home/Desktop")); } if (string.IsNullOrEmpty(user) || string.IsNullOrEmpty(pass)) { return(Redirect("Index")); } else { bool allowed = UsersBll.GetInstance().IsAllowedLogin(new UsersEntity { UserCode = user, Password = pass }); if (allowed) { Session.Add("_User", user); FormsAuthentication.SetAuthCookie(user, true); return(Redirect("/Home/Desktop")); } else { return(Redirect("Index")); } } }
private void Button_Click(object sender, RoutedEventArgs e) { string Dname = Application.Current.MainWindow.DataContext.ToString(); string oldpwd = OldPassWord.Password; string newpwd = NewPassWord.Password; string newokpwd = NewPassWord.Password; //调用代码 if (newpwd != newokpwd) { MessageBox.Show("新密码不一致!"); } else { if (oldpwd == newpwd) { MessageBox.Show("新旧密码不能相同!"); } else { UsersBll usersBll = new UsersBll(); UsersModel user = usersBll.CheckByDName(Dname, Md5Helper.EncryptString(newpwd)); if (user.PassWord.Equals(Md5Helper.EncryptString(oldpwd))) { user.OK = true; MessageBox.Show("修改密码成功!"); } else { MessageBox.Show("原始密码错误!"); } } } }
protected void Button1_Click(object sender, EventArgs e) { try { UsersBll userBll = new UsersBll(); UsersModel loginUser = new UsersModel(); loginUser.UserName = TextBox1.Text; loginUser.Pwd = TextBox2.Text; loginUser = userBll.GetModelLogin(loginUser); if (loginUser.UserId != 0) { Session["CurrentUser"] = loginUser; Response.Redirect("./Home.aspx"); } else { Response.Write("<script>alert('用户名或密码错误')</script>"); } } catch { Response.Write("<script>alert('登录异常')</script>"); } finally { } }
public ActionResult DoChangePassword(FormCollection form) { if (form.Count == 0) { return(Redirect("/User/ChangePassword")); } foreach (var item in form.Keys) { if (string.IsNullOrEmpty(form[item.ToString()].ToString())) { return(Redirect("/User/ChangePassword")); } } string newPassword = form["newPassword"]; string loginUser = Session["user"].ToString(); bool ret = UsersBll.GetInstance().ChangePassword(loginUser, newPassword); if (ret) { //更新密码成功 return(Redirect("/User/Index")); } else { //更新密码失败 return(Redirect("/User/ChangePassword")); } }
private void Login_Click(object sender, RoutedEventArgs e) { //获取用户输入的信息 string name = UserName.Text; string pwd = PassWord.Password; //调用代码 if (UserName.SelectedText == null) { MessageBox.Show("用户名或密码为空"); } else { UsersBll usersBll = new UsersBll(); UsersModel user = usersBll.GetByName(name); if (user == null) { MessageBox.Show("用户名错误"); } else { if (user.PassWord.Equals(Md5Helper.EncryptString(pwd))) { //将登陆者传递给主窗口 Application.Current.MainWindow.DataContext = user.DisplayName; Application.Current.MainWindow.Content = new ViewDataGrid(); } else { MessageBox.Show("密码错误"); } } } }
protected void Button1_Click(object sender, EventArgs e) { Users users = new Users(); users.Users_Name1 = txtName1.Text.Trim(); users.Users_Password1 = txtPassword1.Text.Trim(); users.Users_Tel1 = txtTel1.Text.Trim(); users.Users_Sex1 = RadioButtonList_sex.SelectedItem.Text; users.Users_Vip1 = int.Parse(RadioButtonList_vip.SelectedValue) == 1 ? true:false; users.Users_Admin1 = int.Parse(RadioButtonList_admin.SelectedValue) == 1 ? true : false; users.Users_Img1 = @"~/Img_Users/" + FileUpload1.PostedFile.FileName; try { if (UsersBll.update(users) == 1) { BindView(); Page.ClientScript.RegisterClientScriptBlock(typeof(Object), "alert", "<script>alert('修改成功!');</script>"); } else { Page.ClientScript.RegisterClientScriptBlock(typeof(object), "alert", "<script>alert('修改失败!');</script>"); } } catch (Exception ex) { Response.Write("错误原因:" + ex.Message); } }
public void ProcessRequest(HttpContext context) { context.Response.ContentType = "text/plain"; string oldpwd = context.Request["oldpwd"]; string userPwd = ((Users)context.Session["user"]).LoginPwd; int userId = ((Users)context.Session["user"]).Id; string newpwd = context.Request["newpwd"]; if (Password_Encryption.Md5(Password_Encryption.Md5(oldpwd)) != userPwd) { context.Response.Write("原密码输入错误,请重试"); } else { bool flag = new UsersBll().UpdatePwd(userId, newpwd); if (flag) { context.Session["user"] = null; context.Response.Write("ok"); } else { context.Response.Write("服务器繁忙,请稍后重试!!!"); } } }
public JsonResult AchieveLeftAuthNode() { if (Utits.IsLogin) { #region 设置IP string GetIP = RequestParameters.Pstring("YlyClientIP"); //登录IP var itemUsers = new Users(); itemUsers.UserID = Utits.CurrentUserID; itemUsers.UserCode = GetIP; var cBllUsers = new UsersBll(); bool IsFlagUsers = cBllUsers.AddOrUpdate(itemUsers, false); #endregion var listLeftAuthNode = new AuthRoleNodeBll().SearchListByLeftUserId(Utits.CurrentUserID, Utits.IsSuper); if (listLeftAuthNode != null) { var listAchieveAuthNode = listLeftAuthNode.Select(itemNode => new TreeModel { Id = itemNode.NodeId, Pid = itemNode.ParentID, Name = itemNode.NodeName, Target = itemNode.NodeTarget, Url = itemNode.NodePath, NodeClassName = itemNode.NodeClassName, Remark = itemNode.Remark }).OrderBy(c => c.Remark).ToList(); if (listAchieveAuthNode.Count > 0) { return(Json(listAchieveAuthNode)); } } } return(Json("[]")); }
//姓名下拉 public JsonResult AutoUserName() { string keyword = RequestParameters.Pstring("q"); int limit = RequestParameters.Pint("limit"); if (limit <= 0) { limit = 10; } if (limit >= 10) { limit = 10; } if (limit > 100) { limit = 10; } var cBll = new UsersBll(); var searchList = cBll.SearchListByAuto(keyword, limit); if (searchList == null) { searchList = new List <tbOrgTLJGCongYe>(); } return(Json(searchList)); }
public void ProcessRequest(HttpContext context) { context.Response.ContentType = "text/plain"; string phone = context.Request["phone"]; //测试用的验证码 string code = Verification_Code.GetRandomint(4); context.Session["code"] = new SMS_Verification().VerCode(phone, code);//真实验证码 string op = context.Request["op"]; //找回密码 if (op == "find") { int r = new UsersBll().ExistsByLoginId(phone); if (r < 1) { context.Response.Write("nofind"); } else { context.Response.Write(code); } } else if (op == "reg") { context.Response.Write(code); } }
private void Button_Click(object sender, RoutedEventArgs e) { //获取用户输入的信息 string name = UserName.Text; string pwd = PassWord.Password; string Dname = DisplayName.Text; string OKpwd = OKPassWord.Password; //调用代码 if (name == "" || pwd == "" || Dname == "" || OKpwd == "") { MessageBox.Show("各项不可为空!"); } else { if (pwd != OKpwd) { MessageBox.Show("密码不一致!"); } else { UsersBll usersBll = new UsersBll(); UsersModel user = usersBll.CheckByName(name, Dname, Md5Helper.EncryptString(pwd)); if (user != null) { MessageBox.Show("该用户已存在!"); } else { MessageBox.Show("注册成功!"); } } } }
public void ProcessRequest(HttpContext context) { context.Response.ContentType = "text/plain"; int userId = ((Users)context.Session["user"]).Id; string telphone = context.Request["phone"]; string yan = context.Request["yan"]; string code = context.Session["code"].ToString(); if (yan != code) { context.Response.Write("验证码不正确,请重试"); } else { bool flag = new UsersBll().Update(userId, telphone); if (flag) { context.Session["user"] = new UsersBll().GetModel(userId); context.Response.Write("ok"); } else { context.Response.Write("服务器繁忙,请稍后重试"); } } }
public ActionResult CreateProxy(UsersEntity user) { string createBy = System.Web.HttpContext.Current.User.Identity.Name; if (string.IsNullOrEmpty(createBy) || null == user) { //当前没有用户登录 return(Redirect("/Home/Index")); } UsersEntity entity = new UsersEntity(); entity.UserName = user.UserName; entity.UserCode = user.UserCode; entity.Password = user.Password == null ? "111111" : user.Password; entity.CreateBy = createBy; entity.Phone = user.Phone; entity.UserType = user.UserType; entity.IsActive = user.IsActive; entity.Memo = user.Memo; entity.CreateTime = DateTime.Now; entity.UpdateTime = DateTime.Now; UsersBll.GetInstance().Insert(entity); return(Redirect("/User/Index/")); }
public ActionResult Delete(long uid) { long ret = UsersBll.GetInstance().DeleteLogical(uid); return(Redirect("/User/Index")); }
public void ProcessRequest(HttpContext context) { context.Response.ContentType = "text/html"; if (context.Request.Form["username"] != null) { string username = context.Request.Form["username"]; string password = context.Request.Form["password"]; UsersBll bll = new UsersBll(); if (username != "" && password != "") { int i = bll.Login(username, password); if (i > 0) { context.Session["Name"] = username; context.Response.Redirect("../list.html"); } else { context.Response.Write("<script>alert('Error');window.location='../index.html';</script>"); } } } else { context.Response.Redirect("../index.html"); } context.Response.End(); }
/// <summary> /// 登录 /// </summary> /// <returns></returns> public ActionResult Index() { HttpCookie cookie = Request.Cookies["USERINFO"]; if (cookie == null) { return(View()); } string USERNAME = cookie.Values["USERNAME"]; string PASSWORD = cookie.Values["PASSWORD"]; if (string.IsNullOrEmpty(USERNAME) || string.IsNullOrEmpty(PASSWORD)) { cookie.Expires = DateTime.Now.AddDays(-30); Response.AppendCookie(cookie); } else { var usersBll = new UsersBll(); var item = usersBll.LoginUsers(HashEncrypt.DecryptQueryString(USERNAME), HashEncrypt.DecryptQueryString(PASSWORD)); if (item != null) { Session["USERID"] = HashEncrypt.EncryptQueryString(item.UserID.ToString()); return(RedirectPermanent("../Home/Index")); } else { cookie.Expires = DateTime.Now.AddDays(-30); Response.AppendCookie(cookie); } } return(View()); }
public JsonResult ResetPassword() { #region 权限控制 //显示申明哪几个节点具有该功能->解决已拥有部分权限,而想跳过权限判断问题。 int[] iRangePage = { AddPageNodeId, EditPageNodeId, DetailPageNodeId }; int iCurrentPageNodeId = RequestParameters.Pint("NodeId"); int iCurrentButtonId = (int)EButtonType.ResetPassword; var tempNoAuth = Utits.IsOperateAuth(iRangePage, iCurrentPageNodeId, iCurrentButtonId); if (tempNoAuth.ErrorType != 1) { return(Json(tempNoAuth)); } #endregion string szIds = RequestParameters.Pstring("ids"); if (string.IsNullOrEmpty(szIds)) { var sRetrunModel = new ResultMessage(); sRetrunModel.ErrorType = 0; sRetrunModel.MessageContent = "参数错误."; return(Json(sRetrunModel)); } string[] strids = szIds.Split(','); System.Collections.ArrayList arrayList = new System.Collections.ArrayList(); foreach (string t in strids) { if (RegexValidate.IsGuid(t)) { arrayList.Add(t); } } string[] ids = (string[])arrayList.ToArray(typeof(string)); if (!ids.Any()) { var sRetrunModel = new ResultMessage { ErrorType = 0, MessageContent = "参数错误." }; return(Json(sRetrunModel)); } var cBll = new UsersBll(); bool isFlag = cBll.ResetPassword(ids); if (isFlag) { var sRetrunModel = new ResultMessage(); sRetrunModel.ErrorType = 1; sRetrunModel.MessageContent = string.Format("操作成功,重置后的密码为:{0}.", CommonLib.Config.SystemInitPassword); return(Json(sRetrunModel)); } else { var sRetrunModel = new ResultMessage(); sRetrunModel.ErrorType = 0; sRetrunModel.MessageContent = "操作失败."; return(Json(sRetrunModel)); } }
public string AddOrder(int userid, int productid, int pronum) { string result = "1"; Order order = new Order(); OrderBll orderbll = new OrderBll(); OrderList orderlist = new OrderList(); OrderListBll orderlistbll = new OrderListBll(); ProductBll pbll = new ProductBll(); UsersBll ubll = new UsersBll(); try { //检查 当前用户是否有末完成的订单 有不能 //if (orderbll.GetAll("*", " [status]=1 and userid=" + userid, null, "id").Entity.Count <= 0) //{ var p = pbll.GetByPrimaryKey(productid).Entity; var u = ubll.GetByPrimaryKey(userid).Entity; order.UserId = userid; order.ReciverName = u.UserName; order.PayMentTypeId = 1;//货到付款 order.RevicerAddress = u.Address; order.RevicerTel = u.Mobile; order.Status = 1;// order.RealPrice = pronum * p.OemPrice; order.TotalPrice = pronum * p.OemPrice; order.Count = 1; order.OrderTime = DateTime.Now; order.OrderNo = OrderHelper.GetProNo(); //添加订单 int orderaddid = orderbll.AddAndReturn(order); //添加订单详情 orderlist.Count = order.Count; orderlist.Productid = productid; orderlist.Orderid = orderaddid; orderlist.OemPrice = p.OemPrice; orderlist.MarketPrice = p.MarketPrice; orderlistbll.Add(orderlist); //} //else //{ // result = "-2"; //} } catch { result = "-1"; } return(result); }
/// <summary> /// /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void UC_UserAdd_Load(object sender, EventArgs e) { //初始化Bll _usersBll = new UsersBll(); //初始化用户类型 ComboBox_UserType_Init(); //初始化 UserInfo_Init(); }
/// <summary> /// /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void Frm_EditPwd_Load(object sender, EventArgs e) { if (_curUser == null) { return; } _usersBll = new UsersBll(); textBox_UserAccount.Text = _curUser.UserAccount; }
/// <summary> /// 修改密码 /// </summary> /// <param name="userCode"></param> /// <param name="newPassword"></param> /// <returns></returns> public bool DoChangePassword(string userCode, string newPassword) { bool success = false; if (string.IsNullOrEmpty(userCode) || string.IsNullOrEmpty(newPassword)) { return(success); } success = UsersBll.GetInstance().ChangePassword(userCode, newPassword); return(success); }
// GET: Base protected override void OnActionExecuting(ActionExecutingContext filterContext) { if (null == Session["_User"]) { Redirect("/Home/Index"); return; } base.OnActionExecuting(filterContext); string currentUser = filterContext.HttpContext.User.Identity.Name; var user = UsersBll.GetInstance().GetUserByCode(currentUser); var info = LoginUserInfo.GetInstance(); info.CurrentUser = currentUser; info.Point = user.Point; info.IsAdmin = (user.UserType.Equals("1") || user.UserType.Equals("管理员")) ? true : false; info.PreUserCode = user.CreateBy; info.Id = user.Id; CurrentUserInfo = info; Session["_UserId"] = user.Id; Session["_PreUserCode"] = info.PreUserCode; Session["_Point"] = info.Point; Session["_IsAdmin"] = info.IsAdmin; Session["_UserType"] = user.UserType; Session["_UserInfo"] = info; //获取触发当前方法(OnActionExecuting)的Action名字(即:哪个Action方法被执行的时候触发的 string actionName = filterContext.ActionDescriptor.ActionName; //获取触发当前方法的的Action所在的控制器名字 string controllerName = filterContext.ActionDescriptor.ControllerDescriptor.ControllerName; var paramss = filterContext.ActionParameters; string str = ""; if (paramss.Any()) //Any是判断这个集合是否包含任何元素,如果包含元素返回true,否则返回false { foreach (var key in paramss.Keys) //遍历它的键;(因为我们要获取的是参数的名称s,所以遍历键) { str = key + "的值是" + paramss[key]; //paramss[key] 是key的值 } } if (string.IsNullOrEmpty(filterContext.HttpContext.User.Identity.Name)) { //if (!(actionName == "Index" && controllerName == "Home")) { //filterContext.HttpContext.Response.Redirect("/Home/Index"); } } }
public string AddOrder(int userid, string data, int price, string pno, string payMentType, int bananaCount) { string result = "0"; Order order = new Order(); OrderBll orderbll = new OrderBll(); UsersBll ubll = new UsersBll(); var u = ubll.GetByPrimaryKey(userid).Entity; try { order.UserId = userid; order.ReciverName = u.UserName; order.PayMentTypeId = (byte?)(payMentType == "货到付款" ? 1 : 2);//货到付款 order.RevicerAddress = u.Address; order.RevicerTel = u.Mobile; order.Status = 0;//等待确认 order.RealPrice = price; order.TotalPrice = price; order.Count = 1; order.OrderTime = DateTime.Now; order.OrderNo = OrderHelper.GetProNo(); order.Pno = pno == "" ? null : pno; order.BananaCount = bananaCount; //添加订单 int orderaddid = orderbll.AddAndReturn(order); sendYzm("18758177964", "26871", new string[] { u.UserName + u.Mobile, DateTime.Now.ToString() }); string[] dataArr = data.Split(','); if (dataArr.Length > 0) { for (int d = 0; d < dataArr.Length; d++) { if (!string.IsNullOrEmpty(dataArr[d])) { if (dataArr[d].IndexOf("|") > -1) { string[] arr = dataArr[d].Split('|'); AddOrderList(u, Convert.ToInt32(arr[0]), Convert.ToInt32(arr[1]), orderaddid); result = orderaddid.ToString(); } } } } } catch { result = "-1"; } return(result); }
public void ProcessRequest(HttpContext context) { context.Response.ContentType = "text/plain"; int useerid = Convert.ToInt32(context.Request["id"]); int updateid = Convert.ToInt32(context.Request["dele"]); Users u = new Users(); UsersBll ub = new UsersBll(); u = ub.GetModel(useerid); u.UserStateId = updateid; ub.Update(u); }
public JsonResult ListPhyDel() { #region 权限控制 int[] iRangePage = { AddPageNodeId, EditPageNodeId, DetailPageNodeId }; int iCurrentPageNodeId = RequestParameters.Pint("NodeId"); int iCurrentButtonId = (int)EButtonType.PhyDelete; var tempNoAuth = Utits.IsOperateAuth(iRangePage, iCurrentPageNodeId, iCurrentButtonId); if (tempNoAuth.ErrorType != 1) { return(Json(tempNoAuth)); } #endregion Guid ID = RequestParameters.PGuid("ids"); if (ID == Guid.Empty) { var sRetrunModel = new ResultMessage(); sRetrunModel.ErrorType = 0; sRetrunModel.MessageContent = "参数错误."; return(Json(sRetrunModel)); } var cBll = new UsersBll(); bool isFlag = cBll.PhysicalDelete(ID, Utits.WelfareCentreID); if (isFlag) { var authNodeBll = new AuthNodeBll(); authNodeBll.PhysicalDeleteByUserIDs(ID); var authNodeButtonBll = new AuthNodeButtonBll(); authNodeButtonBll.PhysicalDeleteByUserIDs(ID); ParamState = "4"; ParamID = ID.ToString(); var cLog = new LogsBll(); cLog.Log(ParamID, ParamName, ParamState, Utits.CurrentUserID.ToString(), Utits.CurrentRealName.ToString(), Utits.WelfareCentreID.ToString(), Utits.ClientIPAddress.ToString()); var sRetrunModel = new ResultMessage(); sRetrunModel.ErrorType = 1; sRetrunModel.MessageContent = "操作成功."; return(Json(sRetrunModel)); } else { var sRetrunModel = new ResultMessage(); sRetrunModel.ErrorType = 0; sRetrunModel.MessageContent = "操作失败."; return(Json(sRetrunModel)); } }
protected void Page_Load(object sender, EventArgs e) { if (!Page.IsPostBack) { UsersModel model = new UsersModel(); UsersBll bll = new UsersBll(); int UserId = Convert.ToInt32(Context.Request.Params.Get("UserId")); model = bll.GetModel(UserId); this.txtUserName.Text = model.UserName; this.txtPwd.Text = model.Pwd; this.txtEmail.Text = model.Email; this.txtNick.Text = model.Nick; } }
/// <summary> /// LOAD /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void UC_UserManager_Load(object sender, EventArgs e) { _userBll = new UsersBll(); comboBox_SelectType.SelectedIndex = 0; comboBox_Sore.SelectedIndex = 0; AddDataGridViewButtonColumn(); dataGridView_Users.AutoGenerateColumns = false; button_Select_Click(this, EventArgs.Empty); dataGridView_Users.ClearSelection(); }
public JsonResult BlurName() { #region 权限控制 int[] iRangePage = { AddPageNodeId, EditPageNodeId, DetailPageNodeId }; int iCurrentPageNodeId = RequestParameters.Pint("NodeId"); var tempAuth = Utits.IsNodePageAuth(iRangePage, iCurrentPageNodeId); if (tempAuth.ErrorType != 1) { return(Json(tempAuth)); } #endregion string UserName = RequestParameters.Pstring("UserName"); if (UserName.Length <= 0) { var sRetrunModel = new ResultMessage(); sRetrunModel.ErrorType = 0; sRetrunModel.MessageContent = "用户名不能为空."; return(Json(sRetrunModel)); } var cBll = new UsersBll(); bool isFlagValidation = false; switch (iCurrentPageNodeId) { case (int)NodePagesSetting.EUsers.AddPage: isFlagValidation = cBll.ValidationUserName(UserName); break; case (int)NodePagesSetting.EUsers.EditPage: Guid ID = RequestParameters.PGuid("ID"); isFlagValidation = cBll.ValidationUserName(ID, UserName); break; } if (isFlagValidation) { var sRetrunModel = new ResultMessage(); sRetrunModel.ErrorType = 1; sRetrunModel.MessageContent = "用户名填写正确."; return(Json(sRetrunModel)); } else { var sRetrunModel = new ResultMessage(); sRetrunModel.ErrorType = 0; sRetrunModel.MessageContent = "用户名已存在."; return(Json(sRetrunModel)); } }
public string GetCareName() { var buf = new StringBuilder(); var cBll = new UsersBll(); var list = cBll.SearchListByValid(Utits.WelfareCentreID); buf.AppendFormat("<option value=\"{0}\">{1}</option>", "请选择", "==请选择=="); if (list != null) { foreach (var item in list) { buf.AppendFormat("<option value=\"{0}\">{1}</option>", item.UserID, item.RealName); } } return(buf.ToString()); }