Beispiel #1
0
        // GET: Role
        public ActionResult Index(string CompanyId)
        {
            ViewBag.Companyid = CompanyId;
            CompanyId         = Base64MIMA.JIE(CompanyId);
            #region 添加显示的权限
            //查出所有父权限
            string    sqlstr = string.Format("select * from Author where PID is null and IsValid=0 and Fanwei=0");
            DataTable dt     = sql.GetDataTableCommand(sqlstr);
            //根据父id得到子id
            List <AuthorModellist> authorlist = new List <AuthorModellist>();
            if (dt.Rows.Count > 0)
            {
                for (int i = 0; i < dt.Rows.Count; i++)
                {
                    AuthorModellist Authors = new AuthorModellist();
                    Authors.Id   = dt.Rows[i]["AuthorID"].ToString();
                    Authors.Name = dt.Rows[i]["AuthorName"].ToString();
                    List <AuthorModel> amlist  = new List <AuthorModel>();
                    string             sqlstr2 = string.Format("select * from Author where PID={0} and IsValid=0 and Fanwei=0", dt.Rows[i]["AuthorID"].ToString());
                    DataTable          dt2     = sql.GetDataTableCommand(sqlstr2);
                    if (dt2.Rows.Count > 0)
                    {
                        for (int ii = 0; ii < dt2.Rows.Count; ii++)
                        {
                            AuthorModel am = new AuthorModel();
                            am.AuthorId    = dt2.Rows[ii]["AuthorID"].ToString();
                            am.AuthorName  = dt2.Rows[ii]["AuthorName"].ToString();
                            am.AuthorUrl   = dt2.Rows[ii]["AuthorUrl"].ToString();
                            am.AuthorIcons = dt2.Rows[ii]["AuthorIcon"].ToString();
                            amlist.Add(am);
                        }
                        Authors.listAuthor = amlist;
                    }

                    authorlist.Add(Authors);
                }
                ViewBag.authorlist2 = authorlist;
            }
            else
            {
                ViewBag.authorlist2 = null;
            }
            #endregion

            #region 查询
            //根据公司查对应的角色
            string    sqlstrRole = string.Format("select * from Role where CompanyID='{0}'", CompanyId);
            DataTable dtRole     = sql.GetDataTableCommand(sqlstrRole);
            if (dtRole.Rows.Count > 0)
            {
                ViewBag.Rolelist = dtRole;
            }
            else
            {
                ViewBag.Rolelist = null;
            }
            #endregion
            return(View());
        }
Beispiel #2
0
        //添加页面
        public ActionResult AddRole(string CompanyID)
        {
            #region 添加显示的权限
            try
            {
                //查出所有父权限
                string    sqlstr = string.Format("select * from Author where PID is null and IsValid=0 and Fanwei=0");
                DataTable dt     = sql.GetDataTableCommand(sqlstr);
                //根据父id得到子id
                List <AuthorModellist> authorlist = new List <AuthorModellist>();
                if (dt.Rows.Count > 0)
                {
                    for (int i = 0; i < dt.Rows.Count; i++)
                    {
                        AuthorModellist Authors = new AuthorModellist();
                        Authors.Id   = dt.Rows[i]["AuthorID"].ToString();
                        Authors.Name = dt.Rows[i]["AuthorName"].ToString();
                        List <AuthorModel> amlist  = new List <AuthorModel>();
                        string             sqlstr2 = string.Format("select * from Author where PID={0} and IsValid=0 and Fanwei=0", dt.Rows[i]["AuthorID"].ToString());
                        DataTable          dt2     = sql.GetDataTableCommand(sqlstr2);
                        if (dt2.Rows.Count > 0)
                        {
                            for (int ii = 0; ii < dt2.Rows.Count; ii++)
                            {
                                AuthorModel am = new AuthorModel();
                                am.AuthorId    = dt2.Rows[ii]["AuthorID"].ToString();
                                am.AuthorName  = dt2.Rows[ii]["AuthorName"].ToString();
                                am.AuthorUrl   = dt2.Rows[ii]["AuthorUrl"].ToString();
                                am.AuthorIcons = dt2.Rows[ii]["AuthorIcon"].ToString();
                                amlist.Add(am);
                            }
                            Authors.listAuthor = amlist;
                        }

                        authorlist.Add(Authors);
                    }
                    ViewBag.authorlist2 = authorlist;
                }
                else
                {
                    ViewBag.authorlist2 = null;
                }
            }
            catch (Exception ex)
            {
                return(Redirect("/ErrorPage/Index"));
            }
            #endregion

            ViewBag.CompanyID = CompanyID;
            return(View());
        }
Beispiel #3
0
        // GET: Main
        public ActionResult Index(string userId, string counts, string companyId)
        {
            try
            {
                ViewBag.count     = counts;
                ViewBag.counts    = int.Parse(Base64MIMA.JIE(counts));
                ViewBag.CompanyID = companyId;
                string userid = Base64MIMA.JIE(userId);
                companyId = Base64MIMA.JIE(companyId);
                #region
                //string code1 = Request["code"];
                ////通过code得到userid    解决办法:把code根据时间来刷新,让他可以不停的访问哪个链接
                //log.AppenLog("code1:" + code1);
                //if (code1 != "")
                //{
                //    Tuple<bool, string> tu2 = BonusHelper.AccessTokenHelper.GetWechatUserInfo(code1);
                //    //Tuple<bool, string> tu2 = new Tuple<bool, string>(true,"");
                //    if (tu2.Item1 || Session["aaa"] != null)
                //    {
                //        if (Session["aaa"] == null)
                //        {
                //            log.AppenLog("if");
                //            userid = tu2.Item2;//得到userid
                //            Session["aaa"] = userid;
                //            // c.Value = tu2.Item2;
                //        }
                //        else
                //        {
                //            log.AppenLog("else");
                //            userid = Session["aaa"].ToString();
                //            //userid = c.Value;
                //        }

                //    }
                //}
                //else
                //{

                //}

                //userid = Session["aaa"].ToString();
                //userid = "qwezzz";

                //userid = Session["aaa"].ToString();
                //WriteLog("id:" + Session["aaa"].ToString());
                //userid = userid.Replace('"', ' ');
                //userid = userid.Trim();
                #endregion

                //查找员工所属
                ViewBag.userid        = userId;
                Session["ComeUserID"] = userid;
                //看登录进来的人有没有公司,如果有公司就进入主界面
                #region
                //string[] canshu = new string[] { "SelectEmp", userid };
                //DataTable dt_canshu = sql.GetDataTableProcedure("proc_Main", canshu);
                //if (dt_canshu.Rows.Count > 0)
                //{
                //    //有这个人,判断是否有公司
                //    if (dt_canshu.Rows[0]["CompanyID"].ToString() == "")
                //    {
                //        //没有公司,需要注册公司
                //        return Redirect("/CompanyRegist/Index?UserID=" + userid);
                //    }
                //    else
                //    {
                //        //有公司
                //        //用base64机密用户id和公司id
                //        ViewBag.userids = Convert.ToBase64String(Encoding.Default.GetBytes(userid));
                //        ViewBag.CompanyID = Convert.ToBase64String(Encoding.Default.GetBytes(dt_canshu.Rows[0]["CompanyID"].ToString()));


                //    }
                //}
                //else
                //{
                //    //没有这个人,需要注册公司
                //    return Redirect("/CompanyRegist/Index?UserID=" + userid);
                //}
                #endregion

                //通过userid得到公司id
                //string sqlstr22 = string.Format($"select CompanyID from Employee where EmpID='{userid}'");
                //DataTable dt22 = sql.GetDataTableCommand(sqlstr22);
                //if (dt22.Rows.Count > 0)
                //{
                //    ViewBag.CompanyID = Base64MIMA.JIA(dt22.Rows[0]["CompanyID"].ToString());
                //}
                //else
                //{
                //    //公司注册页面
                //    return Redirect("/CompanyRegist/Index?UserID=" + userId);
                //    //return Content("<script>alert('出现错误,请联系相关人员处理');history.go(-1);</script>");
                //}

                #region 查出所有父权限
                //查出所有父权限
                //string sqlstr = string.Format("select * from Author where PID is null");
                string    sqlstr = string.Format("exec proc_Main 'SelectAuthorFi','{0}',0,'{1}'", userid, companyId);
                DataTable dt     = sql.GetDataTableCommand(sqlstr);
                //根据父id得到子
                List <AuthorModellist> authorlist = new List <AuthorModellist>();
                if (dt.Rows.Count > 0)
                {
                    for (int i = 0; i < dt.Rows.Count; i++)
                    {
                        AuthorModellist Authors = new AuthorModellist();
                        Authors.Id   = dt.Rows[i]["AuthorID"].ToString();
                        Authors.Name = dt.Rows[i]["AuthorName"].ToString();
                        List <AuthorModel> amlist  = new List <AuthorModel>();
                        string             sqlstr2 = string.Format("exec proc_Main 'SelectAuthorzi','{0}',{1},'{2}'", userid, dt.Rows[i]["AuthorID"].ToString(), companyId);
                        DataTable          dt2     = sql.GetDataTableCommand(sqlstr2);
                        if (dt2.Rows.Count > 0)
                        {
                            for (int ii = 0; ii < dt2.Rows.Count; ii++)
                            {
                                AuthorModel am = new AuthorModel();
                                am.AuthorId    = dt2.Rows[ii]["AuthorID"].ToString();
                                am.AuthorName  = dt2.Rows[ii]["AuthorName"].ToString();
                                am.AuthorUrl   = dt2.Rows[ii]["AuthorUrl"].ToString();
                                am.AuthorIcons = dt2.Rows[ii]["AuthorIcon"].ToString();
                                amlist.Add(am);
                            }
                            Authors.listAuthor = amlist;
                        }

                        authorlist.Add(Authors);
                    }
                    ViewBag.authorlist = authorlist;
                }
                else
                {
                    ViewBag.authorlist = null;
                }
                #endregion
            }
            catch (Exception ex)
            {
                log.AppenLog("mainIndex错误:" + ex.Message);
                return(Redirect("/ErrorPage/Index"));
            }
            return(View());
        }
Beispiel #4
0
        //找到编辑的数据
        public ActionResult Detial(string RoleId)
        {
            string    sqlstr3 = string.Format("select r.RoleName,r.RoleID,a.ModuleCode,r.IsActive from Role r,Authorities a where r.RoleID=a.RoleID and a.RoleID='{0}'", RoleId);
            DataTable dt3     = sql.GetDataTableCommand(sqlstr3);

            if (dt3.Rows?.Count > 0)
            {
                ViewBag.detialRole = dt3;
                #region 添加显示的权限
                //查出所有父权限
                string sqlstr = "";
                if (dt3.Rows[0]["RoleName"].ToString() == "超级管理员")
                {
                    sqlstr = string.Format("select * from Author where PID is null and IsValid=0");
                }
                else
                {
                    sqlstr = string.Format("select * from Author where PID is null and IsValid=0 and Fanwei=0");
                }

                DataTable dt = sql.GetDataTableCommand(sqlstr);
                //根据父id得到子id
                List <AuthorModellist> authorlist = new List <AuthorModellist>();
                if (dt.Rows.Count > 0)
                {
                    for (int i = 0; i < dt.Rows.Count; i++)
                    {
                        AuthorModellist Authors = new AuthorModellist();
                        Authors.Id       = dt.Rows[i]["AuthorID"].ToString();
                        Authors.Name     = dt.Rows[i]["AuthorName"].ToString();
                        Authors.AuthName = dt3.Rows[0]["RoleName"].ToString();
                        Authors.AuthId   = dt3.Rows[0]["RoleID"].ToString();
                        Authors.IsActive = dt3.Rows[0]["IsActive"].ToString();//是否有效
                        List <AuthorModel> amlist  = new List <AuthorModel>();
                        string             sqlstr2 = "";
                        if (dt3.Rows[0]["RoleName"].ToString() == "超级管理员")
                        {
                            sqlstr2 = string.Format("select * from Author where PID={0} and IsValid=0", dt.Rows[i]["AuthorID"].ToString());
                        }
                        else
                        {
                            sqlstr2 = string.Format("select * from Author where PID={0} and IsValid=0 and Fanwei=0", dt.Rows[i]["AuthorID"].ToString());
                        }
                        DataTable dt2 = sql.GetDataTableCommand(sqlstr2);
                        if (dt2.Rows.Count > 0)
                        {
                            for (int ii = 0; ii < dt2.Rows.Count; ii++)
                            {
                                AuthorModel am = new AuthorModel();
                                for (int a = 0; a < dt3.Rows.Count; a++)
                                {
                                    if (dt3.Rows[a]["ModuleCode"].ToString() == dt2.Rows[ii]["AuthorID"].ToString())
                                    {
                                        am.AuthorContian = "0";//为0就代表有这个
                                        a = dt3.Rows.Count;
                                    }
                                    else
                                    {
                                        am.AuthorContian = "1";
                                    }
                                }

                                am.AuthorId    = dt2.Rows[ii]["AuthorID"].ToString();
                                am.AuthorName  = dt2.Rows[ii]["AuthorName"].ToString();
                                am.AuthorUrl   = dt2.Rows[ii]["AuthorUrl"].ToString();
                                am.AuthorIcons = dt2.Rows[ii]["AuthorIcon"].ToString();
                                amlist.Add(am);
                            }
                            Authors.listAuthor = amlist;
                        }

                        authorlist.Add(Authors);
                    }
                    ViewBag.authorlist2 = authorlist;
                }
                else
                {
                    ViewBag.authorlist2 = null;
                }
                #endregion
            }
            else
            {
                ViewBag.detialRole = null;
            }
            return(View());
        }