Пример #1
0
        private void btnActualizar_Click(object sender, EventArgs e)
        {
            string   nombre       = tbNombre.Text.Trim();
            string   apellido     = tbApellido.Text.Trim();
            int      dni          = Convert.ToInt32(tbDNI.Text);
            int      cargo        = cbCargo.SelectedIndex;
            string   calle        = tbCalle.Text;
            string   altura       = tbAltura.Text;
            string   telefono     = tbTelefono.Text.Trim();
            DateTime fechaIngreso = dtpIngreso.Value;
            int      id           = Convert.ToInt32(tbID.Text);

            Persona persona = new Persona(id, nombre, apellido, dni, cargo, calle, altura, telefono, fechaIngreso);

            if (persona.Error)
            {
                foreach (string msj in persona.Mensajes)
                {
                    Funciones.mError(this, msj);
                }
            }
            else
            {
                persona.Actualizar();
                MessageBox.Show(this, "Registro actualizado correctamente");
                tbNombre.Text         = "";
                tbApellido.Text       = "";
                tbDNI.Text            = "";
                cbCargo.SelectedIndex = 0;
                tbApellido.Text       = "";
                tbCalle.Text          = "";
                tbAltura.Text         = "";
                tbTelefono.Text       = "";
                tbUsuario.Text        = "";
                tbPass.Text           = "";
                tbRePass.Text         = "";
            }
            dgUsuario.DataSource = Persona.getAll();
        }