static void Main() { Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); Form1 form1 = new Form1(); BusinessRules.employeeList.Clear(); Hourly temp = new Hourly("AA5", "Cheryl", "Kirk", "Cheryl Kirk", 3.98, 4); BusinessRules.AddEmployee(form1, temp); Hourly temp2 = new Hourly("BG6", "Hayao", "Miyazaki", "Hayao Miyazaki", 7.6, 8.7); BusinessRules.AddEmployee(form1, temp2); Hourly temp3 = new Hourly("HE7", "Richard", "Marcus", "Richard Marcus", 8.56, 2); BusinessRules.AddEmployee(form1, temp3); Contract hey = new Contract("7H6", "Michael", "Jackson", "Michael Jackson", 18); BusinessRules.AddEmployee(form1, hey); Contract hey2 = new Contract("L-1337", "John", "Chief", "John Chief", 5); BusinessRules.AddEmployee(form1, hey2); Contract hey3 = new Contract("E64", "Mario", "Mario", "Mario Mario", 92); BusinessRules.AddEmployee(form1, hey3); Salary sup = new Salary("HAMBURGER", "Phil", "Hartman", "Phil Hartman", 7.896); BusinessRules.AddEmployee(form1, sup); Salary sup2 = new Salary("BACON", "George", "Costanza", "George Costanza", 82); BusinessRules.AddEmployee(form1, sup2); Salary sup3 = new Salary("EGGS", "Gordon", "Freeman", "Gordon Freeman", 11); BusinessRules.AddEmployee(form1, sup3); Sales bro = new Sales("EMPLOYEE_ID", "David", "Lynch", "David Lynch", 4, 5.86, 387); BusinessRules.AddEmployee(form1, bro); Sales bro2 = new Sales("HELLO", "George", "Lucas", "George Lucas", 3.2, 5, 3); BusinessRules.AddEmployee(form1, bro2); Sales bro3 = new Sales("HEY", "Martin", "Scorsese", "Martin Scorsese", 4.1, 5.6, 87); BusinessRules.AddEmployee(form1, bro3); BusinessRules.AddEmployee(form1, null); Course course1 = new Course("CS1400", "Fundamentals of Programming", 3, "Basic programming skills"); BusinessRules.courseList.Add(course1.courseID, course1); Course course2 = new Course("CS1410", "Object Oriented Programming", 3, "Intro to object-oriented concepts"); BusinessRules.courseList.Add(course2.courseID, course2); Course course3 = new Course("CS3260", "C# Software Development", 3, "Introduces C# and .NET"); BusinessRules.courseList.Add(course3.courseID, course3); Application.Run(form1); }
static void Main() { Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); Form1 form1 = new Form1(); BusinessRules.employeeList.Clear(); Hourly temp = new Hourly("AA5", "Cheryl", "Kirk", "Cheryl Kirk", 3.98, 4); BusinessRules.AddEmployee(form1, temp); Contract hey = new Contract("L-1337", "John", "Chief", "John Chief", 5); BusinessRules.AddEmployee(form1, hey); Salary sup = new Salary("HAMBURGER", "Phil", "Hartman", "Phil Hartman", 7.896); BusinessRules.AddEmployee(form1, sup); Sales bro = new Sales("EMPLOYEE_ID", "David", "Lynch", "David Lynch", 4, 5.86, 387); BusinessRules.AddEmployee(form1, bro); BusinessRules.AddEmployee(form1, null); Application.Run(form1); }
/// <summary> /// Creates a new employee object from data that has been entered into the forms /// </summary> /// <returns>Returns the employee object or a null reference</returns> public Employee createEmployee() { bool ifBegin = validateText(); if (ifBegin) { Employee emp; string firstN = textBox1.Text; string lastN = textBox2.Text; Object selectedItem = comboBox1.SelectedItem; string type = selectedItem.ToString(); char a = firstN[0]; char b = lastN[0]; string id = a + b + "-"; Random random = new Random(); int randomNumber = random.Next(0, 1000); id = id + randomNumber; string fullN = firstN + " " + lastN; if (type == "Hourly") { double rate = Double.Parse(textBox4.Text); double worked = Double.Parse(textBox5.Text); Hourly temp = new Hourly(id, firstN, lastN, fullN, rate, worked); emp = temp; Employee.empCounter++; return(temp); } else if (type == "Salary") { double monthly = Double.Parse(textBox4.Text); Salary temp = new Salary(id, firstN, lastN, fullN, monthly); emp = temp; Employee.empCounter++; return(temp); } else if (type == "Sales") { double monthly = Double.Parse(textBox4.Text); double comm = Double.Parse(textBox5.Text); double gross = Double.Parse(textBox6.Text); Sales temp = new Sales(id, firstN, lastN, fullN, monthly, comm, gross); emp = temp; Employee.empCounter++; return(temp); } else if (type == "Contract") { double wage = Double.Parse(textBox4.Text); Contract temp = new Contract(id, firstN, lastN, fullN, wage); emp = temp; Employee.empCounter++; return(temp); } Employee.empCounter++; return(null); } else { Employee.empCounter++; return(null); } }
/// <summary> /// List View selection event, that checks to see if another item has been selected into the list view to change what Employee's data to display /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void listView1_SelectedIndexChanged(object sender, EventArgs e) { errorProvider1.SetError(labelError, null); if (listView1.SelectedItems.Count == 0) { return; } if (listView1.SelectedItems[0].Text.Contains("BLANK")) { textBox1.Text = "NULL"; textBox2.Text = "NULL"; textBox3.Text = listView1.SelectedItems[0].Text; textBox4.Text = ""; textBox5.Text = ""; textBox6.Text = ""; textBox4.Visible = false; label6.Visible = false; textBox5.Visible = false; label7.Visible = false; textBox6.Visible = false; label8.Visible = false; comboBox1.SelectedIndex = -1; } else { foreach (KeyValuePair <string, Employee> worker in BusinessRules.employeeList) { try { if (worker.Value.fullName == listView1.SelectedItems[0].Text) { Employee emp = worker.Value; textBox1.Text = emp.firstName; textBox2.Text = emp.lastName; textBox3.Text = emp.empId; if (emp.empType == "Hourly") { Hourly temp = (Hourly)emp; textBox4.Visible = true; label6.Visible = true; textBox5.Visible = true; label7.Visible = true; textBox6.Visible = false; label8.Visible = false; textBox4.Text = temp.hourlyRate.ToString(); textBox5.Text = temp.hoursWorked.ToString(); comboBox1.SelectedItem = "Hourly"; } else if (emp.empType == "Salary") { Salary temp = (Salary)emp; textBox4.Visible = true; label6.Visible = true; textBox5.Visible = false; label7.Visible = false; textBox6.Visible = false; label8.Visible = false; textBox4.Text = temp.monthlySalary.ToString(); comboBox1.SelectedItem = "Salary"; } else if (emp.empType == "Sales") { Sales temp = (Sales)emp; textBox4.Visible = true; label6.Visible = true; textBox5.Visible = true; label7.Visible = true; textBox6.Visible = true; label8.Visible = true; textBox4.Text = temp.monthlySalary.ToString(); textBox5.Text = temp.commission.ToString(); textBox6.Text = temp.grossSales.ToString(); comboBox1.SelectedItem = "Sales"; } else if (emp.empType == "Contract") { Contract temp = (Contract)emp; textBox4.Visible = true; label6.Visible = true; textBox5.Visible = false; label7.Visible = false; textBox6.Visible = false; label8.Visible = false; textBox4.Text = temp.contractWage.ToString(); comboBox1.SelectedItem = "Contract"; } } } catch (NullReferenceException) { continue; } } } }