private void pageLoad(object sender, EventArgs e, tblUser user) { bool isDeleted = false; try { int page = 1; string action = Request.QueryString[CommonConstants.REQ_ACTION]; string sPage = Request.QueryString[CommonConstants.REQ_PAGE]; if (BaseServices.isNullOrBlank(action)) { action = CommonConstants.ACT_SEARCH; } if (BaseServices.isNullOrBlank(sPage)) { sPage = CommonConstants.PAGE_NUMBER_FIRST; } page = Convert.ToInt32(sPage); //action is Search if (action == CommonConstants.ACT_SEARCH) { viewPanel.Visible = true; detailsPanel.Visible = false; messagePanel.Visible = false; IEnumerable<tblAdvertisement> lst = null; //page = Convert.ToInt32(Request.QueryString[CommonConstants.REQ_PAGE]); string key = Request.QueryString[CommonConstants.REQ_KEY]; if (BaseServices.isNullOrBlank(key)) { key = CommonConstants.ALL; } else { key = BaseServices.nullToBlank(key); } if (key == CommonConstants.ALL) { lst = adsDAO.fetchAdsList(((page - 1) * NoOfAdsPerPage), NoOfAdsPerPage); } else if (key == CommonConstants.STATE_UNCHECK.ToString() || key == CommonConstants.STATE_STICKY.ToString() || key == CommonConstants.STATE_PENDING.ToString() || key == CommonConstants.STATE_BLOCK.ToString() || key == CommonConstants.STATE_CHECKED.ToString()) { lst = adsDAO.fetchAdsList(Convert.ToInt32(key), ((page - 1) * NoOfAdsPerPage), NoOfAdsPerPage); } else if (key == CommonConstants.PARAM_LOCATION) { lst = adsDAO.fetchAdsListByLocation(((page - 1) * NoOfAdsPerPage), NoOfAdsPerPage); } // show data bool isOK = false; if (lst != null) { if (lst.Count() > 0) { showAds(lst, page, action, key); isOK = true; } } if(!isOK) { showInfoMessage(CommonConstants.MSG_E_RESOURCE_NOT_FOUND); NewsTable.Visible = false; return; } } //else if (Request.QueryString[CommonConstants.REQ_ACTION] != null) //{ //string action = Request.QueryString[CommonConstants.REQ_ACTION]; // else if (action == CommonConstants.ACT_VIEW || action == CommonConstants.ACT_EDIT) { if (Request.QueryString[CommonConstants.REQ_ID] == null) { showErrorMessage(CommonConstants.MSG_E_RESOURCE_NOT_FOUND); return; } if (!BaseServices.isNumeric(Request.QueryString[CommonConstants.REQ_ID])) { showErrorMessage(CommonConstants.MSG_E_RESOURCE_NOT_FOUND); return; } int _id = Convert.ToInt32(Request.QueryString[CommonConstants.REQ_ID]); viewPanel.Visible = false; detailsPanel.Visible = true; messagePanel.Visible = false; if (ddlState.Items.Count == 0) { //ddlState.Items.Insert(0, new ListItem(CommonConstants.STATE_STICKY_NAME, CommonConstants.STATE_STICKY.ToString())); //ddlState.Items.Insert(0, new ListItem(CommonConstants.STATE_PENDING_NAME, CommonConstants.STATE_PENDING.ToString())); //ddlState.Items.Insert(0, new ListItem(CommonConstants.STATE_CHECKED_NAME, CommonConstants.STATE_CHECKED.ToString())); //ddlState.Items.Insert(0, new ListItem(CommonConstants.STATE_UNCHECK_NAME, CommonConstants.STATE_UNCHECK.ToString())); showAdsDetails(_id, action); } if (action == CommonConstants.ACT_VIEW) { btnEdit.Visible = false; btnClone.Visible = false; } //showAdsDetails(_id, action); } else if (action == CommonConstants.ACT_DELETE) { if (Request.QueryString[CommonConstants.REQ_ID] == null) { showErrorMessage(CommonConstants.MSG_E_RESOURCE_NOT_FOUND); return; } if (!BaseServices.isNumeric(Request.QueryString[CommonConstants.REQ_ID])) { showErrorMessage(CommonConstants.MSG_E_RESOURCE_NOT_FOUND); return; } int _id = Convert.ToInt32(Request.QueryString[CommonConstants.REQ_ID]); //tblUser user = (tblUser)Session[CommonConstants.SES_USER]; //Boolean completeDelete = adsDAO.deleteAds(_id, user.Username); //if (completeDelete) //{ //Response.Write(CommonConstants.ALERT_DELETE_SUCCESSFUL); //Response.Redirect(CommonConstants.PAGE_ADMIN_ADS // + CommonConstants.ADD_PARAMETER // + CommonConstants.REQ_PAGE // + CommonConstants.EQUAL // + "1"); //} //else //{ // Response.Write(CommonConstants.ALERT_DELETE_FAIL); //} bool isMatch = adsDAO.isState(_id, CommonConstants.STATE_UNCHECK); if (adsDAO.deleteAds(_id, user.Username)) { if (isMatch) { ltktDAO.Statistics statDAO = new ltktDAO.Statistics(); statDAO.add(CommonConstants.SF_NUM_NEW_ADV_CONTACT, CommonConstants.CONST_ONE_NEGATIVE); } string mess = BaseServices.createMsgByTemplate(CommonConstants.MSG_I_ACTION_SUCCESSFUL, CommonConstants.ACT_DELETE); //Page.ClientScript.RegisterStartupScript(this.GetType(), "myalert", "alert('" + mess + "');", true); //MessageBox.Show(mess); //Response.End(); ltktDAO.Alert.Show(mess); isDeleted = true; //showErrorMessage(BaseServices.createMsgByTemplate(CommonConstants.MSG_I_ACTION_SUCCESSFUL, CommonConstants.ACT_DELETE)); } } //} //else //{ // Response.Redirect(CommonConstants.PAGE_ADMIN_ADS // + CommonConstants.ADD_PARAMETER // + CommonConstants.REQ_PAGE // + CommonConstants.EQUAL // + "1"); //} } catch (Exception ex) { log.writeLog(DBHelper.strPathLogFile, user.Username, CommonConstants.MSG_E_LINK_INVALID); log.writeLog(DBHelper.strPathLogFile, user.Username, ex.Message + CommonConstants.NEWLINE + ex.Source + CommonConstants.NEWLINE + ex.StackTrace + CommonConstants.NEWLINE + ex.HelpLink); //Session[CommonConstants.SES_ERROR] = CommonConstants.MSG_LINK_ERROR; Response.Redirect(CommonConstants.PAGE_ADMIN_ADS + CommonConstants.ADD_PARAMETER + CommonConstants.REQ_PAGE + CommonConstants.EQUAL + "1"); } if (isDeleted) { Response.Redirect(CommonConstants.PAGE_ADMIN_ADS); } }
protected void btnClone_Click(object sender, EventArgs e) { bool isOK = false; int id = -1; try { string _comName = txtCompany.Text; string _address = txtAddress.Text; string _email = txtEmail.Text; string _phone = txtPhone.Text; string _description = txtDescription.Text; string _navigateUrl = txtNavigateUrl.Text; DateTime _fromDate = DateTime.Parse(txtFromDate.Text); DateTime _toDate = DateTime.Parse(txtEndDate.Text); string _location = txtLocation.Text; if (_toDate.CompareTo(_fromDate) == -1) { showErrorMessage(CommonConstants.MSG_E_INVALID_TO_DATE); return; } id = adsDAO.cloneAds(_comName, _address, _email, _phone, _fromDate, _toDate, _location, _navigateUrl, _description); if (id > 0) { ltktDAO.Statistics statDAO = new ltktDAO.Statistics(); statDAO.add(CommonConstants.SF_NUM_NEW_ADV_CONTACT, CommonConstants.CONST_ONE); isOK = true; } else { showErrorMessage(BaseServices.createMsgByTemplate(CommonConstants.MSG_E_ACTION_FAILED, CommonConstants.ACT_CLONE)); return; } } catch (Exception ex) { tblUser user = (tblUser)Session[CommonConstants.SES_USER]; log.writeLog(Server.MapPath(CommonConstants.PATH_LOG_FILE), user.Username, ex.Message + CommonConstants.NEWLINE + ex.Source + CommonConstants.NEWLINE + ex.StackTrace + CommonConstants.NEWLINE + ex.HelpLink); Session[CommonConstants.SES_ERROR] = CommonConstants.MSG_E_COMMON_ERROR_TEXT; Session[CommonConstants.SES_USER] = null; Response.Redirect(CommonConstants.PAGE_ADMIN_LOGIN); } if (isOK) { string url = CommonConstants.PAGE_ADMIN_ADS + CommonConstants.ADD_PARAMETER + CommonConstants.REQ_ACTION + CommonConstants.EQUAL + CommonConstants.ACT_EDIT + CommonConstants.AND + CommonConstants.REQ_ID + CommonConstants.EQUAL + id.ToString(); ltktDAO.Alert.Show(BaseServices.createMsgByTemplate(CommonConstants.MSG_I_ACTION_SUCCESSFUL, CommonConstants.ACT_CLONE)); Response.Redirect(url); } }
protected void btnEdit_Click(object sender, EventArgs e) { //if (Request.QueryString[CommonConstants.REQ_ACTION] == CommonConstants.ACT_VIEW) //{ // txtFromDate.CssClass = "calendar"; // txtEndDate.CssClass = "calendar"; // Response.Redirect(CommonConstants.PAGE_ADMIN_ADS // + CommonConstants.ADD_PARAMETER // + CommonConstants.REQ_ACTION // + CommonConstants.EQUAL // + CommonConstants.ACT_EDIT // + CommonConstants.AND // + CommonConstants.REQ_ID // + CommonConstants.EQUAL // + Convert.ToInt32(Request.QueryString[CommonConstants.REQ_ID])); //} try { tblAdvertisement Ads = (tblAdvertisement)Session[CommonConstants.SES_EDIT_ADS]; string _company = txtCompany.Text; string _address = txtAddress.Text; string _email = txtEmail.Text; string _phone = txtPhone.Text; DateTime _fromDate = DateTime.Parse(txtFromDate.Text); DateTime _toDate = DateTime.Parse(txtEndDate.Text); if (_toDate.CompareTo(_fromDate) == -1) { showErrorMessage(CommonConstants.MSG_E_INVALID_TO_DATE); return; } int _price = Convert.ToInt32(txtPrice.Text); string _description = txtDescription.Text; string _navigateUrl = txtNavigateUrl.Text; string _size = txtSizeImg.Text; string _location = txtLocation.Text; bool _fileGood = false; string rootFolder = CommonConstants.BLANK; string filename = CommonConstants.BLANK; int _state = CommonConstants.STATE_UNCHECK; switch (Convert.ToInt32(ddlState.SelectedValue)) { case CommonConstants.STATE_UNCHECK: _state = CommonConstants.STATE_UNCHECK; break; case CommonConstants.STATE_CHECKED: _state = CommonConstants.STATE_CHECKED; break; case CommonConstants.STATE_PENDING: _state = CommonConstants.STATE_PENDING; break; case CommonConstants.STATE_STICKY: _state = CommonConstants.STATE_STICKY; break; case CommonConstants.STATE_BLOCK: { _state = CommonConstants.STATE_BLOCK; break; } default: break; } //if change state to CHECKED if (_state == CommonConstants.STATE_CHECKED) { if (_fromDate.CompareTo(DateTime.Today) == -1) { showErrorMessage(CommonConstants.MSG_E_INVALID_FROM_DATE); return; } } string fileSave = Ads.FilePath.Trim(); if (fileAds.HasFile) { string folder = CommonConstants.FOLDER_IMG_ADS; rootFolder = Server.MapPath("~") + "\\" + folder + "\\"; //check file existed: keep both string newFileName = bs.fileNameToSave(fileAds.FileName); filename = rootFolder + newFileName; //check filetype string fileTypes = control.getValueString(CommonConstants.CF_IMG_FILE_TYPE_ALLOW); if (!bs.checkFileType(fileAds.FileName, fileTypes)) { showErrorMessage(CommonConstants.MSG_E_FILE_SIZE_IS_NOT_ALLOW); return; } //check filesize max int fileSizeMax = control.getValueByInt(CommonConstants.CF_IMG_FILE_SIZE_MAX); fileSizeMax = 1024 * fileSizeMax; if (fileAds.PostedFile.ContentLength > fileSizeMax) { showErrorMessage(CommonConstants.MSG_E_FILE_SIZE_IS_TOO_LARGE); return; } fileSave = folder + "/" + newFileName; _fileGood = true; } string _code = ddlLocation.SelectedValue; string _oldCode = Ads.Code; if (_state != CommonConstants.STATE_UNCHECK && _state != CommonConstants.STATE_STICKY && _state != CommonConstants.STATE_BLOCK) { if (_code == CommonConstants.CONST_ONE_NEGATIVE) { showErrorMessage(BaseServices.createMsgByTemplate(CommonConstants.MSG_E_PLEASE_SELECT_ONE_ITEM, CommonConstants.TXT_ADS_LOCATION)); return; } if (BaseServices.isNullOrBlank(_navigateUrl)) { showErrorMessage(BaseServices.createMsgByTemplate(CommonConstants.MSG_E_PLEASE_INPUT_DATA, CommonConstants.TXT_ADS_NAVIGATE_URL)); return; } if (BaseServices.isNullOrBlank(fileSave)) { showErrorMessage(BaseServices.createMsgByTemplate(CommonConstants.MSG_E_PLEASE_INPUT_DATA, CommonConstants.TXT_ADS_IMAGE_URL)); return; } if (BaseServices.isNullOrBlank(_size)) { showErrorMessage(BaseServices.createMsgByTemplate(CommonConstants.MSG_E_PLEASE_INPUT_DATA, CommonConstants.TXT_ADS_IMAGE_SIZE)); return; } else { if (!BaseServices.checkSizePattern(_size, CommonConstants.X)) { showErrorMessage(BaseServices.createMsgByTemplate(CommonConstants.MSG_E_PLEASE_INPUT_RIGHT_FORMAT, CommonConstants.TXT_ADS_IMAGE_SIZE, CommonConstants.DEFAULT_SIZE_FORMAT)); return; } } //if state is pending: keep location if (_state == CommonConstants.STATE_PENDING) { _code = Ads.Code; } } else//state is uncheck or sticky or blocked { _code = CommonConstants.ADS_INACTIVE; } tblUser user = (tblUser)Session[CommonConstants.SES_USER]; bool isOK = adsDAO.updateAds(Ads.ID, user.Username, _company, _address, _email, _phone, _fromDate, _toDate, _price, fileSave, _description, _navigateUrl, _location, _size, _state, _code); if (isOK) { if (_fileGood) { // save file if (!Directory.Exists(rootFolder)) { Directory.CreateDirectory(rootFolder); } fileAds.SaveAs(filename); } // update statistic ltktDAO.Statistics statDAO = new ltktDAO.Statistics(); if (_state == CommonConstants.STATE_UNCHECK) { statDAO.add(CommonConstants.SF_NUM_NEW_ADV_CONTACT, CommonConstants.CONST_ONE); } else if (_state == CommonConstants.STATE_CHECKED) { statDAO.add(CommonConstants.SF_NUM_NEW_ADV_CONTACT, CommonConstants.CONST_ONE_NEGATIVE); } Session[CommonConstants.SES_INFORM] = BaseServices.createMsgByTemplate(CommonConstants.MSG_I_ACTION_SUCCESSFUL, CommonConstants.ACT_EDIT); //Response.Write(CommonConstants.ALERT_UPDATE_SUCCESSFUL); } else { Session[CommonConstants.SES_INFORM] = BaseServices.createMsgByTemplate(CommonConstants.MSG_E_ACTION_FAILED, CommonConstants.ACT_EDIT); //Response.Write(CommonConstants.ALERT_UPDATE_FAIL); } Session[CommonConstants.SES_EDIT_ADS] = null; } catch (Exception ex) { tblUser user = (tblUser)Session[CommonConstants.SES_USER]; log.writeLog(Server.MapPath(CommonConstants.PATH_LOG_FILE), user.Username, 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_ADMIN_LOGIN); } Response.Redirect(CommonConstants.PAGE_ADMIN_ADS); }
private void pageLoad(object sender, EventArgs e, tblUser user) { string action = Request.QueryString[CommonConstants.REQ_ACTION]; string sPage = Request.QueryString[CommonConstants.REQ_PAGE]; bool isDeleted = false; try { //bool isDeleted = false; if (BaseServices.isNullOrBlank(action)) { action = CommonConstants.ACT_SEARCH; } if (BaseServices.isNullOrBlank(sPage)) { sPage = CommonConstants.PAGE_NUMBER_FIRST; } int page = Convert.ToInt32(sPage); if (action == CommonConstants.ACT_SEARCH) { if (Page.IsPostBack) { return; } showCountingArticle(); string key = Request.QueryString[CommonConstants.REQ_KEY]; string state = Request.QueryString[CommonConstants.REQ_STATE]; int totalRecord = 0; viewPanel.Visible = true; detailPanel.Visible = false; messagePanel.Visible = false; IEnumerable<tblContestForUniversity> lst = null; if (BaseServices.isNullOrBlank(key)) { key = CommonConstants.ALL; } else { key = BaseServices.nullToBlank(key); } if (BaseServices.isNullOrBlank(state)) { state = CommonConstants.ALL; } changeViewState(key); if (key == CommonConstants.ALL) { if (state == CommonConstants.ALL)// key = ALL and state = ALL { lst = contestDAO.fetchArticleList((page - 1) * NoOfContestPerPage, NoOfContestPerPage); totalRecord = contestDAO.count(); string txt = hpkShowAllState.Text; txt += "(" + totalRecord + ")"; hpkShowAllState.Text = BaseServices.createMsgByTemplate(CommonConstants.TEMP_B_TAG, txt); hpkShowUncheck.Text += "(" + contestDAO.countArticleByState(CommonConstants.STATE_UNCHECK) + ")"; hpkShowChecked.Text += "(" + contestDAO.countArticleByState(CommonConstants.STATE_CHECKED) + ")"; hpkShowBad.Text += "(" + contestDAO.countArticleByState(CommonConstants.STATE_BAD) + ")"; } else if (state == CommonConstants.STATE_UNCHECK.ToString())// key = ALL and state = UNCHECk { lst = contestDAO.fetchArticleList(CommonConstants.STATE_UNCHECK, (page - 1) * NoOfContestPerPage, NoOfContestPerPage); totalRecord = contestDAO.countArticleByState(CommonConstants.STATE_UNCHECK); hpkShowAllState.Text += "(" + contestDAO.count() + ")"; string txt = hpkShowUncheck.Text; txt += "(" + totalRecord + ")"; hpkShowUncheck.Text = BaseServices.createMsgByTemplate(CommonConstants.TEMP_B_TAG, txt); hpkShowChecked.Text += "(" + contestDAO.countArticleByState(CommonConstants.STATE_CHECKED) + ")"; hpkShowBad.Text += "(" + contestDAO.countArticleByState(CommonConstants.STATE_BAD) + ")"; } else if (state == CommonConstants.STATE_CHECKED.ToString())// key = ALL and state = CHECKED { lst = contestDAO.fetchArticleList(CommonConstants.STATE_CHECKED, (page - 1) * NoOfContestPerPage, NoOfContestPerPage); totalRecord = contestDAO.countArticleByState(CommonConstants.STATE_CHECKED); hpkShowAllState.Text += "(" + contestDAO.count() + ")"; hpkShowUncheck.Text += "(" + contestDAO.countArticleByState(CommonConstants.STATE_UNCHECK) + ")"; string txt = hpkShowChecked.Text; txt += "(" + totalRecord + ")"; hpkShowChecked.Text = BaseServices.createMsgByTemplate(CommonConstants.TEMP_B_TAG, txt); hpkShowBad.Text += "(" + contestDAO.countArticleByState(CommonConstants.STATE_BAD) + ")"; } else if (state == CommonConstants.STATE_BAD.ToString())// key = ALL and state = BAD { lst = contestDAO.fetchArticleList(CommonConstants.STATE_BAD, (page - 1) * NoOfContestPerPage, NoOfContestPerPage); totalRecord = contestDAO.countArticleByState(CommonConstants.STATE_BAD); hpkShowAllState.Text += "(" + contestDAO.count() + ")"; hpkShowUncheck.Text += "(" + contestDAO.countArticleByState(CommonConstants.STATE_UNCHECK) + ")"; hpkShowChecked.Text += "(" + contestDAO.countArticleByState(CommonConstants.STATE_CHECKED) + ")"; string txt = hpkShowBad.Text; txt += "(" + totalRecord + ")"; hpkShowBad.Text = BaseServices.createMsgByTemplate(CommonConstants.TEMP_B_TAG, txt); } } else if (key == CommonConstants.TXT_STICKY.ToLower()) { changeStateLink(key); if (state == CommonConstants.ALL)// key == sticky and state = ALL { lst = contestDAO.fetchStickyContestList(((page - 1) * NoOfContestPerPage), NoOfContestPerPage); totalRecord = contestDAO.countStickyArticle(); hpkShowAllState.Text = BaseServices.createMsgByTemplate(CommonConstants.TEMP_B_TAG, hpkShowAllState.Text + "(" + totalRecord + ")"); hpkShowBad.Text += "(" + contestDAO.countStickyContestList(CommonConstants.STATE_BAD) + ")"; hpkShowChecked.Text += "(" + contestDAO.countStickyContestList(CommonConstants.STATE_CHECKED) + ")"; hpkShowUncheck.Text += "(" + contestDAO.countStickyContestList(CommonConstants.STATE_UNCHECK) + ")"; } else if (state == CommonConstants.STATE_UNCHECK.ToString())// key == sticky and state = UNCHECk { lst = contestDAO.fetchStickyContestList(CommonConstants.STATE_UNCHECK, ((page - 1) * NoOfContestPerPage), NoOfContestPerPage); totalRecord = contestDAO.countStickyContestList(CommonConstants.STATE_UNCHECK); hpkShowAllState.Text += "(" + contestDAO.countStickyArticle() + ")"; hpkShowUncheck.Text = BaseServices.createMsgByTemplate(CommonConstants.TEMP_B_TAG, hpkShowUncheck.Text + "(" + totalRecord + ")"); hpkShowChecked.Text += "(" + contestDAO.countStickyContestList(CommonConstants.STATE_CHECKED) + ")"; hpkShowBad.Text += "(" + contestDAO.countStickyContestList(CommonConstants.STATE_BAD) + ")"; } else if (state == CommonConstants.STATE_CHECKED.ToString())// key = sticky and state = CHECKED { lst = contestDAO.fetchStickyContestList(CommonConstants.STATE_CHECKED, ((page - 1) * NoOfContestPerPage), NoOfContestPerPage); totalRecord = contestDAO.countStickyContestList(CommonConstants.STATE_CHECKED); hpkShowAllState.Text += "(" + contestDAO.countStickyArticle() + ")"; hpkShowBad.Text += "(" + contestDAO.countStickyContestList(CommonConstants.STATE_BAD) + ")"; hpkShowChecked.Text = BaseServices.createMsgByTemplate(CommonConstants.TEMP_B_TAG, hpkShowChecked.Text + "(" + totalRecord + ")"); hpkShowUncheck.Text += "(" + contestDAO.countStickyContestList(CommonConstants.STATE_UNCHECK) + ")"; } else if (state == CommonConstants.STATE_BAD.ToString())// key = sticky and state = BAD { lst = contestDAO.fetchStickyContestList(CommonConstants.STATE_BAD, ((page - 1) * NoOfContestPerPage), NoOfContestPerPage); totalRecord = contestDAO.countStickyContestList(CommonConstants.STATE_BAD); hpkShowAllState.Text += "(" + contestDAO.countStickyArticle() + ")"; hpkShowUncheck.Text += "(" + contestDAO.countStickyContestList(CommonConstants.STATE_UNCHECK) + ")"; hpkShowChecked.Text += "(" + contestDAO.countStickyContestList(CommonConstants.STATE_CHECKED) + ")"; hpkShowBad.Text = BaseServices.createMsgByTemplate(CommonConstants.TEMP_B_TAG, hpkShowBad.Text + "(" + totalRecord + ")"); } } else //key != ALL { changeStateLink(key); string sub = key; if (BaseServices.isNullOrBlank(sub)) { sub = CommonConstants.SUB_MATHEMATICS_CODE; } if (state == CommonConstants.ALL)//key != ALL and state = ALL { lst = contestDAO.fetchArticleList(sub.Trim(), (page - 1) * NoOfContestPerPage, NoOfContestPerPage); totalRecord = contestDAO.countArticleBySubject(sub.Trim()); hpkShowUncheck.Text += "(" + contestDAO.countArticleBySubjectAndState(sub.Trim(), CommonConstants.STATE_UNCHECK) + ")"; hpkShowChecked.Text += "(" + contestDAO.countArticleBySubjectAndState(sub.Trim(), CommonConstants.STATE_CHECKED) + ")"; hpkShowBad.Text += "(" + contestDAO.countArticleBySubjectAndState(sub.Trim(), CommonConstants.STATE_BAD) + ")"; string txt = hpkShowAllState.Text; txt += "(" + totalRecord + ")"; hpkShowAllState.Text = BaseServices.createMsgByTemplate(CommonConstants.TEMP_B_TAG, txt); } else if (state == CommonConstants.STATE_UNCHECK.ToString())//key != ALL and state = UNCHECK { lst = contestDAO.fetchArticleList(sub.Trim(), CommonConstants.STATE_UNCHECK, (page - 1) * NoOfContestPerPage, NoOfContestPerPage); totalRecord = contestDAO.countArticleBySubjectAndState(sub.Trim(), CommonConstants.STATE_UNCHECK); hpkShowAllState.Text += "(" + contestDAO.countArticleBySubject(sub.Trim()) + ")"; hpkShowChecked.Text += "(" + contestDAO.countArticleBySubjectAndState(sub.Trim(), CommonConstants.STATE_CHECKED) + ")"; hpkShowBad.Text += "(" + contestDAO.countArticleBySubjectAndState(sub.Trim(), CommonConstants.STATE_BAD) + ")"; string txt = hpkShowUncheck.Text; txt += "(" + totalRecord + ")"; hpkShowUncheck.Text = BaseServices.createMsgByTemplate(CommonConstants.TEMP_B_TAG, txt); } else if (state == CommonConstants.STATE_CHECKED.ToString())//key != ALL and state = CHECKED { lst = contestDAO.fetchArticleList(sub.Trim(), CommonConstants.STATE_CHECKED, (page - 1) * NoOfContestPerPage, NoOfContestPerPage); totalRecord = contestDAO.countArticleBySubjectAndState(sub.Trim(), CommonConstants.STATE_CHECKED); hpkShowAllState.Text += "(" + contestDAO.countArticleBySubject(sub.Trim()) + ")"; hpkShowUncheck.Text += "(" + contestDAO.countArticleBySubjectAndState(sub.Trim(), CommonConstants.STATE_UNCHECK) + ")"; string txt = hpkShowChecked.Text; txt += "(" + totalRecord + ")"; hpkShowChecked.Text = BaseServices.createMsgByTemplate(CommonConstants.TEMP_B_TAG, txt); hpkShowBad.Text += "(" + contestDAO.countArticleBySubjectAndState(sub.Trim(), CommonConstants.STATE_BAD) + ")"; } else if (state == CommonConstants.STATE_BAD.ToString())//key != ALL and state = BAD { lst = contestDAO.fetchArticleList(sub.Trim(), CommonConstants.STATE_BAD, (page - 1) * NoOfContestPerPage, NoOfContestPerPage); totalRecord = contestDAO.countArticleBySubjectAndState(sub.Trim(), CommonConstants.STATE_BAD); hpkShowAllState.Text += "(" + contestDAO.countArticleBySubject(sub.Trim()) + ")"; hpkShowUncheck.Text += "(" + contestDAO.countArticleBySubjectAndState(sub.Trim(), CommonConstants.STATE_UNCHECK) + ")"; hpkShowChecked.Text += "(" + contestDAO.countArticleBySubjectAndState(sub.Trim(), CommonConstants.STATE_CHECKED) + ")"; string txt = hpkShowBad.Text; txt += "(" + totalRecord + ")"; hpkShowBad.Text = BaseServices.createMsgByTemplate(CommonConstants.TEMP_B_TAG, txt); } else { } } //show data bool isOK = false; if (lst != null) { if (lst.Count() > 0) { showContest(lst, totalRecord, page, action, key, state); isOK = true; } } if (!isOK) { showInfoMessage(CommonConstants.MSG_E_RESOURCE_NOT_FOUND); ContestTable.Visible = false; return; } } else if (action == CommonConstants.ACT_EDIT || action == CommonConstants.ACT_VIEW) { if (Page.IsPostBack) { return; } initial(); viewPanel.Visible = false; detailPanel.Visible = true; messagePanel.Visible = false; Session[CommonConstants.SES_OLD_PAGE] = Request.UrlReferrer.ToString(); int id = BaseServices.convertStringToInt(Request.QueryString[CommonConstants.REQ_ID]); if (Request.QueryString[CommonConstants.REQ_ID] == null) { showErrorMessage(CommonConstants.MSG_E_RESOURCE_NOT_FOUND); return; } if (!BaseServices.isNumeric(Request.QueryString[CommonConstants.REQ_ID])) { showErrorMessage(CommonConstants.MSG_E_RESOURCE_NOT_FOUND); return; } int _id = Convert.ToInt32(Request.QueryString[CommonConstants.REQ_ID]); viewPanel.Visible = false; detailPanel.Visible = true; messagePanel.Visible = false; if (ddlState.Items.Count == 0) { showContestDetails(_id, action); } if (action == CommonConstants.ACT_VIEW) { btnEdit.Visible = false; } } else if (action == CommonConstants.ACT_DELETE) { if (Request.QueryString[CommonConstants.REQ_ID] == null) { showErrorMessage(CommonConstants.MSG_E_RESOURCE_NOT_FOUND); return; } if (!BaseServices.isNumeric(Request.QueryString[CommonConstants.REQ_ID])) { showErrorMessage(CommonConstants.MSG_E_RESOURCE_NOT_FOUND); return; } int id = BaseServices.convertStringToInt(Request.QueryString[CommonConstants.REQ_ID]); bool isMatch = contestDAO.isState(id, CommonConstants.STATE_UNCHECK); if (contestDAO.setDeleteFlag(id, user.Username)) { if (isMatch) { ltktDAO.Statistics statDAO = new ltktDAO.Statistics(); statDAO.add(CommonConstants.SF_NUM_ARTICLE_ON_UNI, CommonConstants.CONST_ONE_NEGATIVE); } string mess = BaseServices.createMsgByTemplate(CommonConstants.MSG_I_ACTION_SUCCESSFUL, CommonConstants.ACT_DELETE); //ltktDAO.Alert.Show(mess); isDeleted = true; Session[CommonConstants.SES_INFORM] = BaseServices.createMsgByTemplate(CommonConstants.MSG_I_ACTION_SUCCESSFUL, CommonConstants.ACT_DELETE); } else { Session[CommonConstants.SES_INFORM] = BaseServices.createMsgByTemplate(CommonConstants.MSG_E_ACTION_FAILED, CommonConstants.ACT_DELETE); } } } catch (Exception ex) { log.writeLog(DBHelper.strPathLogFile, user.Username, CommonConstants.MSG_E_LINK_INVALID); log.writeLog(DBHelper.strPathLogFile, user.Username, ex.Message + CommonConstants.NEWLINE + ex.Source + CommonConstants.NEWLINE + ex.StackTrace + CommonConstants.NEWLINE + ex.HelpLink); Response.Redirect(CommonConstants.PAGE_ADMIN_INFORMATICS + CommonConstants.ADD_PARAMETER + CommonConstants.REQ_PAGE + CommonConstants.EQUAL + CommonConstants.PAGE_NUMBER_FIRST); } if (isDeleted) { Response.Redirect(CommonConstants.PAGE_ADMIN_UNIVERSITY); } }
/// <summary> /// get latest login /// </summary> /// <returns></returns> public string getLatestLogin() { Statistics statisticDAO = new Statistics(); string users = statisticDAO.getValue(CommonConstants.SF_LATEST_LOGIN).Trim(); string res = CommonConstants.BLANK; try { if (!BaseServices.isNullOrBlank(users)) { string[] arrayUsers = users.Split(CommonConstants.COMMA_CHAR); for (int i = 0; i < arrayUsers.Length; i++) { res += formatUsername(arrayUsers[i]); res += CommonConstants.SPACE; res += CommonConstants.BAR; } } } catch (Exception ex) { log.writeLog(DBHelper.strPathLogFile, ex.Message); } return res; }
protected void btnSubmitContact_Click(object sender, EventArgs e) { try { if (!recaptcha.IsValid) { return; } string _companyName = txtboxCompanyName.Text; string _address = txtAddress.Text; string _email = txtboxContactEmail.Text; string _phone = txtboxFone.Text; DateTime _fromDate = DateTime.Parse(txtFromDate.Text); bool isOK = false; int o= _fromDate.CompareTo(DateTime.Today); if (_fromDate.CompareTo(DateTime.Today) == -1) { messagePanel.Visible = true; liMessage.Text = CommonConstants.MSG_E_INVALID_FROM_DATE; return; } DateTime _endDate = DateTime.Parse(txtToDate.Text); if (_endDate.CompareTo(_fromDate) == -1) { messagePanel.Visible = true; liMessage.Text = CommonConstants.MSG_E_INVALID_TO_DATE; return; } string _location = getLocation(sender, e); if (_location == CommonConstants.BLANK) { messagePanel.Visible = true; liMessage.Text = BaseServices.createMsgByTemplate(CommonConstants.MSG_E_PLEASE_SELECT_ONE_ITEM, CommonConstants.TXT_ADS_LOCATION); return; } isOK = adsDAO.insertAds(_companyName, _address, _email, _phone, _fromDate, _endDate, _location); if (isOK) { contactPanel.Visible = false; messagePanel.Visible = true; ltktDAO.Statistics statDAO = new ltktDAO.Statistics(); statDAO.add(CommonConstants.SF_NUM_NEW_ADV_CONTACT, CommonConstants.CONST_ONE ); liMessage.Text = CommonConstants.MSG_I_ADVERTISEMENT_CONTACT_IS_SENT_SUCCESSFUL; } else { messagePanel.Visible = true; liMessage.Text = CommonConstants.MSG_E_COMMON_ERROR_TEXT; } } catch (Exception ex) { string username = CommonConstants.USER_GUEST; log.writeLog(Server.MapPath(CommonConstants.PATH_LOG_FILE), username, 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); } }