/// <summary> /// Converts a RawMaterialQC Entity into a RawMaterialQCModel Model. /// </summary> /// <param name="entity">The RawMaterialQC Entity to convert.</param> /// <param name="to">The RawMaterialQCModel Model to which to convert.</param> /// <returns>An instance of RawMaterialQCModel representing the RawMaterialQC Entity.</returns> private static RawMaterialQCModel Bind(TPO.DL.Models.RawMaterialQC entity, RawMaterialQCModel to) { to.ID = entity.ID; to.PlantID = entity.PlantID; to.QCTechID = entity.QCTechUserID.HasValue ? entity.QCTechUserID.Value : RawMaterialQCModel.INVALID_ID; to.RawMaterialReceivedID = entity.RawMaterialReceivedID; //Code and Lot are one way read and not passed back to model (i.e. read-only) to.RawMaterialCode = entity.RawMaterialReceived.RawMaterial.Code; to.LotCode = entity.RawMaterialReceived.LotNumber; to.VisuallyInspected = entity.VisualInspection.HasValue ? entity.VisualInspection.Value : false; to.SpecificGravity = entity.SpecGrav.HasValue ? (decimal)entity.SpecGrav.Value : 0; to.ColorTestCoA = entity.ColorCoA.HasValue ? (decimal)entity.ColorCoA.Value : 0; to.ColorTestFS = entity.ColorFS.HasValue ? (decimal)entity.ColorFS.Value : 0; to.MeltFlowTestCoA = entity.MFCoA.HasValue ? (decimal)entity.MFCoA.Value : 0; to.MeltFlowTestFS = entity.MFFS.HasValue ? (decimal)entity.MFFS.Value : 0; to.AshContentTestCoA = entity.ACCoA.HasValue ? (decimal)entity.ACCoA.Value : 0; to.AshContentTestFS = entity.ACFS.HasValue ? (decimal)entity.ACFS.Value : 0; to.MoistureTestCoA = entity.MoistCoA.HasValue ? (decimal)entity.MoistCoA.Value : 0; to.MoistureTestFS = entity.MoistFS.HasValue ? (decimal)entity.MoistFS.Value : 0; to.CarbonBlackTestCoA = entity.CBCoA.HasValue ? (decimal)entity.CBCoA.Value : 0; to.CarbonBlackTestFS = entity.CBFS.HasValue ? (decimal)entity.CBFS.Value : 0; to.BoxCar = entity.BoxCarTested; to.Comments = entity.Comments; to.DateEntered = entity.DateEntered; to.EnteredBy = entity.EnteredBy; to.LastModified = entity.LastModified; to.ModifiedBy = entity.ModifiedBy; return(to); }
/// <summary> /// Converts a RawMaterialQCModel Model into a RawMaterialQC Entity. /// </summary> /// <param name="entity">The RawMaterialQCModel Model to convert.</param> /// <param name="to">The RawMaterialQC Entity to which to convert.</param> /// <returns>An instance of RawMaterialQC representing the RawMaterialQCModel Model.</returns> private static TPO.DL.Models.RawMaterialQC Bind(RawMaterialQCModel model, TPO.DL.Models.RawMaterialQC to) { //to.PlantID = model.PlantID; //TODO: Implement retrieving PlantID to.PlantID = 1; if (model.QCTechID != RawMaterialQCModel.INVALID_ID) { to.QCTechUserID = model.QCTechID; } else { to.QCTechUserID = null; } to.RawMaterialReceivedID = model.RawMaterialReceivedID; to.VisualInspection = model.VisuallyInspected; to.SpecGrav = (double?)model.SpecificGravity; to.ColorCoA = (double?)model.ColorTestCoA; to.ColorFS = (double?)model.ColorTestFS; to.MFCoA = (double?)model.MeltFlowTestCoA; to.MFFS = (double?)model.MeltFlowTestFS; to.ACCoA = (double?)model.AshContentTestCoA; to.ACFS = (double?)model.AshContentTestFS; to.MoistCoA = (double?)model.MoistureTestCoA; to.MoistFS = (double?)model.MoistureTestFS; to.CBCoA = (double?)model.CarbonBlackTestCoA; to.CBFS = (double?)model.CarbonBlackTestFS; to.BoxCarTested = model.BoxCar; to.Comments = model.Comments; return(to); }
public string AddRawMaterialTest(TPO.DL.Models.RawMaterialQC RawMaterialQC) { int ID = 1; using (var con = new SqlConnection(ConfigurationManager.ConnectionStrings["ConnectionString1"].ConnectionString)) { using (var cmd = new SqlCommand(StoredProcedures.RawMaterialQcCreate, con)) { cmd.CommandType = CommandType.StoredProcedure; cmd.Parameters.Add(new SqlParameter { ParameterName = "@PlantID", Value = RawMaterialQC.PlantID }); cmd.Parameters.Add(new SqlParameter { ParameterName = "@RawMaterialID", Value = RawMaterialQC.RawMaterialReceivedID }); cmd.Parameters.Add(new SqlParameter { ParameterName = "@LotID", Value = RawMaterialQC.RawMaterialReceived.LotNumber }); cmd.Parameters.Add(new SqlParameter { ParameterName = "@DateEntered", Value = RawMaterialQC.DateEntered }); cmd.Parameters.Add(new SqlParameter { ParameterName = "@EnteredBy", Value = RawMaterialQC.EnteredBy }); cmd.Parameters.Add(new SqlParameter { ParameterName = "@LastModified", Value = Convert.ToDateTime(DateTime.Now) }); cmd.Parameters.Add(new SqlParameter { ParameterName = "@ModifiedBy", Value = RawMaterialQC.ModifiedBy }); con.Open(); ID = Int32.Parse(cmd.ExecuteScalar().ToString()); } } return(ID.ToString()); }
public RawMaterialQCModel InsertRawMaterialQCModel(TPO.Model.RawMaterials.RawMaterialQCModel model) { using (RawMaterialsRepository repo = new RawMaterialsRepository()) { TPO.DL.Models.RawMaterialQC entity = Bind(model, new TPO.DL.Models.RawMaterialQC()); int id = repo.CreateRawMaterialQC(entity); model.ID = id; } return(model); }
/// <summary> /// Updates the RawMaterialQC record in the database that is represented by the RawMaterialQCModel. /// </summary> /// <param name="model">The RawMaterialQCModel representing the RawMaterialQC record.</param> public void UpdateRawMaterialQCModel(TPO.Model.RawMaterials.RawMaterialQCModel model) { using (RawMaterialsRepository repo = new RawMaterialsRepository()) { TPO.DL.Models.RawMaterialQC entity = repo.GetRawMaterialQCByID(model.ID); if (entity != null) { entity = Bind(model, entity); repo.SaveChanges(); } } }
private void GetQcFormDetail(ref TPOWeb.Models.RawMaterialQCRedHoldViewModel model) { //TODO: Rewrite after QC object has been refactored. TPO.DL.Models.RawMaterialQC qcLookupObj = db.RawMaterialQCs.Find(model.RawMaterialQCId); model.RawMaterialQCId = qcLookupObj.ID; model.QCTechId = qcLookupObj.QCTechUserID; model.PlantId = qcLookupObj.PlantID; model.BoxCarTested = qcLookupObj.BoxCarTested; TPO.BL.RawMaterials.RawMaterial RawMatList = new TPO.BL.RawMaterials.RawMaterial(); model.RawMaterialReceived = qcLookupObj.RawMaterialReceived.RawMaterial.Code + " | " + qcLookupObj.RawMaterialReceived.RawMaterial.Description; model.LotNumber = qcLookupObj.RawMaterialReceived.LotNumber; }
// GET: /RawMaterialQCRedHold/Create/QCID public ActionResult Create(DateTime?holddate, DateTime?managerdate, DateTime?reddate, int?id) { TPOWeb.Models.RawMaterialQCRedHoldViewModel model = new Models.RawMaterialQCRedHoldViewModel(); if (id == null) { TempData["ActionMessage"] = MessageRepository.GetStringValue(MessageKeys.ResponseMessageFailNoId); TempData["ActionMessageType"] = MessageRepository.GetStringValue(MessageKeys.ResponseTypeError); return(RedirectToAction("Index", "RawMaterialQC")); //return new HttpStatusCodeResult(HttpStatusCode.BadRequest); } else { //Sloppy error handling, have to fix the null ID variable. RawMaterialQCRedHoldDTO lookupObjByQCId = RawMaterialQCRedHoldRepo.GetByQCID(id ?? -1); //test to see if record already exists, if it does, switch to edit view if (lookupObjByQCId != null && lookupObjByQCId.ID >= 0) { return(RedirectToAction("Edit", "RawMaterialQCRedHold", new { ID = lookupObjByQCId.ID })); } //TODO: Rewrite after QC object has been refactored. TPO.DL.Models.RawMaterialQC qcLookupObj = db.RawMaterialQCs.Find(id); model.RawMaterialQCId = qcLookupObj.ID; model.QCTechId = qcLookupObj.QCTechUserID; model.PlantId = qcLookupObj.PlantID; model.BoxCarTested = qcLookupObj.BoxCarTested; model.RawMaterialReceived = qcLookupObj.RawMaterialReceived.RawMaterial.Code; model.LotNumber = qcLookupObj.RawMaterialReceived.LotNumber; model.RawMaterialReceivedId = qcLookupObj.RawMaterialReceivedID; model.ManagerDate = managerdate; model.HoldDate = holddate; model.RedDate = reddate; PrepareSelectLists(); ViewBag.RawMaterialReceivedID = new SelectList(db.RawMaterialReceiveds, "ID", "RawMaterialID"); } return(View(model)); }
/// <summary> /// Gets a RawMaterialQCModel representing the RawMaterialQC record indicated by the provided ID. /// The RawMaterialQCModel returns also includes configuration data for the various test available. /// </summary> /// <param name="id">The ID of the RawMaterialQC record in the database.</param> /// <returns>A RawMaterialQCModel</returns> public RawMaterialQCModel GetRawMaterialQCModelByRawMaterialQCID(int id) { RawMaterialQCModel model = null; using (RawMaterialsRepository repo = new RawMaterialsRepository()) { TPO.DL.Models.RawMaterialQC entity = repo.GetRawMaterialQCByID(id); if (entity != null) { model = Bind(entity, new RawMaterialQCModel()); RawMaterialTest testBL = new RawMaterialTest(); Int32 rawMatID = 0; TPO.DL.Models.RawMaterialReceived rawMaterialReceived = new TPOMVCApplicationEntities().RawMaterialReceiveds.Where(w => w.ID == model.RawMaterialReceivedID).First(); model.QCConfiguration = testBL.GetQCConfigurationByRawMaterial(rawMaterialReceived.RawMaterial.ID); } } return(model); }
public void UpdateRawMaterialTest(TPO.DL.Models.RawMaterialQC RawMaterialUpdateQC) { using (var con = new SqlConnection(ConfigurationManager.ConnectionStrings["ConnectionString1"].ConnectionString)) { using (var cmd = new SqlCommand(StoredProcedures.RawMaterialQcUpdate, con)) { cmd.CommandType = CommandType.StoredProcedure; cmd.Parameters.Add(new SqlParameter { ParameterName = "@ID", Value = RawMaterialUpdateQC.ID }); cmd.Parameters.Add(new SqlParameter { ParameterName = "@PlantID", Value = RawMaterialUpdateQC.PlantID }); cmd.Parameters.Add(new SqlParameter { ParameterName = "@BoxCarTested", Value = RawMaterialUpdateQC.BoxCarTested }); cmd.Parameters.Add(new SqlParameter { ParameterName = "@QCTechUserID", Value = RawMaterialUpdateQC.QCTechUserID }); cmd.Parameters.Add(new SqlParameter { ParameterName = "@Comments", Value = RawMaterialUpdateQC.Comments }); cmd.Parameters.Add(new SqlParameter { ParameterName = "@DateEntered", Value = RawMaterialUpdateQC.DateEntered }); cmd.Parameters.Add(new SqlParameter { ParameterName = "@EnteredBy", Value = RawMaterialUpdateQC.EnteredBy }); cmd.Parameters.Add(new SqlParameter { ParameterName = "@LastModified", Value = RawMaterialUpdateQC.LastModified }); cmd.Parameters.Add(new SqlParameter { ParameterName = "@ModifiedBy", Value = RawMaterialUpdateQC.ModifiedBy }); con.Open(); cmd.ExecuteNonQuery(); } } }
public ActionResult Index_Post(string Action, FormCollection formCollection, string RawMaterial, string LotID) { if (Action == "Lot Not In List") { return(RedirectToAction("Create", "RawMaterial")); } if (ModelState.IsValid) { TPOMVCApplicationEntities db = new TPOMVCApplicationEntities(); ViewBag.RawMaterial = new SelectList(db.RawMaterialQCs, "ID", "RawMaterialID"); if (Action == "New Test") { TPO.DL.Models.RawMaterialQC rawmaterialqc = new TPO.DL.Models.RawMaterialQC(); //rawmaterialqc.RawMaterialID = RawMaterial; rawmaterialqc.PlantID = CurrentPlantId; string string1 = formCollection["RawMaterialQC"]; string string2 = formCollection["RawMaterialLotQC"]; /* * if (!(string.IsNullOrEmpty(string1))) * { * try * { * rawmaterialqc.RawMaterialReceived.RawMaterialID = int.Parse(string1); * } * catch * { * * } * } */ if (!(string.IsNullOrEmpty(string2))) { try { rawmaterialqc.RawMaterialReceivedID = int.Parse(string2); } catch { } } rawmaterialqc.DateEntered = Convert.ToDateTime(System.DateTime.Now); rawmaterialqc.EnteredBy = ""; rawmaterialqc.LastModified = Convert.ToDateTime(System.DateTime.Now); rawmaterialqc.ModifiedBy = ""; TryUpdateModel(rawmaterialqc); TPO.BL.RawMaterials.RawMaterialQC layer1 = new TPO.BL.RawMaterials.RawMaterialQC(); string ID; TryUpdateModel(rawmaterialqc); if (ModelState.IsValid) { ID = layer1.AddRawMaterialTest(rawmaterialqc); return(RedirectToAction("Edit", new { id = ID, isNew = true })); } else { return(RedirectToAction("index")); } } else { return(RedirectToAction("Index")); } } return(View()); }