Esempio n. 1
0
        public ActionResult Index()
        {
            List <MemberModel> mmList     = new List <MemberModel>();
            List <Member>      memberList = new List <Member>();

            var parent = LoginManager.GetCurrentUser().Account;

            try
            {
                // 獲取當前管理員下面主管   和 主管下員工
                memberList = _underlingManager.GetUnderlingList();
                mmList     = ModelChangeManager.ChangeTOMemberModel(memberList);
            }
            catch (Exception ex)
            {
                LogHelper.writeLog_error(ex.Message);
                LogHelper.writeLog_error(ex.StackTrace);
            }

            ViewData["UserList"] = mmList;
            return(View());
        }
Esempio n. 2
0
        public ActionResult AddMember(MemberModel model)
        {
            AjaxResult ar = new AjaxResult();

            if (model == null)
            {
                ar.state   = ResultType.error;
                ar.message = "提交的数据为空,添加失败";

                return(Json(ar, JsonRequestBehavior.AllowGet));
            }

            try
            {
                Member member = new Member();

                var currentUser = LoginManager.GetCurrentUser();

                #region 判斷上級是否是同級了

                object parent = null;
                if (model.ParentName == null)
                {
                    parent = currentUser.Account;
                }
                else
                {
                    var parentResult = IsSameRange(model.ParentName, model.RoleCode);
                    if (parentResult == OperatorState.empty)
                    {
                        ar.state   = ResultType.error.ToString();
                        ar.message = "不能獲取對應的上級賬號,添加新用戶失敗";

                        return(Json(ar, JsonRequestBehavior.AllowGet));
                    }
                    else if (parentResult == OperatorState.error)
                    {
                        parent = currentUser.Account;
                    }
                    else if (parentResult == OperatorState.success)
                    {
                        parent = model.ParentName;
                    }
                }
                #endregion

                var result = _memberBLL.AddMember(model.Name, model.RoleCode, parent.ToString(), currentUser.CompanyCode, ref member);

                if (result == OperatorState.error)
                {
                    ar.state   = ResultType.error.ToString();
                    ar.message = "添加新用户失败";
                }
                else if (result == OperatorState.success)
                {
                    ar.state = ResultType.success.ToString();
                    _underlingManager.AddUnderlingList(member);
                    ar.data    = ModelChangeManager.ChangeTOMemberModel(member);
                    ar.message = "添加成功";
                }

                return(Json(ar, JsonRequestBehavior.AllowGet));
            }
            catch (Exception ex)
            {
                LogHelper.writeLog_error(ex.Message);
                LogHelper.writeLog_error(ex.StackTrace);

                ar.state   = ResultType.error;
                ar.message = "系统错误,添加新用户失败";

                return(Json(ar, JsonRequestBehavior.AllowGet));
            }
        }