Пример #1
0
 public ActionResult Edit([Bind(Include = "ID,PlantID,QCTechUserID,RawMaterialID,RawMaterialLotID,VisualInspection,SpecGrav,ColorCoA,ColorFS,MFCoA,MFFS,ACCoA,ACFS,MoistCoA,MoistFS,CBCoA,CBFS,BoxCarTested,Comments,DateEntered,EnteredBy,LastModified,ModifiedBy")] RawMaterialQC rawmaterialqc)
 {
     if (ModelState.IsValid)
     {
         db.Entry(rawmaterialqc).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     ViewBag.PlantID      = new SelectList(db.Plants, "ID", "Code", rawmaterialqc.PlantID);
     ViewBag.QCTechUserID = new SelectList(db.Users, "ID", "Username", rawmaterialqc.QCTechUserID);
     return(View(rawmaterialqc));
 }
 public ActionResult Edit([Bind(Include = "ID,PlantID,RawMaterialID,UseColorTest,ColorLimitTypeID,ColorLimit1,ColorLimit2,UseMFTest,MFLimitTypeID,MFLimit1,MFLimit2,UseACTest,ACLimitTypeID,ACLimit1,ACLimit2,UseMoistTest,MoistLimitTypeID,MoistLimit1,MoistLimit2,UseCBTest,CBLimitTypeID,CBLimit1,CBLimit2,UseSpecGrav,UseVisual,TestFrequency,DateEntered,EnteredBy,LastModified,ModifiedBy")] RawMaterialTest rawmaterialtest)
 {
     if (ModelState.IsValid)
     {
         db.Entry(rawmaterialtest).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     ViewBag.PlantID          = new SelectList(db.Plants, "ID", "Code", rawmaterialtest.PlantID);
     ViewBag.ACLimitTypeID    = new SelectList(db.TestLimitTypes, "ID", "Code", rawmaterialtest.ACLimitTypeID);
     ViewBag.CBLimitTypeID    = new SelectList(db.TestLimitTypes, "ID", "Code", rawmaterialtest.CBLimitTypeID);
     ViewBag.ColorLimitTypeID = new SelectList(db.TestLimitTypes, "ID", "Code", rawmaterialtest.ColorLimitTypeID);
     ViewBag.MFLimitTypeID    = new SelectList(db.TestLimitTypes, "ID", "Code", rawmaterialtest.MFLimitTypeID);
     ViewBag.MoistLimitTypeID = new SelectList(db.TestLimitTypes, "ID", "Code", rawmaterialtest.MoistLimitTypeID);
     return(View(rawmaterialtest));
 }
 public void Update(RawMaterialQCRedHoldDTO dto)
 {
     try
     {
         using (var context = new TPOMVCApplicationEntities())
         {
             var toUpdate = context.RawMaterialQCRedHolds.Find(dto.ID);
             toUpdate.RawMaterialQCID       = dto.RawMaterialQCID;
             toUpdate.PlantID               = dto.PlantID;
             toUpdate.RawMaterialReceivedID = dto.RawMaterialReceivedID;
             toUpdate.QCTechID              = dto.QCTechID;
             toUpdate.SupervisorID          = dto.SupervisorID;
             toUpdate.LeadOperatorID        = dto.LeadOperatorID;
             toUpdate.RedDate               = dto.RedDate;
             toUpdate.FailPropertyID        = dto.FailPropertyID;
             toUpdate.Zone                 = dto.Zone;
             toUpdate.RedComments          = dto.RedComments;
             toUpdate.RedCorrectionAction  = dto.RedCorrectionAction;
             toUpdate.HoldDate             = dto.HoldDate;
             toUpdate.HoldLotNumber        = dto.HoldLotNumber;
             toUpdate.HoldComments         = dto.HoldComments;
             toUpdate.ManagerID            = dto.ManagerID;
             toUpdate.ManagerDate          = dto.ManagerDate;
             toUpdate.ManagerComments      = dto.ManagerComments;
             toUpdate.PrimeBoxCar          = dto.PrimeBoxCar;
             toUpdate.PrimeUOM             = dto.PrimeUOM;
             toUpdate.ReworkBoxCar         = dto.ReworkBoxCar;
             toUpdate.ReworkUOM            = dto.ReworkUOM;
             toUpdate.ScrapBoxCar          = dto.ScrapBoxCar;
             toUpdate.ScrapUOM             = dto.ScrapUOM;
             toUpdate.DateEntered          = dto.DateEntered ?? DateTime.Now;
             toUpdate.EnteredBy            = dto.EnteredBy;
             toUpdate.LastModified         = dto.LastModified ?? DateTime.Now;
             toUpdate.ModifiedBy           = dto.ModifiedBy;
             context.Entry(toUpdate).State = EntityState.Modified;
             context.SaveChanges();
         }
     }
     catch (Exception ex)
     {
         throw;
     }
 }
        public void Update(CurrentRawMaterialDTO dto)
        {
            try
            {
                using (var context = new TPOMVCApplicationEntities())
                {
                    var toUpdate = context.TPOCurrentRawMaterials.Find(dto.Id);

                    toUpdate.LineID  = dto.LineId;
                    toUpdate.PlantID = dto.PlantId;
                    // do not allow edit to initial data
                    //toUpdate.DateEntered = dto.DateEntered;
                    //if (!string.IsNullOrWhiteSpace(dto.EnteredBy))
                    //{
                    //    toUpdate.EnteredBy = dto.EnteredBy;
                    //}
                    if (!string.IsNullOrWhiteSpace(dto.ModifiedBy))
                    {
                        toUpdate.ModifiedBy = dto.ModifiedBy;
                    }
                    toUpdate.LastModified = DateTime.Now;

                    toUpdate.Plant = context.Plants.Where(p => p.ID == dto.PlantId).FirstOrDefault();

                    toUpdate.RawMaterialReceivedID = dto.RawMaterialReceivedId;
                    toUpdate.RawMaterialReceived   =
                        context.RawMaterialReceiveds.Where(m => m.ID == dto.RawMaterialReceivedId).FirstOrDefault();

                    context.Entry(toUpdate).State = EntityState.Modified;
                    context.SaveChanges();
                }
            }
            catch (Exception ex)
            {
                throw;
            }
        }