示例#1
0
        /// <summary>
        /// Sets the data properties used to color surveyed roads on the map. Roads are colored based RSL or Treatment
        /// </summary>
        public void applyColorizedProperties()
        {
            FeatureLayer selectionLayer = (FeatureLayer)moduleRoads.Layer;

            moduleRoads.UnsavedChanges = false;
            selectionLayer.SelectAll();
            ISelection shpSelection   = selectionLayer.Selection;
            DataTable  selectionTable = shpSelection.ToFeatureSet().DataTable;
            string     tamsidcolumn   = Project.settings.GetValue(ModuleName + "_f_TAMSID");

            selectionTable.DefaultView.Sort = tamsidcolumn + " asc";
            selectionTable = selectionTable.DefaultView.ToTable();
            string[] symbols = { "TAMSROADRSL", "TAMSTREATMENT" };
            moduleRoads.PrepareDatatable(selectionTable, symbols);
            string    roadSQL   = moduleRoads.SelectionSql.Replace("[[IDLIST]]", moduleRoads.extractTAMSIDs(selectionTable));
            DataTable tamsTable = Database.GetDataByQuery(Project.conn, roadSQL);

            tamsTable.DefaultView.Sort = "TAMSID asc";
            tamsTable = tamsTable.DefaultView.ToTable();
            for (int i = 0; i < selectionTable.Rows.Count; i++)
            {
                selectionTable.Rows[i]["TAMSROADRSL"]   = i >= tamsTable.Rows.Count ? -1 : string.IsNullOrWhiteSpace(tamsTable.Rows[i]["rsl"].ToString()) ? -1 : Util.ToInt(tamsTable.Rows[i]["rsl"].ToString());
                selectionTable.Rows[i]["TAMSTREATMENT"] = i >= tamsTable.Rows.Count ? -1 : tamsTable.Rows[i]["suggested_treatment"];
            }
            selectionLayer.DataSet.DataTable = selectionTable;
        }
示例#2
0
        public void reportSelected(object sender, EventArgs e)
        {
            DataTable    general        = addColumns();
            FeatureLayer selectionLayer = (FeatureLayer)moduleRoads.Layer;
            ISelection   shpSelection   = selectionLayer.Selection;
            DataTable    selectionTable = shpSelection.ToFeatureSet().DataTable;
            string       thisSql        = moduleRoads.SelectionSql.Replace("[[IDLIST]]", moduleRoads.extractTAMSIDs(selectionTable));

            try
            {
                DataTable selectedResultsTable = Database.GetDataByQuery(Project.conn, thisSql);
                double    totalCost            = 0;
                double    totalArea            = 0;

                foreach (DataRow row in selectedResultsTable.Rows)
                {
                    DataRow nr = general.NewRow();
                    addRows(nr, row);
                    general.Rows.Add(nr);
                    string costStr = nr["Cost"].ToString();
                    if (costStr[costStr.Length - 1] == 'k')
                    {
                        totalCost += Util.ToDouble(costStr.Remove(costStr.Length - 1)) * 1000;
                    }
                    else if (costStr[costStr.Length - 1] == 'M')
                    {
                        totalCost += Util.ToDouble(costStr.Remove(costStr.Length - 1)) * 1000000;
                    }
                    else
                    {
                        totalCost += Util.ToDouble(costStr);
                    }
                    totalArea += Util.ToDouble(nr["Area (yds\u00b2)"].ToString());
                }
                general.DefaultView.Sort = "Name asc, Treatment asc, From Address asc";
                general = general.DefaultView.ToTable();
                DataRow totals = general.NewRow();
                totals["Treatment"] = "Total";
                if (totalCost > 1000000)
                {
                    totals["Cost"] = Math.Round(totalCost / 1000000, 2).ToString() + "M";
                }
                else if (totalCost > 1000)
                {
                    totals["Cost"] = Math.Round(totalCost / 1000).ToString() + "k";
                }
                else
                {
                    totals["Cost"] = Math.Round(totalCost).ToString();
                }
                totals["Area (yds\u00b2)"] = totalArea / 9;
                general.Rows.Add(totals);
                reportTable = general.DefaultView.ToTable();
                FormOutput report = new FormOutput(Project, moduleRoads);
                report.dataGridViewReport.DataSource = reportTable;
                report.Text = "Treatment Report";
                report.Show();
                report.FormClosing += updateChanges;
            }
            catch (Exception err)
            {
                Log.Error("Could not get database values for " + ModuleName + " module.\n" + err.ToString());
                MessageBox.Show("An error has occured while trying to consolidate data.");
            }
        }