Beispiel #1
0
        private void btnIngresar_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                Competencia com = new Competencia();
                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;
                            }
                            com.NIVEL_OPTIMO_ESPERADO = int.Parse(cmbNivel.SelectedItem.ToString());
                            #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;
                            XML    formato = new XML();
                            string xml     = formato.Serializar(com);
                            WFBS.Presentation.ServiceWFBS.ServiceWFBSClient servicio = new WFBS.Presentation.ServiceWFBS.ServiceWFBSClient();

                            if (servicio.CrearCompetencia(xml))
                            {
                                MessageBox.Show("Agregado correctamente", " Éxito!");
                                this.Limpiar();
                                NavigationService      navService = NavigationService.GetNavigationService(this);
                                MantenedorCompetencias nextPage   = new MantenedorCompetencias();
                                navService.Navigate(nextPage);
                            }
                            else
                            {
                                MessageBox.Show("No se pudo agregar 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");
                }
            }
            catch (Exception)
            {
                MessageBox.Show("No se pudo agregar la Competencia!", "Alerta");
            }
        }