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; } } }
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 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 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; } } }