Пример #1
0
    public string GetModuleOrPageRight()
    {
        //DbHelperSQL.connectionString = System.Configuration.ConfigurationManager.AppSettings["ConnectionStringSQL"];
        //string strSql = string.Empty;
        //strSql = "select Module_Right from CMS_SYS_PERMISSION where USER_ID=N'" + _userid + "' and Permission_Type=1 and Module_Type=1 and Module_ID=" + _moduleid;
        //object cnt = DbHelperSQL.GetSingle(strSql);

        PermissionDBEntity permissionDBEntity = new PermissionDBEntity();
        permissionDBEntity.USER_ID = _userid;
        permissionDBEntity.Module_ID = _moduleid;
        object cnt = rightDA.SelectRightByUserAccoutAndModuleID(permissionDBEntity);

        if (cnt == null)
            return string.Empty;
        else
            return cnt.ToString();
    }
Пример #2
0
 public int UpdateRightForUserModuleTypeEqual1(PermissionDBEntity permissionDBEntity)
 {
     int rtnResult = 0;
     DataCommand cmd = DataCommandManager.GetDataCommand("UpdateRightForUserModuleTypeEqual1");
     cmd.SetParameterValue("@Module_Right", permissionDBEntity.Module_Right);
     cmd.SetParameterValue("@UpdatedBy", permissionDBEntity.UpdatedBy);
     cmd.SetParameterValue("@Update_Time", permissionDBEntity.Update_Time);
     cmd.SetParameterValue("@USER_ID", permissionDBEntity.USER_ID);
     cmd.SetParameterValue("@Module_ID", permissionDBEntity.Module_ID);
     rtnResult = cmd.ExecuteNonQuery();
     return rtnResult;
 }
Пример #3
0
 public int UpdateRightForRole(PermissionDBEntity permissionDBEntity)
 {
     int rtnResult = 0;
     DataCommand cmd = DataCommandManager.GetDataCommand("UpdateRightForRole");
     cmd.SetParameterValue("@Module_Right", permissionDBEntity.Module_Right);
     cmd.SetParameterValue("@Creator", permissionDBEntity.Creator);
     cmd.SetParameterValue("@Update_Time", permissionDBEntity.Update_Time);
     cmd.SetParameterValue("@Role_ID", permissionDBEntity.Role_ID);
     cmd.SetParameterValue("@Module_ID", permissionDBEntity.Module_ID);
     rtnResult = cmd.ExecuteNonQuery();
     return rtnResult;
 }
Пример #4
0
 public object SelectRightByUserAccoutAndModuleID(PermissionDBEntity permissionDBEntity)
 {
     DataCommand cmd = DataCommandManager.GetDataCommand("SelectRightByUserAccoutAndModuleID");
     cmd.SetParameterValue("@USER_ID", permissionDBEntity.USER_ID);
     cmd.SetParameterValue("@Module_ID", permissionDBEntity.Module_ID);
     object objResult = cmd.ExecuteScalar();
     return objResult;
 }
Пример #5
0
 public object SelectRightByRoleIDAndModuleID(PermissionDBEntity permissionDBEntity)
 {
     DataCommand cmd = DataCommandManager.GetDataCommand("SelectRightByRoleIDAndModuleID");
     cmd.SetParameterValue("@Role_ID", permissionDBEntity.Role_ID);
     cmd.SetParameterValue("@Module_ID", permissionDBEntity.Module_ID);
     object rtnResult = cmd.ExecuteScalar();
     return rtnResult;
 }
Пример #6
0
 public object SelectMenuIDByParentMenuID(PermissionDBEntity permissionDBEntity)
 {
     DataCommand cmd = DataCommandManager.GetDataCommand("SelectMenuIDByParentMenuID");
     cmd.SetParameterValue("@Module_ID", permissionDBEntity.Module_ID);
     object objResult = cmd.ExecuteScalar();
     return objResult;
 }
Пример #7
0
 public int SelectCountByRoleIDAndModuleID(PermissionDBEntity permissionDBEntity)
 {
     DataCommand cmd = DataCommandManager.GetDataCommand("SelectCountByRoleIDAndModuleID");
     cmd.SetParameterValue("@Role_ID", permissionDBEntity.Role_ID);
     cmd.SetParameterValue("@Module_ID", permissionDBEntity.Module_ID);
     object rtnResult = cmd.ExecuteScalar();
     return Convert.ToInt32(rtnResult);
 }
Пример #8
0
 public int InsertRightForUser(PermissionDBEntity permissionDBEntity)
 {
     int rtnResult = 0;
     DataCommand cmd = DataCommandManager.GetDataCommand("InsertRightForUser");
     cmd.SetParameterValue("@USER_ID", permissionDBEntity.USER_ID);
     cmd.SetParameterValue("@Permission_Type", permissionDBEntity.Permission_Type);
     cmd.SetParameterValue("@Module_ID", permissionDBEntity.Module_ID);
     cmd.SetParameterValue("@Module_Type", permissionDBEntity.Module_Type);
     cmd.SetParameterValue("@Module_Right", permissionDBEntity.Module_Right);
     cmd.SetParameterValue("@Creator", permissionDBEntity.Creator);
     rtnResult = cmd.ExecuteNonQuery();
     return rtnResult;
 }
Пример #9
0
    /// <summary>
    /// �����Ƿ���Ȩ�޸���Ȩ�ޱ�
    /// </summary>
    /// <param name="haveornot"></param>
    public void SetNewRight()
    {
        DbHelperSQL.connectionString = System.Configuration.ConfigurationManager.AppSettings["ConnectionStringSQL"];
        //string getdatestr = " getdate() ";
        string getdatestr = System.DateTime.Now.ToString();

        List<string> listSql = new List<string>();
        //ArrayList listSql = new ArrayList();

        PermissionDBEntity pDBEntity = new PermissionDBEntity();

        foreach (string code in _oldRight.Keys)
        {
            if (_newRight[code].ToString() != _oldRight[code].ToString())
            {
                //��~��β���ǿؼ�Ȩ��
                if (code.EndsWith("~"))
                {
                    string[] temp = _oldRight[code].ToString().Split(new char[] { '^' });
                    string[] newright = _newRight[code].ToString().Split(new char[] { '^' });
                    if (temp[1] == string.Empty)
                    {
                        //listSql.Add("insert into CMS_SYS_PERMISSION(USER_ID,Permission_Type,Module_ID,Module_Type,Module_Right,Creator) values(N'"
                        //    + _userid + "',1," + temp[0] + ",3," + newright[1] + ",N'" + _operator + "')");

                        pDBEntity.USER_ID = _userid;
                        pDBEntity.Permission_Type = "1";
                        pDBEntity.Module_ID = temp[0];
                        pDBEntity.Module_Type = "3";
                        pDBEntity.Module_Right = newright[1];
                        pDBEntity.Creator = _operator;
                        rightDA.InsertRightForUser(pDBEntity);

                    }
                    else
                    {
                        //listSql.Add("update CMS_SYS_PERMISSION set Module_Right=" + newright[1] + ",UpdatedBy=N'" + _operator + "',Update_Time=" + getdatestr + " where USER_ID=N'" + _userid
                        //    + "' and Permission_Type=1 and Module_ID=" + temp[0] + " and Module_Type=3");

                        pDBEntity.Module_Right = newright[1];
                        pDBEntity.UpdatedBy = _operator;
                        pDBEntity.Update_Time = getdatestr;
                        pDBEntity.USER_ID = _userid;
                        pDBEntity.Permission_Type = "1";
                        pDBEntity.Module_ID = temp[0];
                        pDBEntity.Module_Type = "3";
                        rightDA.UpdateRightForUser(pDBEntity);
                    }
                }
                else
                {
                    UseModuleLevel(code, listSql);
                    if (_oldRight[code].ToString() == string.Empty)
                    {
                        //listSql.Add("insert into CMS_SYS_PERMISSION(USER_ID,Permission_Type,Module_ID,Module_Type,Module_Right,Creator) values(N'"
                        //    + _userid + "',1," + _moduleid + ",1," + _newRight[code].ToString() + ",N'" + _operator + "')");

                        pDBEntity.USER_ID = _userid;
                        pDBEntity.Permission_Type = "1";
                        pDBEntity.Module_ID = _moduleid;
                        pDBEntity.Module_Type = "1";
                        pDBEntity.Module_Right = _newRight[code].ToString();
                        pDBEntity.Creator = _operator;
                        rightDA.InsertRightForUser(pDBEntity);

                    }
                    else
                    {
                        //listSql.Add("update CMS_SYS_PERMISSION set Module_Right=" + _newRight[code].ToString() + ",UpdatedBy=N'" + _operator + "',Update_Time=" + getdatestr + " where USER_ID=N'" + _userid
                        //    + "' and Permission_Type=1 and Module_ID=" + _moduleid + " and Module_Type=1");

                        pDBEntity.Module_Right = _newRight[code].ToString();
                        pDBEntity.UpdatedBy = _operator;
                        pDBEntity.Update_Time = getdatestr;
                        pDBEntity.USER_ID = _userid;
                        pDBEntity.Permission_Type = "1";
                        pDBEntity.Module_ID = _moduleid;
                        pDBEntity.Module_Type = "1";
                        rightDA.UpdateRightForUserModuleTypeEqual1(pDBEntity);
                    }
                }
            }
        }

        //DbHelperSQL.ExecuteSqlTran(listSql);
    }
Пример #10
0
    /// <summary>
    /// 
    /// </summary>
    /// <param name="code"></param>
    /// <param name="sql"></param>
    private void UseModuleLevel(string code, List<string> sql)
    {
        DbHelperSQL.connectionString = System.Configuration.ConfigurationManager.AppSettings["ConnectionStringSQL"];

        //string getdatestr = " getdate() ";
        string getdatestr = System.DateTime.Now.ToString();

        string strSql = string.Empty;
        PermissionDBEntity permissionDBEntity = new PermissionDBEntity();

        if (_oldRight[code].ToString() == string.Empty)
        {
            //strSql = "select Menu_ID from CMS_SYS_MENU where Menu_ID=(select Parent_MenuId from CMS_SYS_MENU where Menu_ID=" + _moduleid + ")";
            //object id = DbHelperSQL.GetSingle(strSql);

            permissionDBEntity.Module_ID = _moduleid;
            object id = rightDA.SelectMenuIDByMenuIDInParentMenuID(permissionDBEntity);

            if (id != null)
            {
                //strSql = "select count(*) from CMS_SYS_PERMISSION where USER_ID=N'" + _userid  + "' and Permission_Type=1 and Module_ID=" + id.ToString() + " and Module_Type=1";
                //object cnt = DbHelperSQL.GetSingle(strSql);

                permissionDBEntity.USER_ID = _userid;
                permissionDBEntity.Module_ID =id.ToString();
                object cnt = rightDA.SelectCountByUserIDAndModuleID(permissionDBEntity);

                if (cnt != null)
                {
                    if (Convert.ToInt32( cnt) == 0)
                    {
                        //sql.Add("insert into CMS_SYS_PERMISSION(USER_ID,Permission_Type,Module_ID,Module_Type,Module_Right,Creator) values(N'"
                        //        + _userid + "',1," + id.ToString() + ",1," + _newRight[code].ToString() + ",N'" + _operator + "')");

                        permissionDBEntity.USER_ID = _userid;
                        permissionDBEntity.Permission_Type = "1";
                        permissionDBEntity.Module_ID = id.ToString();
                        permissionDBEntity.Module_Type = "1";
                        permissionDBEntity.Module_Right = _newRight[code].ToString();
                        permissionDBEntity.Creator = _operator;
                        int i=  rightDA.InsertRightForUser(permissionDBEntity);

                    }
                    else if (_newRight[code].ToString() == "1")
                    {
                        //sql.Add("update CMS_SYS_PERMISSION set Module_Right=" + _newRight[code].ToString() + ",UpdatedBy=N'" + _operator + "',Update_Time=" + getdatestr + " where USER_ID=N'" + _userid
                        //        + "' and Permission_Type=1 and Module_ID=" + id.ToString() + " and Module_Type=1");

                        permissionDBEntity.Module_Right = _newRight[code].ToString();
                        permissionDBEntity.UpdatedBy = _operator;
                        permissionDBEntity.Update_Time = getdatestr;
                        permissionDBEntity.USER_ID = _userid;
                        permissionDBEntity.Permission_Type = "1";
                        permissionDBEntity.Module_ID = id.ToString();
                        permissionDBEntity.Module_Type = "1";
                        int i = rightDA.UpdateRightForUserModuleTypeEqual1(permissionDBEntity);

                    }

                }
            }
        }
        else
        {
            if (_pageid == string.Empty)
            {
                if (_newRight[code].ToString() == "-1")
                {
                    //strSql = "select Menu_ID from CMS_SYS_MENU where Parent_MenuID=" + _moduleid;
                    //DataSet ds = DbHelperSQL.Query(strSql);
                    //foreach (DataRow dr in ds.Tables[0].Rows)
                    //{
                    //    sql.Add("update CMS_SYS_PERMISSION set Module_Right=" + _newRight[code].ToString() + ",UpdatedBy=N'" + _operator + "',Update_Time=" + getdatestr + " where USER_ID=N'" + _userid
                    //            + "' and Permission_Type=1 and Module_ID=" + dr["Menu_ID"].ToString() + " and Module_Type=1");

                    //}

                    permissionDBEntity.Module_ID = _moduleid;
                    object objMenuID = rightDA.SelectMenuIDByParentMenuID(permissionDBEntity);

                    if (objMenuID != null && objMenuID != DBNull.Value)
                    {
                        //sql.Add("update CMS_SYS_PERMISSION set Module_Right=" + _newRight[code].ToString() + ",UpdatedBy=N'" + _operator + "',Update_Time=" + getdatestr + " where USER_ID=N'" + _userid
                        //           + "' and Permission_Type=1 and Module_ID=" + dr["Menu_ID"].ToString() + " and Module_Type=1");

                        permissionDBEntity.Module_Right = _newRight[code].ToString();
                        permissionDBEntity.UpdatedBy = _operator;
                        permissionDBEntity.Update_Time = getdatestr;
                        permissionDBEntity.USER_ID = _userid;
                        permissionDBEntity.Permission_Type = "1";
                        permissionDBEntity.Module_ID = objMenuID.ToString();
                        permissionDBEntity.Module_Type = "1";
                        rightDA.UpdateRightForUser(permissionDBEntity);

                    }

                }
            }
            else
            {
                if (_newRight[code].ToString() == "1")
                {
                    //strSql = "select Menu_ID from CMS_SYS_MENU where Menu_ID=(select Parent_MenuID from CMS_SYS_MENU where Menu_Id=" + _moduleid + ")";
                    //object id = DbHelperSQL.GetSingle(strSql);

                    permissionDBEntity.Module_ID = _moduleid;
                    rightDA.SelectMenuIDByParentMenuID(permissionDBEntity);
                    object id = rightDA.SelectMenuIDByMenuIDInParentMenuID(permissionDBEntity);

                    if (id != null)
                    {
                        //sql.Add("update CMS_SYS_PERMISSION set Module_Right=" + _newRight[code].ToString() + ",UpdatedBy=N'" + _operator + "',Update_Time=" + getdatestr + " where USER_ID=N'" + _userid
                        //        + "' and Permission_Type=1 and Module_ID=" + id.ToString() + " and Module_Type=1");

                        permissionDBEntity.Module_Right = _newRight[code].ToString();
                        permissionDBEntity.UpdatedBy = _operator;
                        permissionDBEntity.Update_Time = getdatestr;
                        permissionDBEntity.USER_ID = _userid;
                        permissionDBEntity.Permission_Type = "1";
                        permissionDBEntity.Module_ID = id.ToString();
                        permissionDBEntity.Module_Type = "1";
                        int i = rightDA.UpdateRightForUserModuleTypeEqual1(permissionDBEntity);
                    }

                }
            }
        }
    }