Example #1
0
 private void button13_Click(object sender, EventArgs e)
 {
     if (comboBox2.Text.Length == 0)
     {
         MessageBox.Show("Please select a group to add the user to from the drop down box", "Select Group");
         return;
     }
     var colleges = new ArrayList();
     var tempDS = Database.Retrieve("users");
     foreach (DataRow theRow in tempDS.Tables["users"].Rows)
     {
         colleges.Add(theRow["username"]);
     }
     var tempSelect = new frmSelectSingle("Transfer Learner", "Select College", colleges);
     tempSelect.ShowDialog();
     if (tempSelect.Selection == "***")
         return;
     Database.Command("INSERT INTO users_groups(idUserGroups,idUsers) VALUES('" +
         Database.Retrieve("userGroups","name = '" + comboBox2.Text + "'","idUserGroups") + "','" +
         Database.Retrieve("users", "Username = '******'", "idUsers") + "')");
     var x1 = listView3.Items.Add(tempSelect.Selection);
     x1.ImageIndex = 0;
 }
Example #2
0
        private void barButtonItem19_ItemClick(object sender, ItemClickEventArgs e)
        {
            var number = new frmSubmitText("Learner Number", "Please enter learner number");
            number.ShowDialog();
            while (Database.Count("learner_details", "LearnerNumber = '" + number.Selection + "' AND Division = '" +
                GlobalProperties.loggedOnUserDivison + "'") == 0)
            {
                if (number.Selection == "***")
                    return;
                MessageBox.Show("Invalid Learner Number", "Error");
                number.ShowDialog();
            }
            var reason = new frmSubmitText("Reason", "Please enter reason for course change");
            reason.ShowDialog();
            var list = new ArrayList();
            var courses = Database.Query("courses", "Not Type = 'CC'");
            foreach (DataRow theRow in courses.Tables["courses"].Rows)
            {
                list.Add(theRow["Name"]);
            }
            var frmSelect = new frmSelectSingle("Select Course", "New Course to Enroll In", list);
            frmSelect.ShowDialog();
            if (frmSelect.Selection == "***" || reason.Selection == "***")
                return;
            var report = new rptCourseChange();
            var data =
                Database.Row(@"SELECT *
            FROM learner_details a JOIN enrollments b ON b.LearnerKey = a.LearnerKey
            LEFT JOIN  enrollmentscourses c ON c.idEnrollments = b.idEnrollments
            LEFT JOIN courses d ON d.idCourses = c.idCourses
            WHERE a.Division = '" + GlobalProperties.loggedOnUserDivison + "' AND a.LearnerNumber = '" +
                               number.Selection + "' AND d.Type <> 'CC'");
            if (data == null)
            {
                data =
                Database.Row(@"SELECT *
            FROM learner_details a JOIN enrollments b ON b.LearnerKey = a.LearnerKey
            LEFT JOIN  enrollmentscourses c ON c.idEnrollments = b.idEnrollments
            LEFT JOIN courses d ON d.idCourses = c.idCourses
            WHERE a.Division = '" + GlobalProperties.loggedOnUserDivison + "' AND a.LearnerNumber = '" +
                               number.Selection + "'");
            }

            report.DataDefinition.FormulaFields["date"].Text = "\"" + DateTime.Now.ToLongDateString() + "\"";
            report.DataDefinition.FormulaFields["college"].Text = "\"" + GlobalProperties.LoggedOnUserDivision + "\"";
            report.DataDefinition.FormulaFields["principle"].Text = "\"" + GlobalProperties.DivisionPrinciple + "\"";
            report.DataDefinition.FormulaFields["learnerNumber"].Text = "\"" + number.Selection + "\"";
            report.DataDefinition.FormulaFields["reason"].Text = "\"" + reason.Selection + "\"";
            report.DataDefinition.FormulaFields["currentProgramme"].Text = "\"" + Convert.ToString(data["Name1"]) + "\"";
            report.DataDefinition.FormulaFields["learnerName"].Text = "\"" + Convert.ToString(data["Name"]) + " " +
                                                                      Convert.ToString(data["Surname"]) + "\"";
            report.DataDefinition.FormulaFields["newProgram"].Text = "\"" + frmSelect.Selection + "\"";
            //report.DataDefinition.FormulaFields["course"].Text = "\"" + Convert.ToString(data["Name1"]) + "\"";

            //logs.WriteXml(@"C:\tmpXml.xml");
            var frmReport = new frmReport(report) { Text = "Cancellation Request" };
            frmReport.ShowDialog();
        }
Example #3
0
 private void collegeButton_ItemClick(object sender, ItemClickEventArgs e)
 {
     var data = Database.Query("SELECT divisionAbrev FROM division");
     var myList = new ArrayList();
     foreach (DataRow theRow in data.Tables[0].Rows)
     {
         myList.Add(theRow["divisionAbrev"]);
     }
     var theForm = new frmSelectSingle("Colleges:", "Select College", myList);
     theForm.ShowDialog();
     if (theForm.Selection == "***")
         return;
     GlobalProperties.loggedOnUserDivison = theForm.Selection;
 }
Example #4
0
        private void barButtonItem23_ItemClick(object sender, ItemClickEventArgs e)
        {
            var number = new frmSubmitText("Learner Number", "Please enter learner number");
            number.ShowDialog();
            while (Database.Count("learner_details", "LearnerNumber = '" + number.Selection + "' AND Division = '" +
                GlobalProperties.loggedOnUserDivison + "'") == 0)
            {
                if (number.Selection == "***")
                    return;
                MessageBox.Show("Invalid Learner Number", "Error");
                number.ShowDialog();
            }
            var response = InputDialog.Show("Contact Details", "Enter learner contact number:");
            if (response.Result != DialogResult.OK)
            {
                return;
            }
            var divisions = Database.Retrieve("division");
            var theList = new ArrayList();
            foreach (DataRow theRow in divisions.Tables[0].Rows)
            {
                theList.Add(Convert.ToString(theRow["DivisionName"]));
            }
            var select = new frmSelectSingle("Division", "Please select new UCO branch", theList);
            select.ShowDialog();
            //var report = new rptTransfer();
            DataSet data;
            try
            {
                data =
                    Database.Query(@"SELECT *
            FROM learner_details a LEFT JOIN enrollments b on b.LEarnerKEy = a.LearnerKey
            LEFT JOIN enrollmentscourses c on c.idEnrollments = b.idEnrollments
            LEFT JOIN courses d on d.idCourses = c.idCourses
            LEFT JOIN paymentinfo e ON e.idEnrollments = b.idEnrollments
            WHERE a.Division = '" + GlobalProperties.loggedOnUserDivison + "' AND a.LearnerNumber = '" +
                                   number.Selection + @"'
            AND (d.Type <> 'CC' OR d.Type IS NULL) LIMIT 1");
                //data.WriteXml(@"C:\LAD_DATA_DUMP\transfer.xml",XmlWriteMode.WriteSchema);
            }
            catch
            {
                MessageBox.Show("There is an error with this learner's enrollment. Please correct before trying to redo the transaction.");
                return;
            }
            var report = new rptTransfer();
            report.transferLable.Text = select.Selection;
            report.responsibleClarkLabel.Text = GlobalProperties.loggedOnUser;
            report.contactNumberLabel.Text = response.Submission;
            report.divisionLabel.Text = GlobalProperties.LoggedOnUserDivision;
                //report.DataDefinition.FormulaFields["learnerNumber"].Text = "\"" + number.Selection + "\"";
                //report.DataDefinition.FormulaFields["transferBranch"].Text = "\"" + select.Selection + "\"";
                //report.DataDefinition.FormulaFields["learnerName"].Text = "\"" + Convert.ToString(data["Name"]) + " " +
                //                                                          Convert.ToString(data["Surname"]) + "\"";
                //report.DataDefinition.FormulaFields["learnerTel"].Text = "\"" + response.Submission + "\"";
                //report.DataDefinition.FormulaFields["Date"].Text = "\"" + DateTime.Now.ToString("dd/MM/yyyy") + "\"";
                //report.DataDefinition.FormulaFields["Branch"].Text = "\"" + clsGlobal.LoggedOnUserDivision + "\"";
                //report.DataDefinition.FormulaFields["clerk"].Text = "\"" + clsGlobal.LoggedOnUser + "\"";
                //report.DataDefinition.FormulaFields["course"].Text = "\"" + Convert.ToString(data["Name1"]) + "\"";
                //report.DataDefinition.FormulaFields["coursePrice"].Text = "\"" + Convert.ToString(data["totalContractPrice"]) + "\"";
                //report.DataDefinition.FormulaFields["course"].Text = "\"" + Convert.ToString(data["Name1"]) + "\"";

            //logs.WriteXml(@"C:\tmpXml.xml");
            report.DataSource = data;
            report.ShowPreviewDialog();
        }
Example #5
0
        private void barButtonItem20_ItemClick(object sender, ItemClickEventArgs e)
        {
            var number = new frmSubmitText("Learner Number", "Please enter learner number");
            number.ShowDialog();
            while (Database.Count("learner_details", "LearnerNumber = '" + number.Selection + "' AND Division = '" +
                GlobalProperties.loggedOnUserDivison + "'") == 0)
            {
                if (number.Selection == "***")
                    return;
                MessageBox.Show("Invalid Learner Number", "Error");
                number.ShowDialog();
            }
            var enrollments = Database.Query("learner_details a, enrollments b",
                               "a.Division = '" + GlobalProperties.loggedOnUserDivison + "' AND a.LearnerNumber = '" +
                               number.Selection + "' AND b.LearnerKey = a.LearnerKey");
            var myList = new ArrayList();
            foreach (DataRow theRow in enrollments.Tables[0].Rows)
            {
                try
                {
                    myList.Add((string)("ENR" + theRow["idEnrollments"] + " - " + ((DateTime)theRow["regDate1"]).ToString("dd/MM/yyyy")));
                }
                catch
                {
                }
            }
            var theList = new frmSelectSingle("Please Select Enrollment","Select Enrollment",myList);
            theList.ShowDialog();
            if (theList.Selection == "***")
                return;
            string[] theEnrollment = theList.Selection.Split(new string[] {" - "},StringSplitOptions.RemoveEmptyEntries);
            var endDateSelect = new frmSubmitDate("Submit Date", "Please submit end of studies date:");
            endDateSelect.ShowDialog();
            if (endDateSelect.status == false)
                return;
            var report = new rptDiplomaRequest();

            var data =
                Database.Query("learner_details a, enrollments b, enrollmentscourses c, courses d",
                               "a.Division = '" + GlobalProperties.loggedOnUserDivison + "' AND a.LearnerNumber = '" +
                               number.Selection + "' AND b.LearnerKey = a.LearnerKey AND c.idEnrollments = b.idEnrollments AND" +
                               " d.idCourses = c.idCourses AND b.idEnrollments = " + theEnrollment[0].Replace("ENR","") + " ORDER BY d.Type DESC LIMIT 1");
            report.startDateLabel.Text = theEnrollment[1];
            report.endDateTraining.Text = endDateSelect.Selection.ToString("dd/MM/yyyy");
            report.prinicipleLabel.Text = GlobalProperties.DivisionPrinciple;

            report.DataSource = data;
            report.ShowPreviewDialog();
            //data.WriteXml(@"C:\LAD_DATA_DUMP\diploma.xml", XmlWriteMode.WriteSchema);
            //report.DataDefinition.FormulaFields["date"].Text = "\"" + DateTime.Now.ToLongDateString() + "\"";
            //report.DataDefinition.FormulaFields["startdate"].Text = "\"" + theEnrollment[1] + "\"";
            //report.DataDefinition.FormulaFields["enddate"].Text = "\"" + endDateSelect.Selection.ToString("dd/MM/yyyy") + "\"";
            //report.DataDefinition.FormulaFields["college"].Text = "\"" + clsGlobal.LoggedOnUserDivision + "\"";
            //report.DataDefinition.FormulaFields["learnerNumber"].Text = "\"" + number.Selection + "\"";
            //report.DataDefinition.FormulaFields["principle"].Text = "\"" + clsGlobal.DivisionPrinciple + "\"";
            //report.DataDefinition.FormulaFields["learnerName"].Text = "\"" + Convert.ToString(data["Name"]) + "\"";
            //report.DataDefinition.FormulaFields["surname"].Text = "\"" + Convert.ToString(data["Surname"]) + "\"";
            //report.DataDefinition.FormulaFields["diplomaName"].Text = "\"" + Convert.ToString(data["Name1"]) + "\"";
            //report.DataDefinition.FormulaFields["respParty"].Text = "\"" + clsGlobal.loggedOnUser + "\"";

            ////report.DataDefinition.FormulaFields["course"].Text = "\"" + Convert.ToString(data["Name1"]) + "\"";

            ////data.WriteXml(@"C:\LAD_DATA_DUMP\tmpXml.xml");
            //var frmReport = new frmReport(report) { Text = "Diploma Request" };
            //frmReport.ShowDialog();
        }
Example #6
0
        private void addShortCourseToolStripMenuItem_Click(object sender, EventArgs e)
        {
            var colleges = new ArrayList();

            var tempDS = Database.Query("Components", "(ComponentAbrev = 'PROJ' OR ComponentAbrev = 'SC') AND singleSubject = 1" +
            " ORDER BY Name");
            foreach (DataRow theRow in tempDS.Tables["Components"].Rows)
            {
                colleges.Add(Convert.ToString(theRow["Name"]) + " - " + Convert.ToString(theRow["idCourseComponents"]));
            }
            var tempSelect = new frmSelectSingle("Replace Course", "Select Course", colleges);
            tempSelect.ShowDialog();
            if (tempSelect.Selection == "***")
                return;
            string[] separate = { " - " };
            string[] select = tempSelect.Selection.Split(separate, StringSplitOptions.None);
            addComponent(txtID.Text, select[1]);
            try
            {
                var split = SplitByString(trvCourses.SelectedNode.Text, " - ");
                var component = Database.Query("SELECT * FROM courseComponents cc JOIN components c ON c.idCourseComponents = cc.idComponents" +
                                               " WHERE idCourses = '" + split[0] + "'");
                trvCourses.SelectedNode.Nodes.Clear();
                foreach (DataRow theRow in component.Tables[0].Rows)
                {

                    trvCourses.SelectedNode.Nodes.Add((string)theRow["Name"],
                                                      Convert.ToString(theRow["idCourseComponents"]) + " - " +
                                                      (string)theRow["Name"]);
                    if (Convert.ToString(theRow["isElective"]) == "1")
                        trvCourses.SelectedNode.Nodes[(string)theRow["Name"]].ForeColor = Color.Blue;
                }
            }
            catch
            {
                load_items();
            }
        }
Example #7
0
        private void approveButton_Click(object sender, EventArgs e)
        {
            if (comboBox1.Text.Contains("Marketing"))
            {
                var colleges = Database.Retrieve("division", "divisionName");
                ArrayList myList = new ArrayList();

                foreach (DataRow theRows in colleges.Tables[0].Rows)
                {
                    myList.Add(theRows["divisionName"]);
                }
                frmSelectSingle myForm = new frmSelectSingle("Select College","Select college to reflect on marketing budget",myList);
                myForm.ShowDialog();
                if (myForm.Selection == "***") return;
                DateTime entrydate = new DateTime();
                var split = entryList.FocusedItem.Text.Split(new char[] { '/' });
                if (!DateTime.TryParse(split[1] + "/" + split[0] + "/" + split[2], out entrydate) || entrydate.ToString("dd/MM/yyyy") != entryList.FocusedItem.Text)
                {
                   // MessageBox.Show("Date was not detected properly from the first method.");
                    DateTime.TryParse(split[0] + "/" + split[1] + "/" + split[2], out entrydate);
                    //MessageBox.Show("Date now detected as " + entrydate.ToString("dd/MM/yyyy"));
                }
                else
                {
                    //MessageBox.Show("Date WAS detected properly from the first method.");
                }

                Database.Command("INSERT INTO marketingentries(division, entryDate,details1,details2,cost,marketingTypeID,`status`) VALUES('" +
                    clsFunctions.GetDivisionAbrev(myForm.Selection) + "'," + entrydate.ToString("yyyyMMdd") +
                    ",'" + destinationText.Text + "','" + reasonText.Text + "'," + entryList.FocusedItem.SubItems[4].Text +
                    "," + Database.Retrieve("marketingTypes", "Name = '" + comboBox1.Text.Replace("Marketing ","") + "'", "id") + ",'Planned')");
            }

            entryList.FocusedItem.SubItems[5].Text = "Approved";
            Database.Command("UPDATE travellingclaims SET approved = 'Approved' WHERE id = " + entryList.FocusedItem.SubItems[6].Text);
            var theRow = Database.Query("SELECT * FROM travellingClaims tc JOIN employees e on e.id = tc.EmployeeId WHERE tc.id = " +
                 entryList.FocusedItem.SubItems[6].Text);

            //theRow.WriteXml(@"C:\LAD_DATA_DUMP\singleTravelClaim.xml", XmlWriteMode.WriteSchema);
            var Report = new Reports.rptTravelClaimSingle();
            Report.headerLabel.Text = comboBox1.Text;
            Report.DataSource = theRow;
            FileInfo exportFile = new FileInfo(Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments) + "\\tempClaim" + DateTime.Now.ToString("ddMMyyyyhhmmss") + ".rtf");
            var stream = exportFile.Create();
            Report.ExportToRtf(stream);
            stream.Close();

            clsFunctions.SendEmailAttachment("*****@*****.**",
                "Approved " + comboBox1.Text + " : " + employeeCombo.Text, "Please find attached Travel Claim", exportFile);
            clsFunctions.WriteLog(comboBox1.Text + " Approved for " + employeeCombo.Text);
            //exportFile.Delete();
            loadEntries();
        }
Example #8
0
        private void btnTransfer_Click(object sender, EventArgs e)
        {
            var colleges = new ArrayList();
            var tempDS = Database.Retrieve("division");
            foreach (DataRow theRow in tempDS.Tables["division"].Rows)
            {
                colleges.Add(theRow["DivisionName"]);
            }
            var tempSelect = new frmSelectSingle("Transfer Learner", "Select College", colleges);
            tempSelect.ShowDialog();
            if (tempSelect.Selection == "***")
                return;
            if (Database.Count("oldlearnernumbers", "divisionAbrev = '" + clsFunctions.GetDivisionAbrev(GlobalProperties.selection) + "' AND ID = '" + GlobalProperties.varLearner_id + "'") > 0)
            {

                MessageBox.Show(
                    "This learner already has a learner number at the destination College.\r\nThe old number will be used.");
                tempDS = Database.Query("learner_details", "ID = '" + GlobalProperties.varLearner_id + "'");
                string oldNumber = (string)tempDS.Tables[0].Rows[0]["LearnerNumber"];
                string oldDivision = (string)tempDS.Tables[0].Rows[0]["division"];
                Database.Command("INSERT INTO oldLearnerNumbers(divisionAbrev,ID,LearnerNumber) VALUES('" +
                                 GlobalProperties.loggedOnUserDivison + "','" + GlobalProperties.varLearner_id + "','" +
                                 oldNumber + "')");
                tempDS = Database.Query("learner_details", "ID = '" + GlobalProperties.varLearner_id + "'");
                tempDS.Tables[0].Rows[0]["Division"] = clsFunctions.GetDivisionAbrev(GlobalProperties.selection);
                tempDS.Tables[0].Rows[0]["LearnerNumber"] = Database.Retrieve("oldlearnernumbers",
                                                                              "divisionAbrev = '" +
                                                                              clsFunctions.GetDivisionAbrev(
                                                                                  GlobalProperties.selection) + "' AND ID = '" +
                                                                              GlobalProperties.varLearner_id + "'",
                                                                              "LearnerNumber");
                Database.Delete("oldlearnerNumbers", "divisionAbrev = '" + clsFunctions.GetDivisionAbrev(GlobalProperties.selection) + "' AND ID = '" + GlobalProperties.varLearner_id + "'");

                var number = Convert.ToString(tempDS.Tables[0].Rows[0]["LearnerNumber"]);
                Database.Update(tempDS, "learner_details", "ID = '" + GlobalProperties.varLearner_id + "'");
                var division = clsFunctions.GetDivisionAbrev(GlobalProperties.selection);

                Database.Command("UPDATE photos SET division = '" + division + "', learnerNumber = '" + number +
                    "' WHERE learnerNumber = '" + oldNumber + "' AND division = '" + GlobalProperties.loggedOnUserDivison + "'");
                Database.Command("UPDATE learnerActivity SET division = '" + division + "', learnerNumber = '" + number +
                    "' WHERE division = '" + oldDivision + "' AND learnerNumber = '" + oldNumber + "'");
                MessageBox.Show("Learner has been transferred.\r\nNew learner number: " + number);
            }
            else
            {
                tempDS = Database.Query("learner_details", "ID = '" + GlobalProperties.varLearner_id + "'");
                string oldNumber = (string)tempDS.Tables[0].Rows[0]["LearnerNumber"];
                string oldDivision = (string)tempDS.Tables[0].Rows[0]["division"];
                tempDS.Tables[0].Rows[0]["Division"] = clsFunctions.GetDivisionAbrev(GlobalProperties.selection);
                Database.Command("INSERT INTO oldLearnerNumbers(divisionAbrev,ID,LearnerNumber) VALUES('" +
                                 GlobalProperties.loggedOnUserDivison + "','" + GlobalProperties.varLearner_id + "','" +
                                 Convert.ToString(tempDS.Tables[0].Rows[0]["LearnerNumber"]) + "')");
                tempDS.Tables[0].Rows[0]["LearnerNumber"] =
                    clsFunctions.nextLearnerNumber(clsFunctions.GetDivisionAbrev(GlobalProperties.selection));
                var number = Convert.ToString(tempDS.Tables[0].Rows[0]["LearnerNumber"]);
                var division = clsFunctions.GetDivisionAbrev(GlobalProperties.selection);
                var learnerNumber = Convert.ToString(tempDS.Tables[0].Rows[0]["LearnerNumber"]);
                Database.Command("UPDATE photos SET division = '" + clsFunctions.GetDivisionAbrev(GlobalProperties.selection) + "', learnerNumber = '" +
                     learnerNumber +
                    "' WHERE learnerNumber = '" + oldNumber + "' AND division = '" + GlobalProperties.loggedOnUserDivison + "'");

                Database.Update(tempDS, "learner_details", "ID = '" + GlobalProperties.varLearner_id + "'");
                Database.Command("UPDATE learnerActivity SET division = '" + division + "', learnerNumber = '" + learnerNumber +
                    "' WHERE division = '" + oldDivision + "' AND learnerNumber = '" + oldNumber + "'");

                MessageBox.Show("Learner has been transferred.\r\nNew learner number: " + number);
            }
            updated_LearnerInfo = false;
            Close();
        }
Example #9
0
 private void button6_Click(object sender, EventArgs e)
 {
     if (comboBox1.Text.Length == 0)
     {
         MessageBox.Show("Please select a group to add the college to from the drop down box", "Select Group");
         return;
     }
     var colleges = new ArrayList();
     var tempDS = Database.Retrieve("division");
     foreach (DataRow theRow in tempDS.Tables["division"].Rows)
     {
         colleges.Add(theRow["DivisionName"]);
     }
     var tempSelect = new frmSelectSingle("Transfer Learner", "Select College", colleges);
     tempSelect.ShowDialog();
     if (tempSelect.Selection == "***")
         return;
     Database.Command("INSERT INTO divisions_groups(idDivision,iddivisionGroups) VALUES('" +
         clsFunctions.GetDivisionAbrev(tempSelect.Selection) + "','" +
         Database.Retrieve("divisionGroups","Name = '" + comboBox1.Text + "'","iddivisionGroups")+"')");
     var x1 = listView2.Items.Add(tempSelect.Selection);
     x1.ImageIndex = 0;
 }
Example #10
0
        private void subjectEnrollmentToolStripMenuItem_Click(object sender, EventArgs e)
        {
            //ArrayList list = new ArrayList();
            //DataSet courses = Database.Query("courses", "Not Type = 'CC'");
            //foreach (DataRow theRow in courses.Tables["courses"].Rows)
            //{
            //    list.Add(theRow["idCourses"] + " - " + theRow["Name"]);
            //}

            DataSet temp = Database.Query("enrollments", "idEnrollments = 0");

            string[] columns = { "LearnerKey", "regDate", "numRegistrations", "dateOfFirstLesson" };
            string[] values = new string[temp.Tables[0].Columns.Count - 3];

            values[0] = Database.Retrieve("learner_details", "division = '" + GlobalProperties.loggedOnUserDivison + "' AND learnerNumber = '" + GlobalProperties.strLearnerNumber + "'", "LearnerKey");
            var dateSelect = new frmSubmitDate("Please select registration date", "Please select registration date");
            dateSelect.ShowDialog();
            if (dateSelect.status == false)
                return;
            values[1] = dateSelect.Selection.ToString("yyyyMMdd");
            values[2] = "1";
            values[3] = DateTime.Now.ToString("yyyyMMdd");

            Database.Insert("enrollments", columns, values);

            DataSet tempe = Database.Query("enrollments", "LearnerKey = '" + clsFunctions.GetLearnerKey(GlobalProperties.varLearner_id) + "' AND regDate = '" + dateSelect.Selection.ToString("yyyyMMdd") + "' ORDER BY idEnrollments DESC");

            string[] coursescolumns = { "idcourses", "Name", "Status", "xPeriod", "Type" };
            string[] coursesvalues = new string[5];
            coursesvalues[0] = "ENR" + Convert.ToString(tempe.Tables[0].Rows[0]["idEnrollments"]);
            coursesvalues[1] = "Custom Course Selection";
            coursesvalues[2] = "1";
            coursesvalues[3] = "0";
            coursesvalues[4] = "CC";

            Database.Insert("courses", coursescolumns, coursesvalues);

            //check if this course has electives

            //columns = new string[2];

            //values = new string[2];
            //values[0] = Convert.ToString(tempe.Tables[0].Rows[0]["idEnrollments"]);
            //values[1] = arrSplit3[0];
            //Database.Insert("enrollmentscourses", columns, values);
            //frmSelect.Dispose();
            columns = new string[2];
            values = new string[2];
            columns[0] = "idEnrollments";
            columns[1] = "idCourses";
            values[0] = Convert.ToString(tempe.Tables[0].Rows[0]["idEnrollments"]);
            values[1] = "ENR" + Convert.ToString(tempe.Tables[0].Rows[0]["idEnrollments"]);
            Database.Insert("enrollmentscourses", columns, values);

            var colleges = new ArrayList();
            var tempDS = Database.Query("Components", "(ComponentAbrev = 'PROJ' OR ComponentAbrev = 'SC') AND singleSubject = 1" +
            " ORDER BY Name");
            foreach (DataRow theRow in tempDS.Tables["Components"].Rows)
            {
                colleges.Add(Convert.ToString(theRow["Name"]) + " - " + Convert.ToString(theRow["idCourseComponents"]));
            }
            var tempSelect = new frmSelectSingle("Replace Course", "Select Course", colleges);
            tempSelect.ShowDialog();
            if (tempSelect.Selection == "***")
                return;
            string[] separate = { " - " };
            string[] select = tempSelect.Selection.Split(separate, StringSplitOptions.None);
            DataSet Check = Database.Query("components", "idCourseComponents = '" + select[1] + "'");

            string[] columns2 = { "idCourses", "idComponents" };
            string[] values2 = { "ENR" + Convert.ToString(tempe.Tables[0].Rows[0]["idEnrollments"]), select[1] };
            Database.Insert("coursecomponents", columns2, values2);
            if (Convert.ToString(Check.Tables[0].Rows[0]["isElective"]) == "1")
            {
                columns2 = new string[2];
                columns2[0] = "idEnrollments";
                columns2[1] = "idCourseComponents";
                values2[0] = Convert.ToString(tempe.Tables[0].Rows[0]["idEnrollments"]);
                values2[1] = select[1];
                Database.Insert("enrollmentcomponents", columns, values);
            }
            clsFunctions.WriteLog("Created new enrollment for learner (" + GlobalProperties.strLearnerNumber + ") : Course " + select[1] + ": Enrollment (" + Convert.ToString(tempe.Tables[0].Rows[0]["idEnrollments"]) + ")\nEnrolled By:" + GlobalProperties.loggedOnUser);
            string subject = (cboEnrollments.Items.Count >= 1 ? "Additional Enrollment :" : "NewEnrollment :");
            string message = "Created new enrollment for learner (" + GlobalProperties.strLearnerNumber + ") : Project/Short Course " + select[1] + ": Enrollment (" + Convert.ToString(tempe.Tables[0].Rows[0]["idEnrollments"]) + ")\nEnrolled By:" + GlobalProperties.loggedOnUser;
            clsFunctions.SendEmail("*****@*****.**", subject + GlobalProperties.LoggedOnUserDivision, message);
            DataSet payment = Database.Query("paymentinfo", "idenrollments = '0'");
            columns = new string[12];
            values = new string[12];

            for (int i = 0; i < payment.Tables[0].Columns.Count; i++)
            {
                DataColumn theColumn = payment.Tables[0].Columns[i];

                columns[i] = theColumn.ColumnName;

            }
            values[0] = "0";
            values[1] = "0";
            values[2] = "0";
            values[3] = "0";
            values[4] = "0";
            values[5] = "0";
            values[6] = "0";
            values[7] = "0";
            values[8] = "No";
            values[9] = "No";
            values[10] = "0";
            values[11] = Convert.ToString(tempe.Tables[0].Rows[0]["idEnrollments"]);
            Database.Insert("paymentinfo", columns, values);

            load_enrollmentstab();
            cboEnrollments.SelectedIndex = cboEnrollments.Items.Count - 1;
            string[] arrEnrollmentID = new string[5];

            arrEnrollmentID = SplitByString(cboEnrollments.Text, "-");

            load_enrollments(arrEnrollmentID[1]);
            panel1.Visible = true;
        }
Example #11
0
        private void statementOfResultsToolStripMenuItem1_Click(object sender, EventArgs e)
        {
            if (lstEnrollments.Items.Count == 0) return;

            var items = new ArrayList();

            foreach (ListViewItem item in lstEnrollments.Items)
            {
                if (item.SubItems[2].Text == "PROJ")
                {
                    items.Add(String.Format("{0} - {1}", item.Text, item.SubItems[1].Text));
                }
            }

            if (items.Count == 0)
            {
                MessageBox.Show("No projects in enrollment!");
                return;
            }

            var myForm = new frmSelectSingle("Select Project", "Project", items);
            myForm.ShowDialog();

            if (myForm.Selection == "***")
                return;

            var courseSplit = SplitByString(myForm.Selection, " - ");
            string[] splitter = SplitByString(cboEnrollments.Text, "-");

            new StatementOfResultsAction().Execute(splitter[1], courseSplit[0]);
        }
Example #12
0
        private void reToolStripMenuItem_Click(object sender, EventArgs e)
        {
            string[] splitter = SplitByString(cboEnrollments.Text, "-");
            if (lstEnrollments.FocusedItem == null)
                return;
            Regex regex = new Regex(@"-\d{4}-");
            if (regex.IsMatch(lstEnrollments.FocusedItem.Text))
            {
                var theRow = Database.Row("SELECT * FROM courseComponents WHERE idComponents = '" + lstEnrollments.FocusedItem.Text + "'");
                string locate = Convert.ToString(theRow["idCourses"]);
                string year = locate.Substring(locate.LastIndexOf('-') + 1);
                if (Database.Count(@"SELECT COUNT(*) FROM components c LEFT JOIN courseComponents CC on cc.idComponents = c.idCourseComponents
            WHERE c.Name = '" + lstEnrollments.FocusedItem.SubItems[1].Text.Replace("*", "") + @"' AND RIGHT(idCourses,LOCATE('-',REVERSE(idCourses))-1) = " + year + @"
            AND c.idCourseComponents = myParent AND (idCourses is Null OR (NOT idCourses LIKE 'ENR%')) AND c.idCourseComponents <> '" + lstEnrollments.FocusedItem.Text + "'") > 0)
                {

                    var theList = Database.Query(@"SELECT c.idCourseComponents, componentAbrev, Name, myParent, cc.*,
            RIGHT(idCourses,LOCATE('-',REVERSE(idCourses))-1) as year
            FROM components c LEFT JOIN courseComponents CC on cc.idComponents = c.idCourseComponents
            WHERE c.Name = '" + lstEnrollments.FocusedItem.SubItems[1].Text.Replace("*", "") + @"' AND RIGHT(idCourses,LOCATE('-',REVERSE(idCourses))-1) = " + year + @"
            AND c.idCourseComponents = myParent AND (idCourses is Null OR (NOT idCourses LIKE 'ENR%')) AND c.idCourseComponents <> '" + lstEnrollments.FocusedItem.Text + "'");
                    clsFunctions.WriteLog("Enrollment " + splitter[1] + ": Re-Enrolled Subject(" + lstEnrollments.FocusedItem.Text + ") with " + Convert.ToString(theList.Tables[0].Rows[0]["idCourseComponents"]));
                    addToExisting(Convert.ToString(theList.Tables[0].Rows[0]["idCourseComponents"]));

                }
            }
            else
            {
                var theList = Database.Query(@"SELECT c.idCourseComponents, componentAbrev, Name, myParent, cc.*,
            RIGHT(idCourses,LOCATE('-',REVERSE(idCourses))-1) as year
            FROM components c LEFT JOIN courseComponents CC on cc.idComponents = c.idCourseComponents
            WHERE c.Name = '" + lstEnrollments.FocusedItem.SubItems[1].Text.Replace("*", "") + @"'
            AND c.idCourseComponents = myParent AND (idCourses is Null OR (NOT idCourses LIKE 'ENR%')) AND c.idCourseComponents <> '" + lstEnrollments.FocusedItem.Text + @"'
            GROUP BY RIGHT(idCourses,LOCATE('-',REVERSE(idCourses))-1)
            ORDER BY RIGHT(idCourses,LOCATE('-',REVERSE(idCourses))-1)");

                ArrayList theDisplayList = new ArrayList();
                foreach (DataRow theRow in theList.Tables[0].Rows)
                {
                    theDisplayList.Add(theRow["idCourseComponents"] + "(" + theRow["year"] + ")");
                }

                frmSelectSingle theForm = new frmSelectSingle("Please select closest match:", "Select the Closest Matching Subject", theDisplayList);
                theForm.ShowDialog();
                if (theForm.Selection == "***")
                    return;

                var theStuff = theForm.Selection.Split(new char[] { '(' });
                clsFunctions.WriteLog("Enrollment " + splitter[1] + ": Re-Enrolled Subject(" + lstEnrollments.FocusedItem.Text + ") with " + theStuff[0]);
                addToExisting(theStuff[0]);

            }
        }
Example #13
0
        private void replaceComponentToolStripMenuItem_Click(object sender, EventArgs e)
        {
            if (MessageBox.Show("This is only reversible by head office.\r\nDo you wish to continue?", "Warning", MessageBoxButtons.YesNo, MessageBoxIcon.Warning) == DialogResult.No)
                return;
            var arrEnrollmentID = SplitByString(cboEnrollments.Text, "-");
            string serialNumber = null;
            DateTime serialDate = new DateTime();
            if (lstEnrollments.SelectedItems.Count <= 0) return;
            var enrollment = Database.Query("enrollmentcomponents",
                                            "idEnrollments = '" + arrEnrollmentID[1] +
                                            "' AND idCourseComponents = '" + lstEnrollments.SelectedItems[0].Text +
                                            "'");
            if (enrollment.Tables[0].Rows.Count <= 0)
            {
                string[] columns = { "idEnrollments", "idCourseComponents", "status" };
                string[] values = { arrEnrollmentID[1], lstEnrollments.SelectedItems[0].Text, "inactive" };
                Database.Insert("enrollmentcomponents", columns, values);
            }
            else
            {
                if (enrollment.Tables[0].Rows[0]["serialNumber"] != DBNull.Value)
                {
                    serialNumber = (string)enrollment.Tables[0].Rows[0]["serialNumber"];
                    serialDate = Convert.ToDateTime(enrollment.Tables[0].Rows[0]["dateIssued"]);
                }
                Database.Command("UPDATE enrollmentComponents SET serialNumber = null, status = 'inactive' WHERE idEnrollments = '" + arrEnrollmentID[1] +
                                                                     "' AND idCourseComponents = '" +
                                                                     lstEnrollments.SelectedItems[0].Text +
                                                                     "'");

            }
            var colleges = new ArrayList();
            var tempDS = Database.Query("Components", "(ComponentAbrev = 'PROJ' OR ComponentAbrev = 'SC') AND singleSubject = 1" +
            " ORDER BY Name");
            foreach (DataRow theRow in tempDS.Tables["Components"].Rows)
            {
                colleges.Add(Convert.ToString(theRow["idCourseComponents"]) + " - " + Convert.ToString(theRow["Name"]));
            }
            var tempSelect = new frmSelectSingle("Replace Course", "Select Course", colleges);
            tempSelect.ShowDialog();
            if (tempSelect.Selection == "***")
                return;
            string[] separate = { " - " };
            string[] select = tempSelect.Selection.Split(separate, StringSplitOptions.None);
            DataSet Check = Database.Query("components", "idCourseComponents = '" + select[0] + "'");
            if (
                Database.Count("coursecomponents",
                               "idCourses = 'ENR" + arrEnrollmentID[1] + "' AND idComponents = '" +
                               select[1] + "'") == 0)
            {
                string[] columns2 = { "idCourses", "idComponents" };
                string[] values2 = { "ENR" + arrEnrollmentID[1], select[0] };
                Database.Insert("coursecomponents", columns2, values2);
            }

            if ((Convert.ToString(Check.Tables[0].Rows[0]["isElective"]) == "1" || serialNumber != null) &&
                Database.Count("enrollmentComponents", "idEnrollments = '" + arrEnrollmentID[1] +
                                            "' AND idCourseComponents = '" + select[0] +
                                            "'") == 0)
            {
                Database.Command(
            @"INSERT INTO enrollmentComponents(idEnrollments, idCourseComponents, serialNumber, dateIssued)
            VALUES(" + arrEnrollmentID[1] + ",'" + select[0] + "'," + (serialNumber == null ? "null" : "'" + serialNumber + "'") + "," +
              (serialNumber == null ? "null" : serialDate.ToString("yyyyMMdd")) + ")");
            }
            else
            {
                Database.Command("UPDATE enrollmentcomponents SET status = Null, serialNumber = " +
                    (serialNumber == null ? "null" : "'" + serialNumber + "'") + ", dateIssued = " +
                    (serialNumber == null ? "null" : serialDate.ToString("yyyyMMdd")) +
                    " WHERE idEnrollments = '" +
                    arrEnrollmentID[1] + "' AND idCourseComponents = '" + select[0] + "'");
            }

            clsFunctions.WriteLog("Replaced Course from Enrolment (" + lstEnrollments.FocusedItem.Text + ")  with (" + select[0] + ") : " +
                                      txtSurname.Text + ", " + txtFullName.Text + " : with learner number : " +
                                      GlobalProperties.strLearnerNumber + " - EnrolmentID = " + cboEnrollments.Text);

            load_enrollments(arrEnrollmentID[1]);
        }
Example #14
0
        private void addToExistingEnrollmentToolStripMenuItem_Click(object sender, EventArgs e)
        {
            var colleges = new ArrayList();

            var tempDS = Database.Query("Components", "(ComponentAbrev = 'PROJ' OR ComponentAbrev = 'SC') AND singleSubject = 1" +
            " ORDER BY Name");
            foreach (DataRow theRow in tempDS.Tables["Components"].Rows)
            {
                colleges.Add(Convert.ToString(theRow["Name"]) + " - " + Convert.ToString(theRow["idCourseComponents"]));
            }
            var tempSelect = new frmSelectSingle("Replace Course", "Select Course", colleges);
            tempSelect.ShowDialog();
            if (tempSelect.Selection == "***")
                return;
            string[] separate = { " - " };
            string[] select = tempSelect.Selection.Split(separate, StringSplitOptions.None);

            //frmSubmitText tempfrm = new frmSubmitText("Enter ID", "Please enter Component ID");
            //tempfrm.ShowDialog();

            //if (Check.Tables[0].Rows.Count == 0)
            //{
            //    MessageBox.Show("Component doesn't exist", "Error");
            //    return;
            //}

            DataSet Check = Database.Query("components", "idCourseComponents = '" + select[1] + "'");

            string[] arrEnrollmentID = SplitByString(cboEnrollments.Text, "-");

            if (
                Database.Count("coursecomponents",
                               "idCourses = 'ENR" + arrEnrollmentID[1] + "' AND idComponents = '" +
                               select[1] + "'") == 0 &&
                Database.Count("enrollmentComponents", "idEnrollments = '" + arrEnrollmentID[1] +
                                            "' AND idCourseComponents = '" + select[1] +
                                            "'") == 0
                )
            {
                string[] columns = { "idCourses", "idComponents" };
                string[] values = { "ENR" + arrEnrollmentID[1], select[1] };
                Database.Insert("coursecomponents", columns, values);
                if (Convert.ToString(Check.Tables[0].Rows[0]["isElective"]) == "1")
                {
                    columns = new string[2];
                    columns[0] = "idEnrollments";
                    columns[1] = "idCourseComponents";
                    values[0] = arrEnrollmentID[1];
                    values[1] = select[1];
                    Database.Insert("enrollmentcomponents", columns, values);

                }
            }
            else
            {
                Database.Command("UPDATE enrollmentcomponents SET status = Null WHERE idEnrollments = '" +
                    arrEnrollmentID[1] + "' AND idCourseComponents = '" + select[1] + "'");
            }

            clsFunctions.WriteLog("Added to Enrollment (" + arrEnrollmentID[1] + ") : " + select[1]);
            load_enrollments(arrEnrollmentID[1]);
        }