Exemplo n.º 1
0
        // Key Methods

        public int CreateNewKey(int RecordID, string Key)
        {
            using (HowToDBEntities db = new HowToDBEntities())
            {
                Key k = new Key
                {
                    TreeID  = (short)this.CurrentTree,
                    NodeID  = RecordID,
                    TypeID  = 7,
                    KeyText = Key
                };

                db.Keys.Add(k);
                db.SaveChanges();
                RecordID = k.KeyID;
                var keys =
                    (from ke in db.Keys
                     where ke.TreeID == 2
                     orderby ke.KeyText
                     select new
                {
                    ke.KeyText
                }).Distinct();
                if (keys.Count() > 0)
                {
                    treelbxKeys.DataSource = keys.ToList();
                    treelbxKeys.DataBind();
                }
            }
            return(RecordID);
        }
Exemplo n.º 2
0
 public void UpdateNode(int i)
 {
     using (HowToDBEntities db = new HowToDBEntities())
     {
         Node node = db.Nodes.FirstOrDefault(n => n.NodeID == i);
         node.Heading  = treetxtHeading.Text;
         node.NodeText = treetxtNodeText.Text;
         db.SaveChanges();
     }
 }
Exemplo n.º 3
0
        // Node Methods

        public int CreateNewNode()
        {
            int RecordID;

            using (HowToDBEntities db = new HowToDBEntities())
            {
                Node n = new Node
                {
                    TreeID       = (short)this.CurrentTree,
                    TypeID       = (short)this.NodeType,
                    TreeLevel    = (short)this.CurrentLevel,
                    ParentNodeID = this.ParentNode,
                    Heading      = treetxtHeading.Text,
                    NodeText     = treetxtNodeText.Text
                };

                db.Nodes.Add(n);
                db.SaveChanges();
                RecordID = n.NodeID;
                if (this.CurrentLevel == 1)
                {
                    var nodes =
                        from no in db.Nodes
                        where no.TreeID == 2 && no.ParentNodeID == this.ParentNode
                        orderby no.Heading
                        select no;
                    if (nodes.Count() > 0)
                    {
                        treelbxNodes.DataSource = nodes.ToList();
                        treelbxNodes.DataBind();
                    }
                }
                else
                {
                    var nodes =
                        from no in db.Nodes
                        where no.TreeID == 2 && no.ParentNodeID == this.ParentNode
                        select no;
                    if (nodes.Count() > 0)
                    {
                        treelbxNodes.DataSource = nodes.ToList();
                        treelbxNodes.DataBind();
                    }
                }
            }
            return(RecordID);
        }