public virtual CrystalDecisions.CrystalReports.Engine.ReportDocument CreateReport()
 {
     rptCalculationSheetTyping rpt = new rptCalculationSheetTyping();
     rpt.Site = this.Site;
     return rpt;
 }
Example #2
0
        private void button3_Click(object sender, EventArgs e)
        {
            if (listView1.SelectedItems.Count == 0)
            {
                MessageBox.Show("Please select an enrollment");
                return;
            }
            if (listView2.SelectedItems.Count == 0)
            {
                MessageBox.Show("Please select a subject");
                return;
            }
            var splitter = clsFunctions.SplitByString(listView1.SelectedItems[0].SubItems[1].Text, "-");
            if (listView2.SelectedItems[0].SubItems[2].Text != "PROJ")
            {
                if (listView4.Items.Count == 0)
                {
                    MessageBox.Show("Please select valid exam version and try again.", "Select Exam");
                    return;
                }
                var examsWritten = false;
                foreach (ListViewItem theItem in listView4.Items)
                {
                    if (theItem.SubItems[2].Text != "")
                        examsWritten = true;
                }
                if (!examsWritten)
                {
                    MessageBox.Show(
                        "No Exams of this version have been written. Please Enter results or choose a different version",
                        "No Exam Results");
                    return;
                }
            }
            if ((label11.Visible && label11.Text == "*This components marks have already been moderated") ||
                (label10.Visible && label10.Text == "*This components marks have already been moderated"))
            {
                if (clsFunctions.CheckRights("6") && MessageBox.Show("Do you want to send the marks for moderation again?", "Mark for Moderation", MessageBoxButtons.YesNo) == DialogResult.Yes)
                {
                    Database.Command("UPDATE enrollmentcomponents SET moderated = 'no' WHERE idEnrollments = '" +
                                         splitter[1] +
                                         "' and idCourseComponents = '" +
                                         listView2.SelectedItems[0].Text + "'");
                    clsFunctions.WriteLog("Subject sent for re-moderation. Learner Number: " + learnerNumberTextBox.Text + " Division: " + GlobalProperties.LoggedOnUserDivision + " Subject: " + listView2.SelectedItems[0].Text);
                }
                else
                {
                }
            }
            else
            {

                Moderate();
                if ((Database.Retrieve("components", "idCourseComponents = '" + listView2.SelectedItems[0].Text + "'", "ComponentAbrev") != "PROJ"))
                    if (
                        MessageBox.Show("Marks Processed. Would you like to view a calculation sheet?", "Calculation Sheet",
                                        MessageBoxButtons.YesNo) == DialogResult.No)
                    {
                        Database.Command("UPDATE enrollmentcomponents SET printed = 'yes' WHERE idEnrollments = '" +
                                         splitter[1] +
                                         "' and idCourseComponents = '" +
                                         listView2.SelectedItems[0].Text + "'");
                        return;
                    }
            }

            if (System.Text.RegularExpressions.Regex.IsMatch(listView2.SelectedItems[0].SubItems[1].Text, ".*Typing.*") ||
                System.Text.RegularExpressions.Regex.IsMatch(listView2.SelectedItems[0].SubItems[1].Text, ".*ATS.*"))
            {
                Database.Command("UPDATE enrollmentcomponents SET printed = 'yes' WHERE idEnrollments = '" +
                                     splitter[1] +
                                     "' and idCourseComponents = '" +
                                     listView2.SelectedItems[0].Text + "'");
                var results =
                   Database.Query(
                       "components a LEFT OUTER JOIN results b ON a.idCourseComponents=b.idCourseComponents",
                       "a.idCourseComponents LIKE '" + listView4.SelectedItems[0].SubItems[5].Text + "-%' AND idEnrollments = '" +
                       splitter[1] + "' AND b.active is Null");
                var learner = Database.Row("learner_details a, enrollments b",
                                           "a.LearnerKey = b.LearnerKey AND idEnrollments = '" + Convert.ToString(results.Tables[0].Rows[0]["idEnrollments"]) +
                                           "'");
                var course = Database.Row("components a, enrollmentcomponents b", "a.idCourseComponents = '" +
                    listView2.SelectedItems[0].Text + "' AND a.idCourseComponents = b.idCourseComponents AND idEnrollments ='" +
                    splitter[1] + "'");
                //results.WriteXmlSchema(@"c:\schema.xml");
                var report = new rptCalculationSheetTyping();
                report.SetDataSource(results);
                report.DataDefinition.FormulaFields["learnerNumber"].Text = "\"" + learnerNumberTextBox.Text + "\"";
                report.DataDefinition.FormulaFields["learnerName"].Text = "\"" + Convert.ToString(learner["Name"]) + " " + Convert.ToString(learner["Surname"]) + "\"";
                report.DataDefinition.FormulaFields["bookSerial"].Text = "\"" + textBox2.Text + "\"";
                report.DataDefinition.FormulaFields["course"].Text = "\"" + listView2.SelectedItems[0].SubItems[1].Text + "\"";
                report.DataDefinition.FormulaFields["practicalWeight"].Text = "\"" + Convert.ToString(course["practicalWeight"]) + "\"";
                report.DataDefinition.FormulaFields["assWeight"].Text = "\"" + Convert.ToString(course["finalWeight"]) + "\"";
                report.DataDefinition.FormulaFields["finalPerc"].Text = "\"" + Convert.ToString(course["result"]) + "\"";
                report.DataDefinition.FormulaFields["finalOutcome"].Text = "\"" + Convert.ToString(course["outcome"]) + "\"";
                var frmReport = new frmReport(report) { Text = "Calculation Sheet" };
                frmReport.ShowDialog();
            }
            else
            {
                if (listView2.SelectedItems[0].SubItems[2].Text == "SC")
                {
                    var results =
                        Database.Query(
                            "components a RIGHT OUTER JOIN results b ON a.idCourseComponents=b.idCourseComponents JOIN components c on c.idCourseComponents = a.myParent",
                            "((NOT(a.ComponentAbrev = 'EXV' OR a.ComponentAbrev = 'EX' OR a.ComponentAbrev = 'DIV') AND a.idCourseComponents LIKE '" +
                            listView2.SelectedItems[0].Text +
                            "-%')OR((a.ComponentAbrev = 'EXV' OR a.ComponentAbrev = 'EX' OR a.ComponentAbrev = 'DIV')AND a.idCourseComponents LIKE '" +
                            listView4.SelectedItems[0].SubItems[5].Text + "-%')) AND idEnrollments = '" +
                            splitter[1] + "' AND b.active is Null ORDER BY CONCAT(c.Name,' - ',a.Name)", @"a.idCourseComponents, a.ComponentAbrev, CONCAT(c.Name,' - ',a.Name) as Name, a.myParent,
                                                                      a.totalMark, b.result, b.`Date`, b.capturedDate, b.outcome, b.idEnrollments", true,
                                                                                                                                                  "myTable");
                    var learner = Database.Row("learner_details a, enrollments b",
                                               "a.LearnerKey = b.LearnerKey AND idEnrollments = '" +
                                               Convert.ToString(results.Tables[0].Rows[0]["idEnrollments"]) +
                                               "'");
                    var course = Database.Row("components a, enrollmentcomponents b", "a.idCourseComponents = '" +
                                                                                      listView2.SelectedItems[0].Text +
                                                                                      "' AND a.idCourseComponents = b.idCourseComponents AND idEnrollments = '" +
                                                                                      splitter[1] + "'");
                    //results.WriteXmlSchema(@"c:\schema.xml");
                    var report = new rptCalculationSheet();
                    report.SetDataSource(results);
                    report.DataDefinition.FormulaFields["learnerNumber"].Text = "\"" + learnerNumberTextBox.Text + "\"";
                    report.DataDefinition.FormulaFields["learnerName"].Text = "\"" + Convert.ToString(learner["Name"]) +
                                                                              " " + Convert.ToString(learner["Surname"]) +
                                                                              "\"";
                    report.DataDefinition.FormulaFields["bookSerial"].Text = "\"" + textBox2.Text + "\"";
                    report.DataDefinition.FormulaFields["course"].Text = "\"" +
                                                                         listView2.SelectedItems[0].SubItems[1].Text +
                                                                         " - " + listView2.SelectedItems[0].SubItems[0].Text + "\"";
                    report.DataDefinition.FormulaFields["practicalWeight"].Text = "\"" +
                                                                                  Convert.ToString(
                                                                                      course["practicalWeight"]) + "\"";
                    report.DataDefinition.FormulaFields["assWeight"].Text = "\"" +
                                                                            Convert.ToString(course["finalWeight"]) +
                                                                            "\"";
                    report.DataDefinition.FormulaFields["finalPerc"].Text = "\"" + Convert.ToString(course["result"]) +
                                                                            "\"";
                    report.DataDefinition.FormulaFields["finalOutcome"].Text = "\"" +
                                                                               Convert.ToString(course["outcome"]) +
                                                                               "\"";
                    var frmReport = new frmReport(report) {Text = "Calculation Sheet"};
                    frmReport.ShowDialog();
                }
                else if (listView2.SelectedItems[0].SubItems[2].Text == "PROJ")
                {
                    var summative = Database.Query("results_summative",
                                                   "idEnrollments = '" + splitter[1] + "' AND idCourseComponents = '" +
                                                   listView2.SelectedItems[0].Text + "'");
                    if (!label10.Visible && !label11.Visible)
                    {
                        var summativeForm = new frmSummative(listView2.SelectedItems[0].Text, Convert.ToInt32(splitter[1]));
                        summativeForm.ShowDialog();
                        if (summativeForm.status == false)
                            return;
                        summative = Database.Query("results_summative",
                                                   "idEnrollments = '" + splitter[1] + "' AND idCourseComponents = '" +
                                                   listView2.SelectedItems[0].Text + "'");

                    }

                    var results =
                        Database.Query("components a LEFT OUTER JOIN results b ON a.idCourseComponents=b.idCourseComponents",
                            "a.myParent = '" + listView2.SelectedItems[0].Text +
                            "' AND NOT a.idCourseComponents = a.MyParent AND idEnrollments = '" +
                            splitter[1] + "'","idEnrollments, Name, totalMark, Result, Attempt, if(capturedDate, capturedDate, `Date`) as `Date`");

                    var learner = Database.Row("learner_details a, enrollments b",
                                               "a.LearnerKey = b.LearnerKey AND idEnrollments = '" +
                                               Convert.ToString(results.Tables[0].Rows[0]["idEnrollments"]) +
                                               "'");
                    DataRow summativeRow;
                    try
                    {
                        summativeRow = summative.Tables[0].Rows[0];
                    }
                    catch
                    {
                        MessageBox.Show("No Summative Assessment Request has been saved. Please complete this first.");
                        return;
                    }
                    var report = new rptProjCalcSheet();
                    report.SetDataSource(results);

                    report.DataDefinition.FormulaFields["learnerNumber"].Text = "\"" + learnerNumberTextBox.Text + "\"";
                    report.DataDefinition.FormulaFields["learnerName"].Text = "\"" + Convert.ToString(learner["Name"]) +
                                                                              "\"";
                    report.DataDefinition.FormulaFields["learnerSurname"].Text = "\"" +
                                                                                 Convert.ToString(learner["Surname"]) +
                                                                                 "\"";
                    report.DataDefinition.FormulaFields["learnerID"].Text = "\"" + Convert.ToString(learner["ID"]) +
                                                                            "\"";
                    report.DataDefinition.FormulaFields["course"].Text = "\"" +
                                                                         listView2.SelectedItems[0].SubItems[1].Text +
                                                                         "\"";
                    report.DataDefinition.FormulaFields["ProjNum"].Text = "\"" +
                                                                         listView2.SelectedItems[0].SubItems[0].Text +
                                                                         "\"";
                    report.DataDefinition.FormulaFields["college"].Text = "\"" + GlobalProperties.LoggedOnUserDivision + "\"";

                    report.DataDefinition.FormulaFields["date"].Text = "\"" +
                                                                       (Convert.ToDateTime(summativeRow["date"])).
                                                                           ToString("dd/MM/yyy") + "\"";
                    report.DataDefinition.FormulaFields["assessor"].Text = "\"" +
                                                                           Convert.ToString(summativeRow["assesor"]) +
                                                                           "\"";
                    report.DataDefinition.FormulaFields["assessorReg"].Text = "\"" +
                                                                              Convert.ToString(
                                                                                  summativeRow["assesorReg"]) + "\"";
                    report.DataDefinition.FormulaFields["moderator"].Text = "\"" +
                                                                            Convert.ToString(summativeRow["moderator"]) +
                                                                            "\"";
                    report.DataDefinition.FormulaFields["moderatorReg"].Text = "\"" +
                                                                               Convert.ToString(
                                                                                   summativeRow["moderatorReg"]) + "\"";
                    report.DataDefinition.FormulaFields["comments"].Text = "\"" +
                                                                           Convert.ToString(
                                                                               summativeRow["facilitatorRemarks"]) +
                                                                           "\"";

                    report.DataDefinition.FormulaFields["projEvalDate"].Text = "\"" +
                                                                               (Convert.ToDateTime(
                                                                                   summativeRow["projEvalDate"])).
                                                                                   ToString("dd/MM/yyy") + "\"";
                    report.DataDefinition.FormulaFields["projEvalCom"].Text = "\"" +
                                                                              Convert.ToString(
                                                                                  summativeRow["projEvalComment"]) +
                                                                              "\"";
                    report.DataDefinition.FormulaFields["workbookDate"].Text = "\"" +
                                                                               (Convert.ToDateTime(
                                                                                   summativeRow["workbookErrateDate"])).
                                                                                   ToString("dd/MM/yyy") + "\"";
                    report.DataDefinition.FormulaFields["workbookCom"].Text = "\"" +
                                                                              Convert.ToString(
                                                                                  summativeRow["workbookErrataComment"]) +
                                                                              "\"";
                    report.DataDefinition.FormulaFields["recordDate"].Text = "\"" +
                                                                             (Convert.ToDateTime(
                                                                                 summativeRow["recordComDate"])).
                                                                                 ToString("dd/MM/yyy") + "\"";
                    report.DataDefinition.FormulaFields["recordCom"].Text = "\"" +
                                                                            Convert.ToString(
                                                                                summativeRow["recordComComment"]) + "\"";
                    report.DataDefinition.FormulaFields["learnerDate"].Text = "\"" +
                                                                              (Convert.ToDateTime(
                                                                                  summativeRow["learnerGuideErrataDate"]))
                                                                                  .ToString("dd/MM/yyy") + "\"";
                    report.DataDefinition.FormulaFields["learnerCom"].Text = "\"" +
                                                                             Convert.ToString(
                                                                                 summativeRow[
                                                                                     "learnerGuideErrataComment"]) +
                                                                             "\"";
                    report.DataDefinition.FormulaFields["formativeDate"].Text = "\"" +
                                                                                (Convert.ToDateTime(
                                                                                    summativeRow["formAssDate"])).
                                                                                    ToString("dd/MM/yyy") + "\"";
                    report.DataDefinition.FormulaFields["formativeCom"].Text = "\"" +
                                                                               Convert.ToString(
                                                                                   summativeRow["formAssComment"]) +
                                                                               "\"";
                    report.DataDefinition.FormulaFields["summaryDate"].Text = "\"" +
                                                                              (Convert.ToDateTime(
                                                                                  summativeRow["summaryDate"])).ToString
                                                                                  ("dd/MM/yyy") + "\"";
                    report.DataDefinition.FormulaFields["summaryCom"].Text = "\"" +
                                                                             Convert.ToString(
                                                                                 summativeRow["summaryComment"]) + "\"";
                    report.DataDefinition.FormulaFields["portfolioDate"].Text = "\"" +
                                                                                (Convert.ToDateTime(
                                                                                    summativeRow["portfolioDate"])).
                                                                                    ToString("dd/MM/yyy") + "\"";
                    report.DataDefinition.FormulaFields["portfolioCom"].Text = "\"" +
                                                                               Convert.ToString(
                                                                                   summativeRow["portfolioComment"]) +
                                                                               "\"";
                    report.DataDefinition.FormulaFields["ccfoDate"].Text = "\"" +
                                                                           (Convert.ToDateTime(summativeRow["ccfoDate"]))
                                                                               .ToString("dd/MM/yyy") + "\"";
                    report.DataDefinition.FormulaFields["ccfoCom"].Text = "\"" +
                                                                          Convert.ToString(summativeRow["ccfoComment"]) +
                                                                          "\"";
                    var frmReport = new frmReport(report) {Text = "Summative Judgement Request"};
                    frmReport.ShowDialog();

                    //results.WriteXmlSchema(@"c:\schema.xml");
                }
                Database.Command("UPDATE enrollmentcomponents SET printed = 'yes' WHERE idEnrollments = '" +
                                     splitter[1] +
                                     "' and idCourseComponents = '" +
                                     listView2.SelectedItems[0].Text + "'");

            }
        }