public DataTable check()
        {
            ItemDatabaseHelper it = new ItemDatabaseHelper();

            return(it.SelectItemsByCategory(ItemCategory));
        }
Ejemplo n.º 2
0
        private void TextBoxSearchBar_KeyUp(object sender, KeyEventArgs e)
        {
            try
            {
                if (String.IsNullOrWhiteSpace(TextBoxSearchBar.Text) == false)
                {
                    if (ComboBoxFilterSection.SelectedItem.ToString() == "Item")
                    {
                        switch (ComboBoxItemFilter.SelectedItem.ToString())
                        {
                        case "Item Name":
                            DatagridViewSearchItem.DataSource = DatabaseHelper.SelectItemsByName(TextBoxSearchBar.Text);
                            break;

                        case "Item Category":
                            DatagridViewSearchItem.DataSource = DatabaseHelper.SelectItemsByCategory(TextBoxSearchBar.Text);
                            break;

                        case "Item Code":
                            DatagridViewSearchItem.DataSource = DatabaseHelper.SelectItemsByCode(Convert.ToInt32(TextBoxSearchBar.Text));
                            break;

                        case "Item Brand":
                            DatagridViewSearchItem.DataSource = DatabaseHelper.SelectItemsByBrand(TextBoxSearchBar.Text);
                            break;
                        }
                    }
                    else if (ComboBoxFilterSection.SelectedItem.ToString() == "Supplier")
                    {
                        switch (ComboBoxSupplierFilter.SelectedItem.ToString())
                        {
                        case "Supplier Name":
                            DatagridViewSearchItem.DataSource = SupplierDatabaseHelper.SelectSupplierByName(TextBoxSearchBar.Text);
                            break;

                        case "Supplier Code":
                            DatagridViewSearchItem.DataSource = SupplierDatabaseHelper.SelectSupplierByCode(Convert.ToInt32(TextBoxSearchBar.Text));
                            break;

                        case "Supplier City":
                            DatagridViewSearchItem.DataSource = SupplierDatabaseHelper.SelectSupplierByCity(TextBoxSearchBar.Text);
                            break;

                        case "Supplier Address":
                            DatagridViewSearchItem.DataSource = SupplierDatabaseHelper.SelectSupplierByAddress(TextBoxSearchBar.Text);
                            break;
                        }
                    }
                }
                else
                {
                    DatagridViewSearchItem.DataSource = null;
                }
            }
            catch (FormatException)
            {
                MessageBox.Show("Please enter correct input!", "Bad input", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
            }
            catch (Exception)
            {
                MessageBox.Show("Error, please try again!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }