internal void CreateActivity(string name, string location, string reason, string measurementMethod, Employee measurementEmployee, string insertedMeasurementDate,
            string insertedMeasurementNumber, string frequencyMeasurementType, string expectedResultMin, string expectedResultMax, string failureAction, Employee failureActionEmployee, string productName)
        {
            int frequencyMeasurementNumber = Convert.ToInt32(insertedMeasurementNumber);
            
            DateTime measurementDate = Convert.ToDateTime(insertedMeasurementDate);
            //public Activity(string name, string location, string reason, string measurementMethod, Employee measurementEmployee, DateTime measurementDate, int frequencyMeasurementNumber,
            //string frequencyMeasurementType, double expectedResultMin, double expectedResultMax, string failureAction, string failureActionEmployeeName, double measureMent, string productName)

            Activity newActivity = new Activity(name, location, reason, measurementMethod, measurementEmployee, measurementDate,
                frequencyMeasurementNumber, frequencyMeasurementType, expectedResultMin, expectedResultMax, failureAction, failureActionEmployee, productName);
            dataQualityAssurance.AddNewActivity(newActivity);
        }
Esempio n. 2
0
        public string CreateEmployee(Employee employee)
        {
            int EmailExist = 0;
            try
            {
                SqlCommand sqlcmd = new SqlCommand("checkEmployeeByEmail", conn);
                sqlcmd.CommandType = CommandType.StoredProcedure;
                sqlcmd.Parameters.Add(new SqlParameter("@email", employee.Email));
                conn.Open();
                if (sqlcmd.ExecuteScalar() == null)
                    EmailExist = 0;
                else
                    EmailExist = 1;
                conn.Close();
            }
            catch(SqlException e)
            {
                return e.Message;
            }
            if (EmailExist == 0)
            {


                try
                {
                    SqlCommand sqlcmd = new SqlCommand("createNewEmployee", conn);
                    sqlcmd.CommandType = CommandType.StoredProcedure;
                    sqlcmd.Parameters.Add(new SqlParameter("@email", employee.Email));
                    sqlcmd.Parameters.Add(new SqlParameter("@name", employee.Name));
                    sqlcmd.Parameters.Add(new SqlParameter("@address", employee.Address));
                    sqlcmd.Parameters.Add(new SqlParameter("@employeetitle", employee.Title));
                    sqlcmd.Parameters.Add(new SqlParameter("@employeetype", employee.Type));
                    sqlcmd.Parameters.Add(new SqlParameter("@hoursperweek", employee.WorkHours));
                    sqlcmd.Parameters.Add(new SqlParameter("@fromdate", DateTime.Parse(employee.DateOfEmployment)));
                    conn.Open();
                    sqlcmd.ExecuteNonQuery();
                    conn.Close();
                    return "Employee created!";
                }
                catch (SqlException e)
                {
                    return e.Message;
                }
            } else
            return "Email is already in use";
        }
Esempio n. 3
0
        public Activity(string name, string location, string reason, string measurementMethod, Employee measurementEmployee, DateTime measurementDate, int frequencyMeasurementNumber, string frequencyMeasurementType, string expectedResultMin, string expectedResultMax, string failureAction, Employee failureActionEmployee, string productName)

        {
            Name = name;
            Location = location;
            Reason = reason;
            MeasurementMethod = measurementMethod;
            MeasurementEmployee = measurementEmployee;
            MeasurementDate = measurementDate;
            FrequencyMeasurementNumber = frequencyMeasurementNumber;
            FrequencyMeasurementType = frequencyMeasurementType;
            ExpectedResultMin = Double.Parse(expectedResultMin);
            ExpectedResultMax = Double.Parse(expectedResultMax);
            FailureAction = failureAction;
            FailureActionEmployee = failureActionEmployee;
            ProductName = productName;
        }
Esempio n. 4
0
        public Employee GetEmployeeByEmail(string email)
        {
            try
            {
                conn.Open();
                SqlCommand sqlcmd = new SqlCommand("getEmployeeByEmail", conn);
                sqlcmd.CommandType = CommandType.StoredProcedure;
                sqlcmd.Parameters.Add(new SqlParameter("@email", email));

                SqlDataReader reader = sqlcmd.ExecuteReader();
                Employee employee = new Employee(
                    reader["EmployeeName"].ToString(),
                    reader["EmployeeAddress"].ToString(),
                    email,
                    reader["Shiftname"].ToString(),
                    reader["WorkTitle"].ToString(),
                    int.Parse(reader["WeeklyWorkHours"].ToString()),
                    reader["DateOfEmployment"].ToString());
                return employee;                 
            }
            catch (Exception)
            {
                return null;
            }
            finally
            {
                conn.Close();
            }
        }
Esempio n. 5
0
 public List<Employee> ReadEmployees()
 {
     List<Employee> employees = new List<Employee>();
     try
     {
         conn.Open(); 
         SqlCommand sqlcmd = new SqlCommand("GetAllEmployees", conn);
         sqlcmd.CommandType = CommandType.StoredProcedure;
                    
         DataTable table = new DataTable();
         SqlDataAdapter adapter = new SqlDataAdapter(sqlcmd);
         adapter.Fill(table);
         SqlDataReader reader = sqlcmd.ExecuteReader();
         reader.Read();
         foreach (DataRow row in table.Rows)
         {
             Employee employee = new Employee(
             row["EmployeeName"].ToString(),
             row["EmployeeAddress"].ToString(),
             row["EmployeeEmail"].ToString(),
             row["Shiftname"].ToString(),
             row["WorkTitle"].ToString(),
             int.Parse(row["WeeklyWorkHours"].ToString()),
             row["DateOfEmployment"].ToString().Substring(0, 10),                    
             row["Status"].ToString());
             employees.Add(employee);
         }
         conn.Close();
         return employees;
     }
     catch (Exception e)
     {
         throw e;          
     }
 }
        public List<Employee> ReadEmployeeFromId(int id)
        {
            List<Employee> employees = new List<Employee>();
            try
            {
                if (conn.State != ConnectionState.Open)
                    conn.Open();
                SqlCommand sqlcmd = new SqlCommand("GetEmployeeById", conn);
                sqlcmd.CommandType = CommandType.StoredProcedure;
                sqlcmd.Parameters.Add(new SqlParameter("@idEmployees", id));
                DataTable table = new DataTable();
                SqlDataAdapter adapter = new SqlDataAdapter(sqlcmd);
                adapter.Fill(table);
                SqlDataReader reader = sqlcmd.ExecuteReader();
                reader.Read();

                foreach (DataRow row in table.Rows)
                {
                    Employee employee = new Employee(
                    row["nameUser"].ToString(),
                    row["idEmployees"].ToString(),
                    row["emailUser"].ToString(),
                    "employee",
                    "ProduktionsMedarbejder",
                    int.Parse(row["hoursPerWeek"].ToString()),
                    row["from_date"].ToString().Substring(0, 10),
                    "Well");
                    employee.Id = (int)row["idEmployees"];
                    employees.Add(employee);
                }
                conn.Close();
                return employees;
            }
            catch (SqlException e)
            {
                throw e;
            }
            finally
            {
                conn.Close();
            }
        }
 public string CreateEmployee(string name, string address, string email, string type, string title, string workhours, string dateOfEmployment)
 {
     Employee NewEmp = new Employee(name, address, email, type, title, int.Parse(workhours), dateOfEmployment );
     return data.CreateEmployee(NewEmp);
 }