Ejemplo n.º 1
0
        //id=productdetailid
        public ActionResult CreatePrePackStock(int id)
        {
            var pd = db.tblProductDetail.Find(id);
            var pm = db.tblProductMaster.Find(pd.ProductMasterID);
            var cl = db.tblClient.Find(pm.ClientID);

            PrePackStock vm = new PrePackStock();

            vm.ProductDetailID = id;
            vm.BulkContainer = new BulkContainerViewModel();
            vm.BulkContainer.logofilename = cl.LogoFileName;
            vm.BulkContainer.bulkid = -1;
            vm.BulkContainer.receivedate = System.DateTime.Now;
            vm.BulkContainer.warehouse = cl.CMCLocation;
            vm.BulkContainer.lotnumber = "lotnumber";
            vm.BulkContainer.mfgdate = System.DateTime.Now;
            vm.BulkContainer.clientid = pm.ClientID;
            vm.BulkContainer.productmasterid = pm.ProductMasterID;
            vm.BulkContainer.bulkstatus = "AVAIL";
            vm.ProductCode = pd.ProductCode;
            vm.ProductName = pd.ProductName;
            vm.BulkContainer.bin = "PREPACK";
            vm.ListOfShelfMasterIDs = (from t in db.tblShelfMaster
                                       where t.ProductDetailID == id && t.Discontinued == false
                                       select new ShelfMasterViewModel
                                       {
                                           shelfid = t.ShelfID,
                                           productdetailid = t.ProductDetailID,
                                           bin = t.Bin,
                                           size = t.Size
                                       }).ToList();

            vm.ShelfMasterCount = vm.ListOfShelfMasterIDs.Count();

            return View("~/Views/Inventory/PrePackStock.cshtml", vm);
        }
Ejemplo n.º 2
0
        public static void fnSavePrePackStock(PrePackStock vm, FormCollection fc)
        {
            using (var db = new CMCSQL03Entities())
            {
                // for each sm, insert tblStock
                vm.BulkContainer.bulkid = fnNewBulkID();

                var dbBulk = db.tblBulk.Find(vm.BulkContainer.bulkid);
                var dbPD = db.tblProductDetail.Find(vm.ProductDetailID);

                dbBulk.ProductMasterID = dbPD.ProductMasterID;
                dbBulk.Qty = 1;
                dbBulk.ReceiveDate = vm.BulkContainer.receivedate;
                dbBulk.LotNumber = vm.BulkContainer.lotnumber;
                dbBulk.MfgDate = vm.BulkContainer.mfgdate;
                dbBulk.ExpirationDate = vm.BulkContainer.expirationdate;
                dbBulk.CeaseShipDate = vm.BulkContainer.ceaseshipdate;
                dbBulk.QCDate = vm.BulkContainer.qcdate;
                dbBulk.BulkStatus = vm.BulkContainer.bulkstatus;
                dbBulk.Bin = vm.BulkContainer.bin;
                dbBulk.Warehouse = vm.BulkContainer.warehouse;
                dbBulk.CreateDate = System.DateTime.Now;
                dbBulk.CreateUser = System.Web.HttpContext.Current.User.Identity.Name;
                dbBulk.ReceiveWeight = 0;
                dbBulk.CurrentWeight = 0;

                for (int i = 1; i <= vm.ShelfMasterCount; i++)
                {
                    // this will always have a value
                    string sThisShelfID = fc["Key" + i.ToString()];
                    Int32 ThisShelfID = Convert.ToInt32(sThisShelfID);

                    string sThisQty = fc["Value" + i.ToString()];
                    if (!String.IsNullOrEmpty(sThisQty))
                    {
                        Int32 ThisQty = Convert.ToInt32(sThisQty);
                        var newstock = new EF.tblStock();
                        newstock.ShelfID = ThisShelfID;
                        newstock.BulkID = vm.BulkContainer.bulkid;
                        newstock.Warehouse = vm.BulkContainer.warehouse;
                        newstock.QtyOnHand = ThisQty;

                        var sm = (from t in db.tblShelfMaster
                                  where t.ShelfID == ThisShelfID
                                  select t).FirstOrDefault();   // needed for default bin

                        dbBulk.ReceiveWeight = dbBulk.ReceiveWeight + (ThisQty * sm.UnitWeight);
                        newstock.Bin = sm.Bin;
                        newstock.ShelfStatus = "AVAIL";
                        newstock.CreateDate = DateTime.Now;
                        newstock.CreateUser = HttpContext.Current.User.Identity.Name;
                        db.tblStock.Add(newstock);

                        db.SaveChanges();
                    }
                }
            }
        }
Ejemplo n.º 3
0
        public ActionResult SavePrePackStock(PrePackStock vm, FormCollection fc)
        {
            Services.InventoryService.fnSavePrePackStock(vm, fc);

            return RedirectToAction("Edit", new { id = vm.ProductDetailID });
        }