コード例 #1
0
ファイル: CourseDetails.aspx.cs プロジェクト: kstengle/sites
    /// <summary>
    ///  Update Course Code of the Course
    /// </summary>
    /// <param name="courseID">CourseId</param>
    private void updateCourseCode(long courseID)
    {
        CourseCodeDataAccess codeDAL = new CourseCodeDataAccess();

        codeDAL.DeleteCourseCodeByCourseID(courseID); // Delete course codes of the Course

        string[] descList = splitString(courseDesc);
        string[] typeList = splitString(courseType);
        //string[] typeList = courseType.Split('|');

        if (!courseType.Equals(string.Empty))
        {
            for (int i = 0; i < typeList.Length; i++)
            {
                CourseCode code = new CourseCode();
                code.Description = descList[i];
                code.CodeID      = Convert.ToInt32(typeList[i]);
                code.CourseID    = courseID;
                try
                {
                    codeDAL.AddCourseCode(code); // Add course Code
                }
                catch (Exception ex)
                {
                    Session["AdminCourseCodeFailed"] = "yes";
                }
            }
        }
        populateCourseCodeInfo(courseID); // on Load script for populating the Course code after page refresh.
    }
コード例 #2
0
ファイル: CourseDetails.aspx.cs プロジェクト: kstengle/sites
    /// <summary>
    ///  Populate Course Code Information
    /// </summary>
    /// <param name="courseID"></param>
    private void populateCourseCodeInfo(long courseID)
    {
        CourseCodeDataAccess courseCodeDAL  = new CourseCodeDataAccess();
        IList <CourseCode>   courseCodeList = courseCodeDAL.GetAllCourseCodeByCourseID(courseID); // Get all Course code of the course

        // On load Script for Populate Course Code Dynamic Table in Edit Mode
        string StartupScriptString = "<script language=\"JavaScript\">";

        StartupScriptString += "function initializeValueOnLoad(){ init(); ";

        foreach (CourseCode courseCode in courseCodeList)
        {
            StartupScriptString += " AddNewCourseCodeTypeRow(\"" + courseCode.Description.Replace("\"", "&quot;").Replace("\\", "\\\\") + "\",\"" + courseCode.CodeType + "\",\"" + courseCode.CodeID + "\",\"" + txtTitle.ClientID + "\"); ";

            // Starts - used for Prompting user for unsaved Course Code when navigating
            if (courseTypeValue == string.Empty)
            {
                courseTypeValue = courseCode.CodeID.ToString();
                courseDescValue = courseCode.Description.Replace("\"", "\"");
            }
            else
            {
                courseTypeValue = courseTypeValue + delimiter + courseCode.CodeID.ToString();
                courseDescValue = courseDescValue + delimiter + courseCode.Description.Replace("\"", "\"");  //&quot;
            }
            //txtHidType.Text = courseTypeValue + courseDescValue;
            // Ends - used for Prompting user for unsaved Course Code when navigating
        }
        StartupScriptString += " } ";
        StartupScriptString += " window.onload = initializeValueOnLoad; ";
        StartupScriptString += " </script> ";

        Page.ClientScript.RegisterStartupScript(System.Type.GetType("System.String"), "PageIni", StartupScriptString);
    }
コード例 #3
0
    /// <summary>
    ///  Populate comma seperated Course Code Information
    /// </summary>
    /// <param name="courseID"></param>
    protected string populateCourseCodeInfo(long courseID)
    {
        CourseCodeDataAccess courseCodeDAL  = new CourseCodeDataAccess();
        IList <CourseCode>   courseCodeList = courseCodeDAL.GetAllCourseCodeByCourseID(courseID); // Get all Course code of the course

        string courseCodes = "";

        foreach (CourseCode courseCode in courseCodeList)
        {
            courseCodes += courseCode.CodeType.ToString() + ": " + courseCode.Description.Replace("\"", "\"") + ", ";
        }

        if (courseCodes.LastIndexOf(',') > 1)
        {
            courseCodes = courseCodes.Substring(0, courseCodes.LastIndexOf(','));
        }

        return(courseCodes);
    }
コード例 #4
0
ファイル: UploadCourses.aspx.cs プロジェクト: kstengle/sites
    private bool UploadExcelFile()
    {
        try
        {
            //get the course id from query string
            List <Course> courseList = new List <Course>();

            //create the file loacton
            FileStream oFileStream = File.Create(fileLocation);

            foreach (byte b in FileUpload1.FileBytes)
            {
                oFileStream.WriteByte(b);
            }
            oFileStream.Close();
            Course oCourse = null;

            DataTable oDataTable = LACESUtilities.ReadXLFile(fileLocation, "Courses");

            bool                      useNext  = false;
            ApprovedProvider          provider = (ApprovedProvider)Session[LACESConstant.SessionKeys.LOGEDIN_APPROVED_PROVIDER]; // get approved provider information from Session
            System.Text.StringBuilder sbResult = new System.Text.StringBuilder();
            foreach (DataRow dr in oDataTable.Rows)
            {
                oCourse = new Course();

                string strCol1 = dr[0].ToString().Trim();

                if (useNext)
                {
                    bool   isAllRequiredFilled = true;
                    string strCourseTitle      = dr[0].ToString().Trim();
                    oCourse.Title = strCourseTitle;
                    string strCourseRegUrl = dr[1].ToString().Trim();
                    oCourse.Hyperlink = strCourseRegUrl;
                    string strRegEligibility = dr[2].ToString().Trim();
                    oCourse.RegistrationEligibility = strRegEligibility;
                    string   strStartDate = dr[3].ToString().Trim();
                    DateTime dtStart;
                    if (DateTime.TryParse(strStartDate, out dtStart))
                    {
                        oCourse.StartDate = dtStart;
                    }
                    else
                    {
                        oCourse.StartDate = (DateTime)SqlDateTime.MinValue;
                    }

                    string   strEndDate = dr[4].ToString().Trim();
                    DateTime dtEndDate;
                    if (DateTime.TryParse(strEndDate, out dtEndDate))
                    {
                        oCourse.EndDate = dtStart;
                    }
                    else
                    {
                        oCourse.EndDate = (DateTime)SqlDateTime.MinValue;
                    }

                    string strDescription = dr[5].ToString().Trim();
                    oCourse.Description = strDescription;
                    string strCity = dr[6].ToString().Trim();
                    oCourse.City = strCity;
                    string strState = dr[7].ToString().Trim();
                    oCourse.StateProvince = strStartDate;
                    string strDistanceEd = dr[8].ToString();
                    if (strDistanceEd.Length == 0)
                    {
                        oCourse.DistanceEducation = " ";
                    }
                    else
                    {
                        oCourse.DistanceEducation = strDistanceEd;
                    }

                    string strCourseEquivalency = dr[9].ToString();
                    if (strCourseEquivalency.Length == 0)
                    {
                        oCourse.CourseEquivalency = " ";
                    }
                    else
                    {
                        oCourse.CourseEquivalency = strCourseEquivalency;
                    }
                    string strSubjects = dr[10].ToString().Trim();
                    oCourse.Subjects = strSubjects;
                    string strHealthSafety = dr[11].ToString().Trim();
                    oCourse.Healths = strHealthSafety;
                    string strPersonalDevelopmentHours = dr[12].ToString().Trim();
                    oCourse.Hours = strPersonalDevelopmentHours;
                    string strLearningOutcomes = dr[13].ToString().Trim();
                    oCourse.LearningOutcomes = strLearningOutcomes;
                    string strInstructors = dr[14].ToString().Trim();
                    oCourse.Instructors = strInstructors;
                    string strNoProprietary = dr[15].ToString().Trim();

                    string strCourseCode = dr[16].ToString().Trim();
                    oCourse.ProviderID = provider.ID;
                    string strCourseErrors = LACESUtilities.CheckCourseValid(oCourse);
                    //oCourse.OrgStateCourseIDNumber = strCourseCode;
                    if (strCourseErrors.Length == 0)
                    {
                        oCourse.Status = "NP";
                    }
                    else
                    {
                        oCourse.Status = "IC";
                    }
                    CourseDataAccess cd = new CourseDataAccess();
                    long             lngCourseID;
                    if (long.TryParse(cd.AddCourseDetails(oCourse).ToString(), out lngCourseID))
                    {
                        if (strCourseCode.Trim().Length > 0)
                        {
                            CourseCodeDataAccess codeDAL = new CourseCodeDataAccess();
                            CourseCode           code    = new CourseCode();
                            //code.Description = descList[i];
                            code.CodeID   = Convert.ToInt32(strCourseCode);
                            code.CourseID = lngCourseID;
                            try
                            {
                                codeDAL.AddCourseCode(code); // Add course Code
                            }
                            catch (Exception ex)
                            {
                                uiLblResults.Text = ex.Message;
                                Response.End();
                            }
                        }
                    }
                    if (strCourseErrors.Length == 0)
                    {
                        sbResult.Append("SUCCESS" + lngCourseID.ToString() + " - " + oCourse.Title);
                    }
                    else
                    {
                        sbResult.Append(lngCourseID.ToString() + " - " + oCourse.Title + "<br />" + strCourseErrors);
                    }
                }
                if (strCol1 == "*Course Title")
                {
                    useNext = true;
                }
                //long newCourse = cd.AddCourseDetails(oCourse);
            }
            uiLblResults.Text = sbResult.ToString();
        }
        catch (Exception ex)
        {
            Response.Write(ex.Message);
            Response.End();
        }
        return(false);
    }