private void btnAlta_Click(object sender, EventArgs e) { if (confirmaAlta()) { clsHistorial h = new clsHistorial(pacientes[dgvAlta.CurrentRow.Index].Id, rtbDiagAlta.Text, rtbObserAlta.Text, dtpFechaAlta.Value); try { rh.Alta(h); } catch (Exception ex) { MessageBox.Show("Se ha pruducido el Sgte. error: " + ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } finally { pagina = 0; iniciar(); } } }
public IEntidad buscaPorId(int id) { DataTable aux = new DataTable(); clsHistorial hist = new clsHistorial(); try { aux = manager.consultar("select * from historial where idpaciente=" + id + " and activo=1"); if(aux.Rows.Count!=0) { hist.Id = Convert.ToInt32(aux.Rows[0]["idpaciente"]); hist.Diagnostico = aux.Rows[0]["diagnostico"].ToString(); hist.Observaciones = aux.Rows[0]["observaciones"].ToString(); hist.Fecha = Convert.ToDateTime(aux.Rows[0]["fecha"]); } } catch (Exception ex) { throw ex; } return hist; }
public List<clsHistorial> Todo(int pag) { DataTable tabla; List<clsHistorial> lista = new List<clsHistorial>(); try { tabla = manejahistorial.Todo(pag); foreach (DataRow aux in tabla.Rows) { clsHistorial hist = new clsHistorial(); hist.Id = Convert.ToInt32(aux["id"]); hist.Diagnostico = aux["diagnostico"].ToString(); hist.Observaciones = aux["observaciones"].ToString(); hist.Fecha = Convert.ToDateTime(aux["fecha"]); lista.Add(hist); } } catch (SqlException ex) { throw ex; } catch (Exception ex) { throw ex; } return lista; }