예제 #1
0
        /// <summary>
        /// Метод срабатывает при клике на автомобиль из списка.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void listBox1Automobile_SelectedIndexChanged(object sender, EventArgs e)
        {
            // проверка на пустой индекс
            if (listBox1Automobile.SelectedItem == null)
            {
                return;
            }

            AutomobileClass CheckedCar = new AutomobileClass();

            CheckedCar                   = (AutomobileClass)listBox1Automobile.SelectedItem;
            textBox1ModelCar.Text        = CheckedCar.ModelCar.ToString();
            textBox4PriceForHourCar.Text = CheckedCar.PriceHourCar.ToString();
            comboBox2CarType.Text        = CheckedCar.TypeCar;
            textBox9CapacityCar.Text     = CheckedCar.CapacityCar.ToString();
            textBox7YearIssueCar.Text    = CheckedCar.YearIssueCar.ToString();
            AutoGosNumberTextBox.Text    = CheckedCar.GosNumberCar.ToString();
            textBox14CarryingCar.Text    = CheckedCar.CarryingCar.ToString();

            if (CheckedCar.PhotoCar == "")
            {
                // pictureBox1.Image = null;
                //   pictureBox1.BackColor = Color.Gray;
                pictureBox1.Image = CarDefaultPhoto;
            }
            else
            {
                pictureBox1.Load(CheckedCar.PhotoCar);
            }

            /// Выбираем автомрбиль для оформления заказа
            listBox1CarForOrder.Items.Clear();
            listBox1CarForOrder.Items.Add(CheckedCar);
        }
예제 #2
0
        /// <summary>
        /// Добавление автомобиля. Не протестировано
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void button1AddAuto_Click(object sender, EventArgs e)
        {
            AutomobileClass AddCar = new AutomobileClass();

            AddCar.PhotoCar      = destFile;
            AddCar.ModelCar      = textBox1ModelCar.Text;
            AddCar.PriceHourCar  = textBox4PriceForHourCar.Text;
            AddCar.CarCategoryID = comboBox2CarType.SelectedIndex + 1;
            AddCar.CapacityCar   = textBox9CapacityCar.Text;
            AddCar.YearIssueCar  = textBox7YearIssueCar.Text;
            AddCar.GosNumberCar  = AutoGosNumberTextBox.Text;
            AddCar.CarryingCar   = textBox14CarryingCar.Text;

            if (FlagCopy)
            {
                File.Copy(sourcePath, destFile, true);
                destFile = "";
            }
            AddCar.InsertCar();

            UpdateCarsListbox();
            FlagCopy = false;

            ClearCarPanel();
        }
예제 #3
0
        /// <summary>
        /// Сохранение автомобиля (редактирование).
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void button3RedactionAuto_Click(object sender, EventArgs e)
        {
            AutomobileClass RedactionCar = new AutomobileClass();

            RedactionCar               = (AutomobileClass)listBox1Automobile.SelectedItem;
            RedactionCar.ModelCar      = textBox1ModelCar.Text;
            RedactionCar.PriceHourCar  = textBox4PriceForHourCar.Text;
            RedactionCar.CarCategoryID = comboBox2CarType.SelectedIndex + 1;
            RedactionCar.CapacityCar   = textBox9CapacityCar.Text;
            RedactionCar.YearIssueCar  = textBox7YearIssueCar.Text;
            RedactionCar.GosNumberCar  = AutoGosNumberTextBox.Text;
            RedactionCar.CarryingCar   = textBox14CarryingCar.Text;

            if (destFile != "")
            {
                ListDeletePhoto.Add(RedactionCar.PhotoCar);
                RedactionCar.PhotoCar = destFile;
            }

            if (FlagCopy)
            {
                File.Copy(sourcePath, destFile, true);
                destFile = "";
            }
            RedactionCar.EditCar();

            UpdateCarsListbox();
            UpdateOrdersListbox();
            FlagCopy = false;
            ClearCarPanel();
        }
예제 #4
0
        //////////////////////////////////////// Автомобили
        /// <summary>
        /// Обновляет содержимое лист-бокса для списка автомобилей. Не протестировано
        /// </summary>
        private void UpdateCarsListbox()
        {
            listBox1Automobile.Items.Clear();

            List <AutomobileClass> AllCars = new List <AutomobileClass>();

            AllCars = AutomobileClass.ReadAllCars();
            AllCars.ForEach(delegate(AutomobileClass Car)
            {
                listBox1Automobile.Items.Add(Car);
            });
        }
예제 #5
0
        /// <summary>
        /// Удаляем автомобиль.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void button1DeleteCar_Click(object sender, EventArgs e)
        {
            AutomobileClass CarToDelete = new AutomobileClass();

            CarToDelete = (AutomobileClass)listBox1Automobile.SelectedItem;
            CarToDelete.DeleteCar();
            ListDeletePhoto.Add(CarToDelete.PhotoCar);

            ClearCarPanel();
            UpdateCarsListbox();

            listBox1CarForOrder.Items.Clear();
        }