/// <summary>
 /// 往用户运维操作表中插入数据
 /// </summary>
 /// <param name="info">用户操作产生的信息</param>
 /// <returns></returns>
 public static Boolean InsertUserprotectInfo(TBL_USERPROTECT info)
 {
     try
     {
         using (LampNetEntities db = new LampNetEntities())
         {
             db.TBL_USERPROTECT.Add(info);
             db.SaveChanges();
             return(true);
         }
     }
     catch
     {
         return(false);
     }
 }
Esempio n. 2
0
 /// <summary>
 /// 查找用户运维操作表中符合条件的信息
 /// </summary>
 /// <param name="whereLambda">u => u.userId == info.userId, u => u.userId</param>
 /// <returns>用户操作数据数组</returns>
 public static TBL_USERPROTECT[] SelectUserprotectInfo <TKey>(Expression <Func <TBL_USERPROTECT, bool> > whereLambda, Expression <Func <TBL_USERPROTECT, TKey> > orderBy)
 {
     try
     {
         using (LampNetEntities db = new LampNetEntities())
         {
             DbQuery <TBL_USERPROTECT> dataObject = db.TBL_USERPROTECT.Where(whereLambda).OrderBy(orderBy) as DbQuery <TBL_USERPROTECT>;
             TBL_USERPROTECT[]         infoList   = dataObject.ToArray();
             return(infoList);
         }
     }
     catch
     {
         TBL_USERPROTECT[] nullInfo = new TBL_USERPROTECT[0];
         return(nullInfo);
     }
 }
 /// <summary>
 /// 修改TBL_USERPROTECT表的数据
 /// </summary>
 /// <param name="whereLambda"> (u=>u.userId == info.userId, info) == true </param>
 /// 判断有无userId
 /// <param name="info"> info是需要修改的信息 </param>
 /// <notice></notice>
 public static Boolean UpdateUserprotectInfo(Expression <Func <TBL_USERPROTECT, bool> > whereLambda, TBL_USERPROTECT info)
 {
     try
     {
         using (LampNetEntities db = new LampNetEntities())
         {
             DbQuery <TBL_USERPROTECT> dataObject = db.TBL_USERPROTECT.Where(whereLambda) as DbQuery <TBL_USERPROTECT>;
             TBL_USERPROTECT           oldInfo    = dataObject.FirstOrDefault();
             oldInfo.userprotectKind    = info.userprotectKind;
             oldInfo.userprotectModule  = info.userprotectModule;
             oldInfo.userprotectLoginfo = info.userprotectLoginfo;
             oldInfo.userprotectOpttime = info.userprotectOpttime;
             db.SaveChanges();
             return(true);
         }
     }
     catch
     {
         return(false);
     }
 }
Esempio n. 4
0
        public ActionResult ProtectDataUserSelect(TBL_USERPROTECT table)
        {
            try
            {
                if (table.userId != 0)
                {
                    //如果有站点号,按照站点号查找
                    int sumPage = GetSumPage(30);
                    int nowPage = 1;
                    TBL_USERPROTECT[] ProtectUserInfo = GetPagedList(1, 30, u => u.userId == table.userId, u => u.userId);
                    ViewBag.nowPage = nowPage;
                    ViewBag.sumPage = sumPage;
                    TBL_USER[] userInfo = SelectTools.SelectUserInfo(u => u.userId == u.userId, u => u.userId);
                    if (userInfo == null || userInfo.Length == 0)
                    {
                        return(Content("没有此展示!"));
                    }
                    ViewBag.ProtectUserInfo = ProtectUserInfo;
                    ViewBag.userInfo        = userInfo;

                    HttpCookie cookie = Request.Cookies["userId"];
                    if (cookie.Name != null)
                    {
                        ViewBag.user = cookie.Value;
                    }
                    return(View());
                }
                else if (table.userprotectKind != -1)
                {
                    //如果输入了时间,按时间查找
                    int sumPage = GetSumPage(30);
                    int nowPage = 1;
                    TBL_USERPROTECT[] ProtectUserInfo = GetPagedList(1, 30, u => u.userprotectKind == table.userprotectKind, u => u.userId);
                    ViewBag.nowPage = nowPage;
                    ViewBag.sumPage = sumPage;
                    TBL_USER[] userInfo = SelectTools.SelectUserInfo(u => u.userId == u.userId, u => u.userId);
                    if (userInfo == null || userInfo.Length == 0)
                    {
                        return(Content("没有此展示!"));
                    }
                    ViewBag.ProtectUserInfo = ProtectUserInfo;
                    ViewBag.userInfo        = userInfo;

                    HttpCookie cookie = Request.Cookies["userId"];
                    if (cookie.Name != null)
                    {
                        ViewBag.user = cookie.Value;
                    }
                    return(View());
                }
                else if (table.userprotectModule != -1)
                {
                    //如果没有时间和站点号,则按照名称查找
                    int sumPage = GetSumPage(30);
                    int nowPage = 1;
                    TBL_USERPROTECT[] ProtectUserInfo = GetPagedList(1, 30, u => u.userprotectModule == table.userprotectModule, u => u.userId);
                    ViewBag.nowPage = nowPage;
                    ViewBag.sumPage = sumPage;
                    TBL_USER[] userInfo = SelectTools.SelectUserInfo(u => u.userId == u.userId, u => u.userId);
                    if (userInfo == null || userInfo.Length == 0)
                    {
                        return(Content("没有此展示!"));
                    }
                    ViewBag.ProtectUserInfo = ProtectUserInfo;
                    ViewBag.userInfo        = userInfo;

                    HttpCookie cookie = Request.Cookies["userId"];
                    if (cookie.Name != null)
                    {
                        ViewBag.user = cookie.Value;
                    }
                    return(View());
                }
                else
                {
                    return(Content("查询信息为空!"));
                }
            }
            catch
            {
                return(Content("查询失败!(ERROR)"));
            }
        }