Exemple #1
0
    public List <ILMPCourseGridVO> GetILMPCoursesForId(int ilmpId)
    {
        List <ILMPCourseGridVO> ilmpCourses = new List <ILMPCourseGridVO>();

        try
        {
            DBConnection.conn.Open();
            string query = "SELECT ic.CourseCode,c.Title,c.Credits,c.Level,cp.AllPrerequisites,ic.Semester,ic.Year,ic.Result, ic.CourseType " + //, ct.CourseType  " +
                           " FROM dbo.Ilmp i " +
                           " INNER JOIN dbo.IlmpCourse ic ON i.IlmpID=ic.IlmpID " +
                           " INNER JOIN dbo.Course c ON  c.CourseCode = ic.CourseCode " +
                           " INNER JOIN dbo.StudentMajor sm ON sm.StudentId = i.StudentID " +
                           //  " INNER JOIN dbo.CourseProgramme ct ON ct.ProgrammeID = sm.ProgrammeID and ct.MajorID = sm.MajorID and ct.CourseCode=ic.CourseCode " +
                           " LEFT JOIN dbo.CoursePrerequisite cp ON cp.CourseCode=c.CourseCode " +
                           " WHERE i.IlmpID=@IlmpID and sm.active='Yes' order by ic.year,ic.semester";
            SqlCommand cmd = new SqlCommand(query, DBConnection.conn);
            cmd.Parameters.AddWithValue("@IlmpID", ilmpId);
            SqlDataReader reader = cmd.ExecuteReader();
            if (reader.HasRows)
            {
                ILMPCourseGridVO ilmpCourse;
                while (reader.Read())
                {
                    ilmpCourse               = new ILMPCourseGridVO();
                    ilmpCourse.CourseCode    = reader["CourseCode"].ToString();
                    ilmpCourse.Title         = reader["Title"].ToString();
                    ilmpCourse.Credits       = Int32.Parse(reader["Credits"].ToString());
                    ilmpCourse.Level         = Int32.Parse(reader["Level"].ToString());
                    ilmpCourse.Prerequisites = reader["AllPrerequisites"].ToString();
                    ilmpCourse.Semester      = Int32.Parse(reader["Semester"].ToString());
                    ilmpCourse.Year          = Int32.Parse(reader["Year"].ToString());
                    ilmpCourse.CourseType    = reader["CourseType"].ToString();
                    ilmpCourse.Result        = reader["Result"].ToString();
                    ilmpCourses.Add(ilmpCourse);
                }
            }
        }
        catch (SqlException ex)
        {
            ExceptionUtility.LogException(ex, "Error Page");
            throw ex;
        }
        finally
        {
            if (DBConnection.conn != null)
            {
                DBConnection.conn.Close();
            }
        }
        return(ilmpCourses);
    }
Exemple #2
0
    //get course details for given programme and major
    public ILMPCourseGridVO GetCourseDetailsForTemplate(CourseProgrammeVO courseProgarmmeVO)
    {
        ILMPCourseGridVO ilmpcourseVO = new ILMPCourseGridVO();

        try
        {
            DBConnection.conn.Open();
            string query = "SELECT cpgm.CourseType,c.Title,c.Credits,c.Level,cp.AllPrerequisites from dbo.Course c" +
                           " INNER JOIN dbo.CourseProgramme cpgm ON cpgm.CourseCode=c.CourseCode" +
                           " LEFT JOIN dbo.CoursePrerequisite cp ON cp.CourseCode=c.CourseCode " +
                           " WHERE c.CourseCode = @CourseCode AND cpgm.ProgrammeID=@ProgrammeID AND cpgm.MajorID=@MajorID AND c.Active='Yes'";
            SqlCommand cmd = new SqlCommand(query, DBConnection.conn);
            cmd.Parameters.AddWithValue("@CourseCode", courseProgarmmeVO.CourseCode);
            cmd.Parameters.AddWithValue("@ProgrammeID", courseProgarmmeVO.ProgrammeId);
            cmd.Parameters.AddWithValue("@MajorID", courseProgarmmeVO.MajorId);
            SqlDataReader reader = cmd.ExecuteReader();
            if (reader.HasRows)
            {
                while (reader.Read())
                {
                    ilmpcourseVO.CourseType    = reader["CourseType"].ToString();
                    ilmpcourseVO.Title         = reader["Title"].ToString();
                    ilmpcourseVO.Credits       = Int32.Parse(reader["Credits"].ToString());
                    ilmpcourseVO.Level         = Int32.Parse(reader["Level"].ToString());
                    ilmpcourseVO.Prerequisites = reader["AllPrerequisites"].ToString();
                }
            }
        }
        catch (SqlException e)
        {
            ExceptionUtility.LogException(e, "Error Page");
            throw new CustomException(ApplicationConstants.UnhandledException + ": " + e.Message);
        }
        catch (Exception e)
        {
            ExceptionUtility.LogException(e, "Error Page");
            throw new CustomException(ApplicationConstants.UnhandledException + ": " + e.Message);
        }
        finally
        {
            if (DBConnection.conn != null)
            {
                DBConnection.conn.Close();
            }
        }
        return(ilmpcourseVO);
    }
Exemple #3
0
    public ILMPCourseGridVO GetCourseDetailsForTemplate(CourseProgrammeVO courseProgarmmeVO)
    {
        ILMPCourseGridVO ilmpcourse = courseobj.GetCourseDetailsForTemplate(courseProgarmmeVO);

        return(ilmpcourse);
    }
Exemple #4
0
    private void AddNewRowToCourseGrid(TemplateCourseVO templateCourseVO)
    {
        if (ViewState["CurrentTable"] != null)
        {
            DataTable dtCurrentTable = (DataTable)ViewState["CurrentTable"];
            DataRow   drCurrentRow   = null;

            if (dtCurrentTable.Rows.Count > 0)
            {
                drCurrentRow = dtCurrentTable.NewRow();
                //add new row to DataTable
                dtCurrentTable.Rows.Add(drCurrentRow);
                //Store the current data to ViewState
                ViewState["CurrentTable"] = dtCurrentTable;
                for (int i = 0; i < dtCurrentTable.Rows.Count - 1; i++)
                {
                    if (i != dtCurrentTable.Rows.Count - 2)
                    {
                    }
                    else
                    {
                        DropDownList ddl1 = (DropDownList)gvIlmp.Rows[i].Cells[2].FindControl("ddSemester");
                        DropDownList ddl2 = (DropDownList)gvIlmp.Rows[i].Cells[3].FindControl("ddYear");

                        // Update the DataRow with the DDL Selected Items
                        dtCurrentTable.Rows[i]["Column1"] = templateCourseVO.CourseCode;
                        CourseProgrammeVO coursePgmVO = new CourseProgrammeVO();
                        coursePgmVO.CourseCode  = templateCourseVO.CourseCode;
                        coursePgmVO.ProgrammeId = ddProgramme.SelectedItem.Value;
                        coursePgmVO.MajorId     = ddMajor.SelectedItem.Value;
                        ILMPCourseGridVO ilmpCourseGridVO = new ILMPCourseGridVO();
                        // for custom template, course may not be in same major selected
                        if (rbtnILMPTemplateType.SelectedItem.Text == "Generic")
                        {
                            ilmpCourseGridVO = courseBO.GetCourseDetailsForTemplate(coursePgmVO);
                            dtCurrentTable.Rows[i]["Column2"] = ilmpCourseGridVO.CourseType;
                            dtCurrentTable.Rows[i]["Column5"] = ilmpCourseGridVO.Title;
                            dtCurrentTable.Rows[i]["Column6"] = ilmpCourseGridVO.Credits;
                            dtCurrentTable.Rows[i]["Column7"] = ilmpCourseGridVO.Level;
                            dtCurrentTable.Rows[i]["Column8"] = ilmpCourseGridVO.Prerequisites;
                        }
                        else
                        {
                            CourseVO courseVO = courseBO.GetCourseDetailsForCourseCode(coursePgmVO.CourseCode);
                            dtCurrentTable.Rows[i]["Column2"] = "COM";
                            dtCurrentTable.Rows[i]["Column5"] = courseVO.Title;
                            dtCurrentTable.Rows[i]["Column6"] = courseVO.Credits;
                            dtCurrentTable.Rows[i]["Column7"] = courseVO.Level;
                            dtCurrentTable.Rows[i]["Column8"] = courseVO.Prerequisites.AllPrerequisites;
                        }

                        // fills the semester dropdown from courseoffering. If there is any courseoffering, by default first value coming from db will be selected in semester dropdown
                        FillSemesterDropDown(ddl1, coursePgmVO.CourseCode);
                        // checks whether courseoffering is present by checking semster default selected value
                        if (ddl1.SelectedItem != null && ddl1.SelectedItem.Text != "Select")
                        {
                            dtCurrentTable.Rows[i]["Column3"] = templateCourseVO.Semester; //set the selected semester of dropdown to semester from ILMP template
                            FillYearDropDown(ddl2, coursePgmVO.CourseCode, int.Parse(ddl1.SelectedItem.Text));
                        }
                        if (ddl2.SelectedItem != null)
                        {
                            dtCurrentTable.Rows[i]["Column4"] = templateCourseVO.Year;//set the selected year of dropdown to year from ILMP template
                        }
                    }
                }
                //Rebind the Grid with the current data
                gvIlmp.DataSource = dtCurrentTable;
                gvIlmp.DataBind();
            }
        }
        else
        {
            ScriptManager.RegisterClientScriptBlock(this.Page, this.Page.GetType(), "alert", "alert(' ViewState is null ');", true);
            // Response.Write("ViewState is null");
        }

        //Set Previous Data on Postbacks
        SetPreviousDataInCourseGrid();
    }