Esempio n. 1
0
        /// <summary>
        /// Instantiates the employee using employee builer
        /// </summary>
        /// <param name="fields">The fields.</param>
        /// <returns></returns>
        private Employee InstantiateEmployee(String [] fields)
        {
            int    id          = Convert.ToInt32(fields[0]);
            string name        = fields[1],
                   address     = fields[2],
                   phone       = fields[3],
                   email       = fields[4],
                   designation = fields[5],
                   department  = fields[6];
            int hourlyWage     = Convert.ToInt32(fields[7]);

            Employee emp = new Employee.EmployeeBuilder().SetId(id).SetName(name).SetAddress(address).SetPhone(phone).SetEmail(email).SetDepartment(department).SetDesignation(designation).SetHourlyWage(hourlyWage).build();

            return(emp);
        }
Esempio n. 2
0
        /// <summary>
        /// Prepares the employee form by passing instance of an eployee for update
        /// </summary>
        /// <returns>EmployeeForm</returns>
        private EmployeeForm PrepareEmployeeForm()
        {
            int    id          = this.empList[row].Id;
            string name        = this.empList[row].Name;
            string address     = this.empList[row].Address;
            string phone       = this.empList[row].Phone;
            string email       = this.empList[row].Email;
            string designation = this.empList[row].Designation;
            string department  = this.empList[row].Dept;
            int    hourlyWage  = this.empList[row].HourlyWage;

            Employee emp = new Employee.EmployeeBuilder().SetId(id).SetName(name).SetAddress(address).SetPhone(phone).SetEmail(email).SetDepartment(department).SetDesignation(designation).SetHourlyWage(hourlyWage).build();

            EmployeeForm empForm = new EmployeeForm(emp);

            empForm.EmployeeSaved += UpdateRecord;
            return(empForm);
        }
Esempio n. 3
0
 /// <summary>
 /// Updates the record of employee.
 /// New instance is created as updating only the properties did not result in proper update in the datagridview
 /// </summary>
 /// <param name="emp">The emp.</param>
 private void UpdateRecord(Employee emp)
 {
     if (EmployeeIdExists(emp) && this.empList[row].Id != emp.Id)
     {
         MessageBox.Show("Employee id " + emp.Id + " already exists. Ignoring record update");
         return;
     }
     empList[row] =
         new Employee.EmployeeBuilder()
         .SetId(emp.Id).SetName(emp.Name)
         .SetAddress(emp.Address)
         .SetPhone(emp.Phone)
         .SetEmail(emp.Email)
         .SetDepartment(emp.Dept)
         .SetDesignation(emp.Designation)
         .SetHourlyWage(emp.HourlyWage)
         .build();
 }