private string[] loadScenarioArray(ado_data_access oAdo) { // //OPEN CONNECTION TO DB FILE CONTAINING PROCESSOR SCENARIO TABLE // //scenario mdb connection string strProcessorScenarioMDB = frmMain.g_oFrmMain.frmProject.uc_project1.txtRootDirectory.Text.Trim() + "\\processor\\db\\scenario_processor_rule_definitions.mdb"; // //get a list of all the scenarios // oAdo.OpenConnection(oAdo.getMDBConnString(strProcessorScenarioMDB, "", "")); string[] strScenarioArray = frmMain.g_oUtils.ConvertListToArray( oAdo.CreateCommaDelimitedList( oAdo.m_OleDbConnection, "SELECT scenario_id " + "FROM scenario " + "WHERE scenario_id IS NOT NULL AND " + "LEN(TRIM(scenario_id)) > 0", ""), ","); oAdo.CloseConnection(oAdo.m_OleDbConnection); return(strScenarioArray); }
public void loadvalues(bool p_bScenarioCopy) { int x; ProcessorScenarioTools oTools = new ProcessorScenarioTools(); //Reset m_oProcessorScenarioItem_Collection so we don't get duplicates when we loadAll down below m_oProcessorScenarioItem_Collection = new ProcessorScenarioItem_Collection(); lvProcessorScenario.Items.Clear(); System.Windows.Forms.ListViewItem entryListItem = null; this.m_oLvAlternateColors.InitializeRowCollection(); this.m_oLvAlternateColors.ReferenceAlternateBackgroundColor = frmMain.g_oGridViewAlternateRowBackgroundColor; this.m_oLvAlternateColors.ReferenceAlternateForegroundColor = frmMain.g_oGridViewRowForegroundColor; this.m_oLvAlternateColors.ReferenceBackgroundColor = frmMain.g_oGridViewRowBackgroundColor; this.m_oLvAlternateColors.ReferenceForegroundColor = frmMain.g_oGridViewRowForegroundColor; this.m_oLvAlternateColors.ReferenceSelectedRowBackgroundColor = frmMain.g_oGridViewSelectedRowBackgroundColor; this.m_oLvAlternateColors.ReferenceListView = this.lvProcessorScenario; this.m_oLvAlternateColors.CustomFullRowSelect = true; if (frmMain.g_oGridViewFont != null) { this.lvProcessorScenario.Font = frmMain.g_oGridViewFont; } ado_data_access oAdo = null; string strProcessorScenario = ""; string strFullDetailsYN = "N"; if (p_bScenarioCopy == false) { // //OPEN CONNECTION TO DB FILE CONTAINING PROCESSOR SCENARIO TABLE // //scenario mdb connection string strProcessorScenarioMDB = frmMain.g_oFrmMain.frmProject.uc_project1.txtRootDirectory.Text.Trim() + "\\processor\\db\\scenario_processor_rule_definitions.mdb"; // //get a list of all the scenarios // oAdo = new ado_data_access(); oAdo.OpenConnection(oAdo.getMDBConnString(strProcessorScenarioMDB, "", "")); string[] strScenarioArray = frmMain.g_oUtils.ConvertListToArray( oAdo.CreateCommaDelimitedList( oAdo.m_OleDbConnection, "SELECT scenario_id " + "FROM scenario " + "WHERE scenario_id IS NOT NULL AND " + "LEN(TRIM(scenario_id)) > 0", ""), ","); oAdo.CloseConnection(oAdo.m_OleDbConnection); if (strScenarioArray == null) { return; } for (x = 0; x <= strScenarioArray.Length - 1; x++) { // //LOAD PROJECT DATATASOURCES INFO // m_oQueries.m_oFvs.LoadDatasource = true; m_oQueries.m_oFIAPlot.LoadDatasource = true; m_oQueries.m_oProcessor.LoadDatasource = true; m_oQueries.m_oReference.LoadDatasource = true; m_oQueries.LoadDatasources(true, "processor", strScenarioArray[x]); m_oQueries.m_oDataSource.CreateScenarioRuleDefinitionTableLinks( m_oQueries.m_strTempDbFile, frmMain.g_oFrmMain.frmProject.uc_project1.txtRootDirectory.Text.Trim(), "P"); oTools.LoadAll(m_oQueries.m_strTempDbFile, m_oQueries, strScenarioArray[x], m_oProcessorScenarioItem_Collection); //System.IO.File.Delete(m_oQueries.m_strTempDbFile); } } else { foreach (ProcessorScenarioItem psItem in ReferenceOptimizerScenarioForm.m_oOptimizerScenarioItem.m_oProcessorScenarioItem_Collection) { m_oProcessorScenarioItem_Collection.Add(psItem); if (psItem.Selected == true) { strProcessorScenario = psItem.ScenarioId; strFullDetailsYN = psItem.DisplayFullDetailsYN; } } } for (x = 0; x <= m_oProcessorScenarioItem_Collection.Count - 1; x++) { entryListItem = lvProcessorScenario.Items.Add(" "); entryListItem.UseItemStyleForSubItems = false; this.m_oLvAlternateColors.AddRow(); this.m_oLvAlternateColors.AddColumns(x, lvProcessorScenario.Columns.Count); entryListItem.SubItems.Add(m_oProcessorScenarioItem_Collection.Item(x).ScenarioId); entryListItem.SubItems.Add(m_oProcessorScenarioItem_Collection.Item(x).Description); } this.m_oLvAlternateColors.ListView(); if (p_bScenarioCopy == false) { string strScenarioMDB = frmMain.g_oFrmMain.frmProject.uc_project1.txtRootDirectory.Text.Trim() + "\\" + Tables.OptimizerScenarioRuleDefinitions.DefaultScenarioTableDbFile; string strConn = oAdo.getMDBConnString(strScenarioMDB, "", ""); oAdo.OpenConnection(strConn); if (oAdo.TableExist(oAdo.m_OleDbConnection, Tables.OptimizerScenarioRuleDefinitions.DefaultScenarioProcessorScenarioSelectTableName)) { oAdo.m_strSQL = "SELECT * FROM " + Tables.OptimizerScenarioRuleDefinitions.DefaultScenarioProcessorScenarioSelectTableName + " " + "WHERE TRIM(UCASE(scenario_id)) = '" + ReferenceOptimizerScenarioForm.uc_scenario1.txtScenarioId.Text.Trim().ToUpper() + "';"; oAdo.SqlQueryReader(oAdo.m_OleDbConnection, oAdo.m_strSQL); if (oAdo.m_OleDbDataReader.HasRows) { while (oAdo.m_OleDbDataReader.Read()) { if (oAdo.m_OleDbDataReader["processor_scenario_id"] != System.DBNull.Value && oAdo.m_OleDbDataReader["processor_scenario_id"].ToString().Trim().Length > 0) { strProcessorScenario = oAdo.m_OleDbDataReader["processor_scenario_id"].ToString().Trim(); } if (oAdo.m_OleDbDataReader["FullDetailsYN"] != System.DBNull.Value && oAdo.m_OleDbDataReader["FullDetailsYN"].ToString().Trim().Length > 0) { strFullDetailsYN = oAdo.m_OleDbDataReader["FullDetailsYN"].ToString().Trim(); } } } oAdo.m_OleDbDataReader.Close(); oAdo.CloseConnection(oAdo.m_OleDbConnection); } else { frmMain.g_oTables.m_oOptimizerScenarioRuleDef.CreateScenarioProcessorScenarioSelectTable(oAdo, oAdo.m_OleDbConnection, Tables.OptimizerScenarioRuleDefinitions.DefaultScenarioProcessorScenarioSelectTableName); } } if (lvProcessorScenario.Items.Count > 0) { for (x = 0; x <= lvProcessorScenario.Items.Count - 1; x++) { if (lvProcessorScenario.Items[x].SubItems[COL_SCENARIOID].Text.Trim().ToUpper() == strProcessorScenario.ToUpper()) { lvProcessorScenario.Items[x].Checked = true; for (int y = 0; y <= ReferenceOptimizerScenarioForm.uc_scenario_processor_scenario_select1.m_oProcessorScenarioItem_Collection.Count - 1; y++) { if (lvProcessorScenario.Items[x].SubItems[COL_SCENARIOID].Text.Trim().ToUpper() == ReferenceOptimizerScenarioForm.uc_scenario_processor_scenario_select1.m_oProcessorScenarioItem_Collection.Item(y).ScenarioId.Trim().ToUpper()) { ReferenceOptimizerScenarioForm.uc_scenario_cond_filter1.strLowSlope = ReferenceOptimizerScenarioForm.uc_scenario_processor_scenario_select1.m_oProcessorScenarioItem_Collection.Item(y).m_oHarvestMethod.SteepSlopePercent; ReferenceOptimizerScenarioForm.uc_scenario_cond_filter1.strSteepSlope = ReferenceOptimizerScenarioForm.uc_scenario_processor_scenario_select1.m_oProcessorScenarioItem_Collection.Item(y).m_oHarvestMethod.SteepSlopePercent; } } break; } } if (x <= lvProcessorScenario.Items.Count - 1) { lvProcessorScenario.Items[0].Selected = true; } } if (strFullDetailsYN == "Y") { chkFullDetails.Checked = true; } else { chkFullDetails.Checked = false; } }
private void GetExistingColumns() { int x; string strCol = ""; string strFieldsList = ""; string[] strProcessorColumnsArray = null; System.Data.OleDb.OleDbConnection oConn = new System.Data.OleDb.OleDbConnection(); oConn.ConnectionString = m_oAdo.getMDBConnString(frmMain.g_oFrmMain.frmProject.uc_project1.txtRootDirectory.Text.Trim() + "\\processor\\db\\scenario_processor_rule_definitions.mdb", "", ""); m_oAdo.OpenConnection(oConn.ConnectionString, ref oConn); string strProcessorColumnsList = m_oAdo.CreateCommaDelimitedList(oConn, "SELECT DISTINCT ColumnName FROM scenario_harvest_cost_columns", ","); m_oAdo.CloseConnection(oConn); if (strProcessorColumnsList.Trim().Length > 0) { strFieldsList = strProcessorColumnsList; strProcessorColumnsArray = frmMain.g_oUtils.ConvertListToArray(strProcessorColumnsList, ","); } string strTable = m_oQueries.m_oDataSource.getValidDataSourceTableName("TREATMENT PRESCRIPTIONS HARVEST COST COLUMNS").Trim(); //string strTable = "scenario_harvest_cost_columns"; m_oAdo.m_strSQL = "SELECT DISTINCT ColumnName FROM " + strTable; m_oAdo.SqlQueryReader(m_oAdo.m_OleDbConnection, m_oAdo.m_strSQL); if (m_oAdo.m_OleDbDataReader.HasRows) { while (m_oAdo.m_OleDbDataReader.Read()) { if (m_oAdo.m_OleDbDataReader["ColumnName"] != System.DBNull.Value && Convert.ToString(m_oAdo.m_OleDbDataReader["ColumnName"]).Trim().Length > 0) { strCol = Convert.ToString(m_oAdo.m_OleDbDataReader["ColumnName"]).Trim().ToUpper(); if (strProcessorColumnsArray != null) { for (x = 0; x <= strProcessorColumnsArray.Length - 1; x++) { if (strProcessorColumnsArray[x] != null) { if (strProcessorColumnsArray[x].Trim().ToUpper() == strCol) { break; } } } if (x > strProcessorColumnsArray.Length - 1) { strFieldsList = strFieldsList + Convert.ToString(m_oAdo.m_OleDbDataReader["ColumnName"]).Trim() + ","; } } else { strFieldsList = strFieldsList + Convert.ToString(m_oAdo.m_OleDbDataReader["ColumnName"]).Trim() + ","; } } } } m_oAdo.m_OleDbDataReader.Close(); if (strFieldsList.Trim().Length > 0) { strFieldsList = strFieldsList.Substring(0, strFieldsList.Length - 1); string[] strFieldsArray = frmMain.g_oUtils.ConvertListToArray(strFieldsList, ","); } m_strHarvestTableColumnNameList = strFieldsList; }