Пример #1
0
        public string loadMaxPointArticle()
        {
            string data = CommonConstants.BLANK;
            string temp = CommonConstants.BLANK;
            string sum = CommonConstants.BLANK;
            ltktDAO.Contest contestDAO = new ltktDAO.Contest();
            ltktDAO.English englishDAO = new ltktDAO.English();
            ltktDAO.Informatics inforDAO = new ltktDAO.Informatics();
            BaseServices bs = new BaseServices();

            tblContestForUniversity uni = contestDAO.getMaxPoint();
            tblEnglish el = englishDAO.getMaxPoint();
            tblInformatic it = inforDAO.getMaxPoint();
            if (uni != null)
            {
                temp = BaseServices.createMsgByTemplate(CommonConstants.TEMP_ARTICLE_DETAILS_LINK,
                                                        CommonConstants.SEC_UNIVERSITY_CODE,
                                                        uni.ID.ToString(),
                                                        BaseServices.createMsgByTemplate(CommonConstants.TEMP_STRONG_TAG,
                                                                                        uni.Title.Trim()));

                sum = uni.Contents.Trim();
                if (!BaseServices.isNullOrBlank(sum))
                {
                    temp += CommonConstants.SPACE + bs.subString(sum);
                }
                data += BaseServices.createMsgByTemplate(CommonConstants.TEMP_LI_TAG, temp);
            }
            if (el != null)
            {
                temp = BaseServices.createMsgByTemplate(CommonConstants.TEMP_ARTICLE_DETAILS_LINK,
                                                        CommonConstants.SEC_UNIVERSITY_CODE,
                                                        el.ID.ToString(),
                                                        BaseServices.createMsgByTemplate(CommonConstants.TEMP_STRONG_TAG,
                                                                                       el.Title.Trim()));
                sum = el.Contents.Trim();
                if (!BaseServices.isNullOrBlank(sum))
                {
                    temp += CommonConstants.SPACE + bs.subString(sum);
                }
                data += BaseServices.createMsgByTemplate(CommonConstants.TEMP_LI_TAG, temp);
            }
            if (it != null)
            {
                temp = BaseServices.createMsgByTemplate(CommonConstants.TEMP_ARTICLE_DETAILS_LINK,
                                                        CommonConstants.SEC_UNIVERSITY_CODE,
                                                        it.ID.ToString(),
                                                        BaseServices.createMsgByTemplate(CommonConstants.TEMP_STRONG_TAG,
                                                                                        it.Title.Trim()));
                sum = it.Contents.Trim();
                if (!BaseServices.isNullOrBlank(sum))
                {
                    temp += CommonConstants.SPACE + bs.subString(sum);
                }
                data += BaseServices.createMsgByTemplate(CommonConstants.TEMP_LI_TAG, temp);
            }
            return data;
        }
Пример #2
0
        /// <summary>
        /// build exam lesson for university
        /// </summary>
        /// <param name="item"></param>
        /// <returns></returns>
        private string buildExamLessonForUniversity(tblContestForUniversity item)
        {
            string res = CommonConstants.BLANK;
            try
            {
                BaseServices bs = new BaseServices();
                res += "                <div class='block_details'>\n"
                        + "                <div class='block_details_img'>\n"
                        + "                    <span title='" + item.Title.Trim() + "'>"
                        + BaseServices.createMsgByTemplate(CommonConstants.TEMP_IMG_THUMBNAIL, bs.getThumbnail(item.Thumbnail, item.Location), item.Title.Trim())
                        + "</span>\n"
                        + "                </div>\n"
                        + "                <div class='block_details_title'>\n"
                        + "                    <span title='" + item.Title.Trim() + "'>"
                        + BaseServices.createMsgByTemplate(CommonConstants.TEMP_ARTICLE_DETAILS_LINK, CommonConstants.SEC_UNIVERSITY_CODE, item.ID.ToString(), bs.subString(item.Title))
                        + "</span>\n"
                        + "                </div>\n"
                        + "                <div class='block_details_text'>\n"
                        + "                    " + BaseServices.getNameSubjectByCode(item.Subject.Trim()) + "<br />\n"
                        + contestDAO.getBranch(item.ID) + "<br/>\n"
                        + item.Year
                        + "                </div>\n"
                        + "            </div>\n";
            }
            catch (Exception ex)
            {
                log.writeLog(Server.MapPath(CommonConstants.PATH_LOG_FILE), ex.Message
                                                                            + CommonConstants.NEWLINE
                                                                            + ex.Source
                                                                            + CommonConstants.NEWLINE
                                                                            + ex.StackTrace
                                                                            + CommonConstants.NEWLINE
                                                                            + ex.HelpLink);
                Session[CommonConstants.SES_ERROR] = CommonConstants.MSG_E_COMMON_ERROR_TEXT;
                Response.Redirect(CommonConstants.PAGE_ERROR);
            }

            return res;
        }
Пример #3
0
        private void showNews(int page)
        {
            int totalNews = newsDAO.countNews();
            // Computing total pages
            int totalPages;
            int mod = totalNews % NoOfNewsPerPage;

            IEnumerable<tblNew> lst = newsDAO.fetchNewsList(((page - 1) * NoOfNewsPerPage), NoOfNewsPerPage);

            if (mod == 0)
            {
                totalPages = totalNews / NoOfNewsPerPage;
            }
            else
            {
                totalPages = ((totalNews - mod) / NoOfNewsPerPage) + 1;
            }
            BaseServices bs = new BaseServices();
            for (int idx = 0; idx < lst.Count(); ++idx)
            {
                tblNew news = lst.ElementAt(idx);

                TableCell noCell = new TableCell();
                noCell.CssClass = "table-cell";
                noCell.Style["width"] = "20px";
                noCell.Text = Convert.ToString(idx + 1 + (page - 1) * NoOfNewsPerPage);

                TableCell titleCell = new TableCell();
                titleCell.CssClass = "table-cell";
                //titleCell.Style["width"] = "300px";
                titleCell.Text = String.Format(DisplayNewsLink, news.ID, news.Title);

                TableCell postedCell = new TableCell();
                postedCell.CssClass = "table-cell";
                postedCell.Style["width"] = "80px";
                postedCell.Text = bs.convertDateToString(news.Posted);

                TableCell authorCell = new TableCell();
                authorCell.CssClass = "table-cell";
                authorCell.Style["width"] = "80px";
                authorCell.Text = news.Author;

                TableCell actionCell = new TableCell();
                actionCell.CssClass = "table-cell";
                actionCell.Style["width"] = "40px";
                actionCell.Text = BaseServices.createMsgByTemplate(CommonConstants.TEMP_DISPLAY_LINK,
                                                                     CommonConstants.PAGE_ADMIN_NEWS,
                                                                     CommonConstants.ACT_EDIT,
                                                                     Convert.ToString(news.ID),
                                                                     CommonConstants.HTML_EDIT_ADMIN);

                actionCell.Text += BaseServices.createMsgByTemplate(CommonConstants.TEMP_DISPLAY_LINK,
                                                                     CommonConstants.PAGE_ADMIN_NEWS,
                                                                     CommonConstants.ACT_DELETE,
                                                                     Convert.ToString(news.ID),
                                                                     CommonConstants.HTML_DELETE_ADMIN);

                TableRow newsRow = new TableRow();
                newsRow.Cells.Add(noCell);
                newsRow.Cells.Add(titleCell);
                newsRow.Cells.Add(postedCell);
                newsRow.Cells.Add(authorCell);
                newsRow.Cells.Add(actionCell);

                NewsTable.Rows.AddAt(2 + idx, newsRow);
                string totatRecord = BaseServices.createMsgByTemplate(CommonConstants.TEMP_B_TAG, totalNews.ToString());
                NumRecordLiteral.Text = BaseServices.createMsgByTemplate(CommonConstants.MSG_I_NUM_SEARCHED_RECORD, totatRecord);
            }

            // Creating links to previous and next pages
            if (totalPages > 1)
            {
                if (page > 1)
                    PreviousPageLiteral.Text = BaseServices.createMsgByTemplate(CommonConstants.TEMP_SELF_LINK,
                                                                                CommonConstants.PAGE_ADMIN_NEWS,
                                                                                (page - 1).ToString(),
                                                                                CommonConstants.TXT_PREVIOUS_PAGE);

                if (page > 0 && page < totalPages)
                    NextPageLiteral.Text = BaseServices.createMsgByTemplate (CommonConstants.TEMP_SELF_LINK,
                                                                             CommonConstants.PAGE_ADMIN_NEWS,
                                                                             (page + 1).ToString(),
                                                                             CommonConstants.TXT_NEXT_PAGE);
            }
        }
Пример #4
0
 /// <summary>
 /// build article for informatics
 /// </summary>
 /// <param name="item"></param>
 /// <returns></returns>
 private string buildArticleForInformatics(tblInformatic item)
 {
     string data = CommonConstants.BLANK;
     try
     {
         BaseServices bs = new BaseServices();
         data += "              <div class='block_details'>\n"
                 + "                <div class='block_details_img'>\n"
                 + "                    <span title='" + item.Title + "'>"
                 + BaseServices.createMsgByTemplate(CommonConstants.TEMP_IMG_THUMBNAIL, bs.getThumbnail(item.Thumbnail, item.Location), item.Title.Trim())
                 + "</span>\n"
                 + "                </div>\n"
                 + "                <div class='block_details_title'>\n"
                 + "                    <span title='" + item.Title + "'>"
                 + BaseServices.createMsgByTemplate(CommonConstants.TEMP_ARTICLE_DETAILS_LINK, CommonConstants.SEC_INFORMATICS_CODE, item.ID.ToString(), bs.subString(item.Title))
                 + "</span>\n"
                 + "                </div>\n"
                 + "            </div>\n";
     }
     catch (Exception ex)
     {
         log.writeLog(Server.MapPath(CommonConstants.PATH_LOG_FILE), ex.Message
                                                                     + CommonConstants.NEWLINE
                                                                     + ex.Source
                                                                     + CommonConstants.NEWLINE
                                                                     + ex.StackTrace
                                                                     + CommonConstants.NEWLINE
                                                                     + ex.HelpLink);
         Session[CommonConstants.SES_ERROR] = CommonConstants.MSG_E_COMMON_ERROR_TEXT;
         Response.Redirect(CommonConstants.PAGE_ERROR);
     }
     return data;
 }
Пример #5
0
        protected void btnEdit_Click(object sender, EventArgs e)
        {
            //save wellcome text
            string wellcomeText = Server.HtmlDecode(txtWellcomeText.Text.Trim());
            controlDao.setValue(CommonConstants.CF_WELCOME_TEXT, wellcomeText);
            //title header
            controlDao.setValue(CommonConstants.CF_TITLE_ON_HEADER, txtTitleHeader.Text.Trim());
            //title footer
            controlDao.setValue(CommonConstants.CF_TITLE_ON_FOOTER, txtTitleFooter.Text.Trim());
            //max file size
            controlDao.setValue(CommonConstants.CF_MAX_FILE_SIZE, txtMaxFileSize.Text.Trim());
            //valid file type
            controlDao.setValue(CommonConstants.CF_FILE_TYPE_ALLOW, txtValidExtension.Text.Trim());
            //valid img file
            controlDao.setValue(CommonConstants.CF_IMG_FILE_TYPE_ALLOW, txtValidImageExtension.Text.Trim());
            //max img file sizw
            controlDao.setValue(CommonConstants.CF_IMG_FILE_SIZE_MAX, txtMaxFileImgSize.Text.Trim());
            //Announcement
            controlDao.setValue(CommonConstants.CF_ANNOUCEMENT, txtAnouncement.Text.Trim());
            //email config
            controlDao.setValue(CommonConstants.CF_EMAIL_CONFIG, txtEmailConfig.Text.Trim());
            //num article on contest
            controlDao.setValue(CommonConstants.CF_NUM_ARTICLE_ON_UNI, txtNumArtOnContest.Text.Trim());
            //num article on english
            controlDao.setValue(CommonConstants.CF_NUM_ARTICLE_ON_EL, txtNumArtOnEnglish.Text.Trim());
            //num article on it
            controlDao.setValue(CommonConstants.CF_NUM_ARTICLE_ON_IT, txtNumArtOnInformatics.Text.Trim());
            //num article on tab
            controlDao.setValue(CommonConstants.CF_NUM_ARTICLE_ON_TAB, txtNumArtOnTab.Text.Trim());
            //num article on sticky
            controlDao.setValue(CommonConstants.CF_NUM_ARTICLE_STICKY, txtNumArtSticky.Text.Trim());
            //num relative article
            controlDao.setValue(CommonConstants.CF_NUM_RECORD_RELATIVE, txtNumRelativeArt.Text.Trim());
            //address
            controlDao.setValue(CommonConstants.CF_ADDRESS, txtAddress.Text);
            //upload thumbnail
            string _fileThumbnail = CommonConstants.BLANK;
            string rootFolder = Server.MapPath("~") + "/" + CommonConstants.FOLDER_IMAGES;
            BaseServices bs = new BaseServices();
            string fileTypes = controlDao.getValueString(CommonConstants.CF_FILE_TYPE_ALLOW);
            //check filesize max (KB)
            int fileSizeMax = 0;
            if (fileThumbnail.HasFile)
            {
                //check file existed: keep both
                _fileThumbnail = fileThumbnail.FileName;

                _fileThumbnail = bs.fileNameToSave(rootFolder + "/" + _fileThumbnail);
                //filename = rootFolder + newFileName;

                //check filetype
                fileTypes = controlDao.getValueString(CommonConstants.CF_IMG_FILE_TYPE_ALLOW);
                if (!bs.checkFileType(fileThumbnail.FileName, fileTypes))
                {
                    showErrorMessage(CommonConstants.MSG_E_FILE_SIZE_IS_NOT_ALLOW);
                    return;
                }
                //check filesize max (KB)
                fileSizeMax = controlDao.getValueByInt(CommonConstants.CF_IMG_FILE_SIZE_MAX);
                fileSizeMax = 1024 * fileSizeMax;
                if (fileThumbnail.PostedFile.ContentLength > fileSizeMax)
                {
                    showErrorMessage(CommonConstants.MSG_E_FILE_SIZE_IS_TOO_LARGE);
                    return;
                }
                //logo
                controlDao.setValue(CommonConstants.CF_LOGO, CommonConstants.FOLDER_IMAGES + "/" + fileThumbnail.FileName);
                string folder = Path.GetDirectoryName(_fileThumbnail);
                if (!Directory.Exists(folder))
                    Directory.CreateDirectory(folder);

                fileThumbnail.SaveAs(_fileThumbnail);
                Response.Redirect(CommonConstants.PAGE_ADMIN_CONTROL);
            }
        }