Ejemplo n.º 1
0
        public TechnicalDetails(TechnicalDetails technicalDetails)
        {
            this.ID             = Guid.NewGuid();
            technicalDetails.ID = this.ID;
            ISqlComunicator sqlComunicator = new TechnicalDetailsDataAccess(technicalDetails);

            DataAcces.Instance.AddData(sqlComunicator);
        }
Ejemplo n.º 2
0
 public TechnicalDetailsDataAccess(TechnicalDetails technicalDetails)
 {
     this.TechnicalDetails = technicalDetails;
 }
Ejemplo n.º 3
0
        private void Button_Click(object sender, RoutedEventArgs e)
        {
            this.Car.ID = Guid.NewGuid();



            DateTime yearOfProd     = new DateTime();
            int      mileage        = 0;
            int      engineCapacity = 0;

            try
            {
                if (DateTime.TryParse("01.01." + Year.Text, out yearOfProd))
                {
                    if (int.TryParse(Mileage.Text, out mileage))
                    {
                        if (int.TryParse(EngCap.Text, out engineCapacity))
                        {
                            ;
                        }
                        else
                        {
                            MessageBox.Show("Value in Engice capacity field is incorect!");
                            throw new InvalidCastException();
                        }
                    }
                    else
                    {
                        MessageBox.Show("Value in Milage field is incorect!");
                        throw new InvalidCastException();
                    }
                }
                else
                {
                    MessageBox.Show("Value in year field is incorect!");
                    throw new InvalidCastException();
                }
                this.Equipments = new Equipments()
                {
                    ABS             = ABS.IsChecked,
                    ElectricWindows = ElWind.IsChecked,
                    Airbag          = Airbag.IsChecked,
                    Alu             = Alu.IsChecked,
                    AirConditioning = AirCond.IsChecked,
                    CD             = CD.IsChecked,
                    ElectricMirror = Mirrors.IsChecked,
                    FactoryAudio   = Audo.IsChecked,
                    ESP            = ESP.IsChecked,
                    Computer       = Computer.IsChecked,
                    CentralLock    = CentLock.IsChecked,
                    PowerSteering  = PowSter.IsChecked,
                    Isofix         = Isofix.IsChecked
                };

                Equipments equipments = new Equipments(this.Equipments);

                this.TechnicalDetails = new TechnicalDetails()
                {
                    YearOfProduction = yearOfProd,
                    Mileage          = Convert.ToInt32(Mileage.Text),
                    EngineCapacity   = Convert.ToInt32(EngCap.Text),
                    FuelType         = Fuel.Text,
                    Power            = Power.Text,
                    Transmission     = Transmission.Text,
                    Drive            = Drive.Text,
                    BodyType         = Body.Text,
                    Color            = Color.Text,
                    IsRegistered     = Registered.IsChecked,
                    NoAccident       = Accident.IsChecked,
                    Condition        = Condition.Text
                };

                TechnicalDetails technicalDetails = new TechnicalDetails(this.TechnicalDetails);

                this.Car = new Car()
                {
                    Model            = Model.Text,
                    Brand            = Brand.Text,
                    EquipmentID      = this.Equipments.ID,
                    TechnicalDetails = this.TechnicalDetails.ID,
                    ImagesID         = this.Images.ID,
                    Price            = Price.Text
                };

                ISqlComunicator sqlComunicator = new AddingCarDataAccess(this.Car);
                DataAcces.Instance.AddData(sqlComunicator);
                //this.Car.TechnicalDetails = null;
            }
            catch
            {
                this.Car = new Car()
                {
                    Model            = Model.Text,
                    Brand            = Brand.Text,
                    EquipmentID      = this.Equipments?.ID,
                    TechnicalDetails = this.TechnicalDetails?.ID,
                    ImagesID         = this.Images?.ID,
                    Price            = Price.Text
                };
                ISqlComunicator sqlComunicator = new AddingCarDataAccess(this.Car);
                DataAcces.Instance.ModifyData(sqlComunicator);
            }
        }