コード例 #1
0
        //[HttpPost]
        //public ActionResult Create(TPO.Model.RawMaterials.RawMaterialQCModel model)
        //{
        //   TPO.BL.RawMaterials.RawMaterialQC qcBL = new TPO.BL.RawMaterials.RawMaterialQC();
        //  model = qcBL.InsertRawMaterialQCModel(model);
        //   return RedirectToAction("Edit", new { id = model.ID, unlocked = false });
        //}


        public ActionResult Edit(int id = 0, bool isNew = false, bool success = false)
        {
            TPO.BL.Security.User userBL = new TPO.BL.Security.User();
            ViewBag.QCTech = new SelectList(userBL.GetQCTechUsers(), "ID", "FullName");

            TPO.BL.RawMaterials.RawMaterialQC         qcBL  = new TPO.BL.RawMaterials.RawMaterialQC();
            TPO.Model.RawMaterials.RawMaterialQCModel model = qcBL.GetRawMaterialQCModelByRawMaterialQCID(id);
            //model.IsEditMode = !isNew;

            //hack
            if (success)
            {
                TempData["ActionMessage"]     = MessageRepository.GetStringValue(MessageKeys.ResponseMessageSuccessSave);
                TempData["ActionMessageType"] = MessageRepository.GetStringValue(MessageKeys.ResponseTypeSuccess);
            }
            if (model == null)
            {
                TempData["ActionMessage"] = MessageRepository.GetStringValue(MessageKeys.ResponseMessageFailNoRecord);
                //string.Format("Raw Material QC with ID {0} not found.", id);
                TempData["ActionMessageType"] = MessageRepository.GetStringValue(MessageKeys.ResponseTypeError);
                return(RedirectToAction("Index"));
                //return HttpNotFound(string.Format("Raw Material QC with ID {0} not found.", id));
            }
            return(View(model));
        }
コード例 #2
0
 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);
 }
コード例 #3
0
 /// <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();
         }
     }
 }
コード例 #4
0
        //// GET: /RawMaterialQC/LotID
        //public ActionResult GetTestIDs(int ID)
        //{
        //    List<SelectListItem> testItems = new List<SelectListItem>();
        //    TPOMVCApplicationEntities db = new TPOMVCApplicationEntities();
        //    var testRecords =
        //        db.RawMaterialQCs.Where(x => x.RawMaterialReceivedID == ID)
        //            .OrderByDescending(x => x.DateEntered)
        //            .ToList();

        //    if (testRecords.Count > 0)
        //    {
        //        testItems.Add(new SelectListItem {Value = "", Text = "-- Select Test --"});
        //    }
        //    else
        //    {
        //        testItems.Add(new SelectListItem {Value = "", Text = "-- No Tests for Lot: " + ID + " --"});
        //    }
        //    foreach (var item in testRecords)
        //    {
        //        testItems.Add(new SelectListItem
        //        {
        //            Value = item.ID.ToString(),
        //            Text = item.DateEntered.ToString("MM/dd/yy hh:mm") + " | " + item.BoxCarTested
        //        });
        //    }
        //    return Json(testItems);
        //}

        public ActionResult Create(string rm = "", string lot = "")
        {
            TPO.BL.Security.User userBL = new TPO.BL.Security.User();
            ViewBag.QCTech = new SelectList(userBL.GetQCTechUsers(), "ID", "FullName");

            TPO.Model.RawMaterials.RawMaterialQCModel model = new TPO.Model.RawMaterials.RawMaterialQCModel();
            int tmpRawMaterialReceivedId = 0;

            if (!int.TryParse(lot, out tmpRawMaterialReceivedId))
            {
                tmpRawMaterialReceivedId = 0;
            }
            model.RawMaterialReceivedID = tmpRawMaterialReceivedId;
            TPO.DL.Models.RawMaterialReceived rawMaterialLookup =
                new TPOMVCApplicationEntities().RawMaterialQCs.Where(
                    w => w.RawMaterialReceivedID == tmpRawMaterialReceivedId).First().RawMaterialReceived;
            if (rawMaterialLookup == null)
            {
                TempData["ActionMessage"] = MessageRepository.GetStringValue(MessageKeys.ResponseMessageFailNoRecord);
                //string.Format("Raw Material Test configuration not found for raw material {0}.", rm);
                TempData["ActionMessageType"] = MessageRepository.GetStringValue(MessageKeys.ResponseTypeError);
                return(RedirectToAction("Index"));
                //return HttpNotFound(string.Format("Raw Material Test configuration not found for raw material {0}.", rm));
            }
            model.RawMaterialCode = rawMaterialLookup.RawMaterial.Code;
            model.LotCode         = rawMaterialLookup.LotNumber;
            model.QCTechID        = CurrentUserID;
            TPO.BL.RawMaterials.RawMaterialTest rmtBL = new TPO.BL.RawMaterials.RawMaterialTest();
            model.QCConfiguration = rmtBL.GetQCConfigurationByRawMaterial(tmpRawMaterialReceivedId);
            if (model.QCConfiguration == null)
            {
                TempData["ActionMessage"] = MessageRepository.GetStringValue(MessageKeys.ResponseMessageFailNoRecord);
                //string.Format("Raw Material Test configuration not found for raw material {0}.", rm);
                TempData["ActionMessageType"] = MessageRepository.GetStringValue(MessageKeys.ResponseTypeError);
                return(RedirectToAction("Index"));
                //return HttpNotFound(string.Format("Raw Material Test configuration not found for raw material {0}.", rm));
            }
            TPO.BL.RawMaterials.RawMaterialQC qcBL = new TPO.BL.RawMaterials.RawMaterialQC();
            model = qcBL.InsertRawMaterialQCModel(model);
            model.LastModified = DateTime.Now;
            // return View(model);
            return(RedirectToAction("Edit", new { id = model.ID }));
        }
コード例 #5
0
        public ActionResult Edit_Post(TPO.Model.RawMaterials.RawMaterialQCModel qc, int id = 0)
        //TPO.Model.RawMaterials.RawMaterialQCModel model
        {
            //TPO.BL.RawMaterials.RawMaterialQC qcBL = new TPO.BL.RawMaterials.RawMaterialQC();
            //qcBL.UpdateRawMaterialQCModel(model);
            //return View(model);
            bool success = false;

            if (ModelState.IsValid)
            {
                TPOMVCApplicationEntities db = new TPOMVCApplicationEntities();
                ViewBag.RawMaterial = new SelectList(db.RawMaterialQCs, "ID", "RawMaterialID");
                qc.DateEntered      = Convert.ToDateTime(System.DateTime.Now);
                qc.EnteredBy        = CurrentUser;
                qc.LastModified     = Convert.ToDateTime(System.DateTime.Now);
                qc.ModifiedBy       = CurrentUser;

                TPO.BL.RawMaterials.RawMaterialQC layeredit = new TPO.BL.RawMaterials.RawMaterialQC();
                layeredit.UpdateRawMaterialQCModel(qc);
                success = true;
            }

            return(RedirectToAction("Edit", new { id = id, success = success }));
        }