Ejemplo n.º 1
0
        public Employee getEmployeeByNo(int no)
        {
            Employee result = null;

            using (SqlCommand cmd = new SqlCommand("select * from employee where employeeNo = " + no, DatabaseContext.Connection))
            {
                using (SqlDataReader reader = cmd.ExecuteReader())
                {
                    while (reader.Read())
                    {
                        result = new Employee { EmployeeNo = Convert.ToInt32(reader["EmployeeNo"]), Title = reader["Title"].ToString(), FirstName = reader["FirstName"].ToString(), LastName = reader["LastName"].ToString(), Role = reader["Role"].ToString() };
                    }
                }
            }

            return result;
        }
Ejemplo n.º 2
0
        public Employee getPasswordByNo(int user)
        {
            Employee result = null;

            using (SqlCommand cmd = new SqlCommand("select password from employee where employeeno=" + user, DatabaseContext.Connection))
            {
                using (SqlDataReader reader = cmd.ExecuteReader())
                {
                    while (reader.Read())
                    {
                        result = new Employee { Password = reader["Password"].ToString() };
                    }
                }
            }

            return result;
        }
Ejemplo n.º 3
0
        private void updateEmployee()
        {
            Employee anEmployee = new Employee
            {
                EmployeeNo = Int32.Parse(tbAdminEmployeeNo.Text),
                Title = cbAdminEmployeeRole.Text.ToString(),
                FirstName = tbAdminEmployeeFirstName.Text.ToString(),
                LastName = tbAdminEmployeeLastName.Text.ToString(),
                Role = cbAdminEmployeeRole.Text.ToString(),
                Password = Tools.createHash(tbAdminEmployeePassword.Text.ToString())
            };

            context.EmployeeService.updateEmployee(anEmployee);
        }
Ejemplo n.º 4
0
 public void updateEmployee(Employee anEmployee)
 {
     sqlStatement = "update employee set title=" + "'" + anEmployee.Title + "'" + ",FirstName=" + "'" + anEmployee.FirstName + "',Lastname='" + anEmployee.LastName + "', Role='" + anEmployee.Role;
     if (anEmployee.Password.Length >= 0)
         sqlStatement += " ',Password='******' where employeeno=" + anEmployee.EmployeeNo + ";";
     using (SqlCommand cmd = DatabaseContext.Connection.CreateCommand())
     {
         cmd.CommandText = sqlStatement;
         cmd.ExecuteNonQuery();
     }
 }
Ejemplo n.º 5
0
 public void updateEmployee(Employee anEmployee)
 {
     context.EmployeeRepository.updateEmployee(anEmployee);
 }