示例#1
0
        //panel3 aprove button
        private void button3_Click(object sender, EventArgs e)
        {
            try
            {
                if (student3 == null)
                {
                    throw new Exception();
                }
                int count = 0;
                try
                {
                    count = (int)studentMap.Find(n => n.UserName == student3.UserName).CountDocuments();
                }
                catch { }
                if (count == 0)
                {
                    Thread t1 = new Thread(AddPerson);
                    panel4.Show();
                    t1.Start(student3);
                    t1.Join();
                    buffer = db.GetCollection <Buffer>("buffer");
                    if (buffer.Find(n => true).CountDocuments() != 0)
                    {
                        buffer.DeleteMany(n => true);
                        throw new Exception();
                    }
                }
                attendance3          = new SubjectAttendance();
                attendance3.UserName = student3.UserName;
                attendance3.Name     = student3.Name;

                att3             = new StudentAttendance();
                att3.SubjectId   = subject3.SubjectId;
                att3.SubjectName = subject3.SubjectName;

                subjectAttendance3 = db.GetCollection <SubjectAttendance>(subject3.SubjectId);
                subjectAttendance3.InsertOne(attendance3);

                studentAttendance3 = db.GetCollection <StudentAttendance>(student3.UserName);
                studentAttendance3.InsertOne(att3);
                requestInfo.DeleteOne(n => n.UserNameSubjectId == request3.UserNameSubjectId);
                MessageBox.Show("Operation Sucessfull!");
                panel4.Hide();

                RefreshForm();
            }
            catch
            {
            }
        }
示例#2
0
 public UploadAttendance(string subjectId)
 {
     InitializeComponent();
     client            = new MongoClient();
     db                = client.GetDatabase("ProxyKiller");
     this.subjectId    = subjectId;
     buffer            = db.GetCollection <Buffer>("buffer");
     iBuffer           = db.GetCollection <ImageBuffer>("imageBuffer");
     attendanceMap     = db.GetCollection <AttendanceMap>("attendanceMap");
     subjectAttendance = db.GetCollection <SubjectAttendance>(subjectId);
     subject           = new SubjectAttendance();
     attendance        = new AttendanceMap();
     map               = new StudentMap();
     student           = new StudentAttendance();
     buff              = new Buffer();
     iBuff             = new ImageBuffer();
     buff.UserName     = subjectId;
     label1.Text       = "Subject : " + subjectId;
 }
示例#3
0
        //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;
            }
        }