private void DeleteNorma_Click(object sender, EventArgs e) { int id = -1; if (!NormaID.Equals("-1") && NormaID != null) { id = Int32.Parse(NormaID.Text); Normas norm = _context.Normas.Where(n => n.NormaId == id).FirstOrDefault(); if (norm != null) { var confirmation = MessageBox.Show("¿Estás seguro/a que quieres eliminar esta nroma de uso: " + norm.NormaContent + "?", "LTI Administration", MessageBoxButtons.YesNo); if (DialogResult.Yes == confirmation) { _context.Normas.Remove(norm); _context.SaveChanges(); MessageBox.Show("La norma ha sido eliminada exitosamente.", "LTI Administration", MessageBoxButtons.OK, MessageBoxIcon.Information); PopulatList(); } } else { MessageBox.Show("Error: No se pudo obtener la norma seleccionada. Selecione la fila completa haciendo clic en la fila correspondiente de la primera columna (que no tiene nombre de columna).", "LTI Administration", MessageBoxButtons.OK, MessageBoxIcon.Error); } } else { MessageBox.Show("Error: No se pudo obtener la norma seleccionada. Selecione la fila completa haciendo clic en la fila correspondiente de la primera columna (que no tiene nombre de columna).", "LTI Administration", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
private void Add_Click(object sender, EventArgs e) { if (TeacherList.SelectedItem == null) { MessageBox.Show("Por favor, seleccione un administrador."); } else { int TeacherID = Int32.Parse(TeacherList.SelectedValue.ToString()); var loadAdmins = _context.Admins.Where(a => a.TeacherId == TeacherID); if (loadAdmins.ToList().Count > 0) { MessageBox.Show("Este administrador ya existe."); return; } Teachers Teach = _context.Teachers.Where(t => t.TeacherId == TeacherID).FirstOrDefault(); Admins NewAdmin = new Admins() { Teacher = Teach, TeacherId = Teach.TeacherId }; _context.Admins.Add(NewAdmin); try { _context.SaveChanges(); MessageBox.Show("Administrador agregado exitosamente."); this.Close(); } catch (Exception exp) { Console.WriteLine("Error: " + exp.Message); } } }
private void SaveChanges_Click(object sender, EventArgs e) { int id = Int32.Parse(NormaList.SelectedValue.ToString()); Normas norm = _context.Normas.Where(n => n.NormaId == id).FirstOrDefault(); norm.NormaContent = Content.Text; norm.CreatedBy = CreatedBy.Text; _context.SaveChanges(); MessageBox.Show("Los cambios se han guardado con éxito."); this.Close(); }
private void DeleteNormaBtn_Click(object sender, EventArgs e) { DialogResult confirmation = MessageBox.Show("¿Está seguro que desea eliminar esta norma de uso?", "LTI Administration", MessageBoxButtons.YesNo, MessageBoxIcon.Question); if (confirmation == DialogResult.Yes) { int id = Int32.Parse(NormaList.SelectedValue.ToString()); Normas norm = _context.Normas.Where(n => n.NormaId == id).FirstOrDefault(); _context.Normas.Remove(norm); _context.SaveChanges(); MessageBox.Show("La norma se ha eliminado con éxito.", "LTI Administration"); this.Close(); } }
private void SaveChanges_Click(object sender, EventArgs e) { if (Content.Text.Equals("") || CreatedBy.Text.Equals("")) { MessageBox.Show("Por favor, llene los campos obligatorios, marcados con un *."); } else { Normas norm = new Normas(); norm.CreatedBy = displayName; norm.NormaContent = Content.Text; _context.Normas.Add(norm); _context.SaveChanges(); MessageBox.Show("La norma de uso ha sido agregada con éxito."); this.Close(); } }
private void Add_Click(object sender, EventArgs e) { if (tbeDate.Value > tbsDate.Value) { //okey... string name = tbsDate.Value.ToString("MMMM") + " - " + tbeDate.Value.ToString("MMMM") + " " + tbeDate.Value.Year.ToString(); int active = 1; if (tbActive.Checked) { active = 1; } else { active = 0; } Trimestres tri = new Trimestres() { Name = name, StartDate = tbsDate.Value, EndDate = tbeDate.Value, Active = active }; //MessageBox.Show(name); _context.Trimestres.Add(tri); _context.SaveChanges(); MessageBox.Show("El trimestre ha sido añadido con éxito."); this.Close(); } else { MessageBox.Show("La fecha de término debe ser mayor a la fecha de inicio."); } }
private void SaveChanges_Click(object sender, EventArgs e) { int id = Int32.Parse(TrimestreList.SelectedValue.ToString()); Trimestres tr = _context.Trimestres.Where(t => t.TrimestreId == id).FirstOrDefault(); if (tbActive.Checked) { tr.Active = 1; } else { tr.Active = 0; } tr.Name = tbName.Text; tr.StartDate = tbsDate.Value; tr.EndDate = tbeDate.Value; _context.SaveChanges(); MessageBox.Show("Se han guardado los cambios."); this.Close(); }
private void Delete_Click(object sender, EventArgs e) { if (TeacherList.SelectedItem == null) { MessageBox.Show("Por favor, seleccione un administrador."); } else { int AdminID = Int32.Parse(TeacherList.SelectedValue.ToString()); Admins adm = _context.Admins.Where(a => a.TeacherId == AdminID).FirstOrDefault(); _context.Admins.Remove(adm); try { _context.SaveChanges(); MessageBox.Show("Administrador eliminado exitosamente."); this.Close(); } catch (Exception exp) { Console.WriteLine("Error: " + exp.Message); } } }
private void button1_Click(object sender, EventArgs e) // Save Configurations options { var configs = _context.Configurations.Select(c => c); Configurations AcceptTermsCF = configs.Where(c => c.Key.ToUpper().Equals(ACCEPT_TERMS)).FirstOrDefault(); Configurations ShowRulesReminderCF = configs.Where(c => c.Key.ToUpper().Equals(SHOW_RULES_REMINDER)).FirstOrDefault(); Configurations StudentSurveyTimeCF = configs.Where(c => c.Key.ToUpper().Equals(SURVEY_TIME_STUDENT)).FirstOrDefault(); Configurations TeacherSurveyTimeCF = configs.Where(c => c.Key.ToUpper().Equals(SURVEY_TIME_TEACHER)).FirstOrDefault(); Configurations StudentFullscreenCF = configs.Where(c => c.Key.ToUpper().Equals(FULLSCREEN_STUDENT)).FirstOrDefault(); Configurations TeacherFullscreenCF = configs.Where(c => c.Key.ToUpper().Equals(FULLSCREEN_TEACHER)).FirstOrDefault(); Configurations StudentLinkCF = configs.Where(c => c.Key.ToUpper().Equals(SURVEY_URL_STUDENT)).FirstOrDefault(); Configurations TeacherLinkCF = configs.Where(c => c.Key.ToUpper().Equals(SURVEY_URL_TEACHER)).FirstOrDefault(); Configurations AllowSelectTeacherSubjectCF = configs.Where(c => c.Key.ToUpper().Equals(ALLOW_SELECT_TEACHER_SUBJECT)).FirstOrDefault(); Configurations ReminderTextCF = configs.Where(c => c.Key.ToUpper().Equals(RULES_REMINDER_TEXT)).FirstOrDefault(); // Terms configurations if (AcceptTermsPeriod.Checked) { AcceptTermsCF.Value = TRUE; } else { AcceptTermsCF.Value = FALSE; } if (ShowRulesReminder.Checked) { ShowRulesReminderCF.Value = TRUE; } else { ShowRulesReminderCF.Value = FALSE; } if (SelectTeacherSubject.Checked) { AllowSelectTeacherSubjectCF.Value = TRUE; } else { AllowSelectTeacherSubjectCF.Value = FALSE; } if (!ReminderText.Text.Equals("") && ShowRulesReminder.Checked) { ReminderTextCF.Value = ReminderText.Text; } else { MessageBox.Show("El texto del recordatorio no puede estar vacío."); return; } // Survey configurations if (ActivateSurvey.Checked) { StudentSurveyTimeCF.Value = TRUE; //Set new url? string student_survey_link = SurveyLink.Text; if (!actual_survey_student_link.Equals(student_survey_link)) { StudentLinkCF.Value = SurveyLink.Text; } //Is fullscreen? if (OpenStudentSurveyFullscreen.Checked) { StudentFullscreenCF.Value = TRUE; } else { StudentFullscreenCF.Value = FALSE; } } else { StudentSurveyTimeCF.Value = FALSE; } if (ActivateSurveyTeacher.Checked) { TeacherSurveyTimeCF.Value = TRUE; //Set new url? string teacher_survey_link = SurveyLinkTeacher.Text; if (!actual_survey_teacher_link.Equals(teacher_survey_link)) { TeacherLinkCF.Value = SurveyLinkTeacher.Text; } //Is fullscreen? if (OpenTeacherSurveyFullscreen.Checked) { TeacherFullscreenCF.Value = TRUE; } else { TeacherFullscreenCF.Value = FALSE; } } else { TeacherSurveyTimeCF.Value = FALSE; } try { _context.SaveChanges(); MessageBox.Show("¡Los cambios se han guardado exitosamente!", "LABTI - INTEC"); } catch (Exception exp) { Console.WriteLine(exp.Message); MessageBox.Show("Lo sentimos, no se han podido guardar los cambios."); } }