Exemplo n.º 1
0
        private void Spisok_LB_SelectedValueChanged(object sender, EventArgs e)
        {
            if (Spisok_LB.SelectedItem != null)
            {
                Runner runnerDB = Spisok_LB.SelectedItem as Runner;

                if (runnerDB != null)
                {
                    Height_TB.Text  = runnerDB.Height.ToString();
                    Weight_TB.Text  = runnerDB.Weight.ToString();
                    Age_TB.Text     = runnerDB.Age.ToString();
                    Name_TB.Text    = runnerDB.Name;
                    Surname_TB.Text = runnerDB.Surname;
                    Ranked_TB.Text  = runnerDB.Ranked.ToString();
                }

                StateButton(true);
            }
            else
            {
                Height_TB.Clear();
                Weight_TB.Clear();
                Age_TB.Clear();
                Name_TB.Clear();
                Surname_TB.Clear();
                Ranked_TB.Clear();

                StateButton(false);
            }
        }
        private void Modification_F_FormClosing(object sender, FormClosingEventArgs e)
        {
            if (DialogResult == DialogResult.OK)
            {
                try
                {
                    if (Height_TB.Text.Trim() == "")
                    {
                        Height_TB.Focus();
                        throw new Exception("Вы не ввели рост бегуна");
                    }

                    if (Weight_TB.Text.Trim() == "")
                    {
                        Weight_TB.Focus();
                        throw new Exception("Вы не ввели вес бегуна");
                    }

                    if (Age_TB.Text.Trim() == "")
                    {
                        Age_TB.Focus();
                        throw new Exception("Вы не ввели возраст бегуна");
                    }

                    if (Name_TB.Text.Trim() == "")
                    {
                        Name_TB.Focus();
                        throw new Exception("Вы не ввели имя бегуна");
                    }

                    if (Surname_TB.Text.Trim() == "")
                    {
                        Surname_TB.Focus();
                        throw new Exception("Вы не ввели фамилию бегуна");
                    }

                    if (Ranked_TB.Text.Trim() == "")
                    {
                        Ranked_TB.Focus();
                        throw new Exception("Вы не ввели место, которое бегун занял на олимпиаде");
                    }

                    int R = Convert.ToInt32(Ranked_TB.Text);

                    if (R < 1 || R > 3)
                    {
                        Ranked_TB.Focus();
                        throw new Exception("Занятое место на олимпиаде должно находиться в диапазоне 1...3");
                    }
                }
                catch (FormatException Fx)
                {
                    e.Cancel = true;
                    MessageBox.Show(Fx.Message, "Внимание", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                }
                catch (Exception Ex)
                {
                    e.Cancel = true;
                    MessageBox.Show(Ex.Message, "Внимание", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                }
            }
        }