private void buttonApply_Click(object sender, EventArgs e) { try { if (textBoxServicePrice.Text.Length < 1) { MessageBox.Show("Необходимо ввести стоимость услуги", "Ошибка", MessageBoxButtons.OK); return; } if (edit) { String name = textBoxServiceName.Text; int price = Convert.ToInt32(textBoxServicePrice.Text); //int duration = Convert.ToInt32(textBoxServiceDuration.Text); int duration = trackBarDuration.Value; mainController.changeService(name, price, duration, inputService); this.Close(); } else { String name = textBoxServiceName.Text; int price = Convert.ToInt32(textBoxServicePrice.Text); int duration = trackBarDuration.Value; mainController.registerService(name, price, duration); this.Close(); } } catch (OverflowException ex) { Console.WriteLine("Faild to convert string to Int32: " + ex.Message); textBoxServicePrice.Text = ""; MessageBox.Show("Введено слишком большое число в поле Стоимость.", "Ошибка", MessageBoxButtons.OK); } }