/// <summary>
 /// Get all ItemMasterInventoryID
 /// </summary>
 /// <returns></returns>
 public IEnumerable <ItemMasterInventoryID> Get()
 {
     using (TestAssignmentEntities entities = new TestAssignmentEntities())
     {
         return(entities.ItemMasterInventoryIDs.ToList());
     }
 }
Beispiel #2
0
 /// <summary>
 /// Get all ItemMaster
 /// </summary>
 /// <returns></returns>
 public IEnumerable <ItemMaster> GetAllItemMasters()
 {
     using (TestAssignmentEntities entities = new TestAssignmentEntities())
     {
         return(entities.ItemMasters.ToList());
     }
 }
Beispiel #3
0
 public IEnumerable <ItemMaster> GetItemMasterLikeId(int id)
 {
     using (TestAssignmentEntities entities = new TestAssignmentEntities())
     {
         return(entities.ItemMasters.Where(i => i.ItemMasterID_PK.ToString().Contains(id.ToString())).ToList());
     }
 }
Beispiel #4
0
 /// <summary>
 /// Get Item Master By Id
 /// </summary>
 /// <param name="id"></param>
 /// <returns></returns>
 public ItemMaster GetItemMasterById(int id)
 {
     using (TestAssignmentEntities entities = new TestAssignmentEntities())
     {
         return(entities.ItemMasters.FirstOrDefault(i => i.ItemMasterID_PK == id));
     }
 }
Beispiel #5
0
        public string SaveItemMaster(ItemMaster objItemMaster)
        {
            try
            {
                string result = string.Empty;
                using (TestAssignmentEntities entities = new TestAssignmentEntities())
                {
                    int        itemMasterID_PK = objItemMaster.ItemMasterID_PK;
                    ItemMaster itemMaster      = entities.ItemMasters.Find(itemMasterID_PK);
                    if (itemMaster != null)
                    {
                        itemMaster.IMPack                = objItemMaster.IMPack;
                        itemMaster.IMDescription         = objItemMaster.IMDescription;
                        itemMaster.IMImageData           = objItemMaster.IMImageData;
                        itemMaster.IMIsHazardousMaterial = objItemMaster.IMIsHazardousMaterial;
                        itemMaster.MExpirationDate       = objItemMaster.MExpirationDate;
                        itemMaster.IMUnitPrice           = objItemMaster.IMUnitPrice;
                        itemMaster.IMWidth               = objItemMaster.IMWidth;
                        itemMaster.IMLength              = objItemMaster.IMLength;
                        itemMaster.IMHeight              = objItemMaster.IMHeight;
                        itemMaster.IMIsPrePack           = objItemMaster.IMIsPrePack;

                        itemMaster.IMPrePackStyle   = objItemMaster.IMPrePackStyle;
                        itemMaster.IMCostCenterCode = objItemMaster.IMCostCenterCode;
                        result = "Update ItemMaster Successfully";
                    }
                    else
                    {
                        ItemMaster newItemMaster = new ItemMaster();
                        newItemMaster.ItemMasterID_PK       = objItemMaster.ItemMasterID_PK;
                        newItemMaster.IMPack                = objItemMaster.IMPack;
                        newItemMaster.IMDescription         = objItemMaster.IMDescription;
                        newItemMaster.IMImageData           = objItemMaster.IMImageData;
                        newItemMaster.IMIsHazardousMaterial = objItemMaster.IMIsHazardousMaterial;
                        newItemMaster.MExpirationDate       = objItemMaster.MExpirationDate;
                        newItemMaster.IMUnitPrice           = objItemMaster.IMUnitPrice;
                        newItemMaster.IMWidth               = objItemMaster.IMWidth;
                        newItemMaster.IMHeight              = objItemMaster.IMHeight;
                        newItemMaster.IMIsPrePack           = objItemMaster.IMIsPrePack;
                        newItemMaster.IMPrePackStyle        = objItemMaster.IMPrePackStyle;
                        newItemMaster.IMCostCenterCode      = objItemMaster.IMCostCenterCode;

                        entities.ItemMasters.Add(newItemMaster);
                        result = "Intert new ItemMaster Successfully";
                    }
                    entities.SaveChanges();
                    return(result);
                }
            }
            catch (Exception)
            {
                return("Error when create Master Item. Please help to check input!");
            }
        }
        /// <summary>
        /// Get all ItemMasterInventoryID by id
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        public IEnumerable <Inventory> Get(int id)
        {
            using (TestAssignmentEntities entities = new TestAssignmentEntities())
            {
                List <Inventory> listInventory = new List <Inventory>();

                var queryInventory = from itemMasterInventory in entities.ItemMasterInventoryIDs.AsQueryable()
                                     join itemMaster in entities.ItemMasters on itemMasterInventory.IMIItemMasterID_FK equals itemMaster.ItemMasterID_PK
                                     join location in entities.Locations on itemMasterInventory.ItemLocationID_FK equals location.ItemLocationID_PK
                                     where itemMasterInventory.IMIItemMasterID_FK == id
                                     select new Inventory
                {
                    Location      = location.Location1,
                    OnHand        = itemMasterInventory.IMIQtyOnHand ?? 0,
                    OnHandPcs     = itemMasterInventory.IMIQtyOnHand * itemMaster.IMPack ?? 0,
                    Allocated     = itemMasterInventory.IMIQtyAllocated ?? 0,
                    AllocationPcs = itemMasterInventory.IMIQtyAllocated * itemMaster.IMPack ?? 0,
                    Available     = (itemMasterInventory.IMIQtyOnHand - itemMasterInventory.IMIQtyAllocated) ?? 0,
                    AvailablePcs  = ((itemMasterInventory.IMIQtyOnHand - itemMasterInventory.IMIQtyAllocated) * itemMaster.IMPack) ?? 0
                };
                return(queryInventory.ToList <Inventory>());
            }
        }