// GET: /PackingHeader/Create

        public ActionResult Create()
        {
            PackingHeaderViewModel p = new PackingHeaderViewModel();

            p.DocDate      = DateTime.Now.Date;
            p.CreatedDate  = DateTime.Now;
            p.DivisionId   = (int)System.Web.HttpContext.Current.Session["DivisionId"];
            p.SiteId       = (int)System.Web.HttpContext.Current.Session["SiteId"];
            p.DocNo        = _PackingHeaderService.GetMaxDocNo();
            p.ShipMethodId = new ShipMethodService(_unitOfWork).Find("By Sea").ShipMethodId;

            int DocTypeId = 0;
            var DocType   = new DocumentTypeService(_unitOfWork).GetDocumentTypeList(TransactionDocCategoryConstants.PackingReceive).FirstOrDefault();

            if (DocType != null)
            {
                DocTypeId = DocType.DocumentTypeId;
            }

            //Getting Settings
            var settings = new PackingSettingService(_unitOfWork).GetPackingSettingForDocument(DocTypeId, p.DivisionId, p.SiteId);

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

            PrepareViewBag(p);
            ViewBag.Mode = "Add";
            return(View(p));
        }
Esempio n. 2
0
        // GET: /PackingHeader/Create

        public ActionResult Create()
        {
            PackingHeaderViewModel p = new PackingHeaderViewModel();

            p.DocDate      = DateTime.Now.Date;
            p.CreatedDate  = DateTime.Now;
            p.DivisionId   = (int)System.Web.HttpContext.Current.Session["DivisionId"];
            p.SiteId       = (int)System.Web.HttpContext.Current.Session["SiteId"];
            p.DocNo        = _PackingHeaderService.GetMaxDocNo();
            p.ShipMethodId = new ShipMethodService(_unitOfWork).Find("By Sea").ShipMethodId;

            DocumentType   DT   = new DocumentTypeService(_unitOfWork).FindByName("Packing Receive");
            PackingSetting temp = new PackingSettingService(_unitOfWork).GetPackingSettingForDocument(DT.DocumentTypeId, p.DivisionId, p.SiteId);

            p.PackingSettings = Mapper.Map <PackingSetting, PackingSettingsViewModel>(temp);

            if (System.Web.HttpContext.Current.Session["DefaultGodownId"] != null)
            {
                p.GodownId = (int)System.Web.HttpContext.Current.Session["DefaultGodownId"];
            }

            PrepareViewBag(p);
            ViewBag.Mode = "Add";
            return(View(p));
        }