private async static Task <List <GruposItem> > getGruposItems() { try { var items = new List <GruposItem>(); var grupos = await DBAssets.GetInfoGruposAsync((App.Current as App).ConnectionString); if (grupos != null) { grupos.ForEach(p => items.Add(new GruposItem() { Id = p.id_tutor, Categoria = "Grupos", Grupo = p.grupo.Trim(' '), HeadLine = "Grupo " + p.grupo.Trim(' '), DateLine = p.carrera.Trim(' '), Subhead = p.nombre.Trim(' ') + " " + p.apellidos.Trim(' '), Semestre = p.semestre + " Semestre.", grupo = p, Imagen = "Assets/Antena.png" })); } items.Add(new GruposItem() { Id = 4, Categoria = "Agregar", HeadLine = "Agregar Grupo", DateLine = " ", Subhead = " ", Imagen = "Assets/Add.png" }); return(items); } catch (Exception eSql) { await new MessageDialog("Error!: " + eSql.Message).ShowAsync(); } return(null); }
private async void btn_Agregar_Tapped(object sender, TappedRoutedEventArgs e) { InfoProfesores profesor = new InfoProfesores(); profesor.nombre = txtbx_Nombre.Text; profesor.apellidos = txtbx_Apellidos.Text; profesor.correo = txtbx_correo.Text; if (cmbbx_Departamento.IsEnabled) { profesor.departamento = cmbbx_Departamento.SelectedItem.ToString(); } else { profesor.departamento = txtbx_Departamento.Text; } profesor.cod_postal = int.Parse(txtbx_codigo_postal.Text); profesor.provincia = txtbx_provincia.Text; profesor.imagen = imgPtr; if (await DBAssets.setProfesoresAsync((App.Current as App).ConnectionString, profesor) >= 0) { ProfesoresItems.Add(new ProfesoresItem() { Id = profesor.id_profesor, Categoria = "Tutores", HeadLine = profesor.nombre + " " + profesor.apellidos, Subhead = profesor.departamento, profesor = profesor, Imagen = "Assets/Usuario.png" }); } }
private async void btn_Actualizar_Tapped(object sender, TappedRoutedEventArgs e) { if (listItemSeleccionado != null) { try { foreach (var alumno in AlumnosPtr) { if (alumno.id_alumno == listItemSeleccionado.id_alumno) { alumno.matricula = int.Parse(txtbx_matricula.Text); alumno.nombre = txtbx_Nombre.Text; alumno.apellidos = txtbx_apellidos.Text; alumno.cod_postal = int.Parse(txtbx_codigo_postal.Text); alumno.provincia = txtbx_provincia.Text; if (await DBAssets.setActualizarAlumnoAsync((App.Current as App).ConnectionString, alumno) < 0) { await new MessageDialog("Error actualizando la fila de la base de datos!").ShowAsync(); } break; } } } catch (Exception eSql) { await new MessageDialog("Error!: " + eSql.Message).ShowAsync(); } } }
private async static Task <List <ProfesoresItem> > GetProfesoresItems() { try { var items = new List <ProfesoresItem>(); List <InfoProfesores> profesores = await DBAssets.getProfesoresAsync((App.Current as App).ConnectionString); profesores.ForEach(p => items.Add(new ProfesoresItem() { Id = p.id_profesor, Categoria = "Tutores", HeadLine = p.nombre + " " + p.apellidos, Subhead = p.departamento, profesor = p, Imagen = "Assets/Usuario.png" })); items.Add(new ProfesoresItem() { Id = 0, Categoria = "Agregar", HeadLine = "Agregar Profesor", Subhead = " ", Imagen = "Assets/Add.png" }); return(items); } catch (Exception eSql) { await new MessageDialog("Error!: " + eSql.Message).ShowAsync(); } return(null); }
private async void Alta_Popup(object sender, TappedRoutedEventArgs e) { try { info_alumnos = new InfoAlumnos(); info_alumnos.id_alumno = await GetId((App.Current as App).conexionBD, "SELECT (MAX(id_alumno) + 1) FROM Alumnos"); info_alumnos.matricula = int.Parse(txtbx_matricula.Text); info_alumnos.nombre = txtbx_Nombre.Text; info_alumnos.apellidos = txtbx_apellidos.Text; info_alumnos.id_provincia = await GetId((App.Current as App).conexionBD, "SELECT (MAX(id_provincia) + 1) FROM Provincias"); info_alumnos.cod_postal = int.Parse(txtbx_codigo_postal.Text); info_alumnos.provincia = txtbx_provincia.Text; idTutorSeleccionado = await GetId((App.Current as App).conexionBD, "SELECT DISTINCT id_tutor FROM Tutores " + "INNER JOIN Profesores ON Profesores.id_profesor = Tutores.id_profesor " + "WHERE CONCAT(TRIM(Profesores.nombre), ' ', TRIM(Profesores.apellidos)) LIKE('%" + grupo_seleccionado.Subhead + "%');"); if (await DBAssets.setAlumnoAsync((App.Current as App).ConnectionString, info_alumnos, idTutorSeleccionado) >= 0) { AlumnosPtr.Add(info_alumnos); } } catch (Exception eSql) { await new MessageDialog("Error!: " + eSql.Message).ShowAsync(); } }
private async void btn_Eliminar_Tapped(object sender, TappedRoutedEventArgs e) { await DBAssets.setBajaProfesorAsync((App.Current as App).ConnectionString, profesor_seleccionado.profesor); foreach (var profesor in ProfesoresItems) { if (profesor.profesor.id_profesor == profesor_seleccionado.profesor.id_profesor) { ProfesoresItems.Remove(profesor); } } }
protected override async void OnNavigatedTo(NavigationEventArgs e) { CoreApplication.GetCurrentView().TitleBar.ExtendViewIntoTitleBar = true; ApplicationViewTitleBar titleBar = ApplicationView.GetForCurrentView().TitleBar; titleBar.ButtonBackgroundColor = Colors.Transparent; titleBar.ButtonInactiveBackgroundColor = Colors.Transparent; grupo_seleccionado = (e.Parameter) as GruposItem; AlumnosPtr = await DBAssets.GetInfoAlumnosAsync((App.Current as App).ConnectionString, grupo_seleccionado.Subhead, ""); InventoryList.ItemsSource = AlumnosPtr; }
protected override async void OnNavigatedTo(NavigationEventArgs e) { this.navigationView = e.Parameter as NavigationView; GruposFactory.GetGrupos("Grupos", GruposItems); profesores = await DBAssets.getProfesoresAsync((App.Current as App).ConnectionString); psicologos = await DBAssets.getPsicologosAsync((App.Current as App).ConnectionString); cmbbx_carrera.ItemsSource = await DBAssets.getStringsAsync((App.Current as App).ConnectionString, "SELECT DISTINCT carrera FROM Tutores"); cmbbx_Profesores.ItemsSource = profesores; cmbbx_Psicologo.ItemsSource = psicologos; }
private async void btn_guardar_Tapped(object sender, Windows.UI.Xaml.Input.TappedRoutedEventArgs e) { try { if (await DBAssets.setActualizarJefeAsync((App.Current as App).ConnectionString, txtbx_jefeTut.Text, txtbx_jefeTutIns.Text, txtbx_jefeDep.Text) >= 0) { await new MessageDialog("Actualizacion Exitosa!").ShowAsync(); } } catch (Exception eSql) { await new MessageDialog("Error!: " + eSql.Message).ShowAsync(); } }
protected async override void OnNavigatedTo(NavigationEventArgs e) { this.main_page_obj = e.Parameter as Page; string[] Query = { "SELECT nombre FROM CoordinadoresTutorias", "SELECT nombre FROM CoordinadoresTutoriasInstitucionales", "SELECT nombre FROM JefesDepartamentos WHERE id_jefe = 1", "SELECT nombre FROM JefesDepartamentos WHERE id_jefe = 2" }; txtbx_jefeTut.Text = await DBAssets.getStringAsync((App.Current as App).ConnectionString, Query[0]); txtbx_jefeTutIns.Text = await DBAssets.getStringAsync((App.Current as App).ConnectionString, Query[1]); txtbx_jefeDep.Text = await DBAssets.getStringAsync((App.Current as App).ConnectionString, Query[2]); txtbx_jefeDesAcadem.Text = await DBAssets.getStringAsync((App.Current as App).ConnectionString, Query[3]); }
private async void btn_Agregar_Tapped(object sender, Windows.UI.Xaml.Input.TappedRoutedEventArgs e) { try { Tutores tutor = new Tutores(); tutor.id_tutor = await DBAssets.GetId((App.Current as App).ConnectionString, "SELECT (MAX(id_tutor) + 1) FROM Tutores"); tutor.id_Profesor = (cmbbx_Profesores.SelectedItem as InfoProfesores).id_profesor; tutor.grupo = txtbx_Grupo.Text; tutor.carrera = cmbbx_carrera.SelectedItem.ToString(); tutor.semestre = int.Parse(txtbx_Semestre.Text); Grupos grupo = new Grupos(); grupo.id_tutor = tutor.id_tutor; grupo.id_alumno = 0; if (await DBAssets.SetTutor((App.Current as App).ConnectionString, tutor) >= 0) { if (await DBAssets.SetGrupo((App.Current as App).ConnectionString, grupo) >= 0) { GruposItems.Add(new GruposItem() { Id = tutor.id_tutor, Categoria = "Grupos", Grupo = tutor.grupo.Trim(' '), HeadLine = "Grupo " + tutor.grupo.Trim(' '), DateLine = tutor.carrera.Trim(' '), Subhead = (cmbbx_Profesores.SelectedItem as InfoProfesores).nombre + " " + (cmbbx_Profesores.SelectedItem as InfoProfesores).apellidos, Semestre = tutor.semestre + " Semestre.", Imagen = "Assets/Antena.png" }); } else { await new MessageDialog("Error al crear grupo!").ShowAsync(); } } } catch (Exception eSql) { await new MessageDialog("Error!: " + eSql.Message).ShowAsync(); } }
private async void btn_Actualizar_Tapped(object sender, TappedRoutedEventArgs e) { try { profesor_seleccionado.profesor.nombre = txtbx_Nombre.Text; profesor_seleccionado.profesor.apellidos = txtbx_Apellidos.Text; if (cmbbx_Departamento.IsEnabled) { profesor_seleccionado.profesor.departamento = cmbbx_Departamento.SelectedItem.ToString(); } else { profesor_seleccionado.profesor.departamento = txtbx_Departamento.Text; } profesor_seleccionado.profesor.correo = txtbx_correo.Text; profesor_seleccionado.profesor.provincia = txtbx_provincia.Text; profesor_seleccionado.profesor.imagen = imgPtr; await DBAssets.setActualizarProfesorAsync((App.Current as App).ConnectionString, profesor_seleccionado.profesor); } catch (Exception ex) { } }
private async void btn_Baja_Tapped(object sender, TappedRoutedEventArgs e) { if (listItemSeleccionado != null) { try { if (await DBAssets.setBajaAlumnoAsync((App.Current as App).ConnectionString, listItemSeleccionado) >= 0) { foreach (var alumno in AlumnosPtr) { if (alumno.id_alumno == listItemSeleccionado.id_alumno) { AlumnosPtr.Remove(alumno); break; } } } } catch (Exception eSql) { await new MessageDialog("Error!: " + eSql.Message).ShowAsync(); } } }
protected override async void OnNavigatedTo(NavigationEventArgs e) { CoreApplication.GetCurrentView().TitleBar.ExtendViewIntoTitleBar = true; ApplicationViewTitleBar titleBar = ApplicationView.GetForCurrentView().TitleBar; titleBar.ButtonBackgroundColor = Colors.Transparent; titleBar.ButtonInactiveBackgroundColor = Colors.Transparent; formato_seleccionado = (e.Parameter) as Formato; string sFilePath = "Formatos/" + formato_seleccionado.formato_id + ".pdf"; sFilePathWord = "Formatos/" + formato_seleccionado.formato_id + ".docx"; var uri = new Uri("ms-appx:///Formatos/" + formato_seleccionado.formato_id + ".pdf"); Source = uri; #region CheckBox_GridView checkb_grid = new GridView(); checkb_grid.Width = double.NaN; checkb_grid.HorizontalAlignment = Windows.UI.Xaml.HorizontalAlignment.Center; checkb_grid.HorizontalContentAlignment = Windows.UI.Xaml.HorizontalAlignment.Center; #endregion #region ComboBox_GridView combob_grid = new GridView(); combob_grid.Width = double.NaN; combob_grid.HorizontalAlignment = Windows.UI.Xaml.HorizontalAlignment.Center; combob_grid.HorizontalContentAlignment = Windows.UI.Xaml.HorizontalAlignment.Center; #endregion textbox_sp = new StackPanel(); textbox_sp.Width = double.NaN; string texto = await pdfTextExtract(sFilePath); //int contador = charCounter(ref texto); textAreas = GetWordBasedOn(ref texto, "<[", "]>"); comboBoxes[0].Items.Clear(); comboBoxes[1].Items.Clear(); comboBoxes[2].Items.Clear(); comboBoxes[0].SelectionChanged += async(sender, x) => { comboBoxes[1].ItemsSource = await DBAssets.getGruposOnCarreraAsync((App.Current as App).ConnectionString, comboBoxes[0].SelectedItem.ToString()); }; comboBoxes[1].SelectionChanged += async(sender, x) => { comboBoxes[2].ItemsSource = await DBAssets.GetAlumnosBasedOnGrupoAsync((App.Current as App).ConnectionString, (comboBoxes[1].SelectedItem as InfoGruposGS).grupo, (comboBoxes[1].SelectedItem as InfoGruposGS).semestre); }; for (int i = 0; i < textAreas.Count; i++) { if (textAreas[i].Length <= 1) { CheckBox incisos = new CheckBox(); incisos.Name = textAreas[i]; incisos.Width = double.NaN; incisos.Height = double.NaN; incisos.HorizontalAlignment = Windows.UI.Xaml.HorizontalAlignment.Center; incisos.HorizontalContentAlignment = Windows.UI.Xaml.HorizontalAlignment.Center; incisos.Margin = new Thickness(10, 3, 10, 3); incisos.FlowDirection = FlowDirection.LeftToRight; incisos.Content = textAreas[i] + ")"; checkBoxes.Add(incisos); checkb_grid.Items.Add(incisos); } else { if (textAreas[i].ToLower().Contains("no oficio") || textAreas[i].ToLower().Contains("no semestre") || textAreas[i].ToLower().Contains("no constancias")) { TextBox oficio = new TextBox(); textBoxes.Add(oficio); oficio.Name = textAreas[i].Replace(' ', '_'); oficio.IsReadOnly = false; oficio.Text = "1"; oficio.Margin = new Thickness(10, 3, 10, 3); oficio.Height = double.NaN; oficio.Width = 200; oficio.Header = textAreas[i]; oficio.VerticalAlignment = Windows.UI.Xaml.VerticalAlignment.Center; oficio.HorizontalAlignment = Windows.UI.Xaml.HorizontalAlignment.Center; combob_grid.Items.Add(oficio); } else if (textAreas[i].ToLower().Contains("año") || textAreas[i].ToLower().Contains("periodo")) { DatePicker fecha = new DatePicker(); if (textAreas[i].ToLower().Contains("año")) { fecha.DayVisible = false; fecha.MonthVisible = false; } else { fecha.DayVisible = false; fecha.YearVisible = false; } fecha.Name = textAreas[i].Replace(' ', '_'); fecha.CharacterSpacing = 0; fecha.Header = textAreas[i]; fecha.Margin = new Thickness(10, 3, 10, 3); fecha.Height = double.NaN; fecha.HorizontalContentAlignment = Windows.UI.Xaml.HorizontalAlignment.Left; datePickers.Add(fecha); combob_grid.Items.Add(fecha); } else if (textAreas[i].ToLower().Contains("fecha")) { CalendarDatePicker dp = new CalendarDatePicker(); dp.Name = textAreas[i].Replace(' ', '_'); dp.Header = textAreas[i]; dp.Height = double.NaN; dp.Margin = new Thickness(10, 3, 10, 3); dp.Width = 200; dp.PlaceholderText = "Seleccione la fecha"; dp.VerticalAlignment = Windows.UI.Xaml.VerticalAlignment.Center; dp.HorizontalAlignment = Windows.UI.Xaml.HorizontalAlignment.Center; calendarDatePickers.Add(dp); combob_grid.Items.Add(dp); } else if (textAreas[i].ToLower().Contains("situacion") || textAreas[i].ToLower().Contains("descripcion") || textAreas[i].ToLower().Contains("asunto") || textAreas[i].ToLower().Contains("cargo")) { RichEditBox info = new RichEditBox(); info.Name = textAreas[i].Replace(' ', '_'); info.Width = double.NaN; info.Height = 100; info.Header = textAreas[i]; info.Margin = new Thickness(30, 3, 10, 3); richEditBoxes.Add(info); textbox_sp.Children.Add(info); } else if (textAreas[i].ToLower().ToLower().Contains("jefe") || textAreas[i].ToLower().ToLower().Contains("grupo") || textAreas[i].ToLower().ToLower().Contains("correo") || textAreas[i].ToLower().ToLower().Contains("imagen")) { //if (textAreas[i].ToLower().Contains("Jefe de Tutorias")); //replace(Pagina_Configuracion.); } else if (textAreas[i] != "Carrera") { ComboBox desplegables = new ComboBox(); desplegables.Name = textAreas[i].Replace(' ', '_'); desplegables.Width = 200; desplegables.Margin = new Thickness(10, 3, 10, 3); desplegables.Height = double.NaN; desplegables.Header = textAreas[i]; desplegables.PlaceholderText = "Seleccione un item"; desplegables.VerticalAlignment = Windows.UI.Xaml.VerticalAlignment.Center; desplegables.HorizontalAlignment = Windows.UI.Xaml.HorizontalAlignment.Center; desplegables.Text = textAreas[i]; comboBoxes.Add(desplegables); switch (desplegables.Name) { case "Nombre_Docente": desplegables.ItemsSource = await DBAssets.getProfesoresTutoresAsync((App.Current as App).ConnectionString); break; case "Ciudad_Estado": CiudadesEstados.getCiudadesEstados().ForEach(p => desplegables.Items.Add(p.Capital + ", " + p.Estado)); break; case "Nombre_Tutor": desplegables.ItemsSource = await DBAssets.getProfesoresTutoresAsync((App.Current as App).ConnectionString); break; } combob_grid.Items.Add(desplegables); } else { comboBoxes[0].ItemsSource = await DBAssets.getStringsAsync((App.Current as App).ConnectionString, "SELECT DISTINCT carrera FROM Tutores;"); } } } primary.Children.Add(combob_grid); primary.Children.Add(checkb_grid); primary.Children.Add(textbox_sp); primary.Children.Add(guardarBtn); }
private async void btnGuardar_Tapped(object sender, Windows.UI.Xaml.Input.TappedRoutedEventArgs e) { try { if (document != null) { document.Close(); document = null; } if (document == null) { document = new WordDocument(); docStream = File.OpenRead(Path.GetFullPath(sFilePathWord)); await document.OpenAsync(docStream, FormatType.Docx); docStream.Dispose(); } foreach (var x in textBoxes) { replace(x.Name, x.Text, sFilePathWord); } foreach (var z in richEditBoxes) { string valor; z.TextDocument.GetText(Windows.UI.Text.TextGetOptions.None, out valor); replace(z.Name, valor, sFilePathWord); } foreach (var x in comboBoxes) { if (x.SelectedItem == null) { replace(x.Name, "", sFilePathWord); } else if (x.Name.ToLower().Contains("nombre_tutor")) { replace("Grupo", (x.SelectedItem as TutoresProfesores).grupo + " de " + (x.SelectedItem as TutoresProfesores).semestre + " semestre", sFilePathWord); replace("Correo", (x.SelectedItem as TutoresProfesores).correo, sFilePathWord); if ((x.SelectedItem as TutoresProfesores).imagen != null) { //TextSelection textSelections = document.Find(new Regex("^<[Imagen]>")); Stream imageStream = (x.SelectedItem as TutoresProfesores).imagen; WParagraph paragraph = new WParagraph(document); WPicture picture = paragraph.AppendPicture(imageStream) as WPicture; picture.Width = 60; picture.Height = 60; TextSelection newSelection = new TextSelection(paragraph, 0, 1); TextBodyPart bodyPart = new TextBodyPart(document); bodyPart.BodyItems.Add(paragraph); document.Replace("<[Imagen]>", bodyPart, true, true); } replace(x.Name, x.SelectedItem.ToString(), sFilePathWord); } replace(x.Name, x.SelectedItem.ToString(), sFilePathWord); } foreach (var fecha in datePickers) { if (fecha.SelectedDate == null) { fecha.SelectedDate = DateTime.UtcNow; } if (fecha.Name.ToLower().Contains("año")) { replace(fecha.Name, fecha.Date.DateTime.ToString("yyyy"), sFilePathWord); } else { replace(fecha.Name, fecha.Date.DateTime.ToString("MMMM"), sFilePathWord); } } foreach (var dp in calendarDatePickers) { if (dp.Date.Value.DateTime == null) { dp.Date = DateTime.UtcNow; } replace(dp.Name, dp.Date.Value.DateTime.ToString("dd/MMMM/yyyy"), sFilePathWord); } if (checkBoxes != null) { foreach (var cb in checkBoxes) { if (cb.IsChecked == true) { replace(cb.Name, "x", sFilePathWord); } else { replace(cb.Name, "", sFilePathWord); } } } replace("Jefe_Tutorias", await DBAssets.getStringAsync((App.Current as App).ConnectionString, "SELECT nombre FROM CoordinadoresTutorias;"), sFilePathWord); replace("Jefe_Departamento", await DBAssets.getStringAsync((App.Current as App).ConnectionString, "SELECT nombre FROM JefesDepartamentos WHERE id_jefe = 1;"), sFilePathWord); replace("Jefe_Tutorias_Institucional", await DBAssets.getStringAsync((App.Current as App).ConnectionString, "SELECT nombre FROM CoordinadoresTutoriasInstitucionales;"), sFilePathWord); replace("Jefe_Desarrollo_Académico", await DBAssets.getStringAsync((App.Current as App).ConnectionString, "SELECT nombre FROM JefesDepartamentos WHERE id_jefe = 2;"), sFilePathWord); FileSavePicker savePicker = new FileSavePicker(); savePicker.SuggestedStartLocation = PickerLocationId.Desktop; savePicker.SuggestedFileName = "Resultado"; savePicker.FileTypeChoices.Add("Word Documents", new List <string>() { ".docx" }); StorageFile outputStorageFile = await savePicker.PickSaveFileAsync(); await document.SaveAsync(outputStorageFile, FormatType.Docx); } catch (Exception ex) { var err = new MessageDialog("Unable to open File!" + ex.Message); await err.ShowAsync(); } }
private async void TextBlock_PointerReleased(object sender, PointerRoutedEventArgs e) { TextBlock tx = sender as TextBlock; InventoryList.ItemsSource = await DBAssets.GetInfoAlumnosAsync((App.Current as App).ConnectionString, grupo_seleccionado.Subhead, "ORDER BY " + tx.Name); }
protected override async void OnNavigatedTo(NavigationEventArgs e) { this.navigationView = e.Parameter as NavigationView; ProfesoresFactory.getProfesores("Profesores", ProfesoresItems); cmbbx_Departamento.ItemsSource = await DBAssets.getStringsAsync((App.Current as App).ConnectionString, "SELECT DISTINCT departamento from Profesores;"); }