Exemplo n.º 1
0
        protected override void Load()
        {
            Kunden.Clear();
            foreach (KundeDto kunde in Service.GetKunden())
            {
                Kunden.Add(kunde);
            }

            Autos.Clear();
            foreach (AutoDto auto in Service.GetAutos())
            {
                Autos.Add(auto);
            }

            Reservationen.Clear();
            reservationenOriginal.Clear();
            foreach (ReservationDto res in Service.GetReservationen())
            {
                Reservationen.Add(res);
                reservationenOriginal.Add((ReservationDto)res.Clone());
            }
            selectedReservation = Reservationen.FirstOrDefault();

            reservationen.ToList().ForEach(r =>
            {
                r.Auto =
                    Autos.ToList().Find(a => a.Id == r.Auto.Id);
                r.Kunde = Kunden.ToList().Find(k => k.Id == r.Kunde.Id);
            });
        }
Exemplo n.º 2
0
        private int AsignarNumeroVehiculo()
        {
            int numero = 0;

            while (true)
            {
                numero++;

                if (cbxTipoVehiculo.SelectedIndex == 0)
                {
                    if (!Aviones.Exists(x => x.Numero == numero))
                    {
                        break;
                    }
                }

                if (cbxTipoVehiculo.SelectedIndex == 1)
                {
                    if (!Autos.Exists(x => x.Numero == numero))
                    {
                        break;
                    }
                }

                if (cbxTipoVehiculo.SelectedIndex == 2)
                {
                    if (!Colectivos.Exists(x => x.Numero == numero))
                    {
                        break;
                    }
                }
            }

            return(numero);
        }
Exemplo n.º 3
0
        public int actualizarAutos(Autos objAuto)
        {
            int cantidadRegistros = -1;

            //La estructura using es para crear recursos que solo van a existir en memoria dentro de su bloque de programación
            using (SqlConnection sqlCon = new SqlConnection(cadenaConexion))
            {
                //Todos los recursos que se crean dentro de este bloque, serán automaticamente destruidos cuando se termine el bloque de programacion
                SqlCommand cmd = new SqlCommand();
                cmd.Connection  = sqlCon;
                cmd.CommandType = CommandType.Text;
                cmd.CommandText = "Update Autos " +
                                  "set MARCA = @MARCA, " +
                                  "    MODELO  = @MODELO, " +
                                  "    PAIS = @PAIS, " +
                                  "    COSTO = @COSTO " +
                                  "Where IDCARRO = @IDCARRO ";
                cmd.Parameters.Add(new SqlParameter("@MARCA", objAuto.MARCA));
                cmd.Parameters.Add(new SqlParameter("@MODELO", objAuto.MODELO));
                cmd.Parameters.Add(new SqlParameter("@PAIS", objAuto.PAIS));
                cmd.Parameters.Add(new SqlParameter("@COSTO", objAuto.COSTO));
                cmd.Parameters.Add(new SqlParameter("@IDCARRO", objAuto.IDCARRO));
                sqlCon.Open();
                cantidadRegistros = cmd.ExecuteNonQuery(); //Aqui estamos realizando el Insert en base de datos.
                sqlCon.Close();
            }

            return(cantidadRegistros);
        }
Exemplo n.º 4
0
        public ActionResult Create([Bind(Include = "ID,MakeID,ModeLID,ColorID,RegistryNum")] Autos autos)
        {
            //ViewData["usID"] = ID;
            autos.UserID = Convert.ToInt32(Session["id"]);
            if (ModelState.IsValid)
            {
                db.Autos.Add(autos);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            ViewBag.ColorID = new SelectList(db.Colors, "ID", "Color", autos.ColorID);
            ViewBag.MakeID  = new SelectList(db.Makes, "ID", "Make", autos.MakeID);
            ViewBag.ModeLID = new SelectList(db.CarModels, "ID", "CarModel", autos.ModeLID);
            ViewBag.UserID  = new SelectList(db.Users, "ID", "Email", autos.UserID);

            if (Session["role"].ToString() == "admin")
            {
                return(View(autos));
            }
            else
            {
                return(View("UserCreate", autos));
            }
        }
Exemplo n.º 5
0
        private void bmnNuevoVehiculo_Click(object sender, EventArgs e)
        {
            frmNuevoVehiculo form = new frmNuevoVehiculo();

            form.Owner      = this;
            form.Aviones    = Aviones;
            form.Autos      = Autos;
            form.Colectivos = Colectivos;
            form.ShowDialog();

            if (form.estado)
            {
                if (form.tipo == 0)
                {
                    Aviones.Add(form.Avion);
                    srcAviones.ResetBindings(true);
                    dgvAviones.Refresh();
                }
                else if (form.tipo == 1)
                {
                    Autos.Add(form.Auto);
                    srcAutos.ResetBindings(true);
                    dgvAutos.Refresh();
                }
                else
                {
                    Colectivos.Add(form.Colectivo);
                    srcColectivos.ResetBindings(true);
                    dgvColectivos.Refresh();
                }
            }
        }
Exemplo n.º 6
0
        protected void ExtraModelToEntity(Autos entity, AutosModel model, ActionTypes actionType)
        {
            if (actionType == ActionTypes.Add)
            {
                entity.AutoMaterialRsps = new List<AutoMaterialRsp>();
                var materialManager = GlobalConfiguration.Configuration.DependencyResolver.GetService<IMaterialsManager>();

                foreach (var material in materialManager.GetEntities().Where(o => !o.DeleteDate.HasValue && o.IsForAuto).ToList())
                {
                    entity.AutoMaterialRsps.Add(new AutoMaterialRsp()
                    {
                        Amount = 0,
                        Autos = entity,
                        MaterialId = material.Id
                    });
                }

                entity.AutoInstrumentRsps = new List<AutoInstrumentRsp>();
                var instrumentManager = GlobalConfiguration.Configuration.DependencyResolver.GetService<IInstrumentsManager>();

                foreach (var instrument in instrumentManager.GetEntities().Where(o => !o.DeleteDate.HasValue && o.IsForAuto).ToList())
                {
                    entity.AutoInstrumentRsps.Add(new AutoInstrumentRsp()
                    {
                        Amount = 0,
                        Autos = entity,
                        InstrumentId = instrument.Id
                    });
                }
            }
        }
Exemplo n.º 7
0
        protected void ExtraModelToEntity(Autos entity, AutosModel model, ActionTypes actionType)
        {
            if (actionType == ActionTypes.Add)
            {
                entity.AutoMaterialRsps = new List <AutoMaterialRsp>();
                var materialManager = GlobalConfiguration.Configuration.DependencyResolver.GetService <IMaterialsManager>();

                foreach (var material in materialManager.GetEntities().Where(o => !o.DeleteDate.HasValue && o.IsForAuto).ToList())
                {
                    entity.AutoMaterialRsps.Add(new AutoMaterialRsp()
                    {
                        Amount     = 0,
                        Autos      = entity,
                        MaterialId = material.Id
                    });
                }

                entity.AutoInstrumentRsps = new List <AutoInstrumentRsp>();
                var instrumentManager = GlobalConfiguration.Configuration.DependencyResolver.GetService <IInstrumentsManager>();

                foreach (var instrument in instrumentManager.GetEntities().Where(o => !o.DeleteDate.HasValue && o.IsForAuto).ToList())
                {
                    entity.AutoInstrumentRsps.Add(new AutoInstrumentRsp()
                    {
                        Amount       = 0,
                        Autos        = entity,
                        InstrumentId = instrument.Id
                    });
                }
            }
        }
Exemplo n.º 8
0
        protected void LoadActive()
        {
            Reservationen.Clear();
            Kunden.Clear();
            Autos.Clear();


            foreach (KundeDto kunde in Service.Kunde)
            {
                Kunden.Add(kunde);
            }
            foreach (AutoDto auto in Service.Autos)
            {
                Autos.Add(auto);
            }

            foreach (ReservationDto reservation in Service.Reservation)
            {
                if (DateTime.Now > reservation.Bis)
                {
                }
                else
                {
                    Reservationen.Add(reservation);
                }
            }
            SelectedReservation = Reservationen.FirstOrDefault();
        }
Exemplo n.º 9
0
        protected void GridAutos_RowUpdating(object sender, GridViewUpdateEventArgs e)
        {
            objGestion = new GestionBD();
            Autos objAutos = new Autos();

            objAutos.MARCA   = (GridAutos.Rows[e.RowIndex].FindControl("txtMARCA") as TextBox).Text.Trim();
            objAutos.MODELO  = (GridAutos.Rows[e.RowIndex].FindControl("txtMODELO") as TextBox).Text.Trim();
            objAutos.PAIS    = (GridAutos.Rows[e.RowIndex].FindControl("txtPAIS") as TextBox).Text.Trim();
            objAutos.COSTO   = Convert.ToDouble((GridAutos.Rows[e.RowIndex].FindControl("txtCOSTO") as TextBox).Text.Trim());
            objAutos.IDCARRO = Convert.ToInt32(GridAutos.DataKeys[e.RowIndex].Value.ToString());
            int resultado = objGestion.actualizarAutos(objAutos);

            GridAutos.EditIndex = -1;


            if (resultado == 1)
            {
                cargaAuto();
                mostrarMensaje("Actualización con exito", true);
            }
            else
            {
                mostrarMensaje("Existe un error en el registro de la persona", false);
            }
        }
Exemplo n.º 10
0
        protected override void Load()
        {
            Reservationen.Clear();
            reservationenOriginal.Clear();

            Kunden.Clear();
            Autos.Clear();
            if (Service.Kunden() != null)
            {
                foreach (KundeDto kunde in Service.Kunden())
                {
                    Kunden.Add(kunde);
                }
            }
            if (Service.Autos() != null)
            {
                foreach (AutoDto auto in Service.Autos())
                {
                    Autos.Add(auto);
                }
            }
            if (Service.Reservationen() != null)
            {
                foreach (ReservationDto reservation in Service.Reservationen())
                {
                    Reservationen.Add(reservation);
                    reservationenOriginal.Add((ReservationDto)reservation.Clone());
                }
            }
            SelectedReservation = Reservationen.FirstOrDefault();
        }
Exemplo n.º 11
0
Arquivo: DAO.cs Projeto: SaviN13/Gibdd
 public void AddAuto(Autos newAuto)
 {
     using (DBContext db = new DBContext())
     {
         db.Autos.Add(newAuto);
         db.SaveChanges();
     }
 }
Exemplo n.º 12
0
Arquivo: DAO.cs Projeto: SaviN13/Gibdd
 public void DeleteAuto(int id)
 {
     using (DBContext db = new DBContext())
     {
         Autos autos = db.Autos.Where(o => o.AutoID == id).FirstOrDefault();
         db.Autos.Remove(autos);
     }
 }
Exemplo n.º 13
0
 //Hier wird ein auto zum Kill freigegeben. Tatsächlicher kill wird aber erst in dem Script gemacht welche dem Auto Als Komponente beigefügt wird
 public static void KillCar()
 {
     car =manageDatabase.getrandomparkingcar ();
     Car= GameObject.Find (car.getKennzeichen());
     Car.transform.position = new Vector3(-6.35434f,0.5f,-10.67066f);
     Car.transform.rotation = new Quaternion (0f, 180f, 0f, 1);
     manageDatabase.setcartoleave (car.getKennzeichen ());
 }
Exemplo n.º 14
0
        public ActionResult GetAuto(Autos auto)
        {
            Customers customers = (Customers)Session["Customers"];

            customers.Autos      = auto;
            Session["Customers"] = customers;
            return(RedirectToAction("Contact"));
        }
Exemplo n.º 15
0
        public ActionResult DeleteConfirmed(int id)
        {
            Autos autos = db.Autos.Find(id);

            db.Autos.Remove(autos);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
 protected override void Load()
 {
     Autos.Clear();
     foreach (var auto in Service.GetAutos())
     {
         Autos.Add(auto);
     }
     SelectedAuto = Autos.FirstOrDefault();
 }
        public async Task <Autos> Actualizar(Autos auto, string token)
        {
            HttpClient client   = GetClient(token);
            var        response = await client.PutAsync(URL,
                                                        new StringContent(JsonConvert.SerializeObject(auto), Encoding.UTF8,
                                                                          "application/json"));

            return(JsonConvert.DeserializeObject <Autos>(await response.Content.ReadAsStringAsync()));
        }
 public ActionResult Edit([Bind(Include = "ID,Nombre,Numero_Unidad,Tipo")] Autos autos)
 {
     if (ModelState.IsValid)
     {
         db.Entry(autos).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(autos));
 }
Exemplo n.º 19
0
        //
        // GET: /Autos/Delete/5

        public ActionResult Delete(int id = 0)
        {
            Autos autos = db.Autos.Find(id);

            if (autos == null)
            {
                return(HttpNotFound());
            }
            return(View(autos));
        }
Exemplo n.º 20
0
 public ActionResult Edit(Autos autos)
 {
     if (ModelState.IsValid)
     {
         db.Entry(autos).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(autos));
 }
Exemplo n.º 21
0
        private void SaveAuto(Auto auto)
        {
            AutoAddWindow autoAddWindow = new AutoAddWindow();

            if (autoAddWindow.ShowDialog() ?? false)
            {
                Autos.Add(autoAddWindow.Advm.Auto);
                Empty = Autos.Count == 0;
            }
        }
Exemplo n.º 22
0
 protected override void Load()
 {
     Autos.Clear();
     autosOriginal.Clear();
     foreach (var auto in Service.Autos)
     {
         Autos.Add(auto);
         autosOriginal.Add(auto.Clone());
     }
     SelectedAuto = Autos.FirstOrDefault();
 }
Exemplo n.º 23
0
        public ActionResult Create(Autos autos)
        {
            if (ModelState.IsValid)
            {
                db.Autos.Add(autos);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(autos));
        }
Exemplo n.º 24
0
        private void GetFullInfoAuto(int id)
        {
            Autos auto = new Autos();

            auto = new DAO().GetFullInfoAboutAuto(id);
            numberTextBox.Text       = auto.Number;
            brandTextBox.Text        = auto.Brand;
            modelTextBox.Text        = auto.Model;
            volumeEngineTextBox.Text = auto.Volume.ToString();
            powerTextBox.Text        = auto.Power.ToString();
            typeBodyTextBox.Text     = auto.TypeBody;
            engineIdTexBox.Text      = auto.EngineID;
            bodyIdTextBox.Text       = auto.BodyID;
            Data.IdAuto = auto.AutoID;
            if (auto.Helm == true)
            {
                leftCheckBox.IsChecked  = true;
                rightCheckBox.IsEnabled = false;
            }
            else
            {
                leftCheckBox.IsChecked  = false;
                rightCheckBox.IsEnabled = true;
            }

            yearTaxTextBox.Text = auto.YearTax.ToString();
            yearLabel.Text      = auto.Year.ToString();
            commentTextBox.Text = auto.Comment;

            if (auto.Stealings.Count() >= 0)
            {
                stealingsDataGrid.ItemsSource           = auto.Stealings;
                stealingsDataGrid.Columns[0].Visibility = Visibility.Collapsed;
                stealingsDataGrid.Columns[1].Header     = "Дата угона";
                stealingsDataGrid.Columns[2].Header     = "Дата возврата";
                stealingsDataGrid.Columns[3].Visibility = Visibility.Collapsed;
                stealingsDataGrid.Columns[4].Visibility = Visibility.Collapsed;
            }

            if (auto.TechnicalInspections.Count >= 0)
            {
                techViewAutoDataGrid.ItemsSource           = auto.TechnicalInspections;
                techViewAutoDataGrid.Columns[0].Visibility = Visibility.Collapsed;
                techViewAutoDataGrid.Columns[1].Header     = "Дата";
                techViewAutoDataGrid.Columns[2].Header     = "ФИО инспектора";
                techViewAutoDataGrid.Columns[3].Header     = "Оплата за знак ТО";
                techViewAutoDataGrid.Columns[4].Header     = "Оплата за ТО";
                techViewAutoDataGrid.Columns[5].Header     = "Пробег";
                techViewAutoDataGrid.Columns[6].Header     = "ТО пройден";
                techViewAutoDataGrid.Columns[7].Header     = "Заметки";
                techViewAutoDataGrid.Columns[8].Visibility = Visibility.Collapsed;
                techViewAutoDataGrid.Columns[9].Visibility = Visibility.Collapsed;
            }
        }
        public ActionResult Create([Bind(Include = "ID,Nombre,Numero_Unidad,Tipo")] Autos autos)
        {
            if (ModelState.IsValid)
            {
                db.Autos.Add(autos);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(autos));
        }
        public void Delete(Guid AutoID)
        {
            Autos dbEntry = context.Autos
                            .FirstOrDefault(p => p.Id == AutoID);

            if (dbEntry != null)
            {
                context.Autos.Remove(dbEntry);
                context.SaveChanges();
            }
        }
Exemplo n.º 27
0
        public void AutosPorEstado()
        {
            var mockDb = new Mock <ExamenContext>();

            mockDb.Setup(o => o.Autos).Returns(Autos.GetDbSet());

            var service = new AutoService(mockDb.Object);

            var result = service.getAuto(null, null, null, "nuevo", null, null);

            Assert.AreEqual(12, result.LongCount());
        }
Exemplo n.º 28
0
        public void AutosPorPrecioMaximo()
        {
            var mockDb = new Mock <ExamenContext>();

            mockDb.Setup(o => o.Autos).Returns(Autos.GetDbSet());

            var service = new AutoService(mockDb.Object);

            var result = service.getAuto(null, null, null, null, null, 50000);

            Assert.AreEqual(11, result.LongCount());
        }
Exemplo n.º 29
0
        public void TodoslosAutos()
        {
            var mockDb = new Mock <ExamenContext>();

            mockDb.Setup(o => o.Autos).Returns(Autos.GetDbSet());

            var service = new AutoService(mockDb.Object);

            var result = service.getAuto();

            Assert.AreEqual(18, result.LongCount());
        }
Exemplo n.º 30
0
        public void AutosMarcaAudi()
        {
            var mockDb = new Mock <ExamenContext>();

            mockDb.Setup(o => o.Autos).Returns(Autos.GetDbSet());

            var service = new AutoService(mockDb.Object);

            var result = service.getAuto("Audi", null, null, null, null, null);

            Assert.AreEqual(4, result.LongCount());
        }
Exemplo n.º 31
0
        protected void GridAutos_RowDeleting(object sender, GridViewDeleteEventArgs e)
        {
            objGestion = new GestionBD();
            Autos objAutos = new Autos();

            objAutos.IDCARRO = Convert.ToInt32(GridAutos.DataKeys[e.RowIndex].Value.ToString());
            objGestion.eliminarAutos(objAutos);
            GridAutos.EditIndex = -1;
            cargaAuto();

            mostrarMensaje("Elimino con exito", true);
        }
Exemplo n.º 32
0
        public IActionResult Agregar([FromBody] Autos _autos)
        {
            var result = _service.agregarAutos(_autos);

            if (result)
            {
                return(Ok());
            }
            else
            {
                return(BadRequest());
            }
        }
Exemplo n.º 33
0
    //Diese Methode Schreibt ein Gegebenes Auto in die Datenbank.
    // Das Auto wird als Parameter gegeben
    public void addauto(Autos autodaten)
    {
        IDbConnection _connection = new SqliteConnection(_strDBName);
        IDbCommand _command = _connection .CreateCommand();
        string sql;

        _connection .Open();

        sql = "INSERT INTO AUTOS (KENNZEICHEN, STATUS) Values ('"+ autodaten.getKennzeichen ()+"','"+autodaten.getStatus ()+"')";
        _command.CommandText = sql;
        _command.ExecuteNonQuery();

        _command.Dispose();
        _command = null;
        _connection .Close();
        _connection.Dispose ();
        _connection = null;
        //Debug.Log (autodaten.getKennzeichen ());
    }
Exemplo n.º 34
0
    public static void UmstellenderWayPoints()
    {
        auto = ManageDatabase.getActiveAuto ();
        //Debug.Log (" WaypointControl Kennzeichen " + auto.getKennzeichen ());

        ManageDatabase.getParkplatzViaKennzeichencount (auto.getKennzeichen());
        parki = ManageDatabase.getParkplatzViaKennzeichen (auto.getKennzeichen ());
        routepoints = ManageDatabase.getRouteViaROUTEID (System.Convert.ToString(parki.getROUTENID ()));
        //Debug.Log (routepoints.getSize ());

        //Anweisungen bei 3 Routenpunkten // Im else-Teil werden die ANweisungen für 4 Routenpunkt ausgegeben
        //Knoten werden von 0 bis 3 vergeben
        if (routepoints.getSize() == 3) {
            punkt=ManageDatabase.getRoutePointViaID(System.Convert.ToString(routepoints.getRoutespecPoint(0).getKnotenID()));
            WayPointPack11.transform.position=new Vector3(punkt.getX(),0.8211908f,punkt.getZ());
            punkt=ManageDatabase.getRoutePointViaID(System.Convert.ToString(routepoints.getRoutespecPoint(1).getKnotenID()));
            WayPointPack12.transform.position=new Vector3(punkt.getX(),0.8211908f,punkt.getZ());
            punkt=ManageDatabase.getRoutePointViaID(System.Convert.ToString(routepoints.getRoutespecPoint(2).getKnotenID()));
            WayPointPack13.transform.position=new Vector3(punkt.getX(),0.8211908f,punkt.getZ());
            WayPointPack14.transform.position=new Vector3(punkt.getX(),0.8211908f,punkt.getZ());
            WayPointPack31.transform.position=new Vector3(punkt.getX(),0.8211908f,punkt.getZ());
            WayPointPack32.transform.position=new Vector3(punkt.getX(),3.339992f,punkt.getZ());

                }
        else if(routepoints.getSize()==4){
            punkt=ManageDatabase.getRoutePointViaID(System.Convert.ToString(routepoints.getRoutespecPoint(0).getKnotenID()));
            WayPointPack11.transform.position=new Vector3(punkt.getX(),0.8211908f,punkt.getZ());
            punkt=ManageDatabase.getRoutePointViaID(System.Convert.ToString(routepoints.getRoutespecPoint(1).getKnotenID()));
            WayPointPack12.transform.position=new Vector3(punkt.getX(),0.8211908f,punkt.getZ());
            punkt=ManageDatabase.getRoutePointViaID(System.Convert.ToString(routepoints.getRoutespecPoint(2).getKnotenID()));
            WayPointPack13.transform.position=new Vector3(punkt.getX(),0.8211908f,punkt.getZ());
            punkt=ManageDatabase.getRoutePointViaID(System.Convert.ToString(routepoints.getRoutespecPoint(3).getKnotenID()));
            WayPointPack14.transform.position=new Vector3(punkt.getX(),0.8211908f,punkt.getZ());
            WayPointPack31.transform.position=new Vector3(punkt.getX(),0.8211908f,punkt.getZ());
            WayPointPack32.transform.position=new Vector3(punkt.getX(),3.339992f,punkt.getZ());
        }
    }
Exemplo n.º 35
0
 // Hier wird das Auto Geparkt also sein Status auf PArken gestellt und der QuadCopter im Status auf den Rückweg gestellt
 public static void ParkAuto()
 {
     car = manageDatabase.getActiveAuto ();
     manageDatabase.deactivateauto (car);
     manageDatabase.UpdateStatusDrone ("QuadCopter", "3");
     GameObject.Find ("Parkplatz_new").GetComponent<Waypoint> ().idleset ();
     GameObject.Find ("CarCam").camera.enabled = false;
     GameObject.Find ("Main Camera").camera.enabled = true;
     GameObject.Find ("CarCam").GetComponent<SmoothFollow>().target=Car.transform;
 }
Exemplo n.º 36
0
    // Hier wird ein zufälliges PArkendes Auto zurückgesendet
    public Autos getrandomparkingcar()
    {
        IDbConnection _connection = new SqliteConnection(_strDBName);
        IDbCommand _command = _connection .CreateCommand();
        string sql;
        IDataReader _reader;

        _connection .Open();
        sql = "SELECT Count(KENNZEICHEN) as COUNT FROM AUTOS WHERE STATUS='2' ";
        _command.CommandText = sql;
        _reader = _command.ExecuteReader();
        _reader.Read ();
        int zufall = UnityEngine.Random.Range (1, System.Convert.ToInt32(_reader ["COUNT"]));
        _reader.Close ();
        sql = "SELECT * FROM AUTOS WHERE STATUS = '2' LIMIT "+ zufall;
        _command.CommandText = sql;
        _reader = _command.ExecuteReader();

        // Hier wird ein zufälliges Auto gesucht
        for (int i=0; i<zufall; i++) {
            _reader.Read();
                }
        Autos car = new Autos ();
        //Debug.Log (_reader ["KENNZEICHEN"]);
        car.setKennzeichen (System.Convert.ToString (_reader ["KENNZEICHEN"]));
        car.setStatus("2");
        _command.Dispose();
        _command = null;
        _connection .Close();
        _connection.Dispose ();
        _connection = null;
        _reader.Close ();
        _reader.Dispose ();
        _reader = null;
        return car;
    }
Exemplo n.º 37
0
    // Hier wird ein gegebenes Auto auf Parking gesetzt
    public void deactivateauto(Autos autodaten)
    {
        IDbConnection _connection = new SqliteConnection(_strDBName);
        IDbCommand _command = _connection .CreateCommand();
        string sql;

        _connection .Open();

        sql = "UPDATE AUTOS SET STATUS = '2' WHERE KENNZEICHEN = '"+autodaten.getKennzeichen ()+"'";
        _command.CommandText = sql;
        _command.ExecuteNonQuery();

        _command.Dispose();
        _command = null;
        _connection .Close();
        _connection.Dispose ();
        _connection = null;
    }
Exemplo n.º 38
0
    // Diese Funktion übernimmt die Datenbankeinträge beim Einchecken gleichzeitig wird überprüft ob noch Parkplätze frei sind
    public bool einchecken(String CarKennzeichen)
    {
        int anzahlfreeparkplatz = this.getanzahlfreeparkplaetzelimit1 ();
        // Wenn kein Parkplatz frei ist wird kein auto erzeugt
        if (anzahlfreeparkplatz == 0) {
                return false;
                }
        else
            {
                Autos auto = new Autos ();
                auto.setKennzeichen (CarKennzeichen);
                auto.setStatus ("1");
                this.addauto (auto);
                Parkplatz park = this.getfreeParkplatzlimit1 ();

                this.setStatusbesetztParkplatz (CarKennzeichen,park);
                return true;
            }
    }
Exemplo n.º 39
0
    // Hier wird ein Random Parkplatz aus den Freien Parkplätzen gesucht
    // Der Gewählte Parkplatz wird mit dem als Parameter gegebenem Auto gefüllt
    // Und der gewählte Parkplatz wird zurückgesendet
    public Parkplatz getrandomfreeparkandfillwithcar(String Carname)
    {
        Autos auto = new Autos ();
        auto.setKennzeichen (Carname);
        auto.setStatus ("2");
        this.addauto (auto);
        System.Random Randomizer=new System.Random();
        List<Parkplatz> parkplaetze = this.getfreeParkplatz ();
        int anzahlfreierParkplaetze=parkplaetze.Count;
        Debug.Log ("ParkplätzeCount "+parkplaetze.Count);
        Parkplatz gewaehlt;

        int wohin = Randomizer.Next (0, anzahlfreierParkplaetze-1);
        Debug.Log ("Wohin "+wohin);
        gewaehlt = parkplaetze [wohin];
        this.setStatusbesetztParkplatz (Carname, gewaehlt);
        return  gewaehlt;
    }
Exemplo n.º 40
0
    // Hier wird Ein Auto aus der Datenbank genommen mit einem als Parameter gegebenem Kennzeichen
    // Die Rückgabe ist eine Object der Klasse Autos
    public Autos getAutoViaKennzeichen(String Kennzeichen)
    {
        IDbConnection _connection = new SqliteConnection(_strDBName);
        IDbCommand _command = _connection .CreateCommand();
        string sql;
        IDataReader _reader;
        _connection .Open();
        sql = "SELECT * FROM AUTOS WHERE KENNZEICHEN='"+Kennzeichen+"' ";
        _command.CommandText = sql;
        _reader = _command.ExecuteReader();

        Autos auto = new Autos ();
        _reader.Read ();

        auto.setKennzeichen (System.Convert.ToString(_reader ["KENNZEICHEN"]));
        auto.setStatus (System.Convert.ToString(_reader ["STATUS"]));
        _command.Dispose ();
        _command = null;
        _connection.Close ();
        _connection.Dispose ();
        _connection = null;
        _reader.Close ();
        _reader.Dispose ();
        _reader = null;
        return auto;
    }