コード例 #1
0
        /// <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));
        }
コード例 #2
0
        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);
            }
        }
コード例 #3
0
        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));
        }
コード例 #4
0
        /// <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));
        }
コード例 #5
0
        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)));
        }
コード例 #6
0
        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));
        }
コード例 #7
0
        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));
        }
コード例 #8
0
 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)));
 }
コード例 #9
0
        public void DeleteLimsEquipmentActSparePart(object id)
        {
            LimsEquipmentAct entityToDelete = AppContext.LimsEquipmentActs.Find(id);

            DeleteLimsEquipmentActSparePart(entityToDelete);
        }
コード例 #10
0
 public virtual void UpdateLimsEquipmentAct(LimsEquipmentAct entityToUpdate)
 {
     AppContext.LimsEquipmentActs.Attach(entityToUpdate);
     AppContext.Entry(entityToUpdate).State = EntityState.Modified;
 }
コード例 #11
0
 public void InsertLimsEquipmentAct(LimsEquipmentAct entity)
 {
     AppContext.LimsEquipmentActs.Add(entity);
 }