Пример #1
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (Request.Form["LoginID"] != null && Request.Form["Password"] != null)
            {
                string loginID = Request.Form["LoginID"]; //Textbox: LoginID
                string password = Request.Form["Password"]; //Textbox: Password

                PParent objParent = new PParent();
                objParent.PEmailAddr = loginID;
                objParent.PPassword = password;

                bool ParentAuthenticate = objParent.checkParentLogin();

                Tutor objTutor = new Tutor();
                objTutor.TEmailAddr = loginID;
                objTutor.TPassword = password;

                bool TutorAuthenticate = objTutor.checkTutorLogin();

                if (ParentAuthenticate == true)
                {
                    Session["LoginID"] = objParent.PName;
                    Session["LoginDateTime"] = DateTime.Now.ToString();
                    Session["UserType"] = "Parent";
                    Response.Redirect("Parent/ParentHomepage.aspx");
                }

                else if (TutorAuthenticate == true)
                {
                    Session["LoginID"] = objTutor.TName;
                    Session["LoginDateTime"] = DateTime.Now.ToString();
                    Session["UserType"] = "Tutor";
                    Response.Redirect("Tutor/TutorHomepage.aspx");
                }

                else if (loginID == "*****@*****.**" && password == "passAdmin")
                {
                    Session["LoginID"] = "Administrator";
                    Session["LoginDateTime"] = DateTime.Now.ToString();
                    Session["UserType"] = "Admin";
                    Response.Redirect("Admin/AdminHomepage.aspx");
                }

                else
                {
                    lblError.Text = "Invalid Login Credentials!";
                }
            }
        }
        protected void btnSubmit_Click(object sender, EventArgs e)
        {
            if (Page.IsValid)
            {
                PParent objParent = new PParent();

                objParent.PName = lblName.Text;
                objParent.PEmailAddr = lblEmailAddr.Text;
                objParent.PTelNo = lblPhoneNum.Text;
                objParent.PAddress = lblAddress.Text;

                int errorCode = objParent.add();
                if (errorCode == 0)
                {
                    lblMessage.Text = "Registered successfully";
                }
                else
                {
                    lblMessage.Text = "Unable to register.";
                }
            }
        }