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

            try
            {
                Competencia com = new Competencia();
                com.ID_COMPETENCIA = int.Parse(txtId_Competencia.Text);

                XML    formato = new XML();
                string xml     = formato.Serializar(com);
                WFBS.Presentation.ServiceWFBS.ServiceWFBSClient servicio = new WFBS.Presentation.ServiceWFBS.ServiceWFBSClient();

                if (servicio.LeerCompetencia(xml) != null)
                {
                    //--------------------------------------
                    if (txtNombre.Text.Length > 0 && txtNombre.Text.Trim() != "")
                    {
                        if (txtDescripcion.Text.Length > 0 && txtDescripcion.Text.Trim() != "")
                        {
                            if ((txtSigla.Text.Length > 0 && txtSigla.Text.Length <= 10) && txtSigla.Text.Trim() != "")
                            {
                                com.NOMBRE      = txtNombre.Text;
                                com.DESCRIPCION = txtDescripcion.Text;
                                com.SIGLA       = txtSigla.Text;
                                if (rbNo.IsChecked == true)
                                {
                                    com.OBSOLETA = 0;
                                }
                                if (rbSi.IsChecked == true)
                                {
                                    com.OBSOLETA = 1;
                                }
                                #region Nivel
                                switch (cmbNivel.SelectedIndex)
                                {
                                case 0:
                                    com.NIVEL_OPTIMO_ESPERADO = 0;
                                    break;

                                case 1:
                                    com.NIVEL_OPTIMO_ESPERADO = 1;
                                    break;

                                case 2:
                                    com.NIVEL_OPTIMO_ESPERADO = 2;
                                    break;

                                case 3:
                                    com.NIVEL_OPTIMO_ESPERADO = 3;
                                    break;

                                case 4:
                                    com.NIVEL_OPTIMO_ESPERADO = 4;
                                    break;

                                case 5:
                                    com.NIVEL_OPTIMO_ESPERADO = 5;
                                    break;

                                default:
                                    com.NIVEL_OPTIMO_ESPERADO = 0;
                                    break;
                                }
                                #endregion
                                com.PREGUNTA_ASOCIADA = txtPregunta.Text;

                                string xml2 = formato.Serializar(com);
                                if (servicio.ActualizarCompetencia(xml2))
                                {
                                    MessageBox.Show("Actualizado correctamente", "Éxito!");
                                    NavigationService      navService = NavigationService.GetNavigationService(this);
                                    MantenedorCompetencias nextPage   = new MantenedorCompetencias();
                                    navService.Navigate(nextPage);
                                }
                                else
                                {
                                    MessageBox.Show("No se pudo actualizar la Competencia, verifique que los datos sean correctos", "Aviso");
                                }
                            }
                            else
                            {
                                MessageBox.Show("El campo Sigla es obligatorio y admite como máximo 10 caracteres", "Aviso");
                            }
                        }
                        else
                        {
                            MessageBox.Show("El campo Descripción es obligatorio", "Aviso");
                        }
                    }
                    else
                    {
                        MessageBox.Show("El campo Nombre es obligatorio", "Aviso");
                    }
                }
                else
                {
                    MessageBox.Show("Debe completar los campos antses de continuar, verifique que los datos sean correctos", "Aviso");
                }
            }
            catch (Exception)
            {
                MessageBox.Show("No se pudo actualizar la Competencia!", "Alerta");
            }
        }