public IEnumerable<tblEnglish> searchArticleByClassAndTime(ArticleSCO articleSCO) { LTDHDataContext DB = new LTDHDataContext(@strPathDB); int start = 0; int end = 0; int year = BaseServices.getYearFromString(articleSCO.Time); IEnumerable<tblEnglish> lst = null; //if (articleSCO.Classes == CommonConstants.PARAM_EL_COMMON) //{ // start = CommonConstants.AT_EL_CLASS_START; // end = CommonConstants.AT_EL_CLASS_END; //} //else if (articleSCO.Classes == CommonConstants.PARAM_EL_MAJOR) //{ // start = CommonConstants.AT_EL_MJ_START; // end = CommonConstants.AT_EL_MJ_END; //} //else if (articleSCO.Classes == CommonConstants.PARAM_EL_CERT) //{ // start = CommonConstants.AT_EL_CERT_START; // end = CommonConstants.AT_EL_CERT_END; //} //else if (articleSCO.Classes == CommonConstants.PARAM_EL_CLASS_1_TO_9) //{ // start = CommonConstants.AT_EL_CLASS_1; // end = CommonConstants.AT_EL_CLASS_9; //} //else if (articleSCO.Classes == CommonConstants.PARAM_EL_MATH_ECO) //{ // start = CommonConstants.AT_EL_MJ_MATH; // end = CommonConstants.AT_EL_MJ_ECO; //} //else if (articleSCO.Classes == CommonConstants.PARAM_EL_CHEM_BIO_MAT) //{ // start = CommonConstants.AT_EL_MJ_CHEM; // end = CommonConstants.AT_EL_MJ_MATERIAL; //} //else if (articleSCO.Classes == CommonConstants.PARAM_EL_PHY_TELE_IT) //{ // start = CommonConstants.AT_EL_MJ_PHY; // end = CommonConstants.AT_EL_MJ_IT; //} //else if (articleSCO.Classes == CommonConstants.PARAM_EL_OTHER_MJ) //{ // start = CommonConstants.AT_EL_MJ_IT + 1; // end = CommonConstants.AT_EL_MJ_END; //} //else if (articleSCO.Classes == CommonConstants.PARAM_EL_TOEIC) //{ // start = CommonConstants.AT_EL_CERT_TOEIC_START; // end = CommonConstants.AT_EL_CERT_TOEIC_END; //} //else if (articleSCO.Classes == CommonConstants.PARAM_EL_TOEFL) //{ // start = CommonConstants.AT_EL_CERT_TOEFL_START; // end = CommonConstants.AT_EL_CERT_TOEFL_END; //} //else if (articleSCO.Classes == CommonConstants.PARAM_EL_IELTS) //{ // start = CommonConstants.AT_EL_CERT_IELTS_START; // end = CommonConstants.AT_EL_CERT_IELTS_END; //} //else if (articleSCO.Classes == CommonConstants.PARAM_EL_ABC) //{ // start = CommonConstants.AT_EL_CERT_ABC_START; // end = CommonConstants.AT_EL_CERT_ABC_END; //} locateArticleIndex(articleSCO, out start, out end); if (start > 0 && end > 0 && end >= start) { lst = (from p in DB.tblEnglishes where p.Posted.Year <= year && p.State != CommonConstants.STATE_UNCHECK && p.StickyFlg == false && p.Class >= start && p.Class <= end && p.DeleteFlg == false orderby p.Posted descending select p).Skip(articleSCO.FirstRecord).Take(articleSCO.NumArticleOnPage); } else if (articleSCO.Classes == CommonConstants.ALL) { lst = (from p in DB.tblEnglishes where p.Posted.Year <= year && p.State != CommonConstants.STATE_UNCHECK && p.StickyFlg == false && p.DeleteFlg == false orderby p.Posted descending select p).Skip(articleSCO.FirstRecord).Take(articleSCO.NumArticleOnPage); } return lst; }
private void locateArticleIndex(ArticleSCO articleSCO,out int start, out int end) { start = 0; end = 0; if (articleSCO != null) { if (articleSCO.Classes == CommonConstants.PARAM_EL_COMMON) { start = CommonConstants.AT_EL_CLASS_START; end = CommonConstants.AT_EL_CLASS_END; } else if (articleSCO.Classes == CommonConstants.PARAM_EL_MAJOR) { start = CommonConstants.AT_EL_MJ_START; end = CommonConstants.AT_EL_MJ_END; } else if (articleSCO.Classes == CommonConstants.PARAM_EL_CLASS_1_TO_9) { start = CommonConstants.AT_EL_CLASS_1; end = CommonConstants.AT_EL_CLASS_9; } else if (articleSCO.Classes == CommonConstants.PARAM_EL_CERT) { start = CommonConstants.AT_EL_CERT_TOEFL_START; end = CommonConstants.AT_EL_CERT_ABC_END; } else if (articleSCO.Classes == CommonConstants.AT_EL_CLASS_12_CODE) { start = CommonConstants.AT_EL_CLASS_2; end = start; } else if (articleSCO.Classes == CommonConstants.AT_EL_CLASS_11_CODE) { start = CommonConstants.AT_EL_CLASS_11; end = start; } else if (articleSCO.Classes == CommonConstants.AT_EL_CLASS_10_CODE) { start = CommonConstants.AT_EL_CLASS_10; end = start; } else if (articleSCO.Classes == CommonConstants.PARAM_EL_MATH_ECO) { start = CommonConstants.AT_EL_MJ_MATH; end = CommonConstants.AT_EL_MJ_ECO; } else if (articleSCO.Classes == CommonConstants.PARAM_EL_CHEM_BIO_MAT) { start = CommonConstants.AT_EL_MJ_CHEM; end = CommonConstants.AT_EL_MJ_MATERIAL; } else if (articleSCO.Classes == CommonConstants.PARAM_EL_PHY_TELE_IT) { start = CommonConstants.AT_EL_MJ_PHY; end = CommonConstants.AT_EL_MJ_IT; } else if (articleSCO.Classes == CommonConstants.PARAM_EL_OTHER_MJ) { start = CommonConstants.AT_EL_MJ_IT + 1; end = CommonConstants.AT_EL_MJ_END; } else if (articleSCO.Classes == CommonConstants.PARAM_EL_TOEIC) { start = CommonConstants.AT_EL_CERT_TOEIC_START; end = CommonConstants.AT_EL_CERT_TOEIC_END; } else if (articleSCO.Classes == CommonConstants.PARAM_EL_TOEFL) { start = CommonConstants.AT_EL_CERT_TOEFL_START; end = CommonConstants.AT_EL_CERT_TOEFL_END; } else if (articleSCO.Classes == CommonConstants.PARAM_EL_IELTS) { start = CommonConstants.AT_EL_CERT_IELTS_START; end = CommonConstants.AT_EL_CERT_IELTS_END; } else if (articleSCO.Classes == CommonConstants.PARAM_EL_ABC) { start = CommonConstants.AT_EL_CERT_ABC_START; end = CommonConstants.AT_EL_CERT_ABC_END; } } }
public int countTotalArticles(ArticleSCO articleSCO) { int num = 0; if (articleSCO != null) { LTDHDataContext DB = new LTDHDataContext(@strPathDB); int start = 0; int end = 0; int year = BaseServices.getYearFromString(articleSCO.Time); locateArticleIndex(articleSCO, out start, out end); if (articleSCO.Classes == CommonConstants.ALL) { num = (from p in DB.tblEnglishes where p.State != CommonConstants.STATE_UNCHECK && p.Posted.Year < year && p.DeleteFlg == false select p).Count(); } if (start > 0 && end > 0 && end >= start) { return (from p in DB.tblEnglishes where p.State != CommonConstants.STATE_UNCHECK && p.Posted.Year <= year && p.Class >= start && p.Class <= end && p.DeleteFlg == false select p).Count(); } } return num; }
protected void Page_Load(object sender, EventArgs e) { liTitleHeader.Text = CommonConstants.PAGE_ENGLISH_NAME + CommonConstants.SPACE + CommonConstants.HLINE + CommonConstants.SPACE + control.getValueString(CommonConstants.CF_TITLE_ON_HEADER); lblTitle.Text = CommonConstants.BLANK; numberArtOnPage = control.getValueByInt(CommonConstants.CF_NUM_ARTICLE_ON_EL); if (numberArtOnPage < 1) { numberArtOnPage = CommonConstants.DEFAULT_NUMBER_RECORD_ON_TAB; } ArticleSCO articleSCO = new ArticleSCO(); try { articleSCO.Classes = BaseServices.nullToBlank(Request.QueryString[CommonConstants.REQ_CLASS]); articleSCO.Time = BaseServices.nullToBlank(Request.QueryString[CommonConstants.REQ_TIME]); articleSCO.CurrentPage = BaseServices.convertStringToInt(BaseServices.nullToBlank(Request.QueryString[CommonConstants.REQ_PAGE])); articleSCO.NumArticleOnPage = numberArtOnPage; if (BaseServices.isNullOrBlank(articleSCO.Classes)) { articleSCO.Classes = CommonConstants.ALL; } if (BaseServices.isNullOrBlank(articleSCO.Time)) { articleSCO.Time = CommonConstants.NOW; } articleSCO.TotalRecord = englishDAO.countTotalArticles(articleSCO); if (articleSCO.TotalRecord > 0) { string classes = BaseServices.getNameSubjectByCode(articleSCO.Classes); if (classes != CommonConstants.ALL && !BaseServices.isNullOrBlank(classes)) { lblTitle.Text += classes; } else { lblTitle.Text = CommonConstants.TXT_ENGLISH; } articleSCO.FirstRecord = BaseServices.getRecordFrom(articleSCO.CurrentPage, articleSCO.NumArticleOnPage); articleSCO.TotalPage = BaseServices.getTotalPage(articleSCO.TotalRecord, articleSCO.NumArticleOnPage); if (articleSCO.CurrentPage <= articleSCO.TotalPage && articleSCO.CurrentPage >= BaseServices.convertStringToInt(CommonConstants.PAGE_NUMBER_FIRST)) { if (articleSCO.CurrentPage == BaseServices.convertStringToInt(CommonConstants.PAGE_NUMBER_FIRST)) { IEnumerable<tblEnglish> slst = englishDAO.searchStickyArticleByClassAndTime(articleSCO); if (slst != null) { list_stickyItems.Text = listSItem(slst.ToList(), articleSCO.NumArticleOnPage); } } IEnumerable<tblEnglish> lst = englishDAO.searchArticleByClassAndTime(articleSCO); if (lst != null) { list_items.Text = listItem(lst.ToList()); lDataPager.Text = CommonConstants.TEMP_HR_TAG + BaseServices.createPagingLink(BaseServices.createMsgByTemplate(CommonConstants.TEMP_ENGLISH_URL, articleSCO.Classes, articleSCO.Time), articleSCO.CurrentPage, articleSCO.TotalPage); } } //lblOlderLinks.Text = getOlderLinks(articleSCO); } if (BaseServices.isNullOrBlank(list_items.Text)) { if (BaseServices.isNullOrBlank(list_stickyItems.Text)) { list_items.Text = CommonConstants.MSG_I_ARTICLE_EMPTY_RECORD; } lDataPager.Visible = false; } } catch (Exception ex) { tblUser user = (tblUser)Session[CommonConstants.SES_USER]; string username = CommonConstants.USER_GUEST; if (user != null) { username = user.Username; } log.writeLog(Server.MapPath(CommonConstants.PATH_LOG_FILE), username, ex.Message); log.writeLog(Server.MapPath(CommonConstants.PATH_LOG_FILE), username, ex.StackTrace); Session[CommonConstants.SES_ERROR] = CommonConstants.MSG_E_COMMON_ERROR_TEXT; Response.Redirect(CommonConstants.PAGE_ERROR); } }
public IEnumerable<tblEnglish> searchArticles(ArticleSCO articleSCO) { /*IEnumerable<tblEnglish> lst1 = searchArticleByClassAndTime(articleSCO); IEnumerable<tblEnglish> lst2 = searchStickyArticleByClassAndTime(articleSCO); if(lst2 != null) { if( lst2.Count() > 0) { //lst2.ToList().AddRange(lst1.ToList()); /*int n = lst1.Count(); for (int i = 0; i < n; i++) { lst2.ToList().Add(lst1.ElementAt(i)); } //lst1 = lst2; List<tblEnglish> l = lst1.ToList(); l.Add(lst1.ElementAt(8)); IEnumerable<tblEnglish> h = l; List<tblEnglish> l2 = lst2.ToList(); l2.AddRange(lst1.ToList()); lst1 = l2; } } return lst1;*/ IEnumerable<tblEnglish> lst1 = null; if (articleSCO.CurrentPage == 1) { lst1 = searchStickyArticleByClassAndTime(articleSCO); } if (lst1 != null) { int remain = articleSCO.NumArticleOnPage - lst1.Count(); articleSCO.NumArticleOnPage = remain; } IEnumerable<tblEnglish> lst2 = searchArticleByClassAndTime(articleSCO); if (lst1 != null) { if (lst1.Count() > 0) { List<tblEnglish> l1 = lst1.ToList(); l1.AddRange(lst2.ToList()); lst2 = l1; } } return lst2; }
public IEnumerable<tblInformatic> searchArticle(ArticleSCO articleSCO) { IEnumerable<tblInformatic> lst1 = null; if (articleSCO.CurrentPage == 1) { lst1 = searchLatestStickyArticle(articleSCO); } if (lst1 != null) { int remain = articleSCO.NumArticleOnPage - lst1.Count(); articleSCO.NumArticleOnPage = remain; } IEnumerable<tblInformatic> lst2 = searchLatestArticle(articleSCO); if (lst1 != null) { if (lst1.Count() > 0) { List<tblInformatic> l1 = lst1.ToList(); l1.AddRange(lst2.ToList()); lst2 = l1; } } return lst2; }
//protected void DataPagerArticles_PreRender(object sender, EventArgs e) //{ // ArticleSCO articleSCO = new ArticleSCO(); // articleSCO = (ArticleSCO)Session[CommonConstants.SES_ARTICLE_SCO]; // lblTitle.Text = CommonConstants.SEC_ENGLISH_NAME; // if (articleSCO != null) // { // try // { // if (BaseServices.isNullOrBlank(articleSCO.Classes)) // { // articleSCO.Classes = CommonConstants.ALL; // } // if (BaseServices.isNullOrBlank(articleSCO.Time)) // { // articleSCO.Time = CommonConstants.NOW; // } // if (!BaseServices.isNullOrBlank(articleSCO.Classes) && !BaseServices.isNullOrBlank(articleSCO.Time)) // { // string classes = BaseServices.getNameSubjectByCode(articleSCO.Classes); // if (classes != CommonConstants.ALL && classes != CommonConstants.BLANK) // { // lblTitle.Text += CommonConstants.SPACE; // lblTitle.Text += CommonConstants.BAR; // lblTitle.Text += CommonConstants.SPACE; // lblTitle.Text += classes; // } // IEnumerable<tblEnglish> lst = englishDAO.searchArticles(articleSCO, numberArtOnPage); // productList.DataSource = lst; // productList.DataBind(); // //lblOlderLinks.Text = getOlderLinks(articleSCO); // } // } // catch (Exception ex) // { // tblUser user = (tblUser)Session[CommonConstants.SES_USER]; // string username = CommonConstants.USER_GUEST; // if (user != null) // { // username = user.Username; // } // log.writeLog(Server.MapPath(CommonConstants.PATH_LOG_FILE), username, ex.Message); // Session[CommonConstants.SES_ERROR] = CommonConstants.MSG_COMMON_ERROR_TEXT; // Response.Redirect(CommonConstants.PAGE_ERROR); // } // } //} private string getOlderLinks(ArticleSCO articleSCO) { articleSCO.Section = CommonConstants.SEC_ENGLISH_CODE; string links = service.createOlderLink(CommonConstants.TEMP_ENGLISH_LINK, articleSCO, 10); return links; }
public int countTotalRecord(ArticleSCO articleSCO) { int num = 0; int start = 0; int end = 0; int year = BaseServices.getYearFromString(articleSCO.Time); LTDHDataContext DB = new LTDHDataContext(@strPathDB); locateArticleIndex(articleSCO, out start, out end); /*if (articleSCO.Leitmotif == CommonConstants.PARAM_IT_OFFICE) { start = CommonConstants.AT_IT_OFFICE_START; end = CommonConstants.AT_IT_OFFICE_END; } else if (articleSCO.Leitmotif == CommonConstants.PARAM_IT_SIMPLE) { start = CommonConstants.AT_IT_SIMPLE_TIP; end = CommonConstants.AT_IT_SIMPLE_TIP; } else if (articleSCO.Leitmotif == CommonConstants.PARAM_IT_ADVANCE) { start = CommonConstants.AT_IT_ADVANCE_TIP; end = CommonConstants.AT_IT_ADVANCE_TIP; } else if (articleSCO.Leitmotif == CommonConstants.PARAM_IT_OFFICE_WORD) { start = CommonConstants.AT_IT_OFFICE_WORD; end = start; } else if (articleSCO.Leitmotif == CommonConstants.PARAM_IT_OFFICE_EXCEL) { start = CommonConstants.AT_IT_OFFICE_EXCEL; end = start; } else if (articleSCO.Leitmotif == CommonConstants.PARAM_IT_OFFICE_PP) { start = CommonConstants.AT_IT_OFFICE_POWERPOINT; end = start; } else if (articleSCO.Leitmotif == CommonConstants.PARAM_IT_OFFICE_ACCESS) { start = CommonConstants.AT_IT_OFFICE_ACCESS; end = start; } else */ if (articleSCO.Leitmotif == CommonConstants.ALL) { return (from p in DB.tblInformatics where p.Posted.Year <= year && p.State != CommonConstants.STATE_UNCHECK && p.DeleteFlg == false select p).Count(); } if (start > 0 && end > 0 && end >= start) { num = (from p in DB.tblInformatics where p.Posted.Year <= year && p.State != CommonConstants.STATE_UNCHECK && p.Leitmotif >= start && p.Leitmotif <= end && p.DeleteFlg == false select p).Count(); } return num; }
private void locateArticleIndex(ArticleSCO articleSCO, out int start, out int end) { start = 0; end = 0; if (articleSCO.Leitmotif == CommonConstants.PARAM_IT_OFFICE) { start = CommonConstants.AT_IT_OFFICE_START; end = CommonConstants.AT_IT_OFFICE_END; } else if (articleSCO.Leitmotif == CommonConstants.PARAM_IT_TIP_SIMPLE) { start = CommonConstants.AT_IT_SIMPLE_TIP_START; end = CommonConstants.AT_IT_SIMPLE_TIP_END; } else if (articleSCO.Leitmotif == CommonConstants.PARAM_IT_TIP_ADVANCE) { start = CommonConstants.AT_IT_ADVANCE_TIP_START; end = CommonConstants.AT_IT_ADVANCE_TIP_END; } else if (articleSCO.Leitmotif == CommonConstants.PARAM_IT_OFFICE_WORD) { start = CommonConstants.AT_IT_OFFICE_WORD; end = start; } else if (articleSCO.Leitmotif == CommonConstants.PARAM_IT_OFFICE_EXCEL) { start = CommonConstants.AT_IT_OFFICE_EXCEL; end = start; } else if (articleSCO.Leitmotif == CommonConstants.PARAM_IT_OFFICE_PP) { start = CommonConstants.AT_IT_OFFICE_POWERPOINT; end = start; } else if (articleSCO.Leitmotif == CommonConstants.PARAM_IT_OFFICE_ACCESS) { start = CommonConstants.AT_IT_OFFICE_ACCESS; end = start; } }
public IEnumerable<tblInformatic> searchLatestArticle(ArticleSCO articleSCO) { LTDHDataContext DB = new LTDHDataContext(@strPathDB); IEnumerable<tblInformatic> lst = null; int start = 0; int end = 0; int year = BaseServices.getYearFromString(articleSCO.Time); locateArticleIndex(articleSCO, out start, out end); /*if (articleSCO.Leitmotif == CommonConstants.PARAM_IT_OFFICE) { start = CommonConstants.AT_IT_OFFICE_START; end = CommonConstants.AT_IT_OFFICE_END; } else if (articleSCO.Leitmotif == CommonConstants.PARAM_IT_SIMPLE) { start = CommonConstants.AT_IT_SIMPLE_TIP; end = CommonConstants.AT_IT_SIMPLE_TIP; } else if (articleSCO.Leitmotif == CommonConstants.PARAM_IT_ADVANCE) { start = CommonConstants.AT_IT_ADVANCE_TIP; end = CommonConstants.AT_IT_ADVANCE_TIP; } else if (articleSCO.Leitmotif == CommonConstants.PARAM_IT_OFFICE_WORD) { start = CommonConstants.AT_IT_OFFICE_WORD; end = start; } else if (articleSCO.Leitmotif == CommonConstants.PARAM_IT_OFFICE_EXCEL) { start = CommonConstants.AT_IT_OFFICE_EXCEL; end = start; } else if (articleSCO.Leitmotif == CommonConstants.PARAM_IT_OFFICE_PP) { start = CommonConstants.AT_IT_OFFICE_POWERPOINT; end = start; } else if (articleSCO.Leitmotif == CommonConstants.PARAM_IT_OFFICE_ACCESS) { start = CommonConstants.AT_IT_OFFICE_ACCESS; end = start; }*/ if (articleSCO.Leitmotif == CommonConstants.ALL) { return (from p in DB.tblInformatics where p.Posted.Year <= year && p.State != CommonConstants.STATE_UNCHECK && p.StickyFlg == false && p.DeleteFlg == false select p).Skip(articleSCO.FirstRecord).Take(articleSCO.NumArticleOnPage); } if (start > 0 && end > 0 && end >= start) { lst = (from p in DB.tblInformatics where p.Posted.Year <= year && p.State != CommonConstants.STATE_UNCHECK && p.Leitmotif >= start && p.Leitmotif <= end && p.StickyFlg == false && p.DeleteFlg == false select p).Skip(articleSCO.FirstRecord).Take(articleSCO.NumArticleOnPage); } return lst; }
public IEnumerable<tblInformatic> searchLatestStickyArticle(ArticleSCO articleSCO) { LTDHDataContext DB = new LTDHDataContext(@strPathDB); IEnumerable<tblInformatic> lst = null; int start = 0; int end = 0; int year = BaseServices.getYearFromString(articleSCO.Time); locateArticleIndex(articleSCO, out start, out end); if (articleSCO.Leitmotif == CommonConstants.ALL) { return (from p in DB.tblInformatics where p.Posted.Year <= year && p.State != CommonConstants.STATE_UNCHECK && p.StickyFlg == true && p.DeleteFlg == false select p).Skip(articleSCO.FirstRecord).Take(articleSCO.NumArticleOnPage); } if (start > 0 && end > 0 && end >= start) { lst = (from p in DB.tblInformatics where p.Posted.Year <= year && p.State != CommonConstants.STATE_UNCHECK && p.Leitmotif >= start && p.Leitmotif <= end && p.StickyFlg == true && p.DeleteFlg == false select p).Skip(articleSCO.FirstRecord).Take(articleSCO.NumArticleOnPage); } return lst; }
public string createOlderLink(string linkTemplate, ArticleSCO articleSCO, int numberOlder) { string links = CommonConstants.BLANK; int startYear = getYearFromString(CommonConstants.NOW); int selectedYear = getYearFromString(articleSCO.Time); if (articleSCO.Section == CommonConstants.SEC_UNIVERSITY_CODE) { for (int i = startYear; i >= 2000; i--) { if (i == selectedYear) { links += String.Format(CommonConstants.TEMP_LABEL_TAG, i.ToString()); } else { links += String.Format(linkTemplate, articleSCO.Subject, i.ToString(), CommonConstants.PAGE_NUMBER_FIRST, i.ToString()); } links += CommonConstants.SPACE; } } return links; }
public void Page_Load(object sender, EventArgs e) { liTitle.Text = CommonConstants.PAGE_UNIVERSITY_NAME + CommonConstants.SPACE + CommonConstants.HLINE + CommonConstants.SPACE + control.getValueString(CommonConstants.CF_TITLE_ON_HEADER); numberArtOnPage = control.getValueByInt(CommonConstants.CF_NUM_ARTICLE_ON_UNI); if (numberArtOnPage < 1) { numberArtOnPage = CommonConstants.DEFAULT_NUMBER_RECORD_ON_TAB; } ArticleSCO articleSCO = new ArticleSCO(); try { articleSCO.Subject = BaseServices.nullToBlank(Request.QueryString[CommonConstants.REQ_SUBJECT]); articleSCO.Time = BaseServices.nullToBlank(Request.QueryString[CommonConstants.REQ_TIME]); articleSCO.CurrentPage = BaseServices.convertStringToInt(BaseServices.nullToBlank(Request.QueryString[CommonConstants.REQ_PAGE])); articleSCO.NumArticleOnPage = numberArtOnPage; Session[CommonConstants.SES_ARTICLE_SCO] = articleSCO; lblTitle.Text = CommonConstants.SEC_UNIVERSITY_NAME; if (!IsPostBack) { if(BaseServices.isNullOrBlank(articleSCO.Subject)) { articleSCO.Subject = CommonConstants.ALL; } if(BaseServices.isNullOrBlank(articleSCO.Time)) { articleSCO.Time = CommonConstants.NOW; } articleSCO.TotalRecord = contestDAO.countTotalRecord(articleSCO); if (articleSCO.TotalRecord > 0) { articleSCO.FirstRecord = BaseServices.getRecordFrom(articleSCO.CurrentPage, articleSCO.NumArticleOnPage); articleSCO.TotalPage = BaseServices.getTotalPage(articleSCO.TotalRecord, articleSCO.NumArticleOnPage); string subject = BaseServices.getNameSubjectByCode(articleSCO.Subject); if (subject != CommonConstants.ALL) { lblTitle.Text += CommonConstants.SPACE; lblTitle.Text += CommonConstants.BAR; lblTitle.Text += CommonConstants.SPACE; lblTitle.Text += subject; } if (articleSCO.CurrentPage <= articleSCO.TotalPage && articleSCO.CurrentPage >= BaseServices.convertStringToInt(CommonConstants.PAGE_NUMBER_FIRST)) { if (articleSCO.CurrentPage == BaseServices.convertStringToInt(CommonConstants.PAGE_NUMBER_FIRST)) { IEnumerable<tblContestForUniversity> slst = contestDAO.searchLatestStickyArticles(articleSCO); if (slst != null) { list_stickyItems.Text = listSItem(slst.ToList(), articleSCO.NumArticleOnPage); } } IEnumerable<tblContestForUniversity> lst = contestDAO.searchLatestArticleBySubjectAndTime(articleSCO); if (lst != null) { list_items.Text = listItem(lst.ToList()); lDataPager.Text = CommonConstants.TEMP_HR_TAG + BaseServices.createPagingLink(BaseServices.createMsgByTemplate(CommonConstants.TEMP_UNI_URL, articleSCO.Subject, articleSCO.Time), articleSCO.CurrentPage, articleSCO.TotalPage); } lblOlderLinks.Text = getOlderLinks(articleSCO); } } } } catch (Exception ex) { tblUser user = (tblUser)Session[CommonConstants.SES_USER]; string username = CommonConstants.USER_GUEST; if (user != null) { username = user.Username; } log.writeLog(Server.MapPath(CommonConstants.PATH_LOG_FILE), username, ex.Message + CommonConstants.NEWLINE + ex.StackTrace); Session[CommonConstants.SES_ERROR] = CommonConstants.MSG_E_COMMON_ERROR_TEXT; Response.Redirect(CommonConstants.PAGE_ERROR); } }
protected void Page_Load(object sender, EventArgs e) { liTitle.Text = CommonConstants.PAGE_INFORMATICS_NAME + CommonConstants.SPACE + CommonConstants.HLINE + CommonConstants.SPACE + control.getValueString(CommonConstants.CF_TITLE_ON_HEADER); lblSubTitle.Text = CommonConstants.PAGE_INFORMATICS_NAME; ArticleSCO articleSCO = new ArticleSCO(); numberArtOnPage = control.getValueByInt(CommonConstants.CF_NUM_ARTICLE_ON_IT); if (numberArtOnPage < 1) { numberArtOnPage = CommonConstants.DEFAULT_NUMBER_RECORD_ON_TAB; } articleSCO.CurrentPage = BaseServices.convertStringToInt(Request.QueryString[CommonConstants.REQ_PAGE]); articleSCO.Leitmotif = BaseServices.nullToBlank(Request.QueryString[CommonConstants.REQ_LEITMOTIF]); articleSCO.Time = BaseServices.nullToBlank(Request.QueryString[CommonConstants.REQ_TIME]); articleSCO.NumArticleOnPage = numberArtOnPage; if (BaseServices.isNullOrBlank(articleSCO.Leitmotif)) { articleSCO.Leitmotif = CommonConstants.ALL; } if (BaseServices.isNullOrBlank(articleSCO.Time)) { articleSCO.Time = CommonConstants.NOW; } articleSCO.TotalRecord = infoDAO.countTotalRecord(articleSCO); bool hasRecord = false; bool hasSRecord = false; if (articleSCO.TotalRecord > 0) { articleSCO.FirstRecord = BaseServices.getRecordFrom(articleSCO.CurrentPage, articleSCO.NumArticleOnPage); articleSCO.TotalPage = BaseServices.getTotalPage(articleSCO.TotalRecord, articleSCO.NumArticleOnPage); if (articleSCO.CurrentPage <= articleSCO.TotalPage && articleSCO.CurrentPage >= BaseServices.convertStringToInt(CommonConstants.PAGE_NUMBER_FIRST)) { if (articleSCO.CurrentPage == 1) { IEnumerable<tblInformatic> slst = infoDAO.searchLatestStickyArticle(articleSCO); if (slst != null) { hasSRecord = true; list_stickyItems.Text = listSItem(slst.ToList(), articleSCO.NumArticleOnPage); } } IEnumerable<tblInformatic> lst = infoDAO.searchLatestArticle(articleSCO); if (lst != null) { if (lst.Count() > 0) { hasRecord = true; list_items.Text = listItem(lst.ToList()); lDataPager.Text = CommonConstants.TEMP_HR_TAG + BaseServices.createPagingLink(BaseServices.createMsgByTemplate(CommonConstants.TEMP_INFORMATICS_URL, articleSCO.Leitmotif, articleSCO.Time), articleSCO.CurrentPage, articleSCO.TotalPage); } } } } if(!hasRecord) { if (!hasSRecord) { list_items.Text = CommonConstants.MSG_I_ARTICLE_EMPTY_RECORD; } lDataPager.Visible = false; } }
public int countTotalRecord(ArticleSCO articleSCO) { LTDHDataContext DB = new LTDHDataContext(@strPathDB); int num = 0; if (articleSCO.Subject == CommonConstants.ALL) { num = (from p in DB.tblContestForUniversities where p.Year <= BaseServices.getYearFromString(articleSCO.Time) && p.State != CommonConstants.STATE_UNCHECK && p.DeleteFlg == false orderby p.Year descending select p).Count(); } else { num = (from p in DB.tblContestForUniversities where p.Subject == articleSCO.Subject && p.Year <= BaseServices.getYearFromString(articleSCO.Time) && p.State != CommonConstants.STATE_UNCHECK && p.DeleteFlg == false orderby p.Year descending select p).Count(); } return num; }
public IEnumerable<tblContestForUniversity> searchLatestStickyArticles(ArticleSCO articleSCO) { LTDHDataContext DB = new LTDHDataContext(@strPathDB); IEnumerable<tblContestForUniversity> lst = null; if (articleSCO.Subject == CommonConstants.ALL) { lst = from p in DB.tblContestForUniversities where p.Year <= BaseServices.getYearFromString(articleSCO.Time) && p.State != CommonConstants.STATE_UNCHECK && p.StickyFlg == true && p.DeleteFlg == false orderby p.Year descending select p; } else { lst = from p in DB.tblContestForUniversities where p.Subject == articleSCO.Subject && p.Year <= BaseServices.getYearFromString(articleSCO.Time) && p.State != CommonConstants.STATE_UNCHECK && p.StickyFlg == true && p.DeleteFlg == false orderby p.Year descending select p; } return lst; }