protected void LinkButtonAddCategory_Click(object sender, EventArgs e)
        {
            int parentID = TreeViewCategories1.SelectedNodeID;
            
            //if (int.TryParse(TreeViewCategories1.SelectedNodeID, out parentID))
            {
                CategoriesActions categoriesActions = new CategoriesActions();
                Categories categories = new Categories();
                categories.Name = TextBoxAddCategory.Text;

                int createdID = categoriesActions.AddCategoty(categories, parentID);
                TreeNode treeNode = new TreeNode(categories.Name, createdID.ToString());
                //TreeViewManage.SelectedNode.ChildNodes.Add(treeNode);
                TreeViewCategories1.SelectedNodeCollection.Add(treeNode);
            }
            TextBoxAddCategory.Text = "";
            PanelAddCategory.Visible = false;
        }
Exemplo n.º 2
0
        public int CreateCategory(Categories categories, int parentID)
        {
            int createdID; 
            
            using (Sessions.NewSession = Sessions.SessionFactory.OpenSession())
            {
                using (var transaction = Sessions.NewSession.BeginTransaction())
                {
                    Sessions.NewSession.SaveOrUpdate(categories);
                    Sessions.NewSession.Flush();
                    createdID = categories.ID;

                    Relations relations = new Relations();
                    relations.ChildID = createdID;
                    relations.Categories = Sessions.NewSession.Get<Categories>(parentID);
                    Sessions.NewSession.SaveOrUpdate(relations);
                    Sessions.NewSession.Flush();

                    transaction.Commit();
                }
            }
            return createdID;
        }
Exemplo n.º 3
0
 public int AddCategoty(Categories categories, int parentID)
 {
     CategoriesCRUD categoriesCRUD = new CategoriesCRUD();
     return categoriesCRUD.CreateCategory(categories, parentID);
 }