Ejemplo n.º 1
0
        public static List<LabMS.Model.Function> GetManaFunctionByUserID(string strUserID)
        {
            List<LabMS.Model.UserRole> listuRole = new List<LabMS.Model.UserRole>();
            LabMS.BLL.UserRole buRole = new LabMS.BLL.UserRole();
            List<LabMS.Model.RoleFucntion> listRoleF = new List<LabMS.Model.RoleFucntion>();
            LabMS.BLL.RoleFucntion bRoleF = new LabMS.BLL.RoleFucntion();

            listuRole = buRole.GetModelList("UserID = " + strUserID);

            string strWhere = " 1<>1 ";

            foreach (LabMS.Model.UserRole ur in listuRole)
            {
                strWhere += " or RoleID = " + ur.RoleID.Value.ToString();
            }
            listRoleF = bRoleF.GetModelList(strWhere);

            List<LabMS.Model.Function> listFunction = new List<LabMS.Model.Function>();
            LabMS.BLL.Function bFunction = new LabMS.BLL.Function();
            strWhere = " 1<>1 ";

            foreach (LabMS.Model.RoleFucntion rf in listRoleF)
            {
                strWhere += " or Code = '" + rf.FCode.ToString()+"'";
            }
            listFunction = bFunction.GetModelList(strWhere);
            return listFunction;
        }
Ejemplo n.º 2
0
        /// <summary>
        /// GetCurrentUserInfo
        /// </summary>
        /// <returns></returns>
        public static bool GetCurrentUserInfo()
        {
            if (System.Web.HttpContext.Current.Session != null)
            {
                if (System.Web.HttpContext.Current.Session["User"] != null &&
                    !string.IsNullOrEmpty(System.Web.HttpContext.Current.Session["User"].ToString()) &&
                    System.Web.HttpContext.Current.Session["UserType"] != null &&
                    !string.IsNullOrEmpty(System.Web.HttpContext.Current.Session["UserType"].ToString()))
                {
                    if (System.Web.HttpContext.Current.Session["UserType"].ToString().Equals("mana"))
                    {
                        object obj = System.Web.HttpContext.Current.Session["User"];
                        LabMS.Model.UserTable u = obj as LabMS.Model.UserTable;
                        System.Web.HttpContext.Current.Session["UserID"] = u.UserId;
                        System.Web.HttpContext.Current.Session["UserName"] = u.UserName;
                        System.Web.HttpContext.Current.Session["UserCode"] = u.PCode;
                        if (System.Web.HttpContext.Current.Session["UserPrivilege"] == null)
                        {
                            if (u.UserName == "admin")
                            {
                                LabMS.BLL.Function bf = new LabMS.BLL.Function();
                                System.Web.HttpContext.Current.Session["UserPrivilege"] = bf.GetModelList("");
                            }
                            else
                            {
                                System.Web.HttpContext.Current.Session["UserPrivilege"] = ExtendBLL.Privilege.GetManaFunctionByUserID(u.UserId.ToString());
                            }

                        }
                    }
                    else if (System.Web.HttpContext.Current.Session["UserType"].ToString().Equals("student"))
                    {
                        object obj = System.Web.HttpContext.Current.Session["User"];
                        LabMS.Model.Student s = obj as LabMS.Model.Student;
                        System.Web.HttpContext.Current.Session["UserID"] = s.ID;
                        System.Web.HttpContext.Current.Session["UserName"] = s.Student_Name;
                        System.Web.HttpContext.Current.Session["UserCode"] = s.Student_Code;
                    }
                    else if (System.Web.HttpContext.Current.Session["UserType"].ToString().Equals("teacher"))
                    {
                        object obj = System.Web.HttpContext.Current.Session["User"];
                        LabMS.Model.Teacher t = obj as LabMS.Model.Teacher;
                        System.Web.HttpContext.Current.Session["UserID"] = t.ID;
                        System.Web.HttpContext.Current.Session["UserName"] = t.Teacher_Name;
                        System.Web.HttpContext.Current.Session["UserCode"] = t.Teacher_Code;
                    }

                    return true;
                }
            }
            return false;
        }
Ejemplo n.º 3
0
        void CreatePrivailyPanel()
        {
            lbErr.Visible = false;

            List<LabMS.Model.Plate> listPPlate = new List<LabMS.Model.Plate>();
            List<LabMS.Model.Module> listPModule = new List<LabMS.Model.Module>();
            List<LabMS.Model.Function> listPFuntion = new List<LabMS.Model.Function>();

            LabMS.BLL.Plate bPlate = new LabMS.BLL.Plate();
            LabMS.BLL.Module bModule = new LabMS.BLL.Module();
            LabMS.BLL.Function bFuntion = new LabMS.BLL.Function();

            try
            {
                listPPlate = bPlate.GetModelList("");
            }
            catch (Exception ex)
            {
                lbErr.Visible = true;
                lbErr.Text = ex.Message;
                return;
            }
            PRolePrivaily.Controls.Add(new LiteralControl("<ul class='plate'>"));
            foreach (LabMS.Model.Plate p in listPPlate)
            {
                PRolePrivaily.Controls.Add(new LiteralControl("<li id='"+ p.Code +"'>"));

                PRolePrivaily.Controls.Add(new LiteralControl(p.Name));
                try
                {
                    listPModule = bModule.GetModelList("PCode = '" + p.Code + "'");
                }
                catch (Exception ex)
                {
                    lbErr.Visible = true;
                    lbErr.Text = ex.Message;
                    return;
                }
                PRolePrivaily.Controls.Add(new LiteralControl("<ul class='module'>"));
                foreach (LabMS.Model.Module m in listPModule)
                {
                    PRolePrivaily.Controls.Add(new LiteralControl("<li id='" + m.Code + "'>"));

                    CheckBox check = new CheckBox();
                    check.ID = "chk" + m.Code.ToString();
                    check.Text = m.Name.ToString();
                    check.CssClass = "module";
                    check.Attributes.Add("onclick", "checkAllChanged('chk" + m.Code.ToString() + "','div" + m.Code + "')");
                    PRolePrivaily.Controls.Add(check);
                    PRolePrivaily.Controls.Add(new LiteralControl("<div id='div" + m.Code + "'>"));
                    try
                    {
                        listPFuntion = bFuntion.GetModelList("MCode = '" + m.Code + "'");
                    }
                    catch (Exception ex)
                    {
                        lbErr.Visible = true;
                        lbErr.Text = ex.Message;
                        return;
                    }
                    foreach (LabMS.Model.Function f in listPFuntion)
                    {
                        check = new CheckBox();
                        check.ID = "check" + f.Code.ToString();
                        check.Text = f.Name.ToString();
                        check.CssClass = "function";
                        check.Attributes.Add("onclick", "checkFunctionChanged('chk" + m.Code.ToString()+"','div" + m.Code + "')");
                        PRolePrivaily.Controls.Add(check);
                    }
                    PRolePrivaily.Controls.Add(new LiteralControl("</div >"));
                    PRolePrivaily.Controls.Add(new LiteralControl("</li>"));
                }
                PRolePrivaily.Controls.Add(new LiteralControl("</ul>"));

                PRolePrivaily.Controls.Add(new LiteralControl("</li>"));
            }
            PRolePrivaily.Controls.Add(new LiteralControl("</ul>"));
        }
Ejemplo n.º 4
0
 List<string> GetPrivaily()
 {
     LabMS.BLL.Function bFuntion = new LabMS.BLL.Function();
     List<LabMS.Model.Function> listPFuntion = new List<LabMS.Model.Function>();
     List<string> liststrFunction = new List<string>();
     listPFuntion = bFuntion.GetModelList("");
     for (int i = 0; i < listPFuntion.Count; ++i)
     {
         try
         {
             CheckBox check = (CheckBox)PRolePrivaily.FindControl("check" + listPFuntion[i].Code);
             if (check.Checked)
             {
                 liststrFunction.Add(listPFuntion[i].Code);
             }
         }
         catch
         {
             ;
         }
     }
     return liststrFunction;
 }