Exemplo n.º 1
0
        /**
         * @fn  void InsertEmployee(Employee employee);
         *
         * @brief   inserts new employee into database
         *
         * @return  void
         */
        void InsertEmployee(Employee employee)
        {
            conn.Open();
            SqlCommand cmd = null;

            switch (employee.GetEmployeeType())
            {

                case "fulltime":
                    cmd = new SqlCommand("INSERT INTO Employee (firstName, lastName, socialInsuranceNumber, dateOfBirth, isValid, isActive)" +
                                        "VALUES (" + employee.GetFirstName() + ", " + employee.GetLastName() + ", " + employee.GetSin() + ", " + employee.GetDateOfBirth() + "0, 0");
                    int employeeID = GetEmployeeID();
                    SqlCommand getId = new SqlCommand();
                    cmd = new SqlCommand("INSERT INTO FullTimeEmployee (employeeID, dateOfHire, dateOfTermination, salary)" +
                                        "VALUES (" + employeeID + ((FulltimeEmployee)employee).GetDateOfHire() + ", " + ((FulltimeEmployee)employee).GetDateOfTermination() + ", " + ((FulltimeEmployee)employee).GetSalary() + ")");
                    break;
                case "parttime":

                    break;
                case "seasonal":
                    break;
                case "contract":
                    break;
            }

            cmd.Connection = conn;
            cmd.ExecuteNonQuery();
            conn.Close();
        }