Single Employee Picker Modified for Department permission #23
|
@ -369,7 +369,7 @@ namespace HRM.BO
|
|||
List<SearchEmployee> Find(SearchManager oManager);
|
||||
List<SearchEmployee> FindCordinator(int? id, int? payrollTypeID);
|
||||
List<SearchEmployee> FindEmpCodeName(int payrolltypeid, string code, string name);
|
||||
List<SearchEmployee> FindEmpCodeNameForEmployeePicker(int payrolltypeid, string code, string name);
|
||||
List<SearchEmployee> FindEmpCodeNameForEmployeePicker(int userid, int payrolltypeid, string code, string name);
|
||||
SearchEmployee get(int empid);
|
||||
List<SearchEmployee> GetEmployeeNotYetUser(int payrollTypeID);
|
||||
List<SearchEmployee> GetTeam(int employeeid);
|
||||
|
|
|
@ -246,11 +246,122 @@ END;";
|
|||
"Select %q EmployeeID, EmployeeNo, Name, categoryID, GradeID, LocationID, designationid, DepartmentID From Employee %q Order by %s",
|
||||
top, sqlClause, orderby);
|
||||
}
|
||||
internal static IDataReader SearchForEmployeePicker(TransactionContext tc, int payrollTypeID, string code, string name)
|
||||
internal static IDataReader SearchForEmployeePicker(TransactionContext tc, int userID, int payrollTypeID, string code, string name)
|
||||
{
|
||||
string orderby = "name";
|
||||
string sqlClause = "";
|
||||
string top = "";
|
||||
|
||||
string recurSqlClause = SQLParser.MakeSQL(@"
|
||||
DECLARE @userid INT = %n;
|
||||
DECLARE @payrolltypeid INT = %n;
|
||||
DECLARE @permissionstatus INT = %n;
|
||||
WITH RecursiveCategory AS
|
||||
(
|
||||
SELECT
|
||||
CATEGORYID
|
||||
FROM
|
||||
dbo.CATEGORY
|
||||
WHERE
|
||||
CATEGORYID IN (
|
||||
SELECT REFERENCEID
|
||||
FROM DATAPERMISSION
|
||||
WHERE USERID = @userid
|
||||
AND PAYROLLTYPEID = @payrolltypeid
|
||||
AND PERMISSIONSTATUS = @permissionstatus
|
||||
AND PERMISSIONTYPE = %n
|
||||
)
|
||||
),
|
||||
RecursiveGrade AS
|
||||
(
|
||||
SELECT
|
||||
GRADEID
|
||||
FROM
|
||||
dbo.GRADES
|
||||
WHERE
|
||||
GRADEID IN (
|
||||
SELECT REFERENCEID
|
||||
FROM DATAPERMISSION
|
||||
WHERE USERID = @userid
|
||||
AND PAYROLLTYPEID = @payrolltypeid
|
||||
AND PERMISSIONSTATUS = @permissionstatus
|
||||
AND PERMISSIONTYPE = %n
|
||||
)
|
||||
),
|
||||
RecursiveDepartment AS
|
||||
(
|
||||
SELECT
|
||||
DEPARTMENTID
|
||||
FROM
|
||||
dbo.DEPARTMENT
|
||||
WHERE
|
||||
DEPARTMENTID IN (
|
||||
SELECT REFERENCEID
|
||||
FROM DATAPERMISSION
|
||||
WHERE USERID = @userid
|
||||
AND PAYROLLTYPEID = @payrolltypeid
|
||||
AND PERMISSIONSTATUS = @permissionstatus
|
||||
AND PERMISSIONTYPE = %n
|
||||
)
|
||||
UNION ALL
|
||||
SELECT
|
||||
d.DEPARTMENTID
|
||||
FROM
|
||||
dbo.DEPARTMENT d
|
||||
INNER JOIN
|
||||
RecursiveDepartment rd
|
||||
ON
|
||||
d.PARENTID = rd.DEPARTMENTID
|
||||
),
|
||||
RecursiveLocation AS
|
||||
(
|
||||
SELECT
|
||||
LOCATIONID
|
||||
FROM
|
||||
dbo.LOCATION
|
||||
WHERE
|
||||
LOCATIONID IN (
|
||||
SELECT REFERENCEID
|
||||
FROM DATAPERMISSION
|
||||
WHERE USERID = @userid
|
||||
AND PAYROLLTYPEID = @payrolltypeid
|
||||
AND PERMISSIONSTATUS = @permissionstatus
|
||||
AND PERMISSIONTYPE = %n
|
||||
)
|
||||
UNION ALL
|
||||
SELECT
|
||||
l.LOCATIONID
|
||||
FROM
|
||||
dbo.LOCATION l
|
||||
INNER JOIN
|
||||
RecursiveLocation rl
|
||||
ON
|
||||
l.PARENTID = rl.LOCATIONID
|
||||
)", userID, payrollTypeID, EnumMenuPermissionStatus.Approved, EnumDataPermissionType.Cagtegory, EnumDataPermissionType.Grade, EnumDataPermissionType.Department, EnumDataPermissionType.Location);
|
||||
string recurWhereClause = SQLParser.MakeSQL(@"
|
||||
AND
|
||||
(
|
||||
(
|
||||
EXISTS (SELECT 1 FROM RecursiveCategory)
|
||||
AND CATEGORYID IN (SELECT CATEGORYID FROM RecursiveCategory)
|
||||
)
|
||||
OR
|
||||
(
|
||||
EXISTS (SELECT 1 FROM RecursiveGrade)
|
||||
AND GRADEID IN (SELECT GRADEID FROM RecursiveGrade)
|
||||
)
|
||||
OR
|
||||
(
|
||||
EXISTS (SELECT 1 FROM RecursiveDepartment)
|
||||
AND DEPARTMENTID IN (SELECT DEPARTMENTID FROM RecursiveDepartment)
|
||||
)
|
||||
OR
|
||||
(
|
||||
EXISTS (SELECT 1 FROM RecursiveLocation)
|
||||
AND LOCATIONID IN (SELECT LOCATIONID FROM RecursiveLocation)
|
||||
)
|
||||
)");
|
||||
|
||||
//Previous Code For only Live Employee
|
||||
//sqlClause = SQLParser.TagSQL(sqlClause) + SQLParser.MakeSQL("PayrollTypeID =%n AND Status = %n", payrollTypeID, EnumStatus.Active);
|
||||
|
||||
|
@ -274,10 +385,11 @@ END;";
|
|||
|
||||
if (name != string.Empty)
|
||||
sqlClause = SQLParser.TagSQL(sqlClause) + SQLParser.MakeSQL("Name LIKE %s", ("%" + name + "%"));
|
||||
string finalSQl = SQLParser.MakeSQL(
|
||||
"%q Select %q EmployeeID, EmployeeNo, Name, categoryID, GradeID, LocationID, designationid, DepartmentID From Employee %q %q Order by %s",
|
||||
recurSqlClause, top, sqlClause, recurWhereClause, orderby);
|
||||
|
||||
return tc.ExecuteReader(
|
||||
"Select %q EmployeeID, EmployeeNo, Name, categoryID, GradeID, LocationID, designationid, DepartmentID From Employee %q Order by %s",
|
||||
top, sqlClause, orderby);
|
||||
return tc.ExecuteReader(finalSQl);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
|
|
@ -288,7 +288,7 @@ namespace HRM.DA
|
|||
|
||||
return searchEmployees;
|
||||
}
|
||||
public List<SearchEmployee> FindEmpCodeNameForEmployeePicker(int payrollTypeID, string code, string name)
|
||||
public List<SearchEmployee> FindEmpCodeNameForEmployeePicker(int userID, int payrollTypeID, string code, string name)
|
||||
{
|
||||
List<SearchEmployee> searchEmployees = new List<SearchEmployee>();
|
||||
|
||||
|
@ -297,7 +297,7 @@ namespace HRM.DA
|
|||
{
|
||||
tc = TransactionContext.Begin();
|
||||
|
||||
DataReader dr = new DataReader(SearchEmployeeDA.SearchForEmployeePicker(tc, payrollTypeID, code, name));
|
||||
DataReader dr = new DataReader(SearchEmployeeDA.SearchForEmployeePicker(tc, userID, payrollTypeID, code, name));
|
||||
searchEmployees = this.CreateObjects<SearchEmployee>(dr);
|
||||
//while (dr.Read())
|
||||
//{
|
||||
|
|
|
@ -787,7 +787,7 @@ namespace HRM.UI.Controllers
|
|||
//olist = _serachManager.FindEmpCodeName((int) currentUser.PayrollTypeID, code, name);
|
||||
if(code != "")
|
||||
{
|
||||
List<SearchEmployee> unorderedList = _serachManager.FindEmpCodeNameForEmployeePicker((int)currentUser.PayrollTypeID, code, name);
|
||||
List<SearchEmployee> unorderedList = _serachManager.FindEmpCodeNameForEmployeePicker((int)currentUser.UserID, (int)currentUser.PayrollTypeID, code, name);
|
||||
|
||||
olist = unorderedList
|
||||
.OrderBy(item => item.EmployeeNo != code) // False (0) for priority value, True (1) for others
|
||||
|
@ -795,7 +795,7 @@ namespace HRM.UI.Controllers
|
|||
}
|
||||
else
|
||||
{
|
||||
olist = _serachManager.FindEmpCodeNameForEmployeePicker((int)currentUser.PayrollTypeID, code, name);
|
||||
olist = _serachManager.FindEmpCodeNameForEmployeePicker((int)currentUser.UserID, (int)currentUser.PayrollTypeID, code, name);
|
||||
}
|
||||
|
||||
//List<Grade> grades = new GradeService().Get(EnumStatus.Regardless, (int)currentUser.PayrollTypeID);
|
||||
|
|
Loading…
Reference in New Issue
Block a user