Exemplo n.º 1
0
        protected void loginButton_Click(object sender, EventArgs e)
        {
            /* Check if user passed correct username and password if so redirect to user panel */
            Child         child         = childDAO.getChild(usernameTxt.Text, passwordTxt.Text);
            Parent        parent        = parentDAO.getParent(usernameTxt.Text, passwordTxt.Text);
            Administrator administrator = administratorDAO.getAdministrator(usernameTxt.Text, passwordTxt.Text);

            if (child != null)
            {
                incorrectCredentialsLabel.Text = ""; //Clear the label if was incorrect previously
                Session["Child"] = child;
                Response.Redirect("~/Quizzes.aspx");
            }
            if (parent != null)                      //Successfully logged in
            {
                incorrectCredentialsLabel.Text = ""; //Clear the label if was incorrect previously
                Session["Parent"] = parent;
                Response.Redirect("~/ParentPanel.aspx");
            }
            if (administrator != null)
            {
                incorrectCredentialsLabel.Text = ""; //Clear the label if was incorrect previously
                Session["Administrator"]       = administrator;
                Response.Redirect("~/AdministratorPanel.aspx");
            }

            incorrectCredentialsLabel.Text = "Incorrect Username or Password.";
        }
Exemplo n.º 2
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                Title = "Register children";
                if (Session["SuccessRegister"] == null && Session["SuccessRegisterChild"] == null)
                {
                    Response.Redirect("~/Default.aspx");
                }
            }

            if (Session["Administrator"] != null || Session["Child"] != null || Session["Parent"] == null) //Check if user is logged in
            {
                Response.Redirect("~/Default.aspx");
            }

            if (Session["Parent"] != null)
            {
                parent = (Parent)Session["Parent"];
            }

            registerChildStatus.Visible = false;
            if (Session["SuccessRegister"] == null)
            {
                if (Session["SuccessRegisterChild"] != null)
                {
                    registerChildStatus.Visible = true;
                    if ((bool)Session["SuccessRegisterChild"])
                    {
                        registerChildStatus.Text     = "Successfully registered.";
                        registerChildStatus.CssClass = "alert alert-success";
                        Session["Parent"]            = parentDAO.getParent(parent.Username, parent.Password);
                    }
                    else
                    {
                        registerChildStatus.Text     = "There was an error while registering. Please try again later.";
                        registerChildStatus.CssClass = "alert alert-danger";
                    }
                    Session["SuccessRegisterChild"] = null; //Reset the message
                }
            }
            else
            {
                Session["SuccessRegister"] = null;
            }
        }
Exemplo n.º 3
0
        protected void registerBtn_Click(object sender, EventArgs e)
        {
            if (Page.IsValid)
            {
                try
                {
                    Parent parent = new Parent(usernameTxt.Text, passwordTxt.Text, firstNameTxt.Text,
                                               surnameTxt.Text, postcodeTxt.Text, telephoneTxt.Text, emailTxt.Text, "", new List <Child>());
                    parentDAO.addParent(parent);

                    Session["SuccessRegister"] = true;
                    Session["Parent"]          = parentDAO.getParent(parent.Username, parent.Password); //Pass newly created parent
                }
                catch (Exception ex)
                {
                    Session["SuccessRegister"] = false;
                    Response.Redirect("~/Register.aspx", true);
                }
                Response.Redirect("~/RegisterChildren.aspx");
            }
        }