Exemplo n.º 1
0
        public List <SYS_Modun> SelectAllSYS_Modun()
        {
            List <SYS_Modun> sys_modun  = new List <SYS_Modun>();
            DbDataReader     reader     = null;
            DbConnection     connection = Common.CreateConnection(Common.ConnectionString);

            connection.Open();
            try
            {
                reader = _DbHelper.ExecuteReader(connection, Common.DatabaseSchema + "[SYS_Modun_SelectAll]", (DbParameter[])null);
                if (reader.HasRows)
                {
                    SYS_ModunDataAccess.SetListSYS_ModunInfo(ref reader, ref sys_modun);
                }
                return(sys_modun);
            }
            catch (Exception ex)
            {
                throw new Exception(String.Format(" SYS_ModunDataAccess.SelectAll: {0}", ex.Message));
            }
            finally
            {
                if (reader != null)
                {
                    reader.Close();
                }
                connection.Close();
            }
        }
Exemplo n.º 2
0
        public SYS_Modun SelectSYS_Modun(int ID)
        {
            SYS_Modun    sys_modun  = new SYS_Modun();
            DbDataReader reader     = null;
            DbConnection connection = Common.CreateConnection(Common.ConnectionString);

            connection.Open();
            try
            {
                List <DbParameter> para = new List <DbParameter>();
                para.Add(_DbHelper.CreateParameter(FIELD_ID, ID, false));

                reader = _DbHelper.ExecuteReader(connection, Common.DatabaseSchema + "[SYS_Modun_SelectById]", para.ToArray());
                if (reader.HasRows && reader.Read())
                {
                    SYS_ModunDataAccess.SetSYS_ModunInfo(reader, ref sys_modun);
                }
                return(sys_modun);
            }
            catch (Exception ex)
            {
                throw new Exception(String.Format("SYS_ModunDataAccess.SelectById: {0}", ex.Message));
            }
            finally
            {
                if (reader != null)
                {
                    reader.Close();
                }
                connection.Close();
            }
        }
Exemplo n.º 3
0
        private static void SetListSYS_ModunInfo(ref DbDataReader reader, ref List <SYS_Modun> sys_moduns)
        {
            SYS_Modun sys_modun = null;

            while (reader.Read())
            {
                sys_modun = new SYS_Modun();
                SYS_ModunDataAccess.SetSYS_ModunInfo(reader, ref sys_modun);
                sys_moduns.Add(sys_modun);
            }
        }
Exemplo n.º 4
0
        public List <SYS_Right> GetRightsByRole(SYS_Roles roles)
        {
            DbConnection conn = _DbHelper.CreateConnection(Common.ConnectionString);

            conn.Open();
            List <SYS_Right> result = new List <SYS_Right>();
            DbDataReader     reader = null;

            try
            {
                List <DbParameter> para = new List <DbParameter>();
                para.Add(_DbHelper.CreateParameter("RoleID", roles.ID, false));
                reader = _DbHelper.ExecuteReader(conn, Common.DatabaseSchema + "[SYS_Role_GetRightsByRole]", para.ToArray());
                if (reader.HasRows)
                {
                    SYS_ModunDataAccess modunDataAccess = new SYS_ModunDataAccess();
                    while (reader.Read())
                    {
                        SYS_Right temp = new SYS_Right();
                        SetSYS_RightInfo(reader, ref temp);
                        temp.IsApprove = Boolean.Parse(reader[FIELD_APPROVE].ToString());
                        temp.IsDelete  = Boolean.Parse(reader[FIELD_DELETE].ToString());
                        temp.IsCreate  = Boolean.Parse(reader[FIELD_CREATE].ToString());
                        temp.IsUpdate  = Boolean.Parse(reader[FIELD_UPDATE].ToString());
                        temp.SysModun  = modunDataAccess.SelectSYS_ModunTest(temp.ModuleID);

                        if (temp.SysModun != null)
                        {
                            temp.ModuleName = temp.SysModun.Name;
                        }

                        result.Add(temp);
                    }
                }

                return(result);
            }
            catch (Exception ex)
            {
                throw new Exception(String.Format("SYS_RightDataAccess.GetRightsByRole: {0}", ex.Message));
            }
            finally
            {
                if (reader != null)
                {
                    reader.Close();
                }
                conn.Close();
            }
        }
Exemplo n.º 5
0
        private static void SetListSYS_RightInfoModulName(ref DbDataReader reader, ref List <SYS_Right> sys_rights)
        {
            SYS_Right           sys_right           = null;
            SYS_ModunDataAccess isysModunDataAccess = new SYS_ModunDataAccess();
            SYS_Modun           sysModun            = new SYS_Modun();

            while (reader.Read())
            {
                sys_right = new SYS_Right();
                SYS_RightDataAccess.SetSYS_RightInfo(reader, ref sys_right);
                sysModun             = isysModunDataAccess.SelectSYS_Modun(sys_right.ModuleID);
                sys_right.ModuleName = sysModun.Name;
                sys_rights.Add(sys_right);
            }
        }
Exemplo n.º 6
0
        public List <SYS_Right> GetRightsByNotUser(SYS_User user)
        {
            DbConnection conn = _DbHelper.CreateConnection(Common.ConnectionString);

            conn.Open();
            List <SYS_Right> result = new List <SYS_Right>();
            DbDataReader     reader = null;

            try
            {
                List <DbParameter> para = new List <DbParameter>();
                para.Add(_DbHelper.CreateParameter("UserID", user.ID, false));
                reader = _DbHelper.ExecuteReader(conn, Common.DatabaseSchema + "[SYS_Right_GetByNotUser]", para.ToArray());
                if (reader.HasRows)
                {
                    SYS_ModunDataAccess modunDataAccess = new SYS_ModunDataAccess();

                    while (reader.Read())
                    {
                        SYS_Right temp = new SYS_Right();
                        SetSYS_RightInfo(reader, ref temp);
                        temp.IsApprove  = false;
                        temp.IsDelete   = false;
                        temp.IsCreate   = false;
                        temp.IsUpdate   = false;
                        temp.SysModun   = modunDataAccess.SelectSYS_Modun(temp.ModuleID, conn);
                        temp.ModuleName = temp.SysModun.Name;
                        result.Add(temp);
                    }
                }

                return(result);
            }
            catch (Exception ex)
            {
                throw new Exception(String.Format("SYS_RightDataAccess.GetRightsByNotUser: {0}", ex.Message));
            }
            finally
            {
                if (reader != null)
                {
                    reader.Close();
                }
                conn.Close();
            }
        }