private void addButton_Click(object sender, EventArgs e) { if (ValidInput()) { string[] scheduleValues = new string[7]; for (int i = 0; i < 7; i++) { scheduleValues[i] = scheduleComboBoxes[i].Text; } int id = random.Next(int.MaxValue); bool exists = true; while (exists) { exists = DatabaseWorker.IdExists(id); if (!exists) { DatabaseWorker.tempId = id; DatabaseWorker.AddEmployee(id, nameTextBox.Text, jobTextBox.Text, addressTextBox.Text, phoneTextBox.Text, scheduleValues); } id = random.Next(int.MaxValue); } DialogResult = DialogResult.OK; Close(); } else { PrintErrorMessage(); } }
private void addButton_Click(object sender, EventArgs e) { if (ValidInput()) { string[] attendanceValues = new string[7]; for (int i = 0; i < 7; i++) { attendanceValues[i] = attendanceComboBoxes[i].Text; } int id = random.Next(Int32.MaxValue); bool exists = true; while (exists) { exists = DatabaseWorker.IdExists(id); if (!exists) { DatabaseWorker.tempId = id; DatabaseWorker.AddCustomer(id, nameTextBox.Text, membershipComboBox.SelectedItem.ToString(), phoneTextBox.Text, attendanceValues); } id = random.Next(Int32.MaxValue); } DialogResult = DialogResult.OK; Close(); } else { PrintErrorMessage(); } }
/// <summary> /// Add a new customer in the database. /// </summary> private void AddButton_Click(object sender, EventArgs e) { if (ValidInput()) { string[] attendanceValues = new string[7]; // Get combo box attendance values. for (int i = 0; i < 7; i++) { attendanceValues[i] = attendanceComboBoxes[i].Text; } string name = BuildName(); // Generate a random id. int id = random.Next(Int32.MaxValue); // Used to check whether the id alredy exists in the database. bool exists = true; // Loop until a non-existent id is generated. while (exists) { exists = DatabaseWorker.IdExists(id); if (!exists) { DatabaseWorker.tempId = id; DatabaseWorker.AddCustomer(id, name, membershipComboBox.SelectedItem.ToString(), phoneTextBox.Text, attendanceValues); } // Generate a new id. id = random.Next(Int32.MaxValue); } DialogResult = DialogResult.OK; Close(); } else { PrintErrorMessage(); } }
/// <summary> /// Add a new employee in the database. /// </summary> private void AddButton_Click(object sender, EventArgs e) { if (ValidInput()) { string[] scheduleValues = new string[7]; // Get combo box schedule values. for (int i = 0; i < 7; i++) { scheduleValues[i] = scheduleComboBoxes[i].Text; } string name = BuildName(); string address = BuildAddress(); // Generate a random id. int id = random.Next(int.MaxValue); // Used to check whether the id alredy exists in the database. bool exists = true; // Loop until a non-existent id is generated. while (exists) { exists = DatabaseWorker.IdExists(id); if (!exists) { DatabaseWorker.tempId = id; DatabaseWorker.AddEmployee(id, name, jobTextBox.Text.Trim(' '), address, phoneTextBox.Text, scheduleValues); } id = random.Next(int.MaxValue); } DialogResult = DialogResult.OK; Close(); } else { PrintErrorMessage(); } }