Пример #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!";
            }
        }
Пример #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 == 1)
                {
                    playerlist = FileIO.ReadFile(Server.MapPath("~/App_Data/playerlistfile.ser"));
                    Application.Set("playerlist", playerlist);
                    fp = (Footballplayer)Session["player"];

                    if (fp != null)
                    {
                        LabelMessage.Text = "Welcome Back " + fp.Name;
                        if (TextBoxName.Text == "")
                        {
                            TextBoxName.Text = fp.Name;
                            TextBoxAddress.Text = fp.Address;
                            TextBoxTelephone.Text = "" + fp.Telephone;
                            TextBoxPlayer_number.Text = "" + fp.Player_number;
                            TextBoxHeight.Text = "" + fp.Height;
                            TextBoxWeight.Text = "" + fp.Weight;
                            TextBoxAge.Text = "" + fp.Age;
                        }
                    }
                }
                else
                {
                    Response.Redirect("403.aspx");
                }
            }
        }