public static string CallMgmtRole(string cgi) { CryptoJS objcryptoJS = new CryptoJS(); string AuthUserId = objcryptoJS.AES_decrypt(HttpUtility.UrlEncode(cgi), AppConstants.secretKey, AppConstants.initVec).ToString(); List <clsUserRole> lstURole = new List <clsUserRole>(); lstURole = UserRoleDAL.SelectDynamicUserRole("UserRoleId = " + AuthUserId + "", "UserRoleId"); if (lstURole != null) { if (lstURole.Count > 0) { if (lstURole[0].IsActive == 0) { lstURole[0].IsActive = 1; } else { lstURole[0].IsActive = 0; } if (!UserRoleDAL.UpdateUserRole(lstURole[0])) { } } } return("MDE_AddEmp.aspx?mdeacct=active"); }
/// <summary> /// 根据用户FID获取已授权的ROLE集合 /// </summary> /// <param name="userFid"></param> /// <returns></returns> public List <UserRoleInfo> GetRolesByUser(Guid userFid, string textOrder, int pageIndex, int pageRow , out int dataCount) { dataCount = new UserRoleDAL().GetCounts("and [USER_FID] = '" + userFid + "' and [VALID_FLAG] = 1"); ///用户角色关系数据 List <UserRoleInfo> list = new UserRoleDAL().GetListByPage("and [USER_FID] = '" + userFid + "' and [VALID_FLAG] = 1", textOrder, pageIndex, pageRow); ///角色用户例外条件数据 List <UserRoleRangeAuthInfo> roleuserconditionlist = new UserRoleRangeAuthDAL().GetList("and [USER_FID] = '" + userFid + "' and [VALID_FLAG] = 1 ", string.Empty); ///例外条件基础数据 List <RangeAuthConditionInfo> userroleconditionlist = new RangeAuthConditionDAL().GetList("and [VALID_FLAG] = 1", string.Empty); foreach (var info in list) { for (int i = 1; i <= 20; i++) { if (i > userroleconditionlist.Count) { break; } List <UserRoleRangeAuthInfo> roleuserconditions = roleuserconditionlist.Where(d => d.UserFid.GetValueOrDefault() == info.Fid.GetValueOrDefault() && d.ConditionFid.GetValueOrDefault() == userroleconditionlist[i - 1].Fid.GetValueOrDefault()).ToList(); if (roleuserconditions.Count == 0) { continue; } info.GetType().GetProperty("ExtendField" + i).SetValue(info, string.Join(",", roleuserconditions.Select(d => d.ConditionContext).ToArray()), null); } } return(list); }
public BaseItemRes <InitDataInfo> Test() { var userDAL = new UserDAL(); var lstUser = userDAL.AsQueryable().ToList(); var roleDAL = new RoleDAL(); var lstRole = roleDAL.AsQueryable().ToList(); var authorityDAL = new AuthorityDAL(); var lstAuthority = authorityDAL.AsQueryable().ToList(); var roleAuthorityDAL = new RoleAuthorityDAL(); var lstRoleAuthority = roleAuthorityDAL.AsQueryable().ToList(); var userRoleDAL = new UserRoleDAL(); var lstUserRole = userRoleDAL.AsQueryable().ToList(); var initData = new InitDataInfo() { Users = lstUser, Roles = lstRole, Authoritys = lstAuthority, RoleAuthoritys = lstRoleAuthority, UserRoles = lstUserRole }; return(BaseItemRes <InitDataInfo> .Ok(initData)); }
/// <summary> /// /// </summary> /// <param name="id"></param> /// <param name="modifyDate"></param> /// <param name="modifyUser"></param> /// <returns></returns> public bool LogicDeleteInfo(long id, string modifyUser) { ///未被用户继承的角色可以进行删除,即TS_SYS_USER_ROLE无对应数据 int cnt = new UserRoleDAL().GetCounts("[ROLE_FID] in (select [FID] from dbo.[TS_SYS_ROLE] with(nolock) where [ID] = " + id + " and [VALID_FLAG] = 1)"); if (cnt > 0) { throw new Exception("Err_:MC:0x00000268"); } return(dal.LogicDelete(id, modifyUser) > 0 ? true : false); }
private List <Guid> GetUserRoleFids(long userId) { Guid userFid = dal.GetFid(userId); if (userFid == Guid.Empty) { return(new List <Guid>()); } List <Guid> roleFids = new UserRoleDAL().GetFids(userFid); return(roleFids); }
public static bool IsInstructor(int UserAuthId) { bool isValid = false; List <clsUserRole> lstURole = new List <clsUserRole>(); lstURole = UserRoleDAL.SelectDynamicUserRole("(AuthorizedUserId = " + UserAuthId + ") and (RoleId = 3)", "UserRoleId"); if (lstURole != null) { if (lstURole.Count > 0) { isValid = true; } } return(isValid); }
public List <UserRoleInfo> GetUserRoleList(Guid userRoleFid, Guid roleFid) { UserRoleDAL userRoleDal = new UserRoleDAL(); List <UserRoleInfo> userRoleList = userRoleDal.GetUserRoleList(userRoleFid, roleFid); var userFid = userRoleList.FirstOrDefault().UserFid; //List<RoleUserConditionInfo> roleConditionList = new RoleUserConditionDAL().GetList("and [USER_FID] = '" + userFid + "' and [ROLE_FID] = '" + roleFid + "' and [VALID_FLAG] <> 0 ", string.Empty); //List<UserRoleConditionInfo> userroleConditionList = new UserRoleConditionDAL().GetList("and [VALID_FLAG] <> 0", "[EXTEND_FIELD_SEQ]"); //foreach (var info in userRoleList) //{ // for (int i = 0; i < userroleConditionList.Count; i++) // { // var roleuserconditioninfo = roleConditionList.FirstOrDefault(d => d.ExtendFieldSeq == (i + 1)); // if (roleuserconditioninfo == null) continue; // switch (i) // { // case 0: info.ExtendField1 = roleuserconditioninfo.ConditionContext; break; // case 1: info.ExtendField2 = roleuserconditioninfo.ConditionContext; break; // case 2: info.ExtendField3 = roleuserconditioninfo.ConditionContext; break; // case 3: info.ExtendField4 = roleuserconditioninfo.ConditionContext; break; // case 4: info.ExtendField5 = roleuserconditioninfo.ConditionContext; break; // case 5: info.ExtendField6 = roleuserconditioninfo.ConditionContext; break; // case 6: info.ExtendField7 = roleuserconditioninfo.ConditionContext; break; // case 7: info.ExtendField8 = roleuserconditioninfo.ConditionContext; break; // case 8: info.ExtendField9 = roleuserconditioninfo.ConditionContext; break; // case 9: info.ExtendField10 = roleuserconditioninfo.ConditionContext; break; // case 10: info.ExtendField11 = roleuserconditioninfo.ConditionContext; break; // case 11: info.ExtendField12 = roleuserconditioninfo.ConditionContext; break; // case 12: info.ExtendField13 = roleuserconditioninfo.ConditionContext; break; // case 13: info.ExtendField14 = roleuserconditioninfo.ConditionContext; break; // case 14: info.ExtendField15 = roleuserconditioninfo.ConditionContext; break; // case 15: info.ExtendField16 = roleuserconditioninfo.ConditionContext; break; // case 16: info.ExtendField17 = roleuserconditioninfo.ConditionContext; break; // case 17: info.ExtendField18 = roleuserconditioninfo.ConditionContext; break; // case 18: info.ExtendField19 = roleuserconditioninfo.ConditionContext; break; // case 19: info.ExtendField20 = roleuserconditioninfo.ConditionContext; break; // } // } //} return(userRoleList); }
public static string Disapprove(string cgi) { CryptoJS objcryptoJS = new CryptoJS(); string strURL = string.Empty; string ContractorAppId = string.Empty; try { ContractorAppId = cgi.ToString() == null ? string.Empty : cgi.ToString(); if (GlobalMethods.ValueIsNull(ContractorAppId).Length > 0) { ContractorAppId = objcryptoJS.AES_decrypt(HttpUtility.UrlEncode(cgi), AppConstants.secretKey, AppConstants.initVec).ToString(); } List <clsTrainingProvider> objSPCont = new List <clsTrainingProvider>(); objSPCont = TrainingProviderDAL.SelectDynamicTrainingProvider("TPId = " + ContractorAppId + "", "TPId"); if (objSPCont != null) { objSPCont[0].IsActive = 0; if (TrainingProviderDAL.UpdateTrainingProvider(objSPCont[0])) { List <clsUserRole> lstURole = new List <clsUserRole>(); lstURole = UserRoleDAL.SelectDynamicUserRole("RoleId = 2 and AuthorizedUserId = " + objSPCont[0].CreatedBy + "", "UserRoleId"); if (lstURole != null) { if (lstURole.Count > 0) { // It should get only one record per ROle. if (!UserRoleDAL.DeleteUserRole(lstURole[0].UserRoleId)) { } } } } } } catch (Exception) { ErrorHandler.ErrorPage(); } return("MDE_TPAppView.aspx?tpapps=active&cgi=" + cgi + ""); }
/// <summary> /// 用户启用 /// </summary> /// <param name="id"></param> /// <param name="loginUser"></param> /// <returns></returns> public bool EnableInfo(long id, string loginUser) { int cnt = dal.GetCounts("[ID] = " + id + " and [USER_STATUS] in (" + (int)UserStatusConstants.Disable + "," + (int)UserStatusConstants.Locked + ")"); if (cnt == 0) { throw new Exception("MC:0x00000265");///未启用或已锁定状态的用户可以启用 } Guid userFid = dal.GetFid(id); if (userFid == Guid.Empty) { throw new Exception("MC:0x00000084");///数据错误 } cnt = new UserRoleDAL().GetCounts("[USER_FID] = N'" + userFid + "'"); if (cnt == 0) { throw new Exception("MC:0x00000266");///用户启用前需要先配置角色 } return(dal.UpdateInfo("[USER_STATUS] = " + (int)UserStatusConstants.Enable + ",[MODIFY_USER] = N'" + loginUser + "',[MODIFY_DATE] = GETDATE()", id) > 0 ? true : false); }
protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { bool IsMDE = false; #region User and Company Info clsUser objEmp = new clsUser(); objEmp = UserDAL.SelectUserById(Convert.ToInt32(Session["UserAuthId"].ToString())); #endregion #region Getting User Info // for side menu. if 3 hide. else show. if (objEmp != null) { #region Getting UserRole Id to check if the user is Admin List <clsUserRole> lstUserRoleIs = new List <clsUserRole>(); lstUserRoleIs = UserRoleDAL.SelectDynamicUserRole("AuthorizedUserId = " + objEmp.AuthorisedUserId + "", "UserRoleId"); if (lstUserRoleIs != null) { if (lstUserRoleIs.Count > 0) { for (int i = 0; i < lstUserRoleIs.Count; i++) { if (lstUserRoleIs[i].RoleId == 1) { IsMDE = true; } } } } #endregion #region getting all the roles boxes. int counter = 1; StringBuilder strAccess = new StringBuilder(""); List <clsRole> lstRole = new List <clsRole>(); if (IsMDE) { lstRole = RoleDAL.SelectDynamicRole("IsActive = 1", "DisplayOrder"); } else { lstRole = RoleDAL.SelectDynamicRole("(IsActive = 1) and (RoleId NOT IN (1))", "DisplayOrder"); } if (lstRole != null) { if (lstRole.Count > 0) { StringBuilder strAllRole = new StringBuilder(""); for (int i = 0; i < lstRole.Count; i++) { if (counter < 5) { if (counter == 1) { strAllRole.Append("<div class='Row'>"); } strAllRole.Append("<div class='col-lg-3'>"); strAllRole.Append("<div class='hpanel stats'>"); strAllRole.Append("<div class='panel-body h-200'>"); strAllRole.Append("<div class='stats-title pull-left'><div class='stats-icon pull-left'>"); strAllRole.Append("<i class='" + lstRole[i].RoleIcon + " fa-3x'></i>"); strAllRole.Append("</div><div class='clearfix'></div><h4 class='text-danger' style='font-size:17px'>"); strAllRole.Append(lstRole[i].RoleDispName); strAllRole.Append("</h4></div><div class='clearfix'></div>"); strAllRole.Append("<div class='flot-chart'>"); if (GlobalMethods.ValueIsNull(lstRole[i].Notes) == "") { strAllRole.Append("<small>" + GlobalMethods.ValueIsNull(lstRole[i].Notes) + "</small>"); } else { strAllRole.Append("<small>" + GlobalMethods.ValueIsNull(lstRole[i].Notes).Substring(0, 120) + " ..." + "</small>"); } strAllRole.Append("</div></div><div class='panel-footer'>"); strAllRole.Append(GettingRoleURL(lstRole[i].RoleId.ToString(), objEmp.AuthorisedUserId.HasValue ? objEmp.AuthorisedUserId.Value : 0, lstRole[i].RoleName, strAccess)); strAllRole.Append("</div></div></div>"); if (counter == 4) { strAllRole.Append("</div>"); } counter++; } else { counter = 1; if (counter == 1) { strAllRole.Append("<div class='Row'>"); } strAllRole.Append("<div class='col-lg-3'>"); strAllRole.Append("<div class='hpanel stats'>"); strAllRole.Append("<div class='panel-body h-200'>"); strAllRole.Append("<div class='stats-title pull-left'><div class='stats-icon pull-left'>"); strAllRole.Append("<i class='" + lstRole[i].RoleIcon + " fa-3x'></i>"); strAllRole.Append("</div><div class='clearfix'></div><h4 class='text-danger' style='font-size:17px'>"); strAllRole.Append(lstRole[i].RoleDispName); strAllRole.Append("</h4></div><div class='clearfix'></div>"); strAllRole.Append("<div class='flot-chart'>"); if (GlobalMethods.ValueIsNull(lstRole[i].Notes) == "") { strAllRole.Append("<small>" + GlobalMethods.ValueIsNull(lstRole[i].Notes) + "</small>"); } else { strAllRole.Append("<small>" + GlobalMethods.ValueIsNull(lstRole[i].Notes).Substring(0, 120) + " ..." + "</small>"); } strAllRole.Append("</div></div><div class='panel-footer'>"); strAllRole.Append(GettingRoleURL(lstRole[i].RoleId.ToString(), objEmp.AuthorisedUserId.HasValue ? objEmp.AuthorisedUserId.Value : 0, lstRole[i].RoleName, strAccess)); strAllRole.Append("</div></div></div>"); counter++; } } if (lstRole.Count % 2 != 0) { strAllRole.Append("</div>"); } pnlAllRole.Controls.Add(new LiteralControl(strAllRole.ToString())); } } #endregion } #endregion } }
public static string Approve(string cgi) { CryptoJS objcryptoJS = new CryptoJS(); string strURL = string.Empty; string ContractorAppId = string.Empty; try { ContractorAppId = cgi.ToString() == null ? string.Empty : cgi.ToString(); if (GlobalMethods.ValueIsNull(ContractorAppId).Length > 0) { ContractorAppId = objcryptoJS.AES_decrypt(HttpUtility.UrlEncode(cgi), AppConstants.secretKey, AppConstants.initVec).ToString(); } List <clsTrainingProvider> objSPCont = new List <clsTrainingProvider>(); objSPCont = TrainingProviderDAL.SelectDynamicTrainingProvider("TPId = " + ContractorAppId + "", "TPId"); if (objSPCont != null) { objSPCont[0].IsActive = 1; if (TrainingProviderDAL.UpdateTrainingProvider(objSPCont[0])) { List <clsUserRole> lstURole = new List <clsUserRole>(); lstURole = UserRoleDAL.SelectDynamicUserRole("RoleId = 2 and AuthorizedUserId = " + objSPCont[0].CreatedBy + "", "UserRoleId"); if (lstURole != null) { if (lstURole.Count > 0) { //ROLE HAS BEEN ASSIGNED. THEREFORE, DONT ADD ANOTHER ROLE. } else { clsUserRole objURole = new clsUserRole(); objURole.RoleId = 2; objURole.AuthorizedUserId = Convert.ToInt32(objSPCont[0].CreatedBy); objURole.IsActive = 1; objURole.CreatedDate = DateTime.Now; objURole.CreatedBy = HttpContext.Current.Session["UserAuthId"].ToString(); objURole.UpdatedDate = Convert.ToDateTime("1/1/1900"); objURole.UpdatedBy = ""; objURole.Notes = ""; if (!UserRoleDAL.InsertUserRole(objURole)) { } } } else { clsUserRole objURole = new clsUserRole(); objURole.RoleId = 2; objURole.AuthorizedUserId = Convert.ToInt32(objSPCont[0].CreatedBy); objURole.IsActive = 1; objURole.CreatedDate = DateTime.Now; objURole.CreatedBy = HttpContext.Current.Session["UserAuthId"].ToString(); objURole.UpdatedDate = Convert.ToDateTime("1/1/1900"); objURole.UpdatedBy = ""; objURole.Notes = ""; if (!UserRoleDAL.InsertUserRole(objURole)) { } } } } } catch (Exception) { ErrorHandler.ErrorPage(); } return("MDE_TPAppView.aspx?tpapps=active&cgi=" + cgi + ""); }
protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { #region User and Company Info clsUser objEmp = new clsUser(); objEmp = UserDAL.SelectUserById(Convert.ToInt32(Session["UserAuthId"].ToString())); #endregion #region Getting User Info // for side menu. if 3 hide. else show. if (objEmp != null) { if (GlobalMethods.ValueIsNull(objEmp.ImageURL).Length > 0) { // phProfileImg.Controls.Add(new LiteralControl("<img src='" + objEmp.ImageURL.ToEncryptUrl() + "' width='35%' class='img-circle m-b m-t-md, img-responsive' alt='" + GlobalMethods.stringToMixedCase(objEmp.FName + " " + objEmp.LName) + "'>")); //lblUserName.Text = "<span>" + GlobalMethods.stringToMixedCase(objEmp.FName + " " + objEmp.LName).ToUpper() + "</span>"; // lblUserIs.Text = "<span>" + GlobalMethods.stringToMixedCase(objEmp.FName + " " + objEmp.LName) + "</span>"; //lblDateJoin.Text = Convert.ToDateTime(objEmp.CreatedDate).ToLongDateString(); } else { // phProfileImg.Controls.Add(new LiteralControl("<img src='CSSBackEnd/img/imagemissing.png' width='35%' class='img-circle m-b m-t-md, img-responsive' alt='" + GlobalMethods.stringToMixedCase(objEmp.FName + " " + objEmp.LName) + "'>")); // lblUserName.Text = "<span>" + GlobalMethods.stringToMixedCase(objEmp.FName + " " + objEmp.LName).ToUpper() + "</span>"; // lblUserIs.Text = "<span>" + GlobalMethods.stringToMixedCase(objEmp.FName + " " + objEmp.LName) + "</span>"; // lblDateJoin.Text = Convert.ToDateTime(objEmp.CreatedDate).ToLongDateString(); } //pnlMDEAccess #region Now getting all the UserRole and making sure buttons are displayed accordingly. List <clsUserRole> lstURole = new List <clsUserRole>(); lstURole = UserRoleDAL.SelectDynamicUserRole("AuthorizedUserId = " + objEmp.AuthorisedUserId + "", "UserRoleId"); if (lstURole != null) { if (lstURole.Count > 0) { for (int i = 0; i < lstURole.Count; i++) { // This is MDE Role } } } #endregion #region Getting all the totals for dashboard List <clsCategory> lstMDECourse = new List <clsCategory>(); lstMDECourse = CategoryDAL.SelectAllCategory(); if (lstMDECourse != null) { if (lstMDECourse.Count > 0) { TotalMDECourses = lstMDECourse.Count.ToString(); } } #endregion #region Getting all the Pending Contractor Acc Applications TotalContractorPendingApps = "0"; List <dynamic> lstValues; string strSQL = @"SELECT tbl_SP_Contractor.SPContractorID, tbl_SP_Contractor.ACRDCatID, tbl_SP_Contractor.SPName, tbl_SP_Contractor.AccreditationID, tbl_SP_Contractor.AccreditationExpirationDate, tbl_SP_Contractor.IsActive, tbl_Category.CatTitle, tbl_SP_Contractor.CreatedDate FROM tbl_SP_Contractor INNER JOIN tbl_Category ON tbl_SP_Contractor.ACRDCatID = tbl_Category.ACRDCatID WHERE (tbl_SP_Contractor.SPContractorID NOT IN (SELECT SPContractorID FROM tbl_Contractor_Approval))"; var objPar = new DynamicParameters(); try { //objPar.Add("@CompanyId", CompanyId, dbType: DbType.Int32); using (IDbConnection db = new SqlConnection(System.Configuration.ConfigurationManager.AppSettings["databaseConnection"])) { lstValues = db.Query <dynamic>(strSQL, objPar, commandType: CommandType.Text).ToList(); if (lstValues != null) { if (lstValues.Count > 0) { TotalContractorPendingApps = lstValues.Count.ToString(); } } } } catch (Exception ex) { ErrorHandler.ErrorLogging(ex, false); ErrorHandler.ReadError(); } #endregion #region Getting all New Training Provider Application TotalTP_Apps = "0"; List <dynamic> lstTPTotal; string strSQL3 = @"SELECT tbl_TrainingProvider.TP_Name, tbl_TrainingProvider.TPId, tbl_TrainingProvider.CreatedDate, tbl_Instructor.AccreditationID, tbl_Instructor.AccreditationExpirationDate, tbl_Instructor.Instructor_FName, tbl_Instructor.Instructor_LName FROM tbl_TrainingProvider INNER JOIN tbl_TP_Instructors ON tbl_TrainingProvider.TPId = tbl_TP_Instructors.TPId INNER JOIN tbl_Instructor ON tbl_TP_Instructors.TP_InstructorListId = tbl_Instructor.InstructorId WHERE (tbl_TrainingProvider.TPId NOT IN (SELECT TPId FROM tbl_TP_Approval))"; var objPar3 = new DynamicParameters(); try { //objPar.Add("@CompanyId", CompanyId, dbType: DbType.Int32); using (IDbConnection db = new SqlConnection(System.Configuration.ConfigurationManager.AppSettings["databaseConnection"])) { lstTPTotal = db.Query <dynamic>(strSQL3, objPar3, commandType: CommandType.Text).ToList(); if (lstTPTotal != null) { if (lstTPTotal.Count > 0) { TotalTP_Apps = lstTPTotal.Count.ToString(); } } } } catch (Exception ex) { ErrorHandler.ErrorLogging(ex, false); ErrorHandler.ReadError(); } #endregion #region Getting all the New Instructor Applications List <dynamic> lstInstructorApps; string strSQL4 = @"SELECT Instructor_FName, Instructor_LName, InstructorId, AccreditationID, AccreditationExpirationDate FROM tbl_Instructor WHERE (InstructorId NOT IN (SELECT InstructorId FROM tbl_Instructor_Approval))"; var objPar4 = new DynamicParameters(); try { using (IDbConnection db = new SqlConnection(System.Configuration.ConfigurationManager.AppSettings["databaseConnection"])) { lstInstructorApps = db.Query <dynamic>(strSQL4, objPar4, commandType: CommandType.Text).ToList(); if (lstInstructorApps != null) { if (lstInstructorApps.Count > 0) { TotalInstructor_Apps = lstInstructorApps.Count.ToString(); } } } } catch (Exception ex) { ErrorHandler.ErrorLogging(ex, false); ErrorHandler.ReadError(); } #endregion #region Getting all the New Certifications. List <clsCourse_Result> lstCR = new List <clsCourse_Result>(); lstCR = Course_ResultDAL.SelectDynamicCourse_Result("(IsActive = -1) and (Cast(Acct_Term as int) > 0)", "ClassResultId"); if (lstCR != null) { if (lstCR.Count > 0) { TotalMDECertifications = lstCR.Count.ToString(); } } #endregion #region Getting New Inspector and Risk Assessor TotalRisk_Apps = "0"; List <dynamic> lstRiskAssesorApps; string strSQL6 = @"SELECT InspectorRiskAssId FROM tbl_Inspector_RiskAssessor WHERE (InspectorRiskAssId NOT IN (SELECT InspectorRiskAssId FROM tbl_RiskAssessor_Approval))"; var objPar6 = new DynamicParameters(); try { using (IDbConnection db = new SqlConnection(System.Configuration.ConfigurationManager.AppSettings["databaseConnection"])) { lstRiskAssesorApps = db.Query <dynamic>(strSQL6, objPar6, commandType: CommandType.Text).ToList(); if (lstRiskAssesorApps != null) { if (lstRiskAssesorApps.Count > 0) { TotalRisk_Apps = lstRiskAssesorApps.Count.ToString(); } } } } catch (Exception ex) { ErrorHandler.ErrorLogging(ex, false); ErrorHandler.ReadError(); } #endregion #region Getting New Supervisor TotalSuper_Apps = "0"; List <dynamic> lstSuper_Apps; string strSQL7 = @"SELECT SupervisorId FROM tbl_Supervisor WHERE (SupervisorId NOT IN (SELECT SupervisorId FROM tbl_Supervisor_Approval))"; var objPar7 = new DynamicParameters(); try { using (IDbConnection db = new SqlConnection(System.Configuration.ConfigurationManager.AppSettings["databaseConnection"])) { lstSuper_Apps = db.Query <dynamic>(strSQL7, objPar7, commandType: CommandType.Text).ToList(); if (lstSuper_Apps != null) { if (lstSuper_Apps.Count > 0) { TotalSuper_Apps = lstSuper_Apps.Count.ToString(); } } } } catch (Exception ex) { ErrorHandler.ErrorLogging(ex, false); ErrorHandler.ReadError(); } #endregion #region Getting New Training Courses TotalTrainingCourses = "0"; List <dynamic> lstTCourses; string strSQL8 = @"SELECT TrainingCourseAppId FROM tbl_TrainingCourse WHERE (TrainingCourseAppId NOT IN (SELECT TrainingCourseAppId FROM tbl_TrainingCourse_Approval))"; var objPar8 = new DynamicParameters(); try { using (IDbConnection db = new SqlConnection(System.Configuration.ConfigurationManager.AppSettings["databaseConnection"])) { lstTCourses = db.Query <dynamic>(strSQL8, objPar8, commandType: CommandType.Text).ToList(); if (lstTCourses != null) { if (lstTCourses.Count > 0) { TotalTrainingCourses = lstTCourses.Count.ToString(); } } } } catch (Exception ex) { ErrorHandler.ErrorLogging(ex, false); ErrorHandler.ReadError(); } #endregion } #endregion } }
protected string GettingRoleURL(string RoleId, int AuthUserId, string RoleDesc, StringBuilder strAccess) { strAccess.Clear(); strAccess.Append("<a href='RoleDesc.aspx?Dash=active&cgi=" + objcryptoJS.AES_encrypt(RoleId.ToString(), AppConstants.secretKey, AppConstants.initVec).ToString() + "' class='btn btn-xs btn-info' Title='Click to learn more on " + RoleDesc + "'>Learn More</a>"); List <clsUserRole> lstURole = new List <clsUserRole>(); lstURole = UserRoleDAL.SelectDynamicUserRole("RoleId = " + RoleId + " and AuthorizedUserId = " + AuthUserId + "", "UserRoleId"); if (lstURole != null) { if (lstURole.Count > 0) { // This is MDE Role if (lstURole[0].RoleId == 1) { #region This is MDE Role access allowed. strAccess.Clear(); strAccess.Append("<a href='dashboardMDE.aspx?Dash=active' class='btn btn-xs btn-success' alt='Click here to access MDE Module'>Access MDE Module</a>"); #endregion } if (lstURole[0].RoleId == 2) { #region This is Training Provider access allowed. strAccess.Clear(); strAccess.Append("<a href='RoleDesc.aspx?Dash=active&cgi=" + objcryptoJS.AES_encrypt(lstURole[0].RoleId.ToString(), AppConstants.secretKey, AppConstants.initVec).ToString() + "' class='btn btn-xs btn-success' alt='Click here to view Approved Training Provider Applications'>View Training Providers</a>"); #endregion } if (lstURole[0].RoleId == 3) { #region This is Instructor access allowed. strAccess.Clear(); strAccess.Append("<a href='RoleDesc.aspx?Dash=active&cgi=" + objcryptoJS.AES_encrypt(lstURole[0].RoleId.ToString(), AppConstants.secretKey, AppConstants.initVec).ToString() + "' class='btn btn-xs btn-success' alt='Click here to view Approved Instructors.'>View Instructors</a>"); #endregion } if (lstURole[0].RoleId == 4) { #region This is Property Owner access allowed. strAccess.Clear(); strAccess.Append("<a href='dashboardMDE.aspx?Dash=active' class='btn btn-xs btn-success' alt='Click here to Property Owner'>Property Owner Program</a>"); #endregion } if (lstURole[0].RoleId == 5) { #region This is Inspector access allowed. strAccess.Clear(); strAccess.Append("<a href='dashboardMDE.aspx?Dash=active' class='btn btn-xs btn-success' alt='Click here to Inspector'>Inspector Program</a>"); #endregion } if (lstURole[0].RoleId == 6) { #region This is Trainee access allowed. strAccess.Clear(); strAccess.Append("<a href='dashboardMDE.aspx?Dash=active' class='btn btn-xs btn-success' alt='Click here to Trainee'>Trainee Program</a>"); #endregion } if (lstURole[0].RoleId == 7) { #region This is Contractor access allowed. strAccess.Clear(); strAccess.Append("<a href='RoleDesc.aspx?Dash=active&cgi=" + objcryptoJS.AES_encrypt(lstURole[0].RoleId.ToString(), AppConstants.secretKey, AppConstants.initVec).ToString() + "' class='btn btn-xs btn-success' alt='Click here to view Approved Contractor Applications'>View Contractor</a>"); #endregion } if (lstURole[0].RoleId == 8) { #region This is OVERSIGHT PROGRAM access allowed. strAccess.Clear(); strAccess.Append("<a href='dashboardMDE.aspx?Dash=active' class='btn btn-xs btn-success' alt='Click here to access OVERSIGHT PROGRAM'>OVERSIGHT PROGRAM Program</a>"); #endregion } if (lstURole[0].RoleId == 9) { #region This is CERTIFICATION PROGRAM access allowed. strAccess.Clear(); strAccess.Append("<a href='dashboardMDE.aspx?Dash=active' class='btn btn-xs btn-success' alt='Click here to access CERTIFICATION PROGRAM'>CERTIFICATION PROGRAM Program</a>"); #endregion } } } return(strAccess.ToString()); }
public UserRoleBLL() { _userRoleController = new UserRoleDAL(); }
protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { string strRoleId = string.Empty; phGeneral.Visible = true; phTrainee.Visible = false; phInstructors.Visible = false; phCertAccedit.Visible = false; try { strRoleId = Request["cgi"].ToString() == null ? string.Empty : Request["cgi"].ToString(); if (GlobalMethods.ValueIsNull(strRoleId).Length > 0) { strRoleId = objcryptoJS.AES_decrypt(HttpUtility.UrlEncode(Request["cgi"].ToString()), AppConstants.secretKey, AppConstants.initVec).ToString(); clsRole objRole = new clsRole(); objRole = RoleDAL.SelectRoleById(Convert.ToInt32(strRoleId)); if (objRole != null) { RoleText = objRole.Notes; RoleIcon = objRole.RoleIcon; RoleTitle = objRole.RoleDispName; RoleRegisterURL = GlobalMethods.ValueIsNull(objRole.RoleRegisterURL); } } #region Now Getting Pending Applications. if (strRoleId == "7") // Contractor Role { #region Now Getting Pending Contractor Applications. List <clsSP_Contractor> lstSPContractor = new List <clsSP_Contractor>(); lstSPContractor = SP_ContractorDAL.SelectDynamicSP_Contractor("(CreatedBy = " + HttpContext.Current.Session["UserAuthId"].ToString() + ")", "CreatedDate DESC"); if (lstSPContractor != null) { if (lstSPContractor.Count > 0) { for (int i = 0; i < lstSPContractor.Count; i++) { // showTable(lstSPContractor[i].SPName,lstSPContractor[i].IsActive, lstSPContractor[i].SPContractorID.ToString()); } } } #endregion lblLowerTableHead.Text = "Applications"; pnlLogicalButtons.Controls.Add(new LiteralControl("<div class='input-group'><div class='input-group-btn'><a href='#' onclick='return history.back();' class='btn btn-primary'>Back</a><a href='" + RoleRegisterURL + "' class='btn btn-primary' title='Apply for the " + RoleTitle + "'>Apply for the " + RoleTitle + " </a></div><div class='alert alert-success' style='padding:8px !important;'> </div></div>")); } else if (strRoleId == "2")// Training Provider { bool IsApprTP = false; string strTPId = string.Empty; #region Checking if User have any TP approved. List <clsTrainingProvider> lstTP = new List <clsTrainingProvider>(); lstTP = TrainingProviderDAL.SelectDynamicTrainingProvider("CreatedBy = " + HttpContext.Current.Session["UserAuthId"].ToString() + " and IsActive = 1 ", "TPId"); if (lstTP != null) { if (lstTP.Count > 0) { IsApprTP = true; strTPId = lstTP[0].TPId.ToString(); } } #endregion #region Now Getting All Training Provider Applications. List <clsTrainingProvider> lstSPContractor = new List <clsTrainingProvider>(); lstSPContractor = TrainingProviderDAL.SelectDynamicTrainingProvider("(CreatedBy = " + HttpContext.Current.Session["UserAuthId"].ToString() + ")", "CreatedDate DESC"); if (lstSPContractor != null) { if (lstSPContractor.Count > 0) { for (int i = 0; i < lstSPContractor.Count; i++) { //showTable(lstSPContractor[i].TP_Name, lstSPContractor[i].IsActive, lstSPContractor[i].TPId.ToString()); } } } #endregion strTPId = objcryptoJS.AES_encrypt(HttpUtility.UrlEncode(strTPId.ToString()), AppConstants.secretKey, AppConstants.initVec).ToString(); if (IsApprTP) { //<a class='btn btn-primary' href='TP_AddCourses.aspx?dash=active&cgi=" + Request["cgi"] + "' >Add Courses</a> pnlLogicalButtons.Controls.Add(new LiteralControl("<div class='input-group'><div class='input-group-btn'><a href='#' onclick='return history.back();' class='btn btn-primary'>Back</a><a class='btn btn-primary' href='Inst_ScheduleClass.aspx?dash=active&cgi=" + Request["cgi"] + "' >Schedule Courses</a><a class='btn btn-primary' href='TP_AddLocations.aspx?dash=active' >Add Locations</a><a class='btn btn-primary' href='TP_AddInstructor.aspx?dash=active' >Add Instructors</a> <a class='btn btn-primary' href='TP_MgmtTraineeCards.aspx?dash=active&cgi=" + strTPId + "' >Manage Trainee Cards</a></div><div class='alert alert-success' style='padding:8px !important;'> </div></div>")); } else { pnlLogicalButtons.Controls.Add(new LiteralControl("<div class='input-group'><div class='input-group-btn'><a href='#' onclick='return history.back();' class='btn btn-primary'>Back</a><a href='" + RoleRegisterURL + "' class='btn btn-primary' title='Apply for the " + RoleTitle + "'>Apply for the " + RoleTitle + " </a></div><div class='alert alert-success' style='padding:8px !important;'> </div></div>")); } lblLowerTableHead.Text = "Applications"; } else if (strRoleId == "3")// Instructor { phGeneral.Visible = false; phInstructors.Visible = true; phTrainee.Visible = false; phCertAccedit.Visible = false; string strUserEmail = string.Empty; bool blShowCourseButton = false; string UserId = string.Empty; #region Getting User Email clsUser objUser = new clsUser(); objUser = UserDAL.SelectUserById(Convert.ToInt32(HttpContext.Current.Session["UserAuthId"].ToString())); if (objUser != null) { strUserEmail = objUser.EmailId; UserId = objUser.AuthorisedUserId.ToString(); } #endregion #region Checking if Instructor have any assigned Courses and users that applied to the Course. List <dynamic> lstCourses; string strSQLC = @"SELECT tbl_Instructor.InstructorId, tbl_CourseSchedule.CourseId, tbl_CourseSchedule.TPLocationId, tbl_CourseSchedule.ClassTitle, tbl_CourseSchedule.StartDate, tbl_CourseSchedule.EndDate, tbl_CourseSchedule.InstructionLanguage, tbl_CourseSchedule.CreateDate FROM tbl_Instructor INNER JOIN tbl_CourseSchedule ON tbl_Instructor.InstructorId = tbl_CourseSchedule.InstructorId WHERE (tbl_Instructor.Instructor_Email = @Email)"; var objParC = new DynamicParameters(); objParC.Add("@Email", strUserEmail, DbType.String); try { using (IDbConnection db = new SqlConnection(System.Configuration.ConfigurationManager.AppSettings["databaseConnection"])) { lstCourses = db.Query <dynamic>(strSQLC, objParC, commandType: CommandType.Text).ToList(); if (lstCourses != null) { if (lstCourses.Count > 0) { blShowCourseButton = true; } } } } catch (Exception ex) { ErrorHandler.ErrorLogging(ex, false); ErrorHandler.ReadError(); } #endregion #region Now Getting All Instructor Applications. List <clsInstructor> lstSPContractor = new List <clsInstructor>(); lstSPContractor = InstructorDAL.SelectDynamicInstructor("IsActive = 1", "CreatedDate"); if (lstSPContractor != null) { if (lstSPContractor.Count > 0) { for (int i = 0; i < lstSPContractor.Count; i++) { showTableInst(lstSPContractor[i].Instructor_FName, lstSPContractor[i].Instructor_LName, lstSPContractor[i].Instructor_Phone, lstSPContractor[i].Instructor_Email, lstSPContractor[i].InstructorId.ToString()); } } } #endregion if (blShowCourseButton) {//UserId #region Checking if this user has been added to UserRole as Instructor List <clsUserRole> lstUR = new List <clsUserRole>(); lstUR = UserRoleDAL.SelectDynamicUserRole("(AuthorizedUserId = " + UserId + ") and (RoleId = 3)", "UserRoleId"); if (lstUR != null) { if (lstUR.Count <= 0) { // Dont have UserRole as Instructor. clsUserRole objUR = new clsUserRole(); objUR.RoleId = 3; objUR.AuthorizedUserId = Convert.ToInt32(UserId); objUR.IsActive = 1; objUR.CreatedDate = DateTime.Now; objUR.CreatedBy = UserId; objUR.UpdatedDate = Convert.ToDateTime("1/1/1900"); objUR.UpdatedBy = ""; objUR.Notes = ""; if (!UserRoleDAL.InsertUserRole(objUR)) { } } } #endregion pnlLogicalButtons.Controls.Add(new LiteralControl("<div class='input-group'><div class='input-group-btn'><a href='#' onclick='return history.back();' class='btn btn-primary'>Back</a><a href='Inst_MgmtCourses.aspx?dash=active' class='btn btn-primary'>Manage Scores & Attendence Log</a></div><div class='alert alert-success' style='padding:8px !important;'> </div></div>")); } else { pnlLogicalButtons.Controls.Add(new LiteralControl("<div class='input-group'><div class='input-group-btn'><a href='#' onclick='return history.back();' class='btn btn-primary'>Back</a></div><div class='alert alert-success' style='padding:8px !important;'> </div></div>")); } lblLowerTableHead.Text = "Applications"; } else if (strRoleId == "1") { lblLowerTableHead.Text = "Applications"; pnlLogicalButtons.Controls.Add(new LiteralControl("<div class='input-group'><div class='input-group-btn'><a href='#' onclick='return history.back();' class='btn btn-primary'>Back</a><a href='" + RoleRegisterURL + "' class='btn btn-primary' title='Apply for the " + RoleTitle + "'>Apply for the " + RoleTitle + " </a></div><div class='alert alert-success' style='padding:8px !important;'> </div></div>")); } else if (strRoleId == "4") { lblLowerTableHead.Text = "Applications"; pnlLogicalButtons.Controls.Add(new LiteralControl("<div class='input-group'><div class='input-group-btn'><a href='#' onclick='return history.back();' class='btn btn-primary'>Back</a><a href='" + RoleRegisterURL + "' class='btn btn-primary' title='Apply for the " + RoleTitle + "'>Apply for the " + RoleTitle + " </a></div><div class='alert alert-success' style='padding:8px !important;'> </div></div>")); } else if (strRoleId == "5") { // Inspector lblLowerTableHead.Text = "Applications"; pnlLogicalButtons.Controls.Add(new LiteralControl("<div class='input-group'><div class='input-group-btn'><a href='#' onclick='return history.back();' class='btn btn-primary'>Back</a><a href='" + RoleRegisterURL + "' class='btn btn-primary' title='Apply for the " + RoleTitle + "'>Apply for the " + RoleTitle + " </a></div><div class='alert alert-success' style='padding:8px !important;'> </div></div>")); } else if (strRoleId == "6") { // Trainee phGeneral.Visible = false; phInstructors.Visible = false; phCertAccedit.Visible = false; phTrainee.Visible = true; pnlLogicalButtons.Controls.Add(new LiteralControl("<div class='input-group'><div class='input-group-btn'><a href='#' onclick='return history.back();' class='btn btn-primary'>Back</a></div><div class='alert alert-success' style='padding:8px !important;'> </div></div>")); #region Getting all the current and future courses. List <dynamic> lstCourseTotal; string strTagValue = string.Empty; StringBuilder strContent = new StringBuilder("<tr>"); string strSQL3 = @"SELECT DISTINCT tbl_CourseSchedule.TrainingCourseScheduleId, tbl_MDE_Courses.CourseDescription, tbl_MDE_Courses.InitialOrRenewal, tbl_TrainingProvider.TP_Name, tbl_CourseSchedule.CourseCost, tbl_MDE_Courses.InstructionLanguage, tbl_MDE_Courses.CourseDuration, tbl_MDE_Courses.PassScore, tbl_Category.ACRDCategory, tbl_TP_Location.TP_Address_Line_1, tbl_TP_Location.TP_City, tbl_TP_Location.TP_State, tbl_TP_Location.TP_ZipCode, tbl_TrainingProvider.TP_Telephone, tbl_Instructor.Instructor_FName, tbl_Instructor.Instructor_LName, tbl_MDE_Courses.CourseId, tbl_CourseSchedule.ClassTitle, tbl_CourseSchedule.StartDate, tbl_CourseSchedule.EndDate, tbl_CourseSchedule.Notes FROM tbl_CourseSchedule INNER JOIN tbl_TrainingProvider ON tbl_CourseSchedule.TPId = tbl_TrainingProvider.TPId INNER JOIN tbl_MDE_Courses ON tbl_CourseSchedule.CourseId = tbl_MDE_Courses.CourseId INNER JOIN tbl_Category ON tbl_MDE_Courses.ACRDCatID = tbl_Category.ACRDCatID INNER JOIN tbl_TP_Location ON tbl_CourseSchedule.TPLocationId = tbl_TP_Location.TPLocationId INNER JOIN tbl_Instructor ON tbl_CourseSchedule.InstructorId = tbl_Instructor.InstructorId"; try { var objPar3 = new DynamicParameters(); // objPar3.Add("@DateIn", Convert.ToDateTime(DateTime.Now).ToShortDateString(), dbType: DbType.String); using (IDbConnection db = new SqlConnection(System.Configuration.ConfigurationManager.AppSettings["databaseConnection"])) { lstCourseTotal = db.Query <dynamic>(strSQL3, objPar3, commandType: CommandType.Text).ToList(); if (lstCourseTotal != null) { if (lstCourseTotal.Count > 0) { for (int i = 0; i < lstCourseTotal.Count; i++) { strTagValue = GlobalMethods.ValueIsNull(lstCourseTotal[i].CourseDescription).ToString().Replace("(", "").Replace(" ", "").Replace(")", ""); strContent.Append("<div class='element-item transition " + strTagValue + "' data-category='" + strTagValue + "'>"); if (GlobalMethods.ValueIsNull(lstCourseTotal[i].Notes).Length > 110) { strContent.Append("<h3 class='name'>" + GlobalMethods.ValueIsNull(lstCourseTotal[i].Notes).Substring(0, 100) + "...</h3>"); } else { strContent.Append("<h3 class='name'>" + GlobalMethods.ValueIsNull(lstCourseTotal[i].Notes) + "</h3>"); } strContent.Append("<p class='symbol'><a href='CourseDetails.aspx?dash=active&cgi=" + objcryptoJS.AES_encrypt(HttpUtility.UrlEncode(GlobalMethods.ValueIsNull(lstCourseTotal[i].TrainingCourseScheduleId)), AppConstants.secretKey, AppConstants.initVec).ToString() + "' title='" + GlobalMethods.ValueIsNull(lstCourseTotal[i].ClassTitle) + "'>" + GlobalMethods.ValueIsNull(lstCourseTotal[i].ClassTitle) + "</a></p>"); strContent.Append("<p class='number'>" + GlobalMethods.ValueIsNull(lstCourseTotal[i].InitialOrRenewal) + "</p>"); strContent.Append("<p class='weight' style='align-content:center'><a href='CourseDetails.aspx?dash=active&cgi=" + objcryptoJS.AES_encrypt(HttpUtility.UrlEncode(GlobalMethods.ValueIsNull(lstCourseTotal[i].TrainingCourseScheduleId)), AppConstants.secretKey, AppConstants.initVec).ToString() + "' class='btn btn-xs btn-primary'>View Details</a></p>"); strContent.Append("</div>"); } } } pnlListofCourses.Controls.Add(new LiteralControl(strContent.ToString())); } } catch (Exception ex) { ErrorHandler.ErrorLogging(ex, false); ErrorHandler.ReadError(); } #endregion lblLowerTableHead.Text = "Applications"; } else if (strRoleId == "8") { lblLowerTableHead.Text = "Applications"; pnlLogicalButtons.Controls.Add(new LiteralControl("<div class='input-group'><div class='input-group-btn'><a href='#' onclick='return history.back();' class='btn btn-primary'>Back</a><a href='" + RoleRegisterURL + "' class='btn btn-primary' title='Apply for the " + RoleTitle + "'>Apply for the " + RoleTitle + " </a></div><div class='alert alert-success' style='padding:8px !important;'> </div></div>")); } else if (strRoleId == "9") { //Oversight lblLowerTableHead.Text = "Applications"; pnlLogicalButtons.Controls.Add(new LiteralControl("<div class='input-group'><div class='input-group-btn'><a href='#' onclick='return history.back();' class='btn btn-primary'>Back</a><a href='" + RoleRegisterURL + "' class='btn btn-primary' title='Apply for the " + RoleTitle + "'>Apply for the " + RoleTitle + " </a></div><div class='alert alert-success' style='padding:8px !important;'> </div></div>")); } else if (strRoleId == "10") { //Certificate phGeneral.Visible = false; phTrainee.Visible = false; phInstructors.Visible = false; phCertAccedit.Visible = true; lblLowerTableHead.Text = "Applications"; #region Now building the table with Courses Information. List <dynamic> lstCourses; string strSQLC = @"SELECT tbl_LK_Inst_CourseSchedule.Inst_CourseSchId, tbl_LK_Inst_CourseSchedule.CreatedDate, tbl_LK_Inst_CourseSchedule.ApprovedOn, tbl_Instructor.Instructor_FName, tbl_Instructor.Instructor_LName, tbl_TrainingProvider.TP_Name, tbl_Category.CatTitle, tbl_Course_Result.ClassResultId, tbl_Course_Result.AuthorisedUserId, tbl_Course_Result.IsActive, tbl_CourseSchedule.TPId, tbl_MDE_Courses.ACRDCatID FROM tbl_LK_Inst_CourseSchedule INNER JOIN tbl_Instructor ON tbl_LK_Inst_CourseSchedule.InstructorId = tbl_Instructor.InstructorId INNER JOIN tbl_CourseSchedule ON tbl_LK_Inst_CourseSchedule.TrainingCourseScheduleId = tbl_CourseSchedule.TrainingCourseScheduleId INNER JOIN tbl_Course_Result ON tbl_LK_Inst_CourseSchedule.Inst_CourseSchId = tbl_Course_Result.Inst_CourseSchId INNER JOIN tbl_TrainingProvider ON tbl_CourseSchedule.TPId = tbl_TrainingProvider.TPId INNER JOIN tbl_MDE_Courses ON tbl_CourseSchedule.CourseId = tbl_MDE_Courses.CourseId INNER JOIN tbl_Category ON tbl_MDE_Courses.ACRDCatID = tbl_Category.ACRDCatID WHERE (tbl_LK_Inst_CourseSchedule.AuthorisedUserId = @AuthorisedUserId) AND (tbl_Course_Result.AuthorisedUserId = @AuthorisedUserId) AND (tbl_Course_Result.IsActive = - 1)"; var objParC = new DynamicParameters(); objParC.Add("@AuthorisedUserId", HttpContext.Current.Session["UserAuthId"].ToString(), DbType.String); try { using (IDbConnection db = new SqlConnection(System.Configuration.ConfigurationManager.AppSettings["databaseConnection"])) { lstCourses = db.Query <dynamic>(strSQLC, objParC, commandType: CommandType.Text).ToList(); if (lstCourses != null) { if (lstCourses.Count > 0) { for (int i = 0; i < lstCourses.Count; i++) { showTableCertAccredit(GlobalMethods.ValueIsNull(lstCourses[i].CourseTitle), GlobalMethods.ValueIsNull(lstCourses[i].Instructor_FName) + " " + GlobalMethods.ValueIsNull(lstCourses[i].Instructor_LName), GlobalMethods.ValueIsNull(lstCourses[i].CatTitle), GlobalMethods.ValueIsNull(lstCourses[i].TP_Name), GlobalMethods.ValueIsNull(lstCourses[i].ClassResultId)); } } } } } catch (Exception ex) { ErrorHandler.ErrorLogging(ex, false); ErrorHandler.ReadError(); } #endregion //pnlLogicalButtons.Controls.Add(new LiteralControl("<div class='input-group'><div class='input-group-btn'><a href='#' onclick='return history.back();' class='btn btn-primary'>Back</a></div><div class='alert alert-success' style='padding:8px !important;'> </div></div>")); pnlLogicalButtons.Controls.Add(new LiteralControl("<div class='input-group'><div class='input-group-btn'><a href='dashboard.aspx?Dash=active' class='btn btn-primary'>BACK</a><a href='AppContractor.aspx?Dash=active' class='btn btn-primary' title='CONTRACTOR' >CONTRACTOR</a><a href='AppInspector_RiskAssessor.aspx?Dash=active' class='btn btn-primary' title='INSPECTOR AND RISK ASSESSOR'>INSPECTOR AND RISK ASSESSOR</a><a href='AppSupervisor.aspx?Dash=active' class='btn btn-primary' title='SUPERVISOR'>SUPERVISOR</a><a href='AppTrainingCourse.aspx?Dash=active' class='btn btn-primary' title='TRAINING COURSE'>TRAINING COURSE</a><a href='AppTP.aspx?Dash=active' class='btn btn-primary' title='TRAINING PROVIDER'>TRAINING PROVIDER</a><a href='AppInstructor.aspx?Dash=active' class='btn btn-primary' title='INSTRUCTOR'>INSTRUCTOR</a></div><div class='alert' style='background-color:#354A5F;padding:8px !important;'> </div></div>")); } #endregion } catch (Exception) { ErrorHandler.ErrorPage(); } } }
public int GetUserRoleByUserID(int UserID /*, ref string oUTPUT*/) { UserRoleDAL dAL = new UserRoleDAL(); return(dAL.GetUserRoleByUserID(UserID /*, ref oUTPUT*/)); }
protected void Page_Load(object sender, EventArgs e) { if (!Page.IsPostBack) { string CompId = string.Empty; string BranchId = string.Empty; string BranchName = string.Empty; string LstBranchdropdown = string.Empty; string SelectBranchdrpdown = string.Empty; StringBuilder strAccessRole = new StringBuilder(""); phLogoTop.Controls.Add(new LiteralControl("<a href='dashboard.aspx?Dash=active'><img src='CSSBackEnd/img/logo.png' width='115%' class='img-responsive' alt='LRCA: LEAD Rental Certification and Accreditation'></a>")); clsUser objUser = new clsUser(); objUser = UserDAL.SelectUserById(Convert.ToInt32(Session["UserAuthId"].ToString())); if (objUser != null) { if (GlobalMethods.ValueIsNull(objUser.ImageURL).Length > 0) { phProfileImg.Controls.Add(new LiteralControl("<img src='" + objUser.ImageURL.ToString() + "' class='img-circle m-b, img-responsive, center-block' width='70%' alt='" + GlobalMethods.stringToMixedCase(objUser.FName + " " + objUser.LName) + "'>")); lblUserName.Text = "<span>" + GlobalMethods.stringToMixedCase(objUser.FName + " " + objUser.LName) + "</span>"; } else { phProfileImg.Controls.Add(new LiteralControl("<img src='CSSBackEnd/img/avatars/sunny-big.png' class='img-circle m-b, img-responsive, center-block' width='70%' alt='" + GlobalMethods.stringToMixedCase(objUser.FName + " " + objUser.LName) + "'>")); lblUserName.Text = "<span>" + GlobalMethods.stringToMixedCase(objUser.FName + " " + objUser.LName) + "</span>"; } if (AccessRightsBAL.IsMDE(Convert.ToInt32(objUser.AuthorisedUserId))) { phMDE.Visible = true; } else { phMDE.Visible = false; } if (objUser.IsAdmin == 1) { strAccessRole.Append("Administrator"); } #region Now getting all the UserRole and making sure buttons are displayed accordingly. List <clsUserRole> lstURole = new List <clsUserRole>(); lstURole = UserRoleDAL.SelectDynamicUserRole("AuthorizedUserId = " + objUser.AuthorisedUserId + "", "UserRoleId"); if (lstURole != null) { if (lstURole.Count > 0) { for (int i = 0; i < lstURole.Count; i++) { // This is MDE Role if (lstURole[i].RoleId == 1) { #region This is MDE Role access allowed. strAccessRole.Append("<br />MDE"); #endregion } } } } #endregion pnRole.Controls.Add(new LiteralControl(strAccessRole.ToString())); } } }
public static bool RegistrationByRole(string strFName, string strLName, string strEmail, int RoleIdIs, int CreatedById) { bool IsRegistered = false; string strTempPass = string.Empty; string HashPassword = string.Empty; string HashSalt = string.Empty; string strReturn = string.Empty; string strRoleIs = string.Empty; try { strTempPass = DateTime.Now.Millisecond.ToString() + DateTime.Now.Minute.ToString() + DateTime.Now.Hour.ToString() + DateTime.Now.Second.ToString() + DateTime.Now.Day.ToString(); HashPassword = SecurityObj.SecurityObj.ComputeHash(strTempPass, "SHA1", null); HashSalt = SecurityObj.SecurityObj.GetSalt("SHA1", HashPassword); clsUser objUser = new clsUser(); objUser.FName = GlobalMethods.stringToMixedCase(strFName); objUser.LName = GlobalMethods.stringToMixedCase(strLName); objUser.Password = HashPassword; objUser.TempPassword = strTempPass; objUser.salt = HashSalt; objUser.EmailId = strEmail; objUser.IsCurrent = 1; objUser.IndividualUserID = 0; objUser.CreatedDate = DateTime.Now; objUser.CreatedBy = GlobalMethods.stringToMixedCase(strFName) + " " + GlobalMethods.stringToMixedCase(strLName); objUser.UpdatedDate = Convert.ToDateTime("1/1/1900"); objUser.UpdatedBy = ""; objUser.Notes = ""; objUser.ImageURL = ""; objUser.IsAdmin = 0; objUser.IsActive = -2; if (UserDAL.InsertUser(objUser)) { #region First getting the Title of the ROLE the user has been assigned. clsRole objRole = new clsRole(); objRole = RoleDAL.SelectRoleById(RoleIdIs); if (objRole != null) { strRoleIs = objRole.RoleDispName; } #endregion #region Now we have a new User lets save the ROLE in USERROLE Table List <clsUser> lstUser = new List <clsUser>(); lstUser = UserDAL.SelectDynamicUser("FName = '" + GlobalMethods.stringToMixedCase(strFName) + "' and LName = '" + GlobalMethods.stringToMixedCase(strLName) + "' and EmailId = '" + strEmail + "'", "AuthorisedUserId"); if (lstUser != null) { if (lstUser.Count > 0) { clsUserRole objURole = new clsUserRole(); objURole.RoleId = RoleIdIs; objURole.AuthorizedUserId = lstUser[0].AuthorisedUserId; objURole.IsActive = 1; objURole.CreatedDate = DateTime.Now; objURole.CreatedBy = CreatedById.ToString(); objURole.UpdatedBy = ""; objURole.UpdatedDate = Convert.ToDateTime("1/1/1900"); objURole.Notes = ""; if (UserRoleDAL.InsertUserRole(objURole)) { IsRegistered = true; #region Now sending email with the Temp Password. System.Text.StringBuilder strbEmailMSG = new StringBuilder(); strbEmailMSG.Append(objUser.FName + " " + objUser.LName + "," + System.Environment.NewLine + System.Environment.NewLine); strbEmailMSG.Append("LRCA System created a/an " + strRoleIs + " account with a TEMPORARY PASSWORD." + System.Environment.NewLine + " To access your account enter the following information:" + System.Environment.NewLine + "Username : "******"Temporary Password : "******"To access LRCA application please visit " + AppConstants.ConstAppURL + "." + System.Environment.NewLine); strbEmailMSG.Append(System.Environment.NewLine + System.Environment.NewLine); strbEmailMSG.Append("If you require any further information, feel free to contact " + AppConstants.ConstHelpPhone + System.Environment.NewLine + " or Email us @" + AppConstants.ConstHelpEmail + System.Environment.NewLine + System.Environment.NewLine); GlobalMethods.SendEmail(objUser.EmailId, "", strbEmailMSG, "LRCA - New Account Registration"); #endregion } } } #endregion } } catch (Exception ex) { ErrorHandler.ErrorLogging(ex, false); ErrorHandler.ReadError(); } return(IsRegistered); }