public static bool Guardar(Vendedores vendedor) { bool retorno = false; using (var conexion = new ProyectoFinalDb()) { try { if (Buscar(vendedor.VendedorId) == null) { conexion.Vendedor.Add(vendedor); } else { conexion.Entry(vendedor).State = EntityState.Modified; } conexion.SaveChanges(); retorno = true; } catch (Exception e) { MessageBox.Show(e.ToString()); } return(retorno); } }
public static bool Insertar(Productos productos) { bool obtener = false; using (var conexion = new ProyectoFinalDb()) { try { if (Buscar(productos.IdProducto) == null) { conexion.Producto.Add(productos); } else { conexion.Entry(productos).State = EntityState.Modified; } conexion.SaveChanges(); obtener = true; } catch (Exception e) { MessageBox.Show(e.ToString()); //throw; } return(obtener); } }
public static Usuarios Buscar(int id) { var us = new Usuarios(); var conn = new ProyectoFinalDb(); us = conn.Usuario.Find(id); return(us); }
public static List <Usuarios> GetLista(int usuarioId) { List <Usuarios> lista = new List <Usuarios>(); var db = new ProyectoFinalDb(); lista = db.Usuario.Where(p => p.Usuarioid == usuarioId).ToList(); return(lista); }
public static List <Usuarios> GetLista() { List <Usuarios> lista = new List <Usuarios>(); var db = new ProyectoFinalDb(); lista = db.Usuario.ToList(); return(lista); }
public static List <Proveedores> GetLista() { List <Proveedores> lista = new List <Proveedores>(); using (var conexion = new ProyectoFinalDb()) { try { lista = conexion.Proveedore.ToList(); } catch (Exception e) { MessageBox.Show(e.ToString()); } return(lista); } }
public static List <Productos> ListaCombo() { List <Productos> lista = null; using (var conexion = new ProyectoFinalDb()) { try { lista = conexion.Producto.Where(p => p.Cantidad <= 0 && p.Total <= 0).ToList(); } catch (Exception) { throw; } } return(lista); }
public static Vendedores Buscar(int vendedorId) { var vendedor = new Vendedores(); using (var conexion = new ProyectoFinalDb()) { try { vendedor = conexion.Vendedor.Find(vendedorId); } catch (Exception) { throw; } } return(vendedor); }
public static List <Vendedores> GetListaId(int vendedorId) { List <Vendedores> lista = new List <Vendedores>(); using (var db = new ProyectoFinalDb()) { try { lista = db.Vendedor.Where(p => p.VendedorId == vendedorId).ToList(); } catch (Exception) { throw; } return(lista); } }
public static List <Vendedores> GetListNombre(string nombre) { List <Vendedores> lista = new List <Vendedores>(); using (var conexion = new ProyectoFinalDb()) { try { lista = conexion.Vendedor.Where(n => string.Equals(n.Nombre, nombre)).ToList(); } catch (Exception) { throw; } } return(lista); }
public static Productos Buscar(int productoId) { var producto = new Productos(); using (var conexion = new ProyectoFinalDb()) { try { producto = conexion.Producto.Find(productoId); } catch (Exception) { throw; } } return(producto); }
public static List <TiposVehiculos> GetLista() { List <TiposVehiculos> lista = new List <TiposVehiculos>(); using (var db = new ProyectoFinalDb()) { try { lista = db.TiposVehiculos.ToList(); } catch (Exception e) { MessageBox.Show(e.ToString()); // throw; } return(lista); } }
public static List <Vendedores> GetLista() { List <Vendedores> lista = new List <Vendedores>(); using (var db = new ProyectoFinalDb()) { try { lista = db.Vendedor.ToList(); } catch (Exception e) { MessageBox.Show(e.ToString()); throw; } return(lista); } }
public static List <Productos> GetLista(int idProducto) { List <Productos> lista = new List <Productos>(); using (var conexion = new ProyectoFinalDb()) { try { lista = conexion.Producto.Where(p => p.IdProducto == idProducto).ToList(); } catch (Exception) { throw; } } return(lista); }
public static bool Insertar(Proveedores proveedor) { bool resultado = false; using (var conexion = new ProyectoFinalDb()) { try { conexion.Proveedore.Add(proveedor); conexion.SaveChanges(); resultado = true; } catch (Exception) { throw; } return(resultado); } }
public static bool Insertar(TiposVehiculos tVehiculos) { bool resultado = false; using (var conexion = new ProyectoFinalDb()) { try { conexion.TiposVehiculos.Add(tVehiculos); conexion.SaveChanges(); resultado = true; } catch (Exception) { throw; } return(resultado); } }
public static Double GetPrecio(int productoId) { Double precio = 0; using (var conexion = new ProyectoFinalDb()) { try { Productos p = conexion.Producto.Where(prod => prod.IdProducto == productoId).FirstOrDefault(); precio = p.Precio; } catch (Exception e) { MessageBox.Show(e.ToString()); throw; } return(precio); } }
public static void Eliminar(Vendedores vendedor) { using (var conexion = new ProyectoFinalDb()) { try { if (vendedor != null) { conexion.Entry(vendedor).State = EntityState.Deleted; conexion.SaveChanges(); } } catch (Exception e) { MessageBox.Show(e.ToString()); throw; } } }
public static bool Insertar(Facturas factura) { bool resultado = false; using (var conexion = new ProyectoFinalDb()) { try { conexion.Factura.Add(factura); conexion.SaveChanges(); resultado = true; } catch (Exception e) { MessageBox.Show(e.ToString()); throw; } return(resultado); } }
public static Facturas Buscar(int facturaId) { Facturas factura = null; using (var conexion = new ProyectoFinalDb()) { try { factura = conexion.Factura.Find(facturaId); if (factura != null) { factura.Productos.Count(); } } catch (Exception) { throw; } } return(factura); }
public static List <Productos> Productos(int facturaId) { var producto = new List <Productos>(); using (var conexion = new ProyectoFinalDb()) { try { var factura = BLL.FacturasBLL.Buscar(facturaId); if (factura != null) { producto = factura.Productos; } } catch (Exception) { throw; } } return(producto); }
public static bool Guardar(Usuarios usuario) { bool retorno = false; try { var db = new ProyectoFinalDb(); db.Usuario.Add(usuario); db.SaveChanges(); retorno = true; } catch (Exception) { throw; } return(retorno); }
public static bool Eliminar(int id) { bool obtener = false; using (var db = new ProyectoFinalDb()) { try { Usuarios us = db.Usuario.Find(id); db.Usuario.Remove(us); db.SaveChanges(); obtener = true; } catch (Exception) { throw; } return(obtener); } }