예제 #1
0
        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;
        }
예제 #2
0
        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;
            }
        }