public string ToString(bool fullDetails) { StringBuilder retVal = new StringBuilder(); Enums.CouponDiscountType type = (Enums.CouponDiscountType) this.DiscountTypeID; retVal.Append("Coupon: " + this.RedeemCode + "<br>"); if (fullDetails) { retVal.Append("Title: " + this.Title + "<br>"); if (type == Enums.CouponDiscountType.Monetary) { retVal.Append("Amount: " + this.Amount.ToString("c") + "<br>"); } else if (type == Enums.CouponDiscountType.Percentage) { retVal.Append("Amount: " + this.Amount + "%<br>"); } retVal.Append("Usage: " + ((Enums.CouponUsageType) this.UsageTypeID).ToString() + "<br>"); } return(retVal.ToString()); }
void gvwActiveCoupons_RowDataBound(object sender, GridViewRowEventArgs e) { if (e.Row.RowType == DataControlRowType.DataRow) { hccCoupon coupon = (hccCoupon)e.Row.DataItem; Enums.CouponDiscountType discType = (Enums.CouponDiscountType)coupon.DiscountTypeID; Enums.CouponUsageType discUsage = (Enums.CouponUsageType)coupon.UsageTypeID; string tempDetails = string.Empty, tempDates = string.Empty; Label lblDetails = (Label)e.Row.FindControl("lblDetails"); Label lblEffectiveDates = (Label)e.Row.FindControl("lblEffectiveDates"); try { switch (discType) { case Enums.CouponDiscountType.Monetary: tempDetails = string.Format("{0:c} for {1}", coupon.Amount, Enums.GetEnumDescription(discUsage)); break; case Enums.CouponDiscountType.Percentage: tempDetails = string.Format("{0:p} for {1}", coupon.Amount / 100, Enums.GetEnumDescription(discUsage)); break; default: break; } lblDetails.Text = tempDetails; } catch { } try { if (coupon.StartDate.HasValue) { tempDates = "Start: " + coupon.StartDate.Value.ToShortDateString(); if (coupon.EndDate.HasValue) { tempDates += " - End: " + coupon.EndDate.Value.ToShortDateString(); } } else { if (coupon.EndDate.HasValue) { tempDates += "End: " + coupon.EndDate.Value.ToShortDateString(); } } lblEffectiveDates.Text = tempDates; } catch { } } }