Ejemplo n.º 1
0
        public PRDChemProdReq GetRequisitionDetailsAfterSearch(int _RequisitionID)
        {
            var model = new PRDChemProdReq();


            var RequisitionInfo = (from r in _context.PRD_ChemProdReq.AsEnumerable()
                                   where r.RequisitionID == _RequisitionID

                                   join re in _context.PRD_Recipe on(r == null?null:r.RecipeID) equals re.RecipeID into Recepies
                                   from re in Recepies.DefaultIfEmpty()

                                   join c in _context.Sys_Color on(re == null? null: re.ArticleColor) equals c.ColorID into Colors
                                   from c in Colors.DefaultIfEmpty()

                                   join u in _context.Sys_Unit on(re == null ? 0 : re.BaseUnit) equals u.UnitID into Units
                                   from u in Units.DefaultIfEmpty()

                                   select new PRDChemProdReq
            {
                RequisitionID = r.RequisitionID,
                RequisitionNo = r.RequisitionNo,
                RequisitionCategory = r.RequisitionCategory,
                RequisitionType = r.RequisitionType,
                ReqRaisedOn = (Convert.ToDateTime(r.ReqRaisedOn)).ToString("dd'/'MM'/'yyyy"),
                RequiredByTime = (r.RequiredByTime == 0? null: r.RequiredByTime),
                ReqRaisedBy = (r.ReqRaisedBy),
                RequisitionFrom = r.RequisitionFrom,
                RequisitionTo = r.RequisitionTo,
                RecipeFor = (r.RecipeFor),
                RecipeID = (r.RecipeID),
                ArticleNo = r.ArticleNo,
                ArticleName = (re == null? null: re.ArticleName),
                ArticleChallanNo = (re == null ? null : re.ArticleChallanNo),
                ArticleColor = (re == null ? null : re.ArticleColor),
                ArticleColorName = (c == null ? null : c.ColorName),
                BaseQuantity = (re == null ? null : (re.BaseQuantity).ToString()),
                //BaseUnit = (re == null ? null : re.BaseUnit),
                BaseUnitName = (u == null ? null : u.UnitName),
                LeatherSize = r.LeatherSize,
                SizeUnit = (r.SizeUnit),
                Selection = r.Selection,
                Thickness = r.Thickness,
                ThicknessUnit = (r.ThicknessUnit),
                ProductionQty = (r.ProductionQty == 0 ? null : r.ProductionQty),
                ProductionQuantityUnit = (u == null ? null : u.UnitName),
                RecordStatus = r.RecordStatus
            }).FirstOrDefault();

            model.RequisitionInfo = RequisitionInfo;

            model.RequisitionItemList = GetRequisitionItemList(_RequisitionID, RequisitionInfo.RequisitionTo);

            return(model);
        }
        public ValidationMsg Save(PRDChemProdReq model, int userId, string pageUrl)
        {
            var transactionOption = new TransactionOptions {
                Timeout = new TimeSpan(0, 0, 99999)
            };
            var vMsg = new ValidationMsg();


            using (var transactionScope = new TransactionScope(TransactionScopeOption.RequiresNew, transactionOption))
            {
                try
                {
                    _dalProductionRequisition = new DalProductionRequisition();

                    RequisitionID = _dalProductionRequisition.Save(model, userId, pageUrl);

                    //GetpurchaseID(purchaseID);

                    if (RequisitionID > 0)
                    {
                        transactionScope.Complete();

                        vMsg.Type = Enums.MessageType.Success;
                        vMsg.Msg  = "Saved successfully.";
                        //vMsg.ReturnId = _dalChemicalForeignPurchaseOrder.GetOrderNo(OrderID);
                    }
                    else
                    {
                        vMsg.Type = Enums.MessageType.Error;
                        vMsg.Msg  = "Failed to save.";
                    }
                }

                catch (Exception e)
                {
                    vMsg.Type = Enums.MessageType.Error;
                    vMsg.Msg  = "Failed to save.";
                }
            }



            return(vMsg);
        }
Ejemplo n.º 3
0
        public ActionResult ProductionRequisition(PRDChemProdReq model)
        {
            if (model.RequisitionID == 0)
            {
                //Convert.ToInt32(Session["UserID"])
                var msg                 = objBLL.Save(model, 1, "ProductionRequisition/ProductionRequisition");
                var RequisitionID       = objBLL.GetRequisitionID();
                var RequisitionNo       = objDal.GetRequisitionNo(RequisitionID);
                var RequisitionTo       = objDal.GetRequisitionToInfo(RequisitionID);
                var RequisitionItemList = objDal.GetRequisitionItemList(RequisitionID, RequisitionTo);
                return(Json(new { Msg = msg, RequisitionID = RequisitionID, RequisitionNo = RequisitionNo, RequisitionItemList = RequisitionItemList }, JsonRequestBehavior.AllowGet));
            }
            else
            {
                var msg                 = objBLL.Update(model, 1);
                var RequisitionTo       = objDal.GetRequisitionToInfo(model.RequisitionID);
                var RequisitionItemList = objDal.GetRequisitionItemList(model.RequisitionID, RequisitionTo);

                return(Json(new { Msg = msg, RequisitionItemList = RequisitionItemList }, JsonRequestBehavior.AllowGet));
            }
        }
        public ValidationMsg Update(PRDChemProdReq model, int userId)
        {
            var transactionOption = new TransactionOptions {
                Timeout = new TimeSpan(0, 0, 9999)
            };
            var vMsg = new ValidationMsg();

            using (var transactionScope = new TransactionScope(TransactionScopeOption.RequiresNew, transactionOption))
            {
                try
                {
                    _dalProductionRequisition = new DalProductionRequisition();

                    var UpdateStatus = _dalProductionRequisition.Update(model, userId);

                    if (UpdateStatus > 0)
                    {
                        transactionScope.Complete();

                        vMsg.Type = Enums.MessageType.Update;
                        vMsg.Msg  = "Updated successfully.";
                    }
                    else
                    {
                        vMsg.Type = Enums.MessageType.Error;
                        vMsg.Msg  = "Failed to Update.";
                    }
                }

                catch (Exception)
                {
                    vMsg.Type = Enums.MessageType.Error;
                    vMsg.Msg  = "Failed to Update.";
                }
            }
            return(vMsg);
        }
Ejemplo n.º 5
0
        public int Update(PRDChemProdReq model, int userId)
        {
            try
            {
                using (TransactionScope transaction = new TransactionScope())
                {
                    using (_context)
                    {
                        #region PI_Informaiton_Update
                        var CurrentRequisition = (from p in _context.PRD_ChemProdReq.AsEnumerable()
                                                  where p.RequisitionID == model.RequisitionID
                                                  select p).FirstOrDefault();

                        CurrentRequisition.RequisitionCategory = model.RequisitionCategory;
                        CurrentRequisition.RequisitionType     = model.RequisitionType;
                        CurrentRequisition.RequisitionFrom     = model.RequisitionFrom;
                        CurrentRequisition.RequisitionTo       = model.RequisitionTo;
                        CurrentRequisition.RequiredByTime      = model.RequiredByTime;
                        CurrentRequisition.ReqRaisedBy         = 1;
                        CurrentRequisition.ReqRaisedOn         = DalCommon.SetDate((model.ReqRaisedOn).ToString());

                        if (model.RecipeFor == 0)
                        {
                            CurrentRequisition.RecipeFor = null;
                        }
                        else
                        {
                            CurrentRequisition.RecipeFor = model.RecipeFor;
                        }
                        if (model.RecipeID == 0)
                        {
                            CurrentRequisition.RecipeID = null;
                        }
                        else
                        {
                            CurrentRequisition.RecipeID = model.RecipeID;
                        }

                        //CurrentRequisition.RecipeFor = model.RecipeFor;
                        //CurrentRequisition.RecipeID = model.RecipeID;
                        CurrentRequisition.ArticleNo = model.ArticleNo;

                        CurrentRequisition.Thickness = model.Thickness;
                        if (model.ThicknessUnit != null)
                        {
                            CurrentRequisition.ThicknessUnit = model.ThicknessUnit;
                        }
                        CurrentRequisition.LeatherSize = model.LeatherSize;
                        if (model.SizeUnit != null)
                        {
                            CurrentRequisition.SizeUnit = model.SizeUnit;
                        }
                        CurrentRequisition.Selection     = model.Selection;
                        CurrentRequisition.ProductionQty = model.ProductionQty;
                        CurrentRequisition.ModifiedBy    = userId;
                        CurrentRequisition.ModifiedOn    = DateTime.Now;

                        _context.SaveChanges();
                        #endregion

                        #region Update Requisition ItemList
                        if (model.RequisitionItemList != null)
                        {
                            foreach (var item in model.RequisitionItemList)
                            {
                                var checkRequisitionItem = (from i in _context.PRD_ChemProdReqItem.AsEnumerable()
                                                            where i.RequisitionItemID == item.RequisitionItemID
                                                            select i).Any();

                                #region New_Requisition_Insertion
                                if (!checkRequisitionItem)
                                {
                                    PRD_ChemProdReqItem objItem = new PRD_ChemProdReqItem();
                                    objItem.RequisitionID = model.RequisitionID;
                                    objItem.ItemID        = Convert.ToInt32(item.ItemID);

                                    if (item.SupplierID == 0)
                                    {
                                        objItem.SupplierID = null;
                                    }
                                    else
                                    {
                                        objItem.SupplierID = item.SupplierID;
                                    }

                                    objItem.RequiredQty = item.RequiredQty;


                                    if (item.RequiredUnitName == null)
                                    {
                                        objItem.RequiredUnit = null;
                                    }
                                    else
                                    {
                                        objItem.RequiredUnit = DalCommon.GetUnitCode(item.RequiredUnitName);
                                    }

                                    objItem.RequsitionQty   = Convert.ToDecimal(item.RequsitionQty);
                                    objItem.RequisitionUnit = DalCommon.GetUnitCode(item.RequisitionUnitName);

                                    if (item.PackSizeName == null)
                                    {
                                        objItem.PackSize = null;
                                    }
                                    else
                                    {
                                        objItem.PackSize = DalCommon.GetSizeCode(item.PackSizeName);
                                    }

                                    //objItem.PackSize = DalCommon.GetSizeCode(item.PackSizeName);

                                    if (item.SizeUnitName == null)
                                    {
                                        objItem.SizeUnit = null;
                                    }
                                    else
                                    {
                                        objItem.SizeUnit = DalCommon.GetUnitCode(item.SizeUnitName);
                                    }


                                    objItem.PackQty     = item.PackQty;
                                    objItem.ApproveQty  = item.ApproveQty;
                                    objItem.ApproveUnit = DalCommon.GetUnitCode(item.ApproveUnitName);
                                    //objItem.ManufacturerID = item.ManufacturerID;
                                    objItem.ItemSource = DalCommon.ReturnItemSource(item.ItemSource);
                                    objItem.SetOn      = DateTime.Now;
                                    objItem.SetBy      = userId;

                                    _context.PRD_ChemProdReqItem.Add(objItem);
                                    _context.SaveChanges();
                                }
                                #endregion

                                #region Existing_Requisition_Update
                                else
                                {
                                    var FoundRequisition = (from i in _context.PRD_ChemProdReqItem.AsEnumerable()
                                                            where i.RequisitionItemID == item.RequisitionItemID
                                                            select i).FirstOrDefault();

                                    FoundRequisition.RequisitionID = model.RequisitionID;
                                    FoundRequisition.ItemID        = Convert.ToInt32(item.ItemID);

                                    if (item.SupplierID == 0)
                                    {
                                        FoundRequisition.SupplierID = null;
                                    }
                                    else
                                    {
                                        FoundRequisition.SupplierID = item.SupplierID;
                                    }

                                    FoundRequisition.RequiredQty = item.RequiredQty;

                                    if (item.RequiredUnitName == null)
                                    {
                                        FoundRequisition.RequiredUnit = null;
                                    }
                                    else
                                    {
                                        FoundRequisition.RequiredUnit = DalCommon.GetUnitCode(item.RequiredUnitName);
                                    }

                                    FoundRequisition.RequsitionQty   = Convert.ToDecimal(item.RequsitionQty);
                                    FoundRequisition.RequisitionUnit = DalCommon.GetUnitCode(item.RequisitionUnitName);
                                    if (item.PackSizeName == null)
                                    {
                                        FoundRequisition.PackSize = null;
                                    }
                                    else
                                    {
                                        FoundRequisition.PackSize = DalCommon.GetSizeCode(item.PackSizeName);
                                    }

                                    //objItem.PackSize = DalCommon.GetSizeCode(item.PackSizeName);

                                    if (item.SizeUnitName == null)
                                    {
                                        FoundRequisition.SizeUnit = null;
                                    }
                                    else
                                    {
                                        FoundRequisition.SizeUnit = DalCommon.GetUnitCode(item.SizeUnitName);
                                    }
                                    FoundRequisition.PackQty     = item.PackQty;
                                    FoundRequisition.ApproveQty  = item.ApproveQty;
                                    FoundRequisition.ApproveUnit = DalCommon.GetUnitCode(item.ApproveUnitName);
                                    FoundRequisition.ItemSource  = DalCommon.ReturnItemSource(item.ItemSource);
                                    FoundRequisition.ModifiedOn  = DateTime.Now;
                                    FoundRequisition.ModifiedBy  = userId;

                                    _context.SaveChanges();
                                }
                                #endregion
                            }
                        }

                        #endregion
                    }

                    transaction.Complete();
                }
                return(1);
            }
            catch (Exception e)
            {
                return(0);
            }
        }
Ejemplo n.º 6
0
        public int Save(PRDChemProdReq model, int userId, string pageUrl)
        {
            int CurrentRequisitionID = 0;

            try
            {
                using (TransactionScope transaction = new TransactionScope())
                {
                    using (_context)
                    {
                        var GetRequisitionNo = DalCommon.GetPreDefineNextCodeByUrl(pageUrl);

                        if (GetRequisitionNo != null)
                        {
                            #region New_Requisition_Insert

                            PRD_ChemProdReq objRequisition = new PRD_ChemProdReq();

                            objRequisition.RequisitionNo       = GetRequisitionNo;
                            objRequisition.RequisitionCategory = model.RequisitionCategory;
                            objRequisition.RequisitionType     = model.RequisitionType;
                            objRequisition.RequisitionFrom     = model.RequisitionFrom;
                            objRequisition.RequisitionTo       = model.RequisitionTo;
                            objRequisition.RequiredByTime      = model.RequiredByTime;
                            objRequisition.ReqRaisedBy         = userId;
                            objRequisition.ReqRaisedOn         = DalCommon.SetDate((model.ReqRaisedOn).ToString());
                            if (model.RecipeFor == 0)
                            {
                                objRequisition.RecipeFor = null;
                            }
                            else
                            {
                                objRequisition.RecipeFor = model.RecipeFor;
                            }
                            if (model.RecipeID == 0)
                            {
                                objRequisition.RecipeID = null;
                            }
                            else
                            {
                                objRequisition.RecipeID = model.RecipeID;
                            }
                            objRequisition.ArticleNo = model.ArticleNo;

                            objRequisition.Thickness = model.Thickness;
                            if (model.ThicknessUnit != null)
                            {
                                objRequisition.ThicknessUnit = model.ThicknessUnit;
                            }
                            objRequisition.LeatherSize = model.LeatherSize;
                            if (model.SizeUnit != null)
                            {
                                objRequisition.SizeUnit = model.SizeUnit;
                            }
                            objRequisition.Selection     = model.Selection;
                            objRequisition.ProductionQty = model.ProductionQty;

                            objRequisition.RequisitionState  = "RNG";
                            objRequisition.RequisitionStatus = "PND";
                            objRequisition.RecordStatus      = "NCF";
                            objRequisition.SetBy             = userId;
                            objRequisition.SetOn             = DateTime.Now;



                            //if (model.BuyerAddressID == 0)
                            //    objPI.BeneficiaryAddressID = null;
                            //else
                            //    objPI.BeneficiaryAddressID = model.BuyerAddressID;

                            _context.PRD_ChemProdReq.Add(objRequisition);
                            _context.SaveChanges();
                            CurrentRequisitionID = objRequisition.RequisitionID;
                            #endregion

                            #region Item Insert
                            if (model.RequisitionItemList != null)
                            {
                                foreach (var item in model.RequisitionItemList)
                                {
                                    PRD_ChemProdReqItem objItem = new PRD_ChemProdReqItem();
                                    objItem.RequisitionID = CurrentRequisitionID;
                                    objItem.ItemID        = Convert.ToInt32(item.ItemID);

                                    if (item.SupplierID == 0)
                                    {
                                        objItem.SupplierID = null;
                                    }
                                    else
                                    {
                                        objItem.SupplierID = item.SupplierID;
                                    }
                                    //objItem.SupplierID = item.SupplierID;

                                    objItem.RequiredQty = item.RequiredQty;


                                    if (item.RequiredUnitName == null)
                                    {
                                        objItem.RequiredUnit = null;
                                    }
                                    else
                                    {
                                        objItem.RequiredUnit = DalCommon.GetUnitCode(item.RequiredUnitName);
                                    }


                                    objItem.RequsitionQty   = Convert.ToDecimal(item.RequsitionQty);
                                    objItem.RequisitionUnit = DalCommon.GetUnitCode(item.RequisitionUnitName);

                                    if (item.PackSizeName == null)
                                    {
                                        objItem.PackSize = null;
                                    }
                                    else
                                    {
                                        objItem.PackSize = DalCommon.GetSizeCode(item.PackSizeName);
                                    }

                                    //objItem.PackSize = DalCommon.GetSizeCode(item.PackSizeName);

                                    if (item.SizeUnitName == null)
                                    {
                                        objItem.SizeUnit = null;
                                    }
                                    else
                                    {
                                        objItem.SizeUnit = DalCommon.GetUnitCode(item.SizeUnitName);
                                    }
                                    //objItem.SizeUnit = DalCommon.GetUnitCode(item.SizeUnitName);


                                    objItem.PackQty     = item.PackQty;
                                    objItem.ApproveQty  = item.ApproveQty;
                                    objItem.ApproveUnit = DalCommon.GetUnitCode(item.ApproveUnitName);
                                    //objItem.ManufacturerID = item.ManufacturerID;
                                    objItem.ItemSource = DalCommon.ReturnItemSource(item.ItemSource);
                                    objItem.SetOn      = DateTime.Now;
                                    objItem.SetBy      = userId;

                                    _context.PRD_ChemProdReqItem.Add(objItem);
                                    _context.SaveChanges();
                                }
                            }
                            #endregion
                        }
                    }
                    transaction.Complete();
                }
                return(CurrentRequisitionID);
            }
            catch (Exception e)
            {
                return(0);
            }
        }
Ejemplo n.º 7
0
        // After Requisition LOV
        public PRDChemProdReq GetRequisitionDetailsFromFixedStore(int _RequisitionID, byte _RequisitionAt)
        {
            var FinalStock = DalChemicalStock.ItemWiseStockInSpecificChemicalStore(_RequisitionAt);

            var model = new PRDChemProdReq();

            var RequisitionInfo = (from r in _context.PRD_ChemProdReq.AsEnumerable()
                                   where r.RequisitionID == _RequisitionID

                                   from u in _context.Users.Where(x => x.UserID == r.ReqRaisedBy).DefaultIfEmpty()

                                   select new PRDChemProdReq
            {
                RequisitionID = r.RequisitionID,
                RequisitionNo = r.RequisitionNo,
                JobOrderID = Convert.ToInt16(r.JobOrderID),
                JobOrderNo = r.JobOrderNo,
                ReqRaisedOn = (Convert.ToDateTime(r.ReqRaisedOn)).ToString("dd'/'MM'/'yyyy"),
                ReqRaisedBy = Convert.ToInt16(r.ReqRaisedBy),
                ReqRaisedByName = (u == null ? null : (u.FirstName + " " + u.MiddleName + " " + u.LastName)),
                RequiredByTime = Convert.ToByte(r.RequiredByTime),
                RequisitionCategory = DalCommon.ReturnRequisitionCategory(r.RequisitionCategory),
                RequisitionType = DalCommon.ReturnOrderType(r.RequisitionType),
                IssueTo = r.RequisitionFrom,
                IssueFrom = _RequisitionAt
            }).FirstOrDefault();

            model.RequisitionInfo = RequisitionInfo;

            var RequisitionItemList = (from i in _context.PRD_ChemProdReqItem.AsEnumerable()
                                       where i.RequisitionID == _RequisitionID

                                       from it in _context.Sys_ChemicalItem.Where(x => x.ItemID == i.ItemID).DefaultIfEmpty()

                                       join s in FinalStock on i.ItemID equals s.ItemID into badhon
                                       from item in badhon.DefaultIfEmpty()

                                       join su in _context.Sys_Unit on(item == null? 0: item.UnitID) equals su.UnitID into StockUnits
                                       from su in StockUnits.DefaultIfEmpty()


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

                                       from siu in _context.Sys_Unit.Where(x => x.UnitID == i.SizeUnit).DefaultIfEmpty()
                                       from ru in _context.Sys_Unit.Where(x => x.UnitID == i.RequisitionUnit).DefaultIfEmpty()

                                       from ps in _context.Sys_Size.Where(x => x.SizeID == i.PackSize).DefaultIfEmpty()

                                       select new PRDChemProdReqItem
            {
                ItemID = i.ItemID,
                ItemName = (it == null ? null : it.ItemName),

                StockQty = (item == null ? 0 : item.ClosingQty),
                StockUnitName = (su == null ? null : su.UnitName),
                SupplierID = (finalitem == null ? 0 : finalitem.SupplierID),
                SupplierName = (finalitem == null ? null : finalitem.SupplierName),

                PackSizeName = (ps == null ? null : ps.SizeName),
                SizeUnitName = (siu == null ? null : siu.UnitName),
                PackQty = Convert.ToInt16(i.PackQty),
                RequsitionQty = i.RequsitionQty,
                RequisitionUnitName = (ru == null ? null : ru.UnitName),

                IssuePackSizeName = "Press F9",
                IssueUnitName = "",

                //IssuePackSize = Convert.ToByte(i.PackSize),
                //IssuePackSizeName = (ps == null ? null : ps.SizeName),

                //IssueSizeUnit = Convert.ToByte(i.SizeUnit),
                //IssueSizeUnitName = (siu == null ? null : siu.UnitName),
                //IssuePackQty = Convert.ToInt16(i.PackQty),
                //IssueQty = i.RequsitionQty,
                //IssueUnit = i.RequisitionUnit,
                //IssueUnitName = (ru == null ? null : ru.UnitName),
                ItemSource = "Via Requisition"
            }).ToList();



            model.RequisitionItemList = RequisitionItemList;

            return(model);
        }