public void cargar(String id) { Clases.Paciente pac = new Clases.Paciente(); try { if (con.conectar()) { pac = Clases.Paciente.cargarPaciente(con.conexion, id); label3.Text = Convert.ToString(pac.idPaciente); label11.Text = pac.nombre; label12.Text = pac.apellido; label13.Text = pac.grupoSanguineo; label14.Text = pac.factorRH; label15.Text = pac.vih; label16.Text = pac.genero; label17.Text = pac.direccion; label18.Text = Convert.ToString(pac.edad); label19.Text = pac.telefono; label20.Text = pac.noafiliacion; } }catch (MySqlException ex) { } con.desconectar(); }
private void buttonguardar_Click(object sender, EventArgs e) { Clases.Paciente pac = new Clases.Paciente(Convert.ToInt32(label11.Text), textBoxafiliacion.Text, textBoxnombres.Text, textBoxapellidos.Text, textBoxdireccion.Text, comboBoxgruposanguineo.Text, comboBoxfactorrh.Text, comboBoxgenero.Text, textBoxvih.Text, Convert.ToInt32(textBoxedad.Text), textBoxtelefono.Text); try { if (con.conectar()) { Clases.Paciente.actualizarPaciente(con.conexion, pac); MessageBox.Show("Paciente actualizado exitosamente"); textBoxafiliacion.Text = ""; textBoxnombres.Text = ""; textBoxapellidos.Text = ""; textBoxdireccion.Text = ""; comboBoxgruposanguineo.Text = ""; comboBoxfactorrh.Text = ""; comboBoxgenero.Text = ""; textBoxvih.Text = ""; textBoxedad.Text = ""; textBoxtelefono.Text = ""; } } catch (MySqlException ex) { MessageBox.Show("error es probable que el número de afiliación ya esté registrado" + ex); } con.desconectar(); this.Hide(); Ver_Paciente vnt0 = new Ver_Paciente(); vnt0.Show(); }
private void button1_Click(object sender, EventArgs e) { try { validarDatos(); Clases.Paciente newPaciente = new Clases.Paciente(); newPaciente.Nombre = nombreAgregar.Text; if (!(string.IsNullOrEmpty(nroAfiliado.Text))) { newPaciente.NroAfiliado = nroAfiliado.Text; } FixamoContext context = new FixamoContext(); context.Pacientes.Add(newPaciente); context.SaveChanges(); limpiarDatos(); cargarDataGrid(); buscarCoincidencias(); } catch (Exception exc) { MessageBox.Show(exc.Message); } }
private void txt_buscar_TextChanged(object sender, EventArgs e) { var paciente = new Clases.Paciente(); if (txt_buscar.Text.Trim().Length > 0) { paciente.BuscarPacienteLike(dgv_pacientes, txt_buscar.Text.Trim()); } else { paciente.ListarPacientesDataGridView(dgv_pacientes); } }
private void button4_Click(object sender, EventArgs e) { int idPaciente = (int)dataGridView1.SelectedRows[0].Cells["PacienteId"].Value; // FixamoContext context = new FixamoContext(); Clases.Paciente pacienteSeleccionado = context.Pacientes.Find(idPaciente); pacienteSeleccionado.Habilitado = false; context.SaveChanges(); // cargarDataGrid(); buscarCoincidencias(); }
private void button1_Click(object sender, EventArgs e) { try { validarDatos(); FixamoContext context = new FixamoContext(); if (paciente == null) { Clases.Paciente newPaciente = new Clases.Paciente(); newPaciente.Nombre = nombre.Text; if (string.IsNullOrEmpty(nroAfiliado.Text)) { newPaciente.NroAfiliado = null; } else { newPaciente.NroAfiliado = nroAfiliado.Text; } context.Pacientes.Add(newPaciente); } else { Clases.Paciente newPaciente = context.Pacientes.Find(paciente.PacienteId); newPaciente.Nombre = nombre.Text; if (string.IsNullOrEmpty(nroAfiliado.Text)) { newPaciente.NroAfiliado = null; } else { newPaciente.NroAfiliado = nroAfiliado.Text; } } context.SaveChanges(); this.Close(); } catch (Exception exc) { MessageBox.Show(exc.Message); } }
private void btn_actualizar_Click(object sender, EventArgs e) { if (txt_apellidos.Text.Trim().Equals("")) { txt_apellidos.Focus(); MessageBox.Show("Completar Apellidos", "Mensaje", MessageBoxButtons.OK, MessageBoxIcon.Warning); } else if (txt_nombre.Text.Trim().Equals("")) { txt_nombre.Focus(); MessageBox.Show("Completar Nombre", "Mensaje", MessageBoxButtons.OK, MessageBoxIcon.Warning); } else if (txt_dni.Text.Trim().Equals("")) { txt_dni.Focus(); MessageBox.Show("Completar Dni", "Mensaje", MessageBoxButtons.OK, MessageBoxIcon.Warning); } else if (txt_dni.Text.Trim().Length != 8) { txt_dni.Focus(); MessageBox.Show("Completar Dni de 8 digitos", "Mensaje", MessageBoxButtons.OK, MessageBoxIcon.Warning); } else if (txt_direccion.Text.Trim().Equals("")) { txt_direccion.Focus(); MessageBox.Show("Completar la direccion", "Mensaje", MessageBoxButtons.OK, MessageBoxIcon.Warning); } else if (dtp_fechaNacimiento.Value.Equals("")) { dtp_fechaNacimiento.Focus(); MessageBox.Show("Completar la fecha de nacimiento", "Mensaje", MessageBoxButtons.OK, MessageBoxIcon.Warning); } else if (txt_observaciones.Text.Trim().Equals("")) { txt_observaciones.Focus(); MessageBox.Show("Completar la observacion", "Mensaje", MessageBoxButtons.OK, MessageBoxIcon.Warning); } else if (dgv_telefonos.Rows.Count == 0) { MessageBox.Show("Ingresar al menos un telefono", "Mensaje", MessageBoxButtons.OK, MessageBoxIcon.Warning); } else { var paciente = new Clases.Paciente( txt_apellidos.Text.Trim().ToUpper(), txt_nombre.Text.Trim().ToUpper(), txt_dni.Text.Trim(), cbo_genero.Text, cbo_estadoCivil.Text, txt_direccion.Text.Trim(), cbo_distrito.SelectedValue.ToString(), dtp_fechaNacimiento.Value, txt_observaciones.Text.Trim().ToUpper(), pacienteId_TEMP ); bool resultado_emp = paciente.Actualizar(); if (resultado_emp) { int numero_filas = dgv_telefonos.Rows.Count; for (int i = 0; i < numero_filas; i++) { int id = int.Parse(dgv_telefonos.Rows[i].Cells[3].Value.ToString()); if (id == 0) { string operador = dgv_telefonos.Rows[i].Cells[0].Value.ToString(); string numero = dgv_telefonos.Rows[i].Cells[1].Value.ToString(); var telefono = new Clases.Telefono(operador, numero, pacienteId_TEMP); var resultado = telefono.Registrar(); if (!resultado) { MessageBox.Show("Error al registrar telefono", "Mensaje", MessageBoxButtons.OK, MessageBoxIcon.Error); } } } historiaClinica_TEMP = int.Parse(txt_numeroHC.Text); //ACTUALIZA HC var historia_clinica = new Clases.HistoriaClinica( txt_AntecedentePersonal.Text.Trim().ToUpper(), pacienteId_TEMP, historiaClinica_TEMP //ERROR ); bool resultado_usu = historia_clinica.Actualizar(); MessageBox.Show("Paciente actualizado correctamente", "Mensaje", MessageBoxButtons.OK, MessageBoxIcon.Information); paciente.ListarPacientesDataGridView(Vistas.Formularios.Pacientes.FormListarPacientes.MyForm.dgv_pacientes); limpiar(); } else { MessageBox.Show("Error al actualizar", "Mensaje", MessageBoxButtons.OK, MessageBoxIcon.Error); } } }
public AMPaciente(Clases.Paciente pacienteP) { InitializeComponent(); paciente = pacienteP; }
private void dgv_pacientes_CellMouseDoubleClick(object sender, DataGridViewCellMouseEventArgs e) { if (e.RowIndex != -1) { if (dgv_pacientes.Rows[e.RowIndex].Cells[e.ColumnIndex].Value.ToString().Equals("Editar")) { var f = new FormActualizarPacientes(); f.Show(); var paciente = new Clases.Paciente(); int paciente_id = int.Parse(dgv_pacientes.Rows[e.RowIndex].Cells[6].Value.ToString()); var tabla_paciente = paciente.BuscarPorCodigo(paciente_id); if (tabla_paciente.Rows.Count == 1) { FormActualizarPacientes.MyForm.txt_apellidos.Text = tabla_paciente.Rows[0]["APELLIDOS"].ToString(); FormActualizarPacientes.MyForm.txt_nombre.Text = tabla_paciente.Rows[0]["NOMBRE"].ToString(); FormActualizarPacientes.MyForm.txt_dni.Text = tabla_paciente.Rows[0]["DNI"].ToString(); FormActualizarPacientes.MyForm.cbo_genero.Text = tabla_paciente.Rows[0]["GENERO"].ToString(); FormActualizarPacientes.MyForm.cbo_estadoCivil.Text = tabla_paciente.Rows[0]["ESTADO_CIVIL"].ToString(); FormActualizarPacientes.MyForm.txt_direccion.Text = tabla_paciente.Rows[0]["DIRECCION"].ToString(); FormActualizarPacientes.MyForm.dtp_fechaNacimiento.Text = tabla_paciente.Rows[0]["FECHA_NACIMIENTO"].ToString(); FormActualizarPacientes.MyForm.txt_observaciones.Text = tabla_paciente.Rows[0]["OBSERVACIONES"].ToString(); FormActualizarPacientes.MyForm.cbo_departamento.SelectedValue = tabla_paciente.Rows[0]["DEPARTAMENTO_ID"].ToString(); FormActualizarPacientes.MyForm.cbo_provincia.SelectedValue = tabla_paciente.Rows[0]["PROVINCIA_ID"].ToString(); FormActualizarPacientes.MyForm.cbo_distrito.SelectedValue = tabla_paciente.Rows[0]["DISTRITO_ID"].ToString(); var telefono = new Clases.Telefono(); var tabla_telefonos = telefono.BuscarPorCodigo(paciente_id); var numero_filas = tabla_telefonos.Rows.Count; if (numero_filas > 0) { for (int i = 0; i < numero_filas; i++) { int telefono_id = int.Parse(tabla_telefonos.Rows[i][0].ToString()); string operador = tabla_telefonos.Rows[i][1].ToString(); string numero = tabla_telefonos.Rows[i][2].ToString(); FormActualizarPacientes.MyForm.dgv_telefonos.Rows.Add( operador, numero, "Eliminar", paciente_id, telefono_id ); //listar el número de LA HISTORIA CLINICA var historia_clinica = new Clases.HistoriaClinica(); var tabla_historia_clinica = historia_clinica.BuscarPorCodigo(paciente_id); FormActualizarPacientes.MyForm.txt_numeroHC.Text = tabla_historia_clinica.Rows[0]["NUMERO_HISTORIA"].ToString(); FormActualizarPacientes.MyForm.txt_AntecedentePersonal.Text = tabla_historia_clinica.Rows[0]["ANTECEDENTE_PERSONAL"].ToString(); } } FormActualizarPacientes.MyForm.pacienteId_TEMP = paciente_id; } } if (dgv_pacientes.Rows[e.RowIndex].Cells[e.ColumnIndex].Value.ToString().Equals("Eliminar")) { int paciente_id = int.Parse(dgv_pacientes.Rows[e.RowIndex].Cells[6].Value.ToString()); DialogResult res = MessageBox.Show("Deseas eliminar este Paciente?", "Mensaje", MessageBoxButtons.YesNo, MessageBoxIcon.Warning); if (res == DialogResult.Yes) { var paciente = new Clases.Paciente(paciente_id); if (paciente.Eliminar()) { // ELIMINAR DE DATAGRIDVIEW Y DE LA BASE DE DATOS dgv_pacientes.Rows.RemoveAt(e.RowIndex); } else { MessageBox.Show("Error al eliminar", "Mensaje", MessageBoxButtons.OK, MessageBoxIcon.Error); } } } } }
private void FormListarPacientes_Load(object sender, EventArgs e) { var paciente = new Clases.Paciente(); paciente.ListarPacientesDataGridView(dgv_pacientes); }
private void btn_registrar_Click(object sender, EventArgs e) { if (txt_apellidos.Text.Trim().Equals("")) { txt_apellidos.Focus(); MessageBox.Show("Completar Apellidos", "Mensaje", MessageBoxButtons.OK, MessageBoxIcon.Warning); } else if (txt_nombre.Text.Trim().Equals("")) { txt_nombre.Focus(); MessageBox.Show("Completar Nombre", "Mensaje", MessageBoxButtons.OK, MessageBoxIcon.Warning); } else if (txt_dni.Text.Trim().Equals("")) { txt_dni.Focus(); MessageBox.Show("Completar Dni", "Mensaje", MessageBoxButtons.OK, MessageBoxIcon.Warning); } else if (txt_dni.Text.Trim().Length != 8) { txt_dni.Focus(); MessageBox.Show("Completar Dni de 8 digitos", "Mensaje", MessageBoxButtons.OK, MessageBoxIcon.Warning); } else if (txt_direccion.Text.Trim().Equals("")) { txt_direccion.Focus(); MessageBox.Show("Completar la direccion", "Mensaje", MessageBoxButtons.OK, MessageBoxIcon.Warning); } else if (dtp_fechaNacimiento.Value.Equals("")) { dtp_fechaNacimiento.Focus(); MessageBox.Show("Completar la fecha de nacimiento", "Mensaje", MessageBoxButtons.OK, MessageBoxIcon.Warning); } else if (txt_observaciones.Text.Trim().Equals("")) { txt_observaciones.Focus(); MessageBox.Show("Completar la observacion", "Mensaje", MessageBoxButtons.OK, MessageBoxIcon.Warning); } else if (dgv_telefonos.Rows.Count == 0) { MessageBox.Show("Ingresar al menos un telefono", "Mensaje", MessageBoxButtons.OK, MessageBoxIcon.Warning); } else { var paciente = new Clases.Paciente( txt_apellidos.Text.Trim().ToUpper(), txt_nombre.Text.Trim().ToUpper(), txt_dni.Text.Trim(), cbo_genero.Text, cbo_estadoCivil.Text, txt_direccion.Text.Trim(), cbo_distrito.SelectedValue.ToString(), dtp_fechaNacimiento.Value, txt_observaciones.Text.Trim().ToUpper() ); int ultimo_id = paciente.Registrar(); if (ultimo_id > 0) { int numero_filas = dgv_telefonos.Rows.Count; for (int i = 0; i < numero_filas; i++) { string operador = dgv_telefonos.Rows[i].Cells[0].Value.ToString(); string numero = dgv_telefonos.Rows[i].Cells[1].Value.ToString(); int paciente_id = ultimo_id; var telefono = new Clases.Telefono(operador, numero, paciente_id); var resultado = telefono.Registrar(); if (!resultado) { MessageBox.Show("Error al registrar telefono", "Mensaje", MessageBoxButtons.OK, MessageBoxIcon.Error); } } //REGISTRA LA HISTORIA CLINICA var historia_clinica = new Clases.HistoriaClinica( txt_AntecedentePersonal.Text.Trim(), ultimo_id ); bool resultado_HC = historia_clinica.Registrar(); if (!resultado_HC) { MessageBox.Show("Error al registrar la Historia Clinica del Paciente", "Mensaje", MessageBoxButtons.OK, MessageBoxIcon.Error); } MessageBox.Show("Paciente registrado correctamente", "Mensaje", MessageBoxButtons.OK, MessageBoxIcon.Information); paciente.ListarPacientesDataGridView(Vistas.Formularios.Pacientes.FormListarPacientes.MyForm.dgv_pacientes); limpiar(); } else { MessageBox.Show("Error al registrar paciente", "Mensaje", MessageBoxButtons.OK, MessageBoxIcon.Error); } } }