public void DoRepeaterItem(RepeaterItem item, ArrayList selectedList, ArrayList unselectedList) { HtmlInputCheckBox selected = (HtmlInputCheckBox)item.FindControl("Permission"); HtmlInputCheckBox wselected = (HtmlInputCheckBox)item.FindControl("WritePermission"); EUserGroupFunction a = new EUserGroupFunction(); a.FunctionID = int.Parse(selected.Attributes["id"]); a.FunctionAllowRead = selected.Checked; a.FunctionAllowWrite = wselected.Checked; if (a.FunctionAllowRead || a.FunctionAllowWrite) { selectedList.Add(a); } else { unselectedList.Add(a); } if (!a.FunctionAllowWrite) { ESystemFunction function = new ESystemFunction(); function.FunctionID = a.FunctionID; if (ESystemFunction.db.select(dbConn, function)) { if (function.FunctionCode.Equals("SEC001") || function.FunctionCode.Equals("SEC002")) { checkUserSecurityAccess = true; } } } }
public void DoRepeaterItem(RepeaterItem item, ArrayList list) { HtmlInputCheckBox selected = (HtmlInputCheckBox)item.FindControl("Permission"); HtmlInputCheckBox wselected = (HtmlInputCheckBox)item.FindControl("WritePermission"); EUserGroupFunction a = new EUserGroupFunction(); a.FunctionID = int.Parse(selected.Attributes["id"]); if (selected.Checked) { a.FunctionAllowRead = true; } if (wselected.Checked) { a.FunctionAllowWrite = true; } if (a.FunctionAllowRead || a.FunctionAllowWrite) { list.Add(a); } }
protected void ItemDataBound(object sender, RepeaterItemEventArgs e) { HROne.Common.WebUtility.WebControlsLocalization(this, e.Item.Controls); HtmlInputCheckBox selected = (HtmlInputCheckBox)e.Item.FindControl("Permission"); HtmlInputCheckBox wselected = (HtmlInputCheckBox)e.Item.FindControl("WritePermission"); int id = (int)((DataRowView)e.Item.DataItem)["FunctionID"]; selected.Attributes["id"] = id.ToString(); Label lblFunctionCode = (Label)e.Item.FindControl("FunctionCode"); if (lblFunctionCode != null) { lblFunctionCode.Text = (string)((DataRowView)e.Item.DataItem)["FunctionCode"]; } Label lblDescription = (Label)e.Item.FindControl("Description"); if (lblDescription != null) { lblDescription.Text = HROne.Common.WebUtility.GetLocalizedStringByCode("FUNCTION_" + (string)((DataRowView)e.Item.DataItem)["FunctionCode"], (string)((DataRowView)e.Item.DataItem)["Description"]); } if (selectedFunctionList.ContainsKey(id)) { EUserGroupFunction o = (EUserGroupFunction)selectedFunctionList[id]; selected.Checked = o.FunctionAllowRead; wselected.Checked = o.FunctionAllowWrite; } //if (WebUtils.IsTrialVersion(Session)) //{ // selected.Checked = true; // selected.Disabled = true; // wselected.Checked = true; // wselected.Disabled = true; //} }
protected void Save_Click(object sender, EventArgs e) { EUserGroup c = new EUserGroup(); Hashtable values = new Hashtable(); binding.toValues(values); PageErrors errors = PageErrors.getErrors(db, Page.Master); errors.clear(); db.validate(errors, values); if (!errors.isEmpty()) { return; } db.parse(values, c); ArrayList selectedList = new ArrayList(); ArrayList unselectedList = new ArrayList(); foreach (RepeaterItem item in SystemPermissions.Items) { DoRepeaterItem(item, selectedList, unselectedList); } foreach (RepeaterItem item in SecurityPermissions.Items) { DoRepeaterItem(item, selectedList, unselectedList); } foreach (RepeaterItem item in PersonnelPermissions.Items) { DoRepeaterItem(item, selectedList, unselectedList); } foreach (RepeaterItem item in LeavePermissions.Items) { DoRepeaterItem(item, selectedList, unselectedList); } foreach (RepeaterItem item in PayrollPermissions.Items) { DoRepeaterItem(item, selectedList, unselectedList); } foreach (RepeaterItem item in MPFPermissions.Items) { DoRepeaterItem(item, selectedList, unselectedList); } foreach (RepeaterItem item in CostCenterPermissions.Items) { DoRepeaterItem(item, selectedList, unselectedList); } foreach (RepeaterItem item in AttendancePermissions.Items) { DoRepeaterItem(item, selectedList, unselectedList); } foreach (RepeaterItem item in TaxationPermissions.Items) { DoRepeaterItem(item, selectedList, unselectedList); } foreach (RepeaterItem item in TrainingPermissions.Items) { DoRepeaterItem(item, selectedList, unselectedList); } //foreach (RepeaterItem item in ReportPermissions.Items) // DoRepeaterItem(item, list, unselectedList); foreach (RepeaterItem item in PersonnelReportsPermissions.Items) { DoRepeaterItem(item, selectedList, unselectedList); } foreach (RepeaterItem item in PayrollReportsPermissions.Items) { DoRepeaterItem(item, selectedList, unselectedList); } foreach (RepeaterItem item in TaxationReportsPermissions.Items) { DoRepeaterItem(item, selectedList, unselectedList); } foreach (RepeaterItem item in eChannelPermissions.Items) { DoRepeaterItem(item, selectedList, unselectedList); } if (checkUserSecurityAccess) { if (IsSuperUserMissing(CurID)) { errors.addError("The system should be least 1 user allowed to access User Group Setup and User Maintenance"); errors.addError(HROne.Translation.PageErrorMessage.ERROR_ACTION_ABORT); } } if (!errors.isEmpty()) { return; } WebUtils.StartFunction(Session, FUNCTION_CODE); if (CurID < 0) { // Utils.MarkCreate(Session, c); db.insert(dbConn, c); CurID = c.UserGroupID; // url = Utils.BuildURL(-1, CurID); } else { // Utils.Mark(Session, c); db.update(dbConn, c); } foreach (EUserGroupFunction o in selectedList) { o.UserGroupID = c.UserGroupID; DBFilter filter = new DBFilter(); filter.add(new Match("UserGroupID", c.UserGroupID)); filter.add(new Match("FunctionID", o.FunctionID)); ArrayList groupFunctionList = EUserGroupFunction.db.select(dbConn, filter); if (groupFunctionList.Count == 0) { EUserGroupFunction.db.insert(dbConn, o); } else { EUserGroupFunction updatedGroupFunction = (EUserGroupFunction)groupFunctionList[0]; if (updatedGroupFunction.FunctionAllowRead != o.FunctionAllowRead || updatedGroupFunction.FunctionAllowWrite != o.FunctionAllowWrite) { o.UserGroupFunctionID = updatedGroupFunction.UserGroupFunctionID; EUserGroupFunction.db.update(dbConn, o); } } } foreach (EUserGroupFunction o in unselectedList) { DBFilter filter = new DBFilter(); filter.add(new Match("UserGroupID", c.UserGroupID)); filter.add(new Match("FunctionID", o.FunctionID)); ArrayList groupFunctionList = EUserGroupFunction.db.select(dbConn, filter); if (groupFunctionList.Count != 0) { foreach (EUserGroupFunction groupFunction in groupFunctionList) { EUserGroupFunction.db.delete(dbConn, groupFunction); } } } WebUtils.EndFunction(dbConn); HROne.Common.WebUtility.RedirectURLwithEncryptedQueryString(Response, Session, "UserGroup_View.aspx?UserGroupID=" + CurID); }