public string addEmployee(Employee employee) { SqlConnection conn = null; SqlTransaction trans = null; string returnString = IdProConstants.SUCCESS; UserDAO userDao = new UserDAO(); EmployeeDao EmployeeDao = new EmployeeDao(); ConnectionDao ConnectionDao = new ConnectionDao(); UserServices userServices = new UserServices(); if (isEmployeeEmailexist(employee.Email.Trim())) { returnString = "Employee Email already Exist in the system"; } // else if (userServices.isUserNameExist(employee.USER.Username)) else if (userServices.isUserNameExist(employee.Username)) { returnString = "UserName already Exit in the system"; } else { try { conn = ConnectionDao.getConnection(); trans = conn.BeginTransaction(); returnString = userDao.addUser(conn, trans, employee.USER); if (IdProConstants.SUCCESS.Equals(returnString)) { returnString = EmployeeDao.addEmployee(conn, trans, employee); } if (IdProConstants.SUCCESS.Equals(returnString)) { trans.Commit(); } else { trans.Rollback(); } } catch (Exception exception) { trans.Rollback(); System.Diagnostics.Trace.WriteLine("[EmployeeServices:addEmployee] Exception " + exception.StackTrace); } finally { ConnectionDao.closeConnection(conn); } } return returnString; }