public ActionResult Create([Bind(Include = "ID,Code,Name,DateEntered,EnteredBy,LastModified,ModifiedBy")] Plant plant) { if (ModelState.IsValid) { db.Plants.Add(plant); db.SaveChanges(); return(RedirectToAction("Index")); } return(View(plant)); }
public ActionResult Create([Bind(Include = "ID,Code,Description,SortOrder,DateEntered,EnteredBy,LastModified,ModifiedBy")] FailProperty failproperty) { if (ModelState.IsValid) { db.FailProperties.Add(failproperty); db.SaveChanges(); return(RedirectToAction("Index")); } return(View(failproperty)); }
public ActionResult Create([Bind(Include = "ID,Code,Description,SortOrder,DateEntered,EnteredBy,LastModified,ModifiedBy")] ProductionShiftType productionshifttype) { if (ModelState.IsValid) { db.ProductionShiftTypes.Add(productionshifttype); db.SaveChanges(); return(RedirectToAction("Index")); } return(View(productionshifttype)); }
public ActionResult Create([Bind(Include = "ID,RoleName")] Role role) { if (ModelState.IsValid) { db.Roles.Add(role); db.SaveChanges(); return(RedirectToAction("Index")); } return(View(role)); }
public ActionResult Create([Bind(Include = "ID,PlantID,Username,FullName,DateEntered,EnteredBy,LastModified,ModifiedBy")] User user) { if (ModelState.IsValid) { db.Users.Add(user); db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.PlantID = new SelectList(db.Plants, "ID", "Code", user.PlantID); return(View(user)); }
public ActionResult Create([Bind(Include = "ID,RawMaterialQCID,LabTechUserID,DenIso,DateEntered,EnteredBy,LastModified,ModifiedBy")] RawMaterialSpecificGravity rawmaterialspecificgravity) { if (ModelState.IsValid) { db.RawMaterialSpecificGravities.Add(rawmaterialspecificgravity); db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.RawMaterialQCID = new SelectList(db.RawMaterialQCs, "ID", "RawMaterialID", rawmaterialspecificgravity.RawMaterialQCID); ViewBag.LabTechUserID = new SelectList(db.Users, "ID", "Username", rawmaterialspecificgravity.LabTechUserID); return(View(rawmaterialspecificgravity)); }
public ActionResult Create([Bind(Include = "ID,PlantID,TypeID,Code,StartTime,EndTime,DateEntered,EnteredBy,LastModified,ModifiedBy")] ProductionShift productionshift) { if (ModelState.IsValid) { db.ProductionShifts.Add(productionshift); db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.PlantID = new SelectList(db.Plants, "ID", "Code", productionshift.PlantID); ViewBag.TypeID = new SelectList(db.ProductionShiftTypes, "ID", "Code", productionshift.TypeID); return(View(productionshift)); }
public ActionResult Create([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.RawMaterialQCs.Add(rawmaterialqc); 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 void Add(CurrentRawMaterialDTO dto) { try { using (var context = new TPOMVCApplicationEntities()) { var newEntity = new TPOCurrentRawMaterial(); newEntity.RawMaterialReceivedID = dto.RawMaterialReceivedId; newEntity.LineID = dto.LineId; newEntity.PlantID = dto.PlantId; newEntity.DateEntered = dto.DateEntered; newEntity.EnteredBy = dto.EnteredBy; newEntity.ModifiedBy = dto.ModifiedBy; newEntity.LastModified = dto.LastModified; newEntity.Plant = context.Plants.Where(p => p.ID == dto.PlantId).FirstOrDefault(); newEntity.RawMaterialReceived = context.RawMaterialReceiveds.Where(m => m.ID == dto.RawMaterialReceivedId).FirstOrDefault(); context.TPOCurrentRawMaterials.Add(newEntity); context.SaveChanges(); } } catch (Exception ex) { throw; } }
public ActionResult Create([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.RawMaterialTests.Add(rawmaterialtest); 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 int Add(RawMaterialQCRedHoldDTO dto) { int returnID = -1; try { using (var context = new TPOMVCApplicationEntities()) { var newEntity = new TPO.DL.Models.RawMaterialQCRedHold(); newEntity.RawMaterialQCID = dto.RawMaterialQCID; newEntity.PlantID = dto.PlantID; newEntity.RawMaterialReceivedID = dto.RawMaterialReceivedID; newEntity.QCTechID = dto.QCTechID; newEntity.SupervisorID = dto.SupervisorID; newEntity.LeadOperatorID = dto.LeadOperatorID; newEntity.RedDate = dto.RedDate; newEntity.FailPropertyID = dto.FailPropertyID; newEntity.Zone = dto.Zone; newEntity.RedComments = dto.RedComments; newEntity.RedCorrectionAction = dto.RedCorrectionAction; newEntity.HoldDate = dto.HoldDate; newEntity.HoldLotNumber = dto.HoldLotNumber; newEntity.HoldComments = dto.HoldComments; newEntity.ManagerID = dto.ManagerID; newEntity.ManagerDate = dto.ManagerDate; newEntity.ManagerComments = dto.ManagerComments; newEntity.PrimeBoxCar = dto.PrimeBoxCar; newEntity.PrimeUOM = dto.PrimeUOM; newEntity.ReworkBoxCar = dto.ReworkBoxCar; newEntity.ReworkUOM = dto.ReworkUOM; newEntity.ScrapBoxCar = dto.ScrapBoxCar; newEntity.ScrapUOM = dto.ScrapUOM; newEntity.DateEntered = dto.DateEntered ?? DateTime.Now; newEntity.EnteredBy = dto.EnteredBy; newEntity.LastModified = dto.LastModified ?? DateTime.Now; newEntity.ModifiedBy = dto.ModifiedBy; context.RawMaterialQCRedHolds.Add(newEntity); context.SaveChanges(); //need to return the new record id //easy to do once we update to stored procs returnID = newEntity.ID; } } catch (DbEntityValidationException ex) { throw; } return(returnID); }
public void Delete(int id) { try { using (var context = new TPOMVCApplicationEntities()) { var toDelete = context.RawMaterialQCRedHolds.Find(id); context.RawMaterialQCRedHolds.Remove(toDelete); context.SaveChanges(); } } catch (Exception ex) { throw; } }
public void Update(RawMaterialQCSpecificGravityDTO dto) { try { using (var context = new TPOMVCApplicationEntities()) { // Save Specific gravity var toUpdate = context.RawMaterialSpecificGravities.Find(dto.ID); toUpdate.RawMaterialQCID = dto.RawMaterialQCID; toUpdate.LabTechUserID = dto.LabTechUserID; toUpdate.DenIso = dto.DenIso; toUpdate.DateEntered = dto.DateEntered ?? DateTime.Now; toUpdate.EnteredBy = dto.EnteredBy; toUpdate.ModifiedBy = dto.ModifiedBy; toUpdate.LastModified = DateTime.Now; context.Entry(toUpdate).State = EntityState.Modified; foreach (var detail in toUpdate.RawMaterialSpecificGravityDetails) { var dtoDetail = dto.RawMaterialSpecificGravityDetails.Where(d => d.ID == detail.ID); if (dtoDetail.Any()) { detail.Value = dtoDetail.First().Value; detail.LastModified = DateTime.Now; } } // TODO: Details // Set Specific Gravity on Parent QC record. RawMaterialQC toUpdateRawMaterialQC = context.RawMaterialQCs.Find(dto.RawMaterialQCID); toUpdateRawMaterialQC.SpecGrav = dto.AverageGravity; context.Entry(toUpdateRawMaterialQC).State = EntityState.Modified; context.SaveChanges(); } } catch (Exception ex) { throw; } }
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; } }
public void Add(RawMaterialQCSpecificGravityDTO dto) { try { using (var context = new TPOMVCApplicationEntities()) { var newEntity = new TPO.DL.Models.RawMaterialSpecificGravity(); newEntity.RawMaterialQCID = dto.RawMaterialQCID; newEntity.DateEntered = dto.DateEntered ?? DateTime.Now; newEntity.EnteredBy = dto.EnteredBy; newEntity.LastModified = dto.LastModified ?? DateTime.Now; newEntity.ModifiedBy = dto.ModifiedBy; context.RawMaterialSpecificGravities.Add(newEntity); context.SaveChanges(); //need to return the new record id } } catch (Exception ex) { throw; } }
public RawMaterialQCSpecificGravityDTO GetByQCID(int id) { using (var context = new TPOMVCApplicationEntities()) { var thisItem = (from a in context.RawMaterialSpecificGravities where a.RawMaterialQCID == id select a); if (thisItem.Any()) { return(MapToDTO(thisItem.FirstOrDefault())); } var newEntity = new RawMaterialSpecificGravity { RawMaterialQCID = id, DenIso = 0.7851, DateEntered = DateTime.Now, EnteredBy = "acorrington", LastModified = DateTime.Now, ModifiedBy = "acorrington" }; newEntity.RawMaterialQC = (from a in context.RawMaterialQCs where a.ID == id select a).FirstOrDefault(); for (int i = 0; i < 5; i++) { var dry = new TPO.DL.Models.RawMaterialSpecificGravityDetail { Order = (i + 1), Submerged = false, DateEntered = DateTime.Now, EnteredBy = "acorrington", LastModified = DateTime.Now, ModifiedBy = "acorrington" }; var submerged = new TPO.DL.Models.RawMaterialSpecificGravityDetail { Order = (i + 1), Submerged = true, DateEntered = DateTime.Now, EnteredBy = "acorrington", LastModified = DateTime.Now, ModifiedBy = "acorrington" }; newEntity.RawMaterialSpecificGravityDetails.Add(dry); newEntity.RawMaterialSpecificGravityDetails.Add(submerged); } context.RawMaterialSpecificGravities.Add(newEntity); context.SaveChanges(); var createdItem = (from a in context.RawMaterialSpecificGravities where a.RawMaterialQCID == id select a); if (createdItem.Any()) { return(MapToDTO(createdItem.FirstOrDefault())); } throw new Exception("Error creating Specific Gravity record."); } }