Exemple #1
0
        TableRow addCountRow(SaskSubmittedSchoolCount entry)
        {
            TableRow newRow = new TableRow();

            TableCell nameCell      = new TableCell();
            TableCell countCell     = new TableCell();
            TableCell successesCell = new TableCell();
            TableCell failuresCell  = new TableCell();

            nameCell.Text      = entry.schoolName;
            countCell.Text     = entry.totalCount.ToString();
            successesCell.Text = entry.successes.ToString();
            failuresCell.Text  = entry.failures.ToString();

            newRow.Cells.Add(nameCell);
            newRow.Cells.Add(successesCell);
            newRow.Cells.Add(failuresCell);
            newRow.Cells.Add(countCell);

            return(newRow);
        }
Exemple #2
0
        protected void Page_Load(object sender, EventArgs e)
        {
            // Populate school dropdown list
            // Load school counts
            List <SkSubmittedEntry> allEntries = new List <SkSubmittedEntry>();
            List <School>           allSchools = new List <School>();

            using (SqlConnection connection = new SqlConnection(LSKYCommon.dbConnectionString_SchoolLogic))
            {
                allSchools = School.loadAllSchools(connection);

                foreach (School school in allSchools)
                {
                    ListItem newItem = new ListItem();
                    newItem.Text  = school.getName();
                    newItem.Value = school.getGovID().ToString();
                    drpSchoolList.Items.Add(newItem);
                }

                allEntries = SkSubmittedEntry.loadAllSaskSubmittedEntries(connection);
            }

            //Dictionary<string, int> schoolsWithCounts = new Dictionary<string, int>();

            List <SaskSubmittedSchoolCount> schoolsWithCounts = new List <SaskSubmittedSchoolCount>();

            int totalCount     = 0;
            int totalSuccesses = 0;
            int totalFailures  = 0;

            foreach (School school in allSchools)
            {
                int thisSchoolCount    = 0;
                int thisSchoolSuccess  = 0;
                int thisSchoolFailures = 0;

                foreach (SkSubmittedEntry entry in allEntries)
                {
                    if (entry.schoolID == int.Parse(school.getSchoolLogicID()))
                    {
                        thisSchoolCount++;
                        totalCount++;

                        if (entry.failed)
                        {
                            thisSchoolFailures++;
                            totalFailures++;
                        }
                        else
                        {
                            thisSchoolSuccess++;
                            totalSuccesses++;
                        }
                    }
                }

                if (thisSchoolCount > 0)
                {
                    schoolsWithCounts.Add(new SaskSubmittedSchoolCount(school.getName(), thisSchoolCount, thisSchoolFailures, thisSchoolSuccess));
                }
            }


            SaskSubmittedSchoolCount totals = new SaskSubmittedSchoolCount("<b>Totals</b>", totalCount, totalFailures, totalSuccesses);

            tblCounts.Rows.Add(addCountRow(totals));

            foreach (SaskSubmittedSchoolCount entry in schoolsWithCounts)
            {
                tblCounts.Rows.Add(addCountRow(entry));
            }
        }