void Synchronizer_SyncItemCategoryChangeEvent(BaseAppServerCom.Models.Category rcat, Configuration.Sync.SyncType e) { if (e == Configuration.Sync.SyncType.Add) { try { //TODO: // verify string lenghts POS_ItemCategory lcat = new POS_ItemCategory { CatID = rcat.id, vCategoryCode = rcat.slug, vCategoryDesc = rcat.description, vCategoryShortDesc = rcat.name }; GConfig.POS_Setup.ItemCategories.Add(lcat); //GConfig.DAL.StateChange(GConfig.POS_Setup, System.Data.Entity.EntityState.Modified) GConfig.DAL.SaveChanges(); if (lcat.vCategoryCode != "all-items") { if (Register.CategoriesInitialized) { var cat = GConfig.POS_Setup.ItemCategories.FirstOrDefault(n => n.CatID == lcat.CatID); if (cat != null) { Application.Current.Dispatcher.BeginInvoke(new Action(() => { Register.Categories.Add(new CategoryVM(cat, Register)); })); } } } } catch (Exception ex) { //var error= ((System.Data.Entity.Validation.DbEntityValidationException)ex).EntityValidationErrors; var m = ex; } } }
private void AddCustomItem(decimal price, int quantity, string customitemname) { var cat = GConfig.POS_Setup.ItemCategories.FirstOrDefault(n => n.vCategoryCode == "custom-cat"); var catAll = GConfig.POS_Setup.ItemCategories.FirstOrDefault(n => n.vCategoryCode != "custom-cat"); if (cat == null) { DateTime date = DateTime.Now; var item = new POS_ItemMaster() { vItemDesc1 = "Custom Item", dStartDate = date, dEndDate = date }; //added var to give editable custom item name SAA. cat = new POS_ItemCategory { vCategoryCode = "custom-cat", vStatus = "hidden", vCategoryShortDesc = "Custom", dEndDt = date, dStartDt = date, POS_ItemMasters = new List <POS_ItemMaster> { item } }; GConfig.POS_Setup.ItemCategories.Add(cat); GConfig.DAL.SaveChanges(); } var customitem = cat.POS_ItemMasters.FirstOrDefault(); //Get Normal Custom Item //Below code is for custom items can take user defined item description. //Added 5/6/16 // if (customitemname != null && customitemname.Trim() != "") { var customitemSpecial = cat.POS_ItemMasters.Where(n => n.vItemDesc1 == customitemname); //Check if custom name entered is in itemMaster if (customitemSpecial.Count() == 0 && customitem.vItemDesc1 != customitemname) { Int32 customitemid = cat.POS_ItemMasters.Max(p => p.itemID); //get max itemid of custom items. Int32 ItemMasterid = catAll.POS_ItemMasters.Max(p => p.Id); //get max of id from itemMaster. ItemMasterid++; if (customitemid == 0) { customitemid = 9000; } else { customitemid++; } if (customitem.vItemDesc1 != customitemname) { DateTime date = DateTime.Now; var item = new POS_ItemMaster() { Id = ItemMasterid, itemID = customitemid, vItemStatus = "hidden", vItemDesc1 = customitemname, dStartDate = date, dEndDate = date }; //added var to give editable custom item name SAA. cat.POS_ItemMasters.Add(item); GConfig.DAL.SaveChanges(); customitem = item; } } if (customitemSpecial != null) { customitem = customitemSpecial.FirstOrDefault(); } } //Above code is for custom items can take user defined item description. //Added 5/6/16 if (customitem != null) { OrderLineVM line = new OrderLineVM(customitem, Order, new POS_OrderDetails() { POS_OrderHeaderId = Order._orderHeader.Id, POS_ItemMasterId = customitem.Id, fLineItemPrice = price, fOrderQty = quantity, fLineSubTotal = price * quantity }) { ItemCreated = true }; Order.OrderLines.Add(line); Order.RefreshValues(); _scroll.ScrollToBottom(); } }
public CategoryVM(POS_ItemCategory category, Register parent) { _parent = parent; _category = category; }