protected void BindRoleMenuListBox() { string id = string.Format("Id: {0} Uri: {1}", Guid.NewGuid(), HttpContext.Current.Request.Url); using (Utils utility = new Utils()) { utility.MethodStart(id, System.Reflection.MethodBase.GetCurrentMethod()); } try { _objMenu = new Bill_Sys_Menu(); lstMenusToRole.DataSource = _objMenu.GetSelectedMenu(extCIddlRoleName.Text); lstMenusToRole.DataTextField = "MENU"; lstMenusToRole.DataValueField = "i_menu_id"; lstMenusToRole.DataBind(); if (extCIddlMainMenu.Text != "NA") { lstMenu.DataSource = _objMenu.GetChildMenu(Convert.ToInt32(extCIddlMainMenu.Text)); lstMenu.DataTextField = "SZ_MENU_NAME"; lstMenu.DataValueField = "I_MENU_ID"; lstMenu.DataBind(); } } catch (Exception ex) { Elmah.ErrorSignal.FromCurrentContext().Raise(ex); using (Utils utility = new Utils()) { utility.MethodEnd(id, System.Reflection.MethodBase.GetCurrentMethod()); } string str2 = "Error Request=" + id + ".Please share with Technical support."; base.Response.Redirect("Bill_Sys_ErrorPage.aspx?ErrMsg=" + str2); } //Method End using (Utils utility = new Utils()) { utility.MethodEnd(id, System.Reflection.MethodBase.GetCurrentMethod()); } }
protected void BindTreeView() { string id = string.Format("Id: {0} Uri: {1}", Guid.NewGuid(), HttpContext.Current.Request.Url); using (Utils utility = new Utils()) { utility.MethodStart(id, System.Reflection.MethodBase.GetCurrentMethod()); } try { foreach (TreeNode treenode in tvwmenu.Nodes[0].ChildNodes) { if (treenode.ChildNodes.Count > 0) { foreach (TreeNode childTreenode in treenode.ChildNodes) { childTreenode.Checked = false; } } treenode.Checked = false; } //string connString = ConfigurationManager.AppSettings["Connection_String"]; //SqlConnection connection = new SqlConnection(connString); //SqlCommand command = new SqlCommand("select i_menu_id from TXN_USER_ACCESS where SZ_USER_ROLE_ID = '" + ddlUserRole.SelectedValue + "'", connection); //SqlDataAdapter adapter = new SqlDataAdapter(command); objBillSysMenu = new Bill_Sys_Menu(); DataSet ChildMenuTable = new DataSet(); ChildMenuTable = objBillSysMenu.GetSelectedMenu(ddlUserRole.SelectedValue); // adapter.Fill(ChildMenuTable); if (ChildMenuTable.Tables.Count > 0) { foreach (DataRow row in ChildMenuTable.Tables[0].Rows) { String menuid = row["i_menu_id"].ToString(); foreach (TreeNode treenode in tvwmenu.Nodes[0].ChildNodes) { if (treenode.ChildNodes.Count > 0) { TreeNode parentTreenode = new TreeNode(); TreeNode _parentTreenode = new TreeNode(); parentTreenode = treenode; Boolean status = false; int st = 1; sa: foreach (TreeNode childTreenode in parentTreenode.ChildNodes) { if (childTreenode.Value == menuid) { status = false; childTreenode.Checked = true; break; } if (childTreenode.ChildNodes.Count > 0) { status = true; _parentTreenode = parentTreenode; parentTreenode = childTreenode; goto sa; } if (status == true && parentTreenode.ChildNodes.Count == st) { status = false; parentTreenode = _parentTreenode; childTreenode.Parent.Checked = true; } st = st + 1; } } if (treenode.Value == menuid) { treenode.Checked = true; break; } } } } } catch (Exception ex) { Elmah.ErrorSignal.FromCurrentContext().Raise(ex); using (Utils utility = new Utils()) { utility.MethodEnd(id, System.Reflection.MethodBase.GetCurrentMethod()); } string str2 = "Error Request=" + id + ".Please share with Technical support."; base.Response.Redirect("Bill_Sys_ErrorPage.aspx?ErrMsg=" + str2); } //Method End using (Utils utility = new Utils()) { utility.MethodEnd(id, System.Reflection.MethodBase.GetCurrentMethod()); } }