コード例 #1
0
        private void AddSheet_Click(object sender, RoutedEventArgs e)
        {
            CSheet sheet = new CSheet();

            sheet.Dat = DateTime.Today;
            NodeWindow nodeWindow = new NodeWindow(sheet);

            if (nodeWindow.ShowDialog() == true)
            {
                Collect coll = new Collect();
                coll.Collect_name = nodeWindow._node.Name;
                if (treeColl.SelectedItem.GetType() == typeof(CSheet))
                {
                    coll.Parent_id = (treeColl.SelectedItem as CSheet).ParentId;
                }
                else
                {
                    coll.Parent_id = (treeColl.SelectedItem as CNode).Id;
                }
                coll.Type  = "sheet";
                coll.DDate = (nodeWindow._node as CSheet).Dat;

                db.Collects.Add(coll);
                db.SaveChanges();
                GenerateTree();
            }
        }
コード例 #2
0
        private void Edit_Click(object sender, RoutedEventArgs e)
        {
            if (treeColl.SelectedItem == null)
            {
                return;
            }

            Collect coll;

            if (treeColl.SelectedItem.GetType() == typeof(CSheet))
            {
                CSheet     node       = treeColl.SelectedItem as CSheet;
                NodeWindow nodeWindow = new NodeWindow(node);
                if (nodeWindow.ShowDialog() == true)
                {
                    coll = db.Collects.Find(nodeWindow._node.Id);
                    if (coll != null)
                    {
                        coll.Collect_name    = nodeWindow._node.Name;
                        coll.Type            = "sheet";
                        coll.DDate           = (nodeWindow._node as CSheet).Dat;
                        db.Entry(coll).State = EntityState.Modified;
                        db.SaveChanges();
                    }
                }
            }
            if (treeColl.SelectedItem.GetType() == typeof(CNode))
            {
                CNode      node       = treeColl.SelectedItem as CNode;
                NodeWindow nodeWindow = new NodeWindow(node);
                if (nodeWindow.ShowDialog() == true)
                {
                    coll = db.Collects.Find(nodeWindow._node.Id);
                    if (coll != null)
                    {
                        coll.Collect_name    = nodeWindow._node.Name;
                        db.Entry(coll).State = EntityState.Modified;
                        db.SaveChanges();
                    }
                }
            }
            GenerateTree();
        }
コード例 #3
0
        private void AddCategory_Click(object sender, RoutedEventArgs e)
        {
            CNode      node       = new CNode();
            NodeWindow nodeWindow = new NodeWindow(node);

            if (nodeWindow.ShowDialog() == true)
            {
                Collect coll = new Collect();
                coll.Collect_name = nodeWindow._node.Name;
                if (treeColl.SelectedItem.GetType() == typeof(CSheet))
                {
                    coll.Parent_id = (treeColl.SelectedItem as CSheet).ParentId;
                }
                else
                {
                    coll.Parent_id = (treeColl.SelectedItem as CNode).Id;
                }
                db.Collects.Add(coll);
                db.SaveChanges();
                GenerateTree();
            }
        }