public Employee EmployeeObject(Employee empId, Employee fname, Employee lname, Employee email) { Employee emp = new Employee(empId); Console.WriteLine(emp.ToStringFname(fname)); Console.WriteLine(emp.ToStringLname(lname)); Console.WriteLine(emp.ToStringEmail(email)); //emp.fname = fname; //emp.lname = lname; //emp.email = email; return emp; }
// method to return employee by empId public List<Employee> ReadEmp(Employee empId) { Employee emp; SqlDataReader reader = null; List<Employee> empList = new List<Employee>(); try { dbConn.Open(); SqlCommand command = new SqlCommand(("SELECT (@empId) FROM CinemaPerson"), dbConn); command.Parameters.Add("@empId", SqlDbType.VarChar).Value = "%" + empId + "%"; reader = command.ExecuteReader(); while (reader.Read()) { emp = new Employee((Employee)reader["empId"]); //if (reader["fname" + "lname"] != null) //{ // emp.fname = (Employee)reader["fname"]; // emp.lname = (Employee)reader["lname"]; //} //if (reader["email"] != null) //{ // emp.email = (Employee)reader["email"]; //} empList.Add(emp); } } catch (Exception) { throw; } finally { if (reader != null) { reader.Close(); } if (dbConn != null) { dbConn.Close(); } } return empList; }
//Method to insert Employee. Takes empNo, fname, lname and email as patameters - though only a empNo is needed. // 0 = default state. 1 = success. -1 = error. Perhaps should implement more usefull errorhandling. //(See SQLException class on msdn) public int InsertEmp(Employee emp) { int result = 0; try { dbConn.Open(); SqlCommand command = new SqlCommand("INSERT INTO CinemaEmployee VALUES (@empEmpNo, @empFname, @empLname, @empEmail)", dbConn); command.CommandType = CommandType.Text; command.Parameters.Add("@empEmpNo", SqlDbType.VarChar).Value = emp.empId; command.Parameters.Add("@empFname", SqlDbType.Text).Value = emp.fname; command.Parameters.Add("@empLname", SqlDbType.Text).Value = emp.lname; command.Parameters.Add("@empEmail", SqlDbType.Text).Value = emp.email; result = command.ExecuteNonQuery(); } catch (SqlException) { result = -1; } finally { if (dbConn != null) { dbConn.Close(); } } return result; }
public int InsertEmployee(Employee emp) { return pctrlh.InsertEmp(emp); }
public int InsertEmp(Employee emp) { return pDB.InsertEmp(emp); }
internal string ToStringLname(Employee lname) { throw new NotImplementedException(); }
internal string ToStringEmail(Employee email) { throw new NotImplementedException(); }
public Employee(Employee employee) { // TODO: Complete member initialization this.employee = employee; }
// method to return employee by empId public List<Employee> ReadEmp(int empId) { Employee emp = null; SqlDataReader reader = null; List<Employee> empList = new List<Employee>(); try { dbConn.Open(); SqlCommand command = new SqlCommand(("SELECT * FROM CinemaEmployee WHERE (@empId) = (empId)"), dbConn); command.Parameters.Add("@empId", SqlDbType.VarChar).Value = empId; reader = command.ExecuteReader(); while (reader.Read()) { emp = new Employee((int)reader["empId"], (Person)reader["empFname"], (Person)reader["empLname"], (Person)reader["empEmail"]); empList.Add(emp); } } catch (Exception) { throw; } finally { reader.Close(); dbConn.Close(); } return empList; }
//Method to insert Employee. Takes empNo, fname, lname and email as patameters - though only a empNo is needed. // 0 = default state. 1 = success. -1 = error. Perhaps should implement more usefull errorhandling. //(See SQLException class on msdn) public int InsertEmp(Employee emp) { int result = 0; try { dbConn.Open(); SqlCommand command = new SqlCommand(("INSERT INTO CinemaEmployee (empId, empFname, empLname, empEmail) VALUES ((@empId), (@empFname), (@empLname), (@empEmail))"), dbConn); command.Parameters.Add("@empEmpNo", SqlDbType.Int).Value = emp.empId; command.Parameters.Add("@empFname", SqlDbType.VarChar).Value = emp.fname; command.Parameters.Add("@empLname", SqlDbType.VarChar).Value = emp.lname; command.Parameters.Add("@empEmail", SqlDbType.VarChar).Value = emp.email; result = command.ExecuteNonQuery(); } catch (SqlException) { throw; } finally { dbConn.Close(); } return result; }
public List<Employee> ReadEmp(Employee empId) { return pDB.ReadEmp(empId); }