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();
        }
        private DataTable TransformDataSource(DataTable table)
        {
            List <String> sortColumns;

            System.Text.StringBuilder sb = new System.Text.StringBuilder();

            if (String.IsNullOrEmpty(OrderBy))
            {
                sortColumns = new List <string>(LabelColumns.ToArray());
            }
            else
            {
                sortColumns = new List <String>(OrderBy.Split(",".ToCharArray()));
            }

            sortColumns.ForEach(
                delegate(string col) {
                System.Text.StringBuilder column = new System.Text.StringBuilder(col);

                column.Replace("YearFormatted ASC", "YearFormatted");
                column.Replace("YearFormatted", "YearFormatted DESC");
                column.Replace("year ASC", "year");
                column.Replace("year", "year DESC");

                if (sb.Length > 1)
                {
                    sb.Append(",");
                }
                sb.Append(column);
            }
                );

            OrderBy = sb.ToString();

            //throw new Exception(sortColumns.Count.ToString());
            //throw new Exception(OrderBy);

            if (SelectedSortBySecondarySort)
            {
                if (LabelColumns.Count < 2)
                {
                    throw new Exception("Only one Label Column given with SelectedSortBySecondarySort is True.");
                }

                table = DataTableSorter.SecondarySortCompareSelectedFloatToTop(
                    table,
                    ((PageBaseWI)Page).QueryMarshaller, OrderBy
                    );
            }
            else
            {
                table = DataTableSorter.SortAndCompareSelectedFloatToTop(
                    table,
                    ((PageBaseWI)Page).QueryMarshaller, OrderBy
                    );
            }

            DataTable final = GraphBarChart.GetMeasureColumnsAndCastAsDouble(table, MeasureColumns);

            if (LabelColumns.Count > 1)
            {
                final = AddMergeRowStyleColumn(table, final, LabelColumns);
            }
            else
            {
                final = GraphBarChart.TransferColumnsBetweenDS(table, final, LabelColumns);
                //final = AddMergeRowStyleColumn(table, final, new List<String>(new String[]{LabelColumns[0], LabelColumns[0]}));
            }

            return(final);
        }