// Button event handler for the creating clients private void btnCreateClient_Click(object sender, EventArgs e) { clientClick = true; managerClick = false; workerClick = false; FormControllerClass.activatePerson(this); FormControllerClass.activateClient(this); FormControllerClass.deactivateEmployee(this); FormControllerClass.deactivateManager(this); FormControllerClass.deactivateWorker(this); }
// Button event handler for Edit/Update button // Validation is done as well as displaying data for the person with matching ID private void btnEditUpdate_Click(object sender, EventArgs e) { if (newValidator.IsValidID(txtControlSearchID.Text) == false) { MessageBox.Show("Invalid ID"); return; } FormControllerClass.clear(Globals.newForm); bool foundID = false; foreach (PersonClass personObject in personList.getPersonList()) { if (txtControlSearchID.Text == personObject.personID) { foundID = true; } } if (foundID == false) { MessageBox.Show("ID not found inside serializable file."); return; } int id = 0; string name = ""; DateTime birthDate = DateTime.Today; string type = ""; string title = ""; decimal salary = 0; decimal bonus = 0; decimal hourlyPay = 0; bool isPerson = false; bool isClient = false; bool isEmployee = false; bool isManager = false; bool isWorker = false; db.Select(Convert.ToInt32(txtControlSearchID.Text), ref id, ref name, ref birthDate, ref type, ref title, ref salary, ref bonus, ref hourlyPay, ref isPerson, ref isClient, ref isEmployee, ref isManager, ref isWorker); if (isPerson == true) { FormControllerClass.enableDisplay(Globals.newForm); txtControlPersonID.Text = Convert.ToString(id); txtControlPersonName.Text = name; txtControlPersonBirthDate.Text = birthDate.ToString("MM/dd/yyyy"); } if (isPerson == false) { MessageBox.Show("Not found inside database."); return; } if (isClient == true) { FormControllerClass.activateClient(Globals.newForm); txtControlClientType.Text = type; } if (isEmployee == true) { FormControllerClass.activateEmployee(Globals.newForm); txtControlEmployeeJobTitle.Text = title; } if (isManager == true) { FormControllerClass.activateManager(Globals.newForm); txtControlManagerSalary.Text = Convert.ToString(salary); txtControlManagerBonus.Text = Convert.ToString(bonus); } if (isWorker == true) { FormControllerClass.activateWorker(Globals.newForm); txtControlWorkerHourlyPay.Text = Convert.ToString(hourlyPay); } MessageBox.Show("Update Button Clicked"); findDisplayClick = false; editUpdateClick = true; deleteClick = false; FormControllerClass.deactivateAddButtons(this); }