Beispiel #1
0
        public ActionResult EnterReferenceOrder(string postingType)
        {
            // Initialize viewModel object
            var viewModel = new EnterOrderViewModel()
            {
                PostingTypeID = postingType,
                OrderID       = 0
            };

            return(View("EnterOrderForm", viewModel));
        }
Beispiel #2
0
        public ActionResult New(EnterOrderViewModel eoViewModel)
        {
            // Define view model object
            var viewModel = new StockPostingViewModel();
            List <StockPosting_Item> spItems  = new List <StockPosting_Item>();
            StockPosting_Header      spHeader = new StockPosting_Header();
            StockPosting_Item        spItem   = null;

            switch (eoViewModel.PostingTypeID)
            {
            // Work Order GI
            case ConstantsDefintion.GOOD_ISSUE_WORK_ORDER:

                // Based on Work order items
                var woItems = _context.WO_Items.Where(w => w.WO_HeaderID == eoViewModel.OrderID).ToList();



                // Based on WO item list, initialize stock posting items

                foreach (var item in woItems)
                {
                    spItem            = new StockPosting_Item();
                    spItem.MaterialID = item.MaterialID;
                    spItem.Quantity   = item.Quantity;

                    spItems.Add(spItem);
                }

                // Inistialize stock posting header
                spHeader.ReferenceOrderID = eoViewModel.OrderID;
                spHeader.DateCreated      = DateTime.Now;
                spHeader.PostingTypeID    = byte.Parse(eoViewModel.PostingTypeID);



                // Initialize viewModel object

                viewModel.StockPosting_Header = spHeader;
                viewModel.StockPosting_Items  = spItems;


                viewModel.Products     = _context.Materials.Where(m => m.MaterialTypeID == MaterialType.FinishedProduct).ToList();
                viewModel.RawMaterials = _context.Materials.Where(m => m.MaterialTypeID == MaterialType.RawMaterial).ToList();

                viewModel.PostingTypes = _context.PostingTypes.ToList();

                break;

            // Work Order GR
            case ConstantsDefintion.GOOD_RECEIPT_WORK_ORDER:

                // Based on Work order Header, initialize stock posting item
                var woHeader = _context.WO_Headers.Where(w => w.ID == eoViewModel.OrderID).Single();


                spItem            = new StockPosting_Item();
                spItem.MaterialID = woHeader.ProductID;
                spItem.Quantity   = woHeader.Quantity;

                spItems.Add(spItem);


                // Inistialize stock posting header

                spHeader.ReferenceOrderID = eoViewModel.OrderID;
                spHeader.DateCreated      = DateTime.Now;
                spHeader.PostingTypeID    = byte.Parse(eoViewModel.PostingTypeID);



                // Initialize viewModel object

                viewModel.StockPosting_Header = spHeader;
                viewModel.StockPosting_Items  = spItems;


                viewModel.Products     = _context.Materials.Where(m => m.MaterialTypeID == MaterialType.FinishedProduct).ToList();
                viewModel.RawMaterials = _context.Materials.Where(m => m.MaterialTypeID == MaterialType.RawMaterial).ToList();

                viewModel.PostingTypes = _context.PostingTypes.ToList();

                break;

            default:
                break;
            }

            return(View("StockPostingForm", viewModel));
        }