public static ValorInventario Buscar(int id) { Contexto db = new Contexto(); ValorInventario valor = new ValorInventario(); try { valor = db.ValorInventario.Find(id); } catch (Exception) { throw; } finally { db.Dispose(); } return(valor); }
public static ValorInventario Buscar(int id) { Contexto contexto = new Contexto(); ValorInventario inventario = new ValorInventario(); try { inventario = contexto.Consultas.Find(id); } catch { throw; } finally { contexto.Dispose(); } return(inventario); }
public static bool Modificar(ValorInventario inventario) { bool paso = false; Contexto contexto = new Contexto(); try { contexto.Entry(inventario).State = EntityState.Modified; paso = (contexto.SaveChanges() > 0); contexto.Dispose(); } catch (Exception) { throw; } return(paso); }
public static bool Guardar(ValorInventario valorInventario) { bool paso = false; Contexto contexto = new Contexto(); try { if (contexto.ValorInventario.Add(valorInventario) != null) { paso = contexto.SaveChanges() > 0; } contexto.Dispose(); } catch (Exception) { throw; } return(paso); }
public static bool Modificar(ValorInventario valorinvetario) { bool paso = false; Contexto db = new Contexto(); try { db.Entry(valorinvetario).State = EntityState.Modified; paso = (db.SaveChanges() > 0); } catch (Exception) { throw; } finally { db.Dispose(); } return(paso); }
private void MostrarInventario() { string d = "1"; int.TryParse(d, out id); ValorInventario valorinventario = new ValorInventario(); valorinventario = ValorInventarioBLL.Buscar(id); if (valorinventario != null) { MessageBox.Show("Inventario Actualizado"); LlenaCampo(valorinventario); } else { MessageBox.Show("No actualizasdo"); } }
private void ActualizarButton_Click(object sender, EventArgs e) { ValorInventario valorinventario = new ValorInventario(); bool paso = false; valorinventario = ValorInventarioBLL.Buscar(id); if (valorinventario == null) { valorinventario = LlenaClase(); paso = ValorInventarioBLL.Guardar(valorinventario); } else { valorinventario = LlenaClase(); if (!ExisteEnLaBaseDeDatos()) { MessageBox.Show("No actualizado", "Fallo", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } paso = ValorInventarioBLL.Modificar(valorinventario); } MostrarInventario(); }
public static bool Guardar(Producto productos) { bool paso = false; Contexto contexto = new Contexto(); ValorInventario inventario = new ValorInventario(); try { inventario = ValorInventariosBLL.Buscar(1); if (inventario == null) { inventario = LlenaClase(); paso = ValorInventariosBLL.Guardar(inventario); } if (contexto.Producto.Add(productos) != null) { paso = contexto.SaveChanges() > 0; } inventario.Valor_Inventario += productos.Valor_Inventario; ValorInventariosBLL.Modificar(inventario); } catch (Exception) { throw; } finally { contexto.Dispose(); } return(paso); }
public static bool Guardar(ValorInventario valorinventario) { bool paso = false; Contexto db = new Contexto(); try { if (db.ValorInventario.Add(valorinventario) != null) { paso = db.SaveChanges() > 0; } } catch (Exception) { throw; } finally { db.Dispose(); } return(paso); }
private void MetroTileValorInventarioInicio_Click(object sender, EventArgs e) { ValorInventario vi = new ValorInventario(); vi.Show(); }
private bool ExisteEnLaBaseDeDatos() { ValorInventario valorinventario = ValorInventarioBLL.Buscar(1); return(valorinventario != null); }
private void LlenaCampo(ValorInventario valorinventario) { ValorTotalInvetarioTextBox.Text = Convert.ToString(valorinventario.ValorTotalInventario); }