private string ValidateGroup(ClsGroup objGroup) { try { string strErrorMsg = string.Empty; if (string.IsNullOrEmpty(objGroup.strGroupName)) { strErrorMsg += Functions.AlertMessage("GroupName", MessageType.InputRequired) + "<br/>"; } if (objGroup.lgParentGroupId == 0) { if (objGroup.lgCompanyId == 0) { strErrorMsg += Functions.AlertMessage("Company", MessageType.InputRequired) + "<br/>"; } } if (string.IsNullOrEmpty(objGroup.hdnstrUserIds)) { strErrorMsg += Functions.AlertMessage("User", MessageType.InputRequired) + "<br/>"; } return(strErrorMsg); } catch (Exception ex) { Functions.Write(ex, System.Reflection.MethodBase.GetCurrentMethod().Name, PageMaster.Group, mySession.Current.UserId); return(string.Empty); } }
public ActionResult Group() { try { GetPagePermissionResult objPermission = Functions.CheckPagePermission(PageMaster.Group); if (!objPermission.IsActive) { return(this.RedirectToAction("Logout", "Home")); } ClsGroup objClsGroup = this.objiClsGroup as ClsGroup; long lgUserId = 0; if (this.Request.QueryString.Count > 0) { if (this.Request.QueryString["iFrame"] != null) { if (!objPermission.Add_Right) { return(this.RedirectToAction("PermissionRedirectPage", "Home")); } objClsGroup.hdniFrame = true; } else { if (!objPermission.Edit_Right || string.IsNullOrEmpty(this.Request.QueryString.ToString())) { return(this.RedirectToAction("PermissionRedirectPage", "Home")); } lgUserId = this.Request.QueryString.ToString().longSafe(); objClsGroup = this.objiClsGroup.GetGroupByGroupId(lgUserId); } } 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.ViewData["UserRoleID"] = mySession.Current.RoleId; this.BindDropDownListForGroup(objClsGroup, true, objClsGroup.lgCompanyId, objClsGroup.lgParentGroupId); return(this.View(objClsGroup)); } catch (Exception ex) { Functions.Write(ex, System.Reflection.MethodBase.GetCurrentMethod().Name, PageMaster.Group, mySession.Current.UserId); return(this.View()); } }
//To delete data void CtlGrid_btnDeleteClicked(int ID) { try { varID = _MyGroups[ID].ID; if (MessageBox.Show("Do You Really Want To Delete This Record ?", "Delete Group", MessageBoxButton.YesNo, MessageBoxImage.Question) == MessageBoxResult.Yes) { //Calling Delete function ClsGroup.Delete(_MyGroups[ID].ID); MessageBox.Show("Record Deleted!!", "Group Deleted", MessageBoxButton.OK, MessageBoxImage.Information); //Function for setting the grid after deleting record funSetGrid(); } } catch (Exception ex) { VMuktiHelper.ExceptionHandler(ex, "CtlGrid_btnDeleteClicked", "ctlUserGroup.xaml.cs"); } }
public void BindDropDownListForGroup(ClsGroup objClsGroup, bool blBindDropDownFromDb, long?CompanyId, long?ParentGroupId) { try { if (blBindDropDownFromDb) { objClsGroup.lstGroups = this.objiClsGroup.GetParentGroupForDropDown().ToList(); objClsGroup.lstCompany = this.objiClsCompany.GetCompanyForGroupDropDown().ToList(); objClsGroup.lstUsers = this.objiClsUser.GetAllUsersByCompany(CompanyId ?? 0, ParentGroupId ?? 0).ToList(); } else { objClsGroup.lstGroups = new List <SelectListItem>(); objClsGroup.lstCompany = new List <SelectListItem>(); objClsGroup.lstUsers = new List <SelectListItem>(); } } catch (Exception ex) { Functions.Write(ex, System.Reflection.MethodBase.GetCurrentMethod().Name, PageMaster.Group); } }
//To save new Record private void btnGroupSave_Click(object sender, System.Windows.RoutedEventArgs e) { try { //Validations for group #region GroupName Validation if (txtName.Text.Trim() == "") { MessageBox.Show("Group Name Can't be left Blank ", "-> Please Enter a Name", MessageBoxButton.OK, MessageBoxImage.Information); txtName.Focus(); txtName.Text = txtName.Text.Trim(); return; } #endregion string strUsers = ""; for (int i = 0; i < lstSelectedAgents.Items.Count; i++) { if (i == 0) { strUsers = ((ListBoxItem)lstSelectedAgents.Items[i]).Tag.ToString(); } else { strUsers = strUsers + "," + ((ListBoxItem)lstSelectedAgents.Items[i]).Tag.ToString(); } } int GetId = 0; ClsGroup c = new ClsGroup(); if (varState == 0) { c.ID = -1; } else { c.ID = varID; } c.GroupName = txtName.Text.Trim(); c.Description = txtDescription.Text.Trim(); c.IsActive = (bool)chkIsActive.IsChecked; c.CreatedBy = VMuktiAPI.VMuktiInfo.CurrentPeer.ID; //Function to save new record int gID = c.Save(); if (gID == 0) { MessageBox.Show("User Group With Same Name is Not Allowed", "-> User Group", MessageBoxButton.OK, MessageBoxImage.Information); } else { if (varState != 0) { ClsUser u1 = new ClsUser(); u1.ID = gID; u1.Delete(); } for (int i = 0; i < lstSelectedAgents.Items.Count; i++) { ClsUser u = new ClsUser(); u.ID = int.Parse(((ListBoxItem)lstSelectedAgents.Items[i]).Tag.ToString()); //u.AgentName = ((ListBoxItem)lstSelectedAgents.Items[i]).Content.ToString(); u.GroupId = gID; //Function to Save record in usergroup u.Save(); } System.Windows.MessageBox.Show("Record Saved Successfully!!"); FncClearAll(); //set data in grid funSetGrid(); //set data in listboxes funSetComboboxes(); } } catch (Exception ex) { VMuktiHelper.ExceptionHandler(ex, "btnGroupSave_Click", "ctlUserGroup.xaml.cs"); } }
public ActionResult Group(ClsGroup objGroup) { try { GetPagePermissionResult objPermission = Functions.CheckPagePermission(PageMaster.Group); if (!objPermission.IsActive) { return(this.RedirectToAction("Logout", "Home")); } if (objGroup.lgId == 0) { if (!objPermission.Add_Right) { return(this.RedirectToAction("PermissionRedirectPage", "Home")); } } else { if (!objPermission.Edit_Right) { return(this.RedirectToAction("PermissionRedirectPage", "Home")); } } if (objGroup.hdniFrame) { this.ViewData["iFrame"] = "iFrame"; } bool blExists = this.objiClsGroup.IsGroupExists(objGroup.lgId, objGroup.strGroupName); if (blExists) { this.ViewData["Success"] = "0"; this.ViewData["Message"] = Functions.AlertMessage("Group", MessageType.AlreadyExist); } else { string strErrorMsg = this.ValidateGroup(objGroup); if (!string.IsNullOrEmpty(strErrorMsg)) { this.ViewData["Success"] = "0"; this.ViewData["Message"] = strErrorMsg; } else { long resultId = this.objiClsGroup.SaveGroup(objGroup); if (resultId > 0) { this.ViewData["Success"] = "1"; this.ViewData["Message"] = Functions.AlertMessage("Group", MessageType.Success); this.BindDropDownListForGroup(objGroup, true, objGroup.lgCompanyId, objGroup.lgParentGroupId); return(this.View(objGroup)); } else { this.ViewData["Success"] = "0"; this.ViewData["Message"] = Functions.AlertMessage("Group", MessageType.Fail); } } } this.BindDropDownListForGroup(objGroup, true, objGroup.lgCompanyId, objGroup.lgParentGroupId); return(this.View(objGroup)); } catch (Exception ex) { this.ViewData["Success"] = "0"; this.ViewData["Message"] = Functions.AlertMessage("Group", MessageType.Fail); Functions.Write(ex, System.Reflection.MethodBase.GetCurrentMethod().Name, PageMaster.Group, mySession.Current.UserId); return(this.View(objGroup)); } }