//--Events /// <summary> /// On Function Check Get the users list from the selected Function /// </summary> protected void chklstDept_SelectedIndexChanged(object sender, EventArgs e) { try { BLL_PURC_Permissions objPermsn = new BLL_PURC_Permissions(); string dep = GetDepartmentIDList(); string accessid = string.Empty; DataSet dsuser = objPermsn.PURC_GetDepartmentUsers(dep, accessid); chklstUser.Items.Clear(); chklstUser.DataSource = dsuser.Tables[0]; chklstUser.DataTextField = "UserName"; chklstUser.DataValueField = "UserID"; chklstUser.DataBind(); chklstUser.Items.Insert(0, new ListItem("-ALL-", "0")); for (int i = 0; i < chklstUser.Items.Count; i++) { DataRow[] foundUser = dsuser.Tables[1].Select("UserID = '" + chklstUser.Items[i].Value + "'"); if (foundUser.Length != 0) { chklstUser.Items[i].Selected = true; } } if (rbtAccessType.SelectedValue == "Department") { TDUserlist.Visible = false; } else { //DataTable dt_tosave = new DataTable(); //dt_tosave.Merge(dt_Functions()); //dt_tosave.Merge(dt_Catalogue()); //dt_tosave.Merge(dt_SubCatalogue()); //TDUserlist.Visible = true; //DataTable dt = objPermsn.PURC_GET_PermitedUsers(dt_tosave, GetAccessUserDepList("Department"), rbtAccessType.SelectedValue.ToUpper()).Tables[0]; //foreach (DataRow row in dt.Rows) //{ // if (row["UserID"].ToString() != "0") // { // foreach (ListItem item in chklstUser.Items) // { // if (row["UserID"].ToString() == item.Value.ToString()) // { // item.Selected = true; // break; // } // } // } //} } } catch (Exception ex) { UDFLib.WriteExceptionLog(ex); } }
/// <summary> /// set the Access type and AccessID /// ( if user do not selects the Function ,Cataloge and Subcatalogue then AccessType="Function" and AccessID=0; /// if user selects Function and don't select Cataloge and Subcatalogue then AccessType="Function" and AccessID=(function dropdown selected Value ,ie FunctionID); /// if User selects Function and Catalogue but don't select Subcatalogue then AccessType = "CATALOGUE" and AccessID=(Catalogue dropdown selected Value , ie Catalogue); /// if User selects Function , Catalogue and Subcatalogue then AccessType = "SUBCATALOGUE" and AccessID=(Subcatalogue dropdown selected Value , ie SubcatalogueId);) and saves the Permissions for the selected Users /// </summary> public void btnSaveE_Click(object sender, EventArgs e) // Save Permissions { string msg = ""; if (rbtAccessType.SelectedValue == "Department") { if (chklstDept.SelectedValue.Count() > 0) { string accesstype = ""; string accessid = ""; DataTable dt_tosave = new DataTable(); dt_tosave.Merge(dt_Functions()); dt_tosave.Merge(dt_Catalogue()); dt_tosave.Merge(dt_SubCatalogue()); BLL_PURC_Permissions sp = new BLL_PURC_Permissions(); string departmentId = GetDepartmentIDList(); sp.SavePermissions(dt_tosave, GetAccessUserDepList(rbtAccessType.SelectedValue), accessid, accesstype, GetSessionUserID(), GetDepartmentIDList(), "DEPARTMENT"); msg = "alert('Permission Added Succesfully');"; } else { msg = "alert('Please Select the Department');"; } } else { if (chklstUser.SelectedValue.Count() > 0) { string accesstype = ""; string accessid = ""; DataTable dt_tosave = new DataTable(); dt_tosave.Merge(dt_Functions()); dt_tosave.Merge(dt_Catalogue()); dt_tosave.Merge(dt_SubCatalogue()); BLL_PURC_Permissions sp = new BLL_PURC_Permissions(); string departmentId = GetDepartmentIDList(); sp.SavePermissions(dt_tosave, GetAccessUserDepList(rbtAccessType.SelectedValue), accessid, accesstype, GetSessionUserID(), GetDepartmentIDList(), "User"); msg = "alert('Permission Added Succesfully');"; } else { msg = "alert('Please Select the User');"; } } ScriptManager.RegisterStartupScript(Page, Page.GetType(), "msg", msg, true); }