Beispiel #1
0
 public Afiliado(DAOAfiliado afiliado)
 {
     this.afiliado = afiliado;
     InitializeComponent();
     txtNombre.Text = afiliado.nombre;
     txtNombre.Enabled = false;
     txtApellido.Text = afiliado.apellido;
     txtApellido.Enabled = false;
     DAODocumento.llenarCombo(cmbTipoDocumento);
     cmbTipoDocumento.Text = DAODocumento.nombre(afiliado.tipoDocumento);
     cmbTipoDocumento.Enabled = false;
     txtNroDocumento.Text = afiliado.documento.ToString();
     txtNroDocumento.Enabled = false;
     txtPlan.Items.Clear();
     DataTable planes = DAOPlan.getPlanes();
     foreach (DataRow row in planes.Rows)
     {
         txtPlan.Items.Add(row["PLAN_CODIGO"]);
     }
     txtPlan.Text = afiliado.plan.ToString();
     txtEmail.Text = afiliado.email;
     txtDireccion.Text = afiliado.direccion;
     txtTelefono.Text = afiliado.telefono.ToString();
     dtpFechaNacimiento.Value = afiliado.fechaNacimiento;
     dtpFechaNacimiento.Enabled = false;
     txtEstadoCivil.Text = afiliado.estadoCivil;
     txtCantFamiliares.Text = afiliado.cantFamiliares.ToString();
     txtCantFamiliares.Enabled = false;
     rdbF.Checked = true;
     if (afiliado.sexo == 'X')
     {
         MessageBox.Show("El afiliado actual es migrado, debe completar el estado civil y el sexo.");
         afiliado.sexo = 'F';
         rdbF.Checked = true;
         txtEstadoCivil.Text = txtEstadoCivil.Items[0].ToString();
     }
     else
     {
         rdbF.Checked = afiliado.sexo == 'F';
         rdbM.Checked = afiliado.sexo == 'M';
     }
 }
 private void btnModificar_Click(object sender, EventArgs e)
 {
     if (dtgAfiliados.SelectedRows.GetEnumerator().MoveNext())
     {
         DataGridViewRow selectedRow = dtgAfiliados.SelectedRows[0];
         DAOAfiliado afiliado = new DAOAfiliado(
             (int)selectedRow.Cells["Numero"].Value,
             (int)selectedRow.Cells["Plan"].Value,
             (bool)selectedRow.Cells["A"].Value,
             (string)selectedRow.Cells["Nombre"].Value,
             (string)selectedRow.Cells["Apellido"].Value,
             DAODocumento.codigo(selectedRow.Cells["Tipo Doc"].Value.ToString()),
             (int)selectedRow.Cells["Nro Doc"].Value,
             (string)selectedRow.Cells["Direccion"].Value,
             (string)selectedRow.Cells["Email"].Value,
             (DateTime)selectedRow.Cells["Fecha Nacimiento"].Value,
             (Decimal)selectedRow.Cells["Telefono"].Value,
             selectedRow.Cells["Estado Civil"].Value.ToString(),
             (int)selectedRow.Cells["Cant Familiares"].Value,
             (char)selectedRow.Cells["Sexo"].Value.ToString().ToCharArray()[0]);
         new Abm_de_Afiliado.Afiliado(afiliado).ShowDialog(this);
     }
     else
         MessageBox.Show("Seleccione un afiliado");
 }