/// <summary> /// Get list of Employee Id /// </summary> public static GetEmployeeId[] GetAllEmployeeId(string ConnectionString) { var con = new SqlConnection(ConnectionString); try { using (var cmd = new SqlCommand("select EmployeeId from EmployeeLeaveRegister", con)) { con.Open(); var dr = cmd.ExecuteReader(); var totalEmployeeIndex = 0; while (dr.Read()) { totalEmployeeIndex += 1; } con.Close(); var totalEmployeeIds = new GetEmployeeId[totalEmployeeIndex]; con.Open(); var employees = cmd.ExecuteReader(); var i = 0; while (employees.Read()) { var employeeId = new GetEmployeeId { EmployeeId = employees["EmployeeId"].ToString(), StatusText = "Success" }; totalEmployeeIds[i] = employeeId; i += 1; } con.Close(); return totalEmployeeIds; } } catch (Exception) { var totalEmployeesIds = new GetEmployeeId[1]; totalEmployeesIds[0].StatusText = "Failed"; return totalEmployeesIds; } }
public GetEmployeeId[] EditEmployeeAttendance(string SessionKey, string SessionValue) { var employeeIds = new GetEmployeeId[1]; var empId = new GetEmployeeId {StatusText = "Session out! please login again"}; employeeIds[0] = empId; SessionKey = LeaveRegisterUtils.DecryptPassword(SessionKey); SessionValue = LeaveRegisterUtils.DecryptPassword(SessionValue); if (!DataBaseUtils.IsEmployeeLoggedIn(ConnectionString, SessionKey, SessionValue)) { return employeeIds; } var employeeId = DataBaseUtils.GetEmployeeId(ConnectionString, SessionKey); if (!DataBaseUtils.IsAdminEmployee(ConnectionString, employeeId)) { empId.StatusText = "Employee Id can be display only <b> admin user</b>"; employeeIds[0] = empId; return employeeIds; } return DataBaseUtils.GetAllEmployeeId(ConnectionString); }