/// <summary>
    /// adding a new product
    /// </summary>
    protected void btnAddProduct_Click(object sender, EventArgs e)
    {
        try
        {
            int counter = 1;
            Category c = new Category();
            properties = c.getCategoryProperties(categories[categoriesNamesDDL.SelectedValue.ToString()]);
            propertiesOfCategory = new Dictionary<int, string>();
            foreach (KeyValuePair<string, int> pair in properties)//getting the propery id and its description
            {
                TextBox tb = Page.FindControl("txProperty" + counter) as TextBox;
                if (tb != null)
                {
                    string property = tb.Text;
                    ProductProperty productProp = new ProductProperty();
                    productProp.Description = property;
                    Property pr = new Property();
                    pr.Name = pair.Key;
                    propertiesOfCategory.Add(properties[pr.Name], productProp.Description);
                }
                counter++;
            }

            Product product = new Product();
            product.Id = Convert.ToInt32(productIdTB.Text);
            product.Name = productNameTB.Text;
            product.Description = productDescriptionTB.Text;
            DateTime currentTime = DateTime.Now;
            product.DateModified = currentTime;
            InsertPictureToDirectory();
            product.ImageUrl = ProductpicPath;
            product.Price = Convert.ToDouble(ProductPriceTB.Text);
            if (discountTB.Text == "") { }
            else
                product.Discount = discountTB.Text;
            int numOfRows = product.insertNewProduct(product, categories[categoriesNamesDDL.SelectedValue.ToString()], propertiesOfCategory, "Email");
            if (numOfRows > 0)//מוציא הודעה האם המוצר הוכנס כמו שצריך
            {
                ProductInsertedName.InnerHtml = product.Name;
                Session.Add("numOfRows", numOfRows);
                Session.Add("product", product);
                Response.Redirect("CatalogManager.aspx");
            }
        }
        catch (Exception)
        {

        }
    }
 /// <summary>
 /// insert the updateCategory properties to the table
 /// </summary>
 protected void editCategoryCategoriesDDL_SelectedIndexChanged(object sender, EventArgs e)
 {
     EditCategoryPropTable.Controls.Clear();
     Category c = new Category();
     properties = new Dictionary<string, int>();
     if (editCategoryCategoriesDDL.SelectedValue.ToString() != "בחר")
     {
         properties = c.getCategoryProperties(categories[editCategoryCategoriesDDL.SelectedValue.ToString()]);
         foreach (KeyValuePair<string, int> pair in properties)
         {
             HtmlTableRow tr = new HtmlTableRow();
             HtmlTableCell tc = new HtmlTableCell();
             HtmlTableCell tc1 = new HtmlTableCell();
             Button btn = new Button();
             Button btn1 = new Button();
             btn.Text = "עריכה";
             btn.OnClientClick = "updateRowInEditCategory()";
             btn1.OnClientClick = "deleteRow()";
             btn1.Text = "הסרה";
             tc1.Controls.Add(btn);
             tc1.Controls.Add(btn1);
             tr.Attributes.Add("Class", "odd gradeX");
             tc.InnerHtml = pair.Key;
             tr.Controls.Add(tc);
             tr.Controls.Add(tc1);
             EditCategoryPropTable.Controls.Add(tr);
         }
     }
 }
 /// <summary>
 /// insert the category properties to the addProduct form
 /// </summary>
 protected void insertCategoryProperties()
 {
     Category c = new Category();
     properties = new Dictionary<string, int>();
     if (categoriesNamesDDL.SelectedValue.ToString() != "בחר")
     {
         properties = c.getCategoryProperties(categories[categoriesNamesDDL.SelectedValue.ToString()]);
         HtmlTable tb = new HtmlTable();
         tb.Style.Add("text-align", "right");
         tb.Attributes.Add("runat", "Server");
         tb.ID = "propertiesTable";
         int counter = 1;
         foreach (KeyValuePair<string, int> pair in properties)
         {
             HtmlTableRow tr = new HtmlTableRow();
             HtmlTableCell tc = new HtmlTableCell("th");
             Label l = new Label();
             l.Text = pair.Key;
             HtmlTableCell tc1 = new HtmlTableCell();
             TextBox tx = new TextBox();
             tx.ID = "txProperty" + counter;
             tx.CssClass = "text";
             tc.Controls.Add(l);
             tc1.Controls.Add(tx);
             tr.Controls.Add(tc);
             tr.Controls.Add(tc1);
             tb.Controls.Add(tr);
             counter++;
         }
         propertiesAddPH.Controls.Add(tb);
     }
     else
     {
         propertiesAddPH.Controls.Clear();
     }
 }