public ActionResult KeyManage()
        {
            var gridModel = new KeyManageGridModel();

            SetupkeyMangeGrid(gridModel.KeyManageGrid);
            return(View(gridModel));
        }
        public ActionResult KeyManage_RequestData()
        {
            var gridModel = new KeyManageGridModel();

            SetupkeyMangeGrid(gridModel.KeyManageGrid);
            var keys = (from e in db.ekey
                        join u in db.aspnet_CustomProfile on e.UserId equals u.UserId into eu
                        from eus in eu.DefaultIfEmpty()
                        select new { e.HardwareID, e.CardNo, e.CreateDate, e.IsUse, e.UserId, eus.FullName }).ToList();
            var lkeys = keys.Select(s => new{ s.HardwareID, s.CardNo, s.CreateDate, s.IsUse, UserId = s.UserId.ToString(), s.FullName });

            return(gridModel.KeyManageGrid.DataBind(lkeys.ToList().AsQueryable()));
        }
        public ActionResult KeyManage_EditData(DXInfo.Models.ekey key)
        {
            var gridModel = new KeyManageGridModel();

            SetupkeyMangeGrid(gridModel.KeyManageGrid);
            if (gridModel.KeyManageGrid.AjaxCallBackMode == AjaxCallBackMode.EditRow)
            {
                using (var context = db)
                {
                    var oldkey = context.ekey.Where(w => w.HardwareID == key.HardwareID).FirstOrDefault();
                    if (oldkey != null)
                    {
                        oldkey.IsUse  = key.IsUse;
                        oldkey.UserId = key.UserId;
                        context.SaveChanges();
                    }
                }
            }
            return(RedirectToAction("KeyManage"));
        }