public static bool Guardar(Empleado empleado) { using (var db = new ParcialDb()) { try { if (Buscar(empleado.EmpleadoId) == null) { db.Empleados.Add(empleado); db.SaveChanges(); } else { db.Entry(empleado).State = System.Data.Entity.EntityState.Modified; db.SaveChanges(); } return(true); } catch (Exception) { return(false); throw; } } }
public static bool Guardar(Presupuesto presupuesto, List <Entidades.PresupuestoDetalle> listaRelaciones) { using (var repositorio = new Repositorio <Presupuesto>()) { if (repositorio.Buscar(P => P.PresupuestoId == presupuesto.PresupuestoId) == null) { repositorio.Guardar(presupuesto); bool relacionesGuardadas = true; foreach (var relacion in listaRelaciones) { relacion.PresupuestoId = presupuesto.PresupuestoId; if (!PresupuestoDetalleBLL.Guardar(relacion)) { relacionesGuardadas = false; } } return(relacionesGuardadas); } else { //return repositorio.Modificar(presupuesto); using (var context = new ParcialDb()) { context.Presupuestos.Attach(presupuesto); context.Entry(presupuesto).State = System.Data.Entity.EntityState.Modified; return(context.SaveChanges() > 0); } } } }
public static List <TiposTelefonos> GetLista() { List <TiposTelefonos> lista = new List <TiposTelefonos>(); var db = new ParcialDb(); lista = db.TipoTelefono.ToList(); return(lista); }
public static List <Clientes> GetLista() { List <Clientes> lista = new List <Clientes>(); var db = new ParcialDb(); lista = db.Cliente.ToList(); return(lista); }
public static void Borrar(int id) { var db = new ParcialDb(); var cliente = new Clientes(); cliente = (from c in db.Cliente where id == c.ClienteId select c).FirstOrDefault(); db.Cliente.Remove(cliente); db.SaveChanges(); }
public static List <Clientes> GetLista(int id) { List <Clientes> lista = new List <Clientes>(); var db = new ParcialDb(); lista = (from c in db.Cliente where c.ClienteId == id select c).ToList(); return(lista); }
public static List <Clientes> GetLista(string nombre) { List <Clientes> lista = new List <Clientes>(); var db = new ParcialDb(); lista = (from c in db.Cliente where c.Nombres == nombre select c).ToList(); return(lista); }
public static List <Clientes> GetLista(DateTime desde, DateTime hasta) { List <Clientes> lista = new List <Clientes>(); var db = new ParcialDb(); lista = (from c in db.Cliente where c.FechaNacimiento.Date >= desde && c.FechaNacimiento.Date <= hasta select c).ToList(); return(lista); }
public static void Modificar(int id, Clientes cliente) { var db = new ParcialDb(); Clientes client = db.Cliente.Find(id); client.Nombres = cliente.Nombres; client.LimiteCredito = cliente.LimiteCredito; client.FechaNacimiento = cliente.FechaNacimiento; client.Telefonos = cliente.Telefonos; db.SaveChanges(); }
public static bool Insertar(Clientes cliente) { bool retorno = false; try { var db = new ParcialDb(); db.Cliente.Add(cliente); db.SaveChanges(); retorno = true; }catch (Exception) { throw; } return(retorno); }
public static Entidades.Empleados Buscar1(int id) { Entidades.Empleados emple = null; using (var conexion = new ParcialDb()) { try { emple = conexion.EmpleadoDb.Find(id); } catch (Exception) { throw; } } return(emple); }
public static List <Empleado> GetListNombres(string nombres) { using (var db = new ParcialDb()) { try { return(db.Empleados.Where <Empleado>(P => P.Nombres == nombres).ToList()); } catch (Exception) { return(new List <Empleado>()); throw; } } }
public static Empleado Buscar(int id) { using (var db = new ParcialDb()) { try { return(db.Empleados.Find(id)); } catch (Exception) { return(null); throw; } } }
public static List <Empleado> GetList() { using (var db = new ParcialDb()) { try { return(db.Empleados.ToList()); } catch (Exception) { return(new List <Empleado>()); throw; } } }
public static List <Empleado> GetListNombresFechas(string nombres, DateTime desde, DateTime hasta) { using (var db = new ParcialDb()) { try { return(db.Empleados.Where <Empleado>(P => P.Nombres == nombres).Where <Empleado>(P => P.FechaNacimiento >= desde && P.FechaNacimiento <= hasta).ToList()); } catch (Exception) { return(new List <Empleado>()); throw; } } }
public static Entidades.Retenciones BuscarID(int id) { Entidades.Retenciones retencion = null; using (var conexion = new ParcialDb()) { try { retencion = conexion.RetencionesDb.Find(id); } catch (Exception) { throw; } } return (retencion); }
public static bool Eliminar(int id) { using (var db = new ParcialDb()) { try { db.Entry(Buscar(id)).State = System.Data.Entity.EntityState.Deleted; db.SaveChanges(); return(true); } catch (Exception) { return(false); throw; } } }
public static bool Guardar(Entidades.EmpleadosRetenciones relacion) { bool resultado = false; using (var conexion = new ParcialDb()) { try { conexion.EmpleadosDecuentosDb.Add(relacion); conexion.SaveChanges(); resultado = true; } catch (Exception) { throw; } } return(resultado); }
public static bool Guardar(PresupuestoDetalle relacion) { using (var repositorio = new Repositorio <PresupuestoDetalle>()) { if (repositorio.Buscar(P => P.Id == relacion.Id) == null) { return(repositorio.Guardar(relacion)); } else { //return repositorio.Modificar(presupuestoDetalle); using (var context = new ParcialDb()) { context.PresupuestoDetalle.Attach(relacion); context.Entry(relacion).State = System.Data.Entity.EntityState.Modified; return(context.SaveChanges() > 0); } } } }
public static List <Retenciones> Listar(Expression <Func <Empleados, bool> > criterioBusqueda) { List <Retenciones> listado = new List <Retenciones>(); List <Empleados> relaciones = null; using (var conexion = new ParcialDb()) { try { relaciones = conexion.EmpleadoDb.Where(criterioBusqueda).ToList(); foreach (var item in relaciones) { listado.Add(RetencionesBLL.BuscarID(item.RetencionId)); } } catch (Exception) { throw; } } return(listado); }
public static bool Guardar(Entidades.Empleados empleado) { using (var conec = new ParcialDb()) { try { conec.EmpleadoDb.Add(empleado); foreach (var g in empleado.RetencionesList) { conec.Entry(g).State = System.Data.Entity.EntityState.Unchanged; } conec.SaveChanges(); return(true); } catch (Exception) { throw; } } return(false); }
public static Clientes Buscar(int id) { var db = new ParcialDb(); return(db.Cliente.Find(id)); }