Example #1
0
        public List <SysChemicalItem> GetChemicalItemWithStock(byte _RequisitionFrom, byte _RequisitionTo)
        {
            var FinalStock = DalChemicalStock.ItemWiseStockInSpecificChemicalStore(_RequisitionTo);

            var FinalStockProductionFloor = DalChemicalStock.ItemWiseStockInSpecificProductionFloor(_RequisitionFrom);

            var Data = (from c in _context.Sys_ChemicalItem.AsEnumerable()
                        where c.IsActive == true

                        join fs in FinalStock on c.ItemID equals fs.ItemID into FinalStocks
                        from fs in FinalStocks.DefaultIfEmpty()

                        join ps in FinalStockProductionFloor on c.ItemID equals ps.ItemID into ProductionStock
                        from ps in ProductionStock.DefaultIfEmpty()

                        join it in _context.Sys_ItemType on c.ItemTypeID equals it.ItemTypeID into Items
                        from it2 in Items.DefaultIfEmpty()

                        orderby c.ItemName
                        select new SysChemicalItem
            {
                ItemID = c.ItemID,
                ItemName = c.ItemName,
                ItemCategory = DalCommon.ReturnChemicalItemCategory(c.ItemCategory),
                ItemTypeID = c.ItemTypeID,
                ItemTypeName = (it2 == null ? null : it2.ItemTypeName),
                StockQty = (fs == null ? 0 : fs.ClosingQty),
                SafetyStock = ps == null ? 0 : Convert.ToInt32(ps.ClosingQty)             //Actually Production Stock
            }).ToList();

            return(Data);
        }
Example #2
0
        // For Recipe LOV
        public List <PRDChemProdReqItem> GetRecipeItemListForFixedRecipe(int _RecipeID, byte _RequisitionTo, byte _RequisitionFrom)
        {
            try
            {
                var FinalStock = DalChemicalStock.ItemWiseStockInSpecificChemicalStore(_RequisitionTo);

                var FinalStockProductionFloor = DalChemicalStock.ItemWiseStockInSpecificProductionFloor(_RequisitionFrom);

                if (FinalStock != null)
                {
                    var Data = (from s in _context.PRD_RecipeItem.AsEnumerable()
                                where s.RecipeID == _RecipeID
                                from i in _context.Sys_ChemicalItem.Where(x => x.ItemID == s.ItemID).DefaultIfEmpty()

                                from u in _context.Sys_Unit.Where(x => x.UnitID == s.UnitID).DefaultIfEmpty()

                                join st in FinalStock on i.ItemID equals st.ItemID into badhon
                                from item in badhon.DefaultIfEmpty()
                                join sup in _context.Sys_Supplier on(item == null ? 0 : item.SupplierID) equals sup.SupplierID into badhon2
                                from finalitem in badhon2.DefaultIfEmpty()

                                join ps in FinalStockProductionFloor on i.ItemID equals ps.ItemID into ProductionStock
                                from ps in ProductionStock.DefaultIfEmpty()

                                select new PRDChemProdReqItem
                    {
                        ItemID = s.ItemID,
                        ItemName = (i == null ? null : i.ItemName),
                        RequiredQty = s.RequiredQty,
                        RequiredUnit = s.UnitID,
                        RequiredUnitName = (u == null ? null : u.UnitName),
                        RequsitionQty = s.RequiredQty,
                        ApproveQty = s.RequiredQty,
                        ApproveUnit = s.UnitID,
                        ApproveUnitName = (u == null ? null : u.UnitName),
                        PackSizeName = "",
                        PackQty = 0,
                        SizeUnitName = "",
                        RequisitionUnit = s.UnitID,
                        RequisitionUnitName = (u == null ? null : u.UnitName),

                        StockQty = (item == null ? 0 : item.ClosingQty),
                        //StockUnitName = (su == null ? null : su.UnitName),
                        ProductionStock = (ps == null? "0": ps.ClosingQty.ToString()),
                        SupplierID = (finalitem == null ? 0 : finalitem.SupplierID),
                        SupplierName = (finalitem == null ? null : finalitem.SupplierName),

                        ItemSource = "Via Requisition"
                    }).ToList();

                    return(Data);
                }

                else
                {
                    var Data = (from s in _context.PRD_RecipeItem.AsEnumerable()
                                where s.RecipeID == _RecipeID
                                from i in _context.Sys_ChemicalItem.Where(x => x.ItemID == s.ItemID).DefaultIfEmpty()
                                from u in _context.Sys_Unit.Where(x => x.UnitID == s.UnitID).DefaultIfEmpty()

                                join ps in FinalStockProductionFloor on i.ItemID equals ps.ItemID into ProductionStock
                                from ps in ProductionStock.DefaultIfEmpty()

                                select new PRDChemProdReqItem
                    {
                        ItemID = s.ItemID,
                        ItemName = (i == null ? null : i.ItemName),
                        RequiredQty = s.RequiredQty,
                        RequiredUnit = s.UnitID,
                        RequiredUnitName = (u == null ? null : u.UnitName),
                        ProductionStock = (ps == null ? "0" : ps.ClosingQty.ToString()),
                        RequsitionQty = s.RequiredQty,
                        ApproveQty = s.RequiredQty,
                        ApproveUnit = s.UnitID,
                        ApproveUnitName = (u == null ? null : u.UnitName),
                        PackSizeName = "",
                        PackQty = 0,
                        SizeUnitName = "",
                        RequisitionUnit = s.UnitID,
                        RequisitionUnitName = (u == null ? null : u.UnitName),
                        StockQty = 0,
                        ItemSource = "Via Requisition"
                    }).ToList();
                    return(Data);
                }
            }
            catch (Exception e)
            {
                return(null);
            }
        }