コード例 #1
0
        private void btnEliminar_Click(object sender, EventArgs e)
        {
            clsPersonas persona = new clsPersonas();

            if (dgvLista.Rows.GetRowCount(DataGridViewElementStates.Selected) < 1)
            {
                MessageBox.Show("Selceccione una fila");
                return;
            }
            persona = (clsPersonas)dgvLista.CurrentRow.DataBoundItem;
            listadoPersonas.Remove(persona);
            listaBindeable.ResetBindings();
        }
コード例 #2
0
        private void btnModificar_Click(object sender, EventArgs e)
        {
            if (dgvLista.Rows.GetRowCount(DataGridViewElementStates.Selected) < 1)
            {
                MessageBox.Show("Selceccione una fila");
                return;
            }
            clsPersonas persona = new clsPersonas();

            persona = (clsPersonas)dgvLista.CurrentRow.DataBoundItem;
            int         i = listadoPersonas.IndexOf(persona);
            clsPersonas personaModificada = new clsPersonas(txtNombre.Text.ToString().Trim(), txtApellido.Text.ToString().Trim(), dtpFechaNac.Value.Date,
                                                            SexoSeleccionado().Trim(), musicaSeleccionado().Trim(), cbxColor.SelectedItem.ToString());

            listadoPersonas[i] = personaModificada;
            listaBindeable.ResetBindings();
            inizilizacion();
        }
コード例 #3
0
 private void btnGuardar_Click(object sender, EventArgs e)
 {
     try
     {
         if (!complobacion())
         {
             MessageBox.Show("rellene todos los datos");
             return;
         }
         clsPersonas persona = new clsPersonas(txtNombre.Text.ToString().Trim(), txtApellido.Text.ToString().Trim(), dtpFechaNac.Value.Date,
                                               SexoSeleccionado().Trim(), musicaSeleccionado().Trim(), cbxColor.SelectedItem.ToString());
         listadoPersonas.Add(persona);
         listaBindeable.ResetBindings();
         inizilizacion();
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.ToString());
     }
 }
コード例 #4
0
        //rellena el formulario con las fila seleccionada del datagried
        private void rellenarFormulario()
        {
            Object objetoSeleccionado;

            objetoSeleccionado = dgvLista.CurrentRow.DataBoundItem;
            clsPersonas personaSeleccionada = (clsPersonas)objetoSeleccionado;

            txtApellido.Text      = personaSeleccionada.Apellido;
            txtNombre.Text        = personaSeleccionada.Nombre;
            dtpFechaNac.Value     = personaSeleccionada.FechaNac;
            cbxColor.SelectedItem = personaSeleccionada.ColorFavorito;
            foreach (RadioButton item in gbxSexo.Controls)
            {
                if (item.Text.ToString() == personaSeleccionada.Sexo)
                {
                    item.Checked = true;
                }
            }
            cargarMusica(personaSeleccionada.EstiloMusical);
        }