private void DownvoteButton_Click(object sender, RoutedEventArgs e) { StudentPlanViewDisplay student = (StudentPlanViewDisplay)((FrameworkElement)sender).DataContext; //window._addFrame.Navigate(new AddVote(false, student.StudentId)); Database.Insert.Vote.One(student.StudentId, false, "Downvote en séance"); }
private void RandomInterro_Click(object sender, RoutedEventArgs e) { List <StudentInfo> studentList = Database.Get.Student.AllFromClassroomId(classroomId); List <StudentInfo> studentInterroableList = new List <StudentInfo>(); foreach (StudentInfo student in studentList) { if (student.interrogation == false) { studentInterroableList.Add(student); } } Random random = new Random(); int index = random.Next(studentInterroableList.Count); string[] name = Database.Get.Student.NameFromID(studentInterroableList[index].studentId); MessageBox.Show($"{name[1]} {name[0]}"); List <StudentPlanViewDisplay> allStudentPlanView = new List <StudentPlanViewDisplay>(); foreach (ObservableCollection <StudentPlanViewDisplay> collection in studentPlanViewList) { foreach (StudentPlanViewDisplay studentPlanView in collection) { allStudentPlanView.Add(studentPlanView); } } StudentPlanViewDisplay studentPlanViewSelected = allStudentPlanView.Find(x => x.StudentId == studentInterroableList[index].studentId); Interro_UpdateDB(studentPlanViewSelected, classroomId); }
private void Border_MouseEnter(object sender, RoutedEventArgs e) { StudentPlanViewDisplay student = (StudentPlanViewDisplay)((FrameworkElement)sender).DataContext; if (!student.Enabled) { return; } student.ButtonVisible = true; }
private void Board_UpdateDB(StudentPlanViewDisplay student, int classroomId) { student.BoardEnabled = false; student.BoardCheck = GlobalVariable.specialCharacter["CheckMark"]; using SQLiteCommand cmd = GlobalFunction.OpenDbConnection(); cmd.CommandText = "UPDATE students SET board = true WHERE studentId = @studentId"; cmd.Parameters.AddWithValue("studentId", student.StudentId); cmd.Prepare(); cmd.ExecuteNonQuery(); List <StudentInfo> studentList = Database.Get.Student.AllFromClassroomId(classroomId); int boardCount = 0; foreach (StudentInfo studentInfo in studentList) { if (studentInfo.board == true) { boardCount++; } } if (boardCount == studentList.Count) { cmd.CommandText = "UPDATE students SET board = false WHERE classroomId = @classroomId"; cmd.Parameters.AddWithValue("classroomId", classroomId); cmd.Prepare(); cmd.ExecuteNonQuery(); foreach (ObservableCollection <StudentPlanViewDisplay> collection in studentPlanViewList) { foreach (StudentPlanViewDisplay studentPlanView in collection) { if (studentPlanView.Enabled) { studentPlanView.BoardEnabled = true; studentPlanView.BoardCheck = GlobalVariable.specialCharacter["Cross"]; } } } } }
private void Board_Click(object sender, RoutedEventArgs e) { StudentPlanViewDisplay student = (StudentPlanViewDisplay)((FrameworkElement)sender).DataContext; Board_UpdateDB(student, classroomId); }
public PlanViewPage(int planId) { PlanInfo plan = Database.Get.Plan.FromId(planId); RoomInfo room = Database.Get.Room.FromID(plan.roomId); ScheduleInfo schedule = Database.Get.Schedule.FromId(plan.scheduleId); classroomId = (int)schedule.classroomId; List <int> seperationList = new List <int>(); List <string> separationStringList = new List <string>(); if (plan.spacing != "") { separationStringList = plan.spacing.Split(",").ToList(); for (int i = 0; i < separationStringList.Count; i++) { seperationList.Add(int.Parse(separationStringList[i])); } } int initItemHeight = 40; int initItemWidth = 40; List <PlaceInfo> placeList = Database.Get.Place.AllFromPlanId(planId); //placeList.Find(x => x.Row == 1 && x.Column == 2) rowNumber = room.Rows; columnNumber = room.Columns + seperationList.Count; columnCount = room.Columns; columnSkip = seperationList.Count; int currentColumn = 0; for (int i = 0; i < rowNumber; i++) { //MessageBox.Show("Début de la row " + i.ToString()); studentPlanViewList.Add(new ObservableCollection <StudentPlanViewDisplay>()); currentColumn = 0; for (int j = 0; j < columnNumber; j++) { //MessageBox.Show("Colonne " + j.ToString()); if (seperationList.Contains(j)) { StudentPlanViewDisplay placeDisplay = new StudentPlanViewDisplay() { ItemHeight = initItemHeight, ItemWidth = initItemWidth, AbsoluteWidth = columnSkipSize, Name = "", BoardCheck = "", InterrogationCheck = "", ButtonVisible = false, Thickness = 0, Enabled = false }; studentPlanViewList[i].Add(placeDisplay); } else { PlaceInfo place = placeList.Find(x => x.Row == i && x.Column == currentColumn); if (place == null) { StudentPlanViewDisplay placeDisplayNull = new StudentPlanViewDisplay() { ItemHeight = initItemHeight, ItemWidth = initItemHeight, AbsoluteWidth = 0, Name = "", Thickness = 0, ButtonVisible = false, BoardCheck = "", InterrogationCheck = "", Enabled = false }; studentPlanViewList[i].Add(placeDisplayNull); } else { StudentInfo student = Database.Get.Student.FromId(place.StudentId); string[] name = Database.Get.Student.NameFromID(place.StudentId); string parsedName = name[1] + " " + name[0]; StudentPlanViewDisplay placeDisplay = new StudentPlanViewDisplay() { ItemHeight = initItemHeight, ItemWidth = initItemWidth, AbsoluteWidth = 0, Name = parsedName, Thickness = 1, StudentId = place.StudentId, BoardCheck = student.board ? GlobalVariable.specialCharacter["CheckMark"] : GlobalVariable.specialCharacter["Cross"], InterrogationCheck = student.interrogation ? GlobalVariable.specialCharacter["CheckMark"] : GlobalVariable.specialCharacter["Cross"], InterroEnabled = !student.interrogation, BoardEnabled = !student.board, ButtonVisible = false, Enabled = true }; studentPlanViewList[i].Add(placeDisplay); } currentColumn++; } } } InitializeComponent(); _lst.ItemsSource = studentPlanViewList; }