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;
            }
        }
        public void saveTreeGroupings_FromPropertiesSqlite()
        {
            SQLite.ADO.DataMgr oDataMgr  = new SQLite.ADO.DataMgr();
            string             strDbFile = frmMain.g_oFrmMain.frmProject.uc_project1.txtRootDirectory.Text.Trim() +
                                           "\\processor\\" + Tables.ProcessorScenarioRuleDefinitions.DefaultSqliteDbFile;

            using (System.Data.SQLite.SQLiteConnection conn = new System.Data.SQLite.SQLiteConnection(oDataMgr.GetConnectionString(strDbFile)))
            {
                conn.Open();
                if (oDataMgr.m_intError == 0)
                {
                    string strScenarioId = this.ReferenceProcessorScenarioForm.m_oProcessorScenarioItem.ScenarioId;
                    //delete the current records
                    oDataMgr.m_strSQL = "DELETE FROM " + Tables.ProcessorScenarioRuleDefinitions.DefaultTreeDiamGroupsTableName +
                                        " WHERE TRIM(UPPER(scenario_id)) = '" + strScenarioId.ToUpper().Trim() + "'";
                    oDataMgr.SqlNonQuery(conn, oDataMgr.m_strSQL);

                    // saving tree diameter groups
                    if (oDataMgr.m_intError == 0)
                    {
                        string strMin;
                        string strMax;
                        string strDef;
                        string strId;
                        for (int x = 0; x <= ReferenceProcessorScenarioForm.m_oProcessorScenarioItem.m_oTreeDiamGroupsItem_Collection.Count - 1; x++)
                        {
                            ProcessorScenarioItem.TreeDiamGroupsItem oItem =
                                ReferenceProcessorScenarioForm.m_oProcessorScenarioItem.m_oTreeDiamGroupsItem_Collection.Item(x);
                            strId  = oItem.DiamGroup;
                            strMin = oItem.MinDiam;
                            strMax = oItem.MaxDiam;
                            strDef = oItem.DiamClass;

                            oDataMgr.m_strSQL = "INSERT INTO " + Tables.ProcessorScenarioRuleDefinitions.DefaultTreeDiamGroupsTableName + " " +
                                                "(diam_group,diam_class,min_diam,max_diam,scenario_id) VALUES " +
                                                "(" + strId + ",'" + strDef.Trim() + "'," +
                                                strMin + "," + strMax + ",'" + strScenarioId.Trim() + "');";
                            oDataMgr.SqlNonQuery(conn, oDataMgr.m_strSQL);
                            if (oDataMgr.m_intError != 0)
                            {
                                break;
                            }
                        }
                    }
                    // saving tree species groups
                    if (oDataMgr.m_intError == 0)
                    {
                        string strCommonName;
                        int    intSpCd;
                        int    intSpcGrp;
                        string strGrpLabel;
                        int    x;

                        //delete all records from the tree species group table
                        oDataMgr.m_strSQL = "DELETE FROM " + Tables.ProcessorScenarioRuleDefinitions.DefaultTreeSpeciesGroupsTableName +
                                            " WHERE TRIM(UPPER(scenario_id))='" + strScenarioId.Trim().ToUpper() + "'";
                        oDataMgr.SqlNonQuery(conn, oDataMgr.m_strSQL);
                        if (oDataMgr.m_intError != 0)
                        {
                            return;
                        }

                        //delete all records from the tree species group list table
                        oDataMgr.m_strSQL = "DELETE FROM " + Tables.ProcessorScenarioRuleDefinitions.DefaultTreeSpeciesGroupsListTableName +
                                            " WHERE TRIM(UPPER(scenario_id))='" + strScenarioId.Trim().ToUpper() + "'";
                        oDataMgr.SqlNonQuery(conn, oDataMgr.m_strSQL);

                        if (oDataMgr.m_intError == 0)
                        {
                            for (x = 0; x <= this.ReferenceProcessorScenarioForm.m_oProcessorScenarioItem.m_oSpcGroupItem_Collection.Count - 1; x++)
                            {
                                FIA_Biosum_Manager.ProcessorScenarioItem.SpcGroupItem oItem =
                                    ReferenceProcessorScenarioForm.m_oProcessorScenarioItem.m_oSpcGroupItem_Collection.Item(x);
                                intSpcGrp         = oItem.SpeciesGroup;
                                strGrpLabel       = oItem.SpeciesGroupLabel;
                                oDataMgr.m_strSQL = "INSERT INTO " + Tables.ProcessorScenarioRuleDefinitions.DefaultTreeSpeciesGroupsTableName + " " +
                                                    "(SPECIES_GROUP,SPECIES_LABEL,SCENARIO_ID) VALUES " +
                                                    "(" + Convert.ToString(intSpcGrp).Trim() + ",'" + strGrpLabel.Trim() + "','" + strScenarioId.Trim() + "');";
                                oDataMgr.SqlNonQuery(conn, oDataMgr.m_strSQL);
                            }
                        }
                        if (oDataMgr.m_intError == 0)
                        {
                            for (x = 0; x <= this.ReferenceProcessorScenarioForm.m_oProcessorScenarioItem.m_oSpcGroupListItem_Collection.Count - 1; x++)
                            {
                                ProcessorScenarioItem.SpcGroupListItem oItem =
                                    ReferenceProcessorScenarioForm.m_oProcessorScenarioItem.m_oSpcGroupListItem_Collection.Item(x);
                                intSpcGrp     = oItem.SpeciesGroup;
                                strCommonName = oItem.CommonName;
                                strCommonName = oDataMgr.FixString(strCommonName.Trim(), "'", "''");
                                intSpCd       = oItem.SpeciesCode;

                                oDataMgr.m_strSQL = "INSERT INTO " + Tables.ProcessorScenarioRuleDefinitions.DefaultTreeSpeciesGroupsListTableName + " " +
                                                    "(SPECIES_GROUP,common_name,SCENARIO_ID,SPCD) VALUES " +
                                                    "(" + Convert.ToString(intSpcGrp).Trim() + ",'" + strCommonName + "','" + strScenarioId.Trim() + "', " +
                                                    intSpCd + " );";
                                oDataMgr.SqlNonQuery(conn, oDataMgr.m_strSQL);
                            }
                        }
                    }
                    ReferenceProcessorScenarioForm.m_bTreeGroupsCopied = false;
                }
            }
            oDataMgr = null;
        }