public void SingleSettingInspectionUpdate(TBL_SIGCONTROL sig) { try { HttpCookie cookie = Request.Cookies["userId"]; if (cookie.Name != null) { ViewBag.user = cookie.Value; } if (UpdateTools.UpdateSigcontrolInfo(u => u.ammeterId == sig.ammeterId, sig) == true) { Response.Write("<script language='javascript'>alert('更新成功!');</script>"); Response.Redirect("/SingleControl/SingleSettingInspection"); } else { Response.Write("<script language='javascript'>alert('更新失败!');</script>"); Response.Redirect("/SingleControl/SingleSettingInspection"); } } catch { Response.Write("<script language='javascript'>alert('更新出错!');</script>"); Response.Redirect("/SingleControl/SingleSettingInspection"); } }
/// <summary> /// 往单控信息表中插入数据 /// </summary> /// <param name="info">前端页面输入的信息</param> /// <returns></returns> public static Boolean InsertSigcontrolInfo(TBL_SIGCONTROL info) { try { using (LampNetEntities db = new LampNetEntities()) { db.TBL_SIGCONTROL.Add(info); db.SaveChanges(); return(true); } } catch { return(false); } }
/// <summary> /// 查找单控信息表中符合条件的信息 /// </summary> /// <param name="whereLambda">u => u.ammeterId == info.ammeterId, u => u.ammeterId</param> /// <returns>单控信息数组</returns> public static TBL_SIGCONTROL[] SelectSigcontrolInfo <TKey>(Expression <Func <TBL_SIGCONTROL, bool> > whereLambda, Expression <Func <TBL_SIGCONTROL, TKey> > orderBy) { try { using (LampNetEntities db = new LampNetEntities()) { DbQuery <TBL_SIGCONTROL> dataObject = db.TBL_SIGCONTROL.Where(whereLambda).OrderBy(orderBy) as DbQuery <TBL_SIGCONTROL>; TBL_SIGCONTROL[] infoList = dataObject.ToArray(); return(infoList); } } catch { TBL_SIGCONTROL[] nullInfo = new TBL_SIGCONTROL[0]; return(nullInfo); } }
/// <summary> /// 修改TBL_SIGCONTROL表的数据 /// </summary> /// <param name="whereLambda"> (u=>u.ammeterId == info.ammeterId, info) == true </param> /// 判断有无ammeterId /// <param name="info"> info是需要修改的信息 </param> /// <notice></notice> public static Boolean UpdateSigcontrolInfo(Expression <Func <TBL_SIGCONTROL, bool> > whereLambda, TBL_SIGCONTROL info) { try { using (LampNetEntities db = new LampNetEntities()) { DbQuery <TBL_SIGCONTROL> dataObject = db.TBL_SIGCONTROL.Where(whereLambda) as DbQuery <TBL_SIGCONTROL>; TBL_SIGCONTROL oldInfo = dataObject.FirstOrDefault(); oldInfo.ammeterSwistatus = info.ammeterSwistatus; oldInfo.sigcontrolIndtime = info.sigcontrolIndtime; oldInfo.sigcontrolInsstatime = info.sigcontrolInsstatime; oldInfo.sigcontrolInsendtime = info.sigcontrolInsendtime; oldInfo.sigcontrolAlacurup = info.sigcontrolAlacurup; oldInfo.sigcontrolAlacurlow = info.sigcontrolAlacurlow; db.SaveChanges(); return(true); } } catch { return(false); } }