/// <summary> /// Акт установки запасных частей /// </summary> /// <param name="id"></param> /// <param name="equipmentId"></param> /// <returns></returns> public PartialViewResult ActOfSparePartsForm(Guid?id, Guid?equipmentId) { ViewBag.UiId = Guid.NewGuid().ToString(); EquipmentRepository eRepository = new EquipmentRepository(); LimsEquipmentAct act = new LimsEquipmentAct(); act.Id = Guid.Empty; if (equipmentId.HasValue && !id.HasValue) { act.Id = Guid.NewGuid(); act.IsNew = true; var equipment = eRepository.GetAsQuarable(e => e.Id == equipmentId) .FirstOrDefault(); act.LimsEquipment = equipment; act.EquipmentId = equipmentId.Value; } else if (id.HasValue) { act = eRepository.GetLimsEquipmentActs(ea => ea.Id == id).FirstOrDefault(); if (act != null) { act.IsNew = false; } } return(PartialView("ActOfSparePartsView", act)); }
public void DeleteLimsEquipmentAct(LimsEquipmentAct entityToDelete) { if (AppContext.Entry(entityToDelete).State == EntityState.Detached) { AppContext.LimsEquipmentActs.Attach(entityToDelete); } var entToDelete = entityToDelete as ISoftDeleteEntity; if (entToDelete != null) { entToDelete.DeleteDate = DateTime.Now; UpdateLimsEquipmentAct(entityToDelete); } else { AppContext.LimsEquipmentActs.Remove(entityToDelete); } }
public JsonResult SaveProtocolOfQualification(LimsEquipmentAct model) { string msg = string.Empty; ModelState.Remove("Id"); if (ModelState.IsValid) { try { EquipmentRepository eRepository = new EquipmentRepository(); DictionaryRepository dicRepo = new DictionaryRepository(false); if (model.Id == Guid.Empty) { model.Id = Guid.NewGuid(); model.CreateDate = DateTime.Now; Guid?actTypeId = dicRepo.GetDictionaryElementIdByTypeAndCode(Dictionary.DicEquipmentAct.DicCode, Dictionary.DicEquipmentAct.ProtocolOfQualification); if (actTypeId != null) { model.ActTypeId = actTypeId.Value; } eRepository.InsertLimsEquipmentAct(model); } else { eRepository.UpdateLimsEquipmentAct(model); } eRepository.Save(); } catch (Exception e) { msg = e.ToString(); } } return(Json(new { msg }, JsonRequestBehavior.AllowGet)); }
/// <summary> /// Протокол квалификации /// </summary> /// <param name="id"></param> /// <param name="equipmentId"></param> /// <returns></returns> public PartialViewResult ProtocolOfQualificationForm(Guid?id, Guid?equipmentId) { ViewBag.UiId = Guid.NewGuid().ToString(); EquipmentRepository eRepository = new EquipmentRepository(); LimsEquipmentAct act = new LimsEquipmentAct(); act.Id = Guid.Empty; act.FileLinkData = new FileLink(); if (equipmentId.HasValue && !id.HasValue) { var equipment = eRepository.GetAsQuarable(e => e.Id == equipmentId) .FirstOrDefault(); act.LimsEquipment = equipment; act.EquipmentId = equipmentId.Value; } else if (id.HasValue) { act = eRepository.GetLimsEquipmentActs(ea => ea.Id == id).FirstOrDefault(); if (act != null) { act.FileLinkData = eRepository.GetActualActFile(id.Value); if (act.FileLinkData == null) { DictionaryRepository dicRepo = new DictionaryRepository(false); act.FileLinkData = new FileLink(); act.FileLinkData.CategoryId = dicRepo.GetDictionaryElementIdByTypeAndCode(Dictionary.DicEquipmentAct.DicCode, Dictionary.DicEquipmentAct.ProtocolOfQualification); act.FileLinkData.DocumentId = act.Id; act.FileLinkData.Id = Guid.NewGuid(); } act.FileLinkData.AcceptFormats = "application/msword, application/vnd.openxmlformats-officedocument.wordprocessingml.document, application/pdf, image/jpeg"; } } return(PartialView("ProtocolOfQualificationView", act)); }
public ActionResult CreateSparePart([DataSourceRequest] DataSourceRequest request, [Bind(Exclude = "Id")] LimsEquipmentActSparePart model, Guid actId, Guid equipmentId) { if (ModelState.IsValid) { EquipmentRepository eRepository = new EquipmentRepository(false); var act = eRepository.GetLimsEquipmentActs(a => a.Id == actId).FirstOrDefault(); if (act == null) { act = new LimsEquipmentAct() { Id = actId, CreateDate = DateTime.Now, EquipmentId = equipmentId }; DictionaryRepository dicRepo = new DictionaryRepository(false); Guid?actTypeId = dicRepo.GetDictionaryElementIdByTypeAndCode(Dictionary.DicEquipmentAct.DicCode, Dictionary.DicEquipmentAct.ActOfSpareParts); if (actTypeId != null) { act.ActTypeId = actTypeId.Value; } eRepository.InsertLimsEquipmentAct(act); eRepository.Save(); } model.EquipmentActId = act.Id; model.Id = Guid.NewGuid(); model.CreatedDate = DateTime.Now; eRepository.InsertLimsEquipmentActSparePart(model); eRepository.Save(); } return(Json(new[] { model }.ToDataSourceResult(request, ModelState))); }
public JsonResult SaveActForRepair(LimsEquipmentAct model) { string msg = string.Empty; ModelState.Remove("Id"); if (ModelState.IsValid) { try { EquipmentRepository eRepository = new EquipmentRepository(); DictionaryRepository dicRepo = new DictionaryRepository(false); EmployeesRepository empRepo = new EmployeesRepository(false); var act = eRepository.GetLimsEquipmentActs(a => a.Id == model.Id).FirstOrDefault(); if (act == null) { model.Id = Guid.NewGuid(); model.CreateDate = DateTime.Now; Guid?actTypeId = dicRepo.GetDictionaryElementIdByTypeAndCode(Dictionary.DicEquipmentAct.DicCode, Dictionary.DicEquipmentAct.ActForRepair); if (actTypeId != null) { model.ActTypeId = actTypeId.Value; } var headOfLab = empRepo.GetById(model.HeadOfLaboratoryId); if (headOfLab != null) { model.HeadOfLaboratoryName = headOfLab.FullName; } var engineer = empRepo.GetById(model.EngineerId); if (engineer != null) { model.EngineerName = engineer.FullName; } eRepository.InsertLimsEquipmentAct(model); } else { act.State = model.State; act.Reason = model.Reason; act.HeadOfLaboratoryId = model.HeadOfLaboratoryId; var headOfLab = empRepo.GetById(model.HeadOfLaboratoryId); if (headOfLab != null) { act.HeadOfLaboratoryName = headOfLab.FullName; } act.EngineerId = model.EngineerId; var engineer = empRepo.GetById(model.EngineerId); if (engineer != null) { act.EngineerName = engineer.FullName; } eRepository.UpdateLimsEquipmentAct(act); } eRepository.Save(); } catch (Exception e) { msg = e.ToString(); } } return(Json(new { msg }, JsonRequestBehavior.AllowGet)); }
public JsonResult SaveActOfConversation(LimsEquipmentAct model) { string msg = string.Empty; ModelState.Remove("Id"); if (ModelState.IsValid) { try { EquipmentRepository eRepository = new EquipmentRepository(); DictionaryRepository dicRepo = new DictionaryRepository(false); EmployeesRepository empRepo = new EmployeesRepository(false); if (model.Id == Guid.Empty) { model.Id = Guid.NewGuid(); model.CreateDate = DateTime.Now; Guid?actTypeId = dicRepo.GetDictionaryElementIdByTypeAndCode(Dictionary.DicEquipmentAct.DicCode, Dictionary.DicEquipmentAct.ActOfConversation); if (actTypeId != null) { model.ActTypeId = actTypeId.Value; } var headOfLab = empRepo.GetById(model.HeadOfLaboratoryId); if (headOfLab != null) { model.HeadOfLaboratoryName = headOfLab.FullName; } var director = empRepo.GetById(model.DirectorRCId); if (director != null) { model.DirectorRCName = director.FullName; } eRepository.InsertLimsEquipmentAct(model); } else { var headOfLab = empRepo.GetById(model.HeadOfLaboratoryId); if (headOfLab != null) { model.HeadOfLaboratoryName = headOfLab.FullName; } var director = empRepo.GetById(model.DirectorRCId); if (director != null) { model.DirectorRCName = director.FullName; } eRepository.UpdateLimsEquipmentAct(model); } eRepository.Save(); } catch (Exception e) { msg = e.ToString(); } } return(Json(new { msg }, JsonRequestBehavior.AllowGet)); }
public ActionResult DestroyEquipmentAct([DataSourceRequest] DataSourceRequest request, LimsEquipmentAct model) { if (model != null) { EquipmentRepository eRepository = new EquipmentRepository(false); eRepository.DeleteLimsEquipmentAct(model.Id); eRepository.Save(); } return(Json(new[] { model }.ToDataSourceResult(request, ModelState))); }
public void DeleteLimsEquipmentActSparePart(object id) { LimsEquipmentAct entityToDelete = AppContext.LimsEquipmentActs.Find(id); DeleteLimsEquipmentActSparePart(entityToDelete); }
public virtual void UpdateLimsEquipmentAct(LimsEquipmentAct entityToUpdate) { AppContext.LimsEquipmentActs.Attach(entityToUpdate); AppContext.Entry(entityToUpdate).State = EntityState.Modified; }
public void InsertLimsEquipmentAct(LimsEquipmentAct entity) { AppContext.LimsEquipmentActs.Add(entity); }