// ------------Added by Wei Guang Yan---------------- // Method of inserting suplier's name to database public void AddSupplier(string txtAdd) { // Innitialize for messagebox string message; string title = "New Product Insert"; MessageBoxButtons button = MessageBoxButtons.OK; MessageBoxIcon icon; // Generate new supplier Id based on max id in database int id = SuppliersDB.GetMaxId() + 1; // Add new item to database bool flag = SuppliersDB.AddSupplier(id, txtAdd); // Check whether adding excution is successful, and show message if (flag == true) { comboBox2.DataSource = SuppliersDB.GetSuppliers(); comboBox2.DisplayMember = "SupName"; comboBox2.ValueMember = "SupplierId"; comboBox2.SelectedIndex = comboBox2.Items.Count - 1; txtAddItem.Text = ""; message = "The supplier is added successfully!"; icon = MessageBoxIcon.None; } else { message = "Error: Fail to add new supplier!\n Please try again or contact IT supports."; icon = MessageBoxIcon.Error; } MessageBox.Show(message, title, button, icon); }