public static List <ETratamiento> mostrarTipo(string texto, string tipo) { try { List <ETratamiento> ETratamientos = new List <ETratamiento>(); List <tratamiento> tratamientos = new List <tratamiento>(); using (dbodontogramaEntity cn = new dbodontogramaEntity()) { tratamientos = (from d in cn.tratamiento where d.estado == 1 where d.tipo == tipo where d.nombre.Contains(texto) select d).ToList(); foreach (var item in tratamientos) { ETratamiento Obj = new ETratamiento(); Obj.tratamientoID = item.tratamientoID; Obj.nombre = item.nombre; Obj.color = item.color; Obj.tipo = item.tipo; Obj.precio = item.precio; Obj.estado = item.estado; ETratamientos.Add(Obj); } return(ETratamientos); } } catch (Exception ex) { throw new Exception(ex.Message); } }
public EPaciente mostraPacienteOdontograma(int ID) { try { using (dbodontogramaEntity cn = new dbodontogramaEntity()) { paciente item = new paciente(); item = (from p in cn.paciente join c in cn.atencion on p.pacienteID equals c.pacienteID join ct in cn.atencion_detalle on c.atencionID equals ct.atencionID join od in cn.odontograma_detalle on ct.odontogramaID equals od.odontogramaID join o in cn.odontograma on od.odontogramaID equals o.odontogramaID where p.estado == 1 && o.odontogramaID == ID select p).First(); EPaciente Obj = new EPaciente(); Obj.pacienteID = item.pacienteID; Obj.nombre = item.nombre; Obj.apellido = item.apellido; Obj.telefono = item.telefono; Obj.ci = item.ci; Obj.fechaNacimiento = item.fechaNacimiento; Obj.direccion = item.direccion; Obj.sexo = item.sexo; Obj.estado = item.estado; return(Obj); } } catch (Exception ex) { throw new Exception(ex.Message); } }
public static long save(EParte Parte) { try { CapaDato.dbodontogramaEntity cn = new dbodontogramaEntity(); List <parte> partes = new List <parte>(); parte Obj = new parte(); partes = (from t in cn.parte where t.nombre == Parte.nombre select t).ToList(); if (partes.Count > 0) { throw new Exception("El Parte Ya Existe"); } Obj.nombre = Parte.nombre; cn.parte.Add(Obj); int result = cn.SaveChanges(); if (result > 0) { return(Obj.parteID); } else { throw new Exception("Error al guardar"); } } catch (Exception ex) { throw new Exception(ex.Message); } }
public static List <EDiente> mostrar(string texto, int pag) { try { List <EDiente> dientes = new List <EDiente>(); using (dbodontogramaEntity cn = new dbodontogramaEntity()) { dientes = (from d in cn.diente where d.estado == 1 where d.nombre.Contains(texto) orderby d.dienteID descending select new EDiente { dienteID = d.dienteID, nombre = d.nombre, vector = d.vector, estado = d.estado }).ToList(); pag = pag * 10; var tabla = dientes.Skip(pag).Take(10); if (dientes.Count < pag) { tabla = dientes.Skip(pag).Take(10); } return(tabla.ToList()); } } catch (Exception ex) { throw new Exception(ex.Message); } }
public EPaciente mostraDatos(int id) { try { using (dbodontogramaEntity cn = new dbodontogramaEntity()) { paciente item = new paciente(); item = cn.paciente.Find(id); EPaciente Obj = new EPaciente(); Obj.pacienteID = item.pacienteID; Obj.nombre = item.nombre; Obj.apellido = item.apellido; Obj.telefono = item.telefono; Obj.ci = item.ci; Obj.fechaNacimiento = item.fechaNacimiento; Obj.direccion = item.direccion; Obj.sexo = item.sexo; Obj.estado = item.estado; return(Obj); } } catch (Exception ex) { throw new Exception(ex.Message); } }
public static List <EParte> mostrar(string texto) { try { List <EParte> Partes = new List <EParte>(); List <parte> partes = new List <parte>(); using (dbodontogramaEntity cn = new dbodontogramaEntity()) { partes = (from t in cn.parte where t.estado == 1 where t.nombre.Contains(texto) orderby t.parteID descending select t).ToList(); foreach (var item in partes) { EParte Obj = new EParte(); Obj.parteID = item.parteID; Obj.nombre = item.nombre; Obj.estado = item.estado; Partes.Add(Obj); } return(Partes); } } catch (Exception ex) { throw new Exception(ex.Message); } }
public EUsers mostrarUserID(int ID) { try { using (dbodontogramaEntity cn = new dbodontogramaEntity()) { users Obj = new users(); EUsers login = new EUsers(); Obj = (from u in cn.users where u.usuarioID == ID select u).First(); login.usuarioID = Obj.usuarioID; login.nombre = Obj.nombre; login.apellido = Obj.apellido; login.tipo = Obj.tipo; login.usuario = Obj.usuario; login.password = Obj.password; return(login); } } catch (Exception ex) { //throw new Exception(ex.Message); throw new Exception("El Usuario que Ingresaste no coinciden con ninguna Cuenta " + ex.Message); } }
public static long save(EAtencion Atencion) { try { using (dbodontogramaEntity cn = new dbodontogramaEntity()) { atencion Obj = new atencion(); Obj.pacienteID = Atencion.pacienteID; Obj.empleadoID = Atencion.empleadoID; Obj.odontologoID = Atencion.odontologoID; Obj.fecha = Convert.ToDateTime(DateTime.Now.ToLongDateString()); Obj.hora = Atencion.hora; Obj.importe = Atencion.importe; Obj.descripcion = Atencion.descripcion; Obj.estado = 1; cn.atencion.Add(Obj); int result = cn.SaveChanges(); if (result > 0) { return(Obj.atencionID); } else { throw new Exception("Error Al guardar El Registro"); } } } catch (Exception ex) { throw new Exception(ex.Message); } }
public static long update(EOdontograma_detalle OD) { try { CapaDato.dbodontogramaEntity cn = new dbodontogramaEntity(); odontograma_detalle Obj = new odontograma_detalle(); Obj = (from o in cn.odontograma_detalle where o.odontogramaID == OD.odontogramaID select o).First(); Obj.odontogramaID = OD.odontogramaID; Obj.dienteID = OD.dienteID; Obj.parteID = OD.parteID; Obj.diagnosticoID = OD.diagnosticoID; Obj.procedimientoID = OD.procedimientoID; Obj.estado = OD.estado; int result = cn.SaveChanges(); if (result > 0) { return(Obj.odontogramaID); } else { throw new Exception("error al Editar"); } } catch (Exception ex) { throw new Exception(ex.Message); } }
public static List <EOdontograma_detalle> mostrar(int ID) { try { List <EOdontograma_detalle> Odontogramas = new List <EOdontograma_detalle>(); List <odontograma_detalle> odontogramas = new List <odontograma_detalle>(); using (dbodontogramaEntity cn = new dbodontogramaEntity()) { odontogramas = (from o in cn.odontograma_detalle where o.odontogramaID == ID where o.estado == 1 orderby o.odontogramaID descending select o).ToList(); foreach (var item in odontogramas) { EOdontograma_detalle Obj = new EOdontograma_detalle(); Obj.odontogramaID = item.odontogramaID; Obj.dienteID = item.dienteID; Obj.parteID = item.parteID; Obj.diagnosticoID = item.diagnosticoID; Obj.procedimientoID = item.procedimientoID; Obj.estado = item.estado; Odontogramas.Add(Obj); } return(Odontogramas); } } catch (Exception ex) { throw new Exception(ex.Message); } }
public static long save(EOdontograma_detalle OD) { try { CapaDato.dbodontogramaEntity cn = new dbodontogramaEntity(); odontograma_detalle Obj = new odontograma_detalle(); Obj.odontogramaID = OD.odontogramaID; Obj.dienteID = OD.dienteID; Obj.parteID = OD.parteID; Obj.diagnosticoID = OD.diagnosticoID; Obj.procedimientoID = OD.procedimientoID; Obj.estado = OD.estado; cn.odontograma_detalle.Add(Obj); int result = cn.SaveChanges(); if (result > 0) { return(Obj.odontogramaID); } else { throw new Exception("Error al guardar"); } } catch (Exception ex) { throw new Exception(ex.Message); } }
public static int mostrarTotal(string texto) { try { List <EDiente> dientes = new List <EDiente>(); using (dbodontogramaEntity cn = new dbodontogramaEntity()) { dientes = (from d in cn.diente where d.estado == 1 where d.nombre.Contains(texto) orderby d.dienteID descending select new EDiente { dienteID = d.dienteID, nombre = d.nombre, vector = d.vector, estado = d.estado }).ToList(); return(dientes.Count); } } catch (Exception ex) { throw new Exception(ex.Message); } }
public static List <EAtencion_detalle> mostrar(int ID) { try { List <EAtencion_detalle> EDetalle = new List <EAtencion_detalle>(); List <atencion_detalle> DDetalle = new List <atencion_detalle>(); using (dbodontogramaEntity cn = new dbodontogramaEntity()) { DDetalle = (from c in cn.atencion_detalle where c.estado == 1 where c.atencion.pacienteID == ID select c).ToList(); foreach (var item in DDetalle) { EAtencion_detalle Obj = new EAtencion_detalle(); Obj.odontogramaID = item.odontogramaID; Obj.atencionID = item.atencionID; Obj.estado = item.estado; EDetalle.Add(Obj); } return(EDetalle); } } catch (Exception ex) { throw new Exception(ex.Message); } }
public static List <EOdontograma> mostrar(string nombre, string apellido, int pag) { try { List <EOdontograma> O = new List <EOdontograma>(); using (dbodontogramaEntity cn = new dbodontogramaEntity()) { O = (from o in cn.odontograma join od in cn.odontograma_detalle on o.odontogramaID equals od.odontogramaID join d in cn.diente on od.dienteID equals d.dienteID join par in cn.parte on od.parteID equals par.parteID join tra in cn.tratamiento on od.diagnosticoID equals tra.tratamientoID join pro in cn.tratamiento on od.procedimientoID equals pro.tratamientoID join cd in cn.atencion_detalle on od.odontogramaID equals cd.odontogramaID join c in cn.atencion on cd.atencionID equals c.atencionID join pc in cn.paciente on c.pacienteID equals pc.pacienteID where o.estado == 1 where pc.nombre.Contains(nombre) where pc.apellido.Contains(apellido) group o by new { o.odontogramaID, o.fechaInicio, o.fechaFinal, o.tratamiento, o.montoTotal, o.estado, pc.nombre, pc.apellido } into grupo orderby grupo.Key.odontogramaID descending select new EOdontograma { odontogramaID = grupo.Key.odontogramaID, fechaInicio = grupo.Key.fechaInicio, fechaFinal = grupo.Key.fechaFinal, montoTotal = grupo.Key.montoTotal, tratamiento = grupo.Key.tratamiento, Paciente = grupo.Key.nombre + " " + grupo.Key.apellido, estado = grupo.Key.estado }).ToList(); pag = pag * 10; var tabla = O.Skip(pag).Take(10); if (O.Count < pag) { tabla = O.Skip(pag).Take(10); } return(tabla.ToList()); } } catch (Exception ex) { throw new Exception(ex.Message); } }
public static long save(EUsers Usuario) { try { CapaDato.dbodontogramaEntity cn = new dbodontogramaEntity(); List <users> user = new List <users>(); users Obj = new users(); user = (from u in cn.users where u.nombre == Usuario.nombre && u.apellido == Usuario.apellido select u).ToList(); if (user.Count > 0) { throw new Exception("El Nombre y Apellido Del Usuario Ya Existe"); } user = (from u in cn.users where u.usuario == Usuario.usuario select u).ToList(); if (user.Count > 0) { throw new Exception("El Usuario Ya Existe"); } Obj.nombre = Usuario.nombre; Obj.apellido = Usuario.apellido; Obj.tipo = Usuario.tipo; if (Obj.nombre == string.Empty && Obj.apellido == string.Empty) { throw new Exception("Ingrese Nombre y Apellido"); } Obj.usuario = Usuario.usuario; Obj.password = Usuario.password; Obj.estado = 1; cn.users.Add(Obj); int result = cn.SaveChanges(); if (result > 0) { return(Obj.usuarioID); } else { throw new Exception("Error Al guardar El Registro"); } } catch (Exception ex) { throw new Exception(ex.Message); } }
public static List <EAtencion> mostrar(int pag) { try { List <EAtencion> Atencion = new List <EAtencion>(); using (dbodontogramaEntity cn = new dbodontogramaEntity()) { Atencion = (from p in cn.atencion join cd in cn.atencion_detalle on p.atencionID equals cd.atencionID join pc in cn.paciente on p.pacienteID equals pc.pacienteID join em in cn.users on p.empleado.usuarioID equals em.usuarioID join odon in cn.users on p.odontologo.usuarioID equals odon.usuarioID where p.estado == 1 group p by new { p.atencionID, p.pacienteID, p.empleadoID, p.odontologoID, p.fecha, p.importe, p.descripcion, p.tipo, p.hora, p.estado, p.odontologo, p.empleado, p.paciente } into item orderby item.Key.atencionID descending select new EAtencion { atencionID = item.Key.atencionID, pacienteID = item.Key.pacienteID, empleadoID = item.Key.empleadoID, odontologoID = item.Key.odontologoID, fecha = item.Key.fecha, tipo = item.Key.tipo, hora = item.Key.hora, importe = item.Key.importe, descripcion = item.Key.descripcion, Odontologo = item.Key.odontologo.nombre + " " + item.Key.odontologo.apellido, Paciente = item.Key.paciente.nombre + " " + item.Key.paciente.apellido, Empleado = item.Key.empleado.nombre + " " + item.Key.empleado.apellido, estado = item.Key.estado }).ToList(); pag = pag * 10; var tabla = Atencion.Skip(pag).Take(10); if (Atencion.Count < pag) { tabla = Atencion.Skip(pag).Take(10); } return(Atencion.ToList()); } } catch (Exception ex) { throw new Exception(ex.Message); } }
public static string mostrarNro(int nro) { string rpta = ""; try { CapaDato.dbodontogramaEntity cn = new dbodontogramaEntity(); diente Obj = new diente(); Obj = cn.diente.Find(nro); rpta = Obj.nombre; } catch (Exception ex) { throw new Exception(ex.Message); } return(rpta); }
public static long save(EPaciente Paciente) { try { CapaDato.dbodontogramaEntity cn = new dbodontogramaEntity(); List <paciente> pacientes = new List <paciente>(); paciente Obj = new paciente(); pacientes = (from p in cn.paciente where p.estado == 1 where p.nombre == Paciente.nombre && p.apellido == Paciente.apellido select p).ToList(); if (pacientes.Count > 0) { throw new Exception("El Paciente Ya Existe"); } Obj.nombre = Paciente.nombre; Obj.apellido = Paciente.apellido; Obj.telefono = Paciente.telefono; if (Obj.nombre == string.Empty && Obj.apellido == string.Empty) { throw new Exception("Ingrese Nombre y Apellido"); } Obj.ci = Paciente.ci; Obj.fechaNacimiento = Paciente.fechaNacimiento; Obj.direccion = Paciente.direccion; Obj.sexo = Paciente.sexo; Obj.estado = 1; cn.paciente.Add(Obj); int result = cn.SaveChanges(); if (result > 0) { return(Obj.pacienteID); } else { throw new Exception("Error Al guardar El Registro"); } } catch (Exception ex) { throw new Exception(ex.Message); } }
public static List <EPaciente> mostrar(string nombre, string apellido, int pag) { try { List <EPaciente> Pacientes = new List <EPaciente>(); List <paciente> pacientes = new List <paciente>(); using (dbodontogramaEntity cn = new dbodontogramaEntity()) { pacientes = (from p in cn.paciente where p.estado == 1 where p.nombre.Contains(nombre) where p.apellido.Contains(apellido) orderby p.pacienteID descending select p).ToList(); pag = pag * 10; var tabla = pacientes.Skip(pag).Take(10); if (pacientes.Count < pag) { tabla = pacientes.Skip(pag).Take(10); } foreach (var item in tabla) { EPaciente Obj = new EPaciente(); Obj.pacienteID = item.pacienteID; Obj.nombre = item.nombre; Obj.apellido = item.apellido; Obj.telefono = item.telefono; Obj.ci = item.ci; Obj.fechaNacimiento = item.fechaNacimiento; Obj.direccion = item.direccion; Obj.sexo = item.sexo; Obj.estado = item.estado; Pacientes.Add(Obj); } return(Pacientes); } } catch (Exception ex) { throw new Exception(ex.Message); } }
public static List <EUsers> mostrarOdontologo(string nombre, string apellido, int pag) { try { List <EUsers> Usuarios = new List <EUsers>(); List <users> usuarios = new List <users>(); using (dbodontogramaEntity cn = new dbodontogramaEntity()) { usuarios = (from u in cn.users where u.estado == 1 where u.tipo == "Odontologo" where u.nombre.Contains(nombre) where u.apellido.Contains(apellido) orderby u.usuarioID descending select u).ToList(); pag = pag * 10; var tabla = usuarios.Skip(pag).Take(10); if (usuarios.Count < pag) { tabla = usuarios.Skip(pag).Take(10); } foreach (var item in tabla) { EUsers Obj = new EUsers(); Obj.usuarioID = item.usuarioID; Obj.nombre = item.nombre; Obj.apellido = item.apellido; Obj.tipo = item.tipo; Obj.usuario = item.usuario; Obj.password = item.password; Obj.estado = item.estado; Usuarios.Add(Obj); } return(Usuarios); } } catch (Exception ex) { throw new Exception(ex.Message); } }
public static long update(EPaciente Paciente) { try { CapaDato.dbodontogramaEntity cn = new dbodontogramaEntity(); List <paciente> pacientes = new List <paciente>(); paciente Obj = new paciente(); pacientes = (from p in cn.paciente where p.estado == 1 where p.nombre == Paciente.nombre && p.apellido == Paciente.apellido select p).ToList(); if (pacientes.Count > 1) { throw new Exception("El Paciente Ya Existe"); } Obj = (from p in cn.paciente where p.pacienteID == Paciente.pacienteID select p).First(); Obj.nombre = Paciente.nombre; Obj.apellido = Paciente.apellido; Obj.telefono = Paciente.telefono; Obj.ci = Paciente.ci; Obj.fechaNacimiento = Paciente.fechaNacimiento; Obj.direccion = Paciente.direccion; Obj.sexo = Paciente.sexo; Obj.estado = 1; int result = cn.SaveChanges(); if (result > 0) { return(Obj.pacienteID); } else { throw new Exception("No hubo Ningun Cambio al Editar"); } } catch (Exception ex) { throw new Exception(ex.Message); } }
public static long update(ETratamiento tratamiento) { try { CapaDato.dbodontogramaEntity cn = new dbodontogramaEntity(); List <tratamiento> tratamientos = new List <tratamiento>(); tratamiento Obj = new tratamiento(); tratamientos = (from d in cn.tratamiento where d.nombre == tratamiento.nombre || d.color == tratamiento.color select d).ToList(); if (tratamientos.Count > 1) { throw new Exception("Ingrese Otro Tratamiento, O Seleccione Otro Color"); } Obj = (from d in cn.tratamiento where d.tratamientoID == tratamiento.tratamientoID select d).First(); Obj.nombre = tratamiento.nombre; Obj.color = tratamiento.color; Obj.tipo = tratamiento.tipo; Obj.precio = tratamiento.precio; Obj.estado = 1; int result = cn.SaveChanges(); if (result > 0) { return(Obj.tratamientoID); } else { throw new Exception("No Hubo Ningun Cambio al Editar"); } } catch (Exception ex) { throw new Exception(ex.Message); } }
public static long save(ETratamiento tratamiento) { try { CapaDato.dbodontogramaEntity cn = new dbodontogramaEntity(); List <tratamiento> tratamientos = new List <tratamiento>(); tratamiento Obj = new tratamiento(); tratamientos = (from d in cn.tratamiento where d.nombre == tratamiento.nombre || d.color == tratamiento.color select d).ToList(); if (tratamientos.Count > 1) { throw new Exception("Ingrese Otro Tratamiento o Seleccione Otro Color"); } Obj.nombre = tratamiento.nombre; Obj.color = tratamiento.color; if (Obj.nombre == string.Empty && Obj.color == string.Empty) { throw new Exception("Ingrese Nombre y el Color"); } Obj.tipo = tratamiento.tipo; Obj.precio = tratamiento.precio; Obj.estado = 1; cn.tratamiento.Add(Obj); int result = cn.SaveChanges(); if (result > 0) { return(Obj.tratamientoID); } else { throw new Exception("Error al guardar"); } } catch (Exception ex) { throw new Exception(ex.Message); } }
public static string mostrarNombre(int ID) { try { parte partes = new parte(); using (dbodontogramaEntity cn = new dbodontogramaEntity()) { partes = cn.parte.Find(ID); return(partes.nombre); } } catch (Exception ex) { throw new Exception(ex.Message); } }
//expresiones Landan y Delegados //user Control public static string delete(EAtencion Atencion) { string rpta = ""; try { CapaDato.dbodontogramaEntity cn = new dbodontogramaEntity(); atencion Obj = new atencion(); Obj = cn.atencion.Find(Atencion.atencionID); rpta = Obj.estado == 1 ? "OK" : "No se Puede Eliminar el Registro"; Obj.estado = 0; cn.SaveChanges(); } catch (Exception ex) { rpta = (ex.Message); } return(rpta); }
public static int mostrarTotal() { try { List <atencion> atencions = new List <atencion>(); using (dbodontogramaEntity cn = new dbodontogramaEntity()) { atencions = (from c in cn.atencion where c.estado == 1 orderby c.atencionID descending select c).ToList(); return(atencions.Count); } } catch (Exception ex) { throw new Exception(ex.Message); } }
public static int mostrarAtencionID(int ID) { try { odontograma odontogramas = new odontograma(); using (dbodontogramaEntity cn = new dbodontogramaEntity()) { odontogramas = (from o in cn.odontograma join ct in cn.atencion_detalle on o.odontogramaID equals ct.odontogramaID where o.estado == 1 && ct.atencion.atencionID == ID select o).First(); return(odontogramas.odontogramaID); } } catch (Exception ex) { throw new Exception(ex.Message); } }
public static string delete(ETratamiento tratamiento) { string rpta = ""; try { CapaDato.dbodontogramaEntity cn = new dbodontogramaEntity(); tratamiento Obj = new tratamiento(); Obj = cn.tratamiento.Find(tratamiento.tratamientoID); rpta = Obj.estado == 1 ? "OK" : "No se Puede Eliminar el Registro"; Obj.estado = 0; cn.SaveChanges(); } catch (Exception ex) { rpta = (ex.Message); } return(rpta); }
public static long update(EUsers Usuario) { try { CapaDato.dbodontogramaEntity cn = new dbodontogramaEntity(); List <users> usuarios = new List <users>(); users Obj = new users(); usuarios = (from u in cn.users where u.nombre == Usuario.nombre && u.apellido == Usuario.apellido select u).ToList(); if (usuarios.Count >= 2) { throw new Exception("El Usuario Ya Existe"); } Obj = (from u in cn.users where u.usuarioID == Usuario.usuarioID select u).First(); Obj.nombre = Usuario.nombre; Obj.apellido = Usuario.apellido; Obj.tipo = Usuario.tipo; Obj.usuario = Usuario.usuario; Obj.password = Usuario.password; Obj.estado = 1; int result = cn.SaveChanges(); if (result > 0) { return(Obj.usuarioID); } else { throw new Exception("No Hubo Ningun Cambio al Editar"); } } catch (Exception ex) { throw new Exception(ex.Message); } }
public static List <EAtencion> mostrarReporteAtencionRango(DateTime inicio, DateTime fin) { try { List <EAtencion> Atencions = new List <EAtencion>(); List <atencion> atencions = new List <atencion>(); using (dbodontogramaEntity cn = new dbodontogramaEntity()) { atencions = (from p in cn.atencion where p.estado == 1 where p.fecha >= inicio.Date && p.fecha <= fin.Date select p).ToList(); foreach (var item in atencions) { EAtencion Obj = new EAtencion(); Obj.atencionID = item.atencionID; Obj.pacienteID = item.pacienteID; Obj.empleadoID = item.empleadoID; Obj.odontologoID = item.odontologoID; Obj.fecha = item.fecha; Obj.hora = item.hora; Obj.importe = item.importe; Obj.tipo = item.tipo; Obj.descripcion = item.descripcion; Obj.Odontologo = item.odontologo.nombre + " " + item.odontologo.apellido; Obj.Paciente = item.paciente.nombre + " " + item.paciente.apellido; Obj.Empleado = item.empleado.nombre + " " + item.empleado.apellido; Obj.estado = item.estado; Atencions.Add(Obj); } return(Atencions); } } catch (Exception ex) { throw new Exception(ex.Message); } }