Пример #1
0
        public void SaveScenarioNotes()
        {
            ado_data_access p_ado = new ado_data_access();

            System.Data.OleDb.OleDbConnection oConn = new System.Data.OleDb.OleDbConnection();
            string        strProjDir     = frmMain.g_oFrmMain.frmProject.uc_project1.txtRootDirectory.Text.Trim();
            string        strScenarioDir = strProjDir + "\\" + ScenarioType + "\\db";
            string        strFile        = "scenario_" + ScenarioType + "_rule_definitions.mdb"; //((frmMain)this.ParentForm.ParentForm).frmProject.uc_project1.m_strProjectFile;
            StringBuilder strFullPath    = new StringBuilder(strScenarioDir);

            strFullPath.Append("\\");
            strFullPath.Append(strFile);
            string strNotes = this.txtNotes.Text;
            string strSQL   = "";

            strNotes = p_ado.FixString(strNotes, "'", "''");
            string strConn = p_ado.getMDBConnString(strFullPath.ToString(), "admin", "");

            //string strConn = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + strFullPath.ToString() + ";User Id=admin;Password=;";
            if (ScenarioType.Trim().ToUpper() == "OPTIMIZER")
            {
                strSQL = "UPDATE scenario SET notes = '" +
                         strNotes +
                         "' WHERE trim(lcase(scenario_id)) = '" + ((frmOptimizerScenario)this.ParentForm).uc_scenario1.txtScenarioId.Text.Trim().ToLower() + "';";
            }
            else
            {
                strSQL = "UPDATE scenario SET notes = '" +
                         strNotes +
                         "' WHERE trim(lcase(scenario_id)) = '" + this.ReferenceProcessorScenarioForm.uc_scenario1.txtScenarioId.Text.Trim().ToLower() + "';";
            }
            p_ado.SqlNonQuery(strConn, strSQL);
            p_ado = null;
        }
Пример #2
0
        public void DeleteScenario()
        {
            string       strSQL = "Delete Scenario '" + this.txtScenarioId.Text + "' (Y/N)?";
            DialogResult result = MessageBox.Show(strSQL, "Delete Scenario", MessageBoxButtons.YesNo, MessageBoxIcon.Question);

            switch (result)
            {
            case DialogResult.Yes:
                break;

            case DialogResult.No:
                return;
            }

            string        strScenarioPath = this.txtScenarioPath.Text;
            string        strScenarioFile = "scenario_" + ScenarioType + "_rule_definitions.mdb";
            string        strScenarioDir  = ((frmMain)this.ParentForm.ParentForm).frmProject.uc_project1.m_strProjectDirectory + "\\" + ScenarioType + "\\db";
            string        strFile         = "scenario_" + ScenarioType + "_rule_definitions.mdb"; //((frmMain)this.ParentForm.ParentForm).frmProject.uc_project1.m_strProjectFile;
            StringBuilder strFullPath     = new StringBuilder(strScenarioDir);

            strFullPath.Append("\\");
            strFullPath.Append(strFile);

            System.Data.OleDb.OleDbConnection oConn = new System.Data.OleDb.OleDbConnection();
            ado_data_access p_ado   = new ado_data_access();
            string          strConn = p_ado.getMDBConnString(strFullPath.ToString(), "admin", "");

            //string strConn = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + strFullPath.ToString() + ";User Id=admin;Password=;";

            strSQL = "DELETE * FROM scenario WHERE scenario_id =  " + "'" + this.txtScenarioId.Text.Trim() + "'";
            p_ado.SqlNonQuery(strConn, strSQL);
            if (p_ado.m_intError == 0)
            {
                strSQL = "DELETE * FROM scenario_datasource WHERE scenario_id =  " + "'" + this.txtScenarioId.Text.Trim() + "'";
                p_ado.SqlNonQuery(strConn, strSQL);
            }
            if (p_ado.m_intError == 0)
            {
                strSQL = this.txtScenarioId.Text + " was successfully deleted from the scenario tables. Do you wish to delete the scenario file and directory (Y/N)?";
                result = MessageBox.Show(strSQL, "Delete Scenario", MessageBoxButtons.YesNo, MessageBoxIcon.Question);
                switch (result)
                {
                case DialogResult.Yes:
                    strSQL = strScenarioPath + "\\" + strScenarioFile;
                    try
                    {
                        System.IO.Directory.Delete(strScenarioPath, true);
                    }
                    catch
                    {
                    }
                    break;

                case DialogResult.No:
                    break;
                }
            }
            p_ado = null;
            this.ParentForm.Close();
        }
Пример #3
0
 private void InitializeVariantLocationDictionary()
 {
     m_ado = new ado_data_access();
     dictVariantLocations = new Dictionary <string, List <string> >();
     using (var conn = new OleDbConnection(m_ado.getMDBConnString(
                                               frmMain.g_oEnv.strApplicationDataDirectory.Trim() + frmMain.g_strBiosumDataDir + "\\" +
                                               Tables.Reference.DefaultBiosumReferenceDbFile, "", "")))
     {
         conn.Open();
         m_ado.SqlQueryReader(conn, "SELECT DISTINCT fvs_variant, fvsloccode FROM fiadb_fvs_variant;");
         if (this.m_ado.m_intError == 0)
         {
             if (this.m_ado.m_OleDbDataReader.HasRows)
             {
                 string variant  = "";
                 string location = "";
                 while (this.m_ado.m_OleDbDataReader.Read())
                 {
                     variant = m_ado.m_OleDbDataReader["fvs_variant"].ToString().Trim();
                     if (!dictVariantLocations.ContainsKey(variant))
                     {
                         dictVariantLocations.Add(variant, new List <string>());
                     }
                     location = m_ado.m_OleDbDataReader["fvsloccode"].ToString().Trim();
                     dictVariantLocations[variant].Add(location);
                 }
             }
         }
         m_ado.m_OleDbDataReader.Dispose();
     }
     m_ado = null;
 }
Пример #4
0
        private void saveprivate()
        {
            ado_data_access p_ado   = new ado_data_access();
            string          strMDB  = ((frmMain)this.ParentForm.ParentForm).frmProject.uc_project1.txtPersonal.Text.Trim() + "\\personal_project_links_and_notes.mdb";
            string          strConn = p_ado.getMDBConnString(strMDB, "admin", "");
            //string strConn = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + strMDB + ";User Id=admin;Password=;";
            string strSQL = "";

            p_ado.OpenConnection(strConn);
            if (p_ado.m_intError == 0)
            {
                try
                {
                    string strNotes = this.txtNotesPersonal.Text;
                    strNotes = p_ado.FixString(strNotes, "'", "''");
                    if ((int)p_ado.getRecordCount(p_ado.m_OleDbConnection, "SELECT COUNT(*) FROM NOTES", "NOTES") > 0)
                    {
                        strSQL = "UPDATE NOTES SET NOTES = '" + strNotes + "'";
                        p_ado.SqlNonQuery(p_ado.m_OleDbConnection, strSQL);
                    }
                    else
                    {
                        strSQL = "INSERT INTO NOTES (NOTES) VALUES ('" + strNotes + "')";
                        p_ado.SqlNonQuery(p_ado.m_OleDbConnection, strSQL);
                    }
                }
                catch
                {
                }
            }
            p_ado = null;
        }
Пример #5
0
        public void UpdateDescription()
        {
            string strDesc = "";

            FIA_Biosum_Manager.ado_data_access oAdo = new ado_data_access();
            string        strScenarioDBDir          = frmMain.g_oFrmMain.frmProject.uc_project1.txtRootDirectory.Text.Trim() + "\\" + ScenarioType + "\\db";
            string        strScenarioFile           = "scenario_" + ScenarioType + "_rule_definitions.mdb";
            StringBuilder strScenarioFullPath       = new StringBuilder(strScenarioDBDir);

            strScenarioFullPath.Append("\\");
            strScenarioFullPath.Append(strScenarioFile);
            string strScenarioConn = oAdo.getMDBConnString(strScenarioFullPath.ToString(), "admin", "");

            oAdo.OpenConnection(strScenarioConn);
            if (this.txtDescription.Text.Trim().Length > 0)
            {
                strDesc = oAdo.FixString(this.txtDescription.Text.Trim(), "'", "''");
            }
            oAdo.m_strSQL = "UPDATE scenario SET description='" + strDesc.Trim() + "' WHERE TRIM(scenario_id)='" + this.txtScenarioId.Text.Trim() + "'";
            oAdo.SqlNonQuery(oAdo.m_OleDbConnection, oAdo.m_strSQL);
            oAdo.m_OleDbConnection.Close();
            while (oAdo.m_OleDbConnection.State != System.Data.ConnectionState.Closed)
            {
                oAdo.m_OleDbConnection.Close();
                System.Threading.Thread.Sleep(1000);
            }
            oAdo = null;
        }
        public void loadvalues(string strConn, string strSelectSQL, string strDisplayColumn, string strSelectColumn, string strTable)
        {
            this.m_strCurrentConnection = strConn;
            this.m_strTable             = strTable;

            ado_data_access p_ado = new ado_data_access();


            p_ado.OpenConnection(strConn);
            if (p_ado.m_intError != 0)
            {
                p_ado = null;
                return;
            }

            loadvalues(p_ado, p_ado.m_OleDbConnection, strSelectSQL, strDisplayColumn, strSelectColumn, strTable);


            if (p_ado.m_intError == 0)
            {
                p_ado.m_OleDbDataReader.Close();
            }
            p_ado.m_OleDbConnection.Close();
            p_ado = null;
        }
        public void LoadValues()
        {
            string strNotes = "";

            FIA_Biosum_Manager.ado_data_access oAdo = new ado_data_access();
            string        strScenarioDBDir          = frmMain.g_oFrmMain.frmProject.uc_project1.txtRootDirectory.Text.Trim() + "\\" + ScenarioType + "\\db";
            string        strScenarioFile           = "scenario_" + ScenarioType + "_rule_definitions.mdb";
            StringBuilder strScenarioFullPath       = new StringBuilder(strScenarioDBDir);

            strScenarioFullPath.Append("\\");
            strScenarioFullPath.Append(strScenarioFile);
            string strScenarioConn = oAdo.getMDBConnString(strScenarioFullPath.ToString(), "admin", "");

            oAdo.OpenConnection(strScenarioConn);
            if (ScenarioType.Trim().ToUpper() == "OPTIMIZER")
            {
                oAdo.m_strSQL = "SELECT notes FROM scenario WHERE TRIM(scenario_id)='" + this.ReferenceOptimizerScenarioForm.uc_scenario1.strScenarioId.Trim() + "'";
            }
            else
            {
                oAdo.m_strSQL = "SELECT notes FROM scenario WHERE TRIM(scenario_id)='" + this.ReferenceProcessorScenarioForm.uc_scenario1.strScenarioId.Trim() + "'";
            }
            strNotes = oAdo.getSingleStringValueFromSQLQuery(oAdo.m_OleDbConnection, oAdo.m_strSQL, "scenario");
            oAdo.m_OleDbConnection.Close();
            while (oAdo.m_OleDbConnection.State != System.Data.ConnectionState.Closed)
            {
                oAdo.m_OleDbConnection.Close();
                System.Threading.Thread.Sleep(1000);
            }
            oAdo = null;
            this.txtNotes.Text = strNotes;
        }
        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);
        }
Пример #9
0
        private void populate_state_combo()
        {
            this.cmbState.Items.Clear();
            ado_data_access p_ado   = new ado_data_access();
            env             p_env   = new env();
            string          strConn = p_ado.getMDBConnString(p_env.strAppDir.Trim() + "\\db\\utils.mdb", "", "");

            try
            {
                p_ado.SqlQueryReader(strConn, "select * from states order by stabv");
                if (p_ado.m_OleDbDataReader.HasRows == true)
                {
                    while (p_ado.m_OleDbDataReader.Read())
                    {
                        string strState = p_ado.m_OleDbDataReader["stabv"].ToString().Trim() + " - " +
                                          p_ado.m_OleDbDataReader["state_name"].ToString();
                        this.cmbState.Items.Add(strState);
                    }
                }
                p_ado.m_OleDbDataReader.Close();
                p_ado.m_OleDbConnection.Close();
                p_ado.m_OleDbConnection.Dispose();
            }
            catch
            {
            }
            p_ado = null;
            p_env = null;
        }
        public void loadvalues()
        {
            int x, y, z;

            m_oQueries.m_oFvs.LoadDatasource       = true;
            m_oQueries.m_oReference.LoadDatasource = true;
            m_oQueries.m_oProcessor.LoadDatasource = true;
            m_oQueries.LoadDatasources(true);
            m_oAdo = new ado_data_access();
            m_oAdo.OpenConnection(m_oAdo.getMDBConnString(m_oQueries.m_strTempDbFile, "", ""));

            this.lvRxHarvestCostColumns.Clear();

            this.m_oLvAlternateRowColors.InitializeRowCollection();
            this.lvRxHarvestCostColumns.Columns.Add("", 2, HorizontalAlignment.Left);
            this.lvRxHarvestCostColumns.Columns.Add("Rx", 80, HorizontalAlignment.Left);
            this.lvRxHarvestCostColumns.Columns.Add("Harvest Cost Component", 200, HorizontalAlignment.Left);
            this.lvRxHarvestCostColumns.Columns.Add("Description", 300, HorizontalAlignment.Left);

            this.m_intError = 0;
            this.m_strError = "";

            if (this.ReferenceFormRxItem.m_oRxItem.ReferenceHarvestCostColumnCollection != null)
            {
                this.lvRxHarvestCostColumns.BeginUpdate();

                for (x = 0; x <= this.ReferenceFormRxItem.m_oRxItem.ReferenceHarvestCostColumnCollection.Count - 1; x++)
                {
                    if (ReferenceFormRxItem.m_oRxItem.ReferenceHarvestCostColumnCollection.Item(x).Delete == false)
                    {
                        FIA_Biosum_Manager.RxItemHarvestCostColumnItem oItem =
                            ReferenceFormRxItem.m_oRxItem.ReferenceHarvestCostColumnCollection.Item(x);
                        this.lvRxHarvestCostColumns.Items.Add("");
                        this.lvRxHarvestCostColumns.Items[lvRxHarvestCostColumns.Items.Count - 1].UseItemStyleForSubItems = false;
                        for (z = 1; z <= this.lvRxHarvestCostColumns.Columns.Count - 1; z++)
                        {
                            this.lvRxHarvestCostColumns.Items[lvRxHarvestCostColumns.Items.Count - 1].SubItems.Add(" ");
                        }
                        this.lvRxHarvestCostColumns.Items[lvRxHarvestCostColumns.Items.Count - 1].SubItems[COLUMN_RX].Text    = oItem.RxId;
                        this.lvRxHarvestCostColumns.Items[lvRxHarvestCostColumns.Items.Count - 1].SubItems[COLUMN_FIELD].Text = oItem.HarvestCostColumn;
                        this.lvRxHarvestCostColumns.Items[lvRxHarvestCostColumns.Items.Count - 1].SubItems[COLUMN_DESC].Text  = oItem.Description;

                        this.m_oLvAlternateRowColors.AddRow();
                        this.m_oLvAlternateRowColors.AddColumns(lvRxHarvestCostColumns.Items.Count - 1, this.lvRxHarvestCostColumns.Columns.Count);
                    }
                }
                this.lvRxHarvestCostColumns.EndUpdate();
            }


            this.m_oLvAlternateRowColors.ListView();

            if (this.lvRxHarvestCostColumns.Items.Count > 0)
            {
                this.lvRxHarvestCostColumns.Items[0].Selected = true;
                ReferenceFormRxItem.m_bToolBarButtonEnabled[frmRxItem.UC_HARVESTCOST, frmRxItem.BUTTON_CLEARALL] = true;
                ReferenceFormRxItem.m_bToolBarButtonEnabled[frmRxItem.UC_HARVESTCOST, frmRxItem.BUTTON_DELETE]   = true;
                ReferenceFormRxItem.m_bToolBarButtonEnabled[frmRxItem.UC_HARVESTCOST, frmRxItem.BUTTON_EDIT]     = true;
            }
        }
        public void loadvalues(ado_data_access p_oAdo, System.Data.OleDb.OleDbConnection p_oConn, string p_strSelectSQL, string p_strDisplayColumn, string p_strSelectColumn, string p_strTable)
        {
            ((frmDialog)this.ParentForm).DialogResult = System.Windows.Forms.DialogResult.OK; p_oAdo.SqlQueryReader(p_oAdo.m_OleDbConnection, p_strSelectSQL);

            if (p_oAdo.m_intError != 0)
            {
                return;
            }
            if (p_oAdo.m_OleDbDataReader.HasRows)
            {
                this.listView1.Clear();
                this.listView1.Columns.Add(" ", 10, HorizontalAlignment.Center);
                this.m_strFieldTypeAString_YN = new string[p_oAdo.m_OleDbDataReader.FieldCount];
                for (int x = 0; x <= p_oAdo.m_OleDbDataReader.FieldCount - 1; x++)
                {
                    this.m_strFieldTypeAString_YN[x] = p_oAdo.getIsTheFieldAStringDataType(p_oAdo.m_OleDbDataReader.GetFieldType(x).FullName.ToString());
                    this.listView1.Columns.Add(p_oAdo.m_OleDbDataReader.GetName(x).ToString(), 100, HorizontalAlignment.Left);
                    if (p_oAdo.m_OleDbDataReader.GetName(x).ToString().Trim().ToUpper() ==
                        p_strDisplayColumn.Trim().ToUpper())
                    {
                        this.m_intDisplayColumn = x;
                    }
                    if (p_oAdo.m_OleDbDataReader.GetName(x).ToString().Trim().ToUpper() ==
                        p_strSelectColumn.Trim().ToUpper())
                    {
                        this.m_intSelectColumn = x;
                    }
                }

                while (p_oAdo.m_OleDbDataReader.Read())
                {
                    if (p_oAdo.m_OleDbDataReader[0] != System.DBNull.Value)
                    {
                        if (p_oAdo.m_OleDbDataReader[0].ToString().Trim().Length > 0)
                        {
                            System.Windows.Forms.ListViewItem entryListItem =
                                listView1.Items.Add("", 0);
                            this.m_oLvAlternateColors.AddRow();
                            this.m_oLvAlternateColors.AddColumns(entryListItem.Index, listView1.Columns.Count);
                            entryListItem.UseItemStyleForSubItems = false;
                            this.m_oLvAlternateColors.ListViewSubItem(entryListItem.Index, 0, entryListItem.SubItems[entryListItem.SubItems.Count - 1], false);
                            for (int x = 0; x <= p_oAdo.m_OleDbDataReader.FieldCount - 1; x++)
                            {
                                this.listView1.Items[entryListItem.Index].SubItems.Add(p_oAdo.m_OleDbDataReader[x].ToString().Trim());
                                this.m_oLvAlternateColors.ListViewSubItem(entryListItem.Index, x + 1, entryListItem.SubItems[entryListItem.SubItems.Count - 1], false);
                            }
                            this.listView1.Items[0].Selected = true;
                        }
                    }
                }
            }
            else
            {
                MessageBox.Show("No previous data to choose from", "FIA Biosum", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                ((frmDialog)this.ParentForm).DialogResult = System.Windows.Forms.DialogResult.Cancel;
            }
        }
        public void SaveScenarioNotes()
        {
            ado_data_access p_ado = null;

            SQLite.ADO.DataMgr oDataMgr       = null;
            string             strNotes       = this.txtNotes.Text;
            string             strProjDir     = frmMain.g_oFrmMain.frmProject.uc_project1.txtRootDirectory.Text.Trim();
            string             strScenarioDir = strProjDir + "\\" + ScenarioType + "\\db";

            if ((ReferenceProcessorScenarioForm != null && !ReferenceProcessorScenarioForm.m_bUsingSqlite) ||
                ScenarioType.Trim().ToUpper() == "OPTIMIZER")
            {
                p_ado    = new ado_data_access();
                strNotes = p_ado.FixString(strNotes, "'", "''");
                string strSQL = "";
                if (ScenarioType.Trim().ToUpper() == "OPTIMIZER")
                {
                    strSQL = "UPDATE scenario SET notes = '" +
                             strNotes +
                             "' WHERE trim(lcase(scenario_id)) = '" + ((frmOptimizerScenario)this.ParentForm).uc_scenario1.txtScenarioId.Text.Trim().ToLower() + "';";
                }
                else
                {
                    strSQL = "UPDATE scenario SET notes = '" +
                             strNotes +
                             "' WHERE trim(lcase(scenario_id)) = '" + this.ReferenceProcessorScenarioForm.uc_scenario1.txtScenarioId.Text.Trim().ToLower() + "';";
                }
                System.Data.OleDb.OleDbConnection oConn = new System.Data.OleDb.OleDbConnection();
                string        strFile     = "scenario_" + ScenarioType + "_rule_definitions.mdb";
                StringBuilder strFullPath = new StringBuilder(strScenarioDir);
                strFullPath.Append("\\");
                strFullPath.Append(strFile);
                string strConn = p_ado.getMDBConnString(strFullPath.ToString(), "admin", "");
                p_ado.SqlNonQuery(strConn, strSQL);
                p_ado = null;
            }
            else
            {
                oDataMgr = new SQLite.ADO.DataMgr();
                strNotes = oDataMgr.FixString(strNotes, "'", "''");
                //@ToDo: Only support Processor at this time
                string strSQL = "UPDATE scenario SET notes = '" +
                                strNotes +
                                "' WHERE trim(lower(scenario_id)) = '" + this.ReferenceProcessorScenarioForm.uc_scenario1.txtScenarioId.Text.Trim().ToLower() + "';";
                string        strFile     = "scenario_" + ScenarioType + "_rule_definitions.db";
                StringBuilder strFullPath = new StringBuilder(strScenarioDir);
                strFullPath.Append("\\");
                strFullPath.Append(strFile);
                string strConn = oDataMgr.GetConnectionString(strFullPath.ToString());
                using (System.Data.SQLite.SQLiteConnection conn = new System.Data.SQLite.SQLiteConnection(strConn))
                {
                    conn.Open();
                    oDataMgr.SqlNonQuery(conn, strSQL);
                }
                oDataMgr = null;
            }
        }
Пример #13
0
        public void populate_scenario_listbox()
        {
            string strScenarioId  = "";
            string strDescription = "";
            //string strScenarioMDBFile="";
            string strScenarioPath = "";

            System.Data.OleDb.OleDbConnection oConn = new System.Data.OleDb.OleDbConnection();
            string strProjDir = frmMain.g_oFrmMain.frmProject.uc_project1.txtRootDirectory.Text.Trim();

            string        strScenarioDir = frmMain.g_oFrmMain.frmProject.uc_project1.txtRootDirectory.Text.Trim() + "\\" + ScenarioType + "\\db";
            string        strFile        = "scenario_" + ScenarioType + "_rule_definitions.mdb";
            StringBuilder strFullPath    = new StringBuilder(strScenarioDir);

            strFullPath.Append("\\");
            strFullPath.Append(strFile);
            ado_data_access p_ado   = new ado_data_access();
            string          strConn = p_ado.getMDBConnString(strFullPath.ToString(), "admin", "");

            p_ado.SqlQueryReader(strConn, "select * from scenario");
            if (p_ado.m_intError == 0)
            {
                try
                {
                    this.lstScenario.Items.Clear();
                    while (p_ado.m_OleDbDataReader.Read())
                    {
                        strScenarioId = p_ado.m_OleDbDataReader["scenario_id"].ToString();
                        //strScenarioMDBFile = p_ado.m_OleDbDataReader["file"].ToString();
                        strDescription  = p_ado.m_OleDbDataReader["description"].ToString();
                        strScenarioPath = p_ado.m_OleDbDataReader["path"].ToString();
                        this.lstScenario.Items.Add(p_ado.m_OleDbDataReader["scenario_id"].ToString());
                    }
                    this.lstScenario.SelectedIndex = this.lstScenario.Items.Count - 1;

                    this.txtScenarioPath.Text = strScenarioPath;
                    this.txtDescription.Text  = strDescription;
                }
                catch (Exception caught)
                {
                    intError = -1;
                    strError = caught.Message;
                    MessageBox.Show(strError);
                }
                p_ado.m_OleDbDataReader.Close();
                p_ado.m_OleDbDataReader = null;
                p_ado.m_OleDbCommand    = null;
                p_ado.m_OleDbConnection.Close();
                p_ado.m_OleDbConnection = null;
            }
            p_ado = null;
        }
Пример #14
0
 private void InstantiateConnectionObject(ado_data_access p_oAdo)
 {
     if (_oConn == null)
     {
     }
     else
     {
         p_oAdo.CloseConnection(_oConn);
         _oConn.Dispose();
         _oConn = null;
     }
     _oConn = new System.Data.OleDb.OleDbConnection();
 }
Пример #15
0
        public run_PostFvsForeFrcs(string p_strProjDir)
        {
            this.m_strProjDir = p_strProjDir.Trim();
            m_DataSource      = new Datasource();
            m_DataSource.LoadTableColumnNamesAndDataTypes = false;
            m_DataSource.LoadTableRecordCount             = false;
            m_DataSource.m_strDataSourceMDBFile           = p_strProjDir.Trim() + "\\db\\project.mdb";
            m_DataSource.m_strDataSourceTableName         = "datasource";
            m_DataSource.m_strScenarioId = "";
            m_DataSource.populate_datasource_array();

            this.m_strCondTable = this.m_DataSource.getValidDataSourceTableName("CONDITION");

            this.m_strProcessorInTreeListTable = this.m_DataSource.getValidDataSourceTableName("FVS TREE LIST FOR PROCESSOR");
            this.m_strRxTable     = this.m_DataSource.getValidDataSourceTableName("TREATMENT PRESCRIPTIONS");
            this.m_strTempMDBFile = this.m_DataSource.CreateMDBAndTableDataSourceLinks();
            if (this.m_strCondTable.Trim().Length == 0)
            {
                MessageBox.Show("!!Could Not Locate Cond Table!!", "Process FVS Out", System.Windows.Forms.MessageBoxButtons.OK, System.Windows.Forms.MessageBoxIcon.Exclamation);
                this.m_intError = -1;
                return;
            }
            if (this.m_strFFETable.Trim().Length == 0)
            {
                MessageBox.Show("!!Could Not Locate FFE Table!!", "Process FVS Out", System.Windows.Forms.MessageBoxButtons.OK, System.Windows.Forms.MessageBoxIcon.Exclamation);
                this.m_intError = -1;
                return;
            }
            if (this.m_strProcessorInTreeListTable.Trim().Length == 0)
            {
                MessageBox.Show("!!Could Not Locate Processor In Tree Table!!", "Process FVS Out", System.Windows.Forms.MessageBoxButtons.OK, System.Windows.Forms.MessageBoxIcon.Exclamation);
                this.m_intError = -1;
                return;
            }
            if (this.m_strRxTable.Trim().Length == 0)
            {
                MessageBox.Show("!!Could Not Locate Treatment Table!!", "Process FVS Out", System.Windows.Forms.MessageBoxButtons.OK, System.Windows.Forms.MessageBoxIcon.Exclamation);
                this.m_intError = -1;
                return;
            }

            this.m_ado     = new ado_data_access();
            this.m_strConn = this.m_ado.getMDBConnString(this.m_strTempMDBFile, "", "");
            this.m_dao     = new dao_data_access();



            this.htUserFvsoutSet = new Hashtable();
            this.dsWorkDataSet   = new DataSet("FVS2FRCS");
            this.aryLRxSelected  = new ArrayList();
        }
Пример #16
0
        private string getNextScenarioId()
        {
            System.Data.OleDb.OleDbConnection oConn = new System.Data.OleDb.OleDbConnection();
            string strProjDir     = frmMain.g_oFrmMain.getProjectDirectory();
            string strScenarioDir = strProjDir + "\\" + ScenarioType + "\\db";
            string strFile        = "scenario_" + ScenarioType + "_rule_definitions.mdb";

            System.Text.StringBuilder strFullPath = new System.Text.StringBuilder(strScenarioDir);
            strFullPath.Append("\\");
            strFullPath.Append(strFile);
            ado_data_access oAdo    = new ado_data_access();
            string          strConn = oAdo.getMDBConnString(strFullPath.ToString(), "admin", "");

            oAdo.OpenConnection(strConn);
            string strSQL = "SELECT scenario_id from " + Tables.Scenario.DefaultScenarioTableName;

            System.Collections.Generic.IList <string> lstExistingScenarios = new System.Collections.Generic.List <string>();

            oAdo.SqlQueryReader(oAdo.m_OleDbConnection, strSQL);
            if (oAdo.m_OleDbDataReader.HasRows)
            {
                // Load all of the existing scenarios into a list we can query
                while (oAdo.m_OleDbDataReader.Read())
                {
                    string strScenario = Convert.ToString(oAdo.m_OleDbDataReader["scenario_id"]).Trim();
                    if (!String.IsNullOrEmpty(strScenario))
                    {
                        lstExistingScenarios.Add(strScenario);
                    }
                }
            }
            oAdo.CloseConnection(oAdo.m_OleDbConnection);

            int    i = 1;
            string strTestName;

            // keep incrementing the scenario name until we find one that doesn't exist
            while (i < (lstExistingScenarios.Count + 1))
            {
                strTestName = "scenario" + Convert.ToString(i);
                if (!lstExistingScenarios.Contains(strTestName))
                {
                    break;
                }
                i++;
            }

            strTestName = "scenario" + Convert.ToString(i);
            return(strTestName);
        }
        public int Val_Last_Tiebreak_Rank(bool p_bDisplayMessage)
        {
            int             x;
            int             y;
            ado_data_access p_ado = new ado_data_access();

            if (this.m_DataSet.Tables[this.strRxPackageTableName].Rows.Count == 0)
            {
                if (p_bDisplayMessage)
                {
                    MessageBox.Show("Run Scenario Failed: No treatments defined");
                }
                return(-1);
            }
            //if (((frmScenario)this.ParentForm).m_bSave)
            //   this.savevalues();

            for (x = this.m_DataSet.Tables["scenario_last_tiebreak_rank"].Rows.Count - 1;
                 x >= 0; x--)
            {
                //check for null value
                if (m_DataSet.Tables["scenario_last_tiebreak_rank"].Rows[x]["last_tiebreak_rank"] == System.DBNull.Value)
                {
                    if (p_bDisplayMessage)
                    {
                        MessageBox.Show("Run Scenario Failed: Last Tie-Break Rankings cannot be null in value");
                    }
                    return(-3);
                }
                //check for duplicates
                for (y = x - 1; y >= 0; y--)
                {
                    if (this.m_DataSet.Tables["scenario_last_tiebreak_rank"].Rows[x]["last_tiebreak_rank"].ToString().Trim() ==
                        this.m_DataSet.Tables["scenario_last_tiebreak_rank"].Rows[y]["last_tiebreak_rank"].ToString().Trim())
                    {
                        if (p_bDisplayMessage)
                        {
                            MessageBox.Show("Run Scenario Failed: Last Tie-Break Rankings must be unique");
                        }
                        return(-2);
                    }
                }
            }

            return(0);
        }
        private void Save()
        {
            string          strPath       = "";
            string          strDatasource = "";
            string          strTableType  = "";
            string          strScenario   = "";
            ado_data_access oAdo          = new ado_data_access();

            oAdo.OpenConnection(oAdo.getMDBConnString(m_strRandomPathAndFile, "", ""));

            for (int x = 0; x <= lvDatasources.Items.Count - 1; x++)
            {
                strDatasource = lvDatasources.Items[x].SubItems[COLUMN_DATASOURCE].Text.Trim();
                strTableType  = lvDatasources.Items[x].SubItems[COLUMN_TABLETYPE].Text.Trim();
                strPath       = lvDatasources.Items[x].SubItems[COLUMN_PATH].Text.Trim();
                strScenario   = lvDatasources.Items[x].SubItems[COLUMN_SCENARIO].Text.Trim();
                oAdo.m_strSQL = "";
                if (strDatasource == "Project")
                {
                    oAdo.m_strSQL = "UPDATE project_datasource SET path = '" + strPath + "' WHERE TRIM(Table_Type) = '" + strTableType + "'";
                }
                else if (strDatasource == "TreatmentOptimizer" && strTableType == "NA")
                {
                    oAdo.m_strSQL = "UPDATE optimizer_scenario SET path = '" + strPath + "' WHERE TRIM(scenario_id) = '" + strScenario + "'";
                }
                else if (strDatasource == "TreatmentOptimizer")
                {
                    oAdo.m_strSQL = "UPDATE optimizer_scenario_datasource SET path = '" + strPath + "' WHERE TRIM(scenario_id) = '" + strScenario + "' AND TRIM(Table_Type) = '" + strTableType + "'";
                }
                else if (strDatasource == "Processor" && strTableType == "NA")
                {
                    oAdo.m_strSQL = "UPDATE processor_scenario SET path = '" + strPath + "' WHERE TRIM(scenario_id) = '" + strScenario + "'";
                }
                else if (strDatasource == "Processor")
                {
                    oAdo.m_strSQL = "UPDATE processor_scenario_datasource SET path = '" + strPath + "' WHERE TRIM(scenario_id) = '" + strScenario + "' AND TRIM(Table_Type) = '" + strTableType + "'";
                }
                if (oAdo.m_strSQL.Trim().Length > 0)
                {
                    oAdo.SqlNonQuery(oAdo.m_OleDbConnection, oAdo.m_strSQL);
                }
            }
            oAdo.CloseConnection(oAdo.m_OleDbConnection);
            MessageBox.Show("Done", "FIA Biosum");
            m_bSyncd = false;
        }
Пример #19
0
        public uc_contact_edit(ado_data_access p_ado, string p_strTreeSpcTable)
        {
            // This call is required by the Windows.Forms Form Designer.
            InitializeComponent();
            this.txtPhone.Text    = "";
            this.txtAreaCode.Text = "";
            this.txtPrefix.Text   = "";
            this.txtExt.Text      = "";
            this.txtZip1.Text     = "";
            this.txtZip2.Text     = "";
            this.txtStreet.Text   = "";
            this.txtOrg.Text      = "";
            this.populate_state_combo();



            // TODO: Add any initialization after the InitializeComponent call
        }
Пример #20
0
        //Get the Select files and check to see how many records are in the selected Verified files, TODO: otherwise?
        //Check for null when calling
        private Hashtable DbRecsCountVerify(ArrayList aryOfExistingFvsRxMdbFiles)
        {
            Hashtable htTmp  = null;
            string    strSql = "SELECT COUNT(*) FROM FVS_TREELIST";

            if (aryOfExistingFvsRxMdbFiles.Count < 1)
            {
                return(htTmp);
            }
            else
            {
                htTmp = new Hashtable();
                ado_data_access adoD = new ado_data_access();
                for (short x = 0; x < aryOfExistingFvsRxMdbFiles.Count; x++)
                {
                    htTmp.Add(aryOfExistingFvsRxMdbFiles[x].ToString(), Convert.ToInt32(adoD.getRecordCount(string.Format(this.strDbConx, string.Format(this.strPathFvsDbFile, aryOfExistingFvsRxMdbFiles[x].ToString())), strSql, "FVS_TREELIST")));
                }
            }
            return(htTmp);
        }
        public void loadvalues()
        {
            ScenarioId = this.ReferenceProcessorScenarioForm.uc_scenario1.txtScenarioId.Text.Trim().ToLower();
            m_oAdo     = new ado_data_access();
            m_oAdo.OpenConnection(m_oAdo.getMDBConnString(this.ReferenceProcessorScenarioForm.LoadedQueries.m_strTempDbFile, "", ""));

            ReferenceProcessorScenarioForm.m_oProcessorScenarioTools.LoadMoveInCosts
                (frmMain.g_oFrmMain.frmProject.uc_project1.txtRootDirectory.Text.Trim() +
                "\\processor\\db\\scenario_processor_rule_definitions.mdb",
                ReferenceProcessorScenarioForm.m_oProcessorScenarioItem);

            FIA_Biosum_Manager.ProcessorScenarioItem oItem = ReferenceProcessorScenarioForm.m_oProcessorScenarioItem;
            if (ReferenceProcessorScenarioForm.m_oProcessorScenarioTools.m_intError == 0)
            {
                this.txtYardDistThreshold.Text    = oItem.m_oMoveInCosts.YardDistThreshold;
                this.txtAssumedHarvestArea.Text   = oItem.m_oMoveInCosts.AssumedHarvestAreaAc;
                this.txtMoveInTimeMultiplier.Text = oItem.m_oMoveInCosts.MoveInTimeMultiplier;
                this.txtMoveInAddend.Text         = oItem.m_oMoveInCosts.MoveInHoursAddend;
            }
        }
Пример #22
0
        public int getNumberOfOptimizerTables(string strScenarioMDB, string strScenarioId)
        {
            int intCount = 0;

            System.Data.OleDb.OleDbConnection p_conn;

            ado_data_access p_ado = new ado_data_access();

            p_conn = new System.Data.OleDb.OleDbConnection();
            string strConn = p_ado.getMDBConnString(strScenarioMDB, "admin", "");

            p_ado.OpenConnection(strConn, ref p_conn);
            if (p_ado.m_intError != 0)
            {
                p_ado = null;
                return(intCount);
            }
            string strSQL = "SELECT table_name FROM scenario_datasource WHERE " +
                            " scenario_id = '" + strScenarioId + "';";

            p_ado.SqlQueryReader(p_conn, strSQL);
            if (p_ado.m_intError == 0)
            {
                while (p_ado.m_OleDbDataReader.Read())
                {
                    if (p_ado.m_OleDbDataReader["table_name"] != System.DBNull.Value)
                    {
                        if (p_ado.m_OleDbDataReader["table_name"].ToString().Trim().Length > 0)
                        {
                            intCount++;
                        }
                    }
                }
            }
            p_ado.m_OleDbDataReader.Close();
            p_ado.m_OleDbDataReader = null;
            p_conn.Close();
            p_conn = null;
            p_ado  = null;
            return(intCount);
        }
        public void loadvalues()
        {
            int x;

            this.txtDesc.Text                      = "";
            this.txtRxDesc.Text                    = "";
            this.txtSteepSlopeDesc.Text            = "";
            m_oQueries.m_oFvs.LoadDatasource       = true;
            m_oQueries.m_oReference.LoadDatasource = true;
            m_oQueries.LoadDatasources(true);
            m_oAdo = new ado_data_access();
            m_oAdo.OpenConnection(m_oAdo.getMDBConnString(m_oQueries.m_strTempDbFile, "", ""));
            if (m_oAdo.m_intError == 0)
            {
                this.m_oRxTools.LoadRxHarvestMethods(m_oAdo, m_oAdo.m_OleDbConnection, m_oQueries, cmbMethod, cmbSteepSlopeMethod);
                for (x = 0; x <= this.cmbMethod.Items.Count - 1; x++)
                {
                    if (ReferenceFormRxItem.m_oRxItem.HarvestMethodLowSlope.Trim().ToUpper() ==
                        cmbMethod.Items[x].ToString().Trim().ToUpper())
                    {
                        cmbMethod.Text = cmbMethod.Items[x].ToString().Trim();
                    }
                }
                for (x = 0; x <= this.cmbSteepSlopeMethod.Items.Count - 1; x++)
                {
                    if (ReferenceFormRxItem.m_oRxItem.HarvestMethodSteepSlope.Trim().ToUpper() ==
                        cmbSteepSlopeMethod.Items[x].ToString().Trim().ToUpper())
                    {
                        cmbSteepSlopeMethod.Text = cmbSteepSlopeMethod.Items[x].ToString().Trim();
                    }
                }

                //if (ReferenceFormRxItem != null)
                //{
                //	if (this.cmbMethod.Text.Trim().Length > 0) this.getDesc();
                //	if (this.cmbSteepSlopeMethod.Text.Trim().Length > 0) this.getDescSteepSlope();
                //	this.txtRxDesc.Text = ReferenceFormRxItem.m_oRxItem.Description;
                //}
            }
            this.txtRxDesc.Text = this.ReferenceFormRxItem.m_oRxItem.Description;
        }
Пример #24
0
        //Get rx listing from project and make sure all FSOUT_rx* is present, TODO: otherwise?
        private ArrayList DbRxVerify()
        {
            ArrayList       aryL  = new ArrayList();
            ado_data_access p_ado = new ado_data_access();

            string strSQL = @"SELECT * FROM RX;";

            try
            {
                p_ado.SqlQueryReader(string.Format(this.strDbConx, this.strPathMasterDbFile), strSQL);
                if (p_ado.m_intError == 0)
                {
                    if (p_ado.m_OleDbDataReader.HasRows == true)
                    {
                        while (p_ado.m_OleDbDataReader.Read())
                        {
                            aryL.Add(p_ado.m_OleDbDataReader["RX"].ToString().Trim());
                        }
                    }
                    else
                    {
                        //TODO: Log to file
                    }
                }
            }
            catch (OLE.OleDbException ode)
            {
                p_ado.m_OleDbDataReader.Close();
                p_ado.m_OleDbConnection.Close();
                throw ode;
            }
            finally
            {
                p_ado.m_OleDbDataReader.Close();
                p_ado.m_OleDbConnection.Close();
                p_ado.m_OleDbDataReader = null;
                p_ado.m_OleDbConnection = null;
                p_ado = null;
            }
            return(aryL);
        }
Пример #25
0
        private void RefreshForm()
        {
            string        strScenarioDir = frmMain.g_oFrmMain.frmProject.uc_project1.txtRootDirectory.Text.Trim() + "\\" + ScenarioType + "\\db";
            string        strFile        = "scenario_" + ScenarioType + "_rule_definitions.mdb";
            StringBuilder strFullPath    = new StringBuilder(strScenarioDir);

            strFullPath.Append("\\");
            strFullPath.Append(strFile);
            ado_data_access p_ado   = new ado_data_access();
            string          strConn = p_ado.getMDBConnString(strFullPath.ToString(), "admin", "");
            //string strConn = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + strFullPath.ToString() + ";User Id=admin;Password=;";
            string strSQL = "select * from scenario where scenario_id = '" + this.lstScenario.SelectedItem.ToString() + "';";

            p_ado.SqlQueryReader(strConn, strSQL);
            if (p_ado.m_intError == 0)
            {
                try
                {
                    while (p_ado.m_OleDbDataReader.Read())
                    {
                        this.txtDescription.Text  = p_ado.m_OleDbDataReader["description"].ToString();
                        this.txtScenarioPath.Text = p_ado.m_OleDbDataReader["path"].ToString();
                        this.txtScenarioId.Text   = p_ado.m_OleDbDataReader["scenario_id"].ToString();
                        //((frmScenario)this.ParentForm).uc_scenario_notes1.txtNotes.Text = p_ado.m_OleDbDataReader["notes"].ToString();
                        break;
                    }
                    p_ado.m_OleDbDataReader.Close();
                }
                catch (Exception caught)
                {
                    this.strError = caught.Message;
                    this.intError = -1;
                    MessageBox.Show(this.strError);
                }
                p_ado.m_OleDbDataReader = null;
                p_ado.m_OleDbCommand    = null;
                p_ado.m_OleDbConnection.Close();
                p_ado.m_OleDbConnection = null;
            }
        }
Пример #26
0
 /// <summary>
 /// Populate listbox with the strColumn values
 /// </summary>
 /// <param name="p_oAdo"></param>
 /// <param name="p_oConn"></param>
 /// <param name="strSQL"></param>
 /// <param name="strColumn"></param>
 public void loadvalues(ado_data_access p_oAdo,
                        System.Data.OleDb.OleDbConnection p_oConn,
                        string strSQL, string strColumn)
 {
     listBox1.Items.Clear();
     p_oAdo.SqlQueryReader(p_oConn, strSQL);
     if (p_oAdo.m_OleDbDataReader.HasRows)
     {
         while (p_oAdo.m_OleDbDataReader.Read())
         {
             if (p_oAdo.m_OleDbDataReader[strColumn] != System.DBNull.Value &&
                 p_oAdo.m_OleDbDataReader[strColumn].ToString().Trim().Length > 0)
             {
                 listBox1.Items.Add(p_oAdo.m_OleDbDataReader[strColumn].ToString().Trim());
             }
         }
     }
     else
     {
         MessageBox.Show("No items to add to menu list", "FIA Bisoum");
     }
 }
        public int savevalues()
        {
            int             x      = 0;
            string          strSQL = "";
            ado_data_access p_ado  = new ado_data_access();

            p_ado.m_intError = 0;
            try
            {
                for (x = 0; x <= this.m_DataSet.Tables["scenario_last_tiebreak_rank"].Rows.Count - 1; x++)
                {
                    if (m_DataSet.Tables["scenario_last_tiebreak_rank"].Rows[x]["last_tiebreak_rank"] != System.DBNull.Value &&
                        m_DataSet.Tables["scenario_last_tiebreak_rank"].Rows[x]["last_tiebreak_rank"].ToString().Trim().Length > 0)
                    {
                        strSQL = "UPDATE scenario_last_tiebreak_rank SET last_tiebreak_rank = " +
                                 this.m_DataSet.Tables["scenario_last_tiebreak_rank"].Rows[x]["last_tiebreak_rank"] +
                                 " WHERE TRIM(rxpackage) = '" + this.m_DataSet.Tables["scenario_last_tiebreak_rank"].Rows[x]["rxpackage"].ToString().Trim() + "';";
                    }
                    else
                    {
                        strSQL = "UPDATE scenario_last_tiebreak_rank SET last_tiebreak_rank = null " +
                                 " WHERE TRIM(rxpackage) = '" + this.m_DataSet.Tables["scenario_last_tiebreak_rank"].Rows[x]["rxpackage"].ToString().Trim() + "';";
                    }
                    p_ado.SqlNonQuery(this.m_OleDbConnectionScenario, strSQL);
                    if (p_ado.m_intError < 0)
                    {
                        break;
                    }
                }
            }
            catch (Exception caught)
            {
                MessageBox.Show("Function: uc_optimizer_scenario_last_tiebreak_rank.savevalues ErrMsg:" + caught.Message + " Failed updating scenario_last_tiebreak_rank table with last tiebreak rank ratings");
            }
            x     = p_ado.m_intError;
            p_ado = null;
            return(x);
        }
        public void savevalues()
        {
            ado_data_access oAdo           = new ado_data_access();
            string          strScenarioId  = this.ReferenceOptimizerScenarioForm.uc_scenario1.txtScenarioId.Text.Trim().ToLower();
            string          strScenarioMDB =
                frmMain.g_oFrmMain.frmProject.uc_project1.txtRootDirectory.Text.Trim() + "\\" +
                Tables.OptimizerScenarioRuleDefinitions.DefaultScenarioTableDbFile;

            oAdo.OpenConnection(oAdo.getMDBConnString(strScenarioMDB, "", ""));
            oAdo.m_strSQL = "DELETE FROM " + Tables.OptimizerScenarioRuleDefinitions.DefaultScenarioProcessorScenarioSelectTableName + " " +
                            "WHERE TRIM(UCASE(scenario_id)) = '" +
                            ReferenceOptimizerScenarioForm.uc_scenario1.txtScenarioId.Text.Trim().ToUpper() + "';";
            oAdo.SqlNonQuery(oAdo.m_OleDbConnection, oAdo.m_strSQL);
            if (lvProcessorScenario.CheckedItems.Count > 0)
            {
                string strColumnsList = "scenario_id,processor_scenario_id,FullDetailsYN";
                string strValuesList  = "";
                strValuesList = "'" + ReferenceOptimizerScenarioForm.uc_scenario1.txtScenarioId.Text.Trim() + "',";
                strValuesList = strValuesList + "'" + lvProcessorScenario.CheckedItems[0].SubItems[COL_SCENARIOID].Text.Trim() + "',";
                if (this.chkFullDetails.Checked)
                {
                    strValuesList = strValuesList + "'Y'";
                }
                else
                {
                    strValuesList = strValuesList + "'N'";
                }

                oAdo.m_strSQL = "INSERT INTO " + Tables.OptimizerScenarioRuleDefinitions.DefaultScenarioProcessorScenarioSelectTableName + " " +
                                "(" + strColumnsList + ") " +
                                "VALUES " +
                                "(" + strValuesList + ")";

                oAdo.SqlNonQuery(oAdo.m_OleDbConnection, oAdo.m_strSQL);
            }
            oAdo.CloseConnection(oAdo.m_OleDbConnection);
        }
Пример #29
0
        // We do not currently save the list of selected packages. It is reloaded
        // each time a scenario is loaded.
        public int savevalues()
        {
            string strScenarioId;
            int    x = -1;

            ado_data_access p_ado = new ado_data_access();

            strScenarioId = this.ReferenceOptimizerScenarioForm.uc_scenario1.txtScenarioId.Text.Trim().ToLower();
            string strScenarioMDB =
                frmMain.g_oFrmMain.frmProject.uc_project1.txtRootDirectory.Text.Trim() + "\\" +
                Tables.OptimizerScenarioRuleDefinitions.DefaultScenarioTableDbFile;

            string strConn = p_ado.getMDBConnString(strScenarioMDB, "admin", "");

            p_ado.OpenConnection(strConn);
            if (p_ado.m_intError != 0)
            {
                x     = p_ado.m_intError;
                p_ado = null;
                return(x);
            }

            return(x);
        }
        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 = new ado_data_access();
            string          strProcessorScenario = "";
            string          strFullDetailsYN     = "N";

            if (p_bScenarioCopy == false)
            {
                string[] strScenarioArray = null;
                if (!ReferenceOptimizerScenarioForm.m_bProcessorUsingSqlite)
                {
                    strScenarioArray = loadScenarioArray(oAdo);
                }
                else
                {
                    strScenarioArray = loadScenarioArraySqlite();
                }
                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, ReferenceOptimizerScenarioForm.m_bProcessorUsingSqlite, "processor", strScenarioArray[x]);
                    if (!ReferenceOptimizerScenarioForm.m_bProcessorUsingSqlite)
                    {
                        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);
                    }
                    else
                    {
                        oTools.LoadAllSqlite(m_oQueries, strScenarioArray[x], m_oProcessorScenarioItem_Collection);
                    }
                }
            }
            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;
            }
        }