Ejemplo n.º 1
0
        protected void ButtonCreate_Click(object sender, EventArgs e)
        {
            try
            {
                if (RadioButtonPlayer.Checked)
                {
                    fp = new Footballplayer(TextBoxName.Text, TextBoxAddress.Text, Convert.ToInt32(TextBoxTelephone.Text), TextBoxPassword.Text, userlevel, Convert.ToInt32(TextBoxPlayer_number.Text), Convert.ToInt32(TextBoxHeight.Text), Convert.ToInt32(TextBoxWeight.Text), Convert.ToInt32(TextBoxAge.Text));
                    playerlist.Add(fp);

                    Application.Set("myplayerlist", playerlist);

                    ListBoxCreate.Items.Clear();
                    for (int i = 0; i < playerlist.Count; i++)
                    {
                        ListBoxCreate.Items.Add(((Footballplayer)playerlist[i]).ToString());
                    }

                    TextBoxName.Text = "";
                    TextBoxAddress.Text = "";
                    TextBoxTelephone.Text = "";
                    TextBoxPassword.Text = "";
                    TextBoxPlayer_number.Text = "";
                    TextBoxHeight.Text = "";
                    TextBoxWeight.Text = "";
                    TextBoxAge.Text = "";

                    LabelMessage.Text = "New Football player created";
                }
                else
                {
                    sm = new Staffmember(TextBoxName.Text, TextBoxAddress.Text, Convert.ToInt32(TextBoxTelephone.Text), TextBoxPassword.Text, userlevel, TextBoxPosition.Text);
                    stafflist.Add(sm);

                    Application.Set("mystafflist", stafflist);

                    ListBoxCreate.Items.Clear();
                    for (int i = 0; i < stafflist.Count; i++)
                    {
                        ListBoxCreate.Items.Add(((Staffmember)stafflist[i]).ToString());
                    }

                    TextBoxName.Text = "";
                    TextBoxAddress.Text = "";
                    TextBoxTelephone.Text = "";
                    TextBoxPassword.Text = "";
                    TextBoxPosition.Text = "";

                    LabelMessage.Text = "New Staff member created";
                }
            }
            catch
            {
                LabelMessage.Text = "New person NOT created!";
            }
        }
Ejemplo n.º 2
0
        protected void Page_Load(object sender, EventArgs e)
        {
            Response.Cache.SetCacheability(HttpCacheability.NoCache);
            try
            {
                userlevel = (int)Session["mylevel"];
            }
            catch
            {
                userlevel = 0;
                Session["mylevel"] = userlevel;
            }
            finally
            {
                if (userlevel == 2 || userlevel == 3)
                {
                    if (userlevel == 3)
                    {
                        ButtonGoToWebmaster.Visible = true;
                    }
                    else
                    {
                        ButtonGoToWebmaster.Visible = false;
                    }

                    stafflist = FileIO.ReadFile(Server.MapPath("~/App_Data/stafflistfile.ser"));
                    Application.Set("stafflist", stafflist);
                    sm = (Staffmember)Session["staff"];

                    if (sm != null)
                    {
                        LabelMessage.Text = "Welcome Back " + sm.Name;
                        if (TextBoxName.Text == "")
                        {
                            TextBoxName.Text = sm.Name;
                            TextBoxAddress.Text = sm.Address;
                            TextBoxTelephone.Text = "" + sm.Telephone;
                            TextBoxPosition.Text = sm.Position;
                        }
                    }
                    playerlist = FileIO.ReadFile(Server.MapPath("~/App_Data/playerlistfile.ser"));
                    ListBoxReadPlayer.Items.Clear();
                    for (int i = 0; i < playerlist.Count; i++)
                    {
                        ListBoxReadPlayer.Items.Add(((Footballplayer)playerlist[i]).ToString());
                    }
                    ListBoxReadStaff.Items.Clear();
                    for (int i = 0; i < stafflist.Count; i++)
                    {
                        ListBoxReadStaff.Items.Add(((Staffmember)stafflist[i]).ToString());
                    }
                }
                else
                {
                    Response.Redirect("403.aspx");
                }
            }
        }