protected void uiButtonUpdate_Click(object sender, EventArgs e)
        {
            Product product= new Product();
            if (CurrentProduct != null)
            {
                product = CurrentProduct;
            }
            else
            {
                product.AddNew();
            }

            product.ProductCode = uiTextBoxCode.Text;
            product.Name = uiTextBoxName.Text;
            product.Description = Server.HtmlEncode(uiFCKeditorDesc.Value);
            product.CategoryID = Convert.ToInt32(uiDropDownListCategory.SelectedValue);
            if (!string.IsNullOrEmpty(uiDropDownListSubCat.SelectedValue))
                product.SubCategoryID = Convert.ToInt32(uiDropDownListSubCat.SelectedValue);
            if(!string.IsNullOrEmpty(uiTextBoxPrice.Text))
                product.Price = decimal.Parse(uiTextBoxPrice.Text);
            string file = "";
            if (uiFileUploadImg.HasFile)
            {
                uiFileUploadImg.SaveAs(Server.MapPath("~/UploadFolder/products/" + uiFileUploadImg.FileName));
                file = "/UploadFolder/products/" + uiFileUploadImg.FileName;
                product.PicPath = file;
            }

            product.Save();
            uiPanelEdit.Visible = false;
            uiPanelViewProducts.Visible = true;
            Clearfields();
            BindData();
            CurrentProduct = null;
        }
        protected void uiGridViewProducts_RowCommand(object sender, GridViewCommandEventArgs e)
        {
            if (e.CommandName == "EditProduct")
            {
                Product product = new Product();
                product.LoadByPrimaryKey(Convert.ToInt32(e.CommandArgument));
                CurrentProduct = product;

                uiTextBoxName.Text = product.Name;
                uiTextBoxCode.Text = product.ProductCode;
                if(!product.IsColumnNull("Price"))
                    uiTextBoxPrice.Text = product.Price.ToString();
                uiFCKeditorDesc.Value = Server.HtmlDecode(product.Description);
                uiDropDownListCategory.SelectedValue = product.CategoryID.ToString();
                if (!product.IsColumnNull("SubCategoryID"))
                    uiDropDownListSubCat.SelectedValue = product.SubCategoryID.ToString();
                uiPanelViewProducts.Visible = false;
                uiPanelEdit.Visible = true;
            }
            else if (e.CommandName == "DeleteProduct")
            {
                try
                {
                    Product product = new Product();
                    product.LoadByPrimaryKey(Convert.ToInt32(e.CommandArgument));
                    product.MarkAsDeleted();
                    product.Save();
                    BindData();
                }
                catch (Exception ex)
                {
                    uiLabelError.Visible = true;
                }

            }
        }