コード例 #1
0
        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"));
                }
            }
        }
コード例 #2
0
        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"));
            }
        }
コード例 #3
0
        public ActionResult Delete(long uid)
        {
            long ret = UsersBll.GetInstance().DeleteLogical(uid);


            return(Redirect("/User/Index"));
        }
コード例 #4
0
        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/"));
        }
コード例 #5
0
        // 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");
                }
            }
        }
コード例 #6
0
ファイル: User.svc.cs プロジェクト: XHerbert/CardSaleSystem
        /// <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);
        }
コード例 #7
0
        public ActionResult InputPoint(FormCollection form)
        {
            if (form.Count == 0 || null == Session["_UserId"])
            {
                return(Redirect("/Home/Desktop"));
            }

            string cid = form["cid"];
            string pd  = form["pd"];

            long        uid    = long.Parse(Session["_UserId"].ToString());
            UsersEntity entity = UsersBll.GetInstance().GetAdminSingle(uid);

            CardSecretBll.GetInstance().InputPoint(form["cid"], form["pd"], entity.UserCode);
            //return Content();
            return(Redirect("/Home/Desktop"));
        }
コード例 #8
0
        public ActionResult SearchUser(string info)
        {
            if (null == base.CurrentUserInfo)
            {
                Redirect("/Home/Index");
                return(null);
            }
            info = info.Trim();

            if (!string.IsNullOrEmpty(info))
            {
                long uid  = Session["_UserId"] == null ? 0 : long.Parse(Session["_UserId"].ToString());
                var  user = UsersBll.GetInstance().GetAdminSingle(uid);
                ViewBag.Data = UsersBll.GetInstance().GetSearchUser(user.CreateBy, info);
                Session.Add("_Search", ViewBag.Data);
            }

            return(Redirect("/User/Index"));
        }
コード例 #9
0
        public ActionResult BuyCard(FormCollection form)
        {
            //买家UID
            long userId = base.CurrentUserInfo.Id;

            if (form.Count == 0 || int.Parse(form["count"]) == 0 || userId == 0)
            {
                return(Redirect("/Card/Index"));
            }

            UsersEntity user   = UsersBll.GetInstance().GetAdminSingle(userId);
            UsersEntity seller = UsersBll.GetInstance().GetUserByCode(user.CreateBy);
            //卖家UID
            long   sellerUserId = seller.Id;
            short  status       = 2;
            int    count        = int.Parse(form["count"]);
            long   cardId       = long.Parse(form["cardId"]);
            string buyerCode    = user.UserCode;
            bool   ret          = CardSecretBll.GetInstance().BuyCard(buyerCode, userId, sellerUserId, cardId, status, count);

            return(Redirect("/Card/Index"));
        }
コード例 #10
0
ファイル: User.svc.cs プロジェクト: XHerbert/CardSaleSystem
        /// <summary>
        /// 登录
        /// </summary>
        /// <param name="user"></param>
        /// <param name="pass"></param>
        /// <returns></returns>
        public bool DoLogin(string user, string pass)
        {
            bool success = false;

            if (string.IsNullOrEmpty(user) || string.IsNullOrEmpty(pass))
            {
                return(success);
            }
            else
            {
                bool allowed = UsersBll.GetInstance().IsAllowedLogin(new UsersEntity {
                    UserCode = user, Password = pass
                });
                if (allowed)
                {
                    success = true;
                }
                else
                {
                    success = false;
                }
            }
            return(success);
        }
コード例 #11
0
        // GET: User
        public ActionResult Index()
        {
            string  currentUser = System.Web.HttpContext.Current.User.Identity.Name;
            string  createBy    = string.IsNullOrEmpty(currentUser) ? string.Empty : currentUser;
            UserExt uext        = new UserExt();

            if (Session["_Search"] != null)
            {
                var userEntities = Session["_Search"] as List <UsersEntity>;
                Session.Remove("_Search");
                uext.UsersEntity = userEntities;
                ViewBag.Data     = uext;
            }
            else
            {
                IList <UsersEntity> list = new List <UsersEntity>();
                list             = UsersBll.GetInstance().GetSpecialUsers(createBy);
                uext.UsersEntity = list;
                ViewBag.Data     = uext;
            }


            return(View(uext));
        }
コード例 #12
0
        public ActionResult DoLogin(FormCollection form)
        {
            string user = form["username"];
            string pass = form["password"];

            if (string.IsNullOrEmpty(user) || string.IsNullOrEmpty(pass))
            {
                return(Redirect("Index"));
            }
            else
            {
                bool allowed = UsersBll.GetInstance().IsAllowedLogin(new UsersEntity {
                    UserCode = user, Password = pass
                });
                if (allowed)
                {
                    return(Redirect("/Home/Index"));
                }
                else
                {
                    return(Redirect("Index"));
                }
            }
        }
コード例 #13
0
        public ActionResult GetUsedCard(bool used)
        {
            long uid = Session["_UserId"] == null ? 0 : long.Parse(Session["_UserId"].ToString());

            if (uid <= 0)
            {
                return(Redirect("/Card/Index"));
            }

            var user = UsersBll.GetInstance().GetAdminSingle(uid);

            CardSaleSystem.ServiceReference.CardClient client = new CardClient();
            client.DoWork();

            IList <CardSecretEntity> card = CardSecretBll.GetInstance().GetUsedCard(user.UserCode, used);
            var act = ActTypeBll.GetInstance().GetActTypeList();
            CardSecretEntityExt queryExt = new CardSecretEntityExt();

            queryExt.CardSecretEntity = card;
            queryExt.ActTypeEntity    = act;
            ViewBag.Data = queryExt;
            ModelState.Clear();
            return(PartialView("/Views/Card/Partial/_PartialCardView.cshtml"));
        }
コード例 #14
0
        public ActionResult GetSpecialCard(FormCollection form)
        {
            if (form.Count == 0 || form["querycard"].ToString().Length == 0)
            {
                return(Redirect("/Card/Index"));
            }
            long uid = Session["_UserId"] == null ? 0 : long.Parse(Session["_UserId"].ToString());

            if (uid <= 0)
            {
                return(Redirect("/Card/Index"));
            }

            var    user   = UsersBll.GetInstance().GetAdminSingle(uid);
            string cardNo = form["querycard"];
            IList <CardSecretEntity> card = CardSecretBll.GetInstance().GetSpecialCard(user.UserCode, cardNo);
            var act = ActTypeBll.GetInstance().GetActTypeList();
            CardSecretEntityExt queryExt = new CardSecretEntityExt();

            queryExt.CardSecretEntity = card;
            queryExt.ActTypeEntity    = act;
            Session.Add("special", queryExt);
            return(Redirect("/Card/Index"));
        }