public ActionResult Create(int qcID = 0) { if (qcID == 0) { SetResponseMesssage(ActionTypeMessage.Error, General.ResponseMessageFailNoId); return(RedirectToAction("Index", "RawMaterialQC")); } using (RawMaterialQCRedHoldService rhSvc = new RawMaterialQCRedHoldService()) { var dto = rhSvc.GetByQC(qcID); if (dto != null) { return(RedirectToAction("Edit", new { id = dto.Id })); } } RawMaterialQCRedHoldViewModel model = new RawMaterialQCRedHoldViewModel(); model.RawMaterialQCId = qcID; using (RawMaterialsQcService svc = new RawMaterialsQcService()) { RawMaterialQcDto qcDto = svc.Get(qcID); model.RawMaterialReceivedId = qcDto.RawMaterialReceivedId; using (RawMaterialReceivedService receiveSvc = new RawMaterialReceivedService()) { RawMaterialReceivedDto receivedDto = receiveSvc.Get(qcDto.RawMaterialReceivedId); model.BoxCarTested = receivedDto.LotNumber; model.RawMaterialReceived = receivedDto.RawMaterialCode; ViewBag.RawMaterialReceivedID = new SelectList(receiveSvc.GetAll(), "ID", "RawMaterialID"); } } PrepareSelectLists(); return(View(model)); }
public JsonResult AjaxTypeDelete(string row) { ResponseMessage responseMessage; RawMaterialReceived rawMaterialReceived = JsonConvert.DeserializeObject <RawMaterialReceived>(row); try { if (rawMaterialReceived != null) { RawMaterialReceivedDto dto = new RawMaterialReceivedDto(); using (RawMaterialReceivedService service = new RawMaterialReceivedService()) { Mapper.Map(rawMaterialReceived, dto); if (rawMaterialReceived.Id > 0) { service.DeleteComplete(dto.Id); } } } responseMessage = SetResponseMesssage(ActionTypeMessage.SuccessfulSave); } catch (Exception exc) { responseMessage = SetResponseMesssage(ActionTypeMessage.FailedSave, exc.Message); } return(Json(responseMessage, JsonRequestBehavior.AllowGet)); }
public ActionResult AjaxTypeUpdate(string row, string rawMaterialId) { ResponseMessage responseMessage; RawMaterialReceived rawMaterialReceived = JsonConvert.DeserializeObject <RawMaterialReceived>(row); try { if (rawMaterialReceived != null) { rawMaterialReceived.LastModified = DateTime.Now; RawMaterialReceivedDto dto = new RawMaterialReceivedDto(); using (RawMaterialReceivedService service = new RawMaterialReceivedService()) { Mapper.Map(rawMaterialReceived, dto); if (rawMaterialReceived.Id > 0) { service.Update(dto); } else { dto.RawMaterialId = Convert.ToInt32(rawMaterialId); dto.PlantId = CurrentPlantId; service.Add(dto); } } } responseMessage = SetResponseMesssage(ActionTypeMessage.SuccessfulSave); } catch (Exception exc) { responseMessage = SetResponseMesssage(ActionTypeMessage.FailedSave, exc.Message); } return(Json(responseMessage, JsonRequestBehavior.AllowGet)); }
public JsonResult GridByType(int lineID, int?rows, int?page) { rows = rows ?? DefaultPageSize; page = page ?? DefaultPage; int lineDescription; List <CurrentScrimViewModel> list = new List <CurrentScrimViewModel>(); List <TPOCurrentRawMaterialDto> materialslist = new List <TPOCurrentRawMaterialDto>(); if (lineID != null) { using (var service = new ProductionLineService()) { lineDescription = service.Get(lineID).ID; } using (var service = new TPOCurrentRawMaterialService()) { materialslist = service.GetAll().Where(q => q.LineID == lineDescription).ToList(); } foreach (var dto in materialslist) { RawMaterialReceivedDto rawMaterialReceivedDto = new RawMaterialReceivedDto(); RawMaterialDto rawMaterialDto = new RawMaterialDto(); CurrentScrimViewModel csvm = new CurrentScrimViewModel(); csvm.Id = dto.ID; csvm.PlantId = CurrentPlantId; using (var service = new RawMaterialReceivedService()) { rawMaterialReceivedDto = service.Get(dto.RawMaterialReceivedID ?? 0); csvm.LotNumber = rawMaterialReceivedDto.LotNumber; csvm.RawMaterialID = rawMaterialReceivedDto.Id; } using (var service = new RawMaterialService()) { rawMaterialDto = service.Get(Convert.ToInt32(rawMaterialReceivedDto.RawMaterialId)); csvm.RawMaterialCode = rawMaterialDto.Code; } csvm.EnteredBy = dto.EnteredBy; csvm.ModifiedBy = dto.ModifiedBy; csvm.DateEntered = dto.DateEntered; csvm.LastModified = dto.LastModified; list.Add(csvm); } } int total; total = list.Count(); List <CurrentScrimViewModel> currentPageDtos = new List <CurrentScrimViewModel>(); if (rows.HasValue) { currentPageDtos.AddRange(list.OrderByDescending(r => r.DateEntered).Skip((page.Value - 1) * rows.Value).Take(rows.Value).ToList()); } else { currentPageDtos.AddRange(list); } return(BuildJsonResult(currentPageDtos, total)); }
public JsonResult CurrentScrimAjaxCreate(string id, int lineId) { ResponseMessage responseMessage; try { CurrentScrimViewModel currentSrimViewModel = JsonConvert.DeserializeObject <CurrentScrimViewModel>(id); if (currentSrimViewModel != null) { TPOCurrentRawMaterialDto tpoCurrentRawMaterialdto = new TPOCurrentRawMaterialDto(); if (currentSrimViewModel.Id > 0) { using (TPOCurrentRawMaterialService service = new TPOCurrentRawMaterialService()) { tpoCurrentRawMaterialdto = service.Get(currentSrimViewModel.Id); } using (RawMaterialReceivedService service = new RawMaterialReceivedService()) { RawMaterialReceivedDto rawMaterialDto = new RawMaterialReceivedDto(); rawMaterialDto = service.GetAll() .Where(q => q.Id == Convert.ToInt32(currentSrimViewModel.LotNumber)) .ToList() .FirstOrDefault(); tpoCurrentRawMaterialdto.RawMaterialReceivedID = rawMaterialDto.Id; } } else { tpoCurrentRawMaterialdto.PlantID = CurrentPlantId; using (ProductionLineService service = new ProductionLineService()) { tpoCurrentRawMaterialdto.LineID = service.Get(lineId).ID; } using (RawMaterialReceivedService service = new RawMaterialReceivedService()) { RawMaterialReceivedDto rawMaterialDto = new RawMaterialReceivedDto(); rawMaterialDto = service.GetAll() .Where(q => q.Id == Convert.ToInt32(currentSrimViewModel.LotNumber)) .ToList() .FirstOrDefault(); tpoCurrentRawMaterialdto.RawMaterialReceivedID = rawMaterialDto.Id; } } using (TPOCurrentScrimService service = new TPOCurrentScrimService()) { if (currentSrimViewModel.Id > 0) { service.UpdateTPOCurrentRawMaterial(tpoCurrentRawMaterialdto); } else { service.AddTPOCurrentRawMaterial(tpoCurrentRawMaterialdto); } } } responseMessage = SetResponseMesssage(ActionTypeMessage.SuccessfulSave); } catch (Exception exc) { responseMessage = SetResponseMesssage(ActionTypeMessage.FailedSave, exc.Message); } return(Json(responseMessage, JsonRequestBehavior.AllowGet)); }