Пример #1
0
        protected Model.sys_manager admin_info; //管理员信息
        protected void Page_Load(object sender, EventArgs e)
        {
            admin_info = GetAdminInfo();

            this.action   = RequestHelper.GetQueryString("action");
            this.id       = RequestHelper.GetQueryInt("id");
            this.class_id = RequestHelper.GetQueryInt("class_id");
            this.page     = RequestHelper.GetQueryInt("page", 1);

            if (this.id > 0)
            {
                if (!new BLL.common_resource().Exists(this.id))
                {
                    JscriptMsg("记录不存在或已被删除!", "back");
                    return;
                }
            }
            if (this.class_id > 0)
            {
                Model.classroom_info model = new BLL.classroom_info().GetModel(this.class_id);
                if (model == null)
                {
                    JscriptMsg("没有此课堂!", "back");
                    return;
                }
                else
                {
                    this.user_id        = model.user_id;
                    this.classroom_name = model.name;
                }
            }

            if (!Page.IsPostBack)
            {
                ChkAdminLevel("_classroom_article_materials", EnumCollection.ActionEnum.View.ToString()); //检查权限

                if (action == EnumCollection.ActionEnum.Modify.ToString())                                //修改
                {
                    ShowInfo(this.id);
                }
            }
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            this.keywords  = RequestHelper.GetQueryString("keywords");
            this.page      = RequestHelper.GetQueryInt("page", 1);
            this.pageSize  = GetPageSize(10); //每页数量
            this.class_id  = RequestHelper.GetQueryInt("class_id");
            this.adminInfo = GetAdminInfo();

            if (this.adminInfo == null)
            {
                JscriptMsg("登录超时,请重新登录", "/admin/login.aspx");
                return;
            }
            if (!Page.IsPostBack)
            {
                ChkAdminLevel("_classroom_article_materials", EnumCollection.ActionEnum.View.ToString()); //检查权限
                BindSelect();
                BindData();
            }
        }
        private bool DoEdit(int _id)
        {
            bool result = false;

            BLL.sys_manager   bll   = new BLL.sys_manager();
            Model.sys_manager model = bll.GetModel(_id);
            if (model.role_id != 1 && int.Parse(ddlRoleId.SelectedValue) == 1)
            {
                DBUtility.DbHelperSQL.ExecuteSql("delete ybd_ct_ctinfos where login_name='" + model.user_name + "'");
            }
            model.role_id   = int.Parse(ddlRoleId.SelectedValue);
            model.role_type = new BLL.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(EnumCollection.ActionEnum.Modify.ToString(), "修改管理员:" + model.user_name); //记录日志
                result = true;
            }

            return(result);
        }
        private bool DoAdd()
        {
            Model.sys_manager model = new Model.sys_manager();
            BLL.sys_manager   bll   = new BLL.sys_manager();
            model.role_id   = int.Parse(ddlRoleId.SelectedValue);
            model.role_type = new BLL.manager_role().GetModel(model.role_id).role_type;
            if (cbIsLock.Checked == true)
            {
                model.is_lock = 0;
            }
            else
            {
                model.is_lock = 1;
            }
            //检测用户名是否重复
            if (bll.Exists(txtUserName.Text.Trim()))
            {
                return(false);
            }
            model.user_name = txtUserName.Text.Trim();
            //获得6位的salt加密字符串
            model.salt = Utils.GetCheckCode(6);
            //以随机生成的6位字符串做为密钥加密
            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();
            model.add_time  = DateTime.Now;

            if (bll.Add(model) > 0)
            {
                AddAdminLog(EnumCollection.ActionEnum.Add.ToString(), "添加管理员:" + model.user_name); //记录日志
                return(true);
            }
            return(false);
        }
 private void ShowInfo(int _id)
 {
     BLL.sys_manager   bll   = new BLL.sys_manager();
     Model.sys_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;
 }
 /// <summary>
 /// 更新一条数据
 /// </summary>
 public bool Update(Model.sys_manager model)
 {
     return(dal.Update(model));
 }
 /// <summary>
 /// 增加一条数据
 /// </summary>
 public int Add(Model.sys_manager model)
 {
     return(dal.Add(model));
 }
Пример #8
0
        protected void btnSubmit_Click(object sender, EventArgs e)
        {
            string userName = txtUserName.Text.Trim();
            string userPwd  = txtPassword.Text.Trim();

            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.sys_manager   bll   = new BLL.sys_manager();
            Model.sys_manager model = bll.GetModel(userName, userPwd, true);
            if (model == null)
            {
                msgtip.InnerHtml = "用户名或密码有误,请重试!";
                return;
            }

            //写入登录日志
            Model.siteconfig siteConfig = new BLL.siteconfig().loadConfig();
            if (siteConfig.logstatus > 0)
            {
                new BLL.manager_log().Add(model.id, model.user_name, EnumCollection.ActionEnum.Login.ToString(), "用户登录");
            }

            //写入Cookies
            Utils.WriteCookie("DTRememberName", model.user_name, 14400);
            Session[AppoaKeys.SESSION_ADMIN_INFO] = model;
            Session.Timeout = 45;

            Utils.WriteCookie("AdminName", "DTcms", model.user_name);
            Utils.WriteCookie("AdminPwd", "DTcms", model.password);
            Response.Redirect("index.aspx");
            return;

            //if (model.role_type == 1)
            //{
            //    Session[AppoaKeys.SESSION_ADMIN_INFO] = model;
            //    Session.Timeout = 45;

            //    Utils.WriteCookie("AdminName", "DTcms", model.user_name);
            //    Utils.WriteCookie("AdminPwd", "DTcms", model.password);
            //    Response.Redirect("index.aspx");
            //    return;
            //}
            //if (model.role_type == 2)
            //{
            //    Session[AppoaKeys.SESSION_USER_INFO] = model;
            //    Session.Timeout = 45;

            //    Utils.WriteCookie("UserName", "DTcms", model.user_name);
            //    Utils.WriteCookie("UserPwd", "DTcms", model.password);
            //    Response.Redirect("index_user.aspx");
            //    return;
            //}
        }