public void LowLyingPolice() { LowLyingModel llmodel = new LowLyingModel(); LowLyingOldModel llomodel = new LowLyingOldModel(); List <glxxModel> glxxlist = llbll.GetGlxxList(); foreach (var glxxitem in glxxlist) { List <glxxModel> glxxChildrenlist = llbll.getGlxxChildren(glxxitem.id); foreach (var sbxxitem in glxxChildrenlist) { List <sbxxModel> getSbxxList = llbll.getSbxxList(sbxxitem.id); foreach (var lsjltemp in getSbxxList) { LowLyingModel model = llbll.GetLowLyingModel(lsjltemp.id); if (model != null) { model.id = lsjltemp.id; model.jkdmc = lsjltemp.name; model.zt = lsjltemp.isenabled == "是" ? "启用" : "未启用"; model.whdw = glxxitem.name; model.whry = ""; model.dz = sbxxitem.name; llbll.Edit(model); lsjlModel getOldRecordingList = llbll.getOldRecordingList(lsjltemp.id); llomodel.lowid = lsjltemp.id; llomodel.bjz = getOldRecordingList.waterlevel.ToString(); llomodel.bjljz = model.bjljz; llomodel.cjsj = getOldRecordingList.recordingtime; llomodel.clqk = ""; decimal bjljz = Convert.ToDecimal(model.bjljz); if (bjljz > getOldRecordingList.waterlevel) { llomodel.sfbj = 0; } else { llomodel.sfbj = 1; } llbll.AddPolice(llomodel); } else { llmodel.id = lsjltemp.id; llmodel.jkdmc = lsjltemp.name; llmodel.zt = lsjltemp.isenabled == "是" ? "启用" : "未启用"; llmodel.whdw = glxxitem.name; llmodel.whry = ""; llmodel.bjljz = "0"; llmodel.dz = sbxxitem.name; llbll.Add(llmodel); } } } } }
/// <summary> /// 根据ID查看详情 /// </summary> /// <param name="id"></param> /// <returns></returns> public LowLyingModel GetLowLyingModel(int id) { LowLyingModel model = new LowLyingModel(); using (Entities db = new Entities()) { string sql = string.Format(@"select lo.id,lo.jkdmc,lo.zt,lo.whdw,lo.whry,lo.bjljz,lo.dz,count(ln.lowid) as lsbjsl from low_oldlying lo left JOIN low_newlying ln on lo.id=ln.lowid and ln.sfbj=1 GROUP BY ln.lowid"); IEnumerable <LowLyingModel> querybale = db.Database.SqlQuery <LowLyingModel>(sql); model = querybale.FirstOrDefault(a => a.id == id); } return(model); }
/// <summary> /// 修改 /// </summary> /// <param name="model"></param> public void Edit(LowLyingModel model) { using (Entities db = new Entities()) { low_oldlying lmodel = db.low_oldlying.FirstOrDefault(a => a.id == model.id); lmodel.id = model.id; lmodel.jkdmc = model.jkdmc; lmodel.zt = model.zt; lmodel.whdw = model.whdw; lmodel.whry = model.whry; lmodel.dz = model.dz; db.SaveChanges(); } }
/// <summary> /// 添加 /// </summary> /// <param name="model"></param> public void Add(LowLyingModel model) { using (Entities db = new Entities()) { low_oldlying lmodel = new low_oldlying(); lmodel.id = model.id; lmodel.jkdmc = model.jkdmc; lmodel.zt = model.zt; lmodel.whdw = model.whdw; lmodel.whry = model.whry; lmodel.bjljz = model.bjljz; lmodel.dz = model.dz; db.low_oldlying.Add(lmodel); db.SaveChanges(); } }
/// <summary> /// 修改 /// </summary> /// <param name="model"></param> public void Edit(LowLyingModel model) { dal.Edit(model); }
/// <summary> /// 添加 /// </summary> /// <param name="model"></param> public void Add(LowLyingModel model) { dal.Add(model); }