protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { if (CardID != 0) { Cards card = new Cards(); card.LoadByPrimaryKey(CardID); uiLabelName.Text = card.CardNameEng; uiLabelPriceFrom.Text = card.PriceBefore.ToString(); uiLabelPriceTo.Text = card.PriceNow.ToString(); uiImagemain.ImageUrl = card.MainPhoto; uiLabelDate.Text = card.UploadDate.ToString("dd/MM/yyyy"); uiLiteralDesc.Text = card.DescriptionEng; CardColor colors = new CardColor(); colors.GetCardColorsByCardID(card.CardID); uiRepeaterColor.DataSource = colors.DefaultView; uiRepeaterColor.DataBind(); uiLinkButtonCustomize.PostBackUrl = "customize.aspx?cid=" + card.CardID; BindReviews(); } else { Response.Redirect("~/browse.aspx"); } } }
protected void uiRepeaterItems_ItemDataBound(object sender, RepeaterItemEventArgs e) { if (e.Item.ItemType == ListItemType.AlternatingItem || e.Item.ItemType == ListItemType.Item) { DataRowView row = (DataRowView)e.Item.DataItem; Cards prod = new Cards(); prod.LoadByPrimaryKey(Convert.ToInt32(row["CardID"].ToString())); Image image = (Image)e.Item.FindControl("uiImageMain"); Label name = (Label)e.Item.FindControl("uiLabelName"); name.Text = prod.CardNameEng; image.ImageUrl = prod.MainPhoto; } }
protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { if (CardID != 0) { Cards card = new Cards(); card.LoadByPrimaryKey(CardID); uiLabelName.Text = card.CardNameEng; uiLabelPriceFrom.Text = card.PriceBefore.ToString(); if (card.PriceBefore == 0 || (card.PriceBefore <= card.PriceNow)) uiPlaceholderPriceFrom.Visible = false; else uiPlaceholderPriceFrom.Visible = true; uiLabelPriceTo.Text = card.PriceNow.ToString(); uiImagemain.ImageUrl = card.GeneralPreviewPhoto; uiLabelDate.Text = card.UploadDate.ToString("dd/MM/yyyy"); uiLiteralDesc.Text = card.DescriptionEng; if (card.IsPartySupplier) { uipanelIsCard.Visible = false; uiLinkButtonCustomize.Visible = false; uiLinkButtonAddToCart.Visible = true; uipanelImages.Visible = true; uiImagemain.Visible = false; PartySupplierImages images = new PartySupplierImages(); images.Where.CardID.Value = card.CardID; images.Where.CardID.Operator = MyGeneration.dOOdads.WhereParameter.Operand.Equal; images.Query.Load(); images.AddNew(); images.CardID = card.CardID; images.ImagePath = card.GeneralPreviewPhoto; uiRepeaterImages.DataSource = images.DefaultView; uiRepeaterImages.DataBind(); uiRepeaterthumbs.DataSource = images.DefaultView; uiRepeaterthumbs.DataBind(); } else { uipanelImages.Visible = false; CardColor colors = new CardColor(); colors.GetCardColorsByCardID(card.CardID); uiRepeaterColor.DataSource = colors.DefaultView; uiRepeaterColor.DataBind(); uiLinkButtonCustomize.PostBackUrl = "customize.aspx?cid=" + card.CardID; } BindReviews(); Master.PageTitle = card.CardNameEng; Categories cat = new Categories(); cat.LoadByPrimaryKey(card.CategoryID); MainCat mcat = new MainCat(); mcat.LoadByPrimaryKey(cat.MainCatId); TopLevelCat tcat = new TopLevelCat(); tcat.LoadByPrimaryKey(mcat.TopLevelCatID); Master.Path = "<li><a href='#'>" + tcat.NameEng + "</a></li>" + "<li><a href='#'>" + mcat.NameEng + "</a></li>"; Master.ViewPath = true; } else { Response.Redirect("~/browse.aspx"); } } }
protected void uiLinkButtonAddToCart_Click(object sender, EventArgs e) { UserPayement temp = (UserPayement)Session["UserPayment"]; if (temp == null) temp = new UserPayement(); temp.AddNew(); Cards card = new Cards(); card.LoadByPrimaryKey(CardID); temp.CardID = card.CardID; temp.CardDesign = card.MainPhoto; temp.CardCount = 1; try { temp.GetColumn("ItemPrice"); } catch (Exception) { temp.AddColumn("ItemPrice", Type.GetType("System.Double")); } temp.SetColumn("ItemPrice", card.PriceNow); Session["UserPayment"] = temp; Master.UpdateCart(); ClientScript.RegisterStartupScript(this.GetType(), "showmodal", "$(document).ready(function(){ $('#ViewModal').modal('show'); });", true); }
private void BindData() { Cards cards = new Cards(); cards.SearchCards(SearchText, CatID,MainCatID,TopCatID, PriceFrom, PriceTo, DimIds, ColorIds, IsPartySupplier); PagedDataSource pds = new PagedDataSource(); pds.DataSource = cards.DefaultView; pds.AllowPaging = true; pds.PageSize = 12; pds.CurrentPageIndex = currentPage; uiRepeaterCards.DataSource = pds; uiRepeaterCards.DataBind(); uiLinkButtonPrev.Enabled = true; uiLinkButtonNext.Enabled = true; if (currentPage == 0) { uiLinkButtonPrev.Enabled = false; } if (currentPage == (pds.PageCount - 1)) { uiLinkButtonNext.Enabled = false; } }
private void LoadCardInfo() { CardLayouts layout = new CardLayouts(); layout.GetCardLayoutByCardID(CardID); for (int i = 0; i < layout.RowCount; i++) { uiRadioButtonListLayouts.Items.Add(new ListItem(String.Format("<img src='{0}' style='width:100px' />", "../" + layout.LayoutImage), "../" + layout.LayoutImage + "#" + "../" + layout.LayeoutBackImage)); layout.MoveNext(); } CardColor colors = new CardColor(); colors.GetCardColorsByCardID(CardID); uiRepeaterColors.DataSource = colors.DefaultView; uiRepeaterColors.DataBind(); Dimension dims = new Dimension(); dims.GetAllDims(); uiRepeaterSizes.DataSource = dims.DefaultView; uiRepeaterSizes.DataBind(); CardText texts = new CardText(); texts.GetCardTxtByCardID(CardID); uiDataListCardText.DataSource = texts.DefaultView; uiDataListCardText.DataBind(); Cards card = new Cards(); card.LoadByPrimaryKey(CardID); uiImageMain.ImageUrl = "../" + card.MainPhoto; }
protected void uiGridViewCards_RowCommand(object sender, GridViewCommandEventArgs e) { if (e.CommandName == "EditCard") { Cards objData = new Cards(); objData.LoadByPrimaryKey(Convert.ToInt32(e.CommandArgument.ToString())); uiTextBoxCardNameEn.Text = objData.CardNameEng; uiTextBoxCardNameAr.Text = objData.CardNameAr; uiTextBoxDescEn.Text = objData.DescriptionEng; uiTextBoxDescAr.Text = objData.DescriptionAr; uiTextBoxPriceAfter.Text = objData.PriceNow.ToString(); uiTextBoxPriceBefore.Text = objData.PriceBefore.ToString(); uiPanelAllCards.Visible = false; uiPanelEdit.Visible = true; tabs.Visible = true; tabscontent.Visible = true; CurrentCard = objData; BindData(); BindImages(); } else if (e.CommandName == "DeleteCard") { try { Cards objData = new Cards(); objData.LoadByPrimaryKey(Convert.ToInt32(e.CommandArgument.ToString())); objData.MarkAsDeleted(); objData.Save(); CurrentCard = null; BindData(); } catch (Exception ex) { return; } } }
private void BindData() { Cards cards = new Cards(); if (uiDropDownListCats.SelectedIndex != -1) cards.GetCardsByCategoryID(Convert.ToInt32(uiDropDownListCats.SelectedValue), true); uiGridViewCards.DataSource = cards.DefaultView; uiGridViewCards.DataBind(); }
protected void uiLinkButtonOK_Click(object sender, EventArgs e) { Cards card = new Cards(); if (CurrentCard == null) { card.AddNew(); card.UploadDate = DateTime.Now; card.CategoryID = Convert.ToInt32(uiDropDownListCats.SelectedValue); card.IsPartySupplier = true; } else card = CurrentCard; card.CardNameEng = uiTextBoxCardNameEn.Text; card.CardNameAr = uiTextBoxCardNameAr.Text; card.DescriptionEng = uiTextBoxDescEn.Text; card.DescriptionAr = uiTextBoxDescAr.Text; double priceBefore, priceAfter = 0; double.TryParse(uiTextBoxPriceAfter.Text, out priceAfter); double.TryParse(uiTextBoxPriceBefore.Text, out priceBefore); card.PriceNow = priceAfter; card.PriceBefore = priceBefore; if (uiFileUploadMainImage.HasFile) { string filepath = "/images/Card/" + DateTime.Now.ToString("ddMMyyyyhhmmss") + "_" + uiFileUploadMainImage.FileName; uiFileUploadMainImage.SaveAs(Server.MapPath("~" + filepath)); card.MainPhoto = filepath; } if (uiFileUploadHoverImage.HasFile) { string filepath = "/images/Card/" + DateTime.Now.ToString("ddMMyyyyhhmmss") + "_" + uiFileUploadHoverImage.FileName; uiFileUploadHoverImage.SaveAs(Server.MapPath("~" + filepath)); card.MainPhotoHover = filepath; } card.Save(); uiLabelMsg.Text = "Product saved successfully. Now you can add Product images."; uiLabelMsg.ForeColor = System.Drawing.Color.Green; uiLabelMsg.Visible = true; tabs.Visible = true; tabscontent.Visible = true; CurrentCard = card; }
protected void uiLinkButtonCancel_Click(object sender, EventArgs e) { uiPanelAllCards.Visible = true; uiPanelEdit.Visible = false; CurrentCard = null; ClearFields(); }
protected void uiButtonApply_Click(object sender, EventArgs e) { try { MailMessage msg = new MailMessage(); msg.IsBodyHtml = true; System.Drawing.Graphics myGraphic = null; string[] images = uiRadioButtonListLayouts.SelectedValue.Split('#'); System.Drawing.Image imgSelectedLayout; imgSelectedLayout = System.Drawing.Image.FromFile(Server.MapPath("~/" + images[0])); // add layout as attach msg.Attachments.Add(new Attachment(Server.MapPath("~/" + images[0]))); System.Drawing.Color backcolor = System.Drawing.ColorTranslator.FromHtml(uiHiddenFieldColor.Value); System.Drawing.Brush b = new System.Drawing.SolidBrush(backcolor); Cards card = new Cards(); card.LoadByPrimaryKey(CardID); // add Main card info msg.Body += "<br /> =========================================================== <br />"; msg.Body += " ========================= Card info ================== <br />"; msg.Body += " Card Name : " + card.CardNameEng; msg.Body += "<br /> Card Price : " + card.PriceNow; msg.Body += "<br /> Card Path : " + FullPath + " > " + card.CardNameEng; // add background color msg.Body += "<br /> =========================================================== <br />"; msg.Body += " ========================= Background color ================== <br />"; msg.Body += "Background Color : " + uiHiddenFieldColor.Value + "<br />"; System.Drawing.Bitmap backgroundcolor = new System.Drawing.Bitmap(imgSelectedLayout); System.Drawing.Graphics g = System.Drawing.Graphics.FromImage(backgroundcolor); g.FillRectangle(b, 0, 0, imgSelectedLayout.Width, imgSelectedLayout.Height); g.Save(); string backpath = Guid.NewGuid().ToString(); backgroundcolor.Save(Server.MapPath("~/images/UserOrders/" + backpath + "_1.jpeg")); System.Drawing.Image GeneratedImg;// =new Image.FromFile(ImageBack); // draw background GeneratedImg = System.Drawing.Image.FromFile(Server.MapPath("~/images/UserOrders/" + backpath + "_1.jpeg")); myGraphic = System.Drawing.Graphics.FromImage(GeneratedImg); myGraphic.SmoothingMode = SmoothingMode.HighQuality; msg.Body += "<br /> =========================================================== <br />"; msg.Body += " ========================= Images Info ================== <br />"; //draw user uploaded images foreach (DataListItem dli in uiDataListImages.Items) { if (dli.ItemType == ListItemType.Item || dli.ItemType == ListItemType.AlternatingItem) { FileUpload imgfile = (FileUpload)dli.FindControl("uiFileUploadImg"); HiddenField hfPath = (HiddenField)dli.FindControl("uiHiddenFieldPath"); HiddenField hf = (HiddenField)dli.FindControl("uiHiddenFieldImgID"); HiddenField contrast = (HiddenField)dli.FindControl("uiHiddenFieldContrast"); HiddenField brightness = (HiddenField)dli.FindControl("uiHiddenFieldBrightness"); HiddenField rotate = (HiddenField)dli.FindControl("uiHiddenFieldRotate"); DropDownList style = (DropDownList)dli.FindControl("uiDropDownListStyle"); System.Web.UI.WebControls.Image current = (System.Web.UI.WebControls.Image)dli.FindControl("uiImageCurrent"); CardImages img = new CardImages(); img.LoadByPrimaryKey(Convert.ToInt32(hf.Value)); string path = hfPath.Value; if (imgfile.HasFile) { path = "images/UserOrders/cardImages/" + Guid.NewGuid().ToString() + imgfile.FileName; imgfile.SaveAs(Server.MapPath("~/" + path)); hfPath.Value = path; current.ImageUrl = path; current.Visible = true; } if (!string.IsNullOrEmpty(path)) { System.Drawing.Image currentCardImage; WebClient webclient = new WebClient(); System.IO.Stream s = webclient.OpenRead(ConfigurationManager.AppSettings["appHome"] + "ImageOnDemand.ashx?url=" + path + "&brightness=" + brightness.Value + "&contrast=" + contrast.Value + "&" + style.SelectedValue); currentCardImage = System.Drawing.Image.FromStream(s); if (float.Parse(rotate.Value) > 0) { myGraphic.TranslateTransform((float)img.ImgWidth / 2, (float)img.ImgHieght / 2); myGraphic.RotateTransform(float.Parse(rotate.Value)); myGraphic.DrawImageUnscaled(currentCardImage, img.PosX, img.PosY, img.ImgWidth, img.ImgHieght); myGraphic.RotateTransform(-float.Parse(rotate.Value)); myGraphic.TranslateTransform(-(float)img.ImgWidth / 2, -(float)img.ImgHieght / 2); } else { myGraphic.DrawImageUnscaled(currentCardImage, img.PosX, img.PosY, img.ImgWidth, img.ImgHieght); } // add image uploaded by user as attachment msg.Attachments.Add(new Attachment(Server.MapPath("~/" + path))); msg.Body += "Image " + (dli.ItemIndex + 1).ToString() + " : <br />"; msg.Body += "contrust : " + contrast.Value + "<br />"; msg.Body += "brightness : " + brightness.Value + " <br />"; msg.Body += "rotaion : " + rotate.Value + " <br />"; msg.Body += "style : " + style.SelectedValue.Substring(0, style.SelectedValue.IndexOf("=")) + " <br />"; } } } myGraphic.ResetTransform(); // draw layout //myGraphic.DrawImageUnscaled(imgSelectedLayout, 0, 0,imgSelectedLayout.Width, imgSelectedLayout.Height); myGraphic.DrawImage(imgSelectedLayout, 0, 0, imgSelectedLayout.Width, imgSelectedLayout.Height); myGraphic.Save(); // draw strings myGraphic.TextRenderingHint = System.Drawing.Text.TextRenderingHint.AntiAliasGridFit; msg.Body += "<br /> =========================================================== <br />"; msg.Body += " ========================= Text Info ================== <br />"; foreach (DataListItem dli in uiDataListCardText.Items) { if (dli.ItemType == ListItemType.Item || dli.ItemType == ListItemType.AlternatingItem) { HiddenField hf = (HiddenField)dli.FindControl("uiHiddenFieldTextID"); HiddenField hfc = (HiddenField)dli.FindControl("uiHiddenFieldMyColor"); DropDownList ddlfont = (DropDownList)dli.FindControl("uiDropDownListFonts"); DropDownList ddlfontsize = (DropDownList)dli.FindControl("uiDropDownListFontSize"); CardText text = new CardText(); TextBox tb = (TextBox)dli.FindControl("uiTextBoxText"); text.LoadByPrimaryKey(Convert.ToInt32(hf.Value)); System.Drawing.Color fontcolor = System.Drawing.ColorTranslator.FromHtml(hfc.Value); System.Drawing.Brush fontbrush = new System.Drawing.SolidBrush(fontcolor); FontFamily family = new FontFamily(ddlfont.SelectedItem.Text); float fontsize = (Convert.ToInt32(ddlfontsize.SelectedItem.Text) * family.GetEmHeight(FontStyle.Regular)) / family.GetCellDescent(FontStyle.Regular); myGraphic.DrawString(tb.Text, new Font(ddlfont.SelectedItem.Text, fontsize, FontStyle.Italic), fontbrush, new RectangleF(text.PosX, text.PosY, text.Width, text.Height)); msg.Body += text.TextLabel + " : " + tb.Text + "<br />"; msg.Body += "font : " + ddlfont.SelectedItem.Text + "<br />"; msg.Body += "font size : " + ddlfontsize.SelectedItem.Text + " <br />"; msg.Body += "color : " + hfc.Value + " <br />"; } } myGraphic.Save(); string newpath = Guid.NewGuid().ToString(); // save generated img GeneratedImg.Save(Server.MapPath("~/images/UserOrders/" + newpath + "_2.jpeg"), System.Drawing.Imaging.ImageFormat.Jpeg); uiImageMain.ImageUrl = "~/images/UserOrders/" + newpath + "_2.jpeg"; // add final image as attachment msg.Attachments.Add(new Attachment(Server.MapPath("~/images/UserOrders/" + newpath + "_2.jpeg"))); myGraphic.Dispose(); UserPayement temp = new UserPayement(); temp.AddNew(); temp.CardID = CardID; temp.CardDesign = "images/UserOrders/" + newpath + "_2.jpeg"; temp.CardCount = 1; try { temp.GetColumn("ItemPrice"); } catch (Exception) { temp.AddColumn("ItemPrice", Type.GetType("System.Double")); } temp.SetColumn("ItemPrice", card.PriceNow); Session["UserPayment"] = temp; uipanelError.Visible = false; OrderMail = msg; } catch (Exception ex) { uipanelError.Visible = true; } }
private void LoadCardInfo() { CardLayouts layout = new CardLayouts(); layout.GetCardLayoutByCardID(CardID); for (int i = 0; i < layout.RowCount; i++) { uiRadioButtonListLayouts.Items.Add(new ListItem(String.Format("<img src='{0}' style='width:100px' />", ".." + layout.LayoutImage), ".." + layout.LayoutImage + "#" + ".." + layout.LayeoutBackImage)); layout.MoveNext(); } if (uiRadioButtonListLayouts.Items.Count > 0) uiRadioButtonListLayouts.Items[0].Selected = true; CardColor colors = new CardColor(); colors.GetCardColorsByCardID(CardID); uiRepeaterColors.DataSource = colors.DefaultView; uiRepeaterColors.DataBind(); Dimension dims = new Dimension(); dims.GetAllDims(); uiRepeaterSizes.DataSource = dims.DefaultView; uiRepeaterSizes.DataBind(); CardText texts = new CardText(); texts.GetCardTxtByCardID(CardID); uiDataListCardText.DataSource = texts.DefaultView; uiDataListCardText.DataBind(); CardImages images = new CardImages(); images.GetCardImageByCardID(CardID); if (images.RowCount > 0) { uiDataListImages.DataSource = images.DefaultView; uiDataListImages.DataBind(); uiPanelNoImages.Visible = false; } else { uiDataListImages.Visible = false; uiPanelNoImages.Visible = true; } Cards card = new Cards(); card.LoadByPrimaryKey(CardID); Categories cat = new Categories(); cat.LoadByPrimaryKey(card.CategoryID); MainCat mcat = new MainCat(); mcat.LoadByPrimaryKey(cat.MainCatId); TopLevelCat tcat = new TopLevelCat(); tcat.LoadByPrimaryKey(mcat.TopLevelCatID); uiImageMain.ImageUrl = "../" + card.GeneralPreviewPhoto; FullPath = tcat.NameEng + " > " + mcat.NameEng + " > " + cat.CatNameEng; }
protected void uiDataListCardText_ItemDataBound(object sender, DataListItemEventArgs e) { if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem) { Cards card = new Cards(); card.LoadByPrimaryKey(CardID); TextBox textbox = (TextBox)e.Item.FindControl("uiTextBoxText"); DropDownList dlfonts = (DropDownList)e.Item.FindControl("uiDropDownListFonts"); DataRowView row = (DataRowView)e.Item.DataItem; if (row["IsMultiLine"] != null) { if ((bool)row["IsMultiLine"] == true) textbox.TextMode = TextBoxMode.MultiLine; } if (!card.IsColumnNull("DefaultFont")) { dlfonts.SelectedValue = card.DefaultFont; } } }
protected void uiRepeaterOrder_ItemDataBound(object sender, RepeaterItemEventArgs e) { if (e.Item.ItemType == ListItemType.AlternatingItem || e.Item.ItemType == ListItemType.Item) { Image envelop = (Image)e.Item.FindControl("uiImageEnvelop"); Label maxQty = (Label)e.Item.FindControl("uiLabelMaxQty"); Label Envdash = (Label)e.Item.FindControl("uiLabelEnvDash"); DataRowView row = (DataRowView)e.Item.DataItem; Cards card = new Cards(); card.LoadByPrimaryKey(Convert.ToInt32(row["CardID"])); if (card.IsColumnNull("IsPartySupplier")) { maxQty.Visible = true; } else if (card.IsPartySupplier) { maxQty.Visible = false; } else if (!card.IsPartySupplier) { maxQty.Visible = true; } if (EnverlopID != 0) { Envelops envelopTemp = new Envelops(); envelopTemp.LoadByPrimaryKey(Convert.ToInt32(row["EnvelopID"].ToString())); envelop.ImageUrl = ".." + envelopTemp.ImagePath; Envdash.Visible = false; } else { Envdash.Visible = true; } } }
protected void uiLinkButtonOK_Click(object sender, EventArgs e) { if (!string.IsNullOrEmpty(uiDropDownListCats.SelectedValue) && uiDropDownListCats.SelectedIndex != -1) { Cards card = new Cards(); if (CurrentCard == null) { card.AddNew(); card.UploadDate = DateTime.Now; card.CategoryID = Convert.ToInt32(uiDropDownListCats.SelectedValue); card.IsPartySupplier = false; } else card = CurrentCard; card.CardNameEng = uiTextBoxCardNameEn.Text; card.CardNameAr = uiTextBoxCardNameAr.Text; card.DescriptionEng = uiTextBoxDescEn.Text; card.DescriptionAr = uiTextBoxDescAr.Text; card.DimensionID = Convert.ToInt32(uiDropDownListDim.SelectedValue); card.DefaultFont = uiDropDownListFonts.SelectedItem.Text; double priceBefore, priceAfter = 0; double.TryParse(uiTextBoxPriceAfter.Text, out priceAfter); double.TryParse(uiTextBoxPriceBefore.Text, out priceBefore); card.PriceNow = priceAfter; card.PriceBefore = priceBefore; if (uiFileUploadGeneral.HasFile) { string filepath = "/images/Card/" + DateTime.Now.ToString("ddMMyyyyhhmmss") + "_General_" + uiFileUploadGeneral.FileName; uiFileUploadGeneral.SaveAs(Server.MapPath("~" + filepath)); card.GeneralPreviewPhoto = filepath; } if (uiFileUploadMainImage.HasFile) { string filepath = "/images/Card/" + DateTime.Now.ToString("ddMMyyyyhhmmss") + "_Main_" + uiFileUploadMainImage.FileName; uiFileUploadMainImage.SaveAs(Server.MapPath("~" + filepath)); card.MainPhoto = filepath; } if (uiFileUploadHoverImage.HasFile) { string filepath = "/images/Card/" + DateTime.Now.ToString("ddMMyyyyhhmmss") + "_Hover_" + uiFileUploadHoverImage.FileName; uiFileUploadHoverImage.SaveAs(Server.MapPath("~" + filepath)); card.MainPhotoHover = filepath; } card.Save(); uiLabelMsg.Text = "Card saved successfully. Now you can add card text, card layouts and card default colors."; uiLabelMsg.ForeColor = System.Drawing.Color.Green; uiLabelMsg.Visible = true; tabs.Visible = true; tabscontent.Visible = true; CurrentCard = card; uiLabelCardName.Text = card.CardNameEng; } else { uiLabelMsg.Text = "Error. please back to select a category before adding a new card. "; uiLabelMsg.ForeColor = System.Drawing.Color.Red; uiLabelMsg.Visible = true; } }
protected void uiGridViewCards_RowCommand(object sender, GridViewCommandEventArgs e) { if (e.CommandName == "EditCard") { Cards objData = new Cards(); objData.LoadByPrimaryKey(Convert.ToInt32(e.CommandArgument.ToString())); uiTextBoxCardNameEn.Text = objData.CardNameEng; uiTextBoxCardNameAr.Text = objData.CardNameAr; uiTextBoxDescEn.Text = objData.DescriptionEng; uiTextBoxDescAr.Text = objData.DescriptionAr; if (!objData.IsColumnNull("DefaultFont")) { uiDropDownListFonts.SelectedValue = objData.DefaultFont; } if (!objData.IsColumnNull("DimensionID")) uiDropDownListDim.SelectedValue = objData.DimensionID.ToString(); uiTextBoxPriceAfter.Text = objData.PriceNow.ToString(); uiTextBoxPriceBefore.Text = objData.PriceBefore.ToString(); uiPanelAllCards.Visible = false; uiPanelEdit.Visible = true; tabs.Visible = true; tabscontent.Visible = true; CurrentCard = objData; BindData(); BindCardTxt(); BindCardLayout(); BindCardColors(); BindCardImages(); uiLabelCatName.Text = uiDropDownListCats.SelectedItem.Text; uiLabelCardName.Text = objData.CardNameEng; } else if (e.CommandName == "DeleteCard") { try { int id = Convert.ToInt32(e.CommandArgument.ToString()); CardImages images = new CardImages(); images.GetCardImageByCardID(id); int irows = images.RowCount; for (int i = 0; i < irows; i++) { images.MarkAsDeleted(); images.MoveNext(); } images.Save(); CardLayouts layouts = new CardLayouts(); layouts.GetCardLayoutByCardID(id); int lrows = layouts.RowCount; for (int i = 0; i < lrows; i++) { layouts.MarkAsDeleted(); layouts.MoveNext(); } layouts.Save(); CardText texts = new CardText(); texts.GetCardTxtByCardID(id); int trows = texts.RowCount; for (int i = 0; i < trows; i++) { texts.MarkAsDeleted(); texts.MoveNext(); } texts.Save(); CardColor colors = new CardColor(); colors.GetCardColorsByCardID(id); int crows = colors.RowCount; for (int i = 0; i < crows; i++) { colors.MarkAsDeleted(); colors.MoveNext(); } colors.Save(); Cards objData = new Cards(); objData.LoadByPrimaryKey(id); objData.MarkAsDeleted(); objData.Save(); CurrentCard = null; BindData(); } catch (Exception ex) { return; } } }