public Boolean DeleteInventoryAssociation(Int32 id) { ItemInventoryAssociation item = new ItemInventoryAssociation(); try { using (menuzRusDataContext db = new menuzRusDataContext(base.connectionString)) { item = db.ItemInventoryAssociations.Where(m => m.id == id).FirstOrDefault(); if (item != default(ItemInventoryAssociation)) { db.ItemInventoryAssociations.DeleteOnSubmit(item); db.SubmitChanges(); } } } catch (Exception ex) { return false; } return true; }
public Boolean AddInventoryRegistry(ItemInventoryAssociation association, ChecksMenu checkMenu) { String comment; Int32 associatedItemId; Common.InventoryType type; Decimal quantity; try { comment = String.Format("Taken [{0}] from: [{1}]. Check# {2}", association.Quantity, association.Item.Name, checkMenu.CheckId); associatedItemId = association.AssociatedItemId; type = Common.InventoryType.Out; ; quantity = Math.Abs(association.Quantity) * -1; AddItemRegistry(associatedItemId, quantity, type, comment); AddInventoryRegistryCheckMenu(associatedItemId, checkMenu.id); } catch (Exception ex) { return false; } return true; }
public Boolean DeleteInventoryRegistry(ItemInventoryAssociation association, ChecksMenu checkMenu, String name) { String comment; Int32 associatedItemId; Common.InventoryType type; Decimal quantity; try { comment = String.Format("Added [{0}] of [{1}] for: [{2}]. Check# {3}", association.Quantity, name, association.Item.Name, checkMenu.CheckId); associatedItemId = association.AssociatedItemId; type = Common.InventoryType.In; ; quantity = Math.Abs(association.Quantity); AddItemRegistry(associatedItemId, quantity, type, comment); AddInventoryRegistryCheckMenu(associatedItemId, checkMenu.id); } catch (Exception ex) { return false; } return true; }
partial void DeleteItemInventoryAssociation(ItemInventoryAssociation instance);
partial void UpdateItemInventoryAssociation(ItemInventoryAssociation instance);
partial void InsertItemInventoryAssociation(ItemInventoryAssociation instance);
private void detach_ItemInventoryAssociations(ItemInventoryAssociation entity) { this.SendPropertyChanging(); entity.Item = null; }
private InventoryModel SetModel(String model) { JavaScriptSerializer objJavascript = new JavaScriptSerializer(); Char[] commaDelimiter = new char[] { ',' }; Char[] colonDelimiter = new char[] { ':' }; if (SessionData.item != null) { InventoryModel inventoryModel = new InventoryModel(); Array associations = (Array)objJavascript.DeserializeObject(model); inventoryModel.ItemInventoryAssociations = new List<ItemInventoryAssociation>(); foreach (String association in associations) { Array values = association.Split(commaDelimiter, StringSplitOptions.RemoveEmptyEntries); ItemInventoryAssociation itemInventoryAssociation = new ItemInventoryAssociation(); foreach (String value in values) { Array vars = value.Split(colonDelimiter, StringSplitOptions.RemoveEmptyEntries); itemInventoryAssociation.id = Int32.Parse(vars.GetValue(0).ToString()); ; itemInventoryAssociation.AssociatedItemId = Int32.Parse(vars.GetValue(1).ToString()); itemInventoryAssociation.Quantity = Decimal.Parse(vars.GetValue(2).ToString()); itemInventoryAssociation.ItemInventoryId = SessionData.item.id; } inventoryModel.ItemInventoryAssociations.Add(itemInventoryAssociation); } return inventoryModel; } return null; }
public Boolean SaveInventoryAssociation(ItemInventoryAssociation item) { ItemInventoryAssociation itemQuery = new ItemInventoryAssociation(); try { using (menuzRusDataContext db = new menuzRusDataContext(base.connectionString)) { if (item.id != 0) { itemQuery = db.ItemInventoryAssociations.Where(m => m.id == item.id).FirstOrDefault(); } if (itemQuery != default(ItemInventoryAssociation)) { itemQuery.ItemInventoryId = item.ItemInventoryId; itemQuery.AssociatedItemId = item.AssociatedItemId; itemQuery.Quantity = item.Quantity; } if (item.id == 0) { db.ItemInventoryAssociations.InsertOnSubmit(itemQuery); } db.SubmitChanges(); } } catch (Exception ex) { return false; } return true; }