Merge pull request 'Single Employee Picker Modified for Department permission' (#23) from dev_mashfiq into devqc
Reviewed-on: http://103.197.204.162:3025/CelHRTeam/EchoTex_Payroll/pulls/23
This commit is contained in:
commit
110fc609ac
|
@ -369,7 +369,7 @@ namespace HRM.BO
|
||||||
List<SearchEmployee> Find(SearchManager oManager);
|
List<SearchEmployee> Find(SearchManager oManager);
|
||||||
List<SearchEmployee> FindCordinator(int? id, int? payrollTypeID);
|
List<SearchEmployee> FindCordinator(int? id, int? payrollTypeID);
|
||||||
List<SearchEmployee> FindEmpCodeName(int payrolltypeid, string code, string name);
|
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);
|
SearchEmployee get(int empid);
|
||||||
List<SearchEmployee> GetEmployeeNotYetUser(int payrollTypeID);
|
List<SearchEmployee> GetEmployeeNotYetUser(int payrollTypeID);
|
||||||
List<SearchEmployee> GetTeam(int employeeid);
|
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",
|
"Select %q EmployeeID, EmployeeNo, Name, categoryID, GradeID, LocationID, designationid, DepartmentID From Employee %q Order by %s",
|
||||||
top, sqlClause, orderby);
|
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 orderby = "name";
|
||||||
string sqlClause = "";
|
string sqlClause = "";
|
||||||
string top = "";
|
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
|
//Previous Code For only Live Employee
|
||||||
//sqlClause = SQLParser.TagSQL(sqlClause) + SQLParser.MakeSQL("PayrollTypeID =%n AND Status = %n", payrollTypeID, EnumStatus.Active);
|
//sqlClause = SQLParser.TagSQL(sqlClause) + SQLParser.MakeSQL("PayrollTypeID =%n AND Status = %n", payrollTypeID, EnumStatus.Active);
|
||||||
|
|
||||||
|
@ -274,10 +385,11 @@ END;";
|
||||||
|
|
||||||
if (name != string.Empty)
|
if (name != string.Empty)
|
||||||
sqlClause = SQLParser.TagSQL(sqlClause) + SQLParser.MakeSQL("Name LIKE %s", ("%" + name + "%"));
|
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(
|
return tc.ExecuteReader(finalSQl);
|
||||||
"Select %q EmployeeID, EmployeeNo, Name, categoryID, GradeID, LocationID, designationid, DepartmentID From Employee %q Order by %s",
|
|
||||||
top, sqlClause, orderby);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
|
@ -288,7 +288,7 @@ namespace HRM.DA
|
||||||
|
|
||||||
return searchEmployees;
|
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>();
|
List<SearchEmployee> searchEmployees = new List<SearchEmployee>();
|
||||||
|
|
||||||
|
@ -297,7 +297,7 @@ namespace HRM.DA
|
||||||
{
|
{
|
||||||
tc = TransactionContext.Begin();
|
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);
|
searchEmployees = this.CreateObjects<SearchEmployee>(dr);
|
||||||
//while (dr.Read())
|
//while (dr.Read())
|
||||||
//{
|
//{
|
||||||
|
|
|
@ -787,7 +787,7 @@ namespace HRM.UI.Controllers
|
||||||
//olist = _serachManager.FindEmpCodeName((int) currentUser.PayrollTypeID, code, name);
|
//olist = _serachManager.FindEmpCodeName((int) currentUser.PayrollTypeID, code, name);
|
||||||
if(code != "")
|
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
|
olist = unorderedList
|
||||||
.OrderBy(item => item.EmployeeNo != code) // False (0) for priority value, True (1) for others
|
.OrderBy(item => item.EmployeeNo != code) // False (0) for priority value, True (1) for others
|
||||||
|
@ -795,7 +795,7 @@ namespace HRM.UI.Controllers
|
||||||
}
|
}
|
||||||
else
|
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);
|
//List<Grade> grades = new GradeService().Get(EnumStatus.Regardless, (int)currentUser.PayrollTypeID);
|
||||||
|
|
Loading…
Reference in New Issue
Block a user