public async Task <IActionResult> Edit(int id, [Bind("IdCategoriaProducto,Nombre,Descripcion,Estado")] CategoriaProductos categoriaProductos) { if (id != categoriaProductos.IdCategoriaProducto) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(categoriaProductos); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!CategoriaProductosExists(categoriaProductos.IdCategoriaProducto)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } return(View(categoriaProductos)); }
public bool insertCategoria(CategoriaProductos categoria) { int insertaRegistro = 0; try { SqlCommand _comand = new SqlCommand("SP_InsertCategory", _objConexion.getConexion()); _objConexion.getConexion().Open(); _comand.CommandType = CommandType.StoredProcedure; _comand.Parameters.Add("@Descripcion", SqlDbType.VarChar).Value = categoria.Descripcion; insertaRegistro = _comand.ExecuteNonQuery(); _comand.Connection.Close(); } catch (Exception ex) { System.Windows.Forms.MessageBox.Show("HAY UN PROBLEMA CON LA BASE DE DATOS" + "INFORMACION : " + ex.Message); _objConexion.cerrarConexion(); } finally { _objConexion.cerrarConexion(); } if (insertaRegistro > 0) { return(true); } else { return(false); } }
public async Task <IActionResult> Delete(int?id, CategoriaProductos categoriaProductos) { if (id == null) { return(NotFound()); } if (id != categoriaProductos.ID) { return(NotFound()); } var categoriaProducto = _db.CategoriaProductos.Find(id); if (categoriaProducto == null) { return(NotFound()); } if (ModelState.IsValid) { _db.Remove(categoriaProducto); await _db.SaveChangesAsync(); TempData["eliminar"] = "La categoria se eliminó exitosamente!"; return(RedirectToAction(nameof(Index))); } return(View(categoriaProductos)); }
public async Task <IActionResult> Create([Bind("IdCategoriaProducto,Nombre,Descripcion,Estado")] CategoriaProductos categoriaProductos) { if (ModelState.IsValid) { _context.Add(categoriaProductos); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } return(View(categoriaProductos)); }
public async Task <IActionResult> Edit(CategoriaProductos categoriaProductos) { if (ModelState.IsValid) { _db.Update(categoriaProductos); await _db.SaveChangesAsync(); TempData["editar"] = "La categoria se actualizó exitosamente!"; return(RedirectToAction(nameof(Index))); } return(View(categoriaProductos)); }
public async Task <IActionResult> Create(CategoriaProductos categoriaProductos) { if (ModelState.IsValid) { _db.CategoriaProductos.Add(categoriaProductos); await _db.SaveChangesAsync(); TempData["guardar"] = "La categoria agregó exitosamente!"; return(RedirectToAction(nameof(Index))); } return(View(categoriaProductos)); }
private void ButtonEditar_Click(object sender, RoutedEventArgs e) { if (TextCategoriaId.Text != "") { string resp = ""; ClassCategoriaProducto logica = new ClassCategoriaProducto(); CategoriaProductos cp = new CategoriaProductos(); cp.CategoriaProductosID = Convert.ToInt32(this.TextCategoriaId.Text); cp.Nombre = this.TextNombre.Text; resp = logica.Actualizar(cp); MessageBox.Show(resp); } }
public string Actualizar(CategoriaProductos info) { string resultado = ""; RepositorioGenerico <CategoriaProductos> REP = new RepositorioGenerico <CategoriaProductos>(); try { resultado = REP.Editar(info); } catch (Exception Error) { resultado = "Error: " + Error.Message; } return(resultado); }
public CategoriaProductos Buscar(int id) { Contexto contexto = new Contexto(); CategoriaProductos categoria = new CategoriaProductos(); try { categoria = contexto.Categorias.Find(id); } catch (Exception) { throw; } return(categoria); }
//****************************************************************** //tareas sobre la tabla categoria de productos //****************************************************************** public bool InsertarCateogoriaProd(CategoriaProductos categoriaProductos) { try { using (var connection = new SQLiteConnection(System.IO.Path.Combine(folder, "kigest_sltosAriel.db"))) { connection.Insert(categoriaProductos); return(true); } } catch (SQLiteException ex) { Log.Info("SQLiteException", ex.Message); return(false); } }
private bool Insertar(CategoriaProductos categoria) { Contexto contexto = new Contexto(); bool paso = false; try { contexto.Categorias.Add(categoria); paso = contexto.SaveChanges() > 0; } catch (Exception) { throw; } return(paso); }
public bool ActualizarCategoriaProd(CategoriaProductos categoriaProductos) { try { using (var connection = new SQLiteConnection(System.IO.Path.Combine(folder, "kigest_sltosAriel.db"))) { connection.Query <CategoriaProductos>("UPDATE CategoriaProductos set nombre=? " + "where id=?", categoriaProductos.nombre, categoriaProductos.id); return(true); } } catch (SQLiteException ex) { Log.Info("SQLiteException", ex.Message); return(false); } }
public string NuevaCategoria(string nombre) { RepositorioGenerico <CategoriaProductos> REP = new RepositorioGenerico <CategoriaProductos>(); CategoriaProductos Cat = new CategoriaProductos(); string resultado; try { Cat.Nombre = nombre; resultado = REP.Agregar(Cat); } catch (Exception error) { resultado = "ERROR" + error.Message; } return(resultado); }
private bool Modificar(CategoriaProductos categoria) { Contexto contexto = new Contexto(); bool paso = false; try { contexto.Categorias.Add(categoria); contexto.Entry(categoria).State = EntityState.Modified; paso = contexto.SaveChanges() > 0; } catch (Exception) { throw; } return(paso); }
public bool Eliminar(int id) { Contexto contexto = new Contexto(); bool paso = false; CategoriaProductos categoria = new CategoriaProductos(); try { categoria = contexto.Categorias.Find(id); contexto.Entry(categoria).State = EntityState.Deleted; paso = contexto.SaveChanges() > 0; } catch (Exception) { throw; } return(paso); }
private async void ObtenerCatProd() { try { var databasepath = System.IO.Path.Combine(System.Environment.GetFolderPath(System.Environment.SpecialFolder.Personal), "kigest_sltosAriel.db"); var db = new SQLiteConnection(databasepath); RespuestaServerCategProductos respuestCatprod = await interfazCatprod.GetServerCategProductos(); categoriaProductos = respuestCatprod.ListaCategoriaProductos; //dbUser.VaciarTablaCategoriasProd(); foreach (CategoriaProductosServer categoria in categoriaProductos) { IEnumerable <ConsultasTablas> resultadocatprod = BuscarCatProd(db, categoria.id); if (resultadocatprod.Count() == 0) { CategoriaProductos catprodLocal = new CategoriaProductos() { id = categoria.id, nombre = categoria.nombre, sincro = categoria.sincro }; dbUser.InsertarCateogoriaProd(catprodLocal); } else { CategoriaProductos catprodLocal = new CategoriaProductos() { id = categoria.id, nombre = categoria.nombre, sincro = categoria.sincro }; dbUser.ActualizarCategoriaProd(catprodLocal); } } } catch (Exception ex) { Toast.MakeText(this, ex.Message + "-" + ex.StackTrace, ToastLength.Long).Show(); } }
public bool Guardar(CategoriaProductos categoria) { Contexto contexto = new Contexto(); bool paso = false; try { if (categoria.CategoriaId == 0) { paso = Insertar(categoria); } else { paso = Modificar(categoria); } } catch (Exception) { throw; } return(paso); }
public IActionResult Details(CategoriaProductos categoriaProductos) { return(RedirectToAction(nameof(Index))); }