protected void cldGroupApplicant_DayRender(object sender, DayRenderEventArgs e) { if (IsCanRender == true) { BLL.ExamScheduleBiz biz = new BLL.ExamScheduleBiz(); Func <string, string> GetCrit = anyString => { return(string.IsNullOrEmpty(anyString) ? string.Empty : anyString); }; string strExamPlaceGroup = GetCrit(ddlPlaceGroup.SelectedValue); string strExamPlace = GetCrit(ddlPlace.SelectedValue); string strLicenseType = GetCrit(ddlTypeLicense.SelectedValue); string strYearMonth = string.Empty; strYearMonth = GetCrit(ConvertToYearMonth(e.Day.Date.Month)); string strTime = GetCrit(ddlTime.SelectedValue); var ls = biz.GetExamByCriteria(strExamPlaceGroup, strExamPlace, strLicenseType, strYearMonth, strTime, null, 0, 0, false); DataSet ds = ls.DataResponse; if (ds != null) { DataTable dt = ds.Tables[0]; var list = dt.AsEnumerable().Select(s => s.Field <DateTime>("TESTING_DATE")).Distinct().ToList(); DateTime dtToday = DateTime.Today.AddDays(-1); DateTime dtFinish = DateTime.Today.AddDays(+5); for (int i = 0; i < list.Count; i++) { ExamRender examrender = new ExamRender(); if (e.Day.Date == list[i].Date) { e.Cell.Controls.Add(new LiteralControl("</br>")); Label lbl = new Label { ID = "btn" + i.ToString(), Text = "รายละเอียด" }; e.Cell.Controls.Add(lbl); } if (e.Day.Date == list[i].Date && list[i].Date > dtToday && list[i].Date <= dtFinish) { examrender.IsSetProperty = true; e.Cell.Enabled = false; e.Day.IsSelectable = false; e.Cell.ForeColor = System.Drawing.Color.Gray; } } } } }
private void SelectDataFrombase() { try { DateTime visibleMonth = new DateTime((txtYear.Text.ToInt() - 543), ddlMonth.SelectedValue.ToInt(), 1); BLL.ExamScheduleBiz biz = new BLL.ExamScheduleBiz(); Func <string, string> GetCrit = anyString => { return(string.IsNullOrEmpty(anyString) ? string.Empty : anyString); }; string strTime = GetCrit(ddlTime.SelectedIndex == 0 ? "" : ddlTime.SelectedValue); DTO.Exams.GetExamByCriteriaRequest request = new DTO.Exams.GetExamByCriteriaRequest(); request.ExamPlaceGroupCode = ddlPlaceGroup.SelectedValue; // strExamPlaceGroup; request.ExamPlaceCode = ddlPlace.SelectedValue; request.LicenseTypeCode = ddlTypeLicense.SelectedValue; request.Year = visibleMonth.Year; request.Month = visibleMonth.Month; request.TimeCode = ddlTime.SelectedValue; request.Owner = ""; request.TestingDate = ""; var ls = biz.GetExamByCriteria(request); if (ls.IsError) { throw new ApplicationException(ls.ErrorMsg); } GBBiz gbBiz = new GBBiz(); DTO.ResponseService <DTO.GBHoliday[]> lsHoliday = gbBiz.GetHolidayListByYearMonth(visibleMonth.ToString("yyyyMM", System.Globalization.CultureInfo.CreateSpecificCulture("en-US"))); ExamSchedules = ls.DataResponse.ExamShedules; Holidays = lsHoliday.DataResponse.ToList(); } catch (Exception ex) { LoggerFactory.CreateLog().LogError("ไม่สามารถเรียกข้อมูลได้.", ex); String a = ex.Message; } }
// โหลดข้อมูลปฏิทินจากเงื่อนไข private void BindExamScheduleCalendarByCriteria(DateTime date) { Func <string, string> GetCrit = anyString => { return(string.IsNullOrEmpty(anyString) ? string.Empty : anyString); }; string strExamPlaceGroup = GetCrit(ddlPlaceGroup.SelectedValue); string strExamPlace = GetCrit(ddlPlace.SelectedValue); string strLicenseType = GetCrit(ddlTypeLicense.SelectedValue); string strYearMonth = GetCrit(ConvertToYearMonth()); string strTime = GetCrit(ddlTime.SelectedValue); BLL.ExamScheduleBiz biz = new BLL.ExamScheduleBiz(); var ls = biz.GetExamByCriteria(strExamPlaceGroup, strExamPlace, strLicenseType, strYearMonth, strTime, null, 0, 0, false); DataSet ds = ls.DataResponse; if (ds.Tables.Count > 0) { DataTable dt = ds.Tables[0]; var list = dt.AsEnumerable().Select(s => s.Field <DateTime>("TESTING_DATE")).Distinct().ToList(); for (int i = 0; i < list.Count; i++) { if (date.Day == list[i].Date.Day) { Controls.Add(new LiteralControl("</br>")); Label lbl = new Label { ID = "btn" + i.ToString(), Text = "รายละเอียด" }; Controls.Add(lbl); } } } cldGroupApplicant.TodaysDate = date; upn.Update(); }
protected void cldGroupApplicant_CLICK(Boolean CountAgain)//code เดิมพี่ฟิลด์แค่มาเพิ่มboolean กับตรงที่regionไว้ { gvGroupApplicant.Visible = true; DateTime cldselectDate = cldGroupApplicant.SelectedDate; BLL.ExamScheduleBiz biz = new BLL.ExamScheduleBiz(); string strYear = cldGroupApplicant.SelectedDate.Year.ToString(); string strMonth = cldGroupApplicant.SelectedDate.Month.ToString(); if (cldGroupApplicant.SelectedDate.Month < 10) { strMonth = "0" + strMonth; } #region page int Rpage = (txtNumberGvSearch.Text.Trim() == "") ? 0 : txtNumberGvSearch.Text.Trim().ToInt(); int resultPage = (Rpage == 0) ? 1 : txtNumberGvSearch.Text.Trim().ToInt(); resultPage = resultPage == 0 ? 1 : resultPage; if ((rowPerpage.Text.Trim() == null) || (rowPerpage.Text.Trim() == "") || (rowPerpage.Text.Trim() == "0")) { rowPerpage.Text = PageSize.ToString(); } else { PageSize = Convert.ToInt32(rowPerpage.Text); } #endregion page if (CountAgain) { #region Page var CountPage = biz.GetExamByCriteria("", "", "", "", strYear + strMonth, "", cldselectDate, resultPage, PageSize, true); if (CountPage.DataResponse != null) { if (CountPage.DataResponse.Tables[0].Rows.Count > 0) { Int64 totalROWs = Convert.ToInt32(CountPage.DataResponse.Tables[0].Rows[0]["CCount"].ToString()); VisibleGV(gvGroupApplicant, totalROWs, Convert.ToInt32(rowPerpage.Text), true); if (Rpage == 0) { NPbutton(btnPreviousGvSearch, txtNumberGvSearch, btnNextGvSearch, "", txtTotalPage); } } else { VisibleGV(gvGroupApplicant, 0, Convert.ToInt32(rowPerpage.Text), true); if (Rpage == 0) { NPbutton(btnPreviousGvSearch, txtNumberGvSearch, btnNextGvSearch, "", txtTotalPage); } txtTotalPage.Text = "1"; } } #endregion Page } var res = biz.GetExamByCriteria("", "", "", strYear + strMonth, "", cldselectDate, resultPage, PageSize, false); gvGroupApplicant.DataSource = res.DataResponse; gvGroupApplicant.DataBind(); }
// โหลดข้อมูลตาราง private void BindExamScheduleByTable(Boolean CountAgain) { #region page int Rpage = (txt_page_now.Text.Trim() == "") ? 0 : txt_page_now.Text.Trim().ToInt(); int resultPage = (Rpage == 0) ? 1 : txt_page_now.Text.Trim().ToInt(); resultPage = resultPage == 0 ? 1 : resultPage; if ((txt_input.Text.Trim() == null) || (txt_input.Text.Trim() == "") || (txt_input.Text.Trim() == "0")) { txt_input.Text = PageSize.ToString(); } else { PageSize = Convert.ToInt32(txt_input.Text); } #endregion page BLL.ExamScheduleBiz biz = new BLL.ExamScheduleBiz(); Func <string, string> GetCrit = anyString => { return(string.IsNullOrEmpty(anyString) ? string.Empty : anyString); }; string strExamPlaceGroup = GetCrit(ddlPlaceGroup.SelectedValue); string strExamPlace = GetCrit(ddlPlace.SelectedValue); string strLicenseType = GetCrit(ddlTypeLicense.SelectedIndex == 0 ? "" : ddlTypeLicense.SelectedValue); string strYearMonth = GetCrit(ConvertToYearMonth()); string strTime = GetCrit(ddlTime.SelectedIndex == 0 ? "" : ddlTime.SelectedValue); if (CountAgain) { #region Page var CountPage = biz.GetExamByCriteria(strExamPlaceGroup, strExamPlace, strLicenseType, strYearMonth, strTime, null, resultPage, PageSize, true); if (CountPage.DataResponse != null) { if (CountPage.DataResponse.Tables[0].Rows.Count > 0) { Int64 totalROWs = Convert.ToInt32(CountPage.DataResponse.Tables[0].Rows[0]["CCount"].ToString()); VisibleGV(gvTable, totalROWs, Convert.ToInt32(txt_input.Text), true); if (Rpage == 0) { NPbutton(btnP_table, txt_page_now, btnN_table, "", lbl_pageMax); } } else { VisibleGV(gvTable, 0, Convert.ToInt32(txt_input.Text), true); if (Rpage == 0) { NPbutton(btnP_table, txt_page_now, btnN_table, "", lbl_pageMax); } lbl_pageMax.Text = "1"; } } #endregion Page } var ls = biz.GetExamByCriteria(strExamPlaceGroup, strExamPlace, strLicenseType, strYearMonth, strTime, null, resultPage, PageSize, false); gvTable.DataSource = ls.DataResponse; gvTable.DataBind(); }