示例#1
0
 private void AutTrRadioButton_CheckedChanged(object sender, EventArgs e)
 {
     if (AutTrRadioButton.Checked)
     {
         TransmissionErrorProvider.Clear();
     }
 }
示例#2
0
 private void ReadyButton_Click(object sender, EventArgs e)
 {
     if (NameTextBox2.TextLength != 0 && NameTextBox1.Text.Length != 0 &&
         CountryComboBox.Text.Length != 0 && CategoryComboBox.Text.Length != 0 &&
         SumLeaseMaskedTextBox.MaskFull && PhotoPictureBox.Image != null && DescriptionTextBox.TextLength != 0)
     {
         MessageBox.Show("Регистрация новой модели автомобиля успешно завершена", "", MessageBoxButtons.OK, MessageBoxIcon.Information);
         this.Close();
     }
     else
     {
         if (NameTextBox2.TextLength == 0)
         {
             NameTextBox2.BackColor = Color.IndianRed;
         }
         if (NameTextBox1.TextLength == 0)
         {
             NameTextBox1.BackColor = Color.IndianRed;
         }
         if (FuelInHourTextBox.TextLength == 0)
         {
             FuelInHourTextBox.BackColor = Color.IndianRed;
         }
         if (FuelTextBox.TextLength == 0)
         {
             FuelTextBox.BackColor = Color.IndianRed;
         }
         if (!MechTrRadioButton.Checked && !AutTrRadioButton.Checked &&
             !VarTrRadioButton.Checked && !RobTrRadioButton.Checked)
         {
             TransmissionErrorProvider.SetError(TransmissiomLabel, "Выберите тип коробки передач");
         }
         if (CountryComboBox.Text.Length == 0)
         {
             CountryComboBox.BackColor = Color.IndianRed;
         }
         if (CategoryComboBox.Text.Length == 0)
         {
             CategoryComboBox.BackColor = Color.IndianRed;
         }
         if (!SumLeaseMaskedTextBox.MaskFull)
         {
             SumLeaseMaskedTextBox.BackColor = Color.IndianRed;
         }
         if (PhotoPictureBox.Image == null)
         {
             PhotoPictureBox.BackColor = Color.IndianRed;
         }
         if (DescriptionTextBox.TextLength == 0)
         {
             DescriptionTextBox.BackColor = Color.IndianRed;
         }
     }
 }
示例#3
0
        private void ReadyButton_Click(object sender, EventArgs e)
        {
            try
            {
                Model.ThisAutoModel.Mark.Equals("");
                if (ProductYearMaskedTextBox.MaskFull && ColorTextBox.TextLength != 0 &&
                    MileAgeTextBox.TextLength != 0 &&
                    Convert.ToInt32(ProductYearMaskedTextBox.Text.Remove(5, 2)) <= DateTime.Today.Date.Year &&
                    Convert.ToInt32(ProductYearMaskedTextBox.Text.Remove(5, 2)) >= 1700 && DescriptionTextBox.TextLength != 0)
                {
                    String transmission;
                    if (MechTrRadioButton.Checked)
                    {
                        transmission = "механическая";
                    }
                    else if (VarTrRadioButton.Checked)
                    {
                        transmission = "вариативная";
                    }
                    else if (AutTrRadioButton.Checked)
                    {
                        transmission = "автоматическая";
                    }
                    else
                    {
                        transmission = "роботизированная";
                    }
                    if (FlagFrom && Model.Automobiles.Count == Model.CarsAmount)
                    {
                        Model.CarsAmount++;
                    }

                    Auto autoautomobile = new Auto(Convert.ToInt32(ProductYearMaskedTextBox.Text.Remove(4, 3)), ColorTextBox.Text, MileAgeTextBox.Text,
                                                   Model.Automobiles.Count + 1, PhotoPictureBox.Image, transmission, DescriptionTextBox.Text, Model.ThisAutoModel);

                    AutoService service = new AutoService(Model);
                    autoautomobile.ID = service.generateID();

                    service.automobileRegistration(autoautomobile);
                    MessageBox.Show("Новый автомобиль успешно добавлен.", "", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    this.Close();
                }
                else
                {
                    if (Convert.ToInt32(ProductYearMaskedTextBox.Text.Remove(5, 2)) > DateTime.Today.Date.Year ||
                        Convert.ToInt32(ProductYearMaskedTextBox.Text.Remove(5, 2)) <= 1700)
                    {
                        ErrorProvider.SetError(ProductYearMaskedTextBox, "проверьте введенный год");
                    }

                    if (ColorTextBox.TextLength == 0)
                    {
                        ColorTextBox.BackColor = Color.IndianRed;
                    }
                    if (MileAgeTextBox.TextLength == 0)
                    {
                        MileAgeTextBox.BackColor = Color.IndianRed;
                    }
                    if (!ProductYearMaskedTextBox.MaskFull)
                    {
                        ProductYearMaskedTextBox.BackColor = Color.IndianRed;
                    }
                    if (PhotoPictureBox.Image == null)
                    {
                        PhotoPictureBox.BackColor = Color.IndianRed;
                    }
                    if (!MechTrRadioButton.Checked && !AutTrRadioButton.Checked &&
                        !VarTrRadioButton.Checked && !RobTrRadioButton.Checked)
                    {
                        TransmissionErrorProvider.SetError(TransmissiomLabel, "Выберите тип коробки передач");
                    }
                    if (DescriptionTextBox.TextLength == 0)
                    {
                        DescriptionTextBox.BackColor = Color.IndianRed;
                    }
                }
            }
            catch (NullReferenceException)
            {
                MessageBox.Show("Вы пытаетесь добавить автомобиль несуществующей модели", " ", MessageBoxButtons.OK, MessageBoxIcon.Error);
                this.Close();
            }
        }