//double Id, double type, string first, string full, string last, double wage = 0.0, double rate = 0.0, double sales = 0.0 public void updateEmployee(double Id, double type, string full, string first, string last, double wage = 0.0, double hours = 0.0, double rate = 0.0, double sales = 0.0) { if (type == 0) { //double Id, double type, double rate, double hours, string full, string first, string last Hourly employee = new Hourly(Id, type, rate, hours, full, first, last); empData[Id.ToString()] = employee; } else if (type == 1) { //public Salary(double Id, double type, double salary, string full, string first, string last) : base(Id, type, full, first, last) Salary employee = new Salary(Id, type, wage, full, first, last); empData[Id.ToString()] = employee; } else if (type == 2) { //public Sales(double Id, double type, double salary, double _commision, double sales, string full, string first, string last) : base(Id, type, salary, full, first, last) Sales employee = new Sales(Id, type, wage, rate, sales, full, first, last); empData[Id.ToString()] = employee; } else { //public Contract(double Id, double type, double wage, string full, string first, string last) : base(Id, type, full,first,last) Contract employee = new Contract(Id, type, wage, full, first, last); empData[Id.ToString()] = employee; } }//end updateEmployee
private void btnSave_Click(object sender, EventArgs e) { //catching our random employee ID number and parsing it. double.TryParse(lblDisplayEmpID.Text, out double id); try { switch (typeofEmployee) { case "Hourly": Hourly hourlyEmp = new Hourly(id, 0, Convert.ToDouble(txtPayType.Text), Convert.ToDouble(txtHoursWorked.Text), txtFName.Text + " " + txtLName.Text, txtFName.Text, txtLName.Text); BusinessRules.Instance.addEmployee(id.ToString(), hourlyEmp); break; case "Salary": Salary salaryEmp = new Salary(id, 1, Convert.ToDouble(txtPayType.Text), txtFName.Text + " " + txtLName.Text, txtFName.Text, txtLName.Text); BusinessRules.Instance.addEmployee(id.ToString(), salaryEmp); break; case "Sales": Sales salesEmp = new Sales(id, 2, Convert.ToDouble(txtPayType.Text), Convert.ToDouble(txtCommision.Text), Convert.ToDouble(txtHoursWorked.Text), txtFName.Text + " " + txtLName.Text, txtFName.Text, txtLName.Text); BusinessRules.Instance.addEmployee(id.ToString(), salesEmp); break; case "Contract": Contract contractEmp = new Contract(id, 3, Convert.ToDouble(txtPayType.Text), txtFName.Text + " " + txtLName.Text, txtFName.Text, txtLName.Text); BusinessRules.Instance.addEmployee(id.ToString(), contractEmp); break; default: break; } lblError.Text = " "; } catch (FormatException error) { lblError.Text = "Some Pay type, hours worked, or other number value was not valid." + error; txtPayType.Focus(); } catch (OverflowException error) { lblError.Text = "Some Pay type, hours worked, or other number value was not valid." + error; txtPayType.Focus(); } MainForm mainForm = (MainForm)Owner; mainForm.updateEmpDisplayList(); //mainForm.ShowDialog(); //close this entry form this.Close(); }//end btSave_click