/// <summary> /// Returns all Sections currently in the System /// </summary> /// <returns></returns> public Sections ALLSections() { try { Sections X = new Sections(); string sSQL = "Select * FROM tblSection ORDER BY tblSection.Name"; DataTable DT = GetDataTable(sSQL); foreach(DataRow R in DT.Rows) { Section S = null; S = GetSection(Convert.ToInt32((object)R[0])); if(S != null) X.Add(S); } DT.Dispose(); return X; } catch(Exception Err) { throw new ApplicationException(Err.Message); } }
/// <summary> /// Retrieves all of the Users Member Sections except the System Section /// </summary> /// <param name="UserID"></param> /// <param name="IncludeDefaultSection"></param> /// <returns></returns> internal Sections GetMemberSections(int UserID, bool IncludeDefaultSection) { try { Section SystemSection = GetSystemSection(); Sections SS = new Sections(); string sSQL = "Select SectionId FROM tblUserSectionRel WHERE UserId = " + UserID; DataTable DT = GetDataTable(sSQL); foreach(DataRow R in DT.Rows) { int SectionId = Convert.ToInt32(R[0]); ///Make Certain that the System Section isn't listed as a Member Section ///This is done to forcibly prevent Users from assigning recordings to this section ///Which would mean only the System Administrator would have access to them at that point ///So the recordings would effectively be lost to all other users if(SectionId != SystemSection.ID) { Section S = GetSection(SectionId); S.mvarIsMember = true; SS.Add(S); } else { //Section S = GetSection(SectionId); //S.mvarIsMember = true; //SS.Add(S); //return SS; } } DT.Dispose(); if(IncludeDefaultSection == true) { sSQL = "Select Id FROM tblSection WHERE IsDefault = 1 AND OwnerId = " + UserID; DT = GetDataTable(sSQL); if(DT.Rows.Count != 0) { DataRow R = DT.Rows[0]; int SectionId = Convert.ToInt32(R[0]); Section S = GetSection(SectionId); SS.Add(S); } } DT.Dispose(); return SS; } catch(Exception Err) { throw new ApplicationException(Err.Message); } }
/// <summary> /// Returns only the Sections owned in the current Hierarchy /// </summary> /// <param name="U"></param> /// <param name="MC"></param> /// <returns></returns> public Sections GetUsersOwnedSections(int UserID, int PreviousSectionID) { try { Sections UST = new Sections(); //First Get the SectionType of the Previous Section Section PrevSection = GetSection(PreviousSectionID); //string prevDescription = PrevSection.CreatedBySectionType.Description; //string makes = PrevSection.CreatedBySectionType.CreatesSectionTypeDescription; //string PreviousSectionTypeDescription = PrevSection.CreatedBySectionType.NextSectionType.Description; //string isSame = PrevSection.CreatedBySectionType.NextSectionType.NextSectionType.Description; //Complex statement that retrieves the current SectionType be getting the sectio int CurrentSectionTypeID = PrevSection.CreatedBySectionType.NextSectionType.ID; string speek = PrevSection.mvarDescription; //Next Retrieve all Sections that pertain only to the current User's Hierarchy string sSQL = "SELECT DISTINCT tblSection.* FROM tblSection Left Outer Join tblSectionSectionRel ON tblSection.Id= tblSectionSectionRel.SectionId " + " LEFT OUTER JOIN tblSectionType ON tblSection.CreatedBySectionTypeId = tblSectionType.Id WHERE " + " tblSection.OwnerId = " + UserID + " AND tblSectionSectionRel.PrevSectionId = " + PreviousSectionID + " AND tblSection.IsDefault <> 1 AND tblSectionType.Id = " + CurrentSectionTypeID + " ORDER BY tblSection.Name"; DataTable DT = GetDataTable(sSQL); if(DT.Rows.Count > 0) { foreach(DataRow R in DT.Rows) { Section ST = new Section(); ST = GetSection(Convert.ToInt32((object)R[0])); //Returns the SectionType that created this Section UST.Add(ST); //Add this SectionType to the collection of this User's Section Types } } DT.Dispose(); return UST; } catch(Exception Err) { throw new ApplicationException(Err.Message); //return null; } }
/// <summary> /// Retrieves all Users Sections even if it is the System Section /// This is used for determining Users Highest Authority Level /// </summary> /// <param name="UserID"></param> /// <returns></returns> internal Sections GetAllContainingSections(int UserID) { try { Section SystemSection = GetSystemSection(); Sections SS = new Sections(); string sSQL = "Select SectionId FROM tblUserSectionRel WHERE UserId = " + UserID; DataTable DT = GetDataTable(sSQL); foreach(DataRow R in DT.Rows) { int SectionId = Convert.ToInt32(R[0]); if(SectionId != SystemSection.ID) { Section S = GetSection(SectionId); S.mvarIsMember = true; SS.Add(S); } else { Section S = GetSection(SectionId); S.mvarIsMember = true; SS.Add(S); return SS; } } DT.Dispose(); return SS; } catch(Exception Err) { throw new ApplicationException(Err.Message); } }
//This returns all owned Sections /// <summary> /// Returns all Sections owned by this User /// </summary> /// <param name="UserID"></param> /// <param name="MC"></param> /// <returns></returns> public Sections GetUsersOwnedSections(int UserID) { try { Sections UST = new Sections(); string sSQL = "Select * FROM tblSection WHERE OwnerID = " + UserID + " ORDER BY Name"; DataTable DT = GetDataTable(sSQL); if(DT.Rows.Count > 0) { foreach(DataRow R in DT.Rows) { Section ST = new Section(); ST = GetSection(Convert.ToInt32((object)R[0])); //Returns the SectionType that created this Section UST.Add(ST); //Add this SectionType to the collection of this User's Section Types } } DT.Dispose(); return UST; } catch(Exception Err) { throw new ApplicationException(Err.Message); //return null; } }