private void Addbtn_Click(object sender, EventArgs e) { string category = comboBox1.Text; mDatabaseController = new DatabaseController(); List <CategoryTable> cats = mDatabaseController.GetCategory(); for (int i = 0; i < cats.Count; i++) { if (cats[i].type.ToLower() == category.ToLower()) { MessageBox.Show("The database already contains '" + category + "' and blocked the duplicate entry.", "Duplicate Object Blocked"); return; } } bool valid = true; if (null == category || "" == category) { valid = false; } if (valid) { Submit(category); this.Close(); } else { MessageBox.Show("Data Error"); } }
public AddCategoryForm() { InitializeComponent(); connection.ConnectionString = @"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=N:\Receiving and current inventory\Inventory.mdb; Persist Security Info=False;"; mDatabaseController = new DatabaseController(); List <CategoryTable> cats = mDatabaseController.GetCategory(); FillCombo(cats); }
private void FillCategory() { categorycmb.Items.Clear(); DatabaseController dc = new DatabaseController(); List <CategoryTable> categories = dc.GetCategory(); for (int i = 0; i < categories.Count; i++) { categorycmb.Items.Add(categories[i].type); } }