コード例 #1
0
ファイル: Login.aspx.cs プロジェクト: timothyjxhn/TouristHelp
        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");
                    }
                }
            }
        }
コード例 #2
0
        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");
                }
            }
        }
コード例 #3
0
ファイル: Index.aspx.cs プロジェクト: timothyjxhn/TouristHelp
 protected void Page_Load(object sender, EventArgs e)
 {
     if (Session["tourguide_id"] != null || Session["tourist_id"] != null)
     {
         string name = "";
         try
         {
             name = TouristDAO.SelectTouristById(int.Parse(Session["tourist_id"].ToString())).Name;
         }
         catch
         {
             name = TourGuideDAO.SelectTourGuideById(int.Parse(Session["tourguide_id"].ToString())).Name;
         }
         finally
         {
             LblName.Text = name;
         }
     }
     else
     {
         Response.Redirect("Login.aspx");
     }
 }