Пример #1
0
        protected void btnLogin_Click(object sender, EventArgs e)
        {
            if (Page.IsValid)
            {
                if (tbEmail.Text == "*****@*****.**")
                {
                    Session["admin"] = true;
                    Response.Redirect("IndexAdmin.aspx");
                    return;
                }

                try
                {
                    TourGuide user = TourGuideDAO.SelectTourGuideByEmail(tbEmail.Text);
                    Session["tourguide_id"] = user.TourGuideId.ToString();
                }
                catch (Exception)
                {
                    Tourist user = TouristDAO.SelectTouristByEmail(tbEmail.Text);
                    Session["tourist_id"] = user.TouristId.ToString();
                }
                finally
                {
                    if (Session["tourguide_id"] != null)
                    {
                        Response.Redirect("TourGuideRequestsPage.aspx");
                    }
                    else if (Session["tourist_id"] != null)
                    {
                        Response.Redirect("Index.aspx");
                    }
                }
            }
        }
        protected void btnSignupTourist_Click(object sender, EventArgs e)
        {
            if (Page.IsValid)
            {
                string name   = tbNameTourist.Text;
                string email  = tbEmailTourist.Text.ToLower();
                string pass1  = tbPasswordTourist.Text;
                string pass2  = tbRepeatPassTourist.Text;
                string nation = ddlNation.SelectedValue;
                if (pass1 == pass2 && name != "" && email != "" && pass1 != "" && nation != "-- Select --")
                {
                    string  hash = SHA256Hash.GenerateSHA256(pass1);
                    Tourist obj  = new Tourist(name, email, hash, nation);
                    TouristDAO.InsertTourist(obj);



                    //Michaels Reward insert table stuff (dont touch)
                    int id = Convert.ToInt32(TouristDAO.SelectTouristByEmail(email).UserId);

                    int      logincount      = 0;
                    int      loginstreak     = 0;
                    string   loyaltytier     = "none";
                    int      totaldiscount   = 0;
                    int      bonuscredits    = 10;
                    string   membershiptier  = "normal";
                    int      creditbalance   = 0;
                    int      remainbonusdays = 10;
                    bool     loggedInLog     = false;
                    DateTime loggedInDate    = DateTime.Now;
                    bool     newDateCheck    = true;

                    Reward insertReward = new Reward(id, logincount, loginstreak, loyaltytier, totaldiscount, bonuscredits, membershiptier, creditbalance, remainbonusdays, loggedInLog, loggedInDate, newDateCheck);

                    insertReward.insertNewReward();

                    Response.Redirect("Login.aspx");
                }
            }
        }