/// <summary>
 /// 往运行数据表中插入数据
 /// </summary>
 /// <param name="info">系统产生的信息(本系统模拟)</param>
 /// <returns></returns>
 public static Boolean InsertRunInfo(TBL_RUN info)
 {
     try
     {
         using (LampNetEntities db = new LampNetEntities())
         {
             db.TBL_RUN.Add(info);
             db.SaveChanges();
             return(true);
         }
     }
     catch
     {
         return(false);
     }
 }
Ejemplo n.º 2
0
 /// <summary>
 /// 查找运行数据表中符合条件的信息
 /// </summary>
 /// <param name="whereLambda">u => u.siteId == info.siteId, u => u.siteId</param>
 /// <returns>运行数据数组</returns>
 public static TBL_RUN[] SelectRunInfo <TKey>(Expression <Func <TBL_RUN, bool> > whereLambda, Expression <Func <TBL_RUN, TKey> > orderBy)
 {
     try
     {
         using (LampNetEntities db = new LampNetEntities())
         {
             DbQuery <TBL_RUN> dataObject = db.TBL_RUN.Where(whereLambda).OrderBy(orderBy) as DbQuery <TBL_RUN>;
             TBL_RUN[]         infoList   = dataObject.ToArray();
             return(infoList);
         }
     }
     catch
     {
         TBL_RUN[] nullInfo = new TBL_RUN[0];
         return(nullInfo);
     }
 }
 /// <summary>
 /// 修改TBL_RUN表的数据
 /// </summary>
 /// <param name="whereLambda"> (u=>u.siteId == info.siteId, info) == true </param>
 /// 判断有无siteId
 /// <param name="info"> info是需要修改的信息 </param>
 /// <notice></notice>
 public static Boolean UpdateRunInfo(Expression <Func <TBL_RUN, bool> > whereLambda, TBL_RUN info)
 {
     try
     {
         using (LampNetEntities db = new LampNetEntities())
         {
             DbQuery <TBL_RUN> dataObject = db.TBL_RUN.Where(whereLambda) as DbQuery <TBL_RUN>;
             TBL_RUN           oldInfo    = dataObject.FirstOrDefault();
             oldInfo.runVolt      = info.runVolt;
             oldInfo.runCurrent   = info.runCurrent;
             oldInfo.runStavalue  = info.runStavalue;
             oldInfo.runFreshtime = info.runFreshtime;
             db.SaveChanges();
             return(true);
         }
     }
     catch
     {
         return(false);
     }
 }
        public ActionResult RunDataSelect(string siteName, TBL_RUN run)
        {
            try
            {
                if (run.siteId != 0)
                {
                    //如果有站点号,按照站点号查找
                    int       sumPage = GetSumPage(30);
                    int       nowPage = 1;
                    TBL_RUN[] runInfo = GetPagedList(1, 30, u => u.siteId == run.siteId, u => u.siteId);
                    ViewBag.nowPage = nowPage;
                    ViewBag.sumPage = sumPage;
                    TBL_SITE[] siteInfo = SelectTools.SelectSiteInfo(u => u.siteId == u.siteId, u => u.siteId);
                    if (siteInfo == null || siteInfo.Length == 0)
                    {
                        return(Content("没有此展示!"));
                    }
                    ViewBag.runInfo  = runInfo;
                    ViewBag.siteInfo = siteInfo;

                    HttpCookie cookie = Request.Cookies["userId"];
                    if (cookie.Name != null)
                    {
                        ViewBag.user = cookie.Value;
                    }

                    return(View());
                }
                else if (run.runFreshtime != null)
                {
                    //如果输入了时间,按时间查找
                    int       sumPage = GetSumPage(30);
                    int       nowPage = 1;
                    TimeSpan  ts1     = new TimeSpan(DateTime.Now.Ticks);
                    DateTime  dt      = Convert.ToDateTime(run.runFreshtime);
                    TBL_RUN[] runInfo = GetPagedList(1, 30, u => u.runFreshtime == dt, u => u.siteId);
                    ViewBag.nowPage = nowPage;
                    ViewBag.sumPage = sumPage;
                    TBL_SITE[] siteInfo = SelectTools.SelectSiteInfo(u => u.siteId == u.siteId, u => u.siteId);
                    if (siteInfo == null || siteInfo.Length == 0)
                    {
                        return(Content("没有此展示!"));
                    }
                    ViewBag.runInfo  = runInfo;
                    ViewBag.siteInfo = siteInfo;

                    HttpCookie cookie = Request.Cookies["userId"];
                    if (cookie.Name != null)
                    {
                        ViewBag.user = cookie.Value;
                    }

                    return(View());
                }
                else
                {
                    //如果没有时间和站点号,则按照名称查找
                    int        sumPage = GetSumPage(30);
                    int        nowPage = 1;
                    TBL_SITE[] info    = SelectTools.SelectSiteInfo(u => u.siteName == siteName, u => u.siteId);
                    int        siteId  = info[0].siteId;
                    TBL_RUN[]  runInfo = GetPagedList(1, 30, u => u.siteId == siteId, u => u.siteId);
                    ViewBag.nowPage = nowPage;
                    ViewBag.sumPage = sumPage;
                    TBL_SITE[] siteInfo = SelectTools.SelectSiteInfo(u => u.siteId == u.siteId, u => u.siteId);
                    if (siteInfo == null || siteInfo.Length == 0)
                    {
                        return(Content("没有此展示!"));
                    }
                    ViewBag.runInfo  = runInfo;
                    ViewBag.siteInfo = siteInfo;

                    HttpCookie cookie = Request.Cookies["userId"];
                    if (cookie.Name != null)
                    {
                        ViewBag.user = cookie.Value;
                    }

                    return(View());
                }
            }
            catch
            {
                return(Content("查询失败!(ERROR)"));
            }
        }