/// <summary> /// /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void btnSave_Click(object sender, System.EventArgs e) { //try //{ this.lblErrorMessage.Visible = false; OTC.Web.Promotion.OTCPromotion p = new OTC.Web.Promotion.OTCPromotion(); p.OTCPromotionId = Convert.ToInt32(this.txtPromotionId.Value) > 0 ? Convert.ToInt32(this.txtPromotionId.Value) : 0; p.PromotionName = this.txtPromotionName.Text; p.PromotionKey = this.txtPromotionKey.Text; p.PromotionDescription = this.txtPromotionDescription.Value; p.StartDate = Convert.ToDateTime(this.txtStartDate.Text); p.EndDate = this.txtEndDate.Text.Length > 0 ? Convert.ToDateTime(this.txtEndDate.Text) : System.DateTime.MinValue; p.UsageCount = this.txtNumberOfUses.Text.Length > 0 ? Convert.ToInt32(this.txtNumberOfUses.Text) : 0; p.MinimumPurchaseAmount = this.txtMinimumPurchaseAmount.Text.Length > 0 ? Convert.ToDouble(this.txtMinimumPurchaseAmount.Text) : 0.00; p.DiscountAmount = this.chkDiscountAmount.Checked ? Convert.ToDouble(this.txtDiscountAmount.Text) : 0.00; p.DiscountPercentage = this.chkDiscountPercentage.Checked ? (Convert.ToDouble(this.txtDiscountPercentage.Text) * .01) : .00; p.IsActive = this.chkActivateImmedietly.Checked; if(Convert.ToInt32(this.txtPromotionId.Value) > 0) p.RemoveProductAffiliation(); foreach(ListItem i in this.lstProducts.Items){ if(i.Selected) p.AddProductId(Convert.ToInt32(i.Value)); } if(!(Convert.ToInt32(this.txtPromotionId.Value) > 0)) p.Add(); else p.Save(); //reset ui this.txtDiscountAmount.Enabled = this.chkDiscountAmount.Checked = p.DiscountAmount > 0; this.txtDiscountPercentage.Enabled = this.chkDiscountPercentage.Checked = p.DiscountPercentage > 0; //} //catch(System.FormatException ex) //{ // this.lblErrorMessage.Visible = true; // this.lblErrorMessage.Text = "Please check your entry's. There is in error in one of your fields. " + ex.Message; //} }
private void Page_Load(object sender, System.EventArgs e) { this.m_page = new ITCPage(); if(!(this.m_page.CheckLogin())) Response.Redirect("Login.aspx"); this.m_page.HideWest = true; this.m_promotionId = Request.QueryString.ToString().IndexOf("PID") > - 1 ? Convert.ToInt32(Request.QueryString["PID"]) : 0; this.m_promotion = new OTC.Web.Promotion.OTCPromotion(this.m_promotionId); if(!Page.IsPostBack) { if(!(this.m_promotionId > 0)) { this.cldStartDate.SelectedDate = this.cldStartDate.VisibleDate = System.DateTime.Now; this.cldEndDate.SelectedDate = this.cldEndDate.VisibleDate = System.DateTime.Now; this.txtStartDate.Text = this.cldStartDate.SelectedDate.ToShortDateString(); this.txtEndDate.Text = this.cldEndDate.SelectedDate.ToShortDateString(); this.loadProductList(); } else { OTC.Web.Promotion.OTCPromotion p = new OTC.Web.Promotion.OTCPromotion(this.m_promotionId); this.txtPromotionId.Value = p.OTCPromotionId.ToString(); this.txtStartDate.Text = p.StartDate.ToShortDateString(); this.cldStartDate.SelectedDate = this.cldStartDate.VisibleDate = p.StartDate; this.txtPromotionName.Text = p.PromotionName; this.txtPromotionKey.Text = p.PromotionKey; this.txtPromotionDescription.Value = p.PromotionDescription; this.txtMinimumPurchaseAmount.Text = p.MinimumPurchaseAmount.ToString(); this.txtEndDate.Text = p.EndDate == Convert.ToDateTime("1/1/1900") ? "" : p.EndDate.ToShortDateString(); this.cldEndDate.SelectedDate = this.cldEndDate.VisibleDate = (p.EndDate == Convert.ToDateTime("1/1/1900") ? System.DateTime.Now : p.EndDate); this.txtNumberOfUses.Text = p.UsageCount.ToString(); this.txtDiscountPercentage.Text = (p.DiscountPercentage * 100).ToString(); this.txtDiscountPercentage.Enabled = p.DiscountPercentage > 0 ? true : false; this.chkActivateImmedietly.Checked = p.IsActive; this.chkDiscountAmount.Checked = p.DiscountAmount > 0; this.txtDiscountAmount.Text = Convert.ToDouble(p.DiscountAmount).ToString("c").Replace("$",""); this.txtDiscountAmount.Enabled = p.DiscountAmount > 0 ? true : false; this.chkDiscountPercentage.Checked = p.DiscountPercentage > 0; this.loadProductList(true); } } }
/// <summary> /// /// </summary> private void doDelete() { int promotionId = Convert.ToInt32(Request.QueryString["PID"]); OTC.Web.Promotion.OTCPromotion p = new OTC.Web.Promotion.OTCPromotion(promotionId); if(p.Delete()){ Response.Redirect("PromotionList.aspx?thread=deleteresult&result=1"); } else { Response.Redirect("PromotionList.aspx?thread=deleteresult&result=0"); } }