public static bool Insertar(Usuarios usuario) { bool retorno = false; using (var db = new LavanderiaDb()) { try { if (Buscar(usuario.UsuarioId) == null) { db.Usuario.Add(usuario); } else { db.Entry(usuario).State = System.Data.Entity.EntityState.Modified; } db.SaveChanges(); retorno = true; } catch (Exception) { throw; } return(retorno); } }
public static List <Clientes> GetListNombres(string nombre) { List <Clientes> lista = new List <Clientes>(); using (var db = new LavanderiaDb()) { try { if (db.Cliente.Where(c => c.Nombres == nombre).Count() > 0) { lista = db.Cliente.Where(c => c.Nombres == nombre).ToList(); } else { lista = null; } //lista = db.Cliente.Where(c => c.Nombres == nombre).ToList(); } catch (Exception) { throw; } return(lista); } }
public static bool Insertar(Servicios servicio) { bool retorno = false; using (var db = new LavanderiaDb()) { try { if (Buscar(servicio.ServicioId) == null) { db.Servicio.Add(servicio); } else { db.Entry(servicio).State = System.Data.Entity.EntityState.Modified; } db.SaveChanges(); retorno = true; } catch (Exception e) { MessageBox.Show(e.ToString()); //throw; } return(retorno); } }
//public static Clientes Modificar(int id, string nombre, string direccion, string telefono) //{ // var cliente = new Clientes(); // using (var db = new LavanderiaDb()) // { // try // { // cliente = db.Cliente.Where(c => c.ClienteId.Equals(id)).FirstOrDefault(); // cliente.Nombres = nombre; // cliente.Direccion = direccion; // cliente.Telefono = telefono; // db.SaveChanges(); // } // catch (Exception) // { // throw; // } // return cliente; // } //} public static List <Clientes> GetListClienteId(int clienteId) { List <Clientes> lista = new List <Clientes>(); using (var db = new LavanderiaDb()) { try { if (db.Cliente.Where(c => c.ClienteId == clienteId).Count() > 0) { lista = db.Cliente.Where(c => c.ClienteId == clienteId).ToList(); } else { lista = null; } //lista = db.Cliente.Where(c => c.ClienteId == clienteId).ToList(); } catch (Exception) { throw; } return(lista); } }
public static List <Servicios> GetList() { List <Servicios> lista = new List <Servicios>(); using (var db = new LavanderiaDb()) { try { if (db.Servicio.ToList().Count() > 0) { lista = db.Servicio.ToList(); } else { lista = null; } //lista = db.Servicio.ToList(); } catch (Exception) { throw; } return(lista); } }
public static List <ServiciosArticulos> Buscar(int articuloId) { var servicioArticulo = new List <ServiciosArticulos>(); using (var db = new LavanderiaDb()) { try { servicioArticulo = db.ServicioArticulo.Where(sa => sa.ArticuloId == articuloId).ToList(); } catch (Exception) { throw; } return(servicioArticulo); } }
public static List <Facturas> GetListClienteId(int clienteId) { List <Facturas> lista = new List <Facturas>(); using (var db = new LavanderiaDb()) { try { lista = db.Factura.Where(f => f.ClienteId == clienteId).ToList(); } catch (Exception) { throw; } return(lista); } }
public static Facturas Buscar(int id) { var factura = new Facturas(); using (var db = new LavanderiaDb()) { try { factura = db.Factura.Find(id); } catch (Exception) { throw; } return(factura); } }
public List <FacturasArticulos> GetList() { List <FacturasArticulos> lista = new List <FacturasArticulos>(); using (var db = new LavanderiaDb()) { try { lista = db.FacturaArticulo.ToList(); } catch (Exception) { throw; } return(lista); } }
public static List <Facturas> GetListFecha(DateTime desde, DateTime hasta) { List <Facturas> lista = new List <Facturas>(); using (var db = new LavanderiaDb()) { try { lista = db.Factura.Where(f => f.Fecha >= desde && f.Fecha <= hasta).ToList(); } catch (Exception) { throw; } return(lista); } }
public static Clientes Buscar(int id) { var cliente = new Clientes(); using (var db = new LavanderiaDb()) { try { cliente = db.Cliente.Find(id); } catch (Exception) { throw; } return(cliente); } }
public static Servicios Buscar(int id) { var servicio = new Servicios(); using (var db = new LavanderiaDb()) { try { servicio = db.Servicio.Find(id); } catch (Exception) { throw; } return(servicio); } }
public static Usuarios Buscar(int id) { var usuario = new Usuarios(); using (var db = new LavanderiaDb()) { try { usuario = db.Usuario.Find(id); } catch (Exception) { throw; } return(usuario); } }
public static List <FacturasArticulos> Buscar(int facturaId) { var facturaArticulos = new List <FacturasArticulos>(); using (var db = new LavanderiaDb()) { try { facturaArticulos = db.FacturaArticulo.Where(fa => fa.FacturaId == facturaId).ToList(); } catch (Exception) { throw; } return(facturaArticulos); } }
public static Articulos Buscar(int id) { var articulos = new Articulos(); using (var db = new LavanderiaDb()) { try { articulos = db.Articulo.Find(id); } catch (Exception e) { MessageBox.Show(e.ToString()); //throw; } return(articulos); } }
public static bool Eliminar(Servicios servicio) { bool retorno = false; using (var db = new LavanderiaDb()) { try { db.Entry(servicio).State = EntityState.Deleted; db.SaveChanges(); retorno = true; } catch (Exception) { throw; } return(retorno); } }
public static bool Insertar(List <FacturasArticulos> facturaArticulos) { bool retorno = false; using (var db = new LavanderiaDb()) { try { db.FacturaArticulo.AddRange(facturaArticulos); db.SaveChanges(); retorno = true; } catch (Exception) { throw; } return(retorno); } }
public static bool Eliminar(int facturaId) { bool retorno = false; using (var db = new LavanderiaDb()) { try { db.FacturaArticulo.RemoveRange(db.FacturaArticulo.Where(fa => fa.FacturaId == facturaId)); db.SaveChanges(); retorno = true; } catch (Exception) { throw; } return(retorno); } }
public static bool Insertar(List <ServiciosArticulos> servicioArticulo) { bool retorno = false; using (var db = new LavanderiaDb()) { try { db.ServicioArticulo.AddRange(servicioArticulo); db.SaveChanges(); retorno = true; } catch (Exception e) { MessageBox.Show(e.ToString()); //throw; } return(retorno); } }
public static bool Eliminar(int articuloId) { bool retorno = false; var servicioArticulo = new ServiciosArticulos(); using (var db = new LavanderiaDb()) { try { db.ServicioArticulo.RemoveRange(db.ServicioArticulo.Where(sa => sa.ArticuloId == articuloId)); db.SaveChanges(); retorno = true; } catch (Exception) { throw; } return(retorno); } }
//public static Usuarios Modificar(int id) //{ // var usuario = new Usuarios(); // using (var db = new LavanderiaDb()) // { // try // { // usuario = db.Usuario.Find(id); // db.Usuario.Add(usuario); // db.SaveChanges(); // } // catch (Exception) // { // throw; // } // return usuario; // } //} public static List <Usuarios> GetListNombreUsuarios(string nombreUsuario) { List <Usuarios> lista = new List <Usuarios>(); using (var db = new LavanderiaDb()) { try { //if (db.Usuario.Where(u => u.NombreUsuario == nombreUsuario).Count() > 0) // lista = db.Usuario.Where(u => u.NombreUsuario == nombreUsuario).ToList(); //else // lista = null; lista = db.Usuario.Where(u => u.NombreUsuario == nombreUsuario).ToList(); } catch (Exception) { throw; } return(lista); } }
public static List <Usuarios> GetListClave(string clave) { List <Usuarios> lista = new List <Usuarios>(); using (var db = new LavanderiaDb()) { try { //if (db.Usuario.Where(u => u.Clave == clave).Count() > 0) // lista = db.Usuario.Where(u => u.Clave == clave).ToList(); //else // lista = null; lista = db.Usuario.Where(c => c.Clave == clave).ToList(); } catch (Exception) { throw; } return(lista); } }
public static bool Eliminar(int id) { bool retorno = false; var factura = new Facturas(); using (var db = new LavanderiaDb()) { try { factura = db.Factura.Find(id); db.Factura.Remove(factura); db.SaveChanges(); retorno = true; } catch (Exception) { throw; } return(retorno); } }