Employee Picker search modified
This commit is contained in:
parent
b3aaed7af4
commit
a0474a12b3
|
@ -369,6 +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);
|
||||
SearchEmployee get(int empid);
|
||||
List<SearchEmployee> GetEmployeeNotYetUser(int payrollTypeID);
|
||||
List<SearchEmployee> GetTeam(int employeeid);
|
||||
|
|
|
@ -231,11 +231,8 @@ END;";
|
|||
{
|
||||
string orderby = "name";
|
||||
string sqlClause = "";
|
||||
//Previous Code For only Live Employee
|
||||
//sqlClause = SQLParser.TagSQL(sqlClause) + SQLParser.MakeSQL("PayrollTypeID =%n AND Status = %n", payrollTypeID, EnumStatus.Active);
|
||||
|
||||
//New Code For live And Waitiong for join Employee
|
||||
sqlClause = SQLParser.TagSQL(sqlClause) + SQLParser.MakeSQL("PayrollTypeID =%n AND Status = %n OR Status = %n", payrollTypeID, EnumEmployeeStatus.Live, EnumEmployeeStatus.Waitingforjoin);
|
||||
string top = "";
|
||||
sqlClause = SQLParser.TagSQL(sqlClause) + SQLParser.MakeSQL("PayrollTypeID =%n AND Status = %n", payrollTypeID, EnumStatus.Active);
|
||||
if (code != string.Empty)
|
||||
{
|
||||
sqlClause = SQLParser.TagSQL(sqlClause) + SQLParser.MakeSQL("EmployeeNo LIKE %s", ("%" + code + "%"));
|
||||
|
@ -246,8 +243,41 @@ END;";
|
|||
sqlClause = SQLParser.TagSQL(sqlClause) + SQLParser.MakeSQL("Name LIKE %s", ("%" + name + "%"));
|
||||
|
||||
return tc.ExecuteReader(
|
||||
"Select EmployeeID, EmployeeNo, Name, categoryID, GradeID, LocationID, designationid, DepartmentID From Employee %q Order by %s",
|
||||
sqlClause, orderby);
|
||||
"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)
|
||||
{
|
||||
string orderby = "name";
|
||||
string sqlClause = "";
|
||||
string top = "";
|
||||
//Previous Code For only Live Employee
|
||||
//sqlClause = SQLParser.TagSQL(sqlClause) + SQLParser.MakeSQL("PayrollTypeID =%n AND Status = %n", payrollTypeID, EnumStatus.Active);
|
||||
|
||||
//New Code For live And Waitiong for join Employee
|
||||
sqlClause = SQLParser.TagSQL(sqlClause) + SQLParser.MakeSQL("PayrollTypeID =%n AND (Status = %n OR Status = %n)", payrollTypeID, EnumEmployeeStatus.Live, EnumEmployeeStatus.Waitingforjoin);
|
||||
if (code != string.Empty)
|
||||
{
|
||||
//Previous with suggestion
|
||||
//sqlClause = SQLParser.TagSQL(sqlClause) + SQLParser.MakeSQL("EmployeeNo LIKE %s", ("%" + code + "%"));
|
||||
//orderby = "EmployeeNo";
|
||||
|
||||
//Using TOP
|
||||
sqlClause = SQLParser.TagSQL(sqlClause) + SQLParser.MakeSQL("EmployeeNo LIKE %s", ( code + "%"));
|
||||
orderby = "EmployeeNo";
|
||||
top = "TOP 50";
|
||||
|
||||
//Without suggestion
|
||||
//sqlClause = SQLParser.TagSQL(sqlClause) + SQLParser.MakeSQL("EmployeeNo = %s", code );
|
||||
//orderby = "EmployeeNo";
|
||||
}
|
||||
|
||||
if (name != string.Empty)
|
||||
sqlClause = SQLParser.TagSQL(sqlClause) + SQLParser.MakeSQL("Name LIKE %s", ("%" + name + "%"));
|
||||
|
||||
return tc.ExecuteReader(
|
||||
"Select %q EmployeeID, EmployeeNo, Name, categoryID, GradeID, LocationID, designationid, DepartmentID From Employee %q Order by %s",
|
||||
top, sqlClause, orderby);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
|
|
@ -288,6 +288,43 @@ namespace HRM.DA
|
|||
|
||||
return searchEmployees;
|
||||
}
|
||||
public List<SearchEmployee> FindEmpCodeNameForEmployeePicker(int payrollTypeID, string code, string name)
|
||||
{
|
||||
List<SearchEmployee> searchEmployees = new List<SearchEmployee>();
|
||||
|
||||
TransactionContext tc = null;
|
||||
try
|
||||
{
|
||||
tc = TransactionContext.Begin();
|
||||
|
||||
DataReader dr = new DataReader(SearchEmployeeDA.SearchForEmployeePicker(tc, payrollTypeID, code, name));
|
||||
searchEmployees = this.CreateObjects<SearchEmployee>(dr);
|
||||
//while (dr.Read())
|
||||
//{
|
||||
// SearchEmployee item = new SearchEmployee();
|
||||
// item.Name = dr.GetString("name");
|
||||
// item.EmployeeNo = dr.GetString("employeeNo");
|
||||
|
||||
// searchEmployees.Add(item);
|
||||
//}
|
||||
dr.Close();
|
||||
tc.End();
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
#region Handle Exception
|
||||
|
||||
if (tc != null)
|
||||
tc.HandleError();
|
||||
ExceptionLog.Write(e);
|
||||
|
||||
throw new ServiceException(e.Message, e);
|
||||
|
||||
#endregion
|
||||
}
|
||||
|
||||
return searchEmployees;
|
||||
}
|
||||
|
||||
|
||||
public List<SearchEmployee> GetEmployeeNotYetUser(int payrollTypeID)
|
||||
|
|
|
@ -99,6 +99,13 @@ export class EmployeeServices {
|
|||
return this.apiService.httpGet<SearchEmployee[]>('/Employee/getEmpCodeName' + '/' + ncode + '/' + nname);
|
||||
}
|
||||
|
||||
getEmpCodeNameForEmployeePickerInput(code?: string, name?: string) {
|
||||
let nname = this.apiService.getApiDefaultData(name);
|
||||
let ncode = this.apiService.getApiDefaultData(code);
|
||||
|
||||
return this.apiService.httpGet<SearchEmployee[]>('/Employee/getEmpCodeNameForEmployeePickerInput' + '/' + ncode + '/' + nname);
|
||||
}
|
||||
|
||||
getEmployees() {
|
||||
return this.apiService.httpGet(this.apiService.base_url + 'getemployees');
|
||||
}
|
||||
|
|
|
@ -260,7 +260,8 @@ export class EmployeePickerComponent implements OnInit {
|
|||
];
|
||||
public loadData(): void {
|
||||
this.gridView = {
|
||||
data: orderBy(this.data.slice(this.skip, this.skip + this.pageSize), this.sort),
|
||||
// data: orderBy(this.data.slice(this.skip, this.skip + this.pageSize), this.sort),
|
||||
data: this.data.slice(this.skip, this.skip + this.pageSize),
|
||||
total: this.data.length,
|
||||
};
|
||||
this.selectedItems = [];
|
||||
|
@ -438,13 +439,12 @@ export class EmployeePickerComponent implements OnInit {
|
|||
}
|
||||
|
||||
handleFilter(value) {
|
||||
debugger
|
||||
const str: string = value;
|
||||
if (value.length === 0 || this.empCodeNameList === undefined) {
|
||||
this.empCodeNameList = [];
|
||||
this.empCodeNameListSource = [];
|
||||
}
|
||||
if (str !== '' && str.length > 2) {
|
||||
if (str !== '') {
|
||||
this.empCodeNameList = [];
|
||||
/*if (this.empCodeNameList.length === 0) {*/
|
||||
let code = '';
|
||||
|
@ -455,7 +455,8 @@ export class EmployeePickerComponent implements OnInit {
|
|||
name = value;
|
||||
}
|
||||
this.loadingEmployee = true;
|
||||
this.empSrvc.getEmpCodeName(code, name)
|
||||
// this.empSrvc.getEmpCodeName(code, name)
|
||||
this.empSrvc.getEmpCodeNameForEmployeePickerInput(code, name)
|
||||
.subscribe(
|
||||
(resp: any) => {
|
||||
this.searchEmployees = resp;
|
||||
|
|
|
@ -133,8 +133,11 @@ namespace HRM.UI.Controllers
|
|||
omanager.checkDataPermission = currentUser.hasDataPermission;
|
||||
omanager.userid = currentUser.UserID;
|
||||
|
||||
List<SearchEmployee> unOrderedList = _serachManager.Find(omanager);
|
||||
olist = unOrderedList
|
||||
.OrderBy(num => num.EmployeeNo.Length) // Order by length (smallest to largest)
|
||||
.ThenBy(num => Convert.ToInt32(num.EmployeeNo)).ToList();
|
||||
|
||||
olist = _serachManager.Find(omanager);
|
||||
//omanager.checkDataPermission = false;
|
||||
#region data permission
|
||||
//List<DataPermission> datapermissions = new DataPermissionService().Get(currentUser.UserID,
|
||||
|
@ -771,6 +774,53 @@ namespace HRM.UI.Controllers
|
|||
return Ok(olist);
|
||||
}
|
||||
|
||||
[HttpGet("getEmpCodeNameForEmployeePickerInput/{code}/{name}")]
|
||||
public ActionResult getEmpCodeNameForEmployeePicker(string code, string name)
|
||||
{
|
||||
code = GlobalFunctions.GetApiDefaultData(code);
|
||||
name = GlobalFunctions.GetApiDefaultData(name);
|
||||
|
||||
CurrentUser currentUser = CurrentUser.GetCurrentUser(HttpContext.User);
|
||||
List<SearchEmployee> olist = new List<SearchEmployee>();
|
||||
try
|
||||
{
|
||||
//olist = _serachManager.FindEmpCodeName((int) currentUser.PayrollTypeID, code, name);
|
||||
if(code != "")
|
||||
{
|
||||
List<SearchEmployee> unorderedList = _serachManager.FindEmpCodeNameForEmployeePicker((int)currentUser.PayrollTypeID, code, name);
|
||||
|
||||
olist = unorderedList
|
||||
.OrderBy(item => item.EmployeeNo != code) // False (0) for priority value, True (1) for others
|
||||
.ThenBy(item => item.EmployeeNo).ToList();
|
||||
}
|
||||
else
|
||||
{
|
||||
olist = _serachManager.FindEmpCodeNameForEmployeePicker((int)currentUser.PayrollTypeID, code, name);
|
||||
}
|
||||
|
||||
//List<Grade> grades = new GradeService().Get(EnumStatus.Regardless, (int)currentUser.PayrollTypeID);
|
||||
//List<Designation> designations = new DesignationService().Get(EnumStatus.Regardless, (int)currentUser.PayrollTypeID);
|
||||
//List<Department> departments = new DepartmentService().Get(EnumStatus.Regardless, (int)currentUser.PayrollTypeID);
|
||||
//olist.ForEach(x=>
|
||||
//{
|
||||
// var grd = grades.FirstOrDefault(d => d.ID == x.GradeID);
|
||||
// if(grd != null) x.gradeName = grd.Name;
|
||||
|
||||
// var designation = designations.FirstOrDefault(d => d.ID == x.designationID);
|
||||
// if (designation != null) x.designationName = designation.Name;
|
||||
// var department = departments.FirstOrDefault(d => d.ID == x.DepartmentID);
|
||||
// if (department != null) x.departmentName = department.Name;
|
||||
//}); // Secondary ordering (alphabetical)
|
||||
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
return StatusCode(StatusCodes.Status500InternalServerError, ex.Message);
|
||||
}
|
||||
|
||||
return Ok(olist);
|
||||
}
|
||||
|
||||
[HttpGet("getEmployeeAttachments/{empId}")]
|
||||
public ActionResult GetEmployeeAttachments(int empId)
|
||||
{
|
||||
|
|
Loading…
Reference in New Issue
Block a user