示例#1
0
        private void editarAlumno(object sender, RoutedEventArgs e)
        {
            Button boton = sender as Button;

            if (boton.Content.Equals("MODIFICAR"))
            {
                boton.Content    = "GUARDAR";
                boton.Background = (Brush) new BrushConverter().ConvertFrom("#FF7B9763");
                txtNombrePerfilAlumno.IsEnabled     = true;
                txtNombrePerfilAlumno.IsReadOnly    = false;
                txtApellidosPerfilAlumno.IsEnabled  = true;
                txtApellidosPerfilAlumno.IsReadOnly = false;
                txtDireccionPerfilAlumno.IsEnabled  = true;
                txtDireccionPerfilAlumno.IsReadOnly = false;
                txtTelefonoPerfilAlumno.IsEnabled   = true;
                txtTelefonoPerfilAlumno.IsReadOnly  = false;
                txtEmailPerfilAlumno.IsEnabled      = true;
                txtEmailPerfilAlumno.IsReadOnly     = false;
            }
            else
            {
                // PEDIMOS CONFIRMACIÓN
                MessageBoxResult messageBoxResult = Utils.msgBox("¿Desea guardar los cambios?", "yesno", "question");
                if (messageBoxResult == MessageBoxResult.Yes)
                {
                    // SI EL FORMULARIO SE VALIDA CORRECTAMENTE PROCEDEMOS A REALIZAR EL INSERT
                    if (validarFormulario())
                    {
                        string nombre    = Utils.initCap(txtNombrePerfilAlumno.Text, "no");
                        string apellidos = Utils.initCap(txtApellidosPerfilAlumno.Text, "mayus");
                        string direccion = Utils.initCap(txtDireccionPerfilAlumno.Text, "no");
                        string telefono  = txtTelefonoPerfilAlumno.Text;
                        string email     = txtEmailPerfilAlumno.Text.ToLower();

                        WebService            webService = new WebService();
                        EstadoMensajeResponse response   = webService.editarAlumno(this.idAlumno, MainWindow.user.id, nombre, apellidos, direccion, telefono, email);


                        if (response.estado == 1)
                        {
                            Utils.msgBox(response.mensaje, "ok", "info");
                            ((MainWindow)this.Owner).cargarAlumnos();

                            boton.Content    = "MODIFICAR";
                            boton.Background = (Brush) new BrushConverter().ConvertFrom("#FF979563");
                            txtNombrePerfilAlumno.IsEnabled     = false;
                            txtNombrePerfilAlumno.IsReadOnly    = true;
                            txtApellidosPerfilAlumno.IsEnabled  = false;
                            txtApellidosPerfilAlumno.IsReadOnly = true;
                            txtDireccionPerfilAlumno.IsEnabled  = false;
                            txtDireccionPerfilAlumno.IsReadOnly = true;
                            txtTelefonoPerfilAlumno.IsEnabled   = false;
                            txtTelefonoPerfilAlumno.IsReadOnly  = true;
                            txtEmailPerfilAlumno.IsEnabled      = false;
                            txtEmailPerfilAlumno.IsReadOnly     = true;
                        }
                        else
                        {
                            Utils.msgBox(response.mensaje, "ok", "warning");
                        }
                    }
                }
            }
        }