/// <summary> /// 根据生猪编号删除生猪的相关信息 /// </summary> /// <param name="pigNumber"></param> /// <returns></returns> public bool DelPig(string pigNumber) { var pigService = new PigService(); pig pig = pigService.FindByNumber(pigNumber); var transferService = new TransferService(); if (pig.cure_pig.Count > 0 || pig.task_pig.Count > 0 || pig.sale_pig.Count > 0 || pig.pig_weight.Count > 0 || pigService.FindByFemaleParentId(pig.Id).Count > 0 || pigService.FindByMostLikelyMaleParentId(pig.Id).Count > 0 || pigService.FindBySecondLikelyMaleParentId(pig.Id).Count > 0 || pigService.FindByThirdLikelyMaleParentId(pig.Id).Count > 0) { return false; } foreach (transfer transfer in transferService.FindByPigId(pig.Id)) { transferService = new TransferService(); transferService.Delete(transferService.Find(transfer.Id)); } pigService = new PigService(); pigService.Delete(pigService.Find(pig.Id)); return true; }