public static bool IsUniqueEntry(TextBox textBox) { bool success = true; if ("Product Code".Equals(textBox.Tag)) { Product[] products = ProductDB.GetProducts(); if (products != null) { for (int i = 0; i < ProductDB.count; i++) { if (products[i].Code.Equals(int.Parse(textBox.Text))) { MessageBox.Show(textBox.Tag + " already exists, please enter new unique value.", Title); textBox.Clear(); textBox.Focus(); success = false; } } } } if ("Technician ID".Equals(textBox.Tag)) { Technician[] technicians = TechnicianDB.GetTechnicians(); if (technicians != null) { for (int i = 0; i < TechnicianDB.count; i++) { if (technicians[i].ID.Equals(int.Parse(textBox.Text))) { MessageBox.Show(textBox.Tag + " already exists, please enter new unique value.", Title); textBox.Clear(); textBox.Focus(); success = false; } } } } if ("Customer ID".Equals(textBox.Tag)) { Customer[] customers = CustomerDB.GetCustomers(); if (customers != null) { for (int i = 0; i < CustomerDB.count; i++) { if (customers[i].ID.Equals(int.Parse(textBox.Text))) { MessageBox.Show(textBox.Tag + " already exists, please enter new unique value.", Title); textBox.Clear(); textBox.Focus(); success = false; } } } } return(success); }
private void MaintainTechnician_Load(object sender, EventArgs e) { techs = TechnicianDB.GetTechnicians(); if (techs != null) { FillTechnicianListBox(); } }