public IHttpActionResult PutLocacion(int id, Locacion locacion)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != locacion.Id)
            {
                return(BadRequest());
            }

            db.Entry(locacion).State = EntityState.Modified;

            try
            {
                db.SaveChanges();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!LocacionExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(StatusCode(HttpStatusCode.NoContent));
        }
        // GET: Locacion
        public ActionResult Index()
        {
            AccesoDatos     datos = new AccesoDatos();
            Locacion        aux;
            List <Locacion> locaciones = new List <Locacion>();

            try
            {
                datos.setearQuery("Select * from Locacion as l " +
                                  "inner join TiposActividad as ta on ta.id = l.id_actividad_tipo");
                datos.ejecutarLector();
                while (datos.lector.Read())
                {
                    aux                  = new Locacion();
                    aux.tipo             = new ActividadTipo();
                    aux.id               = datos.lector.GetInt32(0);
                    aux.descripcion      = datos.lector.GetString(2);
                    aux.tipo.id          = datos.lector.GetInt32(3);
                    aux.tipo.descripcion = datos.lector.GetString(4);
                    locaciones.Add(aux);
                }
                datos.cerrarConexion();
            }
            catch (Exception ex)
            {
                datos.cerrarConexion();
                throw;
            }
            return(View(locaciones));
        }
        public ActionResult Create(FormCollection collection)
        {
            Locacion    loc   = new Locacion();
            AccesoDatos datos = new AccesoDatos();



            try
            {
                loc.descripcion = Convert.ToString(collection["descripcion"]);
                loc.tipo        = new ActividadTipo();
                loc.tipo.id     = Convert.ToInt32(collection["Id"]);

                datos.setearQuery("insert into locacion(ID_Actividad_Tipo,descripcion) values(@idTipoActividad,@descripcion)");
                datos.agregarParametro("@descripcion", loc.descripcion);
                datos.agregarParametro("@idTipoActividad", loc.tipo.id);
                datos.ejecutarAccion();
                datos.cerrarConexion();
                // TODO: Add insert logic here

                return(RedirectToAction("Index"));
            }
            catch
            {
                datos.cerrarConexion();
                return(View());
            }
        }
Exemple #4
0
        public List <Locacion> listaLocacion(int id)
        {
            List <Locacion> locaciones = new List <Locacion>();
            AccesoDatos     datos      = new AccesoDatos();
            Locacion        aux;


            try
            {
                datos.setearQuery("select * from Locacion as p" +
                                  " inner join tiposActividad as tp on p.ID_Actividad_Tipo = tp.id where p.ID_Actividad_Tipo = @id");
                datos.agregarParametro("@id", id);
                datos.ejecutarLector();
                while (datos.lector.Read())
                {
                    aux                  = new Locacion();
                    aux.tipo             = new ActividadTipo();
                    aux.id               = datos.lector.GetInt32(0);
                    aux.descripcion      = datos.lector.GetString(2);
                    aux.tipo.id          = datos.lector.GetInt32(3);
                    aux.tipo.descripcion = datos.lector.GetString(4);

                    locaciones.Add(aux);
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }


            return(locaciones);
        }
        public ActionResult DeleteConfirmed(int id)
        {
            Locacion locacion = db.Locacion.Find(id);

            db.Locacion.Remove(locacion);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
Exemple #6
0
        public async Task <ActionResult> DeleteConfirmed(int id)
        {
            Locacion locacion = await db.Locacions.FindAsync(id);

            db.Locacions.Remove(locacion);
            await db.SaveChangesAsync();

            return(RedirectToAction("Index"));
        }
 public ActionResult Edit([Bind(Include = "Id,NombreCorto,Nombre,Activo")] Locacion locacion)
 {
     if (ModelState.IsValid)
     {
         db.Entry(locacion).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(locacion));
 }
Exemple #8
0
        public async Task <ActionResult> Edit([Bind(Include = "LocacionID,Nombre,Descripcion,Direccion,Latitud,Longitud,HorarioServicio,Geolocalizacion")] Locacion locacion)
        {
            if (ModelState.IsValid)
            {
                db.Entry(locacion).State = EntityState.Modified;
                await db.SaveChangesAsync();

                return(RedirectToAction("Index"));
            }
            return(View(locacion));
        }
        public ActionResult Create([Bind(Include = "Id,NombreCorto,Nombre,Activo")] Locacion locacion)
        {
            if (ModelState.IsValid)
            {
                db.Locacion.Add(locacion);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(locacion));
        }
        public IHttpActionResult GetLocacion(int id)
        {
            Locacion locacion = db.Locacion.Find(id);

            if (locacion == null)
            {
                return(NotFound());
            }

            return(Ok(locacion));
        }
        public IHttpActionResult PostLocacion(Locacion locacion)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            db.Locacion.Add(locacion);
            db.SaveChanges();

            return(CreatedAtRoute("DefaultApi", new { id = locacion.Id }, locacion));
        }
Exemple #12
0
        // POST: odata/Locaciones
        public async Task <IHttpActionResult> Post(Locacion locacion)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            db.Locacion.Add(locacion);
            await db.SaveChangesAsync();

            return(Created(locacion));
        }
Exemple #13
0
 public static void ActualizarLocacion(Locacion locacion, string idLocacion, string idEstante)
 {
     SQL = "update locacion set codigo='" + locacion.Codigo + "',idEstante='" + ValidarEstante(idEstante) + "' " +
           "Where idLocacion ='" + ValidarLocacion(idLocacion) + "'";
     if (Conexion.Execute(SQL))
     {
         MessageBox.Show("Registro Actualizado");
     }
     else
     {
         MessageBox.Show("Error al Actualizar");
     }
 }
Exemple #14
0
        private void btnActualizar_Click(object sender, EventArgs e)
        {
            string codigo = txtCodigo.Text;

            locacion = LocacionController.BuscarLocacion(codigo);
            if (locacion != null)
            {
                string codigoEstante = txtCodigoEstante.Text;
                LocacionController.ActualizarLocacion(locacion, codigo, codigoEstante);
                CargarDatos();
                Nuevo();
            }
        }
Exemple #15
0
        public static void InsertarLocacion(Locacion locacion, string id)
        {
            SQL = "insert into locacion(codigo,idEstante) Values ('" + locacion.Codigo + "','" + ValidarEstante(id) + "')";

            if (Conexion.Execute(SQL))
            {
                MessageBox.Show("Registro Guardado");
            }
            else
            {
                MessageBox.Show("Error al Guardar");
            }
        }
Exemple #16
0
        public static Locacion BuscarLocacion(string codigo)
        {
            SQL = "Select codigo from locacion where codigo ='" + codigo + "'";
            MySqlDataReader req = Conexion.Query(SQL);
            Locacion        ob  = null;

            if (req.Read())
            {
                ob        = new Locacion();
                ob.Codigo = req["codigo"].ToString();
            }
            req.Close();
            return(ob);
        }
        // GET: Warehouse/Locacion/Delete/5
        public ActionResult Delete(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            Locacion locacion = db.Locacion.Find(id);

            if (locacion == null)
            {
                return(HttpNotFound());
            }
            return(View(locacion));
        }
Exemple #18
0
        // GET: Locacions/Delete/5
        public async Task <ActionResult> Delete(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            Locacion locacion = await db.Locacions.FindAsync(id);

            if (locacion == null)
            {
                return(HttpNotFound());
            }
            return(View(locacion));
        }
Exemple #19
0
        private void btnInsertar_Click(object sender, EventArgs e)
        {
            string codigo = txtCodigo.Text;

            locacion = LocacionController.BuscarLocacion(codigo);
            if (locacion == null)
            {
                Guardar();
            }
            else
            {
                MessageBox.Show("Locacion ya existe en el estante ingresado");
            }
        }
        public IHttpActionResult DeleteLocacion(int id)
        {
            Locacion locacion = db.Locacion.Find(id);

            if (locacion == null)
            {
                return(NotFound());
            }

            db.Locacion.Remove(locacion);
            db.SaveChanges();

            return(Ok(locacion));
        }
Exemple #21
0
        // DELETE: odata/Locaciones(5)
        public async Task <IHttpActionResult> Delete([FromODataUri] long key)
        {
            Locacion locacion = await db.Locacion.FindAsync(key);

            if (locacion == null)
            {
                return(NotFound());
            }

            db.Locacion.Remove(locacion);
            await db.SaveChangesAsync();

            return(StatusCode(HttpStatusCode.NoContent));
        }
Exemple #22
0
        public static List <Locacion> ListarLocaciones()
        {
            List <Locacion> locacion = new List <Locacion>();

            SQL = "Select l.idLocacion, l.codigo, l.idEstante, e.codigo as codigoEstante from estante e inner join locacion l " +
                  "on e.idEstante=l.idEstante order by l.codigo ASC";
            MySqlDataReader req = Conexion.Query(SQL);

            while (req.Read())
            {
                Locacion ob = new Locacion();
                ob.IdLocacion    = req.GetInt32("idLocacion");
                ob.Codigo        = req["codigo"].ToString();
                ob.IdEstante     = req.GetInt32("idEstante");
                ob.NombreEstante = req["codigoEstante"].ToString();
                locacion.Add(ob);
            }
            req.Close();
            return(locacion);
        }
Exemple #23
0
 public void Buscar()
 {
     if (txtCodigo.Text == "")
     {
         MessageBox.Show("Ingresar codigo para cargar datos");
     }
     else
     {
         string codigo = txtCodigo.Text;
         locacion = LocacionController.BuscarLocacion(codigo);
         if (locacion != null)
         {
             txtCodigo.Text        = locacion.Codigo;
             txtCodigoEstante.Text = locacion.NombreEstante;
         }
         else
         {
             MessageBox.Show("Locacion no encontrada");
         }
     }
 }
Exemple #24
0
        // PUT: odata/Locaciones(5)
        public async Task <IHttpActionResult> Put([FromODataUri] long key, Delta <Locacion> patch)
        {
            Validate(patch.GetEntity());

            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            Locacion locacion = await db.Locacion.FindAsync(key);

            if (locacion == null)
            {
                return(NotFound());
            }

            patch.Put(locacion);

            try
            {
                await db.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!LocacionExists(key))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(Updated(locacion));
        }
Exemple #25
0
 public void Captura()
 {
     locacion               = new Locacion();
     locacion.Codigo        = txtCodigo.Text;
     locacion.NombreEstante = txtCodigoEstante.Text;
 }