Esempio n. 1
0
        //--------------------------------Edit/Delete Showing-----------------------------//

        //-------------------------------------Add Play-----------------------------------//
        private void CreatePlay_AddPlay_button_Click(object sender, RoutedEventArgs e)
        {
            string playName = this.PlayName_AddPlay_txt.Text;

            if (playName.Length == 0)
            {
                MessageBox.Show("Please enter a Play name");
            }
            else
            {
                if (PlaysClass.checkPlayExists(playName) == true)
                {
                    MessageBox.Show("This Play already exists");
                }
                else
                {
                    string playLengthToBeChecked = Length_AddPlay_txt.Text.ToString();
                    if (playLengthToBeChecked.Length == 0)
                    {
                        MessageBox.Show("Please enter a {Play length");
                    }
                    else
                    {
                        playLengthToBeChecked = ValidationClass.IntChecker(playLengthToBeChecked);
                        if (playLengthToBeChecked != null)
                        {
                            MessageBox.Show(playLengthToBeChecked);
                        }
                        else
                        {
                            try
                            {
                                int playLengthToBeCheckedInt = int.Parse(Length_AddPlay_txt.Text.ToString());
                                if (playLengthToBeCheckedInt > 400)
                                {
                                    MessageBox.Show("Play length too high - max length 400 minutes");
                                }
                                else
                                {
                                    int playLength = int.Parse(this.Length_AddPlay_txt.Text.ToString());
                                    PlaysClass.addPlay(playName, playLength);
                                    this.PlayName_AddPlay_txt.Text = "";
                                    this.Length_AddPlay_txt.Text   = "";
                                    MessageBox.Show("Play added");
                                }
                            }
                            catch (Exception)
                            {
                                MessageBox.Show("Play length too high - max length 400 minutes");
                            }
                        }
                    }
                }
            }
        }
Esempio n. 2
0
        private void EditPlay_button_Click(object sender, RoutedEventArgs e)
        {
            if (Play_EditDelPlay_combo.Items.Count == 0)
            {
                MessageBox.Show("Please enter a Play to search for");
            }
            else
            {
                KeyValuePair <int, string> test = (KeyValuePair <int, string>) this.Play_EditDelPlay_combo.SelectedValue;
                int    playId = int.Parse((test.Key).ToString());
                string playLengthToBeChecked = this.Length_EditDelPlay_txt.Text.ToString();
                if (playLengthToBeChecked.Length == 0)
                {
                    MessageBox.Show("Please enter a play length");
                }
                else
                {
                    playLengthToBeChecked = ValidationClass.IntChecker(playLengthToBeChecked);
                    if (playLengthToBeChecked != null)
                    {
                        MessageBox.Show(playLengthToBeChecked);
                    }
                    else
                    {
                        try
                        {
                            int playLengthToBeCheckedInt = int.Parse(Length_EditDelPlay_txt.Text.ToString());
                            if (playLengthToBeCheckedInt > 400)
                            {
                                MessageBox.Show("Play length too high - max length 400 minutes");
                            }
                            else
                            {
                                int newPlayLength = int.Parse(this.Length_EditDelPlay_txt.Text);
                                PlaysClass.editPlay(playId, this.PlayName_EditDelPlay_txt.Text, newPlayLength);

                                this.Length_EditDelPlay_txt.Text = "";
                                this.Play_EditDelPlay_combo.Items.Clear();
                                this.PlayName_EditDelPlay_txt.Text = "";
                                MessageBox.Show("Play edited");
                            }
                        }
                        catch (Exception)
                        {
                            MessageBox.Show("Play length too high - max legth 400 minutes");
                        }
                    }
                }
            }
        }