Пример #1
0
        public ActionResult DeleteConfirmed(int id)
        {
            BomLevel1 bomLevel1 = db.BomLevel1s.Find(id);

            db.BomLevel1s.Remove(bomLevel1);
            db.SaveChanges();
            return(RedirectToAction("Search"));
        }
Пример #2
0
 public ActionResult Edit([Bind(Include = "BomLevel1Id,BomNo,UnitNo,DetailPn,Description,QtyPer,Qoh")] BomLevel1 bomLevel1)
 {
     if (ModelState.IsValid)
     {
         db.Entry(bomLevel1).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Search"));
     }
     return(View(bomLevel1));
 }
Пример #3
0
        public ActionResult Create([Bind(Include = "BomLevel1Id,BomNo,UnitNo,DetailPn,Description,QtyPer,Qoh")] BomLevel1 bomLevel1)
        {
            if (ModelState.IsValid)
            {
                db.BomLevel1s.Add(bomLevel1);
                db.SaveChanges();
                return(RedirectToAction("Search"));
            }

            return(View("Search", bomLevel1));
            //return View(bomLevel1);
        }
Пример #4
0
        // GET: BomLevel1/Details/5
        public ActionResult Details(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            BomLevel1 bomLevel1 = db.BomLevel1s.Find(id);

            if (bomLevel1 == null)
            {
                return(HttpNotFound());
            }
            return(View(bomLevel1));
        }
Пример #5
0
        public ActionResult ProcessBuild(DateTime builddate, int buildqty, string Pn, string WoNo, byte contractor)
        {
            //Initial boms to hold all current parts in bom table
            List <BomLevel1> boms = new List <BomLevel1>();

            //put all parts in current bom table into an in memory list
            boms = db.BomLevel1s.ToList();

            List <BomLevel1> selectboms = new List <BomLevel1>();

            BomLevel1 dpn = new BomLevel1();

            //create a list of parts in bom
            foreach (BomLevel1 a in boms)
            {
                if (a.UnitNo == Pn)
                {
                    dpn.BomNo          = a.BomNo;
                    dpn.UnitNo         = a.UnitNo;
                    dpn.DetailPn       = a.DetailPn;
                    dpn.Description    = a.Description;
                    dpn.PurchaseMake   = a.PurchaseMake;
                    dpn.PartType       = a.PartType;
                    dpn.PartTypeDetail = a.PartTypeDetail;
                    dpn.QtyPer         = a.QtyPer;

                    selectboms.Add(dpn);
                }
            }

            //Initialize build table to add built part into WoBuilds
            WoBuild build = new WoBuild();

            //Initialize build table to subtract out level 1 parts in WoBuilds
            WoBuild takeout = new WoBuild();

            //build the part and add it to WoBuilds
            if (boms.Any(i => i.UnitNo == Pn))
            {
                //add the built part to be assembled
                //build.WoEnterDateTime = TimeZoneInfo.ConvertTime(DateTime.Now, TimeZoneInfo.FindSystemTimeZoneById("Central Standard Time"));
                build.WoEnterDateTime = builddate;
                build.ContractorId    = contractor;
                build.WoNo            = WoNo;
                build.CustomerPn      = Pn;
                build.Qty             = buildqty;
                build.Notes           = null;

                db.WoBuilds.Add(build);
                db.SaveChanges();

                //take out parts that were used to build assembly
                foreach (BomLevel1 b in boms)
                {
                    if (b.UnitNo == Pn)
                    {
                        //takeout.WoEnterDateTime = TimeZoneInfo.ConvertTime(DateTime.Now, TimeZoneInfo.FindSystemTimeZoneById("Central Standard Time"));
                        takeout.WoEnterDateTime = builddate;
                        takeout.ContractorId    = contractor;
                        takeout.WoNo            = WoNo;
                        takeout.CustomerPn      = b.DetailPn;
                        takeout.Qty             = (b.QtyPer * -buildqty);
                        takeout.Notes           = null;

                        db.WoBuilds.Add(takeout);
                        db.SaveChanges();
                    }
                }

                /*
                 * //Initialize build table to subtract out level 2 (or other sublevel) parts in WoBuilds
                 * WoBuild takeout1 = new WoBuild();
                 *
                 * //take out sub part numbers
                 * foreach (BomLevel1 c in boms)
                 * {
                 *
                 *  foreach (BomLevel1 d in selectboms)
                 *  {
                 *
                 *      if (c.UnitNo == d.DetailPn)
                 *      {
                 *          //takeout1.WoEnterDateTime = TimeZoneInfo.ConvertTime(DateTime.Now, TimeZoneInfo.FindSystemTimeZoneById("Central Standard Time"));
                 *          takeout1.WoEnterDateTime = builddate;
                 *          takeout1.ContractorId = contractor;
                 *          takeout1.WoNo = WoNo;
                 *          takeout1.CustomerPn = c.DetailPn;
                 *          takeout1.Qty = (c.QtyPer * -buildqty);
                 *          takeout1.Notes = null;
                 *
                 *          db.WoBuilds.Add(takeout1);
                 *          db.SaveChanges();
                 *      }
                 *
                 *  }
                 * }*/
                return(null);
            }
            else
            {
                ViewBag.Message = "BOM does not exist.  Please create.";
                return(null);
            }
        }