public ActionResult Reviewed(int Id, string IndexType, string UserRemark, string IsContinue)
        {
            ProdOrderHeader pd = new ProdOrderHeaderService(_unitOfWork).Find(Id);

            if (ModelState.IsValid)
            {
                pd.ReviewCount = (pd.ReviewCount ?? 0) + 1;
                pd.ReviewBy   += User.Identity.Name + ", ";

                _ProdOrderHeaderService.Update(pd);

                _unitOfWork.Save();

                LogActivity.LogActivityDetail(LogVm.Map(new ActiivtyLogViewModel
                {
                    DocTypeId    = pd.DocTypeId,
                    DocId        = pd.ProdOrderHeaderId,
                    ActivityType = (int)ActivityTypeContants.Reviewed,
                    UserRemark   = UserRemark,
                    DocNo        = pd.DocNo,
                    DocDate      = pd.DocDate,
                    DocStatus    = pd.Status,
                }));

                //SendEmail_POApproved(Id);

                return(RedirectToAction("Index", new { id = pd.DocTypeId, IndexType = IndexType }).Success("Record reviewed successfully."));
            }

            return(RedirectToAction("Index", new { id = pd.DocTypeId, IndexType = IndexType }).Warning("Error in reviewing."));
        }
Beispiel #2
0
        public ActionResult _ForMaterialPlan(int id)
        {
            ProdOrderLineFilterViewModel vm = new ProdOrderLineFilterViewModel();

            vm.ProdOrderHeaderId = id;
            ProdOrderHeader Header = new ProdOrderHeaderService(_unitOfWork).Find(id);

            vm.DocumentTypeSettings = new DocumentTypeSettingsService(_unitOfWork).GetDocumentTypeSettingsForDocument(Header.DocTypeId);
            return(PartialView("_Filters", vm));
        }
Beispiel #3
0
        public ActionResult DeletePost(ProdOrderLineViewModel vm)
        {
            List <LogTypeViewModel> LogList = new List <LogTypeViewModel>();

            ProdOrderLine   ProdOrderLine = _ProdOrderLineService.Find(vm.ProdOrderLineId);
            ProdOrderHeader header        = new ProdOrderHeaderService(_unitOfWork).Find(ProdOrderLine.ProdOrderHeaderId);
            int             status        = header.Status;

            LogList.Add(new LogTypeViewModel
            {
                ExObj = ProdOrderLine,
            });

            new ProdOrderLineStatusService(_unitOfWork).Delete(ProdOrderLine.ProdOrderLineId);

            _ProdOrderLineService.Delete(vm.ProdOrderLineId);

            if (header.Status != (int)StatusConstants.Drafted && header.Status != (int)StatusConstants.Import)
            {
                header.Status       = (int)StatusConstants.Modified;
                header.ModifiedDate = DateTime.Now;
                header.ModifiedBy   = User.Identity.Name;
                new ProdOrderHeaderService(_unitOfWork).Update(header);
            }
            XElement Modifications = new ModificationsCheckService().CheckChanges(LogList);

            try
            {
                _unitOfWork.Save();
            }

            catch (Exception ex)
            {
                string message = _exception.HandleException(ex);
                TempData["CSEXCL"] += message;
                return(PartialView("_Create", vm));
            }

            LogActivity.LogActivityDetail(LogVm.Map(new ActiivtyLogViewModel
            {
                DocTypeId       = header.DocTypeId,
                DocId           = header.ProdOrderHeaderId,
                DocLineId       = ProdOrderLine.ProdOrderLineId,
                ActivityType    = (int)ActivityTypeContants.Deleted,
                DocNo           = header.DocNo,
                xEModifications = Modifications,
                DocDate         = header.DocDate,
                DocStatus       = header.Status,
            }));

            return(Json(new { success = true }));
        }
Beispiel #4
0
        private ActionResult _Delete(int id)
        {
            ProdOrderLineViewModel temp = _ProdOrderLineService.GetProdOrderLine(id);

            if (temp == null)
            {
                return(HttpNotFound());
            }

            #region DocTypeTimeLineValidation
            try
            {
                TimePlanValidation = DocumentValidation.ValidateDocumentLine(new DocumentUniqueId {
                    LockReason = temp.LockReason
                }, User.Identity.Name, out ExceptionMsg, out Continue);
            }
            catch (Exception ex)
            {
                string message = _exception.HandleException(ex);
                TempData["CSEXCL"] += message;
                TimePlanValidation  = false;
            }

            if (!TimePlanValidation)
            {
                TempData["CSEXCL"] += ExceptionMsg;
            }
            #endregion

            if ((TimePlanValidation || Continue))
            {
                ViewBag.LineMode = "Delete";
            }

            ProdOrderHeader H = new ProdOrderHeaderService(_unitOfWork).Find(temp.ProdOrderHeaderId);
            //Getting Settings
            var settings = new ProdOrderSettingsService(_unitOfWork).GetProdOrderSettingsForDocument(H.DocTypeId, H.DivisionId, H.SiteId);

            temp.ProdOrderSettings = Mapper.Map <ProdOrderSettings, ProdOrderSettingsViewModel>(settings);

            temp.DocumentTypeSettings = new DocumentTypeSettingsService(_unitOfWork).GetDocumentTypeSettingsForDocument(H.DocTypeId);

            ViewBag.DocNo = H.DocNo;

            return(PartialView("_Create", temp));
        }
        private void PrepareViewBag(int id)
        {
            ViewBag.Name = new DocumentTypeService(_unitOfWork).Find(id).DocumentTypeName;
            ViewBag.id   = id;

            int SiteId     = (int)System.Web.HttpContext.Current.Session["SiteId"];
            int DivisionId = (int)System.Web.HttpContext.Current.Session["DivisionId"];
            var Settings   = new ProdOrderHeaderService(_unitOfWork).GetProductionOrderSettingsForDocument(id, DivisionId, SiteId);

            ViewBag.AdminSetting = UserRoles.Contains("Admin").ToString();
            if (Settings != null)
            {
                ViewBag.WizardId             = Settings.WizardMenuId;
                ViewBag.ImportMenuId         = Settings.ImportMenuId;
                ViewBag.SqlProcDocumentPrint = Settings.SqlProcDocumentPrint;
                ViewBag.ExportMenuId         = Settings.ExportMenuId;
            }
        }
Beispiel #6
0
        public ActionResult _Detail(int id)
        {
            ProdOrderLineViewModel temp = _ProdOrderLineService.GetProdOrderLine(id);

            if (temp == null)
            {
                return(HttpNotFound());
            }

            ProdOrderHeader H = new ProdOrderHeaderService(_unitOfWork).Find(temp.ProdOrderHeaderId);
            //Getting Settings
            var settings = new ProdOrderSettingsService(_unitOfWork).GetProdOrderSettingsForDocument(H.DocTypeId, H.DivisionId, H.SiteId);

            temp.ProdOrderSettings = Mapper.Map <ProdOrderSettings, ProdOrderSettingsViewModel>(settings);

            ViewBag.DocNo = H.DocNo;

            return(PartialView("_Create", temp));
        }
Beispiel #7
0
        public ActionResult _Create(int Id) //Id ==>Prod Order Header Id
        {
            ProdOrderHeader        H = new ProdOrderHeaderService(_unitOfWork).Find(Id);
            ProdOrderLineViewModel s = new ProdOrderLineViewModel();

            //Getting Settings
            var settings = new ProdOrderSettingsService(_unitOfWork).GetProdOrderSettingsForDocument(H.DocTypeId, H.DivisionId, H.SiteId);

            s.ProdOrderSettings = Mapper.Map <ProdOrderSettings, ProdOrderSettingsViewModel>(settings);

            s.DocumentTypeSettings = new DocumentTypeSettingsService(_unitOfWork).GetDocumentTypeSettingsForDocument(H.DocTypeId);

            s.ProdOrderHeaderId = H.ProdOrderHeaderId;
            ViewBag.DocNo       = H.DocNo;
            ViewBag.Status      = H.Status;
            ViewBag.LineMode    = "Create";

            return(PartialView("_Create", s));
        }
        public ActionResult Submitted(int Id, string IndexType, string UserRemark, string IsContinue)
        {
            ProdOrderHeader pd = new ProdOrderHeaderService(_unitOfWork).Find(Id);

            if (ModelState.IsValid)
            {
                if (User.Identity.Name == pd.ModifiedBy || UserRoles.Contains("Admin"))
                {
                    pd.Status   = (int)StatusConstants.Submitted;
                    pd.ReviewBy = null;
                    _ProdOrderHeaderService.Update(pd);

                    _unitOfWork.Save();

                    LogActivity.LogActivityDetail(LogVm.Map(new ActiivtyLogViewModel
                    {
                        DocTypeId    = pd.DocTypeId,
                        DocId        = pd.ProdOrderHeaderId,
                        ActivityType = (int)ActivityTypeContants.Submitted,
                        UserRemark   = UserRemark,
                        DocNo        = pd.DocNo,
                        DocDate      = pd.DocDate,
                        DocStatus    = pd.Status,
                    }));

                    //SendEmail_PODrafted(Id);

                    return(RedirectToAction("Index", new { id = pd.DocTypeId, IndexType = IndexType }).Success("Record Submitted successfully."));
                }
                else
                {
                    return(RedirectToAction("Index", new { id = pd.DocTypeId, IndexType = IndexType }).Warning("Record can be submitted by user " + pd.ModifiedBy + " only."));
                }
            }

            return(View());
        }
Beispiel #9
0
        public ActionResult DeleteConfirmed(ReasonViewModel vm)
        {
            if (ModelState.IsValid)
            {
                List <LogTypeViewModel> LogList = new List <LogTypeViewModel>();

                db.Configuration.AutoDetectChangesEnabled = false;
                var temp = _MaterialPlanHeaderService.Find(vm.id);

                int status = temp.Status;

                LogList.Add(new LogTypeViewModel
                {
                    ExObj = temp,
                });


                List <ProdOrderLine> ProdOrderLines = new List <ProdOrderLine>();
                //List<ProdOrderLine> PurchaseIndentLines = new List<ProdOrderLine>();


                var materialplanline = new MaterialPlanLineService(_unitOfWork).GetMaterialPlanForDelete(vm.id).ToList();

                //var MAterialPlanForProdOrderLine = new MaterialPlanForProdOrderLineService(_unitOfWork).GetMAterialPlanForProdORderForMaterialPlan(item.MaterialPlanLineId).ToList();
                var MAterialPlanForProdOrderLine = (from L in db.MaterialPlanForProdOrderLine
                                                    join H in db.MaterialPlanForProdOrder on L.MaterialPlanForProdOrderId equals H.MaterialPlanForProdOrderId into MaterialPlanForProdOrderTable
                                                    from MaterialPlanForProdOrderTab in MaterialPlanForProdOrderTable.DefaultIfEmpty()
                                                    where MaterialPlanForProdOrderTab.MaterialPlanHeaderId == vm.id
                                                    select L).ToList();
                foreach (var item2 in MAterialPlanForProdOrderLine)
                {
                    LogList.Add(new LogTypeViewModel
                    {
                        ExObj = item2,
                    });

                    item2.ObjectState = Model.ObjectState.Deleted;
                    //new MaterialPlanForProdOrderLineService(_unitOfWork).Delete(item2.MaterialPlanForProdOrderLineId);
                    db.MaterialPlanForProdOrderLine.Attach(item2);
                    db.MaterialPlanForProdOrderLine.Remove(item2);
                }

                foreach (var item in materialplanline)
                {
                    //Deleting ProdOrderLines & HEaders
                    ProdOrderLines = new ProdOrderLineService(_unitOfWork).GetProdOrderLineForMaterialPlan(item.MaterialPlanLineId).ToList();

                    int[] LineIds = ProdOrderLines.Select(m => m.ProdOrderLineId).ToArray();

                    List <ProdOrderLineStatus> LineStatus = (from p in db.ProdOrderLineStatus
                                                             where LineIds.Contains(p.ProdOrderLineId.Value)
                                                             select p).ToList();

                    foreach (var LineStatitem in LineStatus)
                    {
                        LineStatitem.ObjectState = Model.ObjectState.Deleted;
                        db.ProdOrderLineStatus.Attach(LineStatitem);
                        db.ProdOrderLineStatus.Remove(LineStatitem);
                    }

                    foreach (var item2 in ProdOrderLines)
                    {
                        LogList.Add(new LogTypeViewModel
                        {
                            ExObj = item2,
                        });

                        item2.ObjectState = Model.ObjectState.Deleted;
                        db.ProdOrderLine.Attach(item2);
                        db.ProdOrderLine.Remove(item2);
                    }


                    //Deleting PurchaseIndentLines & Headers
                    //PurchaseIndentLines = new ProdOrderLineService(_unitOfWork).GetPurchOrProdLineForMaterialPlan(item.MaterialPlanLineId, ).ToList();
                    //foreach (var item2 in PurchaseIndentLines)
                    //{

                    //    LogList.Add(new LogTypeViewModel
                    //    {
                    //        ExObj = item2,
                    //    });

                    //    item2.ObjectState = Model.ObjectState.Deleted;
                    //    db.PurchaseIndentLine.Attach(item2);
                    //    db.PurchaseIndentLine.Remove(item2);
                    //}


                    //Deleting MaterialplanforSaleOrder
                    var MAterialPlanForSaleOrder = new MaterialPlanForSaleOrderService(_unitOfWork).GetMaterialPlanForSaleOrderForMaterialPlanline(item.MaterialPlanLineId).ToList();
                    foreach (var item2 in MAterialPlanForSaleOrder)
                    {
                        LogList.Add(new LogTypeViewModel
                        {
                            ExObj = item2,
                        });

                        item2.ObjectState = Model.ObjectState.Deleted;
                        //new MaterialPlanForSaleOrderService(_unitOfWork).Delete(item2);
                        db.MaterialPlanForSaleOrder.Attach(item2);
                        db.MaterialPlanForSaleOrder.Remove(item2);
                    }

                    //Deleting MaterialPlanForProdOrderLine
                    //var MAterialPlanForProdOrderLine = new MaterialPlanForProdOrderLineService(_unitOfWork).GetMAterialPlanForProdORderForMaterialPlan(item.MaterialPlanLineId).ToList();
                    //foreach (var item2 in MAterialPlanForProdOrderLine)
                    //{

                    //    LogList.Add(new LogTypeViewModel
                    //    {
                    //        ExObj = item2,
                    //    });

                    //    item2.ObjectState = Model.ObjectState.Deleted;
                    //    //new MaterialPlanForProdOrderLineService(_unitOfWork).Delete(item2.MaterialPlanForProdOrderLineId);
                    //    db.MaterialPlanForProdOrderLine.Attach(item2);
                    //    db.MaterialPlanForProdOrderLine.Remove(item2);
                    //}

                    //new MaterialPlanLineService(_unitOfWork).Delete(item.MaterialPlanLineId);

                    //MaterialPlanLine Si = (MaterialPlanLine) item;
                    MaterialPlanLine MPL = new MaterialPlanLineService(_unitOfWork).Find(item.MaterialPlanLineId);

                    LogList.Add(new LogTypeViewModel
                    {
                        ExObj = MPL,
                    });

                    MPL.ObjectState = Model.ObjectState.Deleted;

                    db.MaterialPlanLine.Attach(MPL);
                    db.MaterialPlanLine.Remove(MPL);
                }



                var ProdORderHeaders = new ProdOrderHeaderService(_unitOfWork).GetProdOrderListForMaterialPlan(vm.id).ToList();

                int[] ProdOrderIds = ProdORderHeaders.Select(m => m.ProdOrderHeaderId).ToArray();

                List <ProdOrderHeaderStatus> ProdOrderHeaderStatus = (from p in db.ProdOrderHeaderStatus
                                                                      where ProdOrderIds.Contains(p.ProdOrderHeaderId.Value)
                                                                      select p).ToList();

                foreach (var StatItem in ProdOrderHeaderStatus)
                {
                    StatItem.ObjectState = Model.ObjectState.Deleted;
                    db.ProdOrderHeaderStatus.Attach(StatItem);
                    db.ProdOrderHeaderStatus.Remove(StatItem);
                }
                foreach (var item2 in ProdORderHeaders)
                {
                    LogList.Add(new LogTypeViewModel
                    {
                        ExObj = item2,
                    });

                    item2.ObjectState = Model.ObjectState.Deleted;
                    // new ProdOrderHeaderService(_unitOfWork).Delete(item2.ProdOrderHeaderId);
                    db.ProdOrderHeader.Attach(item2);
                    db.ProdOrderHeader.Remove(item2);
                }
                //var PurchaseIndentHeaders = new PurchaseIndentHeaderService(_unitOfWork).GetPurchaseIndentListForMAterialPlan(vm.id).ToList();
                //foreach (var item2 in PurchaseIndentHeaders)
                //{
                //    LogList.Add(new LogTypeViewModel
                //    {
                //        ExObj = item2,
                //    });

                //    item2.ObjectState = Model.ObjectState.Deleted;
                //    //new PurchaseIndentHeaderService(_unitOfWork).Delete(item2.PurchaseIndentHeaderId);
                //    db.PurchaseIndentHeader.Attach(item2);
                //    db.PurchaseIndentHeader.Remove(item2);
                //}

                //Deleting MaterialPlanForProdORder
                var MaterialPlanForProdOrder = new MaterialPlanForProdOrderService(_unitOfWork).GetMAterialPlanForProdORderForMaterialPlan(vm.id).ToList();
                foreach (var item2 in MaterialPlanForProdOrder)
                {
                    LogList.Add(new LogTypeViewModel
                    {
                        ExObj = item2,
                    });

                    item2.ObjectState = Model.ObjectState.Deleted;
                    //new MaterialPlanForProdOrderService(_unitOfWork).Delete(item2);
                    db.MaterialPlanForProdOrder.Attach(item2);
                    db.MaterialPlanForProdOrder.Remove(item2);
                }

                temp.ObjectState = Model.ObjectState.Deleted;
                // _MaterialPlanHeaderService.Delete(temp);
                db.MaterialPlanHeader.Attach(temp);
                db.MaterialPlanHeader.Remove(temp);

                XElement Modifications = new ModificationsCheckService().CheckChanges(LogList);

                try
                {
                    // _unitOfWork.Save();
                    db.SaveChanges();
                    db.Configuration.AutoDetectChangesEnabled = true;
                }

                catch (Exception ex)
                {
                    string message = _exception.HandleException(ex);
                    TempData["CSEXC"] += message;
                    return(PartialView("_Reason", vm));
                }

                LogActivity.LogActivityDetail(LogVm.Map(new ActiivtyLogViewModel
                {
                    DocTypeId       = temp.DocTypeId,
                    DocId           = temp.MaterialPlanHeaderId,
                    ActivityType    = (int)ActivityTypeContants.Deleted,
                    UserRemark      = vm.Reason,
                    DocNo           = temp.DocNo,
                    xEModifications = Modifications,
                    DocDate         = temp.DocDate,
                    DocStatus       = temp.Status,
                }));

                return(Json(new { success = true }));
            }
            return(PartialView("_Reason", vm));
        }
Beispiel #10
0
        public ActionResult Post(MaterialPlanHeaderViewModel vm)
        {
            MaterialPlanHeader pt = AutoMapper.Mapper.Map <MaterialPlanHeaderViewModel, MaterialPlanHeader>(vm);

            #region DocTypeTimeLineValidation

            try
            {
                if (vm.MaterialPlanHeaderId <= 0)
                {
                    TimePlanValidation = DocumentValidation.ValidateDocument(Mapper.Map <DocumentUniqueId>(vm), DocumentTimePlanTypeConstants.Create, User.Identity.Name, out ExceptionMsg, out Continue);
                }
                else
                {
                    TimePlanValidation = DocumentValidation.ValidateDocument(Mapper.Map <DocumentUniqueId>(vm), DocumentTimePlanTypeConstants.Modify, User.Identity.Name, out ExceptionMsg, out Continue);
                }
            }
            catch (Exception ex)
            {
                string message = _exception.HandleException(ex);
                TempData["CSEXC"] += message;
                TimePlanValidation = false;
            }

            if (!TimePlanValidation)
            {
                TempData["CSEXC"] += ExceptionMsg;
            }

            #endregion

            if (vm.MaterialPlanSettings.isMandatoryMachine == true && vm.MachineId == null)
            {
                ModelState.AddModelError("MachineId", "Machine field is required");
            }

            if (ModelState.IsValid && (TimePlanValidation || Continue))
            {
                #region CreateRecord
                if (vm.MaterialPlanHeaderId <= 0)
                {
                    pt.CreatedDate  = DateTime.Now;
                    pt.ModifiedDate = DateTime.Now;
                    pt.CreatedBy    = User.Identity.Name;
                    pt.ModifiedBy   = User.Identity.Name;
                    pt.ObjectState  = Model.ObjectState.Added;
                    _MaterialPlanHeaderService.Create(pt);

                    try
                    {
                        _unitOfWork.Save();
                    }

                    catch (Exception ex)
                    {
                        string message = _exception.HandleException(ex);
                        TempData["CSEXC"] += message;
                        ViewBag.Mode       = "Add";
                        ViewBag.Name       = new DocumentTypeService(_unitOfWork).Find(vm.DocTypeId).DocumentTypeName;
                        ViewBag.id         = vm.DocTypeId;
                        return(View("Create", vm));
                    }

                    LogActivity.LogActivityDetail(LogVm.Map(new ActiivtyLogViewModel
                    {
                        DocTypeId    = pt.DocTypeId,
                        DocId        = pt.MaterialPlanHeaderId,
                        ActivityType = (int)ActivityTypeContants.Added,
                        DocNo        = pt.DocNo,
                        DocDate      = pt.DocDate,
                        DocStatus    = pt.Status,
                    }));

                    return(RedirectToAction("Modify", new { id = pt.MaterialPlanHeaderId }).Success("Data saved successfully"));
                }
                #endregion

                #region EditRecord
                else
                {
                    List <LogTypeViewModel> LogList = new List <LogTypeViewModel>();

                    MaterialPlanHeader temp = _MaterialPlanHeaderService.Find(pt.MaterialPlanHeaderId);

                    MaterialPlanHeader ExRec = Mapper.Map <MaterialPlanHeader>(temp);

                    temp.DocNo        = pt.DocNo;
                    temp.DocDate      = pt.DocDate;
                    temp.DueDate      = pt.DueDate;
                    temp.Remark       = pt.Remark;
                    temp.BuyerId      = pt.BuyerId;
                    temp.MachineId    = pt.MachineId;
                    temp.ModifiedDate = DateTime.Now;
                    temp.ModifiedBy   = User.Identity.Name;
                    temp.ObjectState  = Model.ObjectState.Modified;
                    _MaterialPlanHeaderService.Update(temp);

                    //PurchaseIndentHeader ExistingIndent = new PurchaseIndentHeaderService(_unitOfWork).GetPurchaseIndentForMaterialPlan(temp.MaterialPlanHeaderId);
                    ProdOrderHeader ExistingIndent = new ProdOrderHeaderService(_unitOfWork).GetPurchOrProdForMaterialPlan(temp.MaterialPlanHeaderId, vm.MaterialPlanSettings.DocTypePurchaseIndentId ?? 0);

                    //ProdOrderHeader ExistingProdOrder = new ProdOrderHeaderService(_unitOfWork).GetProdOrderForMaterialPlan(temp.MaterialPlanHeaderId);
                    ProdOrderHeader ExistingProdOrder = new ProdOrderHeaderService(_unitOfWork).GetPurchOrProdForMaterialPlan(temp.MaterialPlanHeaderId, vm.MaterialPlanSettings.DocTypeProductionOrderId ?? 0);

                    if (ExistingIndent != null)
                    {
                        ExistingIndent.ModifiedBy   = User.Identity.Name;
                        ExistingIndent.ModifiedDate = DateTime.Now;
                        ExistingIndent.Remark       = temp.Remark;
                        ExistingIndent.ObjectState  = Model.ObjectState.Added;
                        //new PurchaseIndentHeaderService(_unitOfWork).Update(ExistingIndent);
                        new ProdOrderHeaderService(_unitOfWork).Update(ExistingIndent);
                    }

                    if (ExistingProdOrder != null)
                    {
                        ExistingProdOrder.ModifiedBy   = User.Identity.Name;
                        ExistingProdOrder.ModifiedDate = DateTime.Now;
                        ExistingProdOrder.Remark       = temp.Remark;
                        ExistingProdOrder.ObjectState  = Model.ObjectState.Added;
                        new ProdOrderHeaderService(_unitOfWork).Update(ExistingProdOrder);
                    }

                    LogList.Add(new LogTypeViewModel
                    {
                        ExObj = ExRec,
                        Obj   = temp,
                    });

                    XElement Modifications = new ModificationsCheckService().CheckChanges(LogList);

                    try
                    {
                        _unitOfWork.Save();
                    }

                    catch (Exception ex)
                    {
                        string message = _exception.HandleException(ex);
                        TempData["CSEXC"] += message;
                        ViewBag.Mode       = "Edit";
                        ViewBag.Name       = new DocumentTypeService(_unitOfWork).Find(vm.DocTypeId).DocumentTypeName;
                        ViewBag.id         = vm.DocTypeId;
                        return(View("Create", pt));
                    }

                    LogActivity.LogActivityDetail(LogVm.Map(new ActiivtyLogViewModel
                    {
                        DocTypeId       = temp.DocTypeId,
                        DocId           = temp.MaterialPlanHeaderId,
                        ActivityType    = (int)ActivityTypeContants.Modified,
                        DocNo           = temp.DocNo,
                        xEModifications = Modifications,
                        DocDate         = temp.DocDate,
                        DocStatus       = temp.Status,
                    }));

                    return(RedirectToAction("Index", new { id = vm.DocTypeId }).Success("Data saved successfully"));
                }
                #endregion
            }
            ViewBag.Name = new DocumentTypeService(_unitOfWork).Find(vm.DocTypeId).DocumentTypeName;
            ViewBag.id   = vm.DocTypeId;
            ViewBag.Mode = "Add";
            return(View("Create", vm));
        }
Beispiel #11
0
        public ActionResult Post(MaterialPlanHeaderViewModel vm)
        {
            MaterialPlanHeader pt = AutoMapper.Mapper.Map <MaterialPlanHeaderViewModel, MaterialPlanHeader>(vm);

            //#region DocTypeTimeLineValidation

            //try
            //{

            //    if (vm.MaterialPlanHeaderId <= 0)
            //        TimePlanValidation = DocumentValidation.ValidateDocument(Mapper.Map<DocumentUniqueId>(vm), DocumentTimePlanTypeConstants.Create, User.Identity.Name, out ExceptionMsg, out Continue);
            //    else
            //        TimePlanValidation = DocumentValidation.ValidateDocument(Mapper.Map<DocumentUniqueId>(vm), DocumentTimePlanTypeConstants.Modify, User.Identity.Name, out ExceptionMsg, out Continue);

            //}
            //catch (Exception ex)
            //{
            //    string message = _exception.HandleException(ex);
            //    TempData["CSEXC"] += message;
            //    TimePlanValidation = false;
            //}

            //if (!TimePlanValidation)
            //    TempData["CSEXC"] += ExceptionMsg;

            //#endregion

            if (ModelState.IsValid && (TimePlanValidation || Continue))
            {
                #region CreateRecord
                if (vm.MaterialPlanHeaderId <= 0)
                {
                    using (var context = new ApplicationDbContext())
                    {
                        pt.CreatedDate  = DateTime.Now;
                        pt.ModifiedDate = DateTime.Now;
                        pt.CreatedBy    = User.Identity.Name;
                        pt.ModifiedBy   = User.Identity.Name;
                        pt.ObjectState  = Model.ObjectState.Added;
                        context.MaterialPlanHeader.Add(pt);

                        int Serial = 0;

                        MaterialPlanLineListViewModel svm = new MaterialPlanLineListViewModel();
                        svm.MaterialPlanLineViewModel = (List <MaterialPlanForSaleOrderViewModel>)System.Web.HttpContext.Current.Session["SODyeingPlan"];

                        var Summary = (IEnumerable <MaterialPlanLineViewModel>)System.Web.HttpContext.Current.Session["SODyeingPlanSummary"];

                        MaterialPlanSettings Settings = new MaterialPlanSettingsService(_unitOfWork).GetMaterialPlanSettingsForDocument(pt.DocTypeId, pt.DivisionId, pt.SiteId);


                        bool isPr = false;
                        bool isPP = false;
                        int  j    = 0;
                        foreach (var item in Summary)
                        {
                            {
                                MaterialPlanLine planLine = new MaterialPlanLine();
                                planLine.RequiredQty          = item.RequiredQty;
                                planLine.ExcessStockQty       = item.ExcessStockQty;
                                planLine.MaterialPlanHeaderId = item.MaterialPlanHeaderId;
                                planLine.ProductId            = item.ProductId;
                                planLine.Dimension1Id         = item.Dimension1Id;
                                planLine.Dimension2Id         = item.Dimension2Id;
                                planLine.ProdPlanQty          = item.ProdPlanQty;
                                planLine.CreatedBy            = User.Identity.Name;
                                planLine.CreatedDate          = DateTime.Now;
                                planLine.Sr                 = Serial++;
                                planLine.Specification      = item.Specification;
                                planLine.ModifiedBy         = User.Identity.Name;
                                planLine.MaterialPlanLineId = j;
                                planLine.ModifiedDate       = DateTime.Now;
                                planLine.ProcessId          = item.ProcessId;
                                planLine.Remark             = item.Remark;
                                planLine.PurchPlanQty       = item.PurchPlanQty;
                                planLine.StockPlanQty       = item.StockPlanQty;
                                planLine.GeneratedFor       = MaterialPlanConstants.SaleOrder;
                                planLine.ObjectState        = Model.ObjectState.Added;
                                context.MaterialPlanLine.Add(planLine);
                                if (!isPr)
                                {
                                    if (item.ProdPlanQty > 0)
                                    {
                                        isPr = true;
                                    }
                                }
                                if (!isPP)
                                {
                                    if (item.PurchPlanQty > 0)
                                    {
                                        isPP = true;
                                    }
                                }
                            }
                            j++;
                        }

                        if (isPr)
                        {
                            ProdOrderHeader ExistingProdOrder = new ProdOrderHeaderService(_unitOfWork).GetProdOrderForMaterialPlan(pt.MaterialPlanHeaderId);
                            int             ProdORderSerial   = 1;
                            if (ExistingProdOrder == null)
                            {
                                ProdOrderHeader prodOrderHeader = new ProdOrderHeader();

                                prodOrderHeader.CreatedBy            = User.Identity.Name;
                                prodOrderHeader.CreatedDate          = DateTime.Now;
                                prodOrderHeader.DivisionId           = pt.DivisionId;
                                prodOrderHeader.DocDate              = pt.DocDate;
                                prodOrderHeader.DocNo                = pt.DocNo;
                                prodOrderHeader.DocTypeId            = Settings.DocTypeProductionOrderId.Value;
                                prodOrderHeader.DueDate              = pt.DueDate;
                                prodOrderHeader.MaterialPlanHeaderId = pt.MaterialPlanHeaderId;
                                prodOrderHeader.ModifiedBy           = User.Identity.Name;
                                prodOrderHeader.ModifiedDate         = DateTime.Now;
                                prodOrderHeader.Remark               = pt.Remark;
                                prodOrderHeader.BuyerId              = pt.BuyerId;
                                prodOrderHeader.SiteId               = pt.SiteId;
                                //prodOrderHeader.Status = header.Status;
                                prodOrderHeader.Status      = (int)StatusConstants.System;
                                prodOrderHeader.ObjectState = Model.ObjectState.Added;
                                context.ProdOrderHeader.Add(prodOrderHeader);

                                //ForCreating ProdOrderStatus
                                ProdOrderHeaderStatus pts = new ProdOrderHeaderStatus();
                                pts.ProdOrderHeaderId = prodOrderHeader.ProdOrderHeaderId;
                                pts.ObjectState       = Model.ObjectState.Added;
                                context.ProdOrderHeaderStatus.Add(pts);

                                int ProdOrderLineKey = 0;
                                foreach (var item in context.MaterialPlanLine.Local.Where(m => m.ProdPlanQty > 0))
                                {
                                    ProdOrderLine prodOrderLine = new ProdOrderLine();
                                    prodOrderLine.CreatedBy          = User.Identity.Name;
                                    prodOrderLine.CreatedDate        = DateTime.Now;
                                    prodOrderLine.MaterialPlanLineId = item.MaterialPlanLineId;
                                    prodOrderLine.ModifiedBy         = User.Identity.Name;
                                    prodOrderLine.ModifiedDate       = DateTime.Now;
                                    prodOrderLine.ProdOrderHeaderId  = prodOrderHeader.ProdOrderHeaderId;
                                    prodOrderLine.Specification      = item.Specification;
                                    prodOrderLine.ProductId          = item.ProductId;
                                    prodOrderLine.Dimension1Id       = item.Dimension1Id;
                                    prodOrderLine.Dimension2Id       = item.Dimension2Id;
                                    prodOrderLine.Sr              = ProdORderSerial++;
                                    prodOrderLine.Qty             = item.ProdPlanQty;
                                    prodOrderLine.Remark          = item.Remark;
                                    prodOrderLine.ProdOrderLineId = ProdOrderLineKey++;
                                    prodOrderLine.ObjectState     = Model.ObjectState.Added;
                                    context.ProdOrderLine.Add(prodOrderLine);

                                    //ForAdding ProdrderLinestatus
                                    ProdOrderLineStatus ptl = new ProdOrderLineStatus();
                                    ptl.ProdOrderLineId = prodOrderLine.ProdOrderLineId;
                                    ptl.ObjectState     = Model.ObjectState.Added;
                                    context.ProdOrderLineStatus.Add(ptl);
                                }
                            }
                            else
                            {
                                ProdORderSerial = new ProdOrderLineService(_unitOfWork).GetMaxSr(ExistingProdOrder.ProdOrderHeaderId);


                                int ProdOrderLineKey = 0;
                                foreach (var item in context.MaterialPlanLine.Local.Where(m => m.ProdPlanQty > 0))
                                {
                                    ProdOrderLine prodOrderLine = new ProdOrderLine();
                                    prodOrderLine.CreatedBy          = User.Identity.Name;
                                    prodOrderLine.CreatedDate        = DateTime.Now;
                                    prodOrderLine.MaterialPlanLineId = item.MaterialPlanLineId;
                                    prodOrderLine.ModifiedBy         = User.Identity.Name;
                                    prodOrderLine.ModifiedDate       = DateTime.Now;
                                    prodOrderLine.ProdOrderHeaderId  = ExistingProdOrder.ProdOrderHeaderId;
                                    prodOrderLine.ProductId          = item.ProductId;
                                    prodOrderLine.Dimension1Id       = item.Dimension1Id;
                                    prodOrderLine.Dimension2Id       = item.Dimension2Id;
                                    prodOrderLine.Specification      = item.Specification;
                                    prodOrderLine.Qty             = item.ProdPlanQty;
                                    prodOrderLine.Sr              = ProdORderSerial++;
                                    prodOrderLine.Remark          = item.Remark;
                                    prodOrderLine.ProdOrderLineId = ProdOrderLineKey++;
                                    prodOrderLine.ObjectState     = Model.ObjectState.Added;
                                    context.ProdOrderLine.Add(prodOrderLine);

                                    //ForAdding ProdrderLinestatus
                                    ProdOrderLineStatus ptl = new ProdOrderLineStatus();
                                    ptl.ProdOrderLineId = prodOrderLine.ProdOrderLineId;
                                    ptl.ObjectState     = Model.ObjectState.Added;
                                    context.ProdOrderLineStatus.Add(ptl);
                                }
                            }
                        }
                        if (isPP)
                        {
                            PurchaseIndentHeader ExistingIndent = new PurchaseIndentHeaderService(_unitOfWork).GetPurchaseIndentForMaterialPlan(pt.MaterialPlanHeaderId);
                            int PurchaseIndentSr = 1;
                            if (ExistingIndent == null)
                            {
                                PurchaseIndentHeader indentHeader = new PurchaseIndentHeader();
                                indentHeader.CreatedBy            = User.Identity.Name;
                                indentHeader.CreatedDate          = DateTime.Now;
                                indentHeader.DivisionId           = pt.DivisionId;
                                indentHeader.DocDate              = pt.DocDate;
                                indentHeader.DocNo                = pt.DocNo;
                                indentHeader.DocTypeId            = Settings.DocTypePurchaseIndentId.Value;
                                indentHeader.ModifiedBy           = User.Identity.Name;
                                indentHeader.MaterialPlanHeaderId = pt.MaterialPlanHeaderId;
                                indentHeader.ModifiedDate         = DateTime.Now;
                                indentHeader.Remark               = pt.Remark;
                                indentHeader.SiteId               = pt.SiteId;
                                //indentHeader.Status = header.Status;
                                indentHeader.Status       = (int)StatusConstants.System;
                                indentHeader.DepartmentId = (int)DepartmentConstants.Production;
                                indentHeader.ObjectState  = Model.ObjectState.Added;
                                context.PurchaseIndentHeader.Add(indentHeader);
                                foreach (var item in context.MaterialPlanLine.Local.Where(m => m.PurchPlanQty > 0))
                                {
                                    PurchaseIndentLine indentLine = new PurchaseIndentLine();
                                    indentLine.CreatedBy              = User.Identity.Name;
                                    indentLine.CreatedDate            = DateTime.Now;
                                    indentLine.MaterialPlanLineId     = item.MaterialPlanLineId;
                                    indentLine.ModifiedBy             = User.Identity.Name;
                                    indentLine.ModifiedDate           = DateTime.Now;
                                    indentLine.ProductId              = item.ProductId;
                                    indentLine.Dimension1Id           = item.Dimension1Id;
                                    indentLine.Dimension2Id           = item.Dimension2Id;
                                    indentLine.Specification          = item.Specification;
                                    indentLine.PurchaseIndentHeaderId = indentHeader.PurchaseIndentHeaderId;
                                    indentLine.Qty         = item.PurchPlanQty;
                                    indentLine.Sr          = PurchaseIndentSr++;
                                    indentLine.Remark      = item.Remark;
                                    indentLine.ObjectState = Model.ObjectState.Added;
                                    context.PurchaseIndentLine.Add(indentLine);
                                }
                            }
                            else
                            {
                                PurchaseIndentSr = new PurchaseIndentLineService(_unitOfWork).GetMaxSr(ExistingIndent.PurchaseIndentHeaderId);
                                foreach (var item in context.MaterialPlanLine.Local.Where(m => m.PurchPlanQty > 0))
                                {
                                    PurchaseIndentLine indentLine = new PurchaseIndentLine();
                                    indentLine.CreatedBy          = User.Identity.Name;
                                    indentLine.CreatedDate        = DateTime.Now;
                                    indentLine.MaterialPlanLineId = item.MaterialPlanLineId;
                                    indentLine.ModifiedBy         = User.Identity.Name;
                                    indentLine.Specification      = item.Specification;
                                    indentLine.ModifiedDate       = DateTime.Now;
                                    indentLine.ProductId          = item.ProductId;
                                    indentLine.Dimension1Id       = item.Dimension1Id;
                                    indentLine.Dimension2Id       = item.Dimension2Id;
                                    indentLine.Sr = PurchaseIndentSr++;
                                    indentLine.PurchaseIndentHeaderId = ExistingIndent.PurchaseIndentHeaderId;
                                    indentLine.Qty         = item.PurchPlanQty;
                                    indentLine.Remark      = item.Remark;
                                    indentLine.ObjectState = Model.ObjectState.Added;
                                    context.PurchaseIndentLine.Add(indentLine);
                                }
                            }
                        }


                        int i = 0;
                        int MaterialPlanForSaleOrderSr = new MaterialPlanForSaleOrderService(_unitOfWork).GetMaxSr(svm.MaterialPlanLineViewModel.FirstOrDefault().MaterialPlanHeaderId);
                        foreach (var item in svm.MaterialPlanLineViewModel)
                        {
                            if (item.Qty > 0)
                            {
                                MaterialPlanForSaleOrder order = new MaterialPlanForSaleOrder();
                                order.MaterialPlanHeaderId = item.MaterialPlanHeaderId;
                                order.Qty                        = item.Qty;
                                order.SaleOrderLineId            = item.SaleOrderLineId;
                                order.MaterialPlanForSaleOrderId = i;
                                order.Sr           = MaterialPlanForSaleOrderSr++;
                                order.CreatedBy    = User.Identity.Name;
                                order.CreatedDate  = DateTime.Now;
                                order.ModifiedBy   = User.Identity.Name;
                                order.ModifiedDate = DateTime.Now;

                                //if (item.Dimension1Id != null)
                                //{
                                //    var MaterialPlan = context.MaterialPlanLine.Local.Where(m => m.ProductId == item.ProductId && m.Dimension1Id == item.Dimension1Id).FirstOrDefault();
                                //    if (order != null)
                                //    {
                                //        order.MaterialPlanLineId = MaterialPlan.MaterialPlanLineId;
                                //    }
                                //}
                                //else
                                //{
                                //    var MaterialPlan = context.MaterialPlanLine.Local.Where(m => m.ProductId == item.ProductId).FirstOrDefault();
                                //    if (order != null)
                                //    {
                                //        order.MaterialPlanLineId = MaterialPlan.MaterialPlanLineId;
                                //    }
                                //}

                                order.ObjectState = Model.ObjectState.Added;
                                context.MaterialPlanForSaleOrder.Add(order);

                                i++;
                            }
                        }

                        try
                        {
                            context.SaveChanges();
                        }

                        catch (Exception ex)
                        {
                            string message = _exception.HandleException(ex);
                            TempData["CSEXC"] += message;
                            ViewBag.Mode       = "Add";
                            ViewBag.Name       = new DocumentTypeService(_unitOfWork).Find(vm.DocTypeId).DocumentTypeName;
                            ViewBag.id         = vm.DocTypeId;
                            return(View("Create", vm));
                        }

                        //LogActivity.LogActivityDetail(LogVm.Map(new ActiivtyLogViewModel
                        //{
                        //    DocTypeId = pt.DocTypeId,
                        //    DocId = pt.MaterialPlanHeaderId,
                        //    ActivityType = (int)ActivityTypeContants.Added,
                        //    DocNo = pt.DocNo,
                        //    DocDate = pt.DocDate,
                        //    DocStatus = pt.Status,
                        //}));

                        return(RedirectToAction("Index", "MaterialPlanHeader", new { id = pt.DocTypeId }));
                    }
                }
                #endregion
            }
            ViewBag.Name = new DocumentTypeService(_unitOfWork).Find(vm.DocTypeId).DocumentTypeName;
            ViewBag.id   = vm.DocTypeId;
            ViewBag.Mode = "Add";
            return(View("Create", vm));
        }
Beispiel #12
0
        public ActionResult _CreatePost(ProdOrderLineViewModel svm)
        {
            ProdOrderLine   s    = Mapper.Map <ProdOrderLineViewModel, ProdOrderLine>(svm);
            ProdOrderHeader temp = new ProdOrderHeaderService(_unitOfWork).Find(s.ProdOrderHeaderId);

            if (svm.Qty <= 0)
            {
                ModelState.AddModelError("Qty", "Please Check Qty");
            }

            if (svm.ProdOrderLineId <= 0)
            {
                ViewBag.LineMode = "Create";
            }
            else
            {
                ViewBag.LineMode = "Edit";
            }

            if (ModelState.IsValid)
            {
                if (svm.ProdOrderLineId == 0)
                {
                    s.CreatedDate  = DateTime.Now;
                    s.ModifiedDate = DateTime.Now;
                    s.CreatedBy    = User.Identity.Name;
                    s.ModifiedBy   = User.Identity.Name;
                    s.Sr           = _ProdOrderLineService.GetMaxSr(s.ProdOrderHeaderId);
                    s.ObjectState  = Model.ObjectState.Added;
                    _ProdOrderLineService.Create(s);

                    new ProdOrderLineStatusService(_unitOfWork).CreateLineStatus(s.ProdOrderLineId);

                    ProdOrderHeader header = new ProdOrderHeaderService(_unitOfWork).Find(s.ProdOrderHeaderId);
                    if (header.Status != (int)StatusConstants.Drafted)
                    {
                        header.Status       = (int)StatusConstants.Modified;
                        header.ModifiedDate = DateTime.Now;
                        header.ModifiedBy   = User.Identity.Name;
                        new ProdOrderHeaderService(_unitOfWork).Update(header);
                    }


                    try
                    {
                        _unitOfWork.Save();
                    }

                    catch (Exception ex)
                    {
                        string message = _exception.HandleException(ex);
                        TempData["CSEXCL"] += message;
                        return(PartialView("_Create", svm));
                    }

                    LogActivity.LogActivityDetail(LogVm.Map(new ActiivtyLogViewModel
                    {
                        DocTypeId    = temp.DocTypeId,
                        DocId        = temp.ProdOrderHeaderId,
                        DocLineId    = s.ProdOrderLineId,
                        ActivityType = (int)ActivityTypeContants.Added,
                        DocNo        = temp.DocNo,
                        DocDate      = temp.DocDate,
                        DocStatus    = temp.Status,
                    }));

                    return(RedirectToAction("_Create", new { id = s.ProdOrderHeaderId }));
                }
                else
                {
                    List <LogTypeViewModel> LogList = new List <LogTypeViewModel>();

                    ProdOrderHeader header    = new ProdOrderHeaderService(_unitOfWork).Find(svm.ProdOrderHeaderId);
                    StringBuilder   logstring = new StringBuilder();
                    int             status    = header.Status;
                    ProdOrderLine   temp1     = _ProdOrderLineService.Find(svm.ProdOrderLineId);

                    ProdOrderLine ExRec = new ProdOrderLine();
                    ExRec = Mapper.Map <ProdOrderLine>(temp1);

                    temp1.DueDate      = svm.DueDate;
                    temp1.ProductId    = svm.ProductId;
                    temp1.Qty          = svm.Qty;
                    temp1.Remark       = svm.Remark;
                    temp1.ModifiedDate = DateTime.Now;
                    temp1.ModifiedBy   = User.Identity.Name;
                    _ProdOrderLineService.Update(temp1);


                    LogList.Add(new LogTypeViewModel
                    {
                        ExObj = ExRec,
                        Obj   = temp1,
                    });

                    if (header.Status != (int)StatusConstants.Drafted && header.Status != (int)StatusConstants.Import)
                    {
                        header.Status       = (int)StatusConstants.Modified;
                        header.ModifiedBy   = User.Identity.Name;
                        header.ModifiedDate = DateTime.Now;
                        new ProdOrderHeaderService(_unitOfWork).Update(header);
                    }

                    XElement Modifications = new ModificationsCheckService().CheckChanges(LogList);
                    try
                    {
                        _unitOfWork.Save();
                    }

                    catch (Exception ex)
                    {
                        string message = _exception.HandleException(ex);
                        TempData["CSEXCL"] += message;
                        return(PartialView("_Create", svm));
                    }


                    LogActivity.LogActivityDetail(LogVm.Map(new ActiivtyLogViewModel
                    {
                        DocTypeId       = temp.DocTypeId,
                        DocId           = s.ProdOrderHeaderId,
                        DocLineId       = s.ProdOrderLineId,
                        ActivityType    = (int)ActivityTypeContants.Modified,
                        DocNo           = temp.DocNo,
                        xEModifications = Modifications,
                        DocDate         = temp.DocDate,
                        DocStatus       = temp.Status,
                    }));

                    return(Json(new { success = true }));
                }
            }

            ViewBag.Status = temp.Status;
            return(PartialView("_Create", svm));
        }
        public ActionResult GeneratePrints(string Ids, int DocTypeId)
        {
            if (!string.IsNullOrEmpty(Ids))
            {
                int SiteId     = (int)System.Web.HttpContext.Current.Session["SiteId"];
                int DivisionId = (int)System.Web.HttpContext.Current.Session["DivisionId"];

                var Settings = new ProdOrderHeaderService(_unitOfWork).GetProductionOrderSettingsForDocument(DocTypeId, DivisionId, SiteId);

                if (new RolePermissionService(_unitOfWork).IsActionAllowed(UserRoles, DocTypeId, null, this.ControllerContext.RouteData.Values["controller"].ToString(), "GeneratePrints") == false)
                {
                    return(View("~/Views/Shared/PermissionDenied.cshtml").Warning("You don't have permission to do this task."));
                }

                try
                {
                    List <byte[]> PdfStream = new List <byte[]>();
                    foreach (var item in Ids.Split(',').Select(Int32.Parse))
                    {
                        DirectReportPrint drp = new DirectReportPrint();

                        var pd = context.ProdOrderCancelHeader.Find(item);

                        LogActivity.LogActivityDetail(LogVm.Map(new ActiivtyLogViewModel
                        {
                            DocTypeId    = pd.DocTypeId,
                            DocId        = pd.ProdOrderCancelHeaderId,
                            ActivityType = (int)ActivityTypeContants.Print,
                            DocNo        = pd.DocNo,
                            DocDate      = pd.DocDate,
                            DocStatus    = pd.Status,
                        }));

                        byte[] Pdf;

                        if (pd.Status == (int)StatusConstants.Drafted || pd.Status == (int)StatusConstants.Import || pd.Status == (int)StatusConstants.Modified)
                        {
                            //LogAct(item.ToString());
                            Pdf = drp.DirectDocumentPrint(Settings.SqlProcDocumentPrint, User.Identity.Name, item);

                            PdfStream.Add(Pdf);
                        }
                        else if (pd.Status == (int)StatusConstants.Submitted || pd.Status == (int)StatusConstants.ModificationSubmitted)
                        {
                            Pdf = drp.DirectDocumentPrint(Settings.SqlProcDocumentPrint, User.Identity.Name, item);

                            PdfStream.Add(Pdf);
                        }
                        else
                        {
                            Pdf = drp.DirectDocumentPrint(Settings.SqlProcDocumentPrint, User.Identity.Name, item);
                            PdfStream.Add(Pdf);
                        }
                    }

                    PdfMerger pm = new PdfMerger();

                    byte[] Merge = pm.MergeFiles(PdfStream);

                    if (Merge != null)
                    {
                        return(File(Merge, "application/pdf"));
                    }
                }

                catch (Exception ex)
                {
                    string message = _exception.HandleException(ex);
                    return(Json(new { success = "Error", data = message }, JsonRequestBehavior.AllowGet));
                }


                return(Json(new { success = "Success" }, JsonRequestBehavior.AllowGet));
            }
            return(Json(new { success = "Error", data = "No Records Selected." }, JsonRequestBehavior.AllowGet));
        }