Ejemplo n.º 1
0
 public JsonResult GetCaseEdit(BA_Case result)
 {
     using (BuyunSiteEntities db = new BuyunSiteEntities())
     {
         var m = from t in db.BA_Case
                 where t.Name == result.Name && t.Id != result.Id
                 select t;
         if (m.Count() > 0)
         {
             return(Json(new { data = "fail", content = "案例名称重复!" }));
         }
         var BA_Case    = from t in db.BA_Case where t.Id == result.Id select t;
         var resultInfo = BA_Case.FirstOrDefault();
         resultInfo.Name       = result.Name;
         resultInfo.SubName    = result.SubName;
         resultInfo.Icon       = result.Icon;
         resultInfo.Background = result.Background;
         resultInfo.Image      = result.Image;
         resultInfo.ToUrl      = result.ToUrl;
         resultInfo.Content    = result.Content;
         resultInfo.Status     = result.Status;
         resultInfo.AddUser    = BasePage.GetCookie("UserNameCookie");
         resultInfo.AddTime    = DateTime.Now;
         db.SaveChanges();
         return(Json(new { data = "success", content = "修改案例成功!" }));
     }
 }
Ejemplo n.º 2
0
        protected override void HandleUnauthorizedRequest(AuthorizationContext context)
        {
            string User = BasePage.GetCookie("UserInfoCookie");

            if (string.IsNullOrEmpty(User))
            {
                HttpContext.Current.Response.Redirect("/Login/Login");
            }
            else
            {
                using (BuyunSiteEntities db = new BuyunSiteEntities())
                {
                    var serializer = new JavaScriptSerializer();
                    serializer.RegisterConverters(new[] { new DynamicJsonConverter() });
                    dynamic data         = serializer.Deserialize <object>(User);
                    string  UserCode     = data.UserCode;
                    string  UserPassword = data.UserPassword;
                    var     UserInfo     = db.Cu_User.Where(o => o.UserCode == UserCode && o.UserPassword == UserPassword);
                    if (UserInfo.Count() <= 0)
                    {
                        HttpContext.Current.Response.Redirect("/Login/Login");
                    }
                }
            }
        }
Ejemplo n.º 3
0
 /// <summary>
 /// 获取管理员的所有信息
 /// </summary>
 /// <returns></returns>
 public ActionResult GetAllUserInfo()
 {
     using (BuyunSiteEntities db = new BuyunSiteEntities())
     {
         var temp = from a in db.Cu_User
                    join b in db.Cu_UserAuthority on new { AuthorityId = (Int32)a.AuthorityId } equals new { AuthorityId = b.AuthorityId }
         select new
         {
             a.UserId,
             a.UserCode,
             a.UserName,
             a.UserPhone,
             a.UserPassword,
             a.IsonLine,
             a.Status,
             a.AddTime,
             a.AddUser,
             a.UpdateTime,
             a.UpdateUser,
             a.UserAuthority,
             a.AuthorityId,
             a.AgID,
             a.IsAdmin,
             a.PageSize,
             b.UserTypeName
         };
         var total = temp.Count();
         var users = temp.OrderBy(s => s.UserId);
         return(Json(new { data = users.ToList(), total = total }));
     }
 }
Ejemplo n.º 4
0
 /// <summary>
 /// 案例查询
 /// </summary>
 /// <param name="UserInfo"></param>
 /// <returns></returns>
 public JsonResult GetCaseList()
 {
     using (BuyunSiteEntities db = new BuyunSiteEntities())
     {
         int PageSize = Request["length"] == null ? 10 : Convert.ToInt32(Request["length"]);                                                 //显示多少数量
         int Page     = Convert.ToInt32(Request["start"]) == 0 ? 0 : Convert.ToInt32(Request["start"]) / Convert.ToInt32(Request["length"]); //当前页
         var search   = Request["search"];                                                                                                   //模糊搜索
         var draw     = Request["draw"];                                                                                                     //datatable固定传值,必需接收再传送,不用赋值
         var Code     = Request["Code"];
         var temp     = from a in db.BA_Case select a;
         var total    = temp.Where(o =>
                                   ((o.Name.Contains(Code) || string.IsNullOrEmpty(Code)))
                                   ).Count();
         var list = temp.OrderByDescending(s => s.Id).Where(o =>
                                                            ((o.Name.Contains(Code) || string.IsNullOrEmpty(Code)))
                                                            ).Skip(Page * PageSize).Take(PageSize);
         var data = new
         {
             draw            = draw,
             recordsTotal    = total,
             recordsFiltered = total,
             data            = list.ToList(),
         };
         return(Json(data));
     }
 }
Ejemplo n.º 5
0
 /// <summary>
 /// 获取菜单信息
 /// </summary>
 /// <param name="UserInfo"></param>
 /// <returns></returns>
 public JsonResult MenuList()
 {
     using (BuyunSiteEntities db = new BuyunSiteEntities())
     {
         var Menu = db.Cu_Menu;
         return(Json(new { data = Menu.ToList() }));
     }
 }
Ejemplo n.º 6
0
 /// <summary>
 /// 获取角色信息
 /// </summary>
 /// <param name="UserInfo"></param>
 /// <returns></returns>
 public JsonResult AuthorityList(Cu_User UserInfo)
 {
     using (BuyunSiteEntities db = new BuyunSiteEntities())
     {
         var Authority = db.Cu_UserAuthority;
         return(Json(new { data = Authority.ToList() }));
     }
 }
Ejemplo n.º 7
0
 /// <summary>
 /// 获取角色信息
 /// </summary>
 /// <param name="UserInfo"></param>
 /// <returns></returns>
 public JsonResult RoleById(int AuthorityId)
 {
     using (BuyunSiteEntities db = new BuyunSiteEntities())
     {
         var Role = db.Cu_UserAuthority.Where(o => o.AuthorityId == AuthorityId).FirstOrDefault();
         return(Json(new { data = Role }));
     }
 }
Ejemplo n.º 8
0
 /// <summary>
 /// 获取网站配置
 /// </summary>
 /// <returns></returns>
 public ActionResult GetAdvertisementInfo()
 {
     using (BuyunSiteEntities db = new BuyunSiteEntities())
     {
         var temp = from a in db.BA_Advertisement select a;
         var data = temp.OrderBy(s => s.AdvertisementId);
         return(Json(new { data = data.FirstOrDefault() }));
     }
 }
Ejemplo n.º 9
0
 /// <summary>
 /// 新增角色信息
 /// </summary>
 /// <param name="UserInfo"></param>
 /// <returns></returns>
 public JsonResult AddRole(Cu_UserAuthority Role)
 {
     using (BuyunSiteEntities db = new BuyunSiteEntities())
     {
         db.Cu_UserAuthority.Add(Role);
         db.SaveChanges();
         return(Json(new { data = "success", content = "新增角色成功!" }));
     }
 }
Ejemplo n.º 10
0
 /// <summary>
 /// 禁用启用
 /// </summary>
 /// <param name="userInfo"></param>
 /// <returns></returns>
 public JsonResult EditStatus(Cu_User UserInfo)
 {
     using (BuyunSiteEntities db = new BuyunSiteEntities())
     {
         Cu_User user = db.Cu_User.First(o => o.UserId == UserInfo.UserId);
         user.Status = UserInfo.Status;
         db.SaveChanges();
         return(Json(new { data = "success" }));
     }
 }
Ejemplo n.º 11
0
 public JsonResult ContactStatusEdit(int Id)
 {
     using (BuyunSiteEntities db = new BuyunSiteEntities())
     {
         var BA_Contact = db.BA_Contact.Where(o => o.Id == Id);
         BA_Contact.FirstOrDefault().Status = 1;
         db.SaveChanges();
         return(Json(new { data = "success", content = "已查看!" }));
     }
 }
Ejemplo n.º 12
0
 /// <summary>
 /// 根据ID查询案例
 /// </summary>
 /// <param name="Id"></param>
 /// <returns></returns>
 public JsonResult GetCaseById(int Id)
 {
     using (BuyunSiteEntities db = new BuyunSiteEntities())
     {
         var data = from t in db.BA_Case
                    where t.Id == Id
                    select t;
         return(Json(new { data = data.FirstOrDefault() }));
     }
 }
Ejemplo n.º 13
0
 /// <summary>
 /// 删除管理员
 /// </summary>
 /// <param name="userInfo"></param>
 /// <returns></returns>
 public JsonResult DelAdmin(Cu_User UserInfo)
 {
     using (BuyunSiteEntities db = new BuyunSiteEntities())
     {
         Cu_User user = db.Cu_User.First(o => o.UserId == UserInfo.UserId);
         db.Cu_User.Remove(user);
         db.SaveChanges();
         return(Json(new { data = "success" }));
     }
 }
Ejemplo n.º 14
0
        /// <summary>
        /// 获取角色信息
        /// </summary>
        /// <param name="UserInfo"></param>
        /// <returns></returns>
        public JsonResult AdminByUserIdList(Cu_User UserInfo)
        {
            int UserId = Convert.ToInt32(Request["UserId"]);

            using (BuyunSiteEntities db = new BuyunSiteEntities())
            {
                var Authority = from a in db.Cu_User where a.UserId == UserId select a;
                return(Json(new { data = Authority.ToList() }));
            }
        }
Ejemplo n.º 15
0
 /// <summary>
 /// 编辑角色信息
 /// </summary>
 /// <param name="UserInfo"></param>
 /// <returns></returns>
 public JsonResult EditRole(Cu_UserAuthority Role)
 {
     using (BuyunSiteEntities db = new BuyunSiteEntities())
     {
         var RoleInfo = from a in db.Cu_UserAuthority where a.AuthorityId == Role.AuthorityId select a;
         RoleInfo.FirstOrDefault().Authority    = Role.Authority;
         RoleInfo.FirstOrDefault().UserTypeName = Role.UserTypeName;
         db.SaveChanges();
         return(Json(new { data = "success", content = "修改角色成功!" }));
     }
 }
Ejemplo n.º 16
0
 /// <summary>
 /// 删除
 /// </summary>
 /// <param name="UserInfo"></param>
 /// <returns></returns>
 public JsonResult CaseDel(string strId)
 {
     using (BuyunSiteEntities db = new BuyunSiteEntities())
     {
         var List = strId.Split(',');
         foreach (var item in List)
         {
             var Id    = Convert.ToInt32(item);
             var dData = from a in db.BA_Case where a.Id == Id select a;
             db.BA_Case.Remove(dData.FirstOrDefault());
         }
         db.SaveChanges();
         return(Json(new { data = "success", content = "删除案例成功!" }));
     }
 }
Ejemplo n.º 17
0
        /// <summary>
        /// 删除角色信息
        /// </summary>
        /// <param name="UserInfo"></param>
        /// <returns></returns>
        public JsonResult DelRole(string AuthorityId)
        {
            using (BuyunSiteEntities db = new BuyunSiteEntities())
            {
                var RemoveId = AuthorityId.Split(',');
                foreach (var item in RemoveId)
                {
                    int Id   = Convert.ToInt32(item);
                    var Role = from t in db.Cu_UserAuthority where t.AuthorityId == Id select t;
                    db.Cu_UserAuthority.Remove(Role.FirstOrDefault());
                }

                db.SaveChanges();
                return(Json(new { data = "success", content = "删除角色成功!" }));
            }
        }
Ejemplo n.º 18
0
 public JsonResult GetCaseAdd(BA_Case result)
 {
     using (BuyunSiteEntities db = new BuyunSiteEntities())
     {
         var m = from t in db.BA_Case
                 where t.Name == result.Name
                 select t;
         if (m.Count() > 0)
         {
             return(Json(new { data = "fail", content = "案例名称重复!" }));
         }
         result.AddUser = BasePage.GetCookie("UserNameCookie");
         result.AddTime = DateTime.Now;
         db.BA_Case.Add(result);
         db.SaveChanges();
         return(Json(new { data = "success", content = "新增案例成功!" }));
     }
 }
Ejemplo n.º 19
0
        public JsonResult GetMenu()
        {
            using (BuyunSiteEntities db = new BuyunSiteEntities())
            {
                var     strUser = BasePage.GetCookie("UserInfoCookie");
                dynamic User    = DynamicJsonConverter.ParseJson(strUser);
                int     UserId  = User.UserId;

                if (User.IsAdmin == true)
                {
                    var Menu = from t in db.Cu_Menu select t;
                    return(Json(new { data = Menu.ToList() }));
                }
                else
                {
                    var Menu = from t in db.Cu_Menu
                               where
                               (int?)("," +
                                      ((from a in db.Cu_User
                                        join b in db.Cu_UserAuthority on new { AuthorityId = (Int32)a.AuthorityId } equals new { AuthorityId = b.AuthorityId }
                                        where
                                        a.UserId == UserId
                                        select new
                    {
                        b.Authority
                    }).FirstOrDefault().Authority) + ",").ToUpper().IndexOf(("," + t.MenuId.ToString().TrimStart() + ",").ToUpper()) + 1 > 0
                               select new
                    {
                        t.MenuId,
                        t.FMenuId,
                        t.MenuName,
                        t.Imageicon,
                        t.URLAddress,
                        t.Status,
                        t.AddTime,
                        t.AddUser,
                        t.UpdateTime,
                        t.UpdateUser,
                        t.IsBlank
                    };
                    return(Json(new { data = Menu.ToList() }));
                }
            }
        }
Ejemplo n.º 20
0
 /// <summary>
 /// 修改网站配置
 /// </summary>
 /// <param name="UserInfo"></param>
 /// <returns></returns>
 public JsonResult EditAdvertisement(BA_Advertisement Advertisement)
 {
     using (BuyunSiteEntities db = new BuyunSiteEntities())
     {
         var BA_Advertisement  = from a in db.BA_Advertisement where a.AdvertisementId == Advertisement.AdvertisementId select a;
         var AdvertisementInfo = BA_Advertisement.FirstOrDefault();
         AdvertisementInfo.CompanyName    = Advertisement.CompanyName;
         AdvertisementInfo.CompanyAddress = Advertisement.CompanyAddress;
         AdvertisementInfo.CompanyLogo    = Advertisement.CompanyLogo;
         AdvertisementInfo.CompanyPhone   = Advertisement.CompanyPhone;
         AdvertisementInfo.CompanyQRCode  = Advertisement.CompanyQRCode;
         AdvertisementInfo.Image          = Advertisement.Image;
         AdvertisementInfo.Email          = Advertisement.Email;
         AdvertisementInfo.UpdateTime     = DateTime.Now;
         AdvertisementInfo.UpdateUser     = BasePage.GetCookie("UserNameCookie");
         db.SaveChanges();
     }
     return(Json(new { data = "success", content = "修改网站配置成功!" }));
 }
Ejemplo n.º 21
0
 /// <summary>
 /// 增加管理员
 /// </summary>
 /// <param name="UserInfo"></param>
 /// <returns></returns>
 public JsonResult AddAdmin(Cu_User UserInfo)
 {
     using (BuyunSiteEntities db = new BuyunSiteEntities())
     {
         var chkUserCode = from a in db.Cu_User where a.UserCode == UserInfo.UserCode select a;
         if (chkUserCode.Count() > 0)
         {
             return(Json(new { data = "fail", content = "管理员编码重复!" }));
         }
         UserInfo.UserPassword = BasePage.Md5Hash(UserInfo.UserPassword);
         UserInfo.AddTime      = DateTime.Now;
         UserInfo.AddUser      = BasePage.GetCookie("UserNameCookie");
         UserInfo.Status       = 1;
         UserInfo.IsAdmin      = false;
         db.Cu_User.Add(UserInfo);
         db.SaveChanges();
     }
     return(Json(new { data = "success", content = "新增管理员成功!" }));
 }
Ejemplo n.º 22
0
 /// <summary>
 /// 修改
 /// </summary>
 /// <param name="UserInfo"></param>
 /// <returns></returns>
 public JsonResult FLinkEdit(BA_FriendshipLink result)
 {
     using (BuyunSiteEntities db = new BuyunSiteEntities())
     {
         var m = from t in db.BA_FriendshipLink
                 where t.Name == result.Name && t.Id != result.Id
                 select t;
         if (m.Count() > 0)
         {
             return(Json(new { data = "fail", content = "名称重复!" }));
         }
         var BA_FriendshipLink = from t in db.BA_FriendshipLink where t.Id == result.Id select t;
         var resultInfo        = BA_FriendshipLink.FirstOrDefault();
         resultInfo.Name    = result.Name;
         resultInfo.Icon    = result.Icon;
         resultInfo.ToUrl   = result.ToUrl;
         resultInfo.AddUser = BasePage.GetCookie("UserNameCookie");
         resultInfo.AddTime = DateTime.Now;
         db.SaveChanges();
         return(Json(new { data = "success", content = "修改成功!" }));
     }
 }
Ejemplo n.º 23
0
 /// <summary>
 /// 处理登录的信息
 /// </summary>
 /// <param name="userInfo"></param>
 /// <returns></returns>
 public JsonResult CheckUserLogin(Cu_User userInfo)
 {
     using (BuyunSiteEntities db = new BuyunSiteEntities())
     {
         //linq查询
         userInfo.UserPassword = BasePage.Md5Hash(userInfo.UserPassword);
         var users = from p in db.Cu_User
                     where p.UserCode == userInfo.UserCode && p.UserPassword == userInfo.UserPassword
                     select p;
         if (users.Count() > 0)
         {
             string strUser = DynamicJsonConverter.GetJson <Cu_User>(users.FirstOrDefault());
             BasePage.WriteCookie("UserNameCookie", users.FirstOrDefault().UserName, 0);
             BasePage.WriteCookie("UserInfoCookie", strUser, 0);
             return(Json(new { result = "success", content = "" }));
         }
         else
         {
             return(Json(new { result = "error", content = "用户名密码错误,请您检查" }));
         }
     }
 }
Ejemplo n.º 24
0
 /// <summary>
 /// 修改管理员
 /// </summary>
 /// <param name="UserInfo"></param>
 /// <returns></returns>
 public JsonResult EditAdmin(Cu_User UserInfo)
 {
     using (BuyunSiteEntities db = new BuyunSiteEntities())
     {
         var chkUserCode = from a in db.Cu_User where a.UserCode == UserInfo.UserCode && a.UserId != UserInfo.UserId select a;
         if (chkUserCode.Count() > 0)
         {
             return(Json(new { data = "fail", content = "管理员编码重复!" }));
         }
         var User = from a in db.Cu_User where a.UserId == UserInfo.UserId select a;
         if (!string.IsNullOrEmpty(UserInfo.UserPassword))
         {
             User.FirstOrDefault().UserPassword = BasePage.Md5Hash(UserInfo.UserPassword);
         }
         User.FirstOrDefault().UserName    = UserInfo.UserName;
         User.FirstOrDefault().UserCode    = UserInfo.UserCode;
         User.FirstOrDefault().UserPhone   = UserInfo.UserPhone;
         User.FirstOrDefault().AuthorityId = UserInfo.AuthorityId;
         User.FirstOrDefault().UpdateTime  = DateTime.Now;
         User.FirstOrDefault().UpdateUser  = BasePage.GetCookie("UserNameCookie");
         db.SaveChanges();
     }
     return(Json(new { data = "success", content = "修改管理员成功!" }));
 }