示例#1
0
 public ActionResult Save(BulkContainerViewModel obj)
 {
     // WIP
     bool bUpdate = BulkService.fnSaveBulk(obj);
     TempData["SaveResult"] = "Bulk Container Saved at " + System.DateTime.Now.ToString();
     return RedirectToAction("Edit", new { id = obj.bulkid });
 }
 public ActionResult EditContainerReceipt(int id)
 {
     // id = bulkid .. Lookup row in DB and load the edit view
     BulkContainerViewModel obj = new BulkContainerViewModel();
     obj = ReceivingService.fnFillBulkContainerFromDB(id);
     return View("~/Views/Receiving/Edit.cshtml", obj);
 }
 public ActionResult CreateContainerReceipt(int id)
 {
     // id = productmasterid .. Build a new viewmodel of a bulk container and load the edit view
     BulkContainerViewModel obj = new BulkContainerViewModel();
     obj = ReceivingService.fnNewBulkContainer(id);
     return View("~/Views/Receiving/Edit.cshtml", obj);
 }
        public ActionResult SaveContainer(BulkContainerViewModel bc)
        {
            // Update a tblBulk record from a BulkContainerViewModel
            bool bUpdate;
            switch (bc.isknownmaterial)
            {
                case true:
                    bUpdate = ReceivingService.fnSaveBulkContainerKnown(bc);
                    break;

                case false:
                    bUpdate = ReceivingService.fnSaveBulkContainerUnKnown(bc);
                    break;

                default:
                    return RedirectToAction("Index");
            }

            return RedirectToAction("Index");
        }
示例#5
0
 public ActionResult Edit(int id)
 {
     BulkContainerViewModel obj = new BulkContainerViewModel();
     obj = BulkService.fnFillBulkContainerFromDB(id);
     return View("~/Views/Bulk/Edit.cshtml", obj);
 }
示例#6
0
        public static bool fnSaveBulk(BulkContainerViewModel incoming)
        {
            bool retval = true;
            try
            {
                using (var db = new EF.CMCSQL03Entities())
                {
                    int pk = incoming.bulkid;
                    if (incoming.bulkid == -1)
                    {
                        var newrec = new EF.tblBulk { ProductMasterID = incoming.productmasterid };
                        db.tblBulk.Add(newrec);
                        newrec.CreateDate = System.DateTime.Now;
                        newrec.CreateUser = HttpContext.Current.User.Identity.Name;
                        db.SaveChanges();
                        pk = newrec.BulkID;
                    }

                    var qry = (from t in db.tblBulk where t.BulkID == pk select t).FirstOrDefault();
                    qry.Warehouse = incoming.warehouse;
                    qry.ReceiveDate = incoming.receivedate;
                    qry.Carrier = incoming.carrier;
                    qry.ReceivedBy = incoming.receivedby;
                    qry.EnteredBy = incoming.enteredby;
                    qry.ProductMasterID = incoming.productmasterid;
                    qry.ReceiveWeight = incoming.receiveweight;
                    qry.LotNumber = incoming.lotnumber;
                    qry.MfgDate = incoming.mfgdate;
                    qry.ExpirationDate = incoming.expirationdate;
                    qry.CeaseShipDate = incoming.ceaseshipdate;
                    qry.BulkStatus = incoming.bulkstatus;
                    qry.UM = incoming.um;
                    qry.ContainerColor = incoming.containercolor;
                    qry.Bin = incoming.bin;
                    qry.ContainerType = incoming.containertype;
                    qry.COAIncluded = incoming.coaincluded;
                    qry.MSDSIncluded = incoming.msdsincluded;
                    qry.ContainerNotes = incoming.containernotes;
                    qry.CurrentWeight = incoming.currentweight;
                    qry.QCDate = incoming.qcdate;
                    qry.ReturnLocation = incoming.returnlocation;
                    qry.NoticeDate = incoming.noticedate;
                    qry.BulkLabelNote = incoming.bulklabelnote;
                    qry.ReceivedAsCode = incoming.receivedascode;
                    qry.ReceivedAsName = incoming.receivedasname;
                    qry.OtherStorage = incoming.otherstorage;
                    qry.UpdateDate = System.DateTime.Now;
                    qry.UpdateUser = HttpContext.Current.User.Identity.Name;
                    db.SaveChanges();
                    retval = true;
                }
            }
            catch
            {
                retval = false;
                throw new Exception("Error occurred saving Bulk Container");
                //System.Diagnostics.Debug.WriteLine(ex.Message);
                //retval = false;
            }
            return retval;
        }
 public static bool fnSaveBulkContainerUnKnown(BulkContainerViewModel incoming)
 {
     // creation of tblBulkUnKnown // This is an INSERT only routine
     bool retval = true;
     try
     {
         using (var db = new EF.CMCSQL03Entities())
         {
             var newitem = new EF.tblBulkUnKnown
             {
                 //IsKnownMaterial = incoming.isknownmaterial,
                 ProductMasterID = incoming.productmasterid,
                 Warehouse = incoming.warehouse,
                 ReceiveDate = incoming.receivedate,
                 Carrier = incoming.carrier,
                 ReceivedBy = incoming.receivedby,
                 EnteredBy = incoming.enteredby,
                 ReceiveWeight = incoming.receiveweight,
                 LotNumber = incoming.lotnumber,
                 MfgDate = incoming.mfgdate,
                 ExpirationDate = incoming.expirationdate,
                 CeaseShipDate = incoming.ceaseshipdate,
                 BulkStatus = incoming.bulkstatus,
                 UM = incoming.um,
                 ContainerColor = incoming.containercolor,
                 Bin = incoming.bin,
                 ContainerType = incoming.containertype,
                 COAIncluded = incoming.coaincluded,
                 MSDSIncluded = incoming.msdsincluded,
                 ContainerNotes = incoming.containernotes,
                 CurrentWeight = incoming.currentweight,
                 QCDate = incoming.qcdate,
                 ReturnLocation = incoming.returnlocation,
                 NoticeDate = incoming.noticedate,
                 BulkLabelNote = incoming.bulklabelnote,
                 ReceivedAsCode = incoming.receivedascode,
                 ReceivedAsName = incoming.receivedasname
             };
             db.tblBulkUnKnown.Add(newitem);
             db.SaveChanges();
             retval = true;
         }
     }
     catch
     {
         retval = false;
     }
     return retval;
 }
 public static BulkContainerViewModel fnNewBulkContainerUnKnown()
 {
     // id=productmasterid
     BulkContainerViewModel obj = new BulkContainerViewModel();
     using (var db = new CMCSQL03Entities())
     {
         obj.isknownmaterial = false;
         obj.productmasterid = null;
         obj.bulkid = -1;    // for insert later
         obj.clientid = null;
         obj.clientname = null;
         obj.logofilename = null;
         obj.productmasterid = null;
         obj.receivedate = DateTime.Now;
         obj.bulkstatus = "RECD";
         obj.MasterCode = null;
         obj.MasterName = null;
         obj.ListOfWareHouses = fnWarehouseIDs();
         obj.ListOfProductMasters = fnProductMasterIDs(obj.clientid, null);
         obj.ListOfBulkStatusIDs = fnBulkStatusIDs();
         obj.ListOfContainerTypeIDs = fnContainerTypeIDs();
         obj.ListOfCarriers = fnCarriers();
         return obj;
     }
 }
        // ************** TODO ***************************
        // Finish adding all properties to next 2
        // ************** TODO ***************************
        public static BulkContainerViewModel fnNewBulkContainer(int id)
        {
            // id=productmasterid
            BulkContainerViewModel obj = new BulkContainerViewModel();
            using (var db = new CMCSQL03Entities())
            {
                obj.isknownmaterial = true;

                var x = (from t in db.tblBulk where t.ProductMasterID == id select t).ToList();
                obj.pm_sumofcurrentweight = 0;
                foreach (var row in x)
                {
                    obj.pm_sumofcurrentweight = obj.pm_sumofcurrentweight + row.CurrentWeight;
                }

                var dbPM = db.tblProductMaster.Find(id);
                // assign ProductMaster fields for R/O
                obj.pm_MasterNotes = dbPM.MasterNotes;
                obj.pm_HandlingOther = dbPM.HandlingOther;
                obj.pm_OtherHandlingInstr = dbPM.OtherHandlingInstr;
                obj.pm_refrigerate = dbPM.Refrigerate;
                obj.pm_flammablestorageroom = dbPM.FlammableStorageRoom;
                obj.pm_freezablelist = dbPM.FreezableList;
                obj.pm_refrigeratedlist = dbPM.RefrigeratedList;

                //var qCL = (from t in db.tblClient where t.ClientID == qPM.ClientID select t).FirstOrDefault();
                var dbClient = db.tblClient.Find(dbPM.ClientID);

                obj.bulkid = -1;    // for insert later
                obj.clientid = dbClient.ClientID;
                obj.warehouse = dbClient.CMCLocation;
                obj.clientname = dbClient.ClientName;
                obj.logofilename = dbClient.LogoFileName;
                obj.productmasterid = id;
                obj.receivedate = DateTime.Now;
                obj.bulkstatus = "RECD";

                obj.ListOfWareHouses = fnWarehouseIDs();
                obj.ListOfProductMasters = fnProductMasterIDs(obj.clientid, id);
                obj.ListOfBulkStatusIDs = fnBulkStatusIDs();
                obj.ListOfContainerTypeIDs = fnContainerTypeIDs();
                obj.ListOfCarriers = fnCarriers();

                // R/O fields from PM
                obj.MasterCode = dbPM.MasterCode;
                obj.MasterName = dbPM.MasterName;
                obj.flammable = dbPM.Flammable;
                obj.freezer = dbPM.FREEZERSTORAGE;
                obj.refrigerated = dbPM.Refrigerate;
                obj.packout = dbPM.PackOutOnReceipt;

                return obj;
            }
        }
 public ActionResult SetupReceiveUnKnown()
 {
     // Load view to receive unknown bulk material
     BulkContainerViewModel obj = new BulkContainerViewModel();
     obj = ReceivingService.fnNewBulkContainerUnKnown();
     return View("~/Views/Receiving/Edit.cshtml", obj);
 }