コード例 #1
0
ファイル: AjaxController.cs プロジェクト: 917457200/TY
        public string OderOa(int Code, int orderCode, string order)
        {
            GetCookie.ExistCookie();
            BLL.NETDISKDBEntities Db  = new BLL.NETDISKDBEntities();
            BLL.NETDISKDBEntities Db2 = new BLL.NETDISKDBEntities();
            int sort;

            BLL.Link L = (from B in Db.Link
                          where B.Code == Code
                          select B).ToList().FirstOrDefault();

            BLL.Link L2 = (from B in Db.Link
                           where B.Code == orderCode
                           select B).ToList().FirstOrDefault();

            sort = (int)L.sort;

            L.sort  = L2.sort;
            L2.sort = sort;

            Db.Link.Attach(L);
            Db.Entry(L).Property(x => x.sort).IsModified = true;
            Db.SaveChanges();
            Db2.Link.Attach(L2);
            Db2.Entry(L2).Property(x => x.sort).IsModified = true;
            Db2.SaveChanges();
            return("Suc");
        }
コード例 #2
0
ファイル: RoleController.cs プロジェクト: 917457200/TY
        public ActionResult Edit(BLL.SMSModel.RoleInfo model)
        {
            try
            {
                BLL.Cookie.TeUser U    = GetCookie.GetUserCookie();
                RoleInfo          item = new RoleInfo();
                ///系统验证

                if (string.IsNullOrEmpty(Request.Form["Link"]))
                {
                    return(Content(@"<script language='javascript'> alert('请选择系统权限!');location.href='" + Url.Action("Edit", new { Code = model.Code }) + "'; </script>", "Text/html"));
                }
                if (UserManager.IsContainRoleInfoName(model.Name) && model.Name != TempData["Name"].ToString())
                {
                    return(Content(@"<script language='javascript'> alert('该角色已经存在,请不要重复!');location.href='" + Url.Action("Edit", new { Code = model.Code }) + "'; </script>", "Text/html"));
                }
                item.code        = model.Code;
                item.handledID   = U.userCode;
                item.handledDate = DateTime.Now;
                item.name        = model.Name;
                item.note        = model.Note == null ? "" : model.Note;
                UserManager.UpdateRoleInfoItem(item);
                Role.delOaRoleByRoleCode(model.Code);

                string LinkCodes = Request.Form["Link"].ToString();
                //添加数据
                using (BLL.NETDISKDBEntities Db = new BLL.NETDISKDBEntities())
                {
                    if (LinkCodes.IndexOf(",") > -1)
                    {
                        string[] LinkCode = LinkCodes.Split(',');
                        for (int i = 0; i < LinkCode.Length; i++)
                        {
                            BLL.OaRole R = new BLL.OaRole();
                            R.LinkCode = LinkCode[i].ToString();
                            R.RoleCode = model.Code.ToString();
                            Db.OaRole.Add(R);
                        }
                    }
                    else
                    {
                        BLL.OaRole R = new BLL.OaRole();
                        R.LinkCode = LinkCodes.ToString();
                        R.RoleCode = model.Code.ToString();
                        Db.OaRole.Add(R);
                    }
                    Db.SaveChanges();
                }
                BLL.Log.UserLog.AddUserLog("添加修改成功", GetCookie.GetUserCookie().userName + " 成功修改 " + model.Name + " 角色 ");
            }
            catch (Exception ex)
            {
                BLL.Log.UserLog.AddUserLog("修改角色失败", ex.Message);
                throw;
            }
            return(View("RoleList"));
        }
コード例 #3
0
ファイル: AjaxController.cs プロジェクト: 917457200/TY
 /// <summary>
 /// 获取系统目录
 /// </summary>
 /// <param name="d"></param>
 /// <param name="e"></param>
 /// <returns></returns>
 public ActionResult GetOaMeun(string d, string e)
 {
     GetCookie.ExistCookie();
     using (BLL.NETDISKDBEntities Db = new BLL.NETDISKDBEntities())
     {
         //数据库访问模式
         var Menu = from b in Db.Menu
                    orderby b.MenuCode
                    select b;
         return(Json(Menu.ToList(), JsonRequestBehavior.AllowGet));
     }
 }
コード例 #4
0
ファイル: RoleController.cs プロジェクト: 917457200/TY
        public ActionResult Add(BLL.SMSModel.RoleInfo model)
        {
            try
            {
                string            partCode2, newCode;
                BLL.Cookie.TeUser U = GetCookie.GetUserCookie();
                ///系统验证
                string LinkCodes = Request.Form["Link"];
                if (string.IsNullOrEmpty(LinkCodes))
                {
                    return(Content(@"<script language='javascript'> alert('请选择系统权限!');location.href='" + Url.Action("Add") + "'; </script>", "Text/html"));
                }
                ///系统验证
                if (UserManager.IsContainRoleInfoName(model.Name))
                {
                    return(Content(@"<script language='javascript'> alert('该角色已经存在,请不要重复添加!');location.href='" + Url.Action("Add") + "'; </script>", "Text/html"));
                }
                ///Role加载
                RoleInfo item  = new RoleInfo();
                int      count = UserManager.GetRoleInfoCount("2");//自定义
                do
                {
                    count++;
                    if (count < 10)
                    {
                        partCode2 = "00" + count.ToString();
                    }
                    else if (count < 100)
                    {
                        partCode2 = "0" + count.ToString();
                    }
                    else
                    {
                        partCode2 = count.ToString().Substring(count.ToString().Length - 3, 3);
                    }

                    newCode = "2" + partCode2;
                }while(UserManager.IsContainRoleInfoCode(newCode));


                item.code        = newCode;
                item.handledID   = U.userCode;
                item.handledDate = DateTime.Now;
                item.name        = model.Name;
                item.note        = model.Note == null ? "" : model.Note;
                //添加数据
                UserManager.InsertRoleInfoItem(item);
                //添加数据
                if (LinkCodes.ToString().IndexOf(",") > -1)
                {
                    string[] LinkCode = LinkCodes.ToString().Split(',');
                    for (int i = 0; i < LinkCode.Length; i++)
                    {
                        using (BLL.NETDISKDBEntities Db = new BLL.NETDISKDBEntities())
                        {
                            BLL.OaRole R = new BLL.OaRole();
                            R.LinkCode = LinkCode[i].ToString();
                            R.RoleCode = newCode.ToString();
                            Db.OaRole.Add(R);
                            Db.SaveChanges();
                        }
                    }
                }
                else
                {
                    using (BLL.NETDISKDBEntities Db = new BLL.NETDISKDBEntities())
                    {
                        BLL.OaRole R = new BLL.OaRole();
                        R.LinkCode = LinkCodes.ToString();
                        R.RoleCode = newCode.ToString();
                        Db.OaRole.Add(R);
                        Db.SaveChanges();
                    }
                }
                BLL.Log.UserLog.AddUserLog("添加角色成功", GetCookie.GetUserCookie().userName + " 成功创建 " + model.Name + " 角色 ");
            }
            catch (Exception ex)
            {
                BLL.Log.UserLog.AddUserLog("创建角色失败", ex.Message);
                throw;
            }
            return(View("RoleList"));
        }