Пример #1
0
    protected void Page_Load(object sender, EventArgs e)
    {
        try
        {
            if (!Page.IsPostBack)
            {
                // 判断是否验证用户
                if (Context.User.Identity.IsAuthenticated)
                {
                    panlAdmin.Visible = false;
                    userName          = Context.User.Identity.Name.ToString(); // 获取票证
                    //lblUserName.Text = userName;

                    Users UserModel = bllUsers.GetModelByUserName(Context.User.Identity.Name);
                    if (UserModel != null)
                    {
                        lblUserName.Text = UserModel.userName;
                        //if (UserModel.roleid == 1)
                        //{
                        //    panlAdmin.Visible = true;
                        //}
                    }
                }
                else
                {
                    FormsAuthentication.RedirectToLoginPage();  //将浏览器重定向到登陆页面
                }
            }
        }
        catch (Exception ex)
        {
            log.Error(ex.Message);
        }
    }
Пример #2
0
 protected void Page_Load(object sender, EventArgs e)
 {
     try
     {
         if (!IsPostBack)
         {
             Users UserModel = bllUser.GetModelByUserName(Context.User.Identity.Name);
             if (UserModel != null)
             {
                 //if (UserModel.roleid == 1)
                 //{
                 InitTree();
                 //}
             }
         }
     }
     catch (Exception ex)
     {
         log.Error(ex.Message);
     }
     if (Request.QueryString["id"] != null)
     {
         try
         {
             int id = int.Parse(Request.QueryString["id"] + "");
         }
         catch { }
     }
 }
Пример #3
0
    protected void btnSubmit_ServerClick(object sender, EventArgs e)
    {
        try
        {
            string username  = this.txtUserName.Value.Trim().ToString();
            string password  = this.txtPassword.Value.Trim().ToString();
            string checkCode = this.txtCheckCode.Value.Trim().ToString();
            string code      = Request.Cookies["CheckCode"].Value.ToString(); //取随机码

            if (username.Equals(""))
            {
                Msg.Show("用户名不能为空!");
                return;
            }
            if (password.Equals(""))
            {
                Msg.Show("密码不能为空!");
                return;
            }
            if (checkCode.Trim().ToLower().Equals(code))
            {
                bool flg = bll.Exists(username, password);
                if (flg)
                {
                    Users model = bll.GetModelByUserName(username);
                    // 检查审核状态
                    if (model.state == 1)
                    {
                        FormsAuthentication.RedirectFromLoginPage(username, false); //经过验证后设置cookie,重定向最初请求的页面或者默认页面
                    }
                    else
                    {
                        Msg.Show("等待管理员审核中...!");
                        this.txtCheckCode.Value = "";
                    }
                }
                else
                {
                    Msg.Show("用户名或者密码错误!");
                    this.txtCheckCode.Value = "";
                }
            }
            else
            {
                Msg.Show("验证码错误!");
                this.txtCheckCode.Value = "";
            }
        }
        catch (Exception ex)
        {
            log.Error(ex.Message);
            Msg.Show("网络链接错误!" + ex.Message);
        }
    }
Пример #4
0
    protected void ibtnAdd_Click(object sender, EventArgs e)
    {
        //验证代码
        try
        {
            TFXK.Model.Articles model = new TFXK.Model.Articles();
            try
            {
                model.id = int.Parse(Request.QueryString["id"].ToString());
            }
            catch { model.id = 0; }
            model.title     = txtTitle.Text;
            model.source    = this.txtSource.Text;
            model.orderId   = int.Parse(this.txtOrderby.Text.Equals("") ? "0" : this.txtOrderby.Text);
            model.parentId  = int.Parse(this.ddlType.SelectedValue + "");
            model.isSlideOn = 0;

            model.createTime  = this.txtDate.Date;
            model.clicks      = int.Parse(this.txtClick.Text.Equals("") ? "0" : this.txtClick.Text);
            model.description = this.txtContent.Value;
            try
            {
                model.publisher = bllUser.GetModelByUserName(Context.User.Identity.Name).trueName;
            }
            catch { }
            model.isOutlLink  = ddlOutLink.SelectedIndex;
            model.outLinkPath = txtOutLink.Text;
            model.state       = int.Parse(this.ddlState.SelectedValue);
            if (hdfImgPath.Value.Length > 10)
            {
                model.imgPath = hdfImgPath.Value;
            }

            string type = this.hdfAction.Value.Trim();
            // 判断动作
            switch (type)
            {
            case "add":
                Add(model);
                break;

            case "modify":
                Modify(model);
                break;
            }
        }
        catch (Exception ex)
        {
            log.Error(ex.Message);
            Msg.Show("网络错误!原因:" + ex.Message);
        }
    }
Пример #5
0
    public void CheckUserRole()
    {
        string userName = string.Empty;

        // 判断是否验证用户
        if (Context.User.Identity.IsAuthenticated)
        {
            userName = Context.User.Identity.Name.ToString(); // 获取票证
            Users Model = bll.GetModelByUserName(userName);
            if (Model != null)
            {
                //  Response.Redirect("Default.aspx", false);
            }
            else
            {
                FormsAuthentication.RedirectToLoginPage();  //将浏览器重定向到登陆页面
            }
        }
        else
        {
            FormsAuthentication.RedirectToLoginPage();  //将浏览器重定向到登陆页面
        }
    }