Ejemplo n.º 1
0
 public ActionResult EnterPrePack(FormCollection fc)
 {
     // Take clientid and productdetailid from POST and build ViewModel, return data entry view
     int fc_clientid = Convert.ToInt32(fc["ClientID"]);
     int fc_productdetailid = Convert.ToInt32(fc["productdetailid"]);
     PrePackViewModel obj = new PrePackViewModel();
     obj = ReceivingService.fnNewBulkContainerForPrePack(fc_clientid, fc_productdetailid);
     return View("~/Views/Receiving/EnterPrePack.cshtml", obj);
 }
Ejemplo n.º 2
0
        public static bool fnSavePrePack(PrePackViewModel vm, FormCollection fc)
        {
            bool retval = true;
            try
            {
                using (var db = new EF.CMCSQL03Entities())
                {
                    var newbulk = new EF.tblBulk();
                    newbulk.ProductMasterID = vm.productmasterid; newbulk.ReceiveDate = vm.receivedate; newbulk.LotNumber = vm.lotnumber;
                    newbulk.CeaseShipDate = vm.ceaseshipdate; newbulk.Carrier = vm.carrier; newbulk.ReceivedBy = vm.receivedby;
                    newbulk.QCDate = vm.qcdate; newbulk.Warehouse = vm.warehouse; newbulk.MfgDate = vm.mfgdate;
                    newbulk.COAIncluded = vm.coaincluded; newbulk.EnteredBy = vm.enteredby; newbulk.ExpirationDate = vm.expirationdate;
                    newbulk.MSDSIncluded = vm.msdsincluded; newbulk.BulkStatus = "PP";
                    db.tblBulk.Add(newbulk);
                    db.SaveChanges();
                    int newBulkID = newbulk.BulkID;

                    for (int i = 1; i <= vm.ItemsCount; i++)
                    {
                        string sThisShelfID = fc["Key" + i.ToString()];
                        int ThisShelfID = Convert.ToInt32(sThisShelfID);

                        string sThisQty = fc["Value" + i.ToString()];
                        int ThisQty = Convert.ToInt32(sThisQty);

                        //System.Diagnostics.Debug.WriteLine("Shelfid=" + ThisShelfID + " | Qty=" + ThisQty);
                        var newstock = new EF.tblStock();
                        newstock.BulkID = newBulkID; newstock.ShelfID = ThisShelfID; newstock.CreateDate = DateTime.Now;
                        newstock.Warehouse = vm.warehouse; newstock.QtyOnHand = ThisQty; //newStock.Bin = null; // ???
                        newstock.ShelfStatus = "PP";
                        db.tblStock.Add(newstock);
                        db.SaveChanges();
                    }
                }
            }
            catch
            {
                retval = false;
                throw new Exception("Error occurred saving Pre Packs");
            }

            return retval;
        }
Ejemplo n.º 3
0
        public static PrePackViewModel fnNewBulkContainerForPrePack(int clientid, int productdetailid)
        {
            PrePackViewModel obj = new PrePackViewModel();
            using (var db = new CMCSQL03Entities())
            {
                var dbClient = db.tblClient.Find(clientid);
                var dbProductDetail = db.tblProductDetail.Find(productdetailid);

                obj.productmasterid = dbProductDetail.ProductMasterID;
                obj.isknownmaterial = true;
                obj.clientid = clientid;
                obj.clientname = dbClient.ClientName;
                obj.logofilename = dbClient.LogoFileName;
                obj.bulkid = -1;    // for insert later
                obj.receivedate = DateTime.Now;
                obj.carrier = null;
                obj.ListOfCarriers = fnCarriers();
                obj.warehouse = null;
                obj.ListOfWareHouses = fnWarehouseIDs();
                obj.enteredby = null;
                obj.lotnumber = null;
                obj.receivedby = null;
                obj.mfgdate = null;
                obj.expirationdate = null;
                obj.ceaseshipdate = null;
                obj.qcdate = null;
                obj.msdsincluded = null;
                obj.coaincluded = null;

                obj.productcode = dbProductDetail.ProductCode;
                obj.productname = dbProductDetail.ProductName;

                obj.ListOfShelfMasters = (from t in db.tblShelfMaster
                                          orderby t.ShelfID
                                          where t.ProductDetailID == productdetailid
                                          select new ItemForPrePackViewModel { shelfid = t.ShelfID, size = t.Size, bin = t.Bin }).ToList();
                obj.ItemsCount = obj.ListOfShelfMasters.Count();
                return obj;
            }
        }
Ejemplo n.º 4
0
 public ActionResult SavePrePack(PrePackViewModel vm, FormCollection fc)
 {
     bool bSave = ReceivingService.fnSavePrePack(vm, fc);
     return Content("Items Added to Shelf Stock: " + DateTime.Now.ToString());
 }