예제 #1
0
    //string sSortOrder = string.Empty;


    #endregion

    #region Page_Load

    /// <summary>
    /// Call every time when page load occur
    /// </summary>
    /// <param name="sender">sender object</param>
    /// <param name="e">EventArgs</param>
    protected void Page_Load(object sender, EventArgs e)
    {
        int iPageIndex = 0;
        int totalCount = 0;

        #region Check Session Data

        //if no search keywords for course record found in the session then redirect to the FindProviders.aspx page
        if (Session[LACESConstant.SessionKeys.COURSE_RECORD_OBJ] == null)
        {
            Response.Redirect("Default.aspx");
        }

        CourseRecord oCourseRecord = (CourseRecord)Session[LACESConstant.SessionKeys.COURSE_RECORD_OBJ];
        title.InnerHtml = "Search Results for: " + Server.HtmlEncode(oCourseRecord.FirstName) + " " + Server.HtmlEncode(oCourseRecord.LastName);

        #endregion

        #region Check Query String Data



        ///Check Sort Column Query String
        //if (Request.QueryString[LACESConstant.QueryString.SORT_COLUMN] != null)
        //{
        //    sSortColumn = Request.QueryString[LACESConstant.QueryString.SORT_COLUMN].ToString();
        //}

        /////Check Sort Order Query String
        //if (Request.QueryString[LACESConstant.QueryString.SORT_ORDER] != null)
        //{
        //    sSortOrder = Request.QueryString[LACESConstant.QueryString.SORT_ORDER].ToString();
        //}

        sSortColumn = "StartDate Desc";

        ///Check Current Page Index Query String
        if (Request.QueryString[LACESConstant.QueryString.PAGE_INDEX] != null)
        {
            iPageIndex = Convert.ToInt32(Request.QueryString[LACESConstant.QueryString.PAGE_INDEX].ToString());
        }
        else
        {
            iPageIndex = 0;
        }

        #endregion

        #region Search

        CourseRecordDataAccess courseRecordDAL = new CourseRecordDataAccess();
        courseResult = courseRecordDAL.GetPagedCourseRecordBySearch(buildSearchCriteria(), iPageIndex, LACESConstant.SEARCH_RESULT_PAGE_SIZE, sSortColumn, ref totalCount);
        uiRptCourseRecordResults.DataSource = courseResult;
        uiRptCourseRecordResults.DataBind();
        #endregion

        ///Generate PreviousPage NextPage link
        setPreviousNextPage(iPageIndex, totalCount);
    }
예제 #2
0
    /// <summary>
    /// Call every time when click on the export link
    /// </summary>
    /// <param name="sender">Sender object</param>
    /// <param name="e">EventArgs</param>
    protected void btnExport_Click(object sender, EventArgs e)
    {
        int totalCount = 0;
        CourseRecordDataAccess courseRecordDAL = new CourseRecordDataAccess();

        courseResult = courseRecordDAL.GetPagedCourseRecordBySearch(buildSearchCriteria(), 0, Int16.MaxValue, "StartDate", ref totalCount);


        for (int i = 0; i < courseResult.Count; i++)
        {
            if (courseResult[i].DistanceEducation == "N")
            {
                courseResult[i].DistanceEducation = "No";
            }
            else if (courseResult[i].DistanceEducation == "Y")
            {
                courseResult[i].DistanceEducation = "Yes";
            }
        }

        DataTable dtCources = new DataTable("SearchResult");

        dtCources.Columns.Add("ID", typeof(long));
        dtCources.Columns.Add("StartDate", typeof(string));
        dtCources.Columns.Add("EndDate", typeof(string));
        dtCources.Columns.Add("CourseTitle", typeof(string));
        dtCources.Columns.Add("Location", typeof(string));
        dtCources.Columns.Add("DistanceLearning", typeof(string));
        dtCources.Columns.Add("Hours", typeof(string));
        dtCources.Columns.Add("HSWClassification", typeof(string));
        dtCources.Columns.Add("CourseCodes", typeof(string));
        dtCources.Columns.Add("Provider", typeof(string));
        //dtCources.Columns.Add("ProviderId", typeof(long));

        foreach (Course c in courseResult)
        {
            DataRow newRow = dtCources.NewRow();
            newRow["ID"]                = c.ID;
            newRow["StartDate"]         = c.StartDate.Month.ToString() + "/" + c.StartDate.Day.ToString() + "/" + c.StartDate.Year.ToString();
            newRow["EndDate"]           = c.EndDate.Month.ToString() + "/" + c.EndDate.Day.ToString() + "/" + c.EndDate.Year.ToString();
            newRow["CourseTitle"]       = c.Title;
            newRow["Location"]          = getFormattedLocation(c);
            newRow["DistanceLearning"]  = c.DistanceEducation;
            newRow["Hours"]             = c.Hours;
            newRow["HSWClassification"] = c.Healths;
            newRow["CourseCodes"]       = populateCourseCodeInfo(c.ID);
            newRow["Provider"]          = c.ProviderName;
            dtCources.Rows.Add(newRow);
        }

        int[]    iColumns;
        string[] sHeaders;

        if (dtCources != null && dtCources.Rows.Count > 0)
        {
            iColumns = new int[9];

            iColumns.SetValue(1, 0);
            iColumns.SetValue(2, 1);
            iColumns.SetValue(3, 2);
            iColumns.SetValue(4, 3);
            iColumns.SetValue(5, 4);
            iColumns.SetValue(6, 5);
            iColumns.SetValue(7, 6);
            iColumns.SetValue(8, 7);
            iColumns.SetValue(9, 8);

            sHeaders = new string[9];
            sHeaders.SetValue("StartDate", 0);
            sHeaders.SetValue("EndDate", 1);
            sHeaders.SetValue("CourseTitle", 2);
            sHeaders.SetValue("Location", 3);
            sHeaders.SetValue("DistanceLearning", 4);
            sHeaders.SetValue("Hours", 5);
            sHeaders.SetValue("Health,SafetyandWelfare", 6);
            sHeaders.SetValue("CourseCodes", 7);
            sHeaders.SetValue("Provider", 8);

            LACES.ExportData.Export objExport = new LACES.ExportData.Export("Web");
            objExport.ExportDetails(dtCources, iColumns, sHeaders, LACES.ExportData.Export.ExportFormat.CSV, "SearchResult.csv");
        }
        else
        {
            //lblMessage.Visible = true;
            //lblMessage.Text = "No data available to be exported.";
        }
    }