public async Task <IActionResult> Edit(int id, [Bind("IdBienes,IdPartidaGasto,CodigoBien,Descripcion,Observacion,IdUnidadMedida,IdUnidadMedidaEmpaque,IdModelo,IdPais,CodigoBienAnterior,DescripcionAnterior,IdRotacionBien,NombreArchivo,Foto,Kit,StockMinimo,StockInicial,StockIngreso,StockSalida,StockActual,PrecioReferenciaCompra,PrecioVentaBase,PrecioVentaFinal,TotalAcumuladoCompraBs,TotalAcumuladoVentaBs,TotalUtilidadBs,IdEstadoVigente,IdEstadoRegistro,IdUsuario,FechaRegistro")] Bienes bienes) { if (id != bienes.IdBienes) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(bienes); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!BienesExists(bienes.IdBienes)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } return(View(bienes)); }
public ActionResult DeleteConfirmed(int id) { Bienes articulos = db.Bienes.Find(id); db.Bienes.Remove(articulos); db.SaveChanges(); DisplaySuccessMessage("Has delete a Bienes record"); return(JsonRedirectToAction("Index")); }
public Bienes obtener(int?id) { //try //{ MySqlDataReader rd; Bienes bie = new Bienes(); using (con = Conexion.conectar()) { using (cmd = new MySqlCommand()) { cmd.CommandText = "SP_O_Tabla_Bienes"; //cmd.CommandText = string.Format("Select * from tbl_categoria where id_categoria='{0}'", id); cmd.CommandType = System.Data.CommandType.StoredProcedure; cmd.Connection = con; cmd.Parameters.AddWithValue("_id_bienes", id); rd = cmd.ExecuteReader(); while (rd.Read()) { bie.Id_bienes = rd.GetInt32("id_bienes"); bie.Id_categoria = rd.GetInt32("id_categoria"); bie.Categoria = rd.GetString("categoria"); bie.Nombre = rd.GetString("nombre"); bie.Serie = rd.GetString("serie"); bie.Descripcion = rd.GetString("descripcion"); bie.Codigo = rd.GetString("codigo"); bie.Precio = rd.GetDouble("precio"); bie.Estado = rd.GetString("estado"); bie.Fecha_ing = rd.GetDateTime("fecha_ing"); bie.Marca = rd.GetString("marca"); bie.Color = rd.GetString("color"); bie.Modelo = rd.GetString("modelo"); bie.Alto = rd.GetInt32("alto"); bie.Ancho = rd.GetInt32("ancho"); bie.Profundidad = rd.GetInt32("profundidad"); } rd.Close(); } } return(bie); //} //catch (Exception) //{ // return null; //} }
public async Task <IActionResult> Create([Bind("IdBienes,IdPartidaGasto,CodigoBien,Descripcion,Observacion,IdUnidadMedida,IdUnidadMedidaEmpaque,IdModelo,IdPais,CodigoBienAnterior,DescripcionAnterior,IdRotacionBien,NombreArchivo,Foto,Kit,StockMinimo,StockInicial,StockIngreso,StockSalida,StockActual,PrecioReferenciaCompra,PrecioVentaBase,PrecioVentaFinal,TotalAcumuladoCompraBs,TotalAcumuladoVentaBs,TotalUtilidadBs,IdEstadoVigente,IdEstadoRegistro,IdUsuario,FechaRegistro")] Bienes bienes) { if (ModelState.IsValid) { bienes.FechaRegistro = DateTime.Now; bienes.IdEstadoRegistro = '1'; _context.Add(bienes); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } return(View(bienes)); }
// GET: Bienes/Delete/5 public ActionResult Delete(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } Bienes articulos = db.Bienes.Find(id); if (articulos == null) { return(HttpNotFound()); } return(PartialView(articulos)); }
public ActionResult Edit([Bind(Include = "Id,CodBien,Bien,FamiliaId,IVAId,Precio,PrecioBase,Descuento,EstadoId,Estados,Familias,IVAs,BienesCompuestos,BienesCompuestos1,Inventario,PedidosProveedoresDetalle,PresupuestosClientesDetalle,Historicos")] Bienes articulos) { if (ModelState.IsValid) { db.Entry(articulos).State = EntityState.Modified; db.SaveChanges(); DisplaySuccessMessage("Has update a Bienes record"); return(JsonRedirectToAction("Index")); } ViewBag.EstadoId = new SelectList(db.Estados, "Id", "Nombre", articulos.EstadoId); ViewBag.FamiliaId = new SelectList(db.Familias, "Id", "CodFamilia", articulos.FamiliaId); ViewBag.IVAId = new SelectList(db.IVAs, "Id", "Descripcion", articulos.IVAId); DisplayErrorMessage(); return(PartialView(articulos)); }
public Boolean actualizar(Bienes bnn) { //try //{ using (con = Conexion.conectar()) { using (cmd = new MySqlCommand()) { cmd.CommandText = "SP_U_Tabla_Bienes"; cmd.CommandType = System.Data.CommandType.StoredProcedure; cmd.Connection = con; cmd.Parameters.AddWithValue("_id_categoria", bnn.Id_categoria); cmd.Parameters.AddWithValue("_nombre", bnn.Nombre); cmd.Parameters.AddWithValue("_serie", bnn.Serie); cmd.Parameters.AddWithValue("_descripcion", bnn.Descripcion); cmd.Parameters.AddWithValue("_codigo", bnn.Codigo); cmd.Parameters.AddWithValue("_precio", bnn.Precio); cmd.Parameters.AddWithValue("_imagen", bnn.Imagen); cmd.Parameters.AddWithValue("_estado", bnn.Estado); cmd.Parameters.AddWithValue("_fecha_ing", bnn.Fecha_ing); cmd.Parameters.AddWithValue("_marca", bnn.Marca); cmd.Parameters.AddWithValue("_color", bnn.Color); cmd.Parameters.AddWithValue("_modelo", bnn.Modelo); cmd.Parameters.AddWithValue("_alto", bnn.Alto); cmd.Parameters.AddWithValue("_ancho", bnn.Ancho); cmd.Parameters.AddWithValue("_profundidad", bnn.Profundidad); cmd.Parameters.AddWithValue("_id_bienes", bnn.Id_bienes); if (cmd.ExecuteNonQuery() > 0) { return(true); } else { return(false); } } } //} //catch (Exception) //{ // return false; //} }
// GET: Bienes/Edit/5 public ActionResult Edit(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } Bienes articulos = db.Bienes.Find(id); if (articulos == null) { return(HttpNotFound()); } ViewBag.EstadoId = new SelectList(db.Estados, "Id", "Nombre", articulos.EstadoId); ViewBag.FamiliaId = new SelectList(db.Familias, "Id", "CodFamilia", articulos.FamiliaId); ViewBag.IVAId = new SelectList(db.IVAs, "Id", "Descripcion", articulos.IVAId); return(PartialView(articulos)); }
public ActionResult Modificar_Bien(int?id) { Modelo_Bienes mb = new Modelo_Bienes(); Modelo_Categoria mc = new Modelo_Categoria(); List <Categoria> cat; if (id != null) { v_bie = mb.obtener(id); cat = mc.listar(); Info datos = new Info(); datos.Obj_bie = v_bie; datos.Cat = cat; return(View(datos)); } else { return(RedirectToAction("Consultar_Bien")); } //return View(); }
public ActionResult Registrar_Bien(int id_categoria, string nombre, string serie, string descripcion, string codigo, double precio, string estado, DateTime?fecha_ing, string marca, string color, string modelo, int alto, int ancho, int profundidad) { Bienes bie = new Bienes(); Modelo_Bienes mb = new Modelo_Bienes(); string message; string imagen = ""; SortedList <string, string> error = new SortedList <string, string>(); if (id_categoria == 0) { error.Add("sp_id_categoria", "Seleccione la categoria"); } if (String.IsNullOrEmpty(nombre)) { error.Add("sp_nombre", "Ingrese el nombre"); } if (String.IsNullOrEmpty(serie)) { error.Add("sp_nombre", "Ingrese el nombre"); } if (String.IsNullOrEmpty(descripcion)) { error.Add("sp_descripcion", "Ingrese su descripción"); } if (String.IsNullOrEmpty(codigo)) { error.Add("sp_codigo", "Ingrese el Codigo del bien"); } if (precio == 0) { error.Add("sp_precio", "Ingrese el Valor del bien"); } if (String.IsNullOrEmpty(estado)) { error.Add("sp_estado", "Ingrese el estado del bien"); } if (fecha_ing == null) { error.Add("sp_fecha_ing", "Ingrese la fecha"); } if (String.IsNullOrEmpty(marca)) { error.Add("sp_marca", "Ingrese la Marca"); } if (String.IsNullOrEmpty(color)) { error.Add("sp_color", "Ingrese el color del bien"); } if (String.IsNullOrEmpty(modelo)) { error.Add("sp_modelo", "Ingrese el modelo"); } if (alto == 0) { error.Add("sp_alto", "Ingrese el alto"); } if (ancho == 0) { error.Add("sp_anchor", "Ingrese el ancho"); } if (profundidad == 0) { error.Add("sp_profundidad", "Ingrese la Profundidad"); } if (error.Count == 0) { bie.Id_categoria = id_categoria == 0 ? 0 : id_categoria;; bie.Nombre = nombre == null ? "" : nombre; bie.Serie = serie == null ? "" : serie; bie.Descripcion = descripcion == null ? "" : descripcion; bie.Codigo = codigo == null ? "" : codigo; bie.Precio = precio == 0 ? 0 : precio; bie.Estado = estado == null ? "" : estado; bie.Fecha_ing = fecha_ing == null ? DateTime.Now : fecha_ing.Value; bie.Marca = marca == null ? "" : marca; bie.Color = color == null ? "" : color; bie.Modelo = modelo == null ? "" : modelo; bie.Alto = alto == 0 ? 0 : alto; bie.Ancho = ancho == 0 ? 0 : ancho; bie.Profundidad = profundidad == 0 ? 0 : profundidad; bie.Imagen = imagen == null ? "" : imagen; if (mb.guardar(bie)) { message = "Se guardaron los datos correctamente"; } else { message = "No se Guardaron lo datos"; } return(Json(new { message = message, success = true })); } else { message = "Ingrese los datos necesarios"; return(Json(new { message = message, success = false, datos = error })); } }