override protected void OnInsertValidate() { var r = new FarmRepository().GetEntitie <LivePig>(p => p.raiserID == raiserID); if (r == null) { throw (new Exception(string.Format("养户编号\"{0}\"不存在", raiserID))); } if (r.grantDate > this.injectionDate) { throw (new Exception(string.Format("注射日期不可能早于调入日期:{0:d}", r.grantDate))); } if (DateTime.Today < this.injectionDate) { throw (new Exception(string.Format("今天是{0:d},请不要提前确认", DateTime.Today))); } var a = new BaseRepository().GetEntitie <tbInjection>(p => p.PigID == r.ID && p.vaccineID == vaccineID); if (a != null) { throw (new Exception(string.Format("不用重复确认同一种疫苗"))); } this.PigID = r.ID; return; }
override protected void OnInsertValidate() { var db = new FarmRepository(); var b = db.GetEntitie <Pact>(p => p.raiserID == this.raiserID && p.statusFlag == 0); if (b == null) { throw(new Exception(string.Format("养户编号\"{0}\"对应的合同信息不存在", this.raiserID))); } this.RID = b.RID; this.PID = b.ID; return; }
override protected void OnInsertValidate() { var r = new FarmRepository().GetEntitie <LivePig>(p => p.raiserID == raiserID); if (r == null) { throw (new Exception(string.Format("养户编号\"{0}\"不存在", raiserID))); } if (r.extantNum < this.salesNum) { throw (new Exception(string.Format("销售数量不能大于当前存栏数量"))); } this.PigID = r.ID; return; }
override protected void OnUpdateValidate() { var db = new FarmRepository(); var model = db.GetEntitie <Raiser>(p => p.ID == this.ID); if (model.statusFlag != 3 && model.statusFlag != 0 && this.isDisabled) { throw(new Exception("不能淘汰非空闲的养户")); } if (db.GetEntitie <Raiser>(p => p.raiserID == this.raiserID && p.ID != this.ID) != null) { throw(new Exception(string.Format("养户编号 \"{0}\" 已经存在,请更换", this.raiserID))); } return; }
override protected void OnInsertValidate() { var r = new FarmRepository().GetEntitie <LivePig>(p => p.raiserID == raiserID); if (r == null) { throw(new Exception(string.Format("养户编号\"{0}\"不存在", raiserID))); } if (r.extantNum < this.deathNum) { throw(new Exception(string.Format("死亡数量不能大于当前存栏数量"))); } this.PigID = r.ID; this.referPerson = Account.userName; this.referTime = DateTime.Now; return; }
override protected void OnInsertValidate() { var db = new FarmRepository(); var r = db.GetEntitie <Raiser>(p => p.raiserID == raiserID); if (r == null) { throw(new Exception(string.Format("养户编号\"{0}\"不存在", raiserID))); } if (r.statusFlag != 3) { throw(new Exception(string.Format("养户\"{0}\"处于非空闲状态,不能签约", raiserID))); } this.RID = r.ID; return; }
override protected void OnInsertValidate() { var db = new FarmRepository(); var r = db.GetEntitie <ClosurePig>(p => p.raiserID == raiserID); if (r == null) { throw(new Exception(string.Format("养户编号\"{0}\"不存在", raiserID))); } if (db.GetEntitie <Checkout>(p => p.PigID == r.ID) != null) { throw(new Exception(string.Format("已存在当前批次的结算记录"))); } this.PigID = r.ID; this.referPerson = Account.userName; this.referTime = DateTime.Now; return; }