protected void lb_studdelete_Click(object sender, EventArgs e)
        {
            LinkButton lb = (LinkButton)sender;
            var        id = int.Parse(lb.CommandArgument);

            var courseToRemove = cc.CourseByID(id);
            var gc             = new GradesControl();

            var gradesToRemove = gc.GetAllGrades().ToList().Where(x => x.CourseID == courseToRemove.Id);

            foreach (var grade in gradesToRemove)
            {
                gc.RemoveGrade(grade);
            }

            var ac = new AttendanceControl();
            var attendanceToRemove = ac.GetAllAttendance().ToList().Where(a => a.CourseID == courseToRemove.Id);

            foreach (var attendance in attendanceToRemove)
            {
                ac.RemoveAttendance(attendance);
            }

            cc.RemoveCourse(courseToRemove);

            Response.Redirect($"Course");
        }
    public void insertUpdate(int month, int year, string locationName, DataGridView dataGridView)
    {
        attendanceContent   = new AttendanceContent();
        attendanceContentDB = new AttendanceContentDB();
        attendanceControl   = new AttendanceControl();
        bool flag         = attendanceControl.checkIfLocationAttendanceSubmitted(month, year, locationName);
        int  attendanceID = attendanceControl.getID(month, year, locationName);

        attendanceContent.setAttendanceID(attendanceID);
        bool flag1 = attendanceContentDB.checkIfAttendanceContentIsSubmitted(attendanceContent);

        if (flag == true)
        {
            //submitted //update
            if (flag1 == true)
            {
                this.update(month, year, locationName, dataGridView);
            }
            else if (flag1 == false)
            {
                this.insert(dataGridView);
            }
        }
        else if (flag == false)
        {
            //not submitted //insert
            attendanceControl.insert(month, year, locationName);
            this.insert(dataGridView);
        }
    }
        protected void DetentionListBtn_Click(object sender, EventArgs e)
        {
            CSV csv = AttendanceControl.GetDetentionLists(DateRange.ThisAttendanceWeek);

            csv.Save(Server.MapPath("~/Temp/Detention.csv"));
            Response.Redirect("~/Temp/Detention.csv");
        }
        protected void LoadBtn_Click(object sender, EventArgs e)
        {
            using (WebhostEntities db = new WebhostEntities())
            {
                if (db.Weekends.Where(w => w.id == WeekendId).Count() > 0)
                {
                    IDField.Value = Convert.ToString(WeekendId);
                    Weekend weekend = db.Weekends.Where(w => w.id == WeekendId).Single();
                    DetentionListSelector.AddStudent(AttendanceControl.GetOneHourDetention(weekend.id));
                    DetentionListSelector.AddStudent(AttendanceControl.GetTwoHourDetention(weekend.id));
                    CampusedListSelector.AddStudent(AttendanceControl.GetCampusedList(weekend.id));

                    LoadBtn.Visible = false;
                    SaveBtn.Visible = true;
                    DetentionListSelector.Visible = true;
                    CampusedListSelector.Visible  = true;

                    return;
                }
            }

            DetentionListSelector.Visible = false;
            CampusedListSelector.Visible  = false;
            LoadBtn.Visible = true;
            SaveBtn.Visible = false;
            LoadBtn.Text    = "That Weekend Schedule hasn't been started yet.";
        }
        protected void GetAttendanceDump_Click(object sender, EventArgs e)
        {
            int StudentId;

            try
            {
                StudentId = Convert.ToInt32(StudentSelector.SelectedValue);
            }
            catch
            {
                ((Default)Page.Master).ShowError("No Student Selected", "You must select a Student to generate this report.");
                return;
            }

            DateRange range;

            try
            {
                range = new DateRange(DateRange.GetDateTimeFromString(StartDateInput.Text), DateRange.GetDateTimeFromString(EndDateInput.Text));
            }
            catch (InvalidCastException)
            {
                ((Default)Page.Master).ShowError("Invalid Date Range Selected.",
                                                 String.Format("Could not parse dates from '{0}'~'{1}' to a valid Date Range.", StartDateInput.Text, EndDateInput.Text));
                return;
            }

            AttendanceControl.AttendanceDump(range, StudentId).Save(Server.MapPath("~/Temp/dump.csv"));
            Response.Redirect("~/Temp/dump.csv");
        }
Example #6
0
        protected void LinkButtonDelete_Click(object sender, EventArgs e)
        {
            LinkButton  lb = (LinkButton)sender;
            HiddenField hd = (HiddenField)lb.FindControl("HiddenFieldStudID");

            int studentID = int.Parse(hd.Value);

            var ac = new AttendanceControl();

            var studentToRemove = studentsControl.GetAllStudents().Where(x => x.Id == studentID).FirstOrDefault();

            if (studentToRemove.Attendance.Count > 0)
            {
                ac.RemoveAttendanceByStudentID(studentID);
            }
            if (studentToRemove != null)
            {
                studentsControl.RemoveStudent(studentID);

                var pc = new PeopleControl();

                pc.RemovePeople(studentToRemove.PersonId);
            }



            BindGrid();
        }
        protected void SubmitNoteBtn_Click(object sender, EventArgs e)
        {
            Dictionary <int, AttendanceControl.ShortMarking> MarkingData = new Dictionary <int, AttendanceControl.ShortMarking>();

            LogInformation("Submitting Requested Notes.");

            Dictionary <int, AttendanceControl.AdditionalInfoRequest> request = (Dictionary <int, AttendanceControl.AdditionalInfoRequest>)Session["required_update_info"];

            AttendancePageInfo api = new AttendancePageInfo()
            {
                SectionId = this.SectionId, Name = ClassInfoLabel.Text, Date = AttendanceDate, Attendances = new List <AttendanceData>()
            };

            using (WebhostEntities db = new WebhostEntities())
            {
                foreach (TableRow row in UpdateTable.Rows)
                {
                    int     studentId = Convert.ToInt32(((HiddenField)row.Cells[1].Controls[0]).Value);
                    Student student   = db.Students.Find(studentId);
                    String  Notes     = ((TextBox)row.Cells[1].Controls[1]).Text;
                    int     markId    = request[studentId].markingId;
                    MarkingData.Add(studentId, new AttendanceControl.ShortMarking()
                    {
                        markId = markId, notes = Notes
                    });
                    AttendanceData atd = new AttendanceData()
                    {
                        StudentId = studentId,
                        Name      = String.Format("{0} {1}", student.FirstName, student.LastName),
                        Marking   = db.GradeTableEntries.Find(markId).Name
                    };
                    ((List <AttendanceData>)api.Attendances).Add(atd);
                }
            }
            LogCurrentData(api);

            request.Clear();
            request = AttendanceControl.SubmitAttendance(SectionId, MarkingData, user.ID, AttendanceDate);
            if (request.Count != 0)
            {
                Session["required_update_info"] = request;
                Response.Redirect("~/Mobile/UpdateInformation.aspx");
            }
            else
            {
                Session["required_update_info"] = null;
                SectionId      = -1;
                AttendanceDate = DateTime.Today;
                if (this.IsRedirect)
                {
                    Redirect(this.RedirectedUrl);
                }
                else
                {
                    Redirect("~/Mobile/Attendance.aspx");
                }
            }
        }
Example #8
0
        public static String SyncAttendanceForSection(int webhost_section_id, DateRange period = null)
        {
            String report = "";

            using (WebhostEntities db = new WebhostEntities())
            {
                Section section = db.Sections.Where(sec => sec.id == webhost_section_id).Single();
                int     schoology_section_id = section.SchoologyId;
                int     attmarkid            = db.AttendanceMarkings.Count() > 0 ? db.AttendanceMarkings.OrderBy(att => att.id).ToList().Last().id : 0;
                List <SchoologyAttendance> schoologyAttendances = SchoologyAttendance.Download(schoology_section_id, period);
                report += String.Format("Found {0} Attendance Markings{1}", schoologyAttendances.Count, Environment.NewLine);
                foreach (SchoologyAttendance sch_att in schoologyAttendances)
                {
                    AttendanceMarking marking;
                    if (section.AttendanceMarkings.Where(mk =>
                                                         mk.AttendanceDate.Date.Equals(sch_att.date) && mk.StudentID == sch_att.enrollment.user_id).Count() <= 0)
                    {
                        marking = new AttendanceMarking()
                        {
                            id             = ++attmarkid,
                            AttendanceDate = sch_att.date,
                            StudentID      = sch_att.enrollment.user_id,
                            SectionIndex   = webhost_section_id,
                            MarkingIndex   = AttendanceControl.LookupAttendanceIdByName(sch_att.AttendanceMarking),
                            Notes          = sch_att.Notes,
                            SubmissionTime = DateTime.Now,
                            SubmittedBy    = 9997
                        };

                        db.AttendanceMarkings.Add(marking);
                        Student         student = db.Students.Where(s => s.ID == sch_att.enrollment.user_id).Single();
                        GradeTableEntry entry   = db.GradeTableEntries.Where(e => e.id == marking.MarkingIndex).Single();
                        report += String.Format("Created new attendance [{3}] for {0} {1} on {2}{4}", student.FirstName, student.LastName, marking.AttendanceDate.ToShortDateString(), entry.Name, Environment.NewLine);
                    }
                    else
                    {
                        marking = section.AttendanceMarkings.Where(mk =>
                                                                   mk.AttendanceDate.Date.Equals(sch_att.date) && mk.StudentID == sch_att.enrollment.user_id).Single();
                        if (marking.MarkingIndex == AttendanceControl.LookupAttendanceIdByName("Excused"))
                        {
                            report += String.Format("Skipping previously excused absence for {0} {1} on {3}{2}", marking.Student.FirstName, marking.Student.LastName, Environment.NewLine, marking.AttendanceDate.ToShortDateString());
                            continue; // Do not overwrite an excused absence.
                        }
                        marking.MarkingIndex   = AttendanceControl.LookupAttendanceIdByName(sch_att.AttendanceMarking);
                        marking.Notes          = sch_att.Notes;
                        marking.SubmissionTime = DateTime.Now;

                        report += String.Format("Updated attendance [{4}] for {0} {1} on {3}{2}", marking.Student.FirstName, marking.Student.LastName, Environment.NewLine, marking.AttendanceDate.ToShortDateString(), marking.Marking.Name);
                    }
                }

                db.SaveChanges();
            }

            return(report);
        }
Example #9
0
        protected void GenerateBtn_Click(object sender, EventArgs e)
        {
            OneHrDetentionListSelector.Clear();
            TwoHrDetentionListSelector.Clear();
            CampusedListSelector.Clear();
            Dictionary <String, List <int> > lists = AttendanceControl.GetWeekendDisciplineLists(new DateRange(DateRange.GetDateTimeFromString(StartDateInput.Text), DateRange.GetDateTimeFromString(EndDateInput.Text)), lpc, c1h, c2h, cc);

            OneHrDetentionListSelector.AddStudent(lists["1Hr"]);
            TwoHrDetentionListSelector.AddStudent(lists["2Hr"]);
            CampusedListSelector.AddStudent(lists["Campused"]);
        }
 protected void SummaryBtn_Click(object sender, EventArgs e)
 {
     if (StartDateInput.Text.Equals(""))
     {
         AttendanceControl.AttendanceDump(new DateRange(DateRange.ThisFriday.AddDays(-7), DateRange.ThisFriday.AddDays(-1))).Save(Server.MapPath("~/Temp/AttendanceDump.csv"));
         Response.Redirect("~/Temp/AttendanceDump.csv");
     }
     else
     {
         AttendanceControl.AttendanceDump(new DateRange(DateRange.GetDateTimeFromString(StartDateInput.Text), DateRange.GetDateTimeFromString(EndDateInput.Text))).Save(Server.MapPath("~/Temp/AttendanceDump.csv"));
         Response.Redirect("~/Temp/AttendanceDump.csv");
     }
 }
    public void update(int month, int year, string locationName, DataGridView dataGridView)
    {
        attendanceControl   = new AttendanceControl();
        attendanceContent   = new AttendanceContent();
        attendanceContentDB = new AttendanceContentDB();
        int           attendanceID = attendanceControl.getID(month, year, locationName);
        List <string> list         = new List <string>();

        foreach (DataGridViewRow row in dataGridView.Rows)
        {
            list.Clear();
            int code = int.Parse(row.Cells[0].Value.ToString());
            //string name = row.Cells[1].Value.ToString();
            list.Add(row.Cells[2].Value.ToString());
            list.Add(row.Cells[3].Value.ToString());
            list.Add(row.Cells[4].Value.ToString());
            list.Add(row.Cells[5].Value.ToString());
            list.Add(row.Cells[6].Value.ToString());
            list.Add(row.Cells[7].Value.ToString());
            list.Add(row.Cells[8].Value.ToString());
            list.Add(row.Cells[9].Value.ToString());
            list.Add(row.Cells[10].Value.ToString());
            list.Add(row.Cells[11].Value.ToString());
            list.Add(row.Cells[12].Value.ToString());
            list.Add(row.Cells[13].Value.ToString());
            list.Add(row.Cells[14].Value.ToString());
            list.Add(row.Cells[15].Value.ToString());
            list.Add(row.Cells[16].Value.ToString());
            list.Add(row.Cells[17].Value.ToString());
            list.Add(row.Cells[18].Value.ToString());
            list.Add(row.Cells[19].Value.ToString());
            list.Add(row.Cells[20].Value.ToString());
            list.Add(row.Cells[21].Value.ToString());
            list.Add(row.Cells[22].Value.ToString());
            list.Add(row.Cells[23].Value.ToString());
            list.Add(row.Cells[24].Value.ToString());
            list.Add(row.Cells[25].Value.ToString());
            list.Add(row.Cells[26].Value.ToString());
            list.Add(row.Cells[27].Value.ToString());
            list.Add(row.Cells[28].Value.ToString());
            list.Add(row.Cells[29].Value.ToString());
            list.Add(row.Cells[30].Value.ToString());
            list.Add(row.Cells[31].Value.ToString());
            list.Add(row.Cells[32].Value.ToString());
            attendanceContent.setDays(list);
            attendanceContent.setEmpID(code);
            attendanceContent.setAttendanceID(attendanceID);
            attendanceContentDB.update(attendanceContent);
        }
    }
Example #12
0
 static void ExcuseJuniors()
 {
     using (WebhostEntities db = new WebhostEntities())
     {
         Term           term    = db.Terms.Find(DateRange.GetCurrentOrLastTerm());
         List <Student> Juniors = db.Students.Where(s => s.isActive && s.GraduationYear == 2017).ToList();
         foreach (Student student in Juniors)
         {
             List <int> classes = student.Sections.Where(sec => sec.Terms.Contains(term)).Select(sec => sec.id).ToList();
             AttendanceControl.ExcuseStudent(student.ID, classes, "On the Junior Trip", ADUser.AttendanceBot, DateTime.Today);
             Console.WriteLine("Excused {0} {1} from {2} classes.", student.FirstName, student.LastName, classes.Count);
         }
     }
     Console.WriteLine("Done!");
     Console.ReadKey();
 }
        protected void SubmitBtn_Click(object sender, EventArgs e)
        {
            Dictionary <int, AttendanceControl.ShortMarking> MarkingData = new Dictionary <int, AttendanceControl.ShortMarking>();

            LogInformation("Submitting Attendance.");

            DateTime           date = TodayCB.Checked ? DateTime.Today : DateRange.GetDateTimeFromString(DateInput.Text);
            AttendancePageInfo api  = new AttendancePageInfo()
            {
                SectionId = this.SectionId, Name = ClassNameLabel.Text, Date = date, Attendances = new List <AttendanceData>()
            };

            foreach (TableRow row in AttendanceTable.Rows)
            {
                int studentId = Convert.ToInt32(((HiddenField)row.Cells[0].Controls[0]).Value);
                int markId    = Convert.ToInt32(((RadioButtonList)row.Cells[1].Controls[0]).SelectedValue);
                MarkingData.Add(studentId, new AttendanceControl.ShortMarking()
                {
                    markId = markId, notes = ""
                });
                AttendanceData atd = new AttendanceData()
                {
                    StudentId = studentId, Name = row.Cells[0].Text, Marking = ((RadioButtonList)row.Cells[1].Controls[0]).SelectedItem.Text
                };
                ((List <AttendanceData>)api.Attendances).Add(atd);
            }

            LogCurrentData(api);

            try
            {
                Dictionary <int, AttendanceControl.AdditionalInfoRequest> request = AttendanceControl.SubmitAttendance(SectionId, MarkingData, user.ID, date);
                if (request.Count != 0)
                {
                    Session["required_update_info"] = request;
                    AttendanceDate = date;
                    Redirect("~/Mobile/UpdateInformation.aspx");
                }

                Redirect(Request.RawUrl);
            }
            catch (WebhostException we)
            {
                SubmittedLabel.Text     = we.Message;
                SubmittedLabel.CssClass = "working_highlight";
            }
        }
Example #14
0
        static void ComplianceReport()
        {
            AttendanceControl.ComplianceReport().Save("C:\\Temp\\AttedanceCompliance.csv");
            using (WebhostEntities db = new WebhostEntities())
            {
                Faculty me           = db.Faculties.Find(67);
                int     studentCount = 0;
                foreach (Section section in me.Sections.Where(s => s.Course.AcademicYearID == 2016 && s.getsComments))
                {
                    Console.WriteLine("[{0}] {1} - {2}", section.Block.LongName, section.Course.Name, section.Students.Count);
                    studentCount += section.Students.Count;
                }

                Console.WriteLine("Total Students:  {0}", studentCount);
                Console.ReadKey();
            }
        }
        protected void SubmitBtn_Click(object sender, EventArgs e)
        {
            Dictionary <int, AttendanceControl.ShortMarking> MarkingData = new Dictionary <int, AttendanceControl.ShortMarking>();

            foreach (TableRow row in AttendanceTable.Rows)
            {
                int studentId = Convert.ToInt32(((HiddenField)row.Cells[0].Controls[0]).Value);
                int markId    = Convert.ToInt32(((DropDownList)row.Cells[1].Controls[0]).SelectedValue);
                MarkingData.Add(studentId, new AttendanceControl.ShortMarking()
                {
                    markId = markId, notes = ""
                });
            }
            DateTime date = TodayCB.Checked ? DateTime.Today : DateRange.GetDateTimeFromString(DateInput.Text);

            AttendanceControl.SubmitAttendance(SectionId, MarkingData, user.ID, date);
        }
        protected void LoadTable()
        {
            Dictionary <String, int> map    = MorningMeetingSeatClicker.MapMarkingToGradeTableEntry();
            Dictionary <int, String> revmap = new Dictionary <int, string>();

            foreach (String key in map.Keys)
            {
                revmap.Add(map[key], key);
            }

            using (WebhostEntities db = new WebhostEntities())
            {
                int     mmid           = AttendanceControl.MorningMeetingSectionId();
                Section morningmeeting = db.Sections.Where(sec => sec.id == mmid).Single();
                if (morningmeeting.SeatingCharts.Count <= 0)
                {
                    MailControler.MailToUser("Morning Meeting Seating Chart.", AttendanceControl.GenerateMorningMeetingSeatingChart(), ((BasePage)Page).user);
                }

                String       rows  = "ABCDEFGHIJKL";
                SeatingChart chart = db.Sections.Where(sec => sec.id == mmid).Single().SeatingCharts.ToList().First();
                foreach (SeatingChartSeat seat in chart.SeatingChartSeats.Where(s => s.StudentId.HasValue).ToList())
                {
                    String id = String.Format("{0}{1}", rows[seat.Row], seat.Column + 1);
                    seatControls.Where(sc => sc.ID.Equals(id)).Single().StudentId = seat.StudentId.Value;
                    seatControls.Where(sc => sc.ID.Equals(id)).Single().ToolTip   = String.Format("{0} {1}", seat.Student.FirstName, seat.Student.LastName);
                    if (morningmeeting.AttendanceMarkings.Where(mk => mk.AttendanceDate.Equals(SelectedDate) && mk.StudentID == seat.StudentId.Value).Count() > 0)
                    {
                        seatControls.Where(sc => sc.ID.Equals(id)).Single().Marking = revmap[morningmeeting.AttendanceMarkings.Where(mk => mk.AttendanceDate.Equals(SelectedDate) && mk.StudentID == seat.StudentId.Value).Single().MarkingIndex];
                    }
                    else
                    {
                        seatControls.Where(sc => sc.ID.Equals(id)).Single().Marking = "OK";
                    }
                }

                foreach (MorningMeetingSeatClicker clicker in seatControls)
                {
                    clicker.Enabled = clicker.StudentId != -1;
                }
            }
        }
Example #17
0
        protected void MarkBtn_Click(object sender, EventArgs e)
        {
            ((BasePage)Page).log.WriteLine("{0} Beginning Marking {1}", Log.TimeStamp(), NameLabel.Text);
            Dictionary <int, AttendanceControl.ShortMarking> mark = new Dictionary <int, AttendanceControl.ShortMarking>()
            {
                {
                    StudentId,
                    new AttendanceControl.ShortMarking()
                    {
                        markId = Convert.ToInt32(AttendanceDDL.SelectedValue),
                        notes  = ""
                    }
                }
            };

            MarkBtn.Text = "Checked In--Click to Update Status";

            AttendanceControl.SubmitAttendance(StudyHallId, mark, ((BasePage)Page).user.ID, Date);

            ((BasePage)Page).log.WriteLine("{0} Completed Marking {1} as {2}", Log.TimeStamp(), NameLabel.Text, AttendanceDDL.SelectedItem.Text);
        }
Example #18
0
        void SyncTimer_Elapsed(object sender, ElapsedEventArgs e)
        {
            ServiceEventLog.WriteEntry("Syncing Schoology Attendances.", EventLogEntryType.Information);
            long   ticks  = DateTime.Now.Ticks;
            String report = "";

            //this.CanStop = false;
            try
            {
                report = AttendanceControl.PullFromSchoology();
            }
            catch (SchoologyAPICall.SchoologyAPIException apiex)
            {
                String    Message = apiex.Message;
                Exception inner   = apiex.InnerException;
                while (inner != null)
                {
                    Message += Environment.NewLine + "________________________________________" + Environment.NewLine + inner.Message;
                }
                ServiceEventLog.WriteEntry(String.Format("API Call failed:{0}{1}", Environment.NewLine, Message), EventLogEntryType.Error);
                MailControler.MailToWebmaster("Schoology Sync Service Error", String.Format("Schoology Sync Service Failed with the following error:{0}{0}{1}", Environment.NewLine, Message));
            }
            catch (Exception ex)
            {
                String Message = ex.Message;
                while (ex.InnerException != null)
                {
                    ex       = ex.InnerException;
                    Message += Environment.NewLine + "________________________________________" + Environment.NewLine + ex.Message;
                }
                MailControler.MailToWebmaster("Schoology Sync Service Error", String.Format("Schoology Sync Service Failed with the following error:{0}{0}{1}", Environment.NewLine, Message));
                ServiceEventLog.WriteEntry(String.Format(Message), EventLogEntryType.Error);
            }
            //this.CanStop = true;
            ServiceEventLog.WriteEntry(report, EventLogEntryType.Information);
            ticks = DateTime.Now.Ticks - ticks;
            TimeSpan ts = new TimeSpan(ticks);

            ServiceEventLog.WriteEntry(String.Format("Syncronization Complete.  This Sync took {0}.", ts), EventLogEntryType.Information);
        }
        protected void SubmitBtn_Click(object sender, EventArgs e)
        {
            Dictionary <String, int> map = MorningMeetingSeatClicker.MapMarkingToGradeTableEntry();

            int mmid = AttendanceControl.MorningMeetingSectionId();

            Dictionary <int, AttendanceControl.ShortMarking> list = new Dictionary <int, AttendanceControl.ShortMarking>();

            foreach (MorningMeetingSeatClicker clicker in seatControls)
            {
                if (!clicker.Enabled || clicker.StudentId == -1)
                {
                    continue;
                }
                list.Add(clicker.StudentId, new AttendanceControl.ShortMarking()
                {
                    notes = "", markId = map[clicker.Marking]
                });
            }

            AttendanceControl.SubmitAttendance(mmid, list, 9997, SelectedDate);
        }
        protected void GetHalfTermAttendance_Click(object sender, EventArgs e)
        {
            DateRange dr;

            using (WebhostEntities db = new WebhostEntities())
            {
                // Select a term.

                DateTime midtermDate;
                try
                {
                    midtermDate = DateRange.GetDateTimeFromString(MidTermDateInput.Text);
                }
                catch (InvalidCastException)
                {
                    ((Default)Page.Master).ShowError("Invalid Date Range Selected.",
                                                     String.Format("Could not parse date from '{0}' to a valid DateTime.", MidTermDateInput.Text));
                    return;
                }

                List <Term> terms = db.Terms.Where(t => t.StartDate <midtermDate && t.EndDate> midtermDate).ToList();

                if (terms.Count < 1)
                {
                    return;
                }

                DateTime termdate = (BeforeOrAfter.SelectedIndex == 0) ? terms[0].StartDate : terms[0].EndDate;

                dr = new DateRange(midtermDate, termdate);
            }

            CSV quick = AttendanceControl.GetQuickOverview(dr);

            quick.Save(Server.MapPath("~/Temp/HalfTermAttendance.csv"));
            Response.Redirect("~/Temp/HalfTermAttendance.csv");
        }
Example #21
0
 protected void AttendanceDump_Click(object sender, EventArgs e)
 {
     AttendanceControl.AttendanceDump(new DateRange(DateRange.ThisFriday.AddDays(-7), DateRange.ThisFriday.AddDays(-1))).Save(Server.MapPath("~/Temp/AttendanceDump.csv"));
     Response.Redirect("~/Temp/AttendanceDump.csv");
 }
Example #22
0
 protected void MorningMeetingGenBtn_Click(object sender, EventArgs e)
 {
     TextEditor1.Html = AttendanceControl.GenerateMorningMeetingSeatingChart();
 }
 public AttendanceConnector(string tag, WorkTimeConnector parent, AttendanceControl control)
     : base(parent, control)
 {
     this.Tag = tag;
 }
        static void Main(string[] args)
        {
            var control = new StudentControl();

            var students = control.GetAllStudents();


            Console.WriteLine("Students\n-----------------------------------------------");
            foreach (var s in students)
            {
                Console.WriteLine("Name: " + s.People.FirstName + " " + s.People.LastName);
                foreach (var g in s.Grades)
                {
                    Console.WriteLine("Course: " + g.Courses.CourseName + " Grade: " + g.Grade);
                    Console.WriteLine("--------------------------------------------------------");
                }
            }

            var peopleCtx = new PeopleControl();

            //var people = peopleCtx.GetAllPeople();


            //// Insert
            //peopleCtx.InsertPeople(new People() { FirstName = "Algot", LastName = "Alfredsson", Email = "*****@*****.**" });

            //people.ToList().ForEach(x => Console.WriteLine($"{x.Id} {x.FirstName} {x.LastName} {x.Email}"));

            //Delete
            //var input = Console.ReadLine();

            //var toDelete = peopleCtx.PeopleByID(int.Parse(input));

            //peopleCtx.RemovePeople(toDelete);

            //var newPeople = peopleCtx.GetAllPeople();

            //newPeople.ToList().ForEach(x => Console.WriteLine($"{x.Id} {x.FirstName} {x.LastName} {x.Email}"));

            //Update
            //Console.WriteLine("id: ");
            //var nameID = Console.ReadLine();
            //Console.WriteLine("New Name:");
            //var namechange = Console.ReadLine();

            //var nameChangePerson = peopleCtx.PeopleByID(int.Parse(nameID));

            //nameChangePerson.FirstName = namechange;

            //peopleCtx.UpdatePeople(nameChangePerson);

            //var newPeople2 = peopleCtx.GetAllPeople();

            //newPeople2.ToList().ForEach(x => Console.WriteLine($"{x.Id} {x.FirstName} {x.LastName} {x.Email}"));

            //Insert Student
            var ppl = new People()
            {
                FirstName = "Lisa", LastName = "Sävås", Email = "Lisa@Sävås.se"
            };

            peopleCtx.InsertPeople(ppl);

            var studentClass = new StudentClasses()
            {
                ClassName = "WIN15"
            };

            var studentClassesCtx = new ClassesControl();

            studentClassesCtx.InsertorUpdateClass(studentClass);



            var educationCTX = new EducationsControl();

            var education = new Educations()
            {
                EducationName = "Administration"
            };

            educationCTX.InsertorUpdateEducation(education);


            var newStudent = new Students()
            {
                PersonId        = ppl.Id,
                StudentClass_Id = studentClass.Id,
                EducationId     = education.Id
            };

            control.InsertStudent(newStudent);

            var newStudentContext = new StudentControl();
            var studentsList      = newStudentContext.GetAllStudents().ToList();

            Console.WriteLine("Added new student Lisa");
            Console.WriteLine("-------Students Again-------");
            foreach (var stud in studentsList)
            {
                Console.WriteLine("Name: " + stud.People.FirstName + " " + stud.People.LastName);
                Console.WriteLine("CourseID: " + stud.StudentClasses.Id + " Class: " + stud.StudentClasses.ClassName);
                Console.WriteLine("ID: " + stud.Educations.Id + " Education Name: " + stud.Educations.EducationName);
                Console.WriteLine("--------------------------------------------------------------------------------");
            }

            var AttendanceControl = new AttendanceControl();

            Attendance att = new Attendance()
            {
                Date = new DateTime(2016, 11, 02), StudentID = newStudent.Id, CourseID = 2, Attendance1 = false
            };

            AttendanceControl.InsertAttendance(att);

            var lisa = newStudentContext.StudentsByID(newStudent.Id);

            var attendance = new AttendanceControl();

            var attendanceObj = attendance.AttendaceByStudentAndCourseID(newStudent.Id, 2);

            Console.WriteLine("Added new attendance for Lisa");
            Console.WriteLine("-----Attendance-----");
            Console.WriteLine($"{lisa.People.FirstName} {lisa.People.LastName} Närvaro i {attendanceObj.Courses.CourseName} den {attendanceObj.Date}: {attendanceObj.Attendance1}");
            Console.WriteLine();

            AttendanceControl.RemoveAttendance(att);
            //educationCTX.RemoveEducation(education);
            control.RemoveStudent(newStudent);
            studentClassesCtx.RemoveClass(studentClass);
            educationCTX.RemoveEducation(education);
            peopleCtx.RemovePeople(ppl);


            Console.ReadKey();
        }
 protected void SendEmail_Click(object sender, EventArgs e)
 {
     AttendanceControl.SendDetentionEmail(AttendanceControl.GetDetentionList(DateRange.ThisAttendanceWeek));
     ((Default)Page.Master).ShowSuccess("Detention Email has been Sent.", "");
 }
        protected void SubmitBtn_Click(object sender, EventArgs e)
        {
            LogInformation("Attempting To Submit an excused absence.");
            int studentId;

            try
            {
                studentId = Convert.ToInt32(StudentNameCBX.SelectedValue);
            }
            catch
            {
                ShowError("You must select a student to excuse.");
                return;
            }

            DateTime date = DateTime.Today;

            if (!TodayCB.Checked)
            {
                try
                {
                    date = DateRange.GetDateTimeFromString(DateInput.Text);
                }
                catch
                {
                    ShowError("Please select a date using the calendar.");
                    return;
                }
            }

            if (NotesInput.Text.Equals(""))
            {
                ShowError("You must enter a reason for the excused absence.");
                return;
            }

            List <int> selectedBlocks = new List <int>();

            foreach (ListItem item in BlocksCBL.Items)
            {
                if (item.Selected)
                {
                    selectedBlocks.Add(Convert.ToInt32(item.Value));
                }
            }

            using (WebhostEntities db = new WebhostEntities())
            {
                List <int> sectionIds = new List <int>();
                Term       theTerm    = null;

                foreach (Term term in db.Terms)
                {
                    DateRange termrange = new DateRange(term.StartDate, term.EndDate);
                    if (termrange.Contains(date))
                    {
                        theTerm = term;
                        break;
                    }
                }

                if (theTerm == null)
                {
                    ShowError("The selected Date is not in any Term.");
                    return;
                }

                foreach (int blkid in selectedBlocks)
                {
                    Block block = db.Blocks.Where(b => b.id == blkid).Single();
                    foreach (Section section in block.Sections.Where(sec => sec.Terms.Contains(theTerm)).ToList())
                    {
                        if (section.Students.Where(stu => stu.ID == studentId).Count() > 0)
                        {
                            sectionIds.Add(section.id);
                        }
                    }
                }

                if (MultiDayCB.Checked)
                {
                    DateTime end = new DateTime();
                    try
                    {
                        end = DateRange.GetDateTimeFromString(EndDateInput.Text);
                    }
                    catch
                    {
                        ShowError("Please select the End Date from the calendar.");
                        return;
                    }

                    String report = AttendanceControl.ExcuseStudent(studentId, sectionIds, NotesInput.Text, ((BasePage)Page).user, new DateRange(date, end));
                    State.log.WriteLine(report);
                }
                else
                {
                    String report = AttendanceControl.ExcuseStudent(studentId, sectionIds, NotesInput.Text, ((BasePage)Page).user, date);
                    State.log.WriteLine(report);
                }

                LogInformation("Excused attendance submitted for student id {0}.  See Webhost MySQL Connection log for details.", studentId);
            }
        }