Beispiel #1
0
        private void btnModificar_Click(object sender, RoutedEventArgs e)
        {
            List <Competencia> competencias = col.ReadAllCompetencias();

            try
            {
                Habilidad hab = new Habilidad();
                hab.Id_Habilidad = int.Parse(txtId_Habilidad.Text);
                if (hab.Read())
                {
                    if (txtNombre.Text.Length > 0 && int.Parse(txtId_Habilidad.Text) > 0)
                    {
                        hab.Nombre = txtNombre.Text;
                        switch (cmbNota.SelectedIndex)
                        {
                        case 0:
                            hab.Nota_Encuesta = 0;
                            break;

                        case 1:
                            hab.Nota_Encuesta = 1;
                            break;

                        case 2:
                            hab.Nota_Encuesta = 2;
                            break;

                        case 3:
                            hab.Nota_Encuesta = 3;
                            break;

                        case 4:
                            hab.Nota_Encuesta = 4;
                            break;

                        case 5:
                            hab.Nota_Encuesta = 5;
                            break;

                        default:
                            hab.Nota_Encuesta = 0;
                            break;
                        }
                        foreach (Competencia c in competencias)
                        {
                            if (c.Nombre == (string)cmbId_Competencia.SelectedItem)
                            {
                                hab.Id_Competencia = c.Id_competencia;
                            }
                        }
                        hab.Update();
                        MessageBox.Show("Actualizado correctamente. Éxito!");
                        NavigationService     navService = NavigationService.GetNavigationService(this);
                        MantenedorHabilidades nextPage   = new MantenedorHabilidades(id_comp);
                        navService.Navigate(nextPage);
                    }
                }
                else
                {
                    MessageBox.Show("Debe completar los campos antes de continuar. Aviso");
                }
            }
            catch (Exception)
            {
                MessageBox.Show("No se ha podido modificar la Habilidad. Verifique que la información esté correcta", "Error");
            }
        }
        public bool ActualizarHabilidad(string xml)
        {
            Habilidad hab = new Habilidad(xml);

            return(hab.Update());
        }