Пример #1
0
        public ActionResult EditUserInfo(Users user)
        {
            int id       = Convert.ToInt32(Request["Id"]);
            var userinfo = userbll.LoadEntities(c => c.Id == id).FirstOrDefault();

            if (userinfo != null)
            {
                string userrole  = Request["UserRoleId"];
                var    roleid    = rolebll.LoadEntities(c => c.RoleName == userrole).FirstOrDefault();
                string userstate = Request["UserStateId"];
                var    stateid   = statebll.LoadEntities(c => c.Name == userstate).FirstOrDefault();
                userinfo.LoginId     = user.LoginId;
                userinfo.LoginPwd    = user.LoginPwd;
                userinfo.Name        = user.Name;
                userinfo.Address     = user.Address;
                userinfo.Phone       = user.Phone;
                userinfo.Mail        = user.Mail;
                userinfo.UserRoleId  = roleid.RoleId;
                userinfo.UserStateId = stateid.Id;
                userinfo.Money       = user.Money;
                if (userbll.UpdateEntity(userinfo))
                {
                    return(Content("ok"));
                }
                else
                {
                    return(Content("no"));
                }
            }
            else
            {
                return(Content("no"));
            }
        }
Пример #2
0
        //
        // GET: /Personal/

        public ActionResult Index()
        {
            //查询用户信息
            if (Session["user"] != null)
            {
                Users user      = Session["user"] as Users;
                var   usermodel = userbll.LoadEntities(c => c.Id == user.Id).FirstOrDefault();
                if (usermodel != null)
                {
                    ViewData["usermodel"] = usermodel;
                }
                else
                {
                    Response.Redirect("/Account/Index");
                }
            }
            else
            {
                Response.Redirect("/Account/Index");
            }
            return(View());
        }
Пример #3
0
        public void Login()
        {
            string email       = Request["Mail"];
            string pwd         = Request["LoginPwd"];
            string vcode       = Request["Vcode"];
            string redirecturl = HttpUtility.UrlDecode(Request["redirecturl"]);

            if (!string.IsNullOrEmpty(email) && !string.IsNullOrEmpty(pwd) && !string.IsNullOrEmpty(vcode))
            {
                if (Session["vcode"] != null && Session["vcode"].ToString() == vcode)
                {
                    string md5pwd = pwd.Md5();
                    var    user   = userbll.LoadEntities(c => c.Mail == email && c.LoginPwd == md5pwd).FirstOrDefault();
                    if (user != null)
                    {
                        Session["user"] = user;
                        Session.Remove("vcode");
                        if (!string.IsNullOrEmpty(redirecturl))
                        {
                            //WebCommon.GoNext("亲,登录成功了哦!", "正在返回登录前页面", HttpUtility.UrlDecode(redirect.ToString()));
                            WebCommon.Url(redirecturl);
                        }
                        else
                        {
                            WebCommon.Url("/Home/Index");
                        }
                    }
                    else
                    {
                        WebCommon.GoBack("亲,邮箱或密码不正确哦!");
                    }
                }
                else
                {
                    WebCommon.GoBack("亲,验证码不正确哦!");
                }
            }
            else
            {
                WebCommon.GoBack("亲,数据还没有填完哦!");
            }
        }
Пример #4
0
        public void Login()
        {
            bool IsPostBack = Convert.ToBoolean(Request["post"]);

            if (IsPostBack)
            {
                string name    = Request["username"];
                string pwd     = Request["password"];
                bool   checkme = Convert.ToBoolean(Request["remember-me"]);
                if (string.IsNullOrEmpty(name))
                {
                    WebCommon.GoBack("账号不能为空!");
                }
                else if (string.IsNullOrEmpty(pwd))
                {
                    WebCommon.GoBack("密码不能为空!");
                }
                else
                {
                    var status = userbll.LoadEntities(c => c.LoginId == name && c.UserStateId == 1).FirstOrDefault();
                    if (status != null)
                    {
                        string md5pwd = pwd.Md5();
                        var    user   = userbll.LoadEntities(c => c.LoginId == name && c.LoginPwd == md5pwd).FirstOrDefault();
                        if (user != null)
                        {
                            var role = userbll.LoadEntities(c => c.LoginId == name && c.LoginPwd == md5pwd && c.UserRoleId == 1).FirstOrDefault();
                            if (role != null)
                            {
                                if (checkme)//记住我
                                {
                                    HttpCookie cp1 = new HttpCookie("name", name);
                                    HttpCookie cp2 = new HttpCookie("pwd", pwd);
                                    cp1.Expires = DateTime.Now.AddDays(7);
                                    cp2.Expires = DateTime.Now.AddDays(7);
                                    Response.Cookies.Add(cp1);
                                    Response.Cookies.Add(cp2);
                                }
                                Session["admin"] = user;
                                WebCommon.GoNext("登录成功", "首页", "/Admin/AdminHome/Index");
                            }
                            else
                            {
                                WebCommon.GoBack("对不起,你不是管理员!");
                            }
                        }
                        else
                        {
                            WebCommon.GoBack("用户名或密码错误!");
                        }
                    }
                    else
                    {
                        WebCommon.GoBack("对不起,你的账号已被锁定!");
                    }
                }
            }
            else
            {
                Response.Redirect("/Admin/AdminLogin/Index");
            }
        }
Пример #5
0
        //购买页面
        public ActionResult OrderInfo()
        {
            if (Session["user"] != null)
            {
                Users   user       = Session["user"] as Users;
                var     userorder  = userbll.LoadEntities(c => c.Id == user.Id).FirstOrDefault();
                string  action     = Request["action"];
                decimal totalPrice = 0;
                //从购物车中购买
                if (action == "cart")
                {
                    int page;
                    int pageSize = 3;
                    int count    = cartbll.LoadEntities(c => c.UserId == user.Id).Count();

                    int pageCount = Convert.ToInt32(Math.Ceiling((double)count / pageSize));
                    if (!int.TryParse(Request["page"], out page))
                    {
                        page = 1;
                    }
                    page = page < 1 ? 1 : page;
                    page = page > pageCount ? pageCount : page;
                    List <Cart> cartmodel = new List <Cart>();
                    if (count != 0)
                    {
                        cartmodel = cartbll.LoadPageEntities <int>(page, pageSize, c => c.UserId == user.Id, c => c.Id, false).ToList();
                    }
                    //计算总金额
                    var pricemodel = cartbll.LoadEntities(c => c.UserId == user.Id).ToList();
                    int ordercount = Convert.ToInt32(Request["count"]);
                    foreach (var item in pricemodel)
                    {
                        double discount = (double)item.Books.Discount / 100;
                        if (discount > 0 && discount < 1)
                        {
                            totalPrice = totalPrice + (int)item.Count * (decimal)item.Books.UnitPrice * (decimal)discount;
                        }
                        else
                        {
                            totalPrice = totalPrice + (int)item.Count * (decimal)item.Books.UnitPrice;
                        }
                    }
                    if (cartmodel != null)
                    {
                        ViewData["cartmodel"]  = cartmodel;
                        ViewData["totalPrice"] = totalPrice.ToString("0.00");
                        ViewData["action"]     = "cart";
                        ViewBag.PageIndex      = page;
                        ViewBag.PageCount      = pageCount;
                    }
                    else
                    {
                        ViewData["cartmodel"] = null;
                    }
                }
                //直接购买
                else
                {
                    int id         = Convert.ToInt32(Request["id"]);
                    int ordercount = Convert.ToInt32(Request["count"]);
                    var bookmodel  = bookbll.LoadEntities(c => c.Id == id).FirstOrDefault();
                    if (bookmodel != null)
                    {
                        ViewData["bookmodel"] = bookmodel;
                        ViewData["count"]     = ordercount;
                        double discount = (double)bookmodel.Discount / 100;
                        if (discount > 0 && discount < 1)
                        {
                            ViewData["totalPrice"] = (bookmodel.UnitPrice * ordercount * (decimal)discount).ToString("0.00");
                        }
                        else
                        {
                            ViewData["totalPrice"] = (bookmodel.UnitPrice * ordercount).ToString("0.00");
                        }
                    }
                    else
                    {
                        return(Redirect("/Home/Index"));
                    }
                }
                ViewData["usermodel"] = userorder;
            }
            else
            {
                return(Redirect("/Account/Index?redirect=" + HttpUtility.UrlEncode(Request.Url.ToString())));
            }
            return(View());
        }