private void btnEdit_Click(object sender, System.EventArgs e)
        {
            string strMax = "";
            string strMin = "";
            string strId  = "";

            if (this.lstTreeDiam.SelectedItems.Count == 0)
            {
                return;
            }



            strId  = this.lstTreeDiam.SelectedItems[0].Text;
            strMin = this.lstTreeDiam.SelectedItems[0].SubItems[1].Text;
            strMax = this.lstTreeDiam.SelectedItems[0].SubItems[2].Text;
            if (strMin.IndexOf(".") < 0)
            {
                strMin += ".0";
            }
            if (strMax.IndexOf(".") < 0)
            {
                strMax += ".0";
            }

            FIA_Biosum_Manager.frmDialog frmTemp = new frmDialog();
            frmTemp.MaximizeBox = false;
            frmTemp.BackColor   = System.Drawing.SystemColors.Control;
            frmTemp.Text        = "Database: Tree Diameter Groups (Edit)";
            frmTemp.Initialize_Plot_Tree_Diam_Edit_User_Control();

            frmTemp.uc_processor_scenario_tree_diam_groups_edit1.txtGroupId         = strId;
            frmTemp.uc_processor_scenario_tree_diam_groups_edit1.txtMaximumDiameter = strMax;
            frmTemp.uc_processor_scenario_tree_diam_groups_edit1.txtMinimumDiameter = strMin;


            frmTemp.Height = 0;
            frmTemp.Width  = 0;
            if (frmTemp.uc_processor_scenario_tree_diam_groups_edit1.Top + frmTemp.uc_processor_scenario_tree_diam_groups_edit1.Height > frmTemp.ClientSize.Height + 2)
            {
                for (int x = 1;; x++)
                {
                    frmTemp.Height = x;
                    if (frmTemp.uc_processor_scenario_tree_diam_groups_edit1.Top +
                        frmTemp.uc_processor_scenario_tree_diam_groups_edit1.Height <
                        frmTemp.ClientSize.Height)
                    {
                        break;
                    }
                }
            }
            if (frmTemp.uc_processor_scenario_tree_diam_groups_edit1.Left + frmTemp.uc_processor_scenario_tree_diam_groups_edit1.Width > frmTemp.ClientSize.Width + 2)
            {
                for (int x = 1;; x++)
                {
                    frmTemp.Width = x;
                    if (frmTemp.uc_processor_scenario_tree_diam_groups_edit1.Left +
                        frmTemp.uc_processor_scenario_tree_diam_groups_edit1.Width <
                        frmTemp.ClientSize.Width)
                    {
                        break;
                    }
                }
            }
            frmTemp.Left            = 0;
            frmTemp.Top             = 0;
            frmTemp.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog;
            frmTemp.StartPosition   = System.Windows.Forms.FormStartPosition.CenterScreen;
            System.Windows.Forms.DialogResult result = frmTemp.ShowDialog();
            if (result == System.Windows.Forms.DialogResult.OK)
            {
                strMax = frmTemp.uc_processor_scenario_tree_diam_groups_edit1.txtMaximumDiameter.Trim();
                //remove the period if it is the last character
                if (strMax.IndexOf(".") == strMax.Length - 1)
                {
                    strMax = strMax.Replace(".", "");
                }
                strMin = frmTemp.uc_processor_scenario_tree_diam_groups_edit1.txtMinimumDiameter.Trim();
                //remove the period if it is the last character
                if (strMin.IndexOf(".") == strMin.Length - 1)
                {
                    strMin = strMin.Replace(".", "");
                }
                this.lstTreeDiam.BeginUpdate();
                this.lstTreeDiam.SelectedItems[0].SubItems[1].Text = strMin;
                this.lstTreeDiam.SelectedItems[0].SubItems[2].Text = strMax;
                this.lstTreeDiam.SelectedItems[0].SubItems[3].Text = strMin + " - " + strMax;
                this.lstTreeDiam.EndUpdate();
                if (this.btnSave.Enabled == false)
                {
                    this.btnSave.Enabled = true;
                }
            }
            frmTemp.Close();
            frmTemp.Dispose();
            frmTemp = null;
        }
        private void btnNew_Click(object sender, System.EventArgs e)
        {
            string strMax = "";
            string strMin = "";
            string strId  = "";
            double dblMin = 0;

            //get the last id if there is one
            if (this.lstTreeDiam.Items.Count > 0)
            {
                strId  = Convert.ToString(Convert.ToInt16(this.lstTreeDiam.Items[this.lstTreeDiam.Items.Count - 1].Text) + 1);
                strMin = this.lstTreeDiam.Items[this.lstTreeDiam.Items.Count - 1].SubItems[2].Text;
                if (strMin.IndexOf(".") < 0)
                {
                    strMin += ".0";
                }

                dblMin = Convert.ToDouble(strMin) + 0.1;
                strMin = Convert.ToString(dblMin);

                strMax = strMin;
                //if (strMin.IndexOf(".") < 0) strMin += ".0";
            }
            else
            {
                strMax = "0.0";
                strMin = "0.0";
                strId  = "1";
            }

            FIA_Biosum_Manager.frmDialog frmTemp = new frmDialog();
            frmTemp.MaximizeBox = false;
            frmTemp.BackColor   = System.Drawing.SystemColors.Control;
            frmTemp.Text        = "Database: Tree Diameter Groups (New)";
            frmTemp.Initialize_Plot_Tree_Diam_Edit_User_Control();

            frmTemp.uc_processor_scenario_tree_diam_groups_edit1.txtGroupId         = strId;
            frmTemp.uc_processor_scenario_tree_diam_groups_edit1.txtMaximumDiameter = strMax;
            frmTemp.uc_processor_scenario_tree_diam_groups_edit1.txtMinimumDiameter = strMin;


            //frmTemp.MdiParent = this;
            //frmTemp.Initialize_Plot_Tree_Diam_User_Control();


            frmTemp.Height = 0;
            frmTemp.Width  = 0;
            if (frmTemp.uc_processor_scenario_tree_diam_groups_edit1.Top + frmTemp.uc_processor_scenario_tree_diam_groups_edit1.Height > frmTemp.ClientSize.Height + 2)
            {
                for (int x = 1;; x++)
                {
                    frmTemp.Height = x;
                    if (frmTemp.uc_processor_scenario_tree_diam_groups_edit1.Top +
                        frmTemp.uc_processor_scenario_tree_diam_groups_edit1.Height <
                        frmTemp.ClientSize.Height)
                    {
                        break;
                    }
                }
            }
            if (frmTemp.uc_processor_scenario_tree_diam_groups_edit1.Left + frmTemp.uc_processor_scenario_tree_diam_groups_edit1.Width > frmTemp.ClientSize.Width + 2)
            {
                for (int x = 1;; x++)
                {
                    frmTemp.Width = x;
                    if (frmTemp.uc_processor_scenario_tree_diam_groups_edit1.Left +
                        frmTemp.uc_processor_scenario_tree_diam_groups_edit1.Width <
                        frmTemp.ClientSize.Width)
                    {
                        break;
                    }
                }
            }
            frmTemp.Left            = 0;
            frmTemp.Top             = 0;
            frmTemp.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog;
            frmTemp.StartPosition   = System.Windows.Forms.FormStartPosition.CenterScreen;
            System.Windows.Forms.DialogResult result = frmTemp.ShowDialog();
            if (result == System.Windows.Forms.DialogResult.OK)
            {
                strMax = frmTemp.uc_processor_scenario_tree_diam_groups_edit1.txtMaximumDiameter.Trim();
                //remove the period if it is the last character
                if (strMax.IndexOf(".") == strMax.Length - 1)
                {
                    strMax = strMax.Replace(".", "");
                }
                strMin = frmTemp.uc_processor_scenario_tree_diam_groups_edit1.txtMinimumDiameter.Trim();
                //remove the period if it is the last character
                if (strMin.IndexOf(".") == strMin.Length - 1)
                {
                    strMin = strMin.Replace(".", "");
                }
                this.lstTreeDiam.BeginUpdate();
                System.Windows.Forms.ListViewItem listItem = new ListViewItem();
                listItem.Text = frmTemp.uc_processor_scenario_tree_diam_groups_edit1.txtGroupId;
                listItem.SubItems.Add(strMin);
                listItem.SubItems.Add(strMax);
                listItem.SubItems.Add(strMin + " - " + strMax);
                this.lstTreeDiam.Items.Add(listItem);
                this.lstTreeDiam.EndUpdate();
                if (this.btnSave.Enabled == false)
                {
                    this.btnSave.Enabled = true;
                }
            }
            frmTemp.Close();
            frmTemp.Dispose();
            frmTemp = null;
        }
        private void btnAnalyze_Click(object sender, EventArgs e)
        {
            List <string> oProjectRootFolders = new List <string>();

            for (int x = 0; x <= lvDatasources.Items.Count - 1; x++)
            {
                string strSyncd = lvDatasources.Items[x].SubItems[COLUMN_SYNCD].Text.Trim();
                if (strSyncd == "No")
                {
                    int    intIndex             = -1;
                    string strProjectRootFolder = "";
                    string strDatasource        = lvDatasources.Items[x].SubItems[COLUMN_DATASOURCE].Text.Trim();
                    string strPath = lvDatasources.Items[x].SubItems[COLUMN_PATH].Text.Trim().ToUpper();
                    if (strDatasource == "Project")
                    {
                        intIndex = strPath.IndexOf(@"\DB", 0);
                        if (intIndex > 0)
                        {
                            strProjectRootFolder = strPath.Substring(0, intIndex + 1);
                        }
                    }
                    else if (strDatasource == "TreatmentOptimizer")
                    {
                        // THIS CONDITION WILL BE MET BY THE 'NA' ROWS THAT ARE LISTED FOR EACH SCENARIO GENERATED FROM THE CORE scenario_core_rule_definitions.mdb\scenario table
                        intIndex = strPath.IndexOf(@"\OPTIMIZER\", 0);
                        if (intIndex > 0)
                        {
                            strProjectRootFolder = strPath.Substring(0, intIndex + 1);
                        }
                    }
                    else if (strDatasource == "Processor")
                    {
                        // THIS CONDITION WILL BE MET BY THE 'NA' ROWS THAT ARE LISTED FOR EACH SCENARIO GENERATED FROM THE PROCESSOR scenario_core_rule_definitions.mdb\scenario table
                        intIndex = strPath.IndexOf(@"\PROCESSOR\", 0);
                        if (intIndex > 0)
                        {
                            strProjectRootFolder = strPath.Substring(0, intIndex + 1);
                        }
                    }
                    if (strProjectRootFolder.Trim().Length > 0)
                    {
                        if ((int)oProjectRootFolders.Where(p => p == strProjectRootFolder).Count() == 0)
                        {
                            oProjectRootFolders.Add(strProjectRootFolder);
                        }
                    }
                }
            }
            if (oProjectRootFolders != null && oProjectRootFolders[0] != null)
            {
                FIA_Biosum_Manager.frmDialog oDlg = new frmDialog();
                oDlg.Text = "FIA Biosum: Scan and Analyze";
                oDlg.uc_select_list_item1.lblTitle.Text   = "Suggested Out-of-Sync Project Root Folder(s)";
                oDlg.uc_select_list_item1.listBox1.Sorted = false;
                oDlg.uc_select_list_item1.lblMsg.Hide();

                oDlg.uc_select_list_item1.loadvalues(oProjectRootFolders);
                oDlg.uc_select_list_item1.Show();

                DialogResult result = oDlg.ShowDialog();
                if (result == DialogResult.OK)
                {
                    if (oDlg.uc_select_list_item1.listBox1.SelectedItems.Count > 0)
                    {
                        this.txtReplace.Text = oDlg.uc_select_list_item1.listBox1.SelectedItems[0].ToString().Trim();
                    }
                }
                oDlg.Dispose();
                oDlg = null;
            }
        }
        private void btnColumnNameEdit_Click(object sender, EventArgs e)
        {
            int y;

            FIA_Biosum_Manager.frmDialog frmTemp = new frmDialog();
            frmTemp.MaximizeBox = false;
            frmTemp.MinimizeBox = false;
            frmTemp.BackColor   = System.Drawing.SystemColors.Control;
            frmTemp.Initialize_Scenario_Harvest_Costs_Column_Edit_Control();


            frmTemp.Height = 0;
            frmTemp.Width  = 0;
            if (frmTemp.Top + frmTemp.uc_scenario_harvest_cost_column_edit1.Height > frmTemp.ClientSize.Height + 2)
            {
                for (y = 1; ; y++)
                {
                    frmTemp.Height = y;
                    if (frmTemp.uc_scenario_harvest_cost_column_edit1.Top +
                        frmTemp.uc_scenario_harvest_cost_column_edit1.Height <
                        frmTemp.ClientSize.Height)
                    {
                        break;
                    }
                }
            }
            if (frmTemp.uc_scenario_harvest_cost_column_edit1.Left + frmTemp.uc_scenario_harvest_cost_column_edit1.Width > frmTemp.ClientSize.Width + 2)
            {
                for (y = 1; ; y++)
                {
                    frmTemp.Width = y;
                    if (frmTemp.uc_scenario_harvest_cost_column_edit1.Left +
                        frmTemp.uc_scenario_harvest_cost_column_edit1.Width <
                        frmTemp.ClientSize.Width)
                    {
                        break;
                    }
                }
            }
            frmTemp.Left = 0;
            frmTemp.Top  = 0;

            frmTemp.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog;
            frmTemp.StartPosition   = System.Windows.Forms.FormStartPosition.CenterScreen;
            frmTemp.uc_scenario_harvest_cost_column_edit1.Dock = System.Windows.Forms.DockStyle.Fill;

            frmTemp.uc_scenario_harvest_cost_column_edit1.EditType = "Edit";


            frmTemp.uc_scenario_harvest_cost_column_edit1.ColumnText        = this.txtColumnName.Text.Trim();
            frmTemp.uc_scenario_harvest_cost_column_edit1.ColumnDescription = this.txtDesc.Text.Trim();
            frmTemp.uc_scenario_harvest_cost_column_edit1.cmbCol.Enabled    = false;
            frmTemp.uc_scenario_harvest_cost_column_edit1.lblEdit.Hide();


            frmTemp.Text = "Edit Harvest Cost Column";
            System.Windows.Forms.DialogResult result = frmTemp.ShowDialog();
            if (result == System.Windows.Forms.DialogResult.OK)
            {
                if (txtDesc.Text.Trim().ToUpper() !=
                    frmTemp.uc_scenario_harvest_cost_column_edit1.ColumnDescription.Trim().ToUpper())
                {
                    ReferenceProcessorScenarioForm.m_bSave = true;
                }

                this.txtDesc.Text = frmTemp.uc_scenario_harvest_cost_column_edit1.ColumnDescription;
            }
            frmTemp.Dispose();
        }
        private void Edit(string strType)
        {
            int y, intIndex, intCount;

            FIA_Biosum_Manager.frmDialog frmTemp = new frmDialog();
            frmTemp.MaximizeBox = false;
            frmTemp.BackColor   = System.Drawing.SystemColors.Control;
            frmTemp.Initialize_Scenario_Harvest_Costs_Column_Edit_Control();
            string strColumnList = "";

            if (this.ReferenceFormRxItem.m_oRxItem.ReferenceHarvestCostColumnCollection != null)
            {
                for (y = 0; y <= this.ReferenceFormRxItem.m_oRxItem.ReferenceHarvestCostColumnCollection.Count - 1; y++)
                {
                    if (this.ReferenceFormRxItem.m_oRxItem.ReferenceHarvestCostColumnCollection.Item(y).Delete == false)
                    {
                        if (this.ReferenceFormRxItem.m_oRxItem.RxId == this.ReferenceFormRxItem.m_oRxItem.ReferenceHarvestCostColumnCollection.Item(y).RxId)
                        {
                            strColumnList = strColumnList + ReferenceFormRxItem.m_oRxItem.ReferenceHarvestCostColumnCollection.Item(y).HarvestCostColumn + ",";
                        }
                    }
                }
                if (strColumnList.Trim().Length > 0)
                {
                    strColumnList = strColumnList.Substring(0, strColumnList.Length - 1);
                }
            }


            frmTemp.Height = 0;
            frmTemp.Width  = 0;
            if (frmTemp.Top + frmTemp.uc_scenario_harvest_cost_column_edit1.Height > frmTemp.ClientSize.Height + 2)
            {
                for (y = 1;; y++)
                {
                    frmTemp.Height = y;
                    if (frmTemp.uc_scenario_harvest_cost_column_edit1.Top +
                        frmTemp.uc_scenario_harvest_cost_column_edit1.Height <
                        frmTemp.ClientSize.Height)
                    {
                        break;
                    }
                }
            }
            if (frmTemp.uc_scenario_harvest_cost_column_edit1.Left + frmTemp.uc_scenario_harvest_cost_column_edit1.Width > frmTemp.ClientSize.Width + 2)
            {
                for (y = 1;; y++)
                {
                    frmTemp.Width = y;
                    if (frmTemp.uc_scenario_harvest_cost_column_edit1.Left +
                        frmTemp.uc_scenario_harvest_cost_column_edit1.Width <
                        frmTemp.ClientSize.Width)
                    {
                        break;
                    }
                }
            }
            frmTemp.Left = 0;
            frmTemp.Top  = 0;

            frmTemp.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog;
            frmTemp.StartPosition   = System.Windows.Forms.FormStartPosition.CenterScreen;
            frmTemp.uc_scenario_harvest_cost_column_edit1.Dock = System.Windows.Forms.DockStyle.Fill;

            frmTemp.uc_scenario_harvest_cost_column_edit1.EditType = strType;

            if (strType.Trim().ToUpper() == "NEW")
            {
                frmTemp.uc_scenario_harvest_cost_column_edit1.ColumnList = strColumnList;
                strColumnList = "";
                for (y = 0; y <= this.lvRxHarvestCostColumns.Items.Count - 1; y++)
                {
                    strColumnList = strColumnList + this.lvRxHarvestCostColumns.Items[y].SubItems[COLUMN_FIELD].Text.Trim() + ",";
                }
                if (strColumnList.Trim().Length > 0)
                {
                    strColumnList = strColumnList.Substring(0, strColumnList.Length - 1);
                }
                frmTemp.uc_scenario_harvest_cost_column_edit1.ColumnText = "";
                frmTemp.uc_scenario_harvest_cost_column_edit1.CurrentSelectedColumnList  = strColumnList;
                frmTemp.uc_scenario_harvest_cost_column_edit1.HarvestCostTableColumnList = this.m_strHarvestTableColumnNameList;
                frmTemp.uc_scenario_harvest_cost_column_edit1.loadvalues();
                frmTemp.uc_scenario_harvest_cost_column_edit1.lblEdit.Show();
            }
            else
            {
                frmTemp.uc_scenario_harvest_cost_column_edit1.ColumnText        = this.lvRxHarvestCostColumns.SelectedItems[0].SubItems[COLUMN_FIELD].Text;
                frmTemp.uc_scenario_harvest_cost_column_edit1.ColumnDescription = this.lvRxHarvestCostColumns.SelectedItems[0].SubItems[COLUMN_DESC].Text;
                frmTemp.uc_scenario_harvest_cost_column_edit1.cmbCol.Enabled    = false;
                frmTemp.uc_scenario_harvest_cost_column_edit1.lblEdit.Hide();
            }

            frmTemp.Text = strType + " Harvest Cost Component";
            System.Windows.Forms.DialogResult result = frmTemp.ShowDialog();
            if (result == System.Windows.Forms.DialogResult.OK)
            {
                if (strType.Trim().ToUpper() == "NEW")
                {
                    if (ReferenceFormRxItem.m_oRxItem.ReferenceHarvestCostColumnCollection == null)
                    {
                        this.ReferenceFormRxItem.m_oRxItem.m_oHarvestCostColumnItem_Collection1 = new RxItemHarvestCostColumnItem_Collection();
                        this.ReferenceFormRxItem.m_oRxItem.ReferenceHarvestCostColumnCollection = this.ReferenceFormRxItem.m_oRxItem.m_oHarvestCostColumnItem_Collection1;
                    }
                    //make sure this item was not previously deleted
                    for (y = 0; y <= this.ReferenceFormRxItem.m_oRxItem.ReferenceHarvestCostColumnCollection.Count - 1; y++)
                    {
                        if (this.ReferenceFormRxItem.m_oRxItem.ReferenceHarvestCostColumnCollection.Item(y).Delete == true)
                        {
                            if (this.ReferenceFormRxItem.m_oRxItem.RxId == this.ReferenceFormRxItem.m_oRxItem.ReferenceHarvestCostColumnCollection.Item(y).RxId&&
                                this.ReferenceFormRxItem.m_oRxItem.ReferenceHarvestCostColumnCollection.Item(y).HarvestCostColumn.Trim().ToUpper() ==
                                frmTemp.uc_scenario_harvest_cost_column_edit1.ColumnText.Trim().ToUpper())
                            {
                                ReferenceFormRxItem.m_oRxItem.ReferenceHarvestCostColumnCollection.Item(y).Delete      = false;
                                ReferenceFormRxItem.m_oRxItem.ReferenceHarvestCostColumnCollection.Item(y).Description =
                                    frmTemp.uc_scenario_harvest_cost_column_edit1.ColumnDescription;
                                break;
                            }
                        }
                    }
                    //new column
                    if (y > this.ReferenceFormRxItem.m_oRxItem.ReferenceHarvestCostColumnCollection.Count - 1)
                    {
                        FIA_Biosum_Manager.RxItemHarvestCostColumnItem oItem = new RxItemHarvestCostColumnItem();
                        oItem.Description       = frmTemp.uc_scenario_harvest_cost_column_edit1.ColumnDescription.Trim();
                        oItem.HarvestCostColumn = frmTemp.uc_scenario_harvest_cost_column_edit1.ColumnText.Trim();
                        oItem.RxId = this.ReferenceFormRxItem.m_oRxItem.RxId;
                        oItem.Add  = true;
                        ReferenceFormRxItem.m_oRxItem.ReferenceHarvestCostColumnCollection.Add(oItem);
                        this.AddItemToList(oItem);
                    }
                }
                else
                {
                    this.lvRxHarvestCostColumns.SelectedItems[0].SubItems[COLUMN_DESC].Text = frmTemp.uc_scenario_harvest_cost_column_edit1.ColumnDescription;

                    for (y = 0; y <= this.ReferenceFormRxItem.m_oRxItem.ReferenceHarvestCostColumnCollection.Count - 1; y++)
                    {
                        if (this.ReferenceFormRxItem.m_oRxItem.ReferenceHarvestCostColumnCollection.Item(y).Delete == false)
                        {
                            if (this.ReferenceFormRxItem.m_oRxItem.RxId == this.ReferenceFormRxItem.m_oRxItem.ReferenceHarvestCostColumnCollection.Item(y).RxId&&
                                this.ReferenceFormRxItem.m_oRxItem.ReferenceHarvestCostColumnCollection.Item(y).HarvestCostColumn.Trim().ToUpper() ==
                                lvRxHarvestCostColumns.SelectedItems[0].SubItems[COLUMN_FIELD].Text.Trim().ToUpper())
                            {
                                ReferenceFormRxItem.m_oRxItem.ReferenceHarvestCostColumnCollection.Item(y).Description =
                                    frmTemp.uc_scenario_harvest_cost_column_edit1.ColumnDescription;
                                break;
                            }
                        }
                    }
                }
            }
            frmTemp.Dispose();
        }