private void SetLastLoadMessage(TrackableCouponProgram tcProgram) { lblStatusMsg.Visible = true; lblCouponuploadSumm.Visible = true; lblStatusMsg.Text = PhraseLib.Lookup("term.statusmessage", LanguageID) + ":"; if (tcProgram == null || tcProgram.LastLoadMsg == null) { lblStatusMsg.Visible = false; } else { lblCouponuploadSumm.Text = Copient.PhraseLib.DecodeEmbededTokens(tcProgram.LastLoadMsg, LanguageID); } if (tcProgram == null || tcProgram.LastLoaded == null) { lblCouponUploadDate.Text = PhraseLib.Lookup("tcpedit.nocouponuploadmsg", LanguageID); //lblCouponuploadSumm.Text = String.Empty; //lblStatusMsg.Text = String.Empty; //lblStatusMsg.Visible = false; //lblCouponuploadSumm.Visible = false; } else { lblCouponUploadDate.Text = tcProgram.LastLoaded.Value.ToLongDateString() + " " + tcProgram.LastLoaded.Value.ToLongTimeString(); //lblStatusMsg.Visible = true; //lblCouponuploadSumm.Visible = true; //lblStatusMsg.Text = PhraseLib.Lookup("term.statusmessage", LanguageID) + ":"; //lblCouponuploadSumm.Text = tcProgram.LastLoadMsg; } }
private void SetAvailableData(bool LoadSavedData) { try { List <TrackableCouponProgram> filterlist = new List <TrackableCouponProgram>(); TrackableCouponProgram includedprog = new TrackableCouponProgram(); GetAllTCProgram(); filterlist = AvailableFilteredTCProgram.ToList(); if (LoadSavedData) { SetSavedOfferTCReward(); IncludedTCProgram = AvailableFilteredTCProgram.Where(p => p.ProgramID == 0).ToList(); foreach (CouponTier cTier in couponReward.CouponTiers) { includedprog = AvailableFilteredTCProgram.Where(p => p.ProgramID == cTier.ProgramID).SingleOrDefault(); if (includedprog != null) { IncludedTCProgram.Add(includedprog); } } if (NumTiers == 1) { foreach (CouponTier cTier in couponReward.CouponTiers) { filterlist = filterlist.Where(p => p.ProgramID != cTier.ProgramID).ToList(); } } } else { if (NumTiers == 1) { if (IncludedTCProgram != null) { foreach (TrackableCouponProgram prog in IncludedTCProgram) { filterlist = filterlist.Where(p => p.ProgramID != prog.ProgramID).ToList(); } } } } filterlist = filterlist.OrderBy(o => o.Name).ToList(); lstAvailable.DataSource = filterlist; lstAvailable.DataBind(); } catch (Exception ex) { DisplayError(ex); } }
private void BindDataToListBox(RepeaterCommandEventArgs e, TrackableCouponProgram progSelected) { List <TrackableCouponProgram> includedList = new List <TrackableCouponProgram>(); if (progSelected != null) { includedList.Add(progSelected); } includedList = includedList.OrderBy(o => o.Name).ToList(); ((ListBox)e.Item.FindControl("lstSelected")).DataSource = includedList; ((ListBox)e.Item.FindControl("lstSelected")).DataBind(); SetAvailableData(false); }
protected void Page_Load(object sender, EventArgs e) { try { (this.Master as logix_LogixMasterPage).Tab_Name = "5_3_2"; (this.Master as logix_LogixMasterPage).OnOverridePageMenu += new logix_LogixMasterPage.OverridePageMenu(logix_tcp_edit_OnOverridePageMenu); btnDelete.Attributes.Add("onclick", "return confirm('" + PhraseLib.Lookup("term.confirmdeleteprogram", LanguageID) + "')"); if (!Page.IsPostBack) { //CSRF CODE ENDS //Set Anti-XSRF token ViewState[AntiXsrfTokenKey] = Page.ViewStateUserKey; //If a user name is assigned, set the user name ViewState[AntiXsrfUserNameKey] = Context.User.Identity.Name ?? String.Empty; //CSRF CODE ENDS TrackableCouponProgram tcProgram = VerifyPageUrl(); FillPageControlText(tcProgram); AssignPageTitle("term.trackablecouponprogram", String.Empty, ProgramID.ToString()); ApplyPermission(); if (SystemCacheData.GetSystemOption_UE_ByOptionId(152) == "0") { lblCouponusCount.Visible = false; CouponCount.Visible = false; } } else { //Validate the Anti-XSRF token if ((string)ViewState[AntiXsrfTokenKey] != _antiXsrfTokenValue || (string)ViewState[AntiXsrfUserNameKey] != (Context.User.Identity.Name ?? String.Empty)) { throw new InvalidOperationException("Validation of Anti - XSRF token failed."); } } ucNotes_Popup.NotesUpdate += new EventHandler(ucNotes_Popup_NotesUpdate); SetUpUserControls(); txtName.Focus(); } catch (Exception ex) { DisplayError(ErrorHandler.ProcessError(ex)); } }
protected void repTier_selectedTCP_ItemCommand(object source, RepeaterCommandEventArgs e) { TrackableCouponProgram progSelected = new TrackableCouponProgram(); if (IncludedTCProgram == null) { IncludedTCProgram = new List <TrackableCouponProgram>(); } if (e.CommandName.ToString() == "Select") { if (lstAvailable.SelectedValue == "") { return; } progSelected = AvailableFilteredTCProgram.Where(p => p.ProgramID == lstAvailable.SelectedValue.ConvertToInt32()).SingleOrDefault(); IncludedTCProgram.Add(progSelected); } else if (e.CommandName.ToString() == "Deselect") { if (((ListBox)e.Item.FindControl("lstSelected")).SelectedValue == "") { return; } if (NumTiers == 1) { progSelected = IncludedTCProgram.Where(p => p.ProgramID == ((ListBox)e.Item.FindControl("lstSelected")).SelectedValue.ConvertToInt32()).SingleOrDefault(); if (progSelected == null) { return; } IncludedTCProgram = IncludedTCProgram.Where(p => p.ProgramID != progSelected.ProgramID).ToList(); } progSelected = null; } BindDataToListBox(e, progSelected); DisableControls(); }
private TrackableCouponProgram VerifyPageUrl() { int pgID = 0; string paramVal = Request.QueryString["tcprogramid"]; TrackableCouponProgram tcProgram = null; if (!String.IsNullOrEmpty(paramVal)) { if (Int32.TryParse(paramVal, out pgID)) { tcProgram = GetProgramByID(pgID); if (tcProgram == null) { Server.Transfer("error-message.aspx?MainHeading=" + PhraseLib.Lookup("term.trackablecouponprogram", LanguageID) + " #" + pgID + "&ErrorMessage=" + PhraseLib.Lookup("term.itemnotfound", LanguageID) + "&TabName=5_3_2", false); } } else { Response.Redirect("~/logix/tcp-edit.aspx", false); } } return(tcProgram); }
private void FillPageControlText(TrackableCouponProgram tcProgram) { Copient.CommonInc MyCommon = new Copient.CommonInc(); #region LabelsNeverbeChange btnSave.Text = PhraseLib.Lookup("term.save", LanguageID); hidentification.InnerText = Collapsadividentification.ToolTip = PhraseLib.Lookup("term.identification", LanguageID); btnUpdate.Text = PhraseLib.Lookup("term.save", LanguageID); btnNew.Text = PhraseLib.Lookup("term.new", LanguageID); btnDelete.Text = PhraseLib.Lookup("term.delete", LanguageID); lblExternalID.Text = String.Concat(PhraseLib.Lookup("term.externalid", LanguageID), ":"); lblName.Text = String.Concat(PhraseLib.Lookup("term.name", LanguageID), ":"); lblDescription.Text = String.Concat(PhraseLib.Lookup("term.description", LanguageID), ":"); lblDescriptionLimitMsg.Text = String.Concat("(", PhraseLib.Lookup("CPEoffergen.description", LanguageID), ")"); hRedemptioninformation.InnerText = CollapsadivRedemptioninformation.ToolTip = PhraseLib.Lookup("term.redemptioninfo", LanguageID); lblMaxRedempCount.Text = String.Concat(PhraseLib.Lookup("term.maxredemptioncount", LanguageID), ":"); lblMaxMinInfoMsg.Text = String.Concat(PhraseLib.Lookup("term.minimum", LanguageID), ":1", " ", PhraseLib.Lookup("term.maximum", LanguageID), ":255"); lblExpire.Text = String.Concat(PhraseLib.Lookup("storedvalue.expiredate", LanguageID), ":"); hCouponUploadSumm.InnerText = CollapsableDivCouponUploadSumm.ToolTip = PhraseLib.Lookup("tcpedit.associatedcoupons", LanguageID); hAssociatedoffer.InnerText = CollapsableDivAssociatedoffer.ToolTip = PhraseLib.Lookup("term.associatedoffers", LanguageID); lblLastUpload.Text = PhraseLib.Lookup("term.lastupload", LanguageID) + ":"; btnAction.Text = PhraseLib.Lookup("term.actions", LanguageID) + " ▼"; lblCouponusCount.Text = PhraseLib.Lookup("tcpedit.couponscount", LanguageID) + ": "; lblExpire.Text = String.Concat(PhraseLib.Lookup("storedvalue.expiredate", LanguageID), ":"); requirefieldName.ErrorMessage = PhraseLib.Lookup("tcpedit.invalidname", LanguageID); requirefieldExternalID.ErrorMessage = PhraseLib.Lookup("tcpedit.invalidexternalprogramid", LanguageID); DescriptionLengthValidator.ErrorMessage = PhraseLib.Lookup("CPEoffergen.description", LanguageID); RangeValidatorMaxRedempCount.ErrorMessage = PhraseLib.Lookup("tcpedit.invalidredeemcount", LanguageID); requirefieldMaxRedempCount.ErrorMessage = PhraseLib.Lookup("tcpedit.blankredemptioninfoerror", LanguageID); hExpiration.InnerText = PhraseLib.Lookup("term.expiration", LanguageID); lblExpirationType.Text = PhraseLib.Lookup("storedvalue.expiretype", LanguageID) + ": "; lblExpirationPeriodType.Text = PhraseLib.Lookup("storedvalue.expireperiodtype", LanguageID) + ": "; lblExpirationPeriod.Text = PhraseLib.Lookup("storedvalue.expireperiod", LanguageID) + ": "; lblExpirationDatePicker.Text = PhraseLib.Lookup("storedvalue.expiredate", LanguageID) + ": "; lblExpirationTime.Text = PhraseLib.Lookup("storedvalue.expiretime", LanguageID) + ": "; rvExpirePeriod.ErrorMessage = PhraseLib.Lookup("sv-edit.InvalidExpirePeriod", LanguageID); FillExpireType(); FillExpirePeriodType(); FillExpireTime(); #endregion ProgramID = tcProgram == null ? "0" : tcProgram.ProgramID.ToString(); btnSave.Visible = tcProgram == null ? true : false; btnAction.Visible = !btnSave.Visible; htitle.InnerText = tcProgram == null?PhraseLib.Lookup("term.new", LanguageID) + " " + PhraseLib.Lookup("term.trackablecouponprogram", LanguageID).ToLower() : PhraseLib.Lookup("term.trackablecouponprogram", LanguageID) + " #" + tcProgram.ProgramID + ": " + tcProgram.Name.TruncateString(15); txtName.Text = tcProgram == null ? String.Empty : tcProgram.Name; txtDescription.InnerText = tcProgram == null ? String.Empty : tcProgram.Description.Trim(); txtExternalID.Text = tcProgram == null ? String.Empty : tcProgram.ExtProgramID; ExpireDate.Text = (tcProgram == null || tcProgram.ExpireDate == null) ? PhraseLib.Lookup("tcpedit.expiredatenotset", LanguageID) : tcProgram.ExpireDate.ConvertToDate().ToShortDateString(); txtMaxRedempCount.Text = tcProgram == null ? "1" : Convert.ToString(tcProgram.MaxRedeemCount); SetLastLoadMessage(tcProgram); CouponCount.Text = tcProgram == null ? "0" : Convert.ToString(tcProgram.AssosiatedCouponCount); ucNotesUI.Visible = tcProgram == null ? false : MyCommon.Fetch_SystemOption(75).Equals("1") ? true : false; lblAssociatedOffer.Text = PhraseLib.Lookup("term.none", LanguageID); AssociateOfferID = String.Empty; bExpireDateEnabled = SystemCacheData.GetSystemOption_General_ByOptionId(TRACKABLE_COUPON_EXPIRE_DATE_SYSOPTION_ID).Equals("1"); ddlExpireTypes.SelectedValue = ((tcProgram == null) || (!bExpireDateEnabled)) ? "1" : tcProgram.TCExpireType.ToString(); ddlExpirePeriodTypes.SelectedValue = tcProgram == null ? "0" : tcProgram.TCExpirePeriodType.ToString(); txtExpirationPeriod.Text = tcProgram == null ? "0" : tcProgram.ExpirePeriod.ToString(); ddlExpireTypes_SelectedIndexChanged(this, EventArgs.Empty); txtDatepicker.Text = (tcProgram == null || tcProgram.ExpireDate == null) ? "" : ExpireDate.Text; ddlExpireTimeHours.SelectedValue = (tcProgram == null || tcProgram.ExpireDate == null) ? "00" : tcProgram.ExpireDate.Value.Hour.ToString("00"); ddlExpireTimeMinutes.SelectedValue = (tcProgram == null || tcProgram.ExpireDate == null) ? "00" : tcProgram.ExpireDate.Value.Minute.ToString("00"); if (bExpireDateEnabled) { divExpiration.Visible = true; } if (tcProgram != null) { List <CMS.AMS.Models.Offer> offersObj = GetAttachedOffersByID(tcProgram.ProgramID); if (offersObj != null && offersObj.Count > 0) { lblAssociatedOffer.Text = String.Empty; offerService = CurrentRequest.Resolver.Resolve <IOffer>(); foreach (var item in offersObj) { AssociateOfferID = item.OfferID.ToString(); if (SystemCacheData.GetSystemOption_General_ByOptionId(66) == "1") { AMSResult <bool> ResultObj = offerService.IsAccessibleBannerEnabledOffer(CurrentUser.AdminUser.ID, item.OfferID); if (ResultObj.ResultType != AMSResultType.Success) { DisplayError(ResultObj.GetLocalizedMessage <bool>(LanguageID)); return; } if (ResultObj.Result) { lblAssociatedOffer.Text += "<a href='offer-redirect.aspx?OfferID=" + item.OfferID + "'>" + item.OfferName + "</a>" + "</br>"; } else { lblAssociatedOffer.Text += item.OfferName + "</br>"; } } else { lblAssociatedOffer.Text += "<a href='offer-redirect.aspx?OfferID=" + item.OfferID + "'>" + item.OfferName + "</a>" + "</br>"; } } } } }
protected void btnSave_Click(Object sender, EventArgs e) { if (!Page.IsValid) { return; } bool isNew = false; string logMsg = String.Empty; try { tcpService = CurrentRequest.Resolver.Resolve <ITrackableCouponProgramService>(); activityLogService = CurrentRequest.Resolver.Resolve <IActivityLogService>(); if (Convert.ToInt32(ProgramID) == 0) { isNew = true; } TrackableCouponProgram tcProgramModel = new TrackableCouponProgram(); tcProgramModel.ProgramID = Convert.ToInt32(ProgramID); tcProgramModel.Name = txtName.Text.Trim(); tcProgramModel.Description = txtDescription.InnerText.Trim(); tcProgramModel.ExtProgramID = txtExternalID.Text.Trim(); tcProgramModel.MaxRedeemCount = Convert.ToByte(txtMaxRedempCount.Text); tcProgramModel.TCExpireType = Convert.ToInt32(ddlExpireTypes.SelectedValue); int ExpirationPeriod; switch (tcProgramModel.TCExpireType) { case 1: tcProgramModel.ExpirePeriod = 0; tcProgramModel.TCExpirePeriodType = 0; tcProgramModel.ExpireDate = null; break; case 2: DateTime dtSpecified; tcProgramModel.ExpirePeriod = 0; tcProgramModel.TCExpirePeriodType = 0; if (DateTime.TryParse(ExpireDate.Text, out dtSpecified)) { tcProgramModel.ExpireDate = dtSpecified; } else { tcProgramModel.ExpireDate = null; } if (tcProgramModel.ExpireDate < DateTime.Now) { DisplayError(Copient.PhraseLib.Lookup("logix-js.EnterValidExpDate", LanguageID).Replace("'", "\'")); return; } break; case 3: if (!Int32.TryParse(txtExpirationPeriod.Text, out ExpirationPeriod)) { DisplayError(Copient.PhraseLib.Lookup("sv-edit.InvalidExpirePeriod", LanguageID)); return; } tcProgramModel.ExpirePeriod = ExpirationPeriod; tcProgramModel.TCExpirePeriodType = Convert.ToInt32(ddlExpirePeriodTypes.SelectedValue); tcProgramModel.ExpireDate = null; break; case 4: if (!Int32.TryParse(txtExpirationPeriod.Text, out ExpirationPeriod)) { DisplayError(Copient.PhraseLib.Lookup("sv-edit.InvalidExpirePeriod", LanguageID)); return; } tcProgramModel.ExpirePeriod = ExpirationPeriod; tcProgramModel.TCExpirePeriodType = 2; tcProgramModel.ExpireDate = null; break; } AMSResult <bool> retVal = tcpService.CreateUpdateTrackableCouponProgram(tcProgramModel); if (retVal.ResultType != AMSResultType.Success) { DisplayError(retVal.GetLocalizedMessage <bool>(LanguageID)); } else { logMsg = isNew == true?String.Concat(PhraseLib.Lookup("term.trackablecouponprogram", LanguageID), " ", PhraseLib.Lookup("term.created", LanguageID)) : String.Concat(PhraseLib.Lookup("term.trackablecouponprogram", LanguageID), " ", PhraseLib.Lookup("term.edited", LanguageID)); activityLogService.Activity_Log(ActivityTypes.TCProgram, tcProgramModel.ProgramID.ConvertToInt32(), CurrentUser.AdminUser.ID, logMsg); Response.Redirect("~/logix/tcp-edit.aspx?tcprogramid=" + tcProgramModel.ProgramID, false); } } catch (Exception ex) { DisplayError(ErrorHandler.ProcessError(ex)); } }