public List <TComentario> getComentarios() { try { FisioDBDataContext dc = new FisioDBDataContext(); var comentarios = from comentario in dc.TComentario orderby comentario.Fecha descending select comentario; if (comentarios.Count() > 0) { return(comentarios.ToList()); } return(null); } catch (SqlException ex) { throw (ex); } }
public List <TTratamiento> recuperarTratamientos(int idHist) { try { FisioDBDataContext dc = new FisioDBDataContext(); var tratamientos = from tratamiento in dc.TTratamiento where tratamiento.Id_historial == idHist orderby tratamiento.F_inicio ascending select tratamiento; if (tratamientos.Count() > 0) { return(tratamientos.ToList()); } return(null); } catch (SqlException ex) { throw (ex); } }
/***********************CITAS*************************/ public List <TSesionCita> getCitas(DateTime date) { List <TSesionCita> listCitas = null; try { FisioDBDataContext dc = new FisioDBDataContext(); var citas = from cita in dc.TSesionCita where cita.Fecha.Day == date.Day && cita.Fecha.Month == date.Month && cita.Fecha.Year == date.Year select cita; if (citas.Count() > 0) { listCitas = citas.ToList(); } return(listCitas); } catch (SqlException ex) { throw (ex); } }
public void registrarPedido(TPedido pedido) { try { FisioDBDataContext dc = new FisioDBDataContext(); foreach (TLineaPedidos l in pedido.TLineaPedidos) { var materiales = from material in dc.TMaterial where material.Id_material == l.Id_material select material; l.TMaterial = materiales.First(); } dc.TPedido.InsertOnSubmit(pedido); dc.SubmitChanges(); } catch (SqlException ex) { throw ex; } }
/*METODOS TSALA*/ public void nuevaSala(TSala s) { try { FisioDBDataContext dc = new FisioDBDataContext(); int existe = (from sala in dc.TSala where sala.Nombre == s.Nombre select sala).Count(); if (existe != 0) { throw new ErrorDatosExistentesException("El nombre de la sala ya existe"); } dc.TSala.InsertOnSubmit(s); dc.SubmitChanges(); } catch (SqlException ex) { throw (ex); } catch (ErrorDatosExistentesException ex) { throw (ex); } }
public List <TPedido> getPedidosMes(DateTime d) { try { FisioDBDataContext dc = new FisioDBDataContext(); DataLoadOptions options = new DataLoadOptions(); options.LoadWith <TPedido>(p => p.TLineaPedidos); dc.LoadOptions = options; var pedidos = from pedido in dc.TPedido where pedido.Fecha.Year == d.Year && pedido.Fecha.Month == d.Month orderby pedido.Fecha select pedido; if (pedidos.Count() > 0) { return(pedidos.ToList()); } return(null); } catch (SqlException ex) { throw (ex); } }
public String getNomDiag(int id) { try { FisioDBDataContext dc = new FisioDBDataContext(); var hists = from hist in dc.THistorial where hist.Id == id select hist; if (hists.Count() > 0) { var diags = from diag in dc.TDiagnostico where diag.Id == hists.First().Id_diagnostico select diag; if (diags.Count() > 0) { return(diags.First().Nombre); } } return("***"); } catch (SqlException ex) { throw (ex); } }
public List <TPedido> getPedidos() { List <TPedido> pedidosR = null; try { FisioDBDataContext dc = new FisioDBDataContext(); DataLoadOptions options = new DataLoadOptions(); options.LoadWith <TPedido>(p => p.TLineaPedidos); dc.LoadOptions = options; var pedidos = from pedido in dc.TPedido orderby pedido.Fecha descending select pedido; if (pedidos.Count() > 0) { pedidosR = pedidos.ToList(); } return(pedidosR); } catch (SqlException ex) { throw ex; } }
/********************MATERIALES*****************/ public List <TMaterial> getMateriales() { List <TMaterial> listMat = null; try { FisioDBDataContext dc = new FisioDBDataContext(); var materiales = from material in dc.TMaterial orderby material.Nombre select material; if (materiales.Count() > 0) { listMat = new List <TMaterial>();; foreach (TMaterial mat in materiales) { listMat.Add(mat); } } return(listMat); } catch (SqlException ex) { throw ex; } }
public void registrarTratamiento(TTratamiento t, String dni, DateTime fecha) { try { FisioDBDataContext dc = new FisioDBDataContext(); var sesiones = from sesion in dc.TSesionCita where sesion.Dni_paciente == dni && sesion.Fecha.Day == fecha.Day && sesion.Fecha.Month == fecha.Month && sesion.Fecha.Year == fecha.Year select sesion; if (sesiones.Count() == 0) { throw new ErrorDatosExistentesException("No se ha realizado la operación. No se registró una sesión previamente.¿Quieres hacerlo ahora?"); } var tratamientos = from tratamiento in dc.TTratamiento where tratamiento.Id_historial == t.Id_historial && tratamiento.Id_terapia == t.Id_terapia select tratamiento; if (tratamientos.Count() > 0) { throw new ErrorDatosExistentesException("Ya se ha aplicado esta terapia a este diagnóstico."); } TSesionCita s = sesiones.First(); if (s.Id_terapia == 0 || s.Id_terapia == null) { s.Id_terapia = t.Id_terapia; } if (s.Id_historial == 0 || s.Id_historial == null) { s.Id_historial = t.Id_historial; } var historiales = from historial in dc.THistorial where historial.Id == t.Id_historial select historial; if (historiales.Count() > 0) { THistorial h = historiales.First(); if (t.F_inicio.Year < h.F_inicio.Year) { h.F_inicio = t.F_inicio; } else if (t.F_inicio.Year == h.F_inicio.Year) { if (t.F_inicio.Month < h.F_inicio.Month) { h.F_inicio = t.F_inicio; } else if (t.F_inicio.Month == h.F_inicio.Month) { if (t.F_inicio.Day < h.F_inicio.Day) { h.F_inicio = t.F_inicio; } } } } dc.TTratamiento.InsertOnSubmit(t); dc.SubmitChanges(); } catch (SqlException ex) { throw (ex); } catch (ErrorDatosExistentesException ex) { throw ex; } }