예제 #1
0
        public ActionResult PermissionsUpdate(string Id, string arrGrantStr)
        {
            string sSucceed = "1";

            try
            {
                //角色ID。
                string loginId = Id;

                //肯定授权。
                string   sGrant   = arrGrantStr;
                string[] arrGrant = null;
                if (sGrant.Length > 0)
                {
                    arrGrant = sGrant.Split(new string[] { "|" }, StringSplitOptions.RemoveEmptyEntries);
                }
                else
                {
                    arrGrant = new string[0];
                }

                var arrDeny = new string[0];

                StaffSrv.UpdatePermissions(loginId, arrGrant, arrDeny);
            }
            catch (Exception ex)
            {
                sSucceed = "-1";
            }
            return(Content(sSucceed));
        }
예제 #2
0
        public ActionResult RolesUpdate(string Id, string sRoleIds)
        {
            string sSucceed = "1";

            try
            {
                //职员ID。
                string StaffId = Id;

                //角色。
                string[] arrRoleIds = null;
                if (sRoleIds.Length > 0)
                {
                    arrRoleIds = sRoleIds.Split(new string[] { "|" }, StringSplitOptions.RemoveEmptyEntries);
                }
                else
                {
                    arrRoleIds = new string[0];
                }

                StaffSrv.UpdateRoles(StaffId, arrRoleIds);
            }
            catch (Exception ex)
            {
                sSucceed = "-1";
            }

            return(Content(sSucceed));
        }
예제 #3
0
        public ActionResult Login(FormCollection fc)
        {
            string txtUserName = fc["userName"].ToString();
            string txtPassword = fc["userpwd"].ToString();

            if (string.IsNullOrEmpty(txtUserName) || string.IsNullOrEmpty(txtPassword))
            {
                ViewBag.ErrorMsg = "用户名或密码不能为空";
                return(View());
            }

            //验证登录ID和密码。
            Staff s = StaffSrv.GetStaffByLoginIdAndPassword(txtUserName, txtPassword);

            if (s == null)
            {
                ViewBag.ErrorMsg = "用户名或密码错误";
                return(View());
            }
            else
            {
                if (s.Disabled == 1)//被禁用。
                {
                    ViewBag.ErrorMsg = "此用户已经被禁用";
                    return(View());
                }
            }

            //保存登录信息。
            SessionUtil.SavaStaffSession(new StaffSession(s.LoginId, s.IsInnerUser));
            return(Redirect("/Home/Index"));
        }
예제 #4
0
        public ActionResult StaffInfo(StaffDTO dto, string actionStr)
        {
            //如果为更新 则移除 password 验证
            if (actionStr == "update")
            {
                ModelState.Remove("Password");
            }

            if (ModelState.IsValid)
            {
                //添加
                if (actionStr == "insert")
                {
                    string result = StaffSrv.InsertStaff(dto);
                    if (!string.IsNullOrEmpty(result) && result != "-2")
                    {
                        result = "1";
                    }
                    return(Content(result, "text/plain"));
                }
                else if (actionStr == "update")
                {
                    //编辑
                    StaffSrv.UpdateStaff(dto);
                    return(Content("1", "text/plain"));
                }
            }

            //获取ErrorMessage
            string errorMsg = ModelState.Values.First(x => x.Errors.Count > 0).Errors[0].ErrorMessage;

            return(Content(errorMsg, "text/plain"));
        }
예제 #5
0
    protected void btnLogin_Click(object sender, EventArgs e)
    {
        try
        {
            if (Page.IsValid)
            {
                //验证验证码。
                if (tbValidCode.Text != StringSecurity.DESDecrypt(Request.Cookies["AreYouHuman"].Value))
                {
                    panelErrorValidCode.Visible = true;
                    tbPassword.Focus();
                    return;
                }

                //验证登录ID和密码。
                Staff s = StaffSrv.GetStaffByLoginIdAndPassword(tbLoginId.Text.Trim(), tbPassword.Text.Trim());
                if (s == null)
                {
                    panelErrorPassword.Visible = true;
                    tbPassword.Focus();
                    return;
                }
                else
                {
                    if (s.Disabled == 1)//被禁用。
                    {
                        panelStaffDisabled.Visible = true;
                        tbLoginId.Focus();
                        return;
                    }
                }

                //在Cookie中保存登录ID。
                HttpCookie hcLoginId = new HttpCookie("LoginId", s.LoginId);
                hcLoginId.Expires = DateTime.Now.AddMonths(1);
                Response.Cookies.Add(hcLoginId);

                //在Cookie中保存界面样式选择。
                HttpCookie hcInterfaceStyle = new HttpCookie("InterfaceStyle", ddlInterfaceStyle.SelectedValue);
                hcInterfaceStyle.Expires = DateTime.Now.AddMonths(1);
                Response.Cookies.Add(hcInterfaceStyle);

                //保存登录信息。
                SessionUtil.SavaStaffSession(new StaffSession(s.LoginId, s.IsInnerUser));
                FormsAuthentication.RedirectFromLoginPage(s.LoginId, false);

                //登陆成功。
                loginSuccessfully = true;
            }
        }
        catch (Exception ex)
        {
            log.Error(null, ex);
            throw;
        }
    }
예제 #6
0
        /// <summary>
        /// 删除用户
        /// </summary>
        /// <param name="Id"></param>
        /// <returns></returns>
        public ActionResult StaffDel(string Id)
        {
            string sSucceed = "1";

            try
            {
                StaffSrv.DeleteStaff(Id);
            }
            catch (Exception ex)
            {
                sSucceed = "-1";
            }
            return(Content(sSucceed));
        }
예제 #7
0
        public ActionResult StaffMove(string id, string newParentPKId)
        {
            string sSucceed = "1";

            try
            {
                string newDepartmentPKId = newParentPKId;
                StaffSrv.MoveStaff(id, newDepartmentPKId);
            }
            catch (Exception ex)
            {
                sSucceed = "-1";
            }
            return(Content(sSucceed));
        }
예제 #8
0
        public ActionResult UpdatePassword(string loginId, string pwd)
        {
            string sSucceed = "1";

            try
            {
                string LoginId  = loginId;
                string Password = pwd;
                StaffSrv.UpdatePassword(LoginId, Password);
            }
            catch (Exception ex)
            {
                sSucceed = "-1";
            }

            return(Content(sSucceed));
        }