Esempio n. 1
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (Session["LoggedIn"] == null)
            {
                Response.Redirect("Default.aspx");
            }

            Person p = (Person)Session["LoggedIn"];

            TheName.Text = p.Name;

            if (Session["LoggedIn"].GetType().ToString() == "MagicalShow_3rd_HandIn.Staff")
            {
                Staff s = (Staff)Session["LoggedIn"];
                LabelSpecific.Text = "Monthly salary:";
                ListBoxSpecific.Items.Add(s.Salary + " DKK/month");
            }
            else if (Session["LoggedIn"].GetType().ToString() == "MagicalShow_3rd_HandIn.Magician")
            {
                Magician m = (Magician)Session["LoggedIn"];
                LabelSpecific.Text = "Favorite Tricks:";
                for (int i = 0; i < m.FavoriteTricks.Count; i++)
                {
                    ListBoxSpecific.Items.Add((string)m.FavoriteTricks[i]);
                }
            }
        }
Esempio n. 2
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!Page.IsPostBack)
            {
                if (Session["LoggedIn"] == null)
                {
                    Response.Redirect("Default.aspx");
                }

                p = (Person)Session["LoggedIn"];
                TextBoxName.Text = p.Name;

                if (Session["LoggedIn"].GetType().ToString() == "MagicalShow_3rd_HandIn.Staff")
                {
                    s = (Staff)Session["LoggedIn"];
                    LabelSpecific.Text   = "Monthly salary:";
                    TextBoxSpecific.Text = s.Salary.ToString();
                }
                else if (Session["LoggedIn"].GetType().ToString() == "MagicalShow_3rd_HandIn.Magician")
                {
                    m = (Magician)Session["LoggedIn"];
                    LabelSpecific.Text = "Favorite Tricks:";
                    string tricks = "";
                    for (int i = 0; i < m.FavoriteTricks.Count; i++)
                    {
                        tricks += m.FavoriteTricks[i] + ",";
                    }
                    TextBoxSpecific.Text = tricks;
                }
            }
        }
        protected void ButtonAdd_Click(object sender, EventArgs e)
        {
            Magician magic = new Magician(TextBoxMagic.Text, TextBoxName.Text, TextBoxPassword.Text);

            localMagicList = (ArrayList)Application["MagicCollection"];
            localMagicList.Add(magic);
            Response.Redirect("Default.aspx");
        }
Esempio n. 4
0
        public void buttonLoginClicked(object sender, EventArgs args)
        {
            Boolean loggedIn      = false;
            string  NameInput     = TextBoxName.Text;
            string  PasswordInput = TextBoxPassword.Text;

            LoginMsg.Text = "";

            for (int i = 0; i < staffList.Count; i++)
            {
                Staff s = (Staff)staffList[i];
                if (s.TryLogin(NameInput, PasswordInput))
                {
                    loggedIn               = true;
                    Session["LoggedIn"]    = s;
                    Session["LoggedIndex"] = i;
                }
            }
            if (!loggedIn)
            {
                for (int i = 0; i < magicList.Count; i++)
                {
                    Magician m = (Magician)magicList[i];
                    if (m.TryLogin(NameInput, PasswordInput))
                    {
                        loggedIn               = true;
                        Session["LoggedIn"]    = m;
                        Session["LoggedIndex"] = i;
                    }
                }
            }

            if (loggedIn)
            {
                Response.Redirect("Overview.aspx");
            }
            else
            {
                LoginMsg.Text = "Login failed wrong credentials!";
            }
        }
Esempio n. 5
0
        public void editProfile(object sender, EventArgs args)
        {
            p = (Person)Session["LoggedIn"];
            if (TextBoxName.Text != "")
            {
                p.Name = TextBoxName.Text;
            }
            if (TextBoxPassword.Text != "")
            {
                p.Password = TextBoxPassword.Text;
            }

            if (Session["LoggedIn"].GetType().ToString() == "MagicalShow_3rd_HandIn.Staff")
            {
                s = (Staff)p;
                if (TextBoxSpecific.Text != "")
                {
                    s.Salary = Int32.Parse(TextBoxSpecific.Text);
                }

                localList = (ArrayList)Application["StaffCollection"];
                p         = s;
            }
            else if (Session["LoggedIn"].GetType().ToString() == "MagicalShow_3rd_HandIn.Magician")
            {
                m = (Magician)p;
                if (TextBoxSpecific.Text != "")
                {
                    m.SetFavoriteTricks(TextBoxSpecific.Text);
                }

                localList = (ArrayList)Application["MagicCollection"];
                p         = m;
            }

            int localListIndex = (int)Session["LoggedIndex"];

            localList[localListIndex] = p;
            Session["LoggedIn"]       = p;
            Response.Redirect("Profile.aspx");
        }