예제 #1
0
 /// <summary>
 ///     公猪下拉列表
 /// </summary>
 /// <returns></returns>
 public IEnumerable<SelectListItem> GetMalePigList()
 {
     var pigService = new PigService();
     var pigTypeService = new PigTypeService();
     pig_type pigType = pigTypeService.FindByName("公猪");
     if (pigType == null) return new List<SelectListItem>();
     IEnumerable<SelectListItem> pigSelect = pigService.FindByPigTypeId(pigType.Id)
                                                       .Select(pigtypeItem => new SelectListItem
                                                                                  {
                                                                                      Text =
                                                                                          pigtypeItem.
                                                                                          Number,
                                                                                      Value =
                                                                                          pigtypeItem.
                                                                                              Id +
                                                                                          string.Empty,
                                                                                  }).OrderBy(m => m.Text);
     return pigSelect;
 }
예제 #2
0
 /// <summary>
 ///     根据公猪的类型id得到所有的公猪编号和名字
 /// </summary>
 /// <returns>所有的公猪编号和名字</returns>
 public string GetMaleParentName()
 {
     var pigservice = new PigService();
     var pigtypeservice = new PigTypeService();
     try
     {
         long maleparentid = pigtypeservice.FindByName("公猪").Id;
         return pigservice.GetPigNumberAndNameByPigType(maleparentid);
     }
     catch (Exception)
     {
         return null;
     }
 }
예제 #3
0
 //判断类型是否重复
 public bool JudgeNameByType(string name, string typename)
 {
     var cureTypeService = new CureTypeService();
     var medicineService = new MedicineService();
     var unitService = new UnitService();
     var fodderTypeService = new FodderTypeService();
     var excetionTypeService = new ExceptionTypeService();
     var pigTypeService = new PigTypeService();
     var pigHouseTypeService = new PigHouseTypeService();
     var taskStatusTypeService = new TaskStatusTypeService();
     var taskTypeService = new TaskTypeService();
     var roleTypeService = new RoleTypeService();
     var preventionTypeService = new PreventionTypeService();
     var customerService = new CustomerService();
     if (typename == "治疗")
     {
         if (cureTypeService.FindByName(name) == null)
             return true;
     }
     if (typename == "单位")
     {
         if (unitService.FindByName(name) == null)
             return true;
     }
     if (typename == "药物")
     {
         if (medicineService.FindByName(name) == null)
             return true;
     }
     if (typename == "异常")
     {
         if (excetionTypeService.FindByName(name).Count == 0)
             return true;
     }
     if (typename == "饲料")
     {
         if (fodderTypeService.FindByName(name) == null)
             return true;
     }
     if (typename == "生猪")
     {
         if (pigTypeService.FindByName(name) == null)
             return true;
     }
     if (typename == "防疫")
     {
         if (preventionTypeService.FindByName(name) == null)
             return true;
     }
     if (typename == "猪舍")
     {
         if (pigHouseTypeService.FindByName(name) == null)
             return true;
     }
     if (typename == "任务状态")
     {
         if (taskStatusTypeService.FindByName(name) == null)
             return true;
     }
     if (typename == "任务类型")
     {
         if (taskTypeService.FindByName(name) == null)
             return true;
     }
     if (typename == "角色")
     {
         if (roleTypeService.FindByName(name) == null)
             return true;
     }
     if (typename == "客户名称")
     {
         if (customerService.FindByName(name) == null)
             return true;
     }
     return false;
 }
예제 #4
0
 public void PigTypeSaveChanges(BasicInfoModel model)
 {
     var typeService = new PigTypeService();
     List<pig_type> types = typeService.FindAll();
     foreach (pig_type type in types)
     {
         int idFlag = 0;
         int nameFlag = 0;
         string newname = "";
         foreach (NameModel name in model.Names)
         {
             if (type.Id == name.Id)
             {
                 idFlag = 1;
                 if (type.Name.Equals(name.Name))
                 {
                     nameFlag = 1;
                 }
                 else
                 {
                     newname = name.Name;
                 }
             }
         }
         //若存在此Id,但是name变化了的,则需要修改数据库
         if (idFlag == 1)
         {
             if (nameFlag == 0)
             {
                 if (newname == "")
                 {
                     throw new Exception();
                 }
                 pig_type modifyCure = typeService.Find(type.Id);
                 modifyCure.Name = newname;
                 typeService.Update(modifyCure);
             }
         }
     }
     //如果model里的Id为0,说明是新建的类型
     foreach (NameModel name in model.Names)
     {
         if (name.Id == 0 && typeService.FindByName(name.Name) == null)
         {
             var newType = new pig_type {Name = name.Name};
             typeService.Insert(newType);
         }
     }
 }