private void TbPacientes_CellClick(object sender, DataGridViewCellEventArgs e) { id = Convert.ToInt32(tbPacientes.Rows[e.RowIndex].Cells["id"].Value.ToString()); var cedula = tbPacientes.Rows[e.RowIndex].Cells["cedula"].Value.ToString(); var apellido1 = tbPacientes.Rows[e.RowIndex].Cells["apellido1"].Value.ToString(); var apellido2 = tbPacientes.Rows[e.RowIndex].Cells["apellido2"].Value.ToString(); var nombre1 = tbPacientes.Rows[e.RowIndex].Cells["nombre1"].Value.ToString(); var nombre2 = tbPacientes.Rows[e.RowIndex].Cells["nombre2"].Value.ToString(); DateTime fechaNacimiento = Convert.ToDateTime(tbPacientes.Rows[e.RowIndex].Cells["fechaNacimiento"].Value.ToString()); var genero = tbPacientes.Rows[e.RowIndex].Cells["genero"].Value.ToString(); DateTime fechaIngreso = Convert.ToDateTime(tbPacientes.Rows[e.RowIndex].Cells["fechaIngreso"].Value.ToString()); var telefono = tbPacientes.Rows[e.RowIndex].Cells["telefono"].Value.ToString(); var direccion = tbPacientes.Rows[e.RowIndex].Cells["direccion"].Value.ToString(); Paciente datosPaciente = new Paciente(id, cedula, apellido1, apellido2, nombre1, nombre2, fechaNacimiento, genero, fechaIngreso, telefono, direccion); pacienteSeleccionado = datosPaciente; if (pacienteSeleccionado != null) { pacientesDatos.txtIdAuxiliar.Text = Convert.ToInt32(pacienteSeleccionado.id).ToString(); pacientesDatos.txtCedula.Text = pacienteSeleccionado.cedula; pacientesDatos.txtApellido1.Text = pacienteSeleccionado.apellido1; pacientesDatos.txtApellido2.Text = pacienteSeleccionado.apellido2; pacientesDatos.txtNombre1.Text = pacienteSeleccionado.nombre1; pacientesDatos.txtNombre2.Text = pacienteSeleccionado.nombre2; string fechaNac = Convert.ToDateTime(pacienteSeleccionado.fechaNacimiento).ToString("yyyy/MM/dd"); pacientesDatos.txtFechaNac.Text = fechaNac.Replace('/', '-'); pacientesDatos.cbGenero.Text = pacienteSeleccionado.genero; string fechaIng = Convert.ToDateTime(pacienteSeleccionado.fechaIngreso).ToString("yyyy/MM/dd"); pacientesDatos.txtFechaIngresPac.Text = fechaIng.Replace('/', '-'); pacientesDatos.txtTelefono.Text = pacienteSeleccionado.telefono; pacientesDatos.txtDireccion.Text = pacienteSeleccionado.direccion; //Obtiene el id del Paciente para asignarle un representante representanteDatos.txtIdAuxiliar.Text = Convert.ToInt32(pacienteSeleccionado.id).ToString(); Representante representante = new Representante(); RepresentanteNegocio.DevolverListadoRepresentantesNegocio(Convert.ToInt32(pacienteSeleccionado.id), representanteDatos.txtIdAuxiliar, representanteDatos.txtCedula, representanteDatos.txtApellido, representanteDatos.txtNombre, representanteDatos.txtTelefono, representanteDatos.txtDireccion, representanteDatos.cbParentesco, representanteDatos.txtEmail); } }
private void BtnGuardar_Click(object sender, EventArgs e) { Representante representante = new Representante(); if (txtIdAuxiliar.Text == "") { representante.id = 0; } else { representante.id = Convert.ToInt32(txtIdAuxiliar.Text); } representante.cedula = txtCedula.Text; representante.apellido = txtApellido.Text; representante.nombre = txtNombre.Text; representante.telefono = txtTelefono.Text; representante.direccion = txtDireccion.Text; representante.parentezco = cbParentesco.Text; representante.email = txtEmail.Text; representante = RepresentanteNegocio.GuardarRepresentanteNegocio(representante, Convert.ToInt32(txtIdAuxiliar.Text)); }