Exemple #1
0
        public ActionResult Import(int id)//Document Type Id
        {
            //ControllerAction ca = new ControllerActionService(_unitOfWork).Find(id);
            SaleDeliveryOrderHeaderViewModel vm = new SaleDeliveryOrderHeaderViewModel();

            vm.DivisionId = (int)System.Web.HttpContext.Current.Session["DivisionId"];
            vm.SiteId     = (int)System.Web.HttpContext.Current.Session["SiteId"];

            var settings = new SaleDeliveryOrderSettingsService(_unitOfWork).GetSaleDeliveryOrderSettingsForDocument(id, vm.DivisionId, vm.SiteId);

            if (settings != null)
            {
                if (settings.ImportMenuId != null)
                {
                    MenuViewModel menuviewmodel = new MenuService(_unitOfWork).GetMenu((int)settings.ImportMenuId);

                    if (menuviewmodel == null)
                    {
                        return(View("~/Views/Shared/UnderImplementation.cshtml"));
                    }
                    else if (!string.IsNullOrEmpty(menuviewmodel.URL))
                    {
                        return(Redirect(System.Configuration.ConfigurationManager.AppSettings[menuviewmodel.URL] + "/" + menuviewmodel.ControllerName + "/" + menuviewmodel.ActionName + "/" + id + "?MenuId=" + menuviewmodel.MenuId));
                    }
                    else
                    {
                        return(RedirectToAction(menuviewmodel.ActionName, menuviewmodel.ControllerName, new { MenuId = menuviewmodel.MenuId, id = id }));
                    }
                }
            }
            return(RedirectToAction("Index", new { id = id }));
        }
Exemple #2
0
        // GET: /SaleDeliveryOrderHeader/Create

        public ActionResult Create(int id)
        {
            SaleDeliveryOrderHeaderViewModel p = new SaleDeliveryOrderHeaderViewModel();

            p.DocDate     = DateTime.Now.Date;
            p.DueDate     = DateTime.Now.Date;
            p.DivisionId  = (int)System.Web.HttpContext.Current.Session["DivisionId"];
            p.SiteId      = (int)System.Web.HttpContext.Current.Session["SiteId"];
            p.CreatedDate = DateTime.Now;

            //Getting Settings
            var settings = new SaleDeliveryOrderSettingsService(_unitOfWork).GetSaleDeliveryOrderSettingsForDocument(id, p.DivisionId, p.SiteId);

            if (settings == null && UserRoles.Contains("SysAdmin"))
            {
                return(RedirectToAction("Create", "SaleDeliveryOrderSettings", new { id = id }).Warning("Please create SaleDeliveryOrder settings"));
            }
            else if (settings == null && !UserRoles.Contains("SysAdmin"))
            {
                return(View("~/Views/Shared/InValidSettings.cshtml"));
            }

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

            p.SaleDeliveryOrderSettings = Mapper.Map <SaleDeliveryOrderSettings, SaleDeliveryOrderSettingsViewModel>(settings);
            PrepareViewBag(id);
            p.DocTypeId  = id;
            ViewBag.Mode = "Add";
            p.DocNo      = new DocumentTypeService(_unitOfWork).FGetNewDocNo("DocNo", ConfigurationManager.AppSettings["DataBaseSchema"] + ".SaleDeliveryOrderHeaders", p.DocTypeId, p.DocDate, p.DivisionId, p.SiteId);
            return(View("Create", p));
        }
Exemple #3
0
        public ActionResult Detail(int id, string transactionType, string IndexType)
        {
            ViewBag.transactionType = transactionType;
            ViewBag.IndexStatus     = IndexType;

            SaleDeliveryOrderHeader s = _SaleDeliveryOrderHeaderService.GetSaleDeliveryOrderHeader(id);

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

            //Job Order Settings
            var settings = new SaleDeliveryOrderSettingsService(_unitOfWork).GetSaleDeliveryOrderSettingsForDocument(s.DocTypeId, s.DivisionId, s.SiteId);

            if (settings == null)
            {
                return(RedirectToAction("Create", "SaleDeliveryOrderSettings", new { id = s.DocTypeId }).Warning("Please create SaleDeliveryOrder settings"));
            }

            SaleDeliveryOrderHeaderViewModel svm = Mapper.Map <SaleDeliveryOrderHeader, SaleDeliveryOrderHeaderViewModel>(s);

            svm.SaleDeliveryOrderSettings = Mapper.Map <SaleDeliveryOrderSettings, SaleDeliveryOrderSettingsViewModel>(settings);

            PrepareViewBag(svm.DocTypeId);

            if (String.IsNullOrEmpty(transactionType) || transactionType == "detail")
            {
                LogActivity.LogActivityDetail(LogVm.Map(new ActiivtyLogViewModel
                {
                    DocTypeId    = s.DocTypeId,
                    DocId        = s.SaleDeliveryOrderHeaderId,
                    ActivityType = (int)ActivityTypeContants.Detail,
                    DocNo        = s.DocNo,
                    DocDate      = s.DocDate,
                    DocStatus    = s.Status,
                }));
            }


            return(View("Create", svm));
        }
Exemple #4
0
        // GET: /SaleDeliveryOrderHeader/Edit/5
        private ActionResult Edit(int id, string IndexType)
        {
            ViewBag.IndexStatus = IndexType;

            SaleDeliveryOrderHeader s = _SaleDeliveryOrderHeaderService.GetSaleDeliveryOrderHeader(id);

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

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

            #region DocTypeTimeLineValidation
            try
            {
                TimePlanValidation = DocumentValidation.ValidateDocument(Mapper.Map <DocumentUniqueId>(s), 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 ((!TimePlanValidation && !Continue))
            {
                return(RedirectToAction("DetailInformation", new { id = id, IndexType = IndexType }));
            }
            //Job Order Settings
            var settings = new SaleDeliveryOrderSettingsService(_unitOfWork).GetSaleDeliveryOrderSettingsForDocument(s.DocTypeId, s.DivisionId, s.SiteId);

            if (settings == null && UserRoles.Contains("SysAdmin"))
            {
                return(RedirectToAction("Create", "SaleDeliveryOrderSettings", new { id = s.DocTypeId }).Warning("Please create SaleDeliveryOrder settings"));
            }
            else if (settings == null && !UserRoles.Contains("SysAdmin"))
            {
                return(View("~/Views/Shared/InValidSettings.cshtml"));
            }

            SaleDeliveryOrderHeaderViewModel svm = Mapper.Map <SaleDeliveryOrderHeader, SaleDeliveryOrderHeaderViewModel>(s);
            svm.SaleDeliveryOrderSettings = Mapper.Map <SaleDeliveryOrderSettings, SaleDeliveryOrderSettingsViewModel>(settings);

            PrepareViewBag(s.DocTypeId);
            ViewBag.Mode = "Edit";

            if (!(System.Web.HttpContext.Current.Request.UrlReferrer.PathAndQuery).Contains("Create"))
            {
                LogActivity.LogActivityDetail(LogVm.Map(new ActiivtyLogViewModel
                {
                    DocTypeId    = s.DocTypeId,
                    DocId        = s.SaleDeliveryOrderHeaderId,
                    ActivityType = (int)ActivityTypeContants.Detail,
                    DocNo        = s.DocNo,
                    DocDate      = s.DocDate,
                    DocStatus    = s.Status,
                }));
            }

            return(View("Create", svm));
        }
Exemple #5
0
        public ActionResult HeaderPost(SaleDeliveryOrderHeaderViewModel svm)
        {
            if (svm.DocDate > svm.DueDate)
            {
                ModelState.AddModelError("DueDate", "DueDate cannot be greater than DocDate");
            }

            #region DocTypeTimeLineValidation

            try
            {
                if (svm.SaleDeliveryOrderHeaderId <= 0)
                {
                    TimePlanValidation = DocumentValidation.ValidateDocument(Mapper.Map <DocumentUniqueId>(svm), DocumentTimePlanTypeConstants.Create, User.Identity.Name, out ExceptionMsg, out Continue);
                }
                else
                {
                    TimePlanValidation = DocumentValidation.ValidateDocument(Mapper.Map <DocumentUniqueId>(svm), 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 (svm.SaleDeliveryOrderHeaderId <= 0)
                {
                    SaleDeliveryOrderHeader s = Mapper.Map <SaleDeliveryOrderHeaderViewModel, SaleDeliveryOrderHeader>(svm);

                    s.CreatedDate  = DateTime.Now;
                    s.ModifiedDate = DateTime.Now;
                    s.CreatedBy    = User.Identity.Name;
                    s.ModifiedBy   = User.Identity.Name;
                    s.Status       = (int)StatusConstants.Drafted;
                    _SaleDeliveryOrderHeaderService.Create(s);

                    try
                    {
                        _unitOfWork.Save();
                    }

                    catch (Exception ex)
                    {
                        string message = _exception.HandleException(ex);
                        TempData["CSEXC"] += message;
                        PrepareViewBag(svm.DocTypeId);
                        ViewBag.Mode = "Add";
                        return(View("Create", svm));
                    }

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

                    return(RedirectToAction("Modify", new { id = s.SaleDeliveryOrderHeaderId }).Success("Data saved Successfully"));
                }
                #endregion

                #region EditRecord
                else
                {
                    //string tempredirect = (Request["Redirect"].ToString());
                    List <LogTypeViewModel> LogList = new List <LogTypeViewModel>();

                    SaleDeliveryOrderHeader s         = Mapper.Map <SaleDeliveryOrderHeaderViewModel, SaleDeliveryOrderHeader>(svm);
                    StringBuilder           logstring = new StringBuilder();
                    SaleDeliveryOrderHeader temp      = _SaleDeliveryOrderHeaderService.Find(s.SaleDeliveryOrderHeaderId);

                    SaleDeliveryOrderHeader ExRec = new SaleDeliveryOrderHeader();
                    ExRec = Mapper.Map <SaleDeliveryOrderHeader>(temp);

                    int status = temp.Status;

                    if (temp.Status != (int)StatusConstants.Drafted && temp.Status != (int)StatusConstants.Import)
                    {
                        temp.Status = (int)StatusConstants.Modified;
                    }

                    temp.DocDate      = s.DocDate;
                    temp.DocNo        = s.DocNo;
                    temp.Priority     = s.Priority;
                    temp.ShipMethodId = s.ShipMethodId;
                    temp.ShipAddress  = s.ShipAddress;
                    temp.Remark       = s.Remark;
                    temp.DueDate      = s.DueDate;
                    temp.ModifiedDate = DateTime.Now;
                    temp.ModifiedBy   = User.Identity.Name;
                    _SaleDeliveryOrderHeaderService.Update(temp);

                    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;
                        PrepareViewBag(svm.DocTypeId);
                        ViewBag.Mode = "Edit";
                        return(View("Create", svm));
                    }

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

                    return(RedirectToAction("Index", new { id = svm.DocTypeId }).Success("Data saved successfully"));
                }
                #endregion
            }
            PrepareViewBag(svm.DocTypeId);
            ViewBag.Mode = "Add";
            return(View("Create", svm));
        }