protected void Page_Load(object sender, EventArgs e)
    {
        admın gelenAdmin = (admın)Session["Admin"];

        lblMessage.Visible = true;
        lblMessage.Text    = "Merhaba " + gelenAdmin.Name + " " + gelenAdmin.Surname;
    }
示例#2
0
    protected void btnLogin_Click(object sender, EventArgs e)
    {
        if (cbRememberMe.Checked)
        {
            Response.Cookies["Email"].Value   = txtUsername.Text;
            Response.Cookies["Email"].Expires = DateTime.Now.AddDays(30);

            Response.Cookies["Password"].Value   = txtPassword.Text;
            Response.Cookies["Password"].Expires = DateTime.Now.AddDays(30);
        }

        if (string.IsNullOrEmpty(txtUsername.Text) || string.IsNullOrEmpty(txtPassword.Text))
        {
            lblMessage.Visible = true;
            lblMessage.Text    = "Please fill all necessary fields!";
        }
        else
        {
            string email    = txtUsername.Text;
            string password = txtPassword.Text;

            semantıcEntities db = new semantıcEntities();

            USER u = (from x in db.USER
                      where x.Email == email && x.Password == password && x.IsActive == true
                      select x).SingleOrDefault();

            admın a = (from x in db.admın
                       where x.Email == email && x.Password == password && x.IsActive == true
                       select x).SingleOrDefault();

            if (u == null && a == null)
            {
                lblMessage.Visible = true;
                lblMessage.Text    = "Please check your information!";
            }

            if (u != null)
            {
                Session["User"] = u;
                Response.Redirect("UserHomepage.aspx");
            }
            else
            {
                lblMessage.Visible = true;
                lblMessage.Text    = "Please check your information!";
            }
            if (a != null)
            {
                Session["Admin"] = a;
                Response.Redirect("AdminHomepage.aspx");
            }
            else
            {
                lblMessage.Visible = true;
                lblMessage.Text    = "Please check your information!";
            }
        }
    }