private void AddTagNode(Tag tag) { foreach (TreeViewItem item in tagtree.Items) { var curtag = item.DataContext as TagGroup; if (curtag == tag.Group) { var subnode = new TreeViewItem(); subnode.Style = Application.Current.Resources["treelevel2_item"] as Style; subnode.DataContext = tag; item.Items.Add(subnode); } } }
public static void AddSampleData() { using (var dbcontext = new WarehouseContext()) { try { var user1 = new User() { Name = "二娃", Username = "******", Password = "******", IdentificationNumber = "310392198305114344", PhoneNumber = "13543776409", Company = "梁山", Department = "库房管理部", Memo = "(●'◡'●)" }; dbcontext.Users.Add(user1); var tg = new TagGroup() { Name = "功能" }; dbcontext.TagGroups.Add(tg); var tag1 = new Tag() { Name = "食品", Group = tg }; dbcontext.Tags.Add(tag1); var tag2 = new Tag() { Name = "书籍", Group = tg }; dbcontext.Tags.Add(tag2); var tag3 = new Tag() { Name = "酒水", Group = tg }; dbcontext.Tags.Add(tag3); var product = new Product() { Name = "乐事薯片100g(清新黄瓜)", ScanCode = "111" }; dbcontext.Products.Add(product); var good = new Goods() { GoodsCode = "111", InboundDate = DateTime.Now, Product = product, State = GoodsState.Inbounding }; dbcontext.Goods.Add(good); dbcontext.SaveChanges(); } catch { // do nothing } } using (var dbcontext = new WarehouseContext()) { var item = dbcontext.Goods.First(); } }
private void addtag_click(object sender, RoutedEventArgs e) { editmode = TagEditMode.AddTag; var tag = new Tag(); var selectedgroup = ((TreeViewItem)tagtree.SelectedItem).DataContext as TagGroup; tag.Group = selectedgroup; formgrid.DataContext = tag; ShowFormGrid(true); }
private void UpdateTag(Tag updatetag) { var findtag = DBContext.Tags.FirstOrDefault((t) => t.Name == updatetag.Name && t.State == StateCode.Active); if (findtag != null) { WindowMgr.SendNotification("标签不能重名", NotificationLevel.Warning); } else { DBContext.SaveChanges(); WindowMgr.SendNotification("成功更改标签", NotificationLevel.Information); ShowFormGrid(false); } }