コード例 #1
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                if (CatID != 0)
                {
                    ProductCategories cat = new ProductCategories();
                    cat.LoadByPrimaryKey(CatID);
                    uiTextBoxName.Text = cat.NameEn;
                    uiTextBoxDesc.Text = cat.DescriptionEn;
                    uiImageMain.ImageUrl = cat.ImagePath;
                    uiPanelEdit.Visible = true;

                }
                else if(AddNew == 1)
                    uiPanelEdit.Visible = true;
                else
                {
                    uiPanelEdit.Visible = false;
                }

                // Bind Categories from the DB.
                FillCategories();
            }
        }
コード例 #2
0
        private void GetCategories(TreeNode TNN)
        {
            // Fill child categories for certain Parent .. and loop inside it to bind all leafs under it.
            ProductCategories objCat = new ProductCategories();
            TreeNode TN = new TreeNode();

            DataTable dt = objCat.GetSubCategories(Int32.Parse(TNN.Value));
            foreach (DataRow dr in dt.Rows)
            {
                TN = new TreeNode(dr[ProductCategories.ColumnNames.NameEn].ToString(), dr[ProductCategories.ColumnNames.ProductCategoryID].ToString(), "", "products.aspx?cid=" + dr[ProductCategories.ColumnNames.ProductCategoryID].ToString(), "");
                TN.SelectAction = TreeNodeSelectAction.Expand;
                //TN.Expanded = true;
                TNN.ChildNodes.Add(TN);
                GetCategories(TN);
            }
        }
コード例 #3
0
        private void FillCategories()
        {
            uiTreeViewCats.Nodes.Clear();
            // Fill Main Categories and loop with each nood to bind it's childs
            ProductCategories objCat = new ProductCategories();

            TreeNode TN = new TreeNode();
            DataTable dt = objCat.GetMainCategories();
            foreach (DataRow dr in dt.Rows)
            {
                TN = new TreeNode(dr[ProductCategories.ColumnNames.NameEn].ToString(), dr[ProductCategories.ColumnNames.ProductCategoryID].ToString(), "", "products.aspx?cid=" + dr[ProductCategories.ColumnNames.ProductCategoryID].ToString(), "");
                TN.SelectAction = TreeNodeSelectAction.Expand;
                //TN.Expanded = true;
                GetCategories(TN);
                uiTreeViewCats.Nodes.Add(TN);
            }
        }
コード例 #4
0
ファイル: Product.cs プロジェクト: menasbeshay/ivalley-svn
        public string GetAllSubCats(int CategoryID)
        {
            string subcats = "";
            ProductCategories subcat = new ProductCategories();
            DataTable dt = subcat.GetSubCategories(CategoryID);

            foreach (DataRow dr in dt.Rows)
            {
                ProductCategories ch = new ProductCategories();
                DataTable children = ch.GetSubCategories(Convert.ToInt32(dr[ProductCategories.ColumnNames.ProductCategoryID]));
                if (children.Rows.Count > 0)
                {
                    subcats += "," + dr["ProductCategoryID"].ToString() + GetAllSubCats(Convert.ToInt32(dr[ProductCategories.ColumnNames.ProductCategoryID]));

                }
                else
                    subcats += "," + dr["ProductCategoryID"].ToString();
            }
            return subcats;
        }
コード例 #5
0
 private string getCatName()
 {
     ProductCategories Cats = new ProductCategories();
     Cats.LoadByPrimaryKey(int.Parse(Session["CategoryID"].ToString()));
     return Cats.NameEn;
 }
コード例 #6
0
 protected void uiLinkButtonSave_Click(object sender, EventArgs e)
 {
     ProductCategories cat = new ProductCategories();
     if (AddNew != 0)
         cat.AddNew();
     else
         cat.LoadByPrimaryKey(CatID);
     cat.NameEn = uiTextBoxName.Text;
     cat.DescriptionEn = uiTextBoxDesc.Text;
     if (!IsParent && ParentCatID !=0)
     {
         cat.CategoryParentID = ParentCatID;
     }
     if (uiFileUploadImg.HasFile)
     {
         string filepath = "/admin/UploadedFiles/cats/" + DateTime.Now.ToString("ddMMyyyyhhmmss") + "_" + uiFileUploadImg.FileName;
         uiFileUploadImg.SaveAs(Server.MapPath("~" + filepath));
         cat.ImagePath= filepath;
     }
     cat.Save();
     FillCategories();
     uiPanelEdit.Visible = false;
     clearFields();
 }
コード例 #7
0
 protected void uiLinkButtonDelete_Click(object sender, EventArgs e)
 {
     ProductCategories cat = new ProductCategories();
     cat.LoadByPrimaryKey(CatID);
     cat.MarkAsDeleted();
     cat.Save();
     FillCategories();
     uiPanelEdit.Visible = false;
 }