//Insert a certificate program with links to specific entrance requirements
        public void InsertCertificateProgram(DiplomaCertificate certProgram, List <EntranceRequirementList> entReqList)
        {
            using (Pathway_Model context = new Pathway_Model())
            {
                DiplomaCertificate  added       = null;
                EntranceRequirement addedEntReq = null;
                added = context.DiplomaCertificates.Add(certProgram);

                if (entReqList != null)
                {
                    // create entrance requirement entry for each row entered
                    foreach (EntranceRequirementList entry in entReqList)
                    {
                        EntranceRequirement entReq = new EntranceRequirement()
                        {
                            ProgramID = added.ProgramID,
                            CourseID  = entry.CourseID,
                            Marks     = entry.Mark
                        };

                        addedEntReq = context.EntranceRequirements.Add(entReq);
                    }
                }
                // commits the add to the databas
                context.SaveChanges();
            }
        }
 public void DegreeRel_Delete(DegreeRelationshipInfo item)
 {
     using (Pathway_Model context = new Pathway_Model())
     {
         Degree             selectedDegree  = context.Degrees.SingleOrDefault(d => d.DegreeID == item.DegreeID);
         DiplomaCertificate selectedDiploma = context.DiplomaCertificates.SingleOrDefault(d => d.ProgramID == item.ProgramID);
         //selectedDegree.DiplomaCertificates.Add(selectedDiploma);
         // EntranceRequirement existing = context.EntranceRequirements.Find(item.ProgramID, item.CourseID);
         selectedDegree.DiplomaCertificates.Remove(selectedDiploma);
         context.SaveChanges();
     }
 }
        public void DegreeRel_Add(DegreeRelationshipInfo item)
        {
            using (Pathway_Model context = new Pathway_Model())
            {
                //create degree diploma entry for row entered
                Degree             selectedDegree  = context.Degrees.SingleOrDefault(d => d.DegreeID == item.DegreeID);
                DiplomaCertificate selectedDiploma = context.DiplomaCertificates.SingleOrDefault(d => d.ProgramID == item.ProgramID);
                selectedDegree.DiplomaCertificates.Add(selectedDiploma);

                context.SaveChanges();
            }
        }
        //Insert a degree program with links to diploma programs
        public void InsertDegreeProgram(Degree degreeProgram, List <int> diplomaIDs)
        {
            using (Pathway_Model context = new Pathway_Model())
            {
                Degree added = null;
                added = context.Degrees.Add(degreeProgram);
                // commits the add to the databas

                if (diplomaIDs != null)
                {
                    //create degree diploma entry for each row entered
                    foreach (int entry in diplomaIDs)
                    {
                        DiplomaCertificate selectedDiploma = context.DiplomaCertificates.SingleOrDefault(d => d.ProgramID == entry);
                        added.DiplomaCertificates.Add(selectedDiploma);
                    }
                }
                context.SaveChanges();
            }
        }
        //Insert a diploma program with entrance requirements for specific courses, and links to degree programs
        public void InsertDiplomaProgram(DiplomaCertificate diplomaProgram, List <EntranceRequirementList> entReqList, List <int> degreeIDs)
        {
            using (Pathway_Model context = new Pathway_Model())
            {
                DiplomaCertificate  added       = null;
                EntranceRequirement addedEntReq = null;
                added = context.DiplomaCertificates.Add(diplomaProgram);

                if (entReqList.Count != 0)
                {
                    // create entrance requirement entry for each row entered
                    foreach (EntranceRequirementList entry in entReqList)
                    {
                        EntranceRequirement entReq = new EntranceRequirement()
                        {
                            ProgramID = added.ProgramID,
                            CourseID  = entry.CourseID,
                            Marks     = entry.Mark
                        };

                        addedEntReq = context.EntranceRequirements.Add(entReq);
                    }
                }
                if (degreeIDs.Count != 0)
                {
                    //create degree diploma entry for each row entered
                    foreach (int entry in degreeIDs)
                    {
                        Degree selectedDegree = context.Degrees.SingleOrDefault(d => d.DegreeID == entry);
                        selectedDegree.DiplomaCertificates.Add(diplomaProgram);
                    }
                }


                // commits the add to the databas
                context.SaveChanges();
            }
        }
        public void CertDiploma_Update(DiplomaCertificate item)
        {
            using (Pathway_Model context = new Pathway_Model())
            {
                DiplomaCertificate entReq = new DiplomaCertificate()
                {
                    ProgramID                 = item.ProgramID,
                    ProgramName               = item.ProgramName,
                    ProgramLength             = item.ProgramLength,
                    EntranceRequirementDetail = item.EntranceRequirementDetail,
                    CompetitveAdvantage       = item.CompetitveAdvantage,
                    ProgramLink               = item.ProgramLink,
                    Activated                 = item.Activated,
                    WorkOutdoors              = item.WorkOutdoors,
                    ShiftWork                 = item.ShiftWork,
                    WorkTravel                = item.WorkTravel,
                    CredentialType            = item.CredentialType,
                    CategoryID                = item.CategoryID
                };

                context.Entry <DiplomaCertificate>(context.DiplomaCertificates.Attach(entReq)).State = System.Data.Entity.EntityState.Modified;
                context.SaveChanges();
            }
        }
    protected void SubmitProgram_Click(object sender, EventArgs e)
    {
        MessageUserControl.TryRun(() =>
        {
            // Variables
            string programName, credentialType, programLink, programLength;
            string errorList = "";
            int categoryID, temp;
            Uri tempUrl;
            bool workOutdoors, shiftWork, travel, activated, checkURL;

            //Validate non-string variables
            //Po
            bool result = int.TryParse(ProgramLength.Text.Trim(), out temp);
            if (!result)
            {
                errorList += "- Please enter a numeric value into the program length field (whole number only).\\n";
            }
            if (temp != 0)
            {
                if ((int.Parse(ProgramLength.Text)) < 0 || (int.Parse(ProgramLength.Text)) > 100)
                {
                    errorList += "- Program length must be a whole number between 1 - 99.\\n";
                }
            }

            //Validate URL
            result = Uri.TryCreate(ProgramLink.Text, UriKind.Absolute, out tempUrl) && tempUrl.Scheme == Uri.UriSchemeHttp;
            if (!result)
            {
                errorList += "- Please enter a properly formatted URL (ex. http://www.example.com).\\n";
            }

            PathwaysController controller = new PathwaysController();

            //Validate field lengths
            if (ProgramName.Text.Trim().Length > 100)
            {
                errorList += "- Program Name cannot exceed 100 characters. \\n";
            }

            if (ProgramLink.Text.Trim().Length > 150)
            {
                errorList += "- Program Link cannot exceed 150 characters. \\n";
            }

            //check to see if program name exists
            //Po
            result = controller.CheckProgramName(ProgramName.Text.Trim());
            //verify the name does not exist
            if (result == false)
            {
                errorList += "- The Program Name selected currently exists in the system, and cannot be repeated.\\n";
            }



            // Get values from page
            //Po
            programName    = ProgramName.Text.Trim();
            credentialType = CredentialType.SelectedValue;
            programLink    = ProgramLink.Text.Trim();
            programLength  = ProgramLength.Text.Trim() + " " + ProgramLengthDDL.SelectedValue;
            workOutdoors   = WorkOutdoors.Checked;
            shiftWork      = ShiftWork.Checked;
            travel         = Travel.Checked;
            activated      = Activated.Checked;
            categoryID     = int.Parse(CategoryList.SelectedValue);



            if (credentialType == "Degree")
            {
                //verify the URL does not exist
                checkURL = controller.CheckDegUrl(programLink);
                if (checkURL == false)
                {
                    errorList += "- The url selected currently exists in the system, and cannot be repeated.\\n";
                }

                // Make a list for entering degree pathway information
                List <int> diplomaIDs = new List <int>();
                Degree degreeProgram  = new Degree();

                // Populate a new degree
                degreeProgram.DegreeName   = programName;
                degreeProgram.DegreeLink   = programLink;
                degreeProgram.DegreeLength = programLength;
                degreeProgram.Activated    = activated;
                degreeProgram.WorkOutdoors = workOutdoors;
                degreeProgram.WorkTravel   = travel;
                degreeProgram.ShiftWork    = shiftWork;
                degreeProgram.CategoryID   = categoryID;

                int numOfRows = Program_GridView.Rows.Count;

                if (numOfRows != 0)
                {
                    //gather data from the degree pathway gridview for processing
                    foreach (GridViewRow row in Program_GridView.Rows)
                    {
                        // Find controls in the Gridview
                        int diplomaID = int.Parse((row.FindControl("ProgramList") as DropDownList).SelectedValue);
                        diplomaIDs.Add(diplomaID);
                    }
                }

                int index = 0;
                diplomaIDs.Sort();
                bool flagDip = true;
                while (index < diplomaIDs.Count - 1 && flagDip == true)
                {
                    if (diplomaIDs[index] == diplomaIDs[index + 1])
                    {
                        errorList += "- Diploma pathways cannot appear more than once.\\n";
                        flagDip    = false;
                    }
                    else
                    {
                        index++;
                    }
                }

                if (errorList != "")
                {
                    throw new Exception(errorList);
                }

                //Insert the entry
                controller.InsertDegreeProgram(degreeProgram, diplomaIDs);
                ClearFields();
                Response.Write("<script type=\"text/javascript\">alert('Entry has been inserted.');</script>");
                //Hide panels
                ShowCoursesView.Checked = false;
                ShowDipPathView.Checked = false;
                ShowDegPathView.Checked = false;
                entrance_req.Visible    = false;
                degree_link.Visible     = false;
                degree_pathways.Visible = false;
            }

            if (credentialType == "Diploma")
            {
                //verify the URL does not exist
                checkURL = controller.CheckDipCertUrl(programLink);
                if (checkURL == false)
                {
                    errorList += "- The url selected currently exists in the system, and cannot be repeated.\\n";
                }
                //validate field length
                if (EntReqDetail.Text.Length > 150)
                {
                    errorList += "- Entrance Requirement Details cannot exceed 150 characters. \\n";
                }

                //check coompetitive advantage
                //Po
                result = int.TryParse(CompetitiveAdv.Text.Trim(), out temp);
                if (!result)
                {
                    errorList += "- Please enter a numeric value into the competitive advantage field (whole number only).\\n";
                }
                if (temp != 0)
                {
                    if ((int.Parse(CompetitiveAdv.Text)) < 0 || (int.Parse(CompetitiveAdv.Text)) > 100)
                    {
                        errorList += "- Competitive advantage must be a whole number between 1 - 99.\\n";
                    }
                }
                // get other required data
                byte competitiveAdvantage = byte.Parse(CompetitiveAdv.Text);
                string entReqDetail       = EntReqDetail.Text;

                DiplomaCertificate diploma = new DiplomaCertificate();

                // Populate a new diploma
                diploma.ProgramName               = programName;
                diploma.ProgramLink               = programLink;
                diploma.ProgramLength             = programLength;
                diploma.Activated                 = activated;
                diploma.WorkOutdoors              = workOutdoors;
                diploma.WorkTravel                = travel;
                diploma.ShiftWork                 = shiftWork;
                diploma.CategoryID                = categoryID;
                diploma.CredentialType            = true;
                diploma.CompetitveAdvantage       = competitiveAdvantage;
                diploma.EntranceRequirementDetail = entReqDetail;

                // Make a list for entering entrance requirement information
                List <EntranceRequirementList> entranceReqList = new List <EntranceRequirementList>();


                if (ShowCoursesView.Checked)
                {
                    // Gather data from course gridview for processing items
                    foreach (GridViewRow row in Course_Gridview.Rows)
                    {
                        // Find controls in the Gridview
                        //Po
                        int courseID = int.Parse((row.FindControl("CourseList") as DropDownList).SelectedValue);
                        byte mark;
                        result = byte.TryParse(((row.FindControl("EnterMark") as TextBox).Text.Trim()), out mark);
                        if (!result)
                        {
                            errorList += "- Marks entered must be numeric values (whole numbers greater than 0). \\n";
                        }
                        if (mark > 100 || mark < 0)
                        {
                            errorList += "- Marks entered must whole numbers between 1 - 99. \\n";
                        }

                        entranceReqList.Add(new EntranceRequirementList()
                        {
                            CourseID = courseID,
                            Mark     = mark
                        });
                    }
                }
                List <int> courseIds = new List <int>();
                foreach (EntranceRequirementList item in entranceReqList)
                {
                    courseIds.Add(item.CourseID);
                }

                courseIds.Sort();
                int index = 0;
                bool flag = true;
                while (index < entranceReqList.Count - 1 && flag == true)
                {
                    if (courseIds[index] == courseIds[index + 1])
                    {
                        errorList += "- Courses in entrance requirements cannot appear more than once.\\n";
                        flag       = false;
                    }
                    else
                    {
                        index++;
                    }
                }

                int numOfRows        = DegreeList_GridView.Rows.Count;
                List <int> degreeIDs = new List <int>();
                if (numOfRows != 0)
                {
                    //gather data from the degree pathway gridview for processing
                    foreach (GridViewRow row in DegreeList_GridView.Rows)
                    {
                        // Find controls in the Gridview
                        int degreeID = int.Parse((row.FindControl("DegreeList") as DropDownList).SelectedValue);
                        if (degreeID != 0)
                        {
                            degreeIDs.Add(degreeID);
                        }
                    }
                }

                degreeIDs.Sort();
                bool flagDeg = true;
                while (index < degreeIDs.Count - 1 && flagDeg == true)
                {
                    if (degreeIDs[index] == degreeIDs[index + 1])
                    {
                        errorList += "- Degree pathways cannot appear more than once.\\n";
                        flagDeg    = false;
                    }
                    else
                    {
                        index++;
                    }
                }

                if (errorList != "")
                {
                    throw new Exception(errorList);
                }

                //Insert the entry
                controller.InsertDiplomaProgram(diploma, entranceReqList, degreeIDs);
                ClearFields();
                Response.Write("<script type=\"text/javascript\">alert('Entry has been inserted.');</script>");
                //Hide panels
                ShowCoursesView.Checked = false;
                ShowDipPathView.Checked = false;
                ShowDegPathView.Checked = false;
                entrance_req.Visible    = false;
                degree_link.Visible     = false;
                degree_pathways.Visible = false;
            }

            if (credentialType == "Certificate")
            {
                //verify the URL does not exist
                checkURL = controller.CheckDipCertUrl(programLink);
                if (checkURL == false)
                {
                    errorList += "- The url selected currently exists in the system, and cannot be repeated.\\n";
                }
                //validate field length
                if (EntReqDetail.Text.Length > 150)
                {
                    errorList += "- Entrance Requirement Details cannot exceed 150 characters. \\n";
                }
                byte competitiveAdvantage;
                //Po
                result = byte.TryParse(CompetitiveAdv.Text.Trim(), out competitiveAdvantage);
                if (!result)
                {
                    errorList += "- Please enter a numeric value into the competitive advantage field (whole numbers greater than zero only).\\n";
                }

                if (competitiveAdvantage < 0 || competitiveAdvantage > 100)
                {
                    errorList += "- Please enter a numeric value between 1 - 99. \\n";
                }
                //check coompetitive advantage
                //po
                result = int.TryParse(CompetitiveAdv.Text.Trim(), out temp);
                if (!result)
                {
                    errorList += "- Please enter a numeric value into the competitive advantage field (whole number only).\\n";
                }
                if (temp != 0)
                {
                    if ((int.Parse(CompetitiveAdv.Text)) < 0 || (int.Parse(CompetitiveAdv.Text)) > 100)
                    {
                        errorList += "- Competitive advantage must be a whole number between 1 - 99.\\n";
                    }
                }
                string entReqDetail = EntReqDetail.Text;


                DiplomaCertificate certificate = new DiplomaCertificate();
                // Populate a new certificate
                certificate.ProgramName               = programName;
                certificate.ProgramLink               = programLink;
                certificate.ProgramLength             = programLength;
                certificate.Activated                 = activated;
                certificate.WorkOutdoors              = workOutdoors;
                certificate.WorkTravel                = travel;
                certificate.ShiftWork                 = shiftWork;
                certificate.CategoryID                = categoryID;
                certificate.CredentialType            = false;
                certificate.CompetitveAdvantage       = competitiveAdvantage;
                certificate.EntranceRequirementDetail = entReqDetail;

                // Make a list for entering entrance requirement information
                List <EntranceRequirementList> entranceReqList = new List <EntranceRequirementList>();
                if (ShowCoursesView.Checked)
                {
                    // Gather data from course gridview for processing items
                    foreach (GridViewRow row in Course_Gridview.Rows)
                    {
                        // Find controls in the Gridview
                        int courseID = int.Parse((row.FindControl("CourseList") as DropDownList).SelectedValue);
                        byte mark;
                        result = byte.TryParse(((row.FindControl("EnterMark") as TextBox).Text.Trim()), out mark);
                        if (!result)
                        {
                            errorList += "- Marks entered must be numeric values (whole numbers greater than 0). \\n";
                        }
                        if (mark > 100 || mark < 0)
                        {
                            errorList += "- Marks entered must whole numbers between 1 - 99. \\n";
                        }

                        entranceReqList.Add(new EntranceRequirementList()
                        {
                            CourseID = courseID,
                            Mark     = mark
                        });
                    }
                    List <int> courseIds = new List <int>();
                    foreach (EntranceRequirementList item in entranceReqList)
                    {
                        courseIds.Add(item.CourseID);
                    }

                    courseIds.Sort();
                    int index = 0;
                    bool flag = true;
                    while (index < entranceReqList.Count - 1 && flag == true)
                    {
                        if (courseIds[index] == courseIds[index + 1])
                        {
                            errorList += "- Courses in entrance requirements cannot appear more than once.\\n";
                            flag       = false;
                        }
                        else
                        {
                            index++;
                        }
                    }
                }

                if (errorList != "")
                {
                    throw new Exception(errorList);
                }

                //Insert the entry
                controller.InsertCertificateProgram(certificate, entranceReqList);
                ClearFields();
                Response.Write("<script type=\"text/javascript\">alert('Entry has been inserted.');</script>");
                //Hide panels
                ShowCoursesView.Checked = false;
                ShowDipPathView.Checked = false;
                ShowDegPathView.Checked = false;
                entrance_req.Visible    = false;
                degree_link.Visible     = false;
                degree_pathways.Visible = false;
            }
        });
    }
    protected void Page_Load(object sender, EventArgs e)
    {
        CourseMarks_Gridview.DataBind();
        MarksNotQualified.Visible = false;

        string programID = Request.QueryString["programID"];

        //Course-Marks query string
        string allEnteredCourseMarks = Request.QueryString["allEnteredCourseMarks"];

        if (!string.IsNullOrEmpty(allEnteredCourseMarks))
        {
            allEnteredCourseMarks = allEnteredCourseMarks.Remove(allEnteredCourseMarks.Length - 1);

            //test data transfer
            List <string> firstSplit  = allEnteredCourseMarks.Split(';').ToList();
            string[]      secondSplit = new string[2];

            List <string> courses = new List <string>();
            List <string> marks   = new List <string>();
            foreach (string item in firstSplit)
            {
                secondSplit = item.Split(',');
                //if (allEnteredCourseMarks.Split(',').Length > 2)
                //{
                courses.Add(secondSplit[0]);
                marks.Add(secondSplit[1]);
                //}
            }

            PathwaysController controller   = new PathwaysController();
            List <CourseMarks> marksEntered = controller.ProcessStudentMarks(courses, marks);

            CourseMarks_Gridview.DataSource = marksEntered;
            CourseMarks_Gridview.DataBind();

            //Compare the certain course-marks
            int countGVRow = 0;

            foreach (GridViewRow theRow in EntReq_GridView.Rows)
            {
                var myCourseReqName  = theRow.FindControl("LB_CourseName") as Label;
                var mycourseReqMarks = theRow.FindControl("LB_Marks") as Label;

                int countCourse = 0;

                foreach (string myCourseId in courses)
                {
                    PathwaysController myCourseController = new PathwaysController();
                    string             myCourseName       = myCourseController.GetCourseNameByID(int.Parse(myCourseId));

                    //Check the same course for comparison marks
                    if (myCourseName.Equals(myCourseReqName.Text))
                    {
                        //for the same column/record check
                        int countMarks = 0;

                        //get marks
                        foreach (string myCourseMarks in marks)
                        {
                            //if they are in the same associated row/data
                            if (countCourse == countMarks)
                            {
                                //compare marks at the certain course
                                if (int.Parse(myCourseMarks) < int.Parse(mycourseReqMarks.Text))
                                {
                                    //show prompt messages
                                    MarksNotQualified.Visible = true;

                                    //Check the same row.data as the one associated with the compared data
                                    int enteredCourseMarksCount = 0;

                                    //for change row color if marks comparison failed
                                    foreach (GridViewRow myEnterCoureMarks in CourseMarks_Gridview.Rows)
                                    {
                                        //check the it is at the same row as the accosicated row
                                        if (countCourse == enteredCourseMarksCount)
                                        {
                                            //change color if marks comparison failed
                                            myEnterCoureMarks.ForeColor = ColorTranslator.FromHtml("#ff3300");
                                            myEnterCoureMarks.Font.Bold = true;
                                        }

                                        //for count the row, which row it is now.
                                        enteredCourseMarksCount += 1;
                                    }
                                }
                            }
                            countMarks += 1;
                        }
                    }
                    countCourse += 1;
                }

                countGVRow += 1;
            }
        }

        if (String.IsNullOrEmpty(programID))
        {
            Response.Redirect("~/Default.aspx");
        }
        else
        {
            PathwaysController controller = new PathwaysController();

            // find out the type of program
            bool programType = controller.GetProgramType(int.Parse(programID));

            if (programType) //if its diploma/certificate
            {
                DiplomaCertificate dipCert = new DiplomaCertificate();
                dipCert = controller.GetSingleProgram(int.Parse(programID));


                //Populate page fields

                //Program Name:
                ProgramName.Text = dipCert.ProgramName;
                //Credential Type:
                if (dipCert.CredentialType == true)
                {
                    CredentialType.Text = "Diploma Program - " + dipCert.ProgramLength;

                    //Po's future path data bind
                    RP_FuturePathWay.DataSourceID = "ODS_FuturePath";
                    RP_FuturePathWay.DataBind();
                    foreach (RepeaterItem myFuturePath in RP_FuturePathWay.Items)
                    {
                        var myFuturePathID = myFuturePath.FindControl("LB_MyFuturePathDegreeID") as Label;

                        if (!string.IsNullOrEmpty(myFuturePathID.Text))
                        {
                            Div_FuturePathway.Visible = true;
                        }
                    }
                }
                else
                {
                    CredentialType.Text = "Certificate Program - " + dipCert.ProgramLength;
                }

                //Competitive Advantage
                CompetitiveAdvantage.Text = dipCert.CompetitveAdvantage + "%";

                //Working outdoors
                if (dipCert.WorkOutdoors == true)
                {
                    WorkOutdoors.Text = "Yes";
                }
                else
                {
                    WorkOutdoors.Text = "No";
                }
                //Travel
                if (dipCert.WorkTravel == true)
                {
                    Travel.Text = "Yes";
                }
                else
                {
                    Travel.Text = "No";
                }
                //Shift Work
                if (dipCert.ShiftWork == true)
                {
                    Schedule.Text = "Rotational";
                }
                else
                {
                    Schedule.Text = "Regular Hours";
                }

                //Program Link
                ProgramLink.Text        = dipCert.ProgramLink;
                ProgramLink.NavigateUrl = dipCert.ProgramLink;

                //Entrance Req Details
                EntranceDetails.Text = dipCert.EntranceRequirementDetail;
            }

            else
            {
                ProgramEnvironment.Visible = false;
                ProgramGradeInfo.Visible   = false;
                MarkInfo.Visible           = false;
                DegreeWorkInfo.Visible     = true;
                Degree degree = new Degree();
                degree = controller.DegreeProgram_byID(int.Parse(programID));


                //Populate page fields

                //Program Name:
                ProgramName.Text = degree.DegreeName;
                //Credential Type:

                CredentialType.Text = "Degree Program - " + degree.DegreeLength;


                //Working outdoors
                if (degree.WorkOutdoors == true)
                {
                    DegOutDoors.Text = "Yes";
                }
                else
                {
                    DegOutDoors.Text = "No";
                }
                //Travel
                if (degree.WorkTravel == true)
                {
                    DegTravel.Text = "Yes";
                }
                else
                {
                    DegTravel.Text = "No";
                }
                //Shift Work
                if (degree.ShiftWork == true)
                {
                    DegSchedule.Text = "Rotational";
                }
                else
                {
                    DegSchedule.Text = "Regular Hours";
                }
                //Program Link
                ProgramLink.Text        = degree.DegreeLink;
                ProgramLink.NavigateUrl = degree.DegreeLink;
            }
        }
    }
Example #9
0
    protected void ShowUpdateFields_Click(object sender, EventArgs e)
    {
        MessageUserControl.TryRun(() =>
        {
            //POPULATE FIELDS BASED ON SELECTION
            if (InitialCredential.SelectedValue == "Certificate")
            {
                // Use a string to capture Program Length for spliting into two fields.
                string programLength;
                string[] programSplit = new string[2];
                char[] splitChar      = { ' ' };

                show_update_form.Visible       = true;
                SubmitProgram.Visible          = true;
                DiplomaCertificate certificate = new DiplomaCertificate();
                PathwaysController controller  = new PathwaysController();


                certificate = controller.CertificateProgram_byID(int.Parse(CertificateList.SelectedValue));

                //Split string before populating form
                programLength = certificate.ProgramLength;
                programSplit  = programLength.Split(splitChar);

                ProgramID.Text                 = certificate.ProgramID.ToString();
                ProgramName.Text               = certificate.ProgramName;
                CategoryList.SelectedValue     = certificate.CategoryID.ToString();
                CredentialType.Text            = "Certificate";
                ProgramLength.Text             = programSplit[0];
                ProgramLengthDDL.SelectedValue = programSplit[1];
                ProgramLink.Text               = certificate.ProgramLink;
                Activated.Checked              = certificate.Activated;
                WorkOutdoors.Checked           = certificate.WorkOutdoors;
                ShiftWork.Checked              = certificate.ShiftWork;
                Travel.Checked                 = certificate.WorkTravel;
                CompetitiveAdv.Text            = certificate.CompetitveAdvantage.ToString();
                EntReqDetail.Text              = certificate.EntranceRequirementDetail;

                DegreePathListView.Visible     = false;
                pathwaysheading_toggle.Visible = false;
                entrance_req.Visible           = true;
                EntReqListView.Visible         = true;
                DiplomaEntReqList.Visible      = false;

                //ProgramLink Holder for comparison later on
                ProgramLinkCompare.Value = certificate.ProgramLink;
                //ProgramName Holder for comparison later on
                ProgramNameCompare.Value = certificate.ProgramName;
            }

            else if (InitialCredential.SelectedValue == "Diploma")
            {
                // Use a string to capture Program Length for spliting into two fields.
                string programLength;
                string[] programSplit = new string[2];
                char[] splitChar      = { ' ' };

                show_update_form.Visible   = true;
                SubmitProgram.Visible      = true;
                DiplomaCertificate diploma = new DiplomaCertificate();

                PathwaysController controller = new PathwaysController();

                diploma = controller.DiplomaProgram_byID(int.Parse(DiplomaList.SelectedValue));

                //Split string before populating form
                programLength = diploma.ProgramLength;
                programSplit  = programLength.Split(splitChar);

                ProgramID.Text                 = diploma.ProgramID.ToString();
                ProgramName.Text               = diploma.ProgramName;
                CategoryList.SelectedValue     = diploma.CategoryID.ToString();
                CredentialType.Text            = "Diploma";
                ProgramLength.Text             = programSplit[0];
                ProgramLengthDDL.SelectedValue = programSplit[1];
                ProgramLink.Text               = diploma.ProgramLink;
                Activated.Checked              = diploma.Activated;
                WorkOutdoors.Checked           = diploma.WorkOutdoors;
                ShiftWork.Checked              = diploma.ShiftWork;
                Travel.Checked                 = diploma.WorkTravel;
                CompetitiveAdv.Text            = diploma.CompetitveAdvantage.ToString();
                EntReqDetail.Text              = diploma.EntranceRequirementDetail;

                entrance_req.Visible           = true;
                EntReqListView.Visible         = false;
                DiplomaEntReqList.Visible      = true;
                DiplomaPathListView.Visible    = true;
                pathwaysheading_toggle.Visible = true;
                DegreePathListView.Visible     = false;

                //ProgramLink Holder for comparison later on
                ProgramLinkCompare.Value = diploma.ProgramLink;
                //ProgramName Holder for comparison later on
                ProgramNameCompare.Value = diploma.ProgramName;
            }
            else if (InitialCredential.SelectedValue == "Degree")
            {
                // Use a string to capture Program Length for spliting into two fields.
                string programLength;
                string[] programSplit = new string[2];
                char[] splitChar      = { ' ' };

                show_update_form.Visible = true;
                SubmitProgram.Visible    = true;
                Degree degree            = new Degree();

                PathwaysController controller = new PathwaysController();
                degree = controller.DegreeProgram_byID(int.Parse(DegreeList.SelectedValue));

                //Split string before populating form
                programLength = degree.DegreeLength;
                programSplit  = programLength.Split(splitChar);

                ProgramID.Text                 = degree.DegreeID.ToString();
                ProgramName.Text               = degree.DegreeName;
                CategoryList.SelectedValue     = degree.CategoryID.ToString();
                CredentialType.Text            = "Degree";
                ProgramLength.Text             = programSplit[0];
                ProgramLengthDDL.SelectedValue = programSplit[1];
                ProgramLink.Text               = degree.DegreeLink;
                Activated.Checked              = degree.Activated;
                WorkOutdoors.Checked           = degree.WorkOutdoors;
                ShiftWork.Checked              = degree.ShiftWork;
                Travel.Checked                 = degree.WorkTravel;

                pathwaysheading_toggle.Visible = true;
                EntReqListView.Visible         = false;
                DegreePathListView.Visible     = true;
                DiplomaEntReqList.Visible      = false;
                DiplomaPathListView.Visible    = false;
                entrance_req.Visible           = false;

                //ProgramLink Holder for comparison later on
                ProgramLinkCompare.Value = degree.DegreeLink;
                //ProgramName Holder for comparison later on
                ProgramNameCompare.Value = degree.DegreeName;

                DegreePathListView.DataSource = DipRelDB_ODS;
                DegreePathListView.DataBind();
            }

            else
            {
                DegreePathListView.Visible     = false;
                DiplomaEntReqList.Visible      = false;
                DiplomaPathListView.Visible    = false;
                pathwaysheading_toggle.Visible = false;
                EntReqListView.Visible         = false;
                entrance_req.Visible           = false;
            }
        });
    }
Example #10
0
    protected void SubmitProgram_Click(object sender, EventArgs e)
    {
        MessageUserControl.TryRun(() =>
        {
            // BUILD OBJECTS AND UPDATE BASED ON PROGRAM TYPE

            //Declare variables for error handling
            Uri tempUrl;
            int temp;
            string errorList = "";

            if (InitialCredential.SelectedValue == "Certificate")
            {
                //Validate non-string variables
                //Po
                bool result = int.TryParse(ProgramLength.Text.Trim(), out temp);
                if (!result)
                {
                    errorList += "- Please enter a numeric value into the program length field (whole number only). \\n";
                }
                if (temp != 0)
                {
                    //Po
                    if ((int.Parse(ProgramLength.Text.Trim())) < 0 || (int.Parse(ProgramLength.Text.Trim())) > 100)
                    {
                        errorList += "- Program length must be a whole number between 1 - 99. \\n";
                    }
                }
                //Validate URL
                //Po
                result = Uri.TryCreate(ProgramLink.Text.Trim(), UriKind.Absolute, out tempUrl) && tempUrl.Scheme == Uri.UriSchemeHttp;
                if (!result)
                {
                    errorList += "- Please enter a properly formatted URL (ex. http://www.example.com). \\n";
                }
                PathwaysController controller = new PathwaysController();



                //verify the URL does not exist
                if (ProgramLinkCompare.Value != ProgramLink.Text.Trim())
                {
                    //Po
                    bool checkURL = controller.CheckDipCertUrl(ProgramLink.Text.Trim());
                    if (checkURL == false)
                    {
                        errorList += "- The url selected currently exists in the system, and cannot be repeated.\\n";
                    }
                }

                //verify the name does not exist
                //Po
                if (ProgramNameCompare.Value != ProgramName.Text.Trim())
                {
                    //Po
                    bool checkName = controller.CheckProgramName(ProgramName.Text.Trim());
                    if (checkName == false)
                    {
                        errorList += "- The Program Name selected currently exists in the system, and cannot be repeated.\\n";
                    }
                }

                //Validate field lengths
                if (ProgramName.Text.Trim().Length > 100)
                {
                    errorList += "- Program Name cannot exceed 100 characters. \\n";
                }

                if (ProgramLink.Text.Trim().Length > 150)
                {
                    errorList += "- Program Link cannot exceed 150 characters. \\n";
                }
                //validate field length
                if (EntReqDetail.Text.Trim().Length > 150)
                {
                    errorList += "- Entrance Requirement Details cannot exceed 150 characters. \\n";
                }

                byte competitiveAdvantage;
                result = byte.TryParse(CompetitiveAdv.Text.Trim(), out competitiveAdvantage);
                if (!result)
                {
                    errorList += "- Please enter a numeric value into the competitive advantage field (whole numbers greater than zero only). \\n";
                }

                if (competitiveAdvantage < 0 || competitiveAdvantage > 100)
                {
                    errorList += "- Please enter a numeric value between 1 - 99. \\n";
                }

                //populate certificate
                DiplomaCertificate certificate = new DiplomaCertificate()
                {
                    ProgramID                 = int.Parse(ProgramID.Text),
                    ProgramName               = ProgramName.Text.Trim(),
                    ProgramLength             = ProgramLength.Text.Trim() + " " + ProgramLengthDDL.SelectedValue,
                    EntranceRequirementDetail = EntReqDetail.Text,
                    CompetitveAdvantage       = competitiveAdvantage,
                    ProgramLink               = ProgramLink.Text.Trim(),
                    Activated                 = Activated.Checked,
                    WorkOutdoors              = WorkOutdoors.Checked,
                    ShiftWork                 = ShiftWork.Checked,
                    WorkTravel                = Travel.Checked,
                    CredentialType            = false,
                    CategoryID                = int.Parse(CategoryList.SelectedValue)
                };
                if (errorList != "")
                {
                    throw new Exception(errorList);
                }
                //process update
                // PathwaysController controller = new PathwaysController();
                controller.CertDiploma_Update(certificate);
                Clear_Click();
                Response.Write("<script type=\"text/javascript\">alert('The selected Certificate program has been updated.');</script>");
            }
            else if (InitialCredential.SelectedValue == "Diploma")
            {
                //Validate non-string variables
                bool result = int.TryParse(ProgramLength.Text.Trim(), out temp);
                if (!result)
                {
                    errorList += "- Please enter a numeric value into the program length field (whole number only). \\n";
                }
                if (temp != 0)
                {
                    if ((int.Parse(ProgramLength.Text)) < 0 || (int.Parse(ProgramLength.Text)) > 100)
                    {
                        errorList += "- Program length must be a whole number between 1 - 99. \\n";
                    }
                }
                //Validate URL
                result = Uri.TryCreate(ProgramLink.Text.Trim(), UriKind.Absolute, out tempUrl) && tempUrl.Scheme == Uri.UriSchemeHttp;
                if (!result)
                {
                    errorList += "- Please enter a properly formatted URL (ex. http://www.example.com). \\n";
                }
                PathwaysController controller = new PathwaysController();

                //verify the URL does not exist
                if (ProgramLinkCompare.Value != ProgramLink.Text.Trim())
                {
                    bool checkURL = controller.CheckDipCertUrl(ProgramLink.Text.Trim());
                    if (checkURL == false)
                    {
                        errorList += "- The url selected currently exists in the system, and cannot be repeated.\\n";
                    }
                }

                //verify the name does not exist
                if (ProgramNameCompare.Value != ProgramName.Text.Trim())
                {
                    bool checkName = controller.CheckProgramName(ProgramName.Text.Trim());
                    if (checkName == false)
                    {
                        errorList += "- The Program Name selected currently exists in the system, and cannot be repeated.\\n";
                    }
                }

                //Validate field lengths
                if (ProgramName.Text.Trim().Length > 100)
                {
                    errorList += "- Program Name cannot exceed 100 characters. \\n";
                }

                if (ProgramLink.Text.Trim().Length > 150)
                {
                    errorList += "- Program Link cannot exceed 150 characters. \\n";
                }
                //validate field length
                if (EntReqDetail.Text.Trim().Length > 150)
                {
                    errorList += "- Entrance Requirement Details cannot exceed 150 characters. \\n";
                }

                byte competitiveAdvantage;
                result = byte.TryParse(CompetitiveAdv.Text.Trim(), out competitiveAdvantage);
                if (!result)
                {
                    errorList += "- Please enter a numeric value into the competitive advantage field (whole numbers greater than zero only). \\n";
                }

                if (competitiveAdvantage < 0 || competitiveAdvantage > 100)
                {
                    errorList += "- Please enter a numeric value between 1 - 99. \\n";
                }

                //populate diploma
                DiplomaCertificate diploma = new DiplomaCertificate()
                {
                    ProgramID                 = int.Parse(ProgramID.Text),
                    ProgramName               = ProgramName.Text.Trim(),
                    ProgramLength             = ProgramLength.Text.Trim() + " " + ProgramLengthDDL.SelectedValue,
                    EntranceRequirementDetail = EntReqDetail.Text.Trim(),
                    CompetitveAdvantage       = competitiveAdvantage,
                    ProgramLink               = ProgramLink.Text.Trim(),
                    Activated                 = Activated.Checked,
                    WorkOutdoors              = WorkOutdoors.Checked,
                    ShiftWork                 = ShiftWork.Checked,
                    WorkTravel                = Travel.Checked,
                    CredentialType            = true,
                    CategoryID                = int.Parse(CategoryList.SelectedValue)
                };
                if (errorList != "")
                {
                    throw new Exception(errorList);
                }
                //process update
                //PathwaysController controller = new PathwaysController();
                controller.CertDiploma_Update(diploma);
                Clear_Click();
                Response.Write("<script type=\"text/javascript\">alert('The selected Diploma program has been updated.');</script>");
            }
            else if (InitialCredential.SelectedValue == "Degree")
            {
                //Validate non-string variables
                bool result = int.TryParse(ProgramLength.Text.Trim(), out temp);
                if (!result)
                {
                    errorList += "- Please enter a numeric value into the program length field (whole number only). \\n";
                }
                if (temp != 0)
                {
                    if ((int.Parse(ProgramLength.Text.Trim())) < 0 || (int.Parse(ProgramLength.Text)) > 100)
                    {
                        errorList += "- Program length must be a whole number between 1 - 99. \\n";
                    }
                }
                //Validate URL
                result = Uri.TryCreate(ProgramLink.Text.Trim(), UriKind.Absolute, out tempUrl) && tempUrl.Scheme == Uri.UriSchemeHttp;
                if (!result)
                {
                    errorList += "- Please enter a properly formatted URL (ex. http://www.example.com). \\n";
                }

                PathwaysController controller = new PathwaysController();
                if (ProgramLinkCompare.Value != ProgramLink.Text.Trim())
                {
                    //verify the URL does not exist
                    bool checkURL = controller.CheckDegUrl(ProgramLink.Text.Trim());
                    if (checkURL == false)
                    {
                        errorList += "- The url selected currently exists in the system, and cannot be repeated.\\n";
                    }
                }

                //verify the name does not exist
                if (ProgramNameCompare.Value != ProgramName.Text.Trim())
                {
                    bool checkName = controller.CheckProgramName(ProgramName.Text.Trim());
                    if (checkName == false)
                    {
                        errorList += "- The Program Name selected currently exists in the system, and cannot be repeated.\\n";
                    }
                }

                //Validate field lengths
                if (ProgramName.Text.Trim().Length > 100)
                {
                    errorList += "- Program Name cannot exceed 100 characters. \\n";
                }

                if (ProgramLink.Text.Trim().Length > 150)
                {
                    errorList += "- Program Link cannot exceed 150 characters. \\n";
                }

                //populate degree
                Degree degree = new Degree()
                {
                    DegreeID     = int.Parse(ProgramID.Text),
                    DegreeName   = ProgramName.Text.Trim(),
                    DegreeLength = ProgramLength.Text.Trim() + " " + ProgramLengthDDL.SelectedValue,
                    DegreeLink   = ProgramLink.Text.Trim(),
                    Activated    = Activated.Checked,
                    WorkOutdoors = WorkOutdoors.Checked,
                    ShiftWork    = ShiftWork.Checked,
                    WorkTravel   = Travel.Checked,
                    CategoryID   = int.Parse(CategoryList.SelectedValue)
                };

                if (errorList != "")
                {
                    throw new Exception(errorList);
                }
                //process update
                //PathwaysController controller = new PathwaysController();
                controller.Degree_Update(degree);
                Clear_Click();
                Response.Write("<script type=\"text/javascript\">alert('The selected Degree program has been updated.');</script>");
            }
            else
            {
            }
        });
    }