private void populateAvailableSchoolsGrid(String selectedAndCurrentCSV)
        {
            NoAppropriateLabel.Text = String.Format(
                "No appropriate {0} of this type in this location.",
                (GlobalValues.CompareTo.Key == CompareToKeys.SelSchools) ? "Schools" : "Districts"
                );

            if (!String.IsNullOrEmpty(selectedAndCurrentCSV))
            {
                GlobalValues.SQL = getAvailableQuery(selectedAndCurrentCSV);
                if (!String.IsNullOrEmpty(GlobalValues.SQL))
                {
                    //throw new Exception(GlobalValues.SQL);
                    QueryMarshaller.AssignQuery(new DALAgencies(), GlobalValues.SQL);
                    _ds = QueryMarshaller.Database.DataSet.Copy();
                }
            }
            if (_ds != null && _ds.Tables[0].Rows.Count > 0)
            {
                gvAvailable.DataSource = DataTableSorter.SortTable(_ds.Tables[0], "DistrictName, SchoolName");
                gvAvailable.DataBind();
                gvAvailable.ShowHeader = false;
            }
            else
            {
                NoAppropriateMessage.Visible = true;
                gvAvailable.Visible          = false;
            }
        }
        private void populateSelectedGrid(String selectedCSV)
        {
            GlobalValues.SQL =
                (GlobalValues.CompareTo.Key == CompareToKeys.SelSchools) ?
                DALAgencies.GetSelectedSchoolsSQL(selectedCSV)
                : DALAgencies.GetSelectedDistrictsSQL(selectedCSV)
            ;
            QueryMarshaller.AssignQuery(new DALAgencies(), GlobalValues.SQL);
            _dsSelected = QueryMarshaller.Database.DataSet.Copy();

            if (_dsSelected != null && _dsSelected.Tables[0].Rows.Count > 0)
            {
                gvSelected.DataSource = DataTableSorter.SortTable(_dsSelected.Tables[0], "SchoolName, DistrictName");
                gvSelected.DataBind();
            }
            gvSelected.ShowHeader = false;
            PanelSelected.Visible = (gvSelected.Rows.Count > 0);
            PanelNoChosen.Visible = !PanelSelected.Visible;
        }
Exemplo n.º 3
0
        /// <summary>
        /// gets a unique list of values for the AxisX and Series labels.
        /// Attempts to retrieve them in the correct order.
        /// Order of collections impacts the pivotDataSource method.
        /// To enable sorting through the graph OrderBy property,
        /// you Must add the column to the sortColumns array in this function.
        /// </summary>
        /// <param name="table"></param>
        private void SaveOriginalAxisAndSeriesLabels(DataTable table)
        {
            /* asymetrical rows: e.g. previous years not having the same grades or races as the most recent year
             * and the typical scenario or years sorted ASC, resulted in AxisX points to be out of order.
             * Sorting years desc, and sorting by gradecode and racecode, for extra measure...
             * results in better AxisX point labeling.
             * Feel free to add more sortColumns: are checked for existence in column collection.
             * Hack-ish, but will solve most cases, for now...
             * NOTE the Lists populated ultimately determine the sort of the graph, which will be ascending for all columns.
             */
            DataTable sorted = new DataTable();

            String[]      sortColumns = new String[] { "year", "gradecode", "racecode", "race", "sex", "sexcode", "DisabilityCode", "EconDisadvCode", "ELPCode", "OrgLevelLabel", "TimeFrameSort" };
            List <String> orderBy     = new List <string>();

            foreach (String col in sortColumns)
            {
                if (table.Columns.Contains(col))
                {
                    orderBy.Add(
                        col + " DESC"  // all columns are reversed because we flip the lists at the end.
                        );
                }
            }
            sorted = DataTableSorter.SortTable(table, String.Join(",", orderBy.ToArray()));

            foreach (DataRow row in sorted.Rows)
            {
                AddUniqueToListIfRowContains(_originalSeriesNames, row, SeriesColumnName);
                AddUniqueToListIfRowContains(_originalAxisXNames, row, LabelColumnName);
            }

            //counter the necessary Descending sort:
            _originalSeriesNames.Reverse();
            _originalAxisXNames.Reverse();
        }