示例#1
0
        public frmEditEmployee(Employee EmployeeToEdit)
        {
            InitializeComponent();

            txtFirstName.Text = EmployeeToEdit.FirstName;
            txtLastName.Text = EmployeeToEdit.LastName;

            if (EmployeeToEdit.Gender == 'M')
            {
                cmbGender.Text = "Male";
            }
            else if (EmployeeToEdit.Gender == 'F')
            {
                cmbGender.Text = "Female";
            }

            txtPhone.Text = EmployeeToEdit.HomePhone;
            txtMobile.Text = EmployeeToEdit.MobilePhone;
            txtAddress1.Text = EmployeeToEdit.Address.Address1;
            txtCounty.Text = EmployeeToEdit.Address.County;
            txtPostCode.Text = EmployeeToEdit.Address.PostCode;
            txtCity.Text = EmployeeToEdit.Address.City;
            txtEmail.Text = EmployeeToEdit.Email;
            txtEntitledHolidays.Text = EmployeeToEdit.HolidaysEntitled.ToString();
            txtHolidaysTaken.Text = EmployeeToEdit.HolidaysTaken.ToString();
            dtpDOB.Value = EmployeeToEdit.DOB;
            if (EmployeeToEdit.DateFinished != new DateTime(0001, 1, 1, 0, 0, 0))
            {
                dtpLeaveDate.Value = EmployeeToEdit.DateFinished;
            }
            dtpStartDate.Value = EmployeeToEdit.DateStarted;
            dtpPVGDate.Value = EmployeeToEdit.PVGDate;
            txtNINo.Text = EmployeeToEdit.NINo;
            txtSalary.Text = EmployeeToEdit.Salary.ToString();
            txtHours.Text = EmployeeToEdit.WeeksHours.ToString();
        }
示例#2
0
        private Employee constructEmployee()
        {
            Employee createdEmployee = new Employee();
            createdEmployee.NINo = txtNINo.Text;
            createdEmployee.FirstName = txtFirstName.Text;
            createdEmployee.LastName = txtLastName.Text;
            createdEmployee.Gender = cmbGender.Text[0];
            createdEmployee.DOB = dtpDOB.Value;
            createdEmployee.DateStarted = dtpStartDate.Value;
            createdEmployee.DateFinished = dtpLeaveDate.Value;
            createdEmployee.PVGDate = dtpPVGDate.Value;
            createdEmployee.HolidaysEntitled = Convert.ToInt16(txtEntitledHolidays.Text);
            createdEmployee.HolidaysTaken = Convert.ToInt16(txtHolidaysTaken.Text);
            createdEmployee.WeeksHours = Convert.ToInt16(txtHours.Text);
            createdEmployee.Salary = Convert.ToInt16(txtSalary.Text);

            createdEmployee.HomePhone = txtPhone.Text;
            createdEmployee.MobilePhone = txtMobile.Text;
            createdEmployee.Email = txtEmail.Text;

            createdEmployee.Address = constructAddress();

            //EmergencyContact
            return createdEmployee;
        }
示例#3
0
        public Employee selectEmployee(String employeeNINo)
        {
            MySqlConnection connection = OpenConnection();
            if (connection == null)
                return null;

            MySqlCommand selectCommand = new MySqlCommand(null, connection);
            selectCommand.CommandText = @"SELECT * FROM employee
                                        INNER JOIN address ON employee.Home_Address = address.Address_1
                                        INNER JOIN medical_information ON employee.Medical_Information = medical_information.Medical_ID
                                        WHERE National_Insurance_Number = @nino;";
            selectCommand.Parameters.AddWithValue("@nino", employeeNINo);

            Console.WriteLine("Executing: [ " + selectCommand.CommandText + "].");
            selectCommand.Prepare();
            MySqlDataReader employeeReader = selectCommand.ExecuteReader();

            //Package into Employee domain entity object
            Employee newEmployee = new Employee();
            while (employeeReader.Read())
            {
                newEmployee = constructEmployee(employeeReader);
            }
            employeeReader.Close();

            CloseConnection(connection);

            return newEmployee;
        }
示例#4
0
        public bool insertEmployee(Employee employeeToAdd)
        {
            MySqlConnection connection = OpenConnection();
            if (connection == null)
                return false;

            try
            {

                MySqlCommand insertCommand = new MySqlCommand(null, connection);

                // Create and prepare an SQL statement.
                insertCommand.CommandText = @"INSERT INTO employee
                                            VALUES (@nino, @firstname, @lastname, @position, @gender, @datestarted, @datefinished, @pvgdate, @holidaysentitled, @holidaystaken, @hours, @address, @dob, @salary, @homephone, @mobilephone, @email, @training, @medical, @ec);";

                //Fill in prepared statement parameters

                insertCommand.Parameters.AddWithValue("@nino", employeeToAdd.NINo);
                insertCommand.Parameters.AddWithValue("@firstname", employeeToAdd.FirstName);
                insertCommand.Parameters.AddWithValue("@lastname", employeeToAdd.LastName);
                insertCommand.Parameters.AddWithValue("@position", employeeToAdd.Position);
                insertCommand.Parameters.AddWithValue("@gender", employeeToAdd.Gender);
                insertCommand.Parameters.AddWithValue("@datestarted", employeeToAdd.DateStarted);
                insertCommand.Parameters.AddWithValue("@datefinished", employeeToAdd.DateFinished);
                insertCommand.Parameters.AddWithValue("@pvgdate", employeeToAdd.PVGDate);
                insertCommand.Parameters.AddWithValue("@holidaysentitled", employeeToAdd.HolidaysEntitled);
                insertCommand.Parameters.AddWithValue("@holidaystaken", employeeToAdd.HolidaysTaken);
                insertCommand.Parameters.AddWithValue("@hours", employeeToAdd.WeeksHours);
                insertCommand.Parameters.AddWithValue("@address", employeeToAdd.Address.Address1);
                insertCommand.Parameters.AddWithValue("@salary", employeeToAdd.Salary);
                insertCommand.Parameters.AddWithValue("@homephone", employeeToAdd.HomePhone);
                insertCommand.Parameters.AddWithValue("@mobile", employeeToAdd.MobilePhone);
                insertCommand.Parameters.AddWithValue("@email", employeeToAdd.Email);
                insertCommand.Parameters.AddWithValue("@training", employeeToAdd.Training);
                insertCommand.Parameters.AddWithValue("@medical", employeeToAdd.Medical.MedicalID);
                //updateCommand.Parameters.AddWithValue("@ec", employeeToAdd.EmergencyContact.ContactID);

                // Prepare statement
                Console.WriteLine("Executing: [ " + insertCommand.CommandText + "].");
                insertCommand.Prepare();
                insertCommand.ExecuteNonQuery();

                lastEmployeeNINO = employeeToAdd.NINo;

            }
            catch (MySqlException mysqle)
            {
                return false;
            }

            return (CloseConnection(connection)); //Successful or not
        }
示例#5
0
 private Employee constructEmployee(MySqlDataReader staffReader)
 {
     Employee newEmployee = new Employee();
     newEmployee.NINo = staffReader.GetString("National_Insurance_Number");
     newEmployee.FirstName = staffReader.GetString("First_Name");
     newEmployee.LastName = staffReader.GetString("Last_Name");
     newEmployee.Position = staffReader.GetString("Position");
     newEmployee.Gender = staffReader.GetChar("Gender");
     newEmployee.DateStarted = staffReader.GetDateTime("Date_Started");
     newEmployee.DateFinished = SafeGetDateTime(staffReader, "Date_Finished");
     newEmployee.PVGDate = staffReader.GetDateTime("PVG_Date");
     newEmployee.HolidaysEntitled = staffReader.GetInt16("Holidays_Entitled");
     newEmployee.HolidaysTaken = staffReader.GetInt16("Holidays_Taken");
     newEmployee.WeeksHours = staffReader.GetInt16("Hours");
     newEmployee.Address = constructAddress(staffReader);
     newEmployee.DOB = staffReader.GetDateTime("DOB");
     newEmployee.Salary = staffReader.GetDecimal("Salary");
     newEmployee.HomePhone = staffReader.GetString("Home_Phone");
     newEmployee.MobilePhone = staffReader.GetString("Mobile_Phone");
     newEmployee.Email = staffReader.GetString("Email");
     newEmployee.Training = SafeGetString(staffReader, "Training");
     newEmployee.Medical = constructMedical(staffReader);
     //EC...
     return newEmployee;
 }
示例#6
0
        public bool updateEmployee(Employee employeeToUpdate)
        {
            MySqlConnection connection = OpenConnection();
            if (connection == null)
                return false;

            MySqlCommand updateCommand = new MySqlCommand(null, connection);
            updateCommand.CommandText = @"UPDATE parent
                                        SET National_Insurance_Number = @nino, First_Name = @firstname, Last_Name = @lastname, Position = @position, Gender = @gender, Date_Started = @datestarted, Date_Finshed = @datefinished, PVG_Date = @pvgdate, Holidays_Entitled = @holidaysentitled, Holidays_Taken = @holidaystaken, Hours = @hours, Home_Address = @address, DOB = @dob, Salary = @salary, Home_Phone = @homephone, Mobile_Phone = @mobilephone, Email = @email, Training = @training, Medical_Information = @medical, Emergency_Contact = @ec;";

            updateCommand.Parameters.AddWithValue("@nino", employeeToUpdate.NINo);
            updateCommand.Parameters.AddWithValue("@firstname", employeeToUpdate.FirstName);
            updateCommand.Parameters.AddWithValue("@lastname", employeeToUpdate.LastName);
            updateCommand.Parameters.AddWithValue("@position", employeeToUpdate.Position);
            updateCommand.Parameters.AddWithValue("@gender", employeeToUpdate.Gender);
            updateCommand.Parameters.AddWithValue("@datestarted", employeeToUpdate.DateStarted);
            updateCommand.Parameters.AddWithValue("@datefinished", employeeToUpdate.DateFinished);
            updateCommand.Parameters.AddWithValue("@pvgdate", employeeToUpdate.PVGDate);
            updateCommand.Parameters.AddWithValue("@holidaysentitled", employeeToUpdate.HolidaysEntitled);
            updateCommand.Parameters.AddWithValue("@holidaystaken", employeeToUpdate.HolidaysTaken);
            updateCommand.Parameters.AddWithValue("@hours", employeeToUpdate.WeeksHours);
            updateCommand.Parameters.AddWithValue("@address", employeeToUpdate.Address.Address1);
            updateCommand.Parameters.AddWithValue("@salary", employeeToUpdate.Salary);
            updateCommand.Parameters.AddWithValue("@homephone", employeeToUpdate.HomePhone);
            updateCommand.Parameters.AddWithValue("@mobile", employeeToUpdate.MobilePhone);
            updateCommand.Parameters.AddWithValue("@email", employeeToUpdate.Email);
            updateCommand.Parameters.AddWithValue("@training", employeeToUpdate.Training);
            updateCommand.Parameters.AddWithValue("@medical", employeeToUpdate.Medical.MedicalID);
            //updateCommand.Parameters.AddWithValue("@ec", employeeToUpdate.EmergencyContact.ContactID);

            // Call Prepare after setting the Commandtext and Parameters.
            Console.WriteLine("Executing: [ " + updateCommand.CommandText + "].");
            updateCommand.Prepare();
            updateCommand.ExecuteNonQuery();

            return (CloseConnection(connection));
        }
示例#7
0
 public frmEmployeeReport(Employee employeeToDisplay)
 {
     InitializeComponent();
     this.employee = employeeToDisplay;
 }