Exemplo n.º 1
0
        private void btnAddCar_Click(object sender, EventArgs e)
        {
            Cars car = new Cars()
            {
                SasiNo    = txtSasiNo.Text,
                Km        = Convert.ToInt32(txtKm.Text),
                ModelYear = dateTimePicker.Value,
                ModelID   = ((int)cmbModels.SelectedValue),
                Price     = Convert.ToDecimal(txtPrice.Text)
            };
            CarsController carsController = new CarsController();
            bool           result         = carsController.AddCar(car);

            //dateTimePicker.Value = default;
            txtPrice.Text = string.Empty;
            if (result)
            {
                foreach (string item in ImagePathList)
                {
                    Images ımage = new Images()
                    {
                        ImageUrl = item,
                    };
                    ImagesController ımagesController = new ImagesController();
                    ımagesController.AddImage(ımage);
                }
            }
            MessageBox.Show("Araba eklenmiştir !");
            flowLayoutPanel1.Controls.Clear();
            cmbBrands.SelectedIndex = -1;
            cmbModels.SelectedIndex = -1;
            txtSasiNo.Text          = string.Empty;
            txtKm.Text           = string.Empty;
            dateTimePicker.Value = DateTime.Now;
        }