private void btnSave_Click(object sender, System.Windows.RoutedEventArgs e) { try { if (txtName.Text.Trim() == "" || txtName.Text.Length > 50) { MessageBox.Show("Name of the Role cannot be left Blank or not more than 50 characters. ", "-> Please Enter a Name", MessageBoxButton.OK, MessageBoxImage.Information); txtName.Focus(); txtName.Text = txtName.Text.Trim(); return; } ClsRole objRole = new ClsRole(); if (varState == 0) //whn edit is clicked var state is sate to 1 so that sstored procedure update the table data { objRole.ID = -1; } else { objRole.ID = varID; } objRole.RoleName = txtName.Text.Trim(); objRole.Description = txtDescription.Text.Trim(); if (chkIsAdmin.IsChecked == true) { objRole.IsAdmin = true; } else { objRole.IsAdmin = false; } objRole.CreatedBy = VMuktiAPI.VMuktiInfo.CurrentPeer.ID; int gID = Convert.ToInt16(objRole.Save()); if (gID == 0) { MessageBox.Show("Duplicate Entry For Role Name Not Allowed !!", "-> Role", MessageBoxButton.OK, MessageBoxImage.Exclamation); } else { lblCurrentRole.Content = "Role : " + txtName.Text; FncSavePermissions(varID); //c.Save(varID); FncClearAll(); funSetGrid(); tbiRoles.IsSelected = true; } } catch (Exception ex) { VMuktiHelper.ExceptionHandler(ex, "btnSave_Click", "CtlRole.xaml.cs"); } }
public ActionResult Role() { try { GetPagePermissionResult objPermission = Functions.CheckPagePermission(PageMaster.Role); if (!objPermission.IsActive) { return(this.RedirectToAction("Logout", "Home")); } ClsRole objClsRole = this.objiClsRole as ClsRole; long lgRoleId = 0; if (this.Request.QueryString.Count > 0) { if (this.Request.QueryString["iFrame"] != null) { if (!objPermission.Add_Right) { return(this.RedirectToAction("PermissionRedirectPage", "Home")); } objClsRole.hdniFrame = true; } else { if (!objPermission.Edit_Right || string.IsNullOrEmpty(this.Request.QueryString.ToString().Decode())) { return(this.RedirectToAction("PermissionRedirectPage", "Home")); } lgRoleId = this.Request.QueryString.ToString().Decode().longSafe(); objClsRole = this.objiClsRole.GetRoleByRoleId(lgRoleId); } } else { if (!objPermission.Add_Right) { return(this.RedirectToAction("PermissionRedirectPage", "Home")); } } #region Menu Access Controllers.BaseController baseController = new Controllers.BaseController(); this.ViewData = baseController.MenuAccessPermissions(objPermission); #endregion Menu Access this.BindCompanyDropDownListForRole(objClsRole, true, objClsRole.lgCompanyID); return(this.View(objClsRole)); } catch (Exception ex) { Functions.Write(ex, System.Reflection.MethodBase.GetCurrentMethod().Name, PageMaster.Role); return(this.View()); } }
void CtlGrid_btnDeleteClicked(int RowID) { try { varID = Convert.ToInt64(objRoleCollection[RowID].ID); if (System.Windows.MessageBox.Show("Do You Really Want To Delete This Record ?", "->Delete Role", MessageBoxButton.YesNo, MessageBoxImage.Question) == MessageBoxResult.Yes) { ClsRole.Delete(varID); System.Windows.MessageBox.Show("Record Deleted!!", "->Role Delete", MessageBoxButton.OK, MessageBoxImage.Information); funSetGrid(); } } catch (Exception ex) { VMuktiHelper.ExceptionHandler(ex, "CtlGrid_btnDeleteClicked", "CtlRole.xaml.cs"); } }
public void BindCompanyDropDownListForRole(ClsRole objRole, bool blBindDropDownFromDb, long?CompanyID) { try { if (blBindDropDownFromDb) { objRole.listCompany = this.objiClsCompany.GetCompanyForDropDown(CompanyID).ToList(); } else { objRole.listCompany = new List <SelectListItem>(); } } catch (Exception ex) { Functions.Write(ex, System.Reflection.MethodBase.GetCurrentMethod().Name, PageMaster.Company); } }
public JsonResult UpdateRole(clsRole _roles) { try { ClsRole clsRole = new ClsRole(); var itemfound = clsRole.CheckRoleName(_roles.RoleName); if (itemfound > 0) { return(Json(new { msg = "This Record is already Exist" }, JsonRequestBehavior.AllowGet)); } tblRole rigt = roles.GetByID(x => x.RoleId == _roles.RoleId); rigt.RoleName = _roles.RoleName; roles.Edit(rigt); roles.Save(); return(Json(rigt, JsonRequestBehavior.AllowGet)); } catch (Exception ex) { Log.Error(ex.ToString()); } return(null); }
private string ValidateRole(ClsRole objRole) { try { string strErrorMsg = string.Empty; if (string.IsNullOrEmpty(objRole.strRoleName)) { strErrorMsg += _alertTextProvider.AlertMessage("Role Name", MessageType.InputRequired) + "<br/>"; } if (string.IsNullOrEmpty(objRole.strRights)) { strErrorMsg += "No Rights Are Selected." + "<br/>"; } return(strErrorMsg); } catch (Exception ex) { Logger.Write(ex, System.Reflection.MethodBase.GetCurrentMethod().Name, PageMaster.Role, _mySession.UserId); return(string.Empty); } }
public JsonResult InsertRole(clsRole _roles) { try { ClsRole clsRole = new ClsRole(); var itemfound = clsRole.CheckRoleName(_roles.RoleName); if (itemfound > 0) { return(Json(new { msg = "This Record is already Exist" }, JsonRequestBehavior.AllowGet)); } tblRole rigt = new tblRole(); rigt.RoleName = _roles.RoleName; rigt.IsDeleted = false; roles.Insert(rigt); roles.Save(); return(Json(rigt, JsonRequestBehavior.AllowGet)); } catch (Exception ex) { Log.Error(ex.ToString()); } return(null); }
public ActionResult Role(ClsRole objRole) { try { GetPagePermissionResult objPermission = _permissionChecker.CheckPagePermission(PageMaster.Role); if (objRole.lgId == 0) { if (!objPermission.Add_Right) { return(RedirectToAction("PermissionRedirectPage", "Home")); } } else { if (!objPermission.Edit_Right) { return(RedirectToAction("PermissionRedirectPage", "Home")); } } if (objRole.hdniFrame) { ViewData["iFrame"] = "iFrame"; } bool blExists = _userService.IsRoleExists(objRole.lgId, objRole.strRoleName); if (blExists) { ViewData["Success"] = "0"; ViewData["Message"] = _alertTextProvider.AlertMessage("Role", MessageType.AlreadyExists); } else { string strErrorMsg = ValidateRole(objRole); if (!string.IsNullOrEmpty(strErrorMsg)) { ViewData["Success"] = "0"; ViewData["Message"] = strErrorMsg; } else { long resultId = _userService.SaveRole(objRole); if (resultId > 0) { ViewData["Success"] = "1"; ViewData["Message"] = _alertTextProvider.AlertMessage("Role", MessageType.Success); } else { ViewData["Success"] = "0"; ViewData["Message"] = _alertTextProvider.AlertMessage("Role", MessageType.Fail); } } } return(View(objRole)); } catch (Exception ex) { ViewData["Success"] = "0"; ViewData["Message"] = _alertTextProvider.AlertMessage("Role", MessageType.Fail); Logger.Write(ex, System.Reflection.MethodBase.GetCurrentMethod().Name, PageMaster.Role); return(View(objRole)); } }
public ActionResult Role() { try { GetPagePermissionResult objPermission = _permissionChecker.CheckPagePermission(PageMaster.Role); if (!objPermission.IsActive) { return(RedirectToAction("Logout", "Home")); } ClsRole objClsRole = _userService as ClsRole; long lgRoleId = 0; if (Request.QueryString.Count > 0) { if (Request.QueryString["iFrame"] != null) { if (!objPermission.Add_Right) { return(RedirectToAction("PermissionRedirectPage", "Home")); } objClsRole.hdniFrame = true; } else { if (!objPermission.Edit_Right || string.IsNullOrEmpty(Request.QueryString.ToString().Decode())) { return(RedirectToAction("PermissionRedirectPage", "Home")); } lgRoleId = Request.QueryString.ToString().Decode().LongSafe(); objClsRole = _userService.GetRoleByRoleId(lgRoleId) as ClsRole; } } else { if (!objPermission.Add_Right) { return(RedirectToAction("PermissionRedirectPage", "Home")); } } #region Menu Access bool blUserAccess = true, blRoleAccess = true, blTrackerAccess = true, blCarFleetAccess = true, blFleetMakesAccess = true, blFleetModelsAccess = true, blFleetColorsAccess = true, blTripReasonAccess = true; objPermission = _permissionChecker.CheckPagePermission(PageMaster.User); if (!objPermission.Add_Right) { blUserAccess = false; } objPermission = _permissionChecker.CheckPagePermission(PageMaster.Role); if (!objPermission.Add_Right) { blRoleAccess = false; } objPermission = _permissionChecker.CheckPagePermission(PageMaster.Tracker); if (!objPermission.Add_Right) { blTrackerAccess = false; } objPermission = _permissionChecker.CheckPagePermission(PageMaster.CarFleet); if (!objPermission.Add_Right) { blCarFleetAccess = false; } objPermission = _permissionChecker.CheckPagePermission(PageMaster.FleetMakes); if (!objPermission.Add_Right) { blFleetMakesAccess = false; } objPermission = _permissionChecker.CheckPagePermission(PageMaster.FleetModels); if (!objPermission.Add_Right) { blFleetModelsAccess = false; } objPermission = _permissionChecker.CheckPagePermission(PageMaster.FleetColors); if (!objPermission.Add_Right) { blFleetColorsAccess = false; } objPermission = _permissionChecker.CheckPagePermission(PageMaster.TripReason); if (!objPermission.Add_Right) { blTripReasonAccess = false; } ViewData["UserAccess"] = blUserAccess; ViewData["RoleAccess"] = blRoleAccess; ViewData["TrackerAccess"] = blTrackerAccess; ViewData["CarFleetAccess"] = blCarFleetAccess; ViewData["FleetMakesAccess"] = blFleetMakesAccess; ViewData["FleetModelsAccess"] = blFleetModelsAccess; ViewData["FleetColorsAccess"] = blFleetColorsAccess; ViewData["TripReasonAccess"] = blTripReasonAccess; #endregion return(View(objClsRole)); } catch (Exception ex) { Logger.Write(ex, System.Reflection.MethodBase.GetCurrentMethod().Name, PageMaster.Role); return(View()); } }
public ActionResult Role(ClsRole objRole) { try { GetPagePermissionResult objPermission = Functions.CheckPagePermission(PageMaster.Role); if (objRole.lgId == 0) { if (!objPermission.Add_Right) { return(this.RedirectToAction("PermissionRedirectPage", "Home")); } } else { if (!objPermission.Edit_Right) { return(this.RedirectToAction("PermissionRedirectPage", "Home")); } } if (objRole.hdniFrame) { this.ViewData["iFrame"] = "iFrame"; } bool blExists = this.objiClsRole.IsRoleExists(objRole.lgId, objRole.strRoleName, objRole.lgCompanyID); if (blExists) { this.ViewData["Success"] = "0"; this.ViewData["Message"] = Functions.AlertMessage("Role", MessageType.AlreadyExist); this.BindCompanyDropDownListForRole(objRole, true, 0); } else { string strErrorMsg = this.ValidateRole(objRole); if (!string.IsNullOrEmpty(strErrorMsg)) { this.ViewData["Success"] = "0"; this.ViewData["Message"] = strErrorMsg; } else { long resultId = this.objiClsRole.SaveRole(objRole); if (resultId > 0) { this.ViewData["Success"] = "1"; this.ViewData["Message"] = Functions.AlertMessage("Role", MessageType.Success); } else { this.ViewData["Success"] = "0"; this.ViewData["Message"] = Functions.AlertMessage("Role", MessageType.Fail); } } this.BindCompanyDropDownListForRole(objRole, true, objRole.lgCompanyID); } return(this.View(objRole)); } catch (Exception ex) { this.ViewData["Success"] = "0"; this.ViewData["Message"] = Functions.AlertMessage("Role", MessageType.Fail); Functions.Write(ex, System.Reflection.MethodBase.GetCurrentMethod().Name, PageMaster.Role); return(this.View(objRole)); } }