private void AddTagGroupNode(TagGroup tg) { var node = new TreeViewItem(); node.Style = Application.Current.Resources["treelevel1_item"] as Style; node.DataContext = tg; tagtree.Items.Add(node); }
private void addtaggroup_click(object sender, RoutedEventArgs e) { editmode = TagEditMode.AddTagGroup; var taggroup = new TagGroup(); formgrid.DataContext = taggroup; ShowFormGrid(true); }
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 UpdateTagGroup(TagGroup updatetg) { var findtg = DBContext.TagGroups.FirstOrDefault((g) => g.Name == updatetg.Name && g.State == StateCode.Active); if (findtg != null) { WindowMgr.SendNotification("标签组不能重名", NotificationLevel.Warning); } else { try { DBContext.SaveChanges(); WindowMgr.SendNotification("成功更改标签组", NotificationLevel.Information); ShowFormGrid(false); } catch (Exception ex) { // TODO WindowMgr.SendNotification("操作失败", NotificationLevel.Error); } } }