コード例 #1
0
 /// <summary>
 /// 往设备运维操作表中插入数据
 /// </summary>
 /// <param name="info">用户操作设备产生的信息</param>
 /// <returns></returns>
 public static Boolean InsertDeviceprotectInfo(TBL_DEVICEPROTECT info)
 {
     try
     {
         using (LampNetEntities db = new LampNetEntities())
         {
             db.TBL_DEVICEPROTECT.Add(info);
             db.SaveChanges();
             return(true);
         }
     }
     catch
     {
         return(false);
     }
 }
コード例 #2
0
 /// <summary>
 /// 查找设备运维数据表中符合条件的信息
 /// </summary>
 /// <param name="whereLambda">u => u.userId == info.userId, u => u.userId</param>
 /// <param name="whereLambda">u => u.siteId == info.siteId, u => u.siteId</param>
 /// <param name="whereLambda">u => u.ammeterId == info.ammeterId, u => u.ammeterId</param>
 /// <returns>设备运维数据数组</returns>
 public static TBL_DEVICEPROTECT[] SelectDeviceprotectInfo <TKey>(Expression <Func <TBL_DEVICEPROTECT, bool> > whereLambda, Expression <Func <TBL_DEVICEPROTECT, TKey> > orderBy)
 {
     try
     {
         using (LampNetEntities db = new LampNetEntities())
         {
             DbQuery <TBL_DEVICEPROTECT> dataObject = db.TBL_DEVICEPROTECT.Where(whereLambda).OrderBy(orderBy) as DbQuery <TBL_DEVICEPROTECT>;
             TBL_DEVICEPROTECT[]         infoList   = dataObject.ToArray();
             return(infoList);
         }
     }
     catch
     {
         TBL_DEVICEPROTECT[] nullInfo = new TBL_DEVICEPROTECT[0];
         return(nullInfo);
     }
 }
コード例 #3
0
 /// <summary>
 /// 修改TBL_DEVICEPROTECT表的数据
 /// </summary>
 /// <param name="whereLambda"> (u=>u.siteId == info.siteId, info) == true </param>
 /// <param name="whereLambda"> (u=>u.siteId == info.siteId, info) == true </param>
 /// <param name="whereLambda"> (u=>u.siteId == info.siteId, info) == true </param>
 /// 判断有无 三个参数都要与原数据中的一样才能修改,否则只能作为新数据插入
 /// <param name="info"> info是需要修改的信息 </param>
 /// <notice></notice>
 public static Boolean UpdateDeviceprotectInfo(Expression <Func <TBL_DEVICEPROTECT, bool> > whereLambda, TBL_DEVICEPROTECT info)
 {
     try
     {
         using (LampNetEntities db = new LampNetEntities())
         {
             DbQuery <TBL_DEVICEPROTECT> dataObject = db.TBL_DEVICEPROTECT.Where(whereLambda) as DbQuery <TBL_DEVICEPROTECT>;
             TBL_DEVICEPROTECT           oldInfo    = dataObject.FirstOrDefault();
             oldInfo.deviceprotectKind    = info.deviceprotectKind;
             oldInfo.deviceprotectModule  = info.deviceprotectModule;
             oldInfo.deviceprotectLoginfo = info.deviceprotectLoginfo;
             oldInfo.deviceprotectOpttime = info.deviceprotectOpttime;
             db.SaveChanges();
             return(true);
         }
     }
     catch
     {
         return(false);
     }
 }
コード例 #4
0
        public ActionResult ProtectDataDeviceSelect(TBL_DEVICEPROTECT table)
        {
            try
            {
                if (table.userId != 0)
                {
                    //按照用户号查找
                    int sumPage = GetSumPage(30);
                    int nowPage = 1;
                    TBL_DEVICEPROTECT[] ProtectDeviceInfo = GetPagedList(1, 30, u => u.userId == table.userId, u => u.userId);
                    ViewBag.nowPage = nowPage;
                    ViewBag.sumPage = sumPage;
                    TBL_SITE[]    siteInfo    = SelectTools.SelectSiteInfo(u => u.siteId == u.siteId, u => u.siteId);
                    TBL_AMMETER[] ammeterInfo = SelectTools.SelectAmmeterInfo(u => u.ammeterId == u.ammeterId, u => u.ammeterId);
                    TBL_USER[]    userInfo    = SelectTools.SelectUserInfo(u => u.userId == u.userId, u => u.userId);
                    ViewBag.userInfo          = userInfo;
                    ViewBag.siteInfo          = siteInfo;
                    ViewBag.ammeterInfo       = ammeterInfo;
                    ViewBag.ProtectDeviceInfo = ProtectDeviceInfo;

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

                    return(View());
                }
                else if (table.siteId != -1)
                {
                    //按站点查找
                    int sumPage = GetSumPage(30);
                    int nowPage = 1;
                    TBL_DEVICEPROTECT[] ProtectDeviceInfo = GetPagedList(1, 30, u => u.siteId == table.siteId, u => u.siteId);
                    ViewBag.nowPage = nowPage;
                    ViewBag.sumPage = sumPage;
                    TBL_SITE[]    siteInfo    = SelectTools.SelectSiteInfo(u => u.siteId == u.siteId, u => u.siteId);
                    TBL_AMMETER[] ammeterInfo = SelectTools.SelectAmmeterInfo(u => u.ammeterId == u.ammeterId, u => u.ammeterId);
                    TBL_USER[]    userInfo    = SelectTools.SelectUserInfo(u => u.userId == u.userId, u => u.userId);
                    ViewBag.userInfo          = userInfo;
                    ViewBag.siteInfo          = siteInfo;
                    ViewBag.ammeterInfo       = ammeterInfo;
                    ViewBag.ProtectDeviceInfo = ProtectDeviceInfo;

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

                    return(View());
                }
                else if (table.ammeterId != -1)
                {
                    //按照电表查找
                    int sumPage = GetSumPage(30);
                    int nowPage = 1;
                    TBL_DEVICEPROTECT[] ProtectDeviceInfo = GetPagedList(1, 30, u => u.ammeterId == table.ammeterId, u => u.ammeterId);
                    ViewBag.nowPage = nowPage;
                    ViewBag.sumPage = sumPage;
                    TBL_SITE[]    siteInfo    = SelectTools.SelectSiteInfo(u => u.siteId == u.siteId, u => u.siteId);
                    TBL_AMMETER[] ammeterInfo = SelectTools.SelectAmmeterInfo(u => u.ammeterId == u.ammeterId, u => u.ammeterId);
                    TBL_USER[]    userInfo    = SelectTools.SelectUserInfo(u => u.userId == u.userId, u => u.userId);
                    ViewBag.userInfo          = userInfo;
                    ViewBag.siteInfo          = siteInfo;
                    ViewBag.ammeterInfo       = ammeterInfo;
                    ViewBag.ProtectDeviceInfo = ProtectDeviceInfo;

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

                    return(View());
                }
                else if (table.deviceprotectKind != -1)
                {
                    //按照电表查找
                    int sumPage = GetSumPage(30);
                    int nowPage = 1;
                    TBL_DEVICEPROTECT[] ProtectDeviceInfo = GetPagedList(1, 30, u => u.deviceprotectKind == table.deviceprotectKind, u => u.userId);
                    ViewBag.nowPage = nowPage;
                    ViewBag.sumPage = sumPage;
                    TBL_SITE[]    siteInfo    = SelectTools.SelectSiteInfo(u => u.siteId == u.siteId, u => u.siteId);
                    TBL_AMMETER[] ammeterInfo = SelectTools.SelectAmmeterInfo(u => u.ammeterId == u.ammeterId, u => u.ammeterId);
                    TBL_USER[]    userInfo    = SelectTools.SelectUserInfo(u => u.userId == u.userId, u => u.userId);
                    ViewBag.userInfo          = userInfo;
                    ViewBag.siteInfo          = siteInfo;
                    ViewBag.ammeterInfo       = ammeterInfo;
                    ViewBag.ProtectDeviceInfo = ProtectDeviceInfo;

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

                    return(View());
                }
                else if (table.deviceprotectModule != -1)
                {
                    //按照电表查找
                    int sumPage = GetSumPage(30);
                    int nowPage = 1;
                    TBL_DEVICEPROTECT[] ProtectDeviceInfo = GetPagedList(1, 30, u => u.deviceprotectModule == table.deviceprotectModule, u => u.userId);
                    ViewBag.nowPage = nowPage;
                    ViewBag.sumPage = sumPage;
                    TBL_SITE[]    siteInfo    = SelectTools.SelectSiteInfo(u => u.siteId == u.siteId, u => u.siteId);
                    TBL_AMMETER[] ammeterInfo = SelectTools.SelectAmmeterInfo(u => u.ammeterId == u.ammeterId, u => u.ammeterId);
                    TBL_USER[]    userInfo    = SelectTools.SelectUserInfo(u => u.userId == u.userId, u => u.userId);
                    ViewBag.userInfo          = userInfo;
                    ViewBag.siteInfo          = siteInfo;
                    ViewBag.ammeterInfo       = ammeterInfo;
                    ViewBag.ProtectDeviceInfo = ProtectDeviceInfo;

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

                    return(View());
                }
                else
                {
                    return(Content("查询信息为空!"));
                }
            }
            catch
            {
                return(Content("查询失败!(ERROR)"));
            }
        }