public List <String> BuildFullKeyList(String fullkey)
        {
            List <String> keylist = new List <string>();

            fullkey = FullKeyUtils.GetMaskedFullkey(fullkey, globals.OrgLevel);

            if ((globals.CompareTo.Key == CompareToKeys.Years) || (globals.CompareTo.Key == CompareToKeys.Current))
            {
                //When comparing to Prior Years or Current School Data,
                keylist.Add(fullkey);
            }

            else if (globals.CompareTo.Key == CompareToKeys.OrgLevel)
            {
                //always add the State fullkey to the list.
                keylist.Add(FullKeyUtils.StateFullKey(fullkey));

                if (globals.OrgLevel.Key != OrgLevelKeys.State)
                {
                    //org level is District or School
                    keylist.Add(FullKeyUtils.DistrictFullKey(fullkey));
                }
                if (globals.OrgLevel.Key == OrgLevelKeys.School)
                {
                    //org level is school
                    keylist.Add(FullKeyUtils.SchoolFullKey(fullkey));
                }
            }

            return(keylist);
        }
        private String CompareSelectedClauseTemplate(String Operator, String Name, String Value)
        {
            String template = " ( ( {0} in ('{1}') and right(fullkey,1){2}'X' ) or FullKey in ('{3}')) ";

            return(String.Format(template,
                                 Name, Value, Operator,
                                 FullKeyUtils.GetMaskedFullkey(globals.FULLKEY, globals.OrgLevel)
                                 ));
        }
        public String BuildClauseForCompareToSelected()
        {
            String clause     = String.Empty;
            String region     = String.Empty;
            String value      = String.Empty;
            String comparison =
                (globals.OrgLevel.Key == OrgLevelKeys.School) ?
                "<>" : "=";

            if (globals.S4orALL.Key == S4orALLKeys.AllSchoolsOrDistrictsIn)
            {
                if (globals.SRegion.Key == SRegionKeys.County)
                {
                    region = "County";
                    value  = globals.SCounty;
                }
                else if (globals.SRegion.Key == SRegionKeys.CESA)
                {
                    region = "CESA";
                    value  = globals.SCESA;
                }
                else if (globals.SRegion.Key == SRegionKeys.AthleticConf)
                {
                    region = "ConferenceKey";
                    value  = globals.SAthleticConf;
                }

                if (globals.SRegion.Key == SRegionKeys.Statewide)
                {
                    clause = CompareSelectedClauseStatewideTemplate(comparison);
                }
                else
                {
                    clause = CompareSelectedClauseTemplate(comparison, region, value);
                }
            }
            else
            {
                region = "fullkey";

                List <String> keylist = new List <String>();

                //add the original fullkey
                keylist.Add(FullKeyUtils.GetMaskedFullkey(globals.FULLKEY, globals.OrgLevel));
                keylist.AddRange(
                    FullKeyUtils.ParseFullKeyString(
                        globals.SFullKeys(globals.OrgLevel)
                        )
                    );

                clause = SQLHelper.WhereClauseValuesInList(SQLHelper.WhereClauseJoiner.NONE, region, keylist);
            }
            return(clause);
        }
        private String CompareSelectedClauseStatewideTemplate(String Operator)
        {
            String template = " ( ( right(fullkey,1){0}'X' ) or FullKey in ('{1}')) ";

            //return an inocuous where clause:
            if (GlobalValues.SuperDownload.Key == SupDwnldKeys.True)
            {
                return(" 1=1 ");
            }

            return(String.Format(template,
                                 Operator,
                                 FullKeyUtils.GetMaskedFullkey(globals.FULLKEY, globals.OrgLevel)
                                 ));
        }
        protected List <string> MyGetFullKeysList(
            CompareTo compareTo, OrgLevel orgLevel, string origFullKey,
            List <string> compareToSchoolsOrDistrict)
        {
            List <string> retval = FullKeyUtils.GetFullKeysList(compareTo,
                                                                orgLevel, origFullKey, compareToSchoolsOrDistrict, S4orALL);

            if (this.OrgLevel.Key != OrgLevelKeys.School)
            {
                List <string> maskedVals = new List <string>();
                foreach (string fullkey in retval)
                {
                    string maskedVal = FullKeyUtils.GetMaskedFullkey(fullkey, this.OrgLevel);
                    maskedVals.Add(maskedVal);
                }
                retval = maskedVals;
            }

            return(retval);
        }
        //Notes for graph

        /* public override string GetViewByColumnName()
         * {
         *   //There is no RaceShortLabel column in this page, so we need to use the Full paramName
         *   if (ViewBy.Key == GroupKeys.Race)
         *   {
         *       return "RaceLabel";
         *   }
         *   else
         *   {
         *       return base.GetViewByColumnName();
         *   }
         * }*/

        //Notes for graph

        /* public override string GetCompareToColumnName()
         * {
         *   if (CompareTo == CompareToEnum.DISTSTATE)
         *   {
         *       return "District paramName";
         *   }
         *   else
         *   {
         *       return base.GetCompareToColumnName();
         *   }
         * }*/


        private List <string> MyGetFullKeysList(
            CompareTo compareTo,
            OrgLevel orgLevel, string origFullKey,
            List <string> compareToSchoolsOrDistrict)
        {
            List <string> retval = new List <string>();


            if (OrgLevel.Key == OrgLevelKeys.School)
            {
                newOrigFullKey    = FullKeyUtils.DistrictFullKey(origFullKey);
                newOrgLevel.Value = newOrgLevel.Range[OrgLevelKeys.District];
                //convert each school into a district fullkey
                foreach (string fullkey in compareToSchoolsOrDistrict)
                {
                    string maskedFullkey = FullKeyUtils.GetMaskedFullkey(fullkey, OrgLevelKeys.District);
                    newCompareToSchools.Add(maskedFullkey);
                }
            }

            if (orgLevel.Key == OrgLevelKeys.District)
            {
                newOrgLevel         = orgLevel;
                newOrigFullKey      = origFullKey;
                newCompareToSchools = compareToSchoolsOrDistrict;
            }

            else if (orgLevel.Key == OrgLevelKeys.State)
            {
                newOrgLevel    = orgLevel;
                newOrigFullKey = FullKeyUtils.StateFullKey(origFullKey);
            }

            retval = FullKeyUtils.GetFullKeysList(compareTo, newOrgLevel, newOrigFullKey, newCompareToSchools, S4orALL);

            return(retval);
        }