public StudentSignUp() { InitializeComponent(); student = new StudentInfo(); user = new LoginCredential(); picture = new StudentPicture(); pictureBox1.ImageLocation = defaultImage; pictureBox2.ImageLocation = defaultImage; pictureBox3.ImageLocation = defaultImage; pictureBox4.ImageLocation = defaultImage; }
//constructor public StudentForm(string user) { client = new MongoClient(); db = client.GetDatabase("ProxyKiller"); studentInfo = db.GetCollection <StudentInfo>("students"); studentPicture = db.GetCollection <StudentPicture>("studentPicture"); subjectInfo = db.GetCollection <SubjectInfo>("subjectInfo"); requestInfo = db.GetCollection <RequestInfo>("requestInfo"); InitializeComponent(); studentAttendance = db.GetCollection <StudentAttendance>(user); student = new StudentInfo(); picture = new StudentPicture(); student = studentInfo.Find(n => n.UserName == user).First(); picture = studentPicture.Find(n => n.UserName == user).First(); pictureBox2.ImageLocation = picture.ImageLocations[0]; label3.Text = student.Name; var list = subjectInfo.AsQueryable().Where(n => true).ToList(); List <string> subjectList = new List <string>(); foreach (var ele in list) { if (studentAttendance.Find(n => n.SubjectId == ele.SubjectId).CountDocuments() == 0) { subjectList.Add(ele.SubjectId); } } listBox1.DataSource = subjectList; student = new StudentInfo(); student = studentInfo.AsQueryable().Where(n => n.UserName == user).First(); subject = new SubjectInfo(); attendance = new StudentAttendance(); try { attendance = studentAttendance.AsQueryable().First(); label1.Text = label1.Text + " " + attendance.SubjectName; label2.Text = label2.Text + " " + attendance.Absent.ToString(); listBox2.DataSource = attendance.listOfAbsents; } catch { label1.Text = label1.Text + " NA "; label2.Text = label2.Text + " NA "; listBox2.DataSource = null; } try { attendance = studentAttendance.AsQueryable().Skip(1).First(); label5.Text = label5.Text + " " + attendance.SubjectName; label4.Text = label4.Text + " " + attendance.Absent.ToString(); listBox3.DataSource = attendance.listOfAbsents; } catch { label5.Text = label5.Text + " NA "; label4.Text = label4.Text + " NA "; listBox3.DataSource = null; } try { attendance = studentAttendance.AsQueryable().Skip(2).First(); label7.Text = label7.Text + " " + attendance.SubjectName; label6.Text = label6.Text + " " + attendance.Absent.ToString(); listBox4.DataSource = attendance.listOfAbsents; } catch { label7.Text = label7.Text + " NA "; label6.Text = label6.Text + " NA "; listBox4.DataSource = null; } try { attendance = studentAttendance.AsQueryable().Skip(3).First(); label9.Text = label9.Text + " " + attendance.SubjectName; label8.Text = label8.Text + " " + attendance.Absent.ToString(); listBox5.DataSource = attendance.listOfAbsents; } catch { label9.Text = label9.Text + " NA "; label8.Text = label8.Text + " NA "; listBox5.DataSource = null; } try { attendance = studentAttendance.AsQueryable().Skip(4).First(); label11.Text = label11.Text + " " + attendance.SubjectName; label10.Text = label10.Text + " " + attendance.Absent.ToString(); listBox6.DataSource = attendance.listOfAbsents; } catch { label11.Text = label11.Text + " NA "; label10.Text = label10.Text + " NA "; listBox6.DataSource = null; } }
//Refresh form void RefreshForm() { panel4.Show(); try { request1 = requestInfo.Find <RequestInfo>(n => true).First(); student1 = new StudentInfo(); picture1 = new StudentPicture(); subject1 = new SubjectInfo(); student1 = studentInfo.Find(n => n.UserName == request1.UserName).First(); picture1 = studentPicture.Find(n => n.UserName == request1.UserName).First(); subject1 = subjectInfo.Find(n => n.SubjectId == request1.SubjectId).First(); label1.Text = student1.Name; label9.Text = subject1.SubjectName; pictureBox2.ImageLocation = picture1.ImageLocations[0]; pictureBox3.ImageLocation = picture1.ImageLocations[1]; pictureBox4.ImageLocation = picture1.ImageLocations[2]; pictureBox5.ImageLocation = picture1.ImageLocations[3]; } catch { label1.Text = "NA"; label9.Text = "NA"; pictureBox2.ImageLocation = "NA"; pictureBox3.ImageLocation = "NA"; pictureBox4.ImageLocation = "NA"; pictureBox5.ImageLocation = "NA"; } try { request2 = requestInfo.Find <RequestInfo>(n => true).Skip(1).First(); student2 = new StudentInfo(); picture2 = new StudentPicture(); subject2 = new SubjectInfo(); student2 = studentInfo.Find(n => n.UserName == request2.UserName).First(); picture2 = studentPicture.Find(n => n.UserName == request2.UserName).First(); subject2 = subjectInfo.Find(n => n.SubjectId == request2.SubjectId).First(); label2.Text = student2.Name; label10.Text = subject2.SubjectName; pictureBox6.ImageLocation = picture2.ImageLocations[0]; pictureBox7.ImageLocation = picture2.ImageLocations[1]; pictureBox8.ImageLocation = picture2.ImageLocations[2]; pictureBox9.ImageLocation = picture2.ImageLocations[3]; } catch { label2.Text = "NA"; label10.Text = "NA"; pictureBox6.ImageLocation = "NA"; pictureBox7.ImageLocation = "NA"; pictureBox8.ImageLocation = "NA"; pictureBox9.ImageLocation = "NA"; } try { request3 = requestInfo.Find <RequestInfo>(n => true).Skip(2).First(); student3 = new StudentInfo(); picture3 = new StudentPicture(); subject3 = new SubjectInfo(); student3 = studentInfo.Find(n => n.UserName == request3.UserName).First(); picture3 = studentPicture.Find(n => n.UserName == request3.UserName).First(); subject3 = subjectInfo.Find(n => n.SubjectId == request3.SubjectId).First(); label3.Text = student3.Name; label11.Text = subject3.SubjectName; pictureBox10.ImageLocation = picture3.ImageLocations[0]; pictureBox11.ImageLocation = picture3.ImageLocations[1]; pictureBox12.ImageLocation = picture3.ImageLocations[2]; pictureBox13.ImageLocation = picture3.ImageLocations[3]; } catch { label3.Text = "NA"; label11.Text = "NA"; pictureBox10.ImageLocation = "NA"; pictureBox11.ImageLocation = "NA"; pictureBox12.ImageLocation = "NA"; pictureBox13.ImageLocation = "NA"; } panel4.Hide(); }