private void btnEliminar_Click(object sender, RoutedEventArgs e) { if (listD.SelectedIndex != -1) { TDiagnostico d = this.diagnosticos.ElementAt(listD.SelectedIndex); MessageBoxResult r = MessageBox.Show("¿Está seguro de que desea eliminar el diagnóstico '" + d.Nombre + "'", "", MessageBoxButton.YesNo, MessageBoxImage.Exclamation); if (r == MessageBoxResult.Yes) { try { ClienteWCF.getServicios().eliminarDiagnostico(d.Id); diagnosticos.Remove(d); listD.Items.Remove(listD.SelectedItem); txtDescripcion.Text = ""; txtNombre.Text = ""; lblMensaje.Content = "Diagnóstico'" + d.Nombre + "' eliminado."; } catch (FaultException <ErrorSql> ex) { MessageBox.Show(ex.Detail.Content); } catch (EndpointNotFoundException ex) { MessageBox.Show("No es posible conectar con el servidor. Comprueba la configuración de red o contacta con tu administrador."); } } } }
private void listViewPac_SelectionChanged(object sender, SelectionChangedEventArgs e) { lblAvisos2.Content = ""; _HistCollection.Clear(); if (listViewPac.SelectedIndex != -1) { TPaciente p = listPacientes.ElementAt(listViewPac.SelectedIndex); if (p.Tfno1 != null) { lblTfno2.Content = Convert.ToString(p.Tfno1); } if (p.Tfno2 != null) { lblMovil2.Content = Convert.ToString(p.Tfno2); } lblEmail2.Content = p.Email; lblfe2.Content = p.F_nac.Value.ToShortDateString(); txtObsPaciente.Text = p.Observs; lblHistTit.Content = "Historial de " + p.Nombre + " " + p.Apellidos; try { listHistoriales = ClienteWCF.getServicios().recuperarHistoriales(p.Dni); if (listHistoriales == null) { listHistoriales = new List <THistorial>(); lblAvisos2.Content = "No hay historiales para " + p.Nombre + " " + p.Apellidos + "."; } else { foreach (THistorial h in listHistoriales) { String fecha = ""; if (h.F_fin != null) { fecha = h.F_fin.Value.ToShortDateString(); } TDiagnostico d = this.getDiagnostico(h.Id_diagnostico); String nomDiagnos = "*Eliminado*"; if (d != null) { nomDiagnos = d.Nombre; } _HistCollection.Add(new HistData { Diagnostico = nomDiagnos, FInicio = h.F_inicio.ToShortDateString(), Estado = h.Estado, Zona = h.Zona, FFin = fecha }); } } } catch (FaultException <ErrorSql> ex) { MessageBox.Show(ex.Detail.Content); } catch (EndpointNotFoundException ex) { MessageBox.Show("No es posible conectar con el servidor. Comprueba la configuración de red o contacta con tu administrador."); } } }
private void listD_SelectionChanged(object sender, SelectionChangedEventArgs e) { if (listD.SelectedIndex != -1) { TDiagnostico d = diagnosticos.ElementAt(listD.SelectedIndex); txtNombre.Text = d.Nombre; txtDescripcion.Text = d.Descripcion; } }
private TDiagnostico getDiagnostico(int id) { TDiagnostico dR = null; foreach (TDiagnostico d in listDiagnosticos) { if (d.Id == id) { return(d); } } return(dR); }
private void btnAgregar_Click(object sender, RoutedEventArgs e) { if (txtNombre.Text == "") { lblMensaje.Content = "El campo nombre es obligaritorio, rellénelo."; } else { try { TDiagnostico diag = new TDiagnostico(); lblMensaje.Content = ""; diag.Nombre = txtNombre.Text; diag.Descripcion = txtDescripcion.Text; ClienteWCF.getServicios().nuevoDiagnostico(diag); lblMensaje.Content = "Diagnóstico'" + diag.Nombre + "' agregado."; if (this.Owner is VNuevoHist) { ((VNuevoHist)this.Owner).actualizar(); this.Close(); } listD.Items.Clear(); this.cargar(); if (listD.Items.Count > 0) { listD.SelectedIndex = 0; } } catch (FaultException <Error> ex) { lblMensaje.Content = ex.Detail.Content; } catch (FaultException <ErrorSql> ex) { MessageBox.Show(ex.Detail.Content); } catch (EndpointNotFoundException ex) { MessageBox.Show("No es posible conectar con el servidor. Comprueba la configuración de red o contacta con tu administrador."); } } }
private void listViewHist_SelectionChanged(object sender, SelectionChangedEventArgs e) { if (listViewHist.SelectedIndex != -1) { THistorial h = listHistoriales.ElementAt(listViewHist.SelectedIndex); TDiagnostico d = this.getDiagnostico(h.Id_diagnostico); String nomD = "*Eliminado*"; if (d != null) { nomD = d.Nombre; } VHistorial v = new VHistorial(h, this.getPaciente(h.Dni_paciente), nomD); v.Owner = this; v.Show(); this.Visibility = Visibility.Hidden; } }
public void nuevoDiagnostico(TDiagnostico d) { try { FisioDBDataContext dc = new FisioDBDataContext(); var diagnosticos = (from diag in dc.TDiagnostico where diag.Nombre == d.Nombre select diag); if (diagnosticos.Count() > 0) { throw new ErrorDatosExistentesException("El diagnóstico ya existe"); } dc.TDiagnostico.InsertOnSubmit(d); dc.SubmitChanges(); } catch (SqlException ex) { throw ex; } }
public void actualizarHistoriales(THistorial h) { listHistoriales.Add(h); String fecha = ""; if (h.F_fin != null) { fecha = h.F_fin.Value.ToShortDateString(); } TDiagnostico d = this.getDiagnostico(h.Id_diagnostico); String nomDiagnos = "*Eliminado*"; if (d != null) { nomDiagnos = d.Nombre; } _HistCollection.Add(new HistData { Diagnostico = nomDiagnos, Zona = h.Zona, Estado = h.Estado, FInicio = h.F_inicio.ToShortDateString(), FFin = fecha }); }
public void nuevoDiagnostico(TDiagnostico d) { IAccesoDatos dao = AccesoDatos.CreateDao(); try { dao.nuevoDiagnostico(d); } catch (SqlException ex) { ErrorSql e = new ErrorSql(); e.Content = ex.Message; throw new FaultException <ErrorSql>(e); } catch (ErrorDatosExistentesException ex) { Error e = new Error(); e.Content = ex.Message; throw new FaultException <Error>(e); } }