Exemplo n.º 1
0
 /// <summary>
 /// 判断管理员是否已经登录(解决Session超时问题)
 /// </summary>
 public bool IsAdminLogin()
 {
     //如果Session为Null
     if (Session[OSKeys.SESSION_ADMIN_INFO] != null)
     {
         return(true);
     }
     else
     {
         //检查Cookies
         string adminname = Utils.GetCookie("AdminName", "OS");
         string adminpwd  = Utils.GetCookie("AdminPwd", "OS");
         if (adminname != "" && adminpwd != "")
         {
             BLL.managers.manager   bll   = new BLL.managers.manager();
             Model.managers.manager model = bll.GetModel(adminname, adminpwd);
             if (model != null)
             {
                 Session[OSKeys.SESSION_ADMIN_INFO] = model;
                 return(true);
             }
         }
     }
     return(false);
 }
Exemplo n.º 2
0
        private bool DoEdit(int _id)
        {
            bool result = false;

            BLL.managers.manager   bll   = new BLL.managers.manager();
            Model.managers.manager model = bll.GetModel(_id);

            model.role_id   = int.Parse(ddlRoleId.SelectedValue);
            model.role_type = new BLL.managers.manager_role().GetModel(model.role_id).role_type;
            if (cbIsLock.Checked == true)
            {
                model.is_lock = 0;
            }
            else
            {
                model.is_lock = 1;
            }
            //判断密码是否更改
            if (txtPassword.Text.Trim() != defaultpassword)
            {
                //获取用户已生成的salt作为密钥加密
                model.password = DESEncrypt.Encrypt(txtPassword.Text.Trim(), model.salt);
            }
            model.real_name = txtRealName.Text.Trim();
            model.telephone = txtTelephone.Text.Trim();
            model.email     = txtEmail.Text.Trim();

            if (bll.Update(model))
            {
                AddAdminLog(OSEnums.ActionEnum.Edit.ToString(), "修改管理员:" + model.user_name); //记录日志
                result = true;
            }

            return(result);
        }
Exemplo n.º 3
0
        protected void btnSubmit_Click(object sender, EventArgs e)
        {
            string userName   = txtUserName.Text.Trim();
            string userPwd    = txtPassword.Text.Trim();
            string ManageCode = TxtManageCode.Text.Trim();

            if (ManageCode != OS.Web.UI.BasePage.config.emailnickname)
            {
                msgtip.InnerHtml = "管理认证码输入不正确";
                return;
            }
            if (userName.Equals("") || userPwd.Equals(""))
            {
                msgtip.InnerHtml = "请输入用户名或密码";
                return;
            }
            if (Session["AdminLoginSun"] == null)
            {
                Session["AdminLoginSun"] = 1;
            }
            else
            {
                Session["AdminLoginSun"] = Convert.ToInt32(Session["AdminLoginSun"]) + 1;
            }
            //判断登录错误次数
            if (Session["AdminLoginSun"] != null && Convert.ToInt32(Session["AdminLoginSun"]) > 5)
            {
                msgtip.InnerHtml = "错误超过5次,关闭浏览器重新登录!";
                return;
            }
            BLL.managers.manager   bll   = new BLL.managers.manager();
            Model.managers.manager model = bll.GetModel(userName, userPwd, true);
            if (model == null)
            {
                msgtip.InnerHtml = "用户名或密码有误,请重试!";
                return;
            }
            Session[OSKeys.SESSION_ADMIN_INFO] = model;
            Session.Timeout = 45;
            //写入登录日志
            Model.configs.siteconfig siteConfig = new BLL.configs.siteconfig().loadConfig();
            if (siteConfig.logstatus > 0)
            {
                new BLL.managers.manager_log().Add(model.id, model.user_name, OSEnums.ActionEnum.Login.ToString(), "用户登录");
            }
            //写入Cookies
            Utils.WriteCookie("LoginName", model.user_name, 14400);
            Utils.WriteCookie("AdminName", "OS", model.user_name);
            Utils.WriteCookie("AdminPwd", "OS", model.password);
            Response.Redirect("Main.aspx");
            return;
        }
Exemplo n.º 4
0
 protected void btnSubmit_Click(object sender, EventArgs e)
 {
     string userName = txtUserName.Text.Trim();
     string userPwd = txtPassword.Text.Trim();
     string ManageCode = TxtManageCode.Text.Trim();
     if (ManageCode != OS.Web.UI.BasePage.config.emailnickname) {
         msgtip.InnerHtml = "管理认证码输入不正确";
         return;
     }
     if (userName.Equals("") || userPwd.Equals("")) {
         msgtip.InnerHtml = "请输入用户名或密码";
         return;
     }
     if (Session["AdminLoginSun"] == null) {
         Session["AdminLoginSun"] = 1;
     }
     else {
         Session["AdminLoginSun"] = Convert.ToInt32(Session["AdminLoginSun"]) + 1;
     }
     //判断登录错误次数
     if (Session["AdminLoginSun"] != null && Convert.ToInt32(Session["AdminLoginSun"]) > 5) {
         msgtip.InnerHtml = "错误超过5次,关闭浏览器重新登录!";
         return;
     }
     BLL.managers.manager bll = new BLL.managers.manager();
     Model.managers.manager model = bll.GetModel(userName, userPwd, true);
     if (model == null) {
         msgtip.InnerHtml = "用户名或密码有误,请重试!";
         return;
     }
     Session[OSKeys.SESSION_ADMIN_INFO] = model;
     Session.Timeout = 45;
     //写入登录日志
     Model.configs.siteconfig siteConfig = new BLL.configs.siteconfig().loadConfig();
     if (siteConfig.logstatus > 0) {
         new BLL.managers.manager_log().Add(model.id, model.user_name, OSEnums.ActionEnum.Login.ToString(), "用户登录");
     }
     //写入Cookies
     Utils.WriteCookie("LoginName", model.user_name, 14400);
     Utils.WriteCookie("AdminName", "OS", model.user_name);
     Utils.WriteCookie("AdminPwd", "OS", model.password);
     Response.Redirect("Main.aspx");
     return;
 }
Exemplo n.º 5
0
 private void ShowInfo(int _id)
 {
     BLL.managers.manager   bll   = new BLL.managers.manager();
     Model.managers.manager model = bll.GetModel(_id);
     ddlRoleId.SelectedValue = model.role_id.ToString();
     if (model.is_lock == 0)
     {
         cbIsLock.Checked = true;
     }
     else
     {
         cbIsLock.Checked = false;
     }
     txtUserName.Text     = model.user_name;
     txtUserName.ReadOnly = true;
     txtUserName.Attributes.Remove("ajaxurl");
     if (!string.IsNullOrEmpty(model.password))
     {
         txtPassword.Attributes["value"] = txtPassword1.Attributes["value"] = defaultpassword;
     }
     txtRealName.Text  = model.real_name;
     txtTelephone.Text = model.telephone;
     txtEmail.Text     = model.email;
 }
Exemplo n.º 6
0
 private void ShowInfo(int _id)
 {
     BLL.managers.manager bll = new BLL.managers.manager();
     Model.managers.manager model = bll.GetModel(_id);
     ddlRoleId.SelectedValue = model.role_id.ToString();
     if (model.is_lock == 0)
     {
         cbIsLock.Checked = true;
     }
     else
     {
         cbIsLock.Checked = false;
     }
     txtUserName.Text = model.user_name;
     txtUserName.ReadOnly = true;
     txtUserName.Attributes.Remove("ajaxurl");
     if (!string.IsNullOrEmpty(model.password))
     {
         txtPassword.Attributes["value"] = txtPassword1.Attributes["value"] = defaultpassword;
     }
     txtRealName.Text = model.real_name;
     txtTelephone.Text = model.telephone;
     txtEmail.Text = model.email;
 }
Exemplo n.º 7
0
        private bool DoEdit(int _id)
        {
            bool result = false;
            BLL.managers.manager bll = new BLL.managers.manager();
            Model.managers.manager model = bll.GetModel(_id);

            model.role_id = int.Parse(ddlRoleId.SelectedValue);
            model.role_type = new BLL.managers.manager_role().GetModel(model.role_id).role_type;
            if (cbIsLock.Checked == true)
            {
                model.is_lock = 0;
            }
            else
            {
                model.is_lock = 1;
            }
            //判断密码是否更改
            if (txtPassword.Text.Trim() != defaultpassword)
            {
                //获取用户已生成的salt作为密钥加密
                model.password = DESEncrypt.Encrypt(txtPassword.Text.Trim(), model.salt);
            }
            model.real_name = txtRealName.Text.Trim();
            model.telephone = txtTelephone.Text.Trim();
            model.email = txtEmail.Text.Trim();

            if (bll.Update(model))
            {
                AddAdminLog(OSEnums.ActionEnum.Edit.ToString(), "修改管理员:" + model.user_name); //记录日志
                result = true;
            }

            return result;
        }
Exemplo n.º 8
0
 /// <summary>
 /// 判断管理员是否已经登录(解决Session超时问题)
 /// </summary>
 public bool IsAdminLogin()
 {
     //如果Session为Null
     if (Session[OSKeys.SESSION_ADMIN_INFO] != null) {
         return true;
     } else {
         //检查Cookies
         string adminname = Utils.GetCookie("AdminName", "OS");
         string adminpwd = Utils.GetCookie("AdminPwd", "OS");
         if (adminname != "" && adminpwd != "") {
             BLL.managers.manager bll = new BLL.managers.manager();
             Model.managers.manager model = bll.GetModel(adminname, adminpwd);
             if (model != null) {
                 Session[OSKeys.SESSION_ADMIN_INFO] = model;
                 return true;
             }
         }
     }
     return false;
 }