private void LoadPromotions() { BEPromotions promotions = new BEPromotions(); BPPromotions bp = new BPPromotions(); promotions = bp.SelectAllActive(); for (int i=0;i<promotions.tbl_Promotions.Count;i++) { if (promotions.tbl_Promotions[i].PromotionName != "" || !promotions.tbl_Promotions[i].IsPromotionImageIDNull() || promotions.tbl_Promotions[i].PromotionDescription != "") { if (this.FindControl("pnlPromotion"+(i+1).ToString()) != null) { this.FindControl("pnlPromotion"+(i+1).ToString()).Visible = true; ((Label)this.FindControl("lblPromotion"+(i+1).ToString()+"Heading")).Text = promotions.tbl_Promotions[i].PromotionName; ((Label)this.FindControl("lblPromotion"+(i+1).ToString()+"Description")).Text = promotions.tbl_Promotions[i].PromotionDescription; if(promotions.tbl_Promotions[i].IsPromotionImageIDNull()) { this.FindControl("pnlPromotionImage"+(i+1).ToString()).Visible = false; this.FindControl("imgPromotion"+(i+1).ToString()).Visible = false; }else { this.FindControl("pnlPromotionImage"+(i+1).ToString()).Visible = true; Image pageImage = ((Image)this.FindControl("imgPromotion"+(i+1).ToString())); pageImage.Visible = true; pageImage.ImageUrl = GetImageName(promotions.tbl_Promotions[i].PromotionImageID,"promo_"); } } } } }
private void Page_Load(object sender, System.EventArgs e) { this.AuthenticatePage(new string[] {PermissionLevels.EditPromotions, PermissionLevels.ViewPromotions, PermissionLevels.AddPromotions}); if (!IsPostBack) { BEPromotions promotions = new BEPromotions(); BPPromotions bp = new BPPromotions(); promotions = bp.SelectAll(); for (int i=1; i<=promotions.tbl_Promotions.Rows.Count;i++) { FillTextBoxesFromDataRow(i.ToString(),promotions.tbl_Promotions[i-1]); } } }
private void FillDataRowFromTextBoxes(string counter, BEPromotions.tbl_PromotionsRow dr) { dr.PromotionName = ((TextBox)this.FindControl("txtNamePromotion"+counter)).Text; dr.PromotionDescription = Request.Form[((SharpEditor.Editor)this.FindControl("edtDescriptionPromotion"+counter.ToString())).Editor_HiddenField].ToString(); if (((ImageWizard)this.FindControl("ddlImagePromotion"+counter)).SelectedImage != 0) { dr.PromotionImageID = ((ImageWizard)this.FindControl("ddlImagePromotion"+counter)).SelectedImage; } else { dr.SetPromotionImageIDNull(); } dr.PromotionActive = ((CheckBox)this.FindControl("chkActivePromotion"+counter)).Checked; dr.PromotionOrder = Convert.ToInt32(counter); }
private void FillTextBoxesFromDataRow(string promotion, BEPromotions.tbl_PromotionsRow dr) { ((TextBox)this.FindControl("txtNamePromotion"+promotion)).Text = dr.PromotionName; if (!dr.IsPromotionImageIDNull()) { ((ImageWizard)this.FindControl("ddlImagePromotion"+promotion)).SelectedImage = dr.PromotionImageID; } ((SharpEditor.Editor)this.FindControl("edtDescriptionPromotion"+promotion)).TextBoxText = dr.PromotionDescription; ((CheckBox)this.FindControl("chkActivePromotion"+promotion)).Checked = dr.PromotionActive; }
private void btnSubmit_ServerClick(object sender, System.EventArgs e) { BEPromotions promotions = new BEPromotions(); BPPromotions bp = new BPPromotions(); promotions = bp.SelectAll(); int counter = 1; while (this.FindControl("pnlPromotion" + counter.ToString()) != null && ((Panel)this.FindControl("pnlPromotion" + counter.ToString())).Visible != false) { BEPromotions.tbl_PromotionsRow dr; if (promotions.tbl_Promotions.Rows.Count >= counter) { dr = promotions.tbl_Promotions[counter-1]; } else { dr = promotions.tbl_Promotions.Newtbl_PromotionsRow(); } FillDataRowFromTextBoxes(counter.ToString(),dr); if (promotions.tbl_Promotions.Rows.Count < counter) { promotions.tbl_Promotions.Addtbl_PromotionsRow(dr); } //CreateResizedImage(BEImages DSImages, int ImageID, string prefix, int width, int height, Page page) if (!dr.IsPromotionImageIDNull()) { MWUtility.CreateResizedImage(dr.PromotionImageID, "promo", "", promotionImageSize, 0, this); } counter++; } bp.Update(promotions); Response.Redirect("index.aspx"); }