/// <summary>
        /// This function will populate the checklist boxes with the new data after a load.
        /// </summary>
        /// <param name="data"></param>
        /// <param name="filter"></param>
        public void UpdateFilters(List <string> data, FilterUtils.Filters filter)
        {
            HasFiltersAdded();

            if (!FiltersAdded)
            {
                btn_applyFilters.Enabled  = false;
                btn_clearFilters.Enabled  = false;
                btn_clearSelected.Enabled = false;
            }
            else
            {
                btn_applyFilters.Enabled  = true;
                btn_clearFilters.Enabled  = true;
                btn_clearSelected.Enabled = true;
            }


            if (!FiltersApplied)
            {
                btn_clearFilters.Enabled = false;
            }
            else
            {
                btn_clearFilters.Enabled = true;
            }



            switch ((int)filter)
            {
            case 0:
            case 1:
                break;

            case 2:     // WBS Project
                ChkdListBx_WBSProject.Invoke((MethodInvoker) delegate {
                    ChkdListBx_WBSProject.Items.Clear();
                    ChkdListBx_WBSProject.Items.AddRange(data.ToArray());
                });
                break;

            case 3:     // Material
                ChkdListBx_Material.Invoke((MethodInvoker) delegate {
                    ChkdListBx_Material.Items.Clear();
                    ChkdListBx_Material.Items.AddRange(data.ToArray());
                });
                break;

            case 4:     // Material Group
                ChkdListBx_MaterialGroup.Invoke((MethodInvoker) delegate {
                    ChkdListBx_MaterialGroup.Items.Clear();
                    ChkdListBx_MaterialGroup.Items.AddRange(data.ToArray());
                });
                break;

            case 5:    // Vendor
                ChkdListBx_Vendor.Invoke((MethodInvoker) delegate {
                    ChkdListBx_Vendor.Items.Clear();
                    ChkdListBx_Vendor.Items.AddRange(data.ToArray());
                });
                break;

            case 6:     // Vendor Description
                ChkdListBx_VendorDesc.Invoke((MethodInvoker) delegate {
                    ChkdListBx_VendorDesc.Items.Clear();
                    ChkdListBx_VendorDesc.Items.AddRange(data.ToArray());
                });
                break;

            case 7:     // Purch Group
                ChkdListBx_PurchGroup.Invoke((MethodInvoker) delegate {
                    ChkdListBx_PurchGroup.Items.Clear();
                    ChkdListBx_PurchGroup.Items.AddRange(data.ToArray());
                });
                break;

            case 8:     // IR Supp Name
                ChkdListBx_IRSuppName.Invoke((MethodInvoker) delegate {
                    ChkdListBx_IRSuppName.Items.Clear();
                    ChkdListBx_IRSuppName.Items.AddRange(data.ToArray());
                });
                break;

            case 9:     // Fxd Supp Name
                ChkdListBx_FxdSuppName.Invoke((MethodInvoker) delegate {
                    ChkdListBx_FxdSuppName.Items.Clear();
                    ChkdListBx_FxdSuppName.Items.AddRange(data.ToArray());
                });
                break;

            case 10:     // Dsrd Supp Name
                ChkdListBx_DsrdSuppName.Invoke((MethodInvoker) delegate {
                    ChkdListBx_DsrdSuppName.Items.Clear();
                    ChkdListBx_DsrdSuppName.Items.AddRange(data.ToArray());
                });
                break;

            case 11:     // Commodity Category
                ChkdListBx_CommodityCat.Invoke((MethodInvoker) delegate {
                    ChkdListBx_CommodityCat.Items.Clear();
                    ChkdListBx_CommodityCat.Items.AddRange(data.ToArray());
                });
                break;

            default:
                break;
            }
        }
        /// <summary>
        /// This function will ensure that values that are checked stay checked
        /// after the check boxes are updated and populated with new values.
        /// </summary>
        private void UpdateCheckedItems()
        {
            int index;

            // Material
            if (Filters.FitlerValues.material.Count > 0)
            {
                ChkdListBx_Material.ItemCheck -= ckdListBox_ItemCheck;
                foreach (string str in Filters.FitlerValues.material)
                {
                    index = ChkdListBx_Material.Items.IndexOf(str);
                    if (index >= 0)
                    {
                        if (!ChkdListBx_Material.GetItemChecked(index))
                        {
                            ChkdListBx_Material.SetItemChecked(index, true);
                        }
                    }
                }
                ChkdListBx_Material.ItemCheck += ckdListBox_ItemCheck;
            }


            // Material Group
            if (Filters.FitlerValues.materialGroup.Count > 0)
            {
                ChkdListBx_MaterialGroup.ItemCheck -= ckdListBox_ItemCheck;
                foreach (string str in Filters.FitlerValues.materialGroup)
                {
                    index = ChkdListBx_MaterialGroup.Items.IndexOf(str);
                    if (index >= 0)
                    {
                        if (!ChkdListBx_MaterialGroup.GetItemChecked(index))
                        {
                            ChkdListBx_MaterialGroup.SetItemChecked(index, true);
                        }
                    }
                }
                ChkdListBx_MaterialGroup.ItemCheck += ckdListBox_ItemCheck;
            }


            // Vendor
            if (Filters.FitlerValues.vendor.Count > 0)
            {
                ChkdListBx_Vendor.ItemCheck -= ckdListBox_ItemCheck;
                foreach (string str in Filters.FitlerValues.vendor)
                {
                    index = ChkdListBx_Vendor.Items.IndexOf(str);
                    if (index >= 0)
                    {
                        if (!ChkdListBx_Vendor.GetItemChecked(index))
                        {
                            ChkdListBx_Vendor.SetItemChecked(index, true);
                        }
                    }
                }
                ChkdListBx_Vendor.ItemCheck += ckdListBox_ItemCheck;
            }


            // Vendor Description
            if (Filters.FitlerValues.vendorDesc.Count > 0)
            {
                ChkdListBx_VendorDesc.ItemCheck -= ckdListBox_ItemCheck;
                foreach (string str in Filters.FitlerValues.vendorDesc)
                {
                    index = ChkdListBx_VendorDesc.Items.IndexOf(str);
                    if (index >= 0)
                    {
                        if (!ChkdListBx_VendorDesc.GetItemChecked(index))
                        {
                            ChkdListBx_VendorDesc.SetItemChecked(index, true);
                        }
                    }
                }
                ChkdListBx_VendorDesc.ItemCheck += ckdListBox_ItemCheck;
            }


            // Purch Group
            if (Filters.FitlerValues.purchGroup.Count > 0)
            {
                ChkdListBx_PurchGroup.ItemCheck -= ckdListBox_ItemCheck;
                foreach (string str in Filters.FitlerValues.purchGroup)
                {
                    index = ChkdListBx_PurchGroup.Items.IndexOf(str);
                    if (index >= 0)
                    {
                        if (!ChkdListBx_PurchGroup.GetItemChecked(index))
                        {
                            ChkdListBx_PurchGroup.SetItemChecked(index, true);
                        }
                    }
                }
                ChkdListBx_PurchGroup.ItemCheck += ckdListBox_ItemCheck;
            }


            // IR Supp Name
            if (Filters.FitlerValues.irSuppName.Count > 0)
            {
                ChkdListBx_IRSuppName.ItemCheck -= ckdListBox_ItemCheck;
                foreach (string str in Filters.FitlerValues.irSuppName)
                {
                    index = ChkdListBx_IRSuppName.Items.IndexOf(str);
                    if (index >= 0)
                    {
                        if (!ChkdListBx_IRSuppName.GetItemChecked(index))
                        {
                            ChkdListBx_IRSuppName.SetItemChecked(index, true);
                        }
                    }
                }
                ChkdListBx_IRSuppName.ItemCheck += ckdListBox_ItemCheck;
            }



            // Fxd Supp Name
            if (Filters.FitlerValues.fxdSuppName.Count > 0)
            {
                ChkdListBx_FxdSuppName.ItemCheck -= ckdListBox_ItemCheck;
                foreach (string str in Filters.FitlerValues.fxdSuppName)
                {
                    index = ChkdListBx_FxdSuppName.Items.IndexOf(str);
                    if (index >= 0)
                    {
                        if (!ChkdListBx_FxdSuppName.GetItemChecked(index))
                        {
                            ChkdListBx_FxdSuppName.SetItemChecked(index, true);
                        }
                    }
                }
                ChkdListBx_FxdSuppName.ItemCheck += ckdListBox_ItemCheck;
            }


            // Dsrd Supp Name
            if (Filters.FitlerValues.dsrdSuppName.Count > 0)
            {
                ChkdListBx_DsrdSuppName.ItemCheck -= ckdListBox_ItemCheck;
                foreach (string str in Filters.FitlerValues.dsrdSuppName)
                {
                    index = ChkdListBx_DsrdSuppName.Items.IndexOf(str);
                    if (index >= 0)
                    {
                        if (!ChkdListBx_DsrdSuppName.GetItemChecked(index))
                        {
                            ChkdListBx_DsrdSuppName.SetItemChecked(index, true);
                        }
                    }
                }
                ChkdListBx_DsrdSuppName.ItemCheck += ckdListBox_ItemCheck;
            }


            // Dsrd Supp Name
            if (Filters.FitlerValues.commCategory.Count > 0)
            {
                ChkdListBx_CommodityCat.ItemCheck -= ckdListBox_ItemCheck;
                foreach (string str in Filters.FitlerValues.commCategory)
                {
                    index = ChkdListBx_CommodityCat.Items.IndexOf(str);
                    if (index >= 0)
                    {
                        if (!ChkdListBx_CommodityCat.GetItemChecked(index))
                        {
                            ChkdListBx_CommodityCat.SetItemChecked(index, true);
                        }
                    }
                }
                ChkdListBx_CommodityCat.ItemCheck += ckdListBox_ItemCheck;
            }
        }
        /// <summary>
        /// Any filters that are checked will be unchecked and the filters check lists
        /// will be set back to the normal state.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btn_clearSelected_Click(object sender, EventArgs e)
        {
            foreach (int i in ChkdListBx_Material.CheckedIndices)
            {
                ChkdListBx_Material.ItemCheck -= ckdListBox_ItemCheck;
                ChkdListBx_Material.SetItemCheckState(i, CheckState.Unchecked);
                ChkdListBx_Material.ItemCheck += ckdListBox_ItemCheck;
            }

            foreach (int i in ChkdListBx_MaterialGroup.CheckedIndices)
            {
                ChkdListBx_MaterialGroup.ItemCheck -= ckdListBox_ItemCheck;
                ChkdListBx_MaterialGroup.SetItemCheckState(i, CheckState.Unchecked);
                ChkdListBx_MaterialGroup.ItemCheck += ckdListBox_ItemCheck;
            }

            foreach (int i in ChkdListBx_Vendor.CheckedIndices)
            {
                ChkdListBx_Vendor.ItemCheck -= ckdListBox_ItemCheck;
                ChkdListBx_Vendor.SetItemCheckState(i, CheckState.Unchecked);
                ChkdListBx_Vendor.ItemCheck += ckdListBox_ItemCheck;
            }

            foreach (int i in ChkdListBx_VendorDesc.CheckedIndices)
            {
                ChkdListBx_VendorDesc.ItemCheck -= ckdListBox_ItemCheck;
                ChkdListBx_VendorDesc.SetItemCheckState(i, CheckState.Unchecked);
                ChkdListBx_VendorDesc.ItemCheck += ckdListBox_ItemCheck;
            }

            foreach (int i in ChkdListBx_PurchGroup.CheckedIndices)
            {
                ChkdListBx_PurchGroup.ItemCheck -= ckdListBox_ItemCheck;
                ChkdListBx_PurchGroup.SetItemCheckState(i, CheckState.Unchecked);
                ChkdListBx_PurchGroup.ItemCheck += ckdListBox_ItemCheck;
            }

            foreach (int i in ChkdListBx_IRSuppName.CheckedIndices)
            {
                ChkdListBx_IRSuppName.ItemCheck -= ckdListBox_ItemCheck;
                ChkdListBx_IRSuppName.SetItemCheckState(i, CheckState.Unchecked);
                ChkdListBx_IRSuppName.ItemCheck += ckdListBox_ItemCheck;
            }

            foreach (int i in ChkdListBx_FxdSuppName.CheckedIndices)
            {
                ChkdListBx_FxdSuppName.ItemCheck -= ckdListBox_ItemCheck;
                ChkdListBx_FxdSuppName.SetItemCheckState(i, CheckState.Unchecked);
                ChkdListBx_FxdSuppName.ItemCheck += ckdListBox_ItemCheck;
            }

            foreach (int i in ChkdListBx_DsrdSuppName.CheckedIndices)
            {
                ChkdListBx_DsrdSuppName.ItemCheck -= ckdListBox_ItemCheck;
                ChkdListBx_DsrdSuppName.SetItemCheckState(i, CheckState.Unchecked);
                ChkdListBx_DsrdSuppName.ItemCheck += ckdListBox_ItemCheck;
            }

            foreach (int i in ChkdListBx_CommodityCat.CheckedIndices)
            {
                ChkdListBx_CommodityCat.ItemCheck -= ckdListBox_ItemCheck;
                ChkdListBx_CommodityCat.SetItemCheckState(i, CheckState.Unchecked);
                ChkdListBx_CommodityCat.ItemCheck += ckdListBox_ItemCheck;
            }


            Filters.FitlerValues.Clear();
            Filters.ClbDictionaryValues.Clear();
            filters = string.Empty;
            FilterUtils.LoadFilters(filters);
        }