/// <summary>
        /// Updates the textbox and checkbox related to the selected price
        /// </summary>
        private void SelectedProductPricesListBox_SelectedIndexChanged(object sender, EventArgs e)
        {
            SalesPriceModel selectedPrice = (SalesPriceModel)SelectedProductPricesListBox.SelectedItem;

            PriceTextBox.Text = selectedPrice == null ? "" : selectedPrice.SalesPrice.ToString();
            IsCurrentlyActivePriceCheckBox.Checked = selectedPrice == null ? false : selectedPrice.CurrentlyActivePrice;;
        }
 /// <summary>
 /// Searches for the current "active price", sets it to false and updates it into the database
 /// </summary>
 public void UncheckPreviousActivePrice(SalesPriceModel currentActivePrice)
 {
     if (currentActivePrice != null)
     {
         currentActivePrice.CurrentlyActivePrice = false;
         GlobalConfig.Connection.UpdateSalesPriceModel(currentActivePrice);
     }
 }
        /// <summary>
        /// Deletes the selected price entry
        /// </summary>
        private void DeletePriceButton_Click(object sender, EventArgs e)
        {
            SalesPriceModel selectedPrice = (SalesPriceModel)SelectedProductPricesListBox.SelectedItem;

            if (selectedPrice != null)
            {
                GlobalConfig.Connection.DeleteSalesPrice(selectedPrice);
                InitializeSelectedProductPriceList((ProductModel)ProductsListBox.SelectedItem);
            }
        }
        /// <summary>
        /// When the selected product changes, in load the prices(related to the selected product) the "SelectedProductPricesListBox" listbox
        /// Displays(by default) the price that has true for "CurrentlyActivePrice" property
        /// </summary>
        private void ProductsListBox_SelectedIndexChanged(object sender, EventArgs e)
        {
            SelectedProductPriceList = InitializeSelectedProductPriceList((ProductModel)ProductsListBox.SelectedItem);
            SalesPriceModel selectedPrice = new SalesPriceModel();

            if (SelectedProductPriceList != null)
            {
                selectedPrice = SelectedProductPriceList.Where(p => p.CurrentlyActivePrice == true).FirstOrDefault();
            }

            PriceTextBox.Text   = selectedPrice == null ? "" : selectedPrice.SalesPrice.ToString();
            lastSelectedProduct = (ProductModel)ProductsListBox.SelectedItem;
            IsCurrentlyActivePriceCheckBox.Checked = selectedPrice == null ? false : selectedPrice.CurrentlyActivePrice;
        }
        /// <summary>
        /// Updates the selected price
        /// </summary>
        private void UpdateProductPriceButton_Click(object sender, EventArgs e)
        {
            ProductModel selectedProduct = (ProductModel)ProductsListBox.SelectedItem;

            if (selectedProduct != null &&
                !RMS_Logic.SalesPriceLogic.CheckIfPriceAlreadyExists(decimal.Parse(PriceTextBox.Text), selectedProduct.Id, IsCurrentlyActivePriceCheckBox.Checked))
            {
                SalesPriceModel newPrice = (SalesPriceModel)SelectedProductPricesListBox.SelectedItem;
                newPrice.SalesPrice           = decimal.Parse(PriceTextBox.Text);
                newPrice.CurrentlyActivePrice = IsCurrentlyActivePriceCheckBox.Checked;

                if (newPrice.CurrentlyActivePrice)
                {
                    RMS_Logic.SalesPriceLogic.UncheckPreviousActivePrice(RMS_Logic.SalesPriceLogic.GetProductActivePrice(selectedProduct.Id));
                }

                GlobalConfig.Connection.UpdateSalesPriceModel(newPrice);
                InitializeSelectedProductPriceList(selectedProduct);
            }
        }
        /// <summary>
        /// Associates a price with the selected product
        /// Creates a Price entry in the database
        /// </summary>
        private void AssociatePriceButton_Click(object sender, EventArgs e)
        {
            ProductModel selectedProduct = (ProductModel)ProductsListBox.SelectedItem;

            if (selectedProduct != null &&
                !RMS_Logic.SalesPriceLogic.CheckIfPriceAlreadyExists(decimal.Parse(PriceTextBox.Text), selectedProduct.Id, IsCurrentlyActivePriceCheckBox.Checked))
            {
                SalesPriceModel newPrice = new SalesPriceModel
                {
                    ProductId            = selectedProduct.Id,
                    SalesPrice           = decimal.Parse(PriceTextBox.Text),
                    CurrentlyActivePrice = IsCurrentlyActivePriceCheckBox.Checked
                };

                if (IsCurrentlyActivePriceCheckBox.Checked)
                {
                    RMS_Logic.SalesPriceLogic.UncheckPreviousActivePrice(RMS_Logic.SalesPriceLogic.GetProductActivePrice(selectedProduct.Id));
                }

                GlobalConfig.Connection.CreateSalesPrice(newPrice);
            }
            ResetForm();
            InitializePriceList();
        }