private void fillSaleDGandProductDG()
        {
            DB.resetConnString();
            productsDG.Items.Clear();
            salesHistoryDG.Items.Clear();
            listView.Items.Clear();
            deleteSelected.IsEnabled = false;
            adjustQuantity.IsEnabled = false;

            if (productModel.SelectedIndex == -1)
            {
                return;
            }

            // for product and barocde datagrid
            product = ProductTableData.getProductByModel(productModel.SelectedItem.ToString());
            Barcode[] barcodes = ProductTableData.getBarcodesByPID(product.ID);

            if (product.Unique_Barcode.StartsWith("Y"))
            {
                deleteSelected.IsEnabled = true;
            }
            else
            {
                adjustQuantity.IsEnabled = true;
            }

            foreach (var item in barcodes)
            {
                if (premitBarcodeinListView(item.Barcode_Serial) == true)
                {
                    listView.Items.Add(new ListViewItems(listView.Items.Count + 1, item.Barcode_Serial, item.Color, item.Date.ToString()));
                }
            }

            productsDG.Items.Add(product);

            //for sales table
            List <Customer_Sale> customer_Sale_List = Customer_SaleTableData.getCustomer_SalebyMatchingProduct(product);

            foreach (var item in customer_Sale_List)
            {
                if (item.Sale == null)
                {
                    MessageBox.Show("Error showing this item. ");
                    continue;
                }
                SalesHistoryDataGrid salesHis;
                if (item.Gifts.Count == 0)
                {
                    salesHis = new SalesHistoryDataGrid(item, "");
                }
                else
                {
                    salesHis = new SalesHistoryDataGrid(item, item.Gifts.First().Barcode);
                }

                salesHistoryDG.Items.Add(salesHis);
            }
        }
        private void ProductModel_ComboBox_TextChanged(object sender, TextChangedEventArgs e)
        {
            if (productModel.SelectedIndex != -1)
            {
                product = ProductTableData.getProductByModel(productModel.Text);

                unitPrice.Text            = product.Unit_Price.ToString();
                sellingPrice.Text         = product.Selling_Price.ToString();
                quantityAvailable.Content = product.Quantity_Available;
                description.Text          = product.Des;

                if (product.Unique_Barcode.Contains("NY"))
                {
                    sameBarcode.IsChecked = true;
                }
                else if (product.Unique_Barcode.Contains("Y"))
                {
                    uniqBarcode.IsChecked = true;
                }
                else if (product.Unique_Barcode.Contains("N"))
                {
                    noBarcode.IsChecked = true;
                }
            }
            else
            {
                unitPrice.Text            = "";
                sellingPrice.Text         = "";
                quantityAvailable.Content = 0;
                quantity.Text             = "";
                description.Text          = "";
            }
        }
        private void sameBarcode_Checked(object sender, RoutedEventArgs e)
        {
            Product pro = ProductTableData.getProductByModel(productModel.Text);

            Barcode[] barcodeList = ProductTableData.getBarcodesByPID(pro.ID);
            listView.Items.Clear();
            if (barcodeList.Count() == 1)
            {
                listView.Items.Add(new ListViewItems(1, barcodeList[0].Barcode_Serial, barcodeList[0].Color));
                barcodeSerial.IsEnabled  = false;
                color.IsEnabled          = false;
                barcodeSerial.Background = new SolidColorBrush(Colors.LightBlue);
                listView.IsEnabled       = false;
                clearAll.IsEnabled       = false;
                Add_Color.IsEnabled      = false;
            }
        }