private void BindRight() { cbx_RoleList1.DataSource = Roles.GetAllRoles(); cbx_RoleList1.DataBind(); cbx_RoleList2.DataSource = Roles.GetAllRoles(); cbx_RoleList2.DataBind(); cbx_RoleList3.DataSource = Roles.GetAllRoles(); cbx_RoleList3.DataBind(); IList <Rpt_FolderRight> rights = Rpt_FolderRightBLL.GetModelList("Folder = " + ViewState["ID"].ToString()); foreach (Rpt_FolderRight r in rights) { if (r.Based_On == 2) { ListItem item = null; switch (r.Action) { case 1: item = cbx_RoleList1.Items.FindByText(r.RoleName); break; case 2: item = cbx_RoleList2.Items.FindByText(r.RoleName); break; case 3: item = cbx_RoleList3.Items.FindByText(r.RoleName); break; default: break; } if (item != null) { item.Selected = true; } } } }
private void SaveRight() { foreach (ListItem item in cbx_RoleList2.Items) { IList <Rpt_FolderRight> rights = Rpt_FolderRightBLL.GetModelList("Folder = " + ViewState["ID"].ToString() + " AND Action = 2 AND Based_On = 2 AND RoleName='" + item.Text + "'"); if (item.Selected) { if (rights.Count == 0) { Rpt_FolderRightBLL bll = new Rpt_FolderRightBLL(); bll.Model.Folder = (int)ViewState["ID"]; bll.Model.Action = 2; bll.Model.Based_On = 2; bll.Model.RoleName = item.Text; bll.Model.InsertStaff = (int)Session["UserID"]; bll.Add(); } } else { if (rights.Count > 0) { new Rpt_FolderRightBLL(rights[0].ID).Delete(); } } } foreach (ListItem item in cbx_RoleList1.Items) { IList <Rpt_FolderRight> rights = Rpt_FolderRightBLL.GetModelList("Folder = " + ViewState["ID"].ToString() + " AND Action = 1 AND Based_On = 2 AND RoleName='" + item.Text + "'"); if (item.Selected) { if (rights.Count == 0 && !cbx_RoleList2.Items.FindByText(item.Text).Selected) { Rpt_FolderRightBLL bll = new Rpt_FolderRightBLL(); bll.Model.Folder = (int)ViewState["ID"]; bll.Model.Action = 1; bll.Model.Based_On = 2; bll.Model.RoleName = item.Text; bll.Model.InsertStaff = (int)Session["UserID"]; bll.Add(); } } else { if (rights.Count > 0) { new Rpt_FolderRightBLL(rights[0].ID).Delete(); } } } foreach (ListItem item in cbx_RoleList3.Items) { IList <Rpt_FolderRight> rights = Rpt_FolderRightBLL.GetModelList("Folder = " + ViewState["ID"].ToString() + " AND Action = 3 AND Based_On = 2 AND RoleName='" + item.Text + "'"); if (item.Selected) { if (rights.Count == 0 && !cbx_RoleList1.Items.FindByText(item.Text).Selected&& !cbx_RoleList2.Items.FindByText(item.Text).Selected) { Rpt_FolderRightBLL bll = new Rpt_FolderRightBLL(); bll.Model.Folder = (int)ViewState["ID"]; bll.Model.Action = 3; bll.Model.Based_On = 2; bll.Model.RoleName = item.Text; bll.Model.InsertStaff = (int)Session["UserID"]; bll.Add(); } } else { if (rights.Count > 0) { new Rpt_FolderRightBLL(rights[0].ID).Delete(); } } } }