/// <summary> /// 根据猪舍id找猪栏下拉列表 /// </summary> /// <returns></returns> public IEnumerable<SelectListItem> FindPigstyListByPigHouseId(string pigHouseId) { var pigHouseService = new PigHouseService(); var pigstyService = new PigstyService(); long id = 0; IEnumerable<SelectListItem> pigstySelect = new List<SelectListItem>(); if (long.TryParse(pigHouseId, out id)) pigstySelect = pigstyService.FindByPigHouseId(id).OrderBy(m=>m.Number).Select( pigstyItem => new SelectListItem { Text = pigstyItem.Number + "", Value = pigstyItem.Id + "" }); return pigstySelect; }
/// <summary> /// 猪舍id为1猪栏下拉列表 /// </summary> /// <returns></returns> public IEnumerable<SelectListItem> GetFirstPigstyList() { var pigHouseService = new PigHouseService(); var pigstyService = new PigstyService(); IEnumerable<SelectListItem> pigstySelect = new List<SelectListItem>(); pig_house firstOrDefault = pigHouseService.FindAll().FirstOrDefault(); if (firstOrDefault != null) { pigstySelect = pigstyService.FindByPigHouseId(firstOrDefault.Id).OrderBy(m=>m.Number).Select( pigstyItem => new SelectListItem { Text = pigstyItem.Number + "", Value = pigstyItem.Id + "" }); } return pigstySelect; }
//猪栏所处猪舍 public bool PigstyRfidCompareByType(long typeid, int number) { var pigstyService = new PigstyService(); return pigstyService.FindByPigHouseId(typeid).All(c => c.Number != number); }
/// <summary> /// 猪栏id为1的猪下拉列表 /// </summary> /// <returns></returns> public IEnumerable<SelectListItem> GetFirstPigList() { var pigHouseService = new PigHouseService(); var pigstyService = new PigstyService(); var transferService = new TransferService(); var pigSelect = new List<SelectListItem>(); pig_house pigHouse = pigHouseService.FindAll().FirstOrDefault(); if (pigHouse != null) { pigsty pigsty = pigstyService.FindByPigHouseId(pigHouse.Id).FirstOrDefault(); if (pigsty != null) { string[] strPig = transferService.GetPigIdAndNum(pigsty.Id).Split(','); if (strPig[0] != "") pigSelect.AddRange( strPig.Select(strPigItem => strPigItem.Split(':')).Select(pig => new SelectListItem { Text = pig[1], Value = pig[0] }).OrderBy(m => m.Text)); } } return pigSelect; }
//猪栏编号 public bool PigstyNumberCompare(int number, long houseid) { var pigstyService = new PigstyService(); List<pigsty> pigsties = pigstyService.FindByPigHouseId(houseid); int flag = 1; foreach (pigsty pigsty in pigsties) { if (pigsty.Number == number) { flag = 0; } } if (flag == 0) { return false; } return true; }