From: <ro...@us...> - 2006-08-08 21:27:07
|
Revision: 284 Author: rouquin Date: 2006-08-08 14:26:55 -0700 (Tue, 08 Aug 2006) ViewCVS: http://svn.sourceforge.net/tcdb/?rev=284&view=rev Log Message: ----------- I ran into a ton of merging conflicts but here's some new stuff. I moved the role assignments to a new page. Modified Paths: -------------- Website/App_Code/Assignments.cs Website/Includes/AssignmentsTree.ascx.cs Website/Includes/RoleAdmin.ascx.cs Website/Includes/Roles.ascx Website/Includes/Roles.ascx.cs Added Paths: ----------- Website/Includes/RoleAssignments.ascx Website/Includes/RoleAssignments.ascx.cs Website/RoleAssignments.aspx Modified: Website/App_Code/Assignments.cs =================================================================== --- Website/App_Code/Assignments.cs 2006-08-08 20:56:12 UTC (rev 283) +++ Website/App_Code/Assignments.cs 2006-08-08 21:26:55 UTC (rev 284) @@ -9,7 +9,6 @@ using System.Web.UI.WebControls.WebParts; using System.Web.UI.HtmlControls; - namespace TCDB.Code { public class AssignmentDB @@ -291,7 +290,7 @@ private User p_creator; private User p_assigned; private DateTime p_dateAssigned; - private DateTime p_dateFinished; + private Nullable<DateTime> p_dateFinished; private DateTime p_dateDue; private WorkOrder p_workOrder; private ActionItem p_actionItem; @@ -311,7 +310,7 @@ p_creator = new User(); p_assigned = new User(); p_dateAssigned = new DateTime(1, 1, 1); - p_dateFinished = new DateTime(1, 1, 1); + p_dateFinished = null; p_dateDue = new DateTime(1, 1, 1); p_workOrder = null; p_actionItem = null; @@ -355,7 +354,7 @@ set { p_dateAssigned = value; } } - public DateTime DATEFINISHED + public Nullable<DateTime> DATEFINISHED { get { return p_dateFinished; } set { p_dateFinished = value; } Modified: Website/Includes/AssignmentsTree.ascx.cs =================================================================== --- Website/Includes/AssignmentsTree.ascx.cs 2006-08-08 20:56:12 UTC (rev 283) +++ Website/Includes/AssignmentsTree.ascx.cs 2006-08-08 21:26:55 UTC (rev 284) @@ -344,14 +344,16 @@ else continue; } if (a.DELETED) - { child.Text = "<font class='deleted'>" + child.Text + "</font>"; - } + else if (a.DATEFINISHED != null) + child.Text = "<font class='finished'>" + child.Text + "</font>"; + else if (a.DATEDUE < DateTime.Today) + child.Text = "<font class='overdue'>" + child.Text + "</font>"; // Add the new child node to the ChildNodes collection of the parent node. parent.ChildNodes.Add(child); } - + // if there are no assignments if (parent.ChildNodes.Count == 0) parent.Parent.ChildNodes.Remove(parent); Modified: Website/Includes/RoleAdmin.ascx.cs =================================================================== --- Website/Includes/RoleAdmin.ascx.cs 2006-08-08 20:56:12 UTC (rev 283) +++ Website/Includes/RoleAdmin.ascx.cs 2006-08-08 21:26:55 UTC (rev 284) @@ -15,11 +15,13 @@ { public partial class RoleAdmin : SiteUserControl { - private static Logger m_logg = new Logger("TCDB.Authenticate"); + private static Logger m_logg = new Logger("TCDB.RoleAdmin"); int productID = Convert.ToInt32(HttpContext.Current.Request.QueryString[Constants.CODE_PRODUCT]); protected void Page_Load(object sender, EventArgs e) { + m_logg.Debug("Loading page Role Admin"); + if (productID == 0) productID = Constants.PRODUCT_ANYID; } @@ -30,7 +32,7 @@ } protected void addRole(object sender, CommandEventArgs e) { - Response.Redirect("Role.aspx?mode=edit&" + Constants.CODE_PRODUCT + "=" + productID + "&" + Constants.CODE_ROLE + "=" + roleList.SelectedValue); + Response.Redirect("RoleAssignments.aspx?" + Constants.CODE_PRODUCT + "=" + productID + "&" + Constants.CODE_ROLE + "=" + roleList.SelectedValue); } protected void newRole(object sender, CommandEventArgs e) { @@ -84,15 +86,15 @@ return; } - if (!m_user.HasRight("dev_access")) + if (!m_user.HasRight("dev_access")) editRightsBtn.Visible = false; - List<Right> rights = RightDB.TCDB_GetRightList(active); + List<Right> rights = RightDB.TCDB_GetRightList(active); - foreach (Right right in rights) + foreach (Right right in rights) { - ListItem item = new ListItem(right.NAME, right.ID.ToString()); - if (!right.ACTIVE) + ListItem item = new ListItem(right.NAME, right.ID.ToString()); + if (!right.ACTIVE) item.Attributes.CssStyle.Add("text-decoration", "line-through"); rightsList.Items.Add(item); @@ -114,6 +116,5 @@ !m_user.HasRight("view_other_roles", productID)) viewRoleBtn.Visible = false; } - } } Added: Website/Includes/RoleAssignments.ascx =================================================================== --- Website/Includes/RoleAssignments.ascx (rev 0) +++ Website/Includes/RoleAssignments.ascx 2006-08-08 21:26:55 UTC (rev 284) @@ -0,0 +1,26 @@ +<%@ Control Language="C#" AutoEventWireup="true" CodeFile="RoleAssignments.ascx.cs" + Inherits="RoleAssignments" %> +<table width="700"> + <tr> + <td> + <h2> + <asp:LinkButton ID="roleNameBtn" runat="server" OnClick="roleNameBtn_Click"></asp:LinkButton></h2> + </td> + <td> + <asp:Button ID="Update" runat="server" Text="Update" OnClick="Update_Click"></asp:Button> + </td> + </tr> + <tr> + <td align="left" valign="top"> + <strong>Products: </strong><asp:DropDownList ID="productList" runat="server" + AutoPostBack="True" OnSelectedIndexChanged="productList_SelectedIndexChanged" + OnInit="productList_Init"> + </asp:DropDownList> + </td> + <td> + <strong>Users:</strong><br /> + <asp:ListBox ID="userList" runat="server" SelectionMode="Multiple" Height="500px" + Width="200px"></asp:ListBox> + </td> + </tr> +</table> Added: Website/Includes/RoleAssignments.ascx.cs =================================================================== --- Website/Includes/RoleAssignments.ascx.cs (rev 0) +++ Website/Includes/RoleAssignments.ascx.cs 2006-08-08 21:26:55 UTC (rev 284) @@ -0,0 +1,175 @@ +using System; +using System.Data; +using System.Configuration; +using System.Web; +using System.Web.Security; +using System.Web.UI; +using System.Web.UI.WebControls; +using System.Web.UI.WebControls.WebParts; +using System.Web.UI.HtmlControls; +using System.Collections.Generic; +using System.Collections; +using TCDB; +using TCDB.Code; +using log4net; + +public partial class RoleAssignments : SiteUserControl +{ + private static ILog m_logg = LogManager.GetLogger("Page:Role Assignments"); + Role role; + int roleID = Convert.ToInt32(HttpContext.Current.Request.QueryString[Constants.CODE_ROLE]); + int productID = Convert.ToInt32(HttpContext.Current.Request.QueryString[Constants.CODE_PRODUCT]); + + protected void Page_Load(object sender, EventArgs e) + { + // Check roleID + if (roleID == 0) + { + m_logg.Info("Could not find role"); + Response.Redirect("~/Administration.aspx"); + } + role = RightDB.GetRoleInfo(roleID); + + // Check rights + if (!m_user.HasRight("edit_role_users",Constants.PRODUCT_ANYID)) + Response.Redirect("~/Administration.aspx"); + + roleNameBtn.Text = role.NAME; + } + + protected void updateUserRoleProducts() + { + Dictionary<int, ArrayList> ProductUsers = (Dictionary<int, ArrayList>)Session["ProductUsers"]; + if (ProductUsers == null) + return; + tcdbDataSetTableAdapters.db_roleUserProductTableAdapter rupAdapter = new tcdbDataSetTableAdapters.db_roleUserProductTableAdapter(); + + // Update ProductUsers + int[] indices = userList.GetSelectedIndices(); + ArrayList users = new ArrayList(); + foreach (int index in indices) + users.Add(userList.Items[index].Value); + if (ProductUsers.ContainsKey(Convert.ToInt32(productList.SelectedValue))) + ProductUsers[Convert.ToInt32(productList.SelectedValue)] = users; + + foreach (ListItem product in productList.Items) + { + /* + String productID = item.Value; + + // Clear list + rupAdapter.upd_userRoleProduct(null,null,Convert.ToInt32(productID),false); + + // update ProductUser roles + if (ProductUsers.ContainsKey(productID)) + { + foreach (String userID in ProductUsers[productID]) + rupAdapter.ins_userRoleProduct(Convert.ToInt32(userID),roleID,Convert.ToInt32(productID)); + } + */ + int productID = Convert.ToInt32(product.Value); + foreach (ListItem user in userList.Items) + { + int userID = Convert.ToInt32(user.Value); + + if (ProductUsers.ContainsKey(productID) && ProductUsers[productID].Contains(userID.ToString())) + rupAdapter.ins_userRoleProduct(userID, roleID, productID); + else + rupAdapter.upd_userRoleProduct(userID, roleID, productID, false); + } + } + } + protected void updateProductUsers() + { + // Init ProductUsers + Dictionary<int, ArrayList> ProductUsers = new Dictionary<int, ArrayList>(); + List<Product> products = ProductDB.GetProductList(active); + + foreach (Product product in products) + { + ArrayList users = new ArrayList(); + + tcdbDataSetTableAdapters.db_roleProductUserTableAdapter roleProductUserAdapter = new tcdbDataSetTableAdapters.db_roleProductUserTableAdapter(); + tcdbDataSet.db_roleProductUserDataTable roleProductUserTable = roleProductUserAdapter.GetData(roleID, product.ID, true); + + foreach (tcdbDataSet.db_roleProductUserRow row in roleProductUserTable) + users.Add(row.userID.ToString()); + + ProductUsers[product.ID] = users; + } + Session["ProductUsers"] = ProductUsers; + } + + protected void productList_Init(object sender, EventArgs e) + { + List<Product> products = ProductDB.GetProductList(active); + foreach (Product product in products) + if (m_user.HasRight("edit_role_users", product.ID)) + productList.Items.Add(new ListItem(product.NAME, product.ID.ToString())); + + // Set selected value + if (productList.Items.FindByValue(productID.ToString()) != null && m_user.HasRight("edit_role_users", productID)) + productList.SelectedValue = productID.ToString(); + Session["product"] = productList.SelectedValue; + + userList_populate(Convert.ToInt32(productList.SelectedValue)); + } + protected void productList_SelectedIndexChanged(object sender, EventArgs e) + { + // Get Product Users + if (Session["ProductUsers"] == null) + updateProductUsers(); + Dictionary<int, ArrayList> ProductUsers = (Dictionary<int, ArrayList>)Session["ProductUsers"]; + + // update selected product + if (Session["product"] != null) + { + int productID = Convert.ToInt32(Session["product"]); + + // Update ProductUsers + int[] indices = userList.GetSelectedIndices(); + ArrayList users = new ArrayList(); + foreach (int index in indices) + users.Add(userList.Items[index].Value); + if (ProductUsers.ContainsKey(productID)) + ProductUsers[productID] = users; + } + Session["product"] = productList.SelectedValue; + + // Update userlist + userList_populate(Convert.ToInt32(productList.SelectedValue)); + } + + protected void userList_populate(int productID) + { + // Get ProductUsers + updateProductUsers(); + Dictionary<int, ArrayList> ProductUsers = (Dictionary<int, ArrayList>)Session["ProductUsers"]; + + // Init selected user list + ArrayList users; + if (ProductUsers.ContainsKey(productID)) + users = ProductUsers[productID]; + else + users = new ArrayList(); + + // populate user list + userList.Items.Clear(); + List<User> usersList = UserDB.TCDB_GetUserList(); + foreach (User user in usersList) + { + ListItem item = new ListItem(user.FULLNAME, user.ID.ToString()); + if (users.Contains(user.ID.ToString())) + item.Selected = true; + userList.Items.Add(item); + } + } + protected void Update_Click(object sender, EventArgs e) + { + updateUserRoleProducts(); + } + protected void roleNameBtn_Click(object sender, EventArgs e) + { + Response.Redirect("~/Role.aspx?" + Constants.CODE_PRODUCT + "=" + productID + "&" + Constants.CODE_ROLE + "=" + roleID); + } +} Modified: Website/Includes/Roles.ascx =================================================================== --- Website/Includes/Roles.ascx 2006-08-08 20:56:12 UTC (rev 283) +++ Website/Includes/Roles.ascx 2006-08-08 21:26:55 UTC (rev 284) @@ -7,9 +7,11 @@ <div align="left"> <h2> User Role</h2> - </div><div align="right"> + </div> + <div align="right"> <asp:Label ID="activeLbl" runat="server" Text="Active"></asp:Label> - <asp:CheckBox ID="activeBox" runat="server" AutoPostBack="True" OnCheckedChanged="activeBox_CheckedChanged" OnInit="activeBox_Init" /></div> + <asp:CheckBox ID="activeBox" runat="server" AutoPostBack="True" OnCheckedChanged="activeBox_CheckedChanged" + OnInit="activeBox_Init" /></div> </HeaderTemplate> <ItemTemplate> <div class="xsnazzy"> @@ -40,6 +42,9 @@ <asp:Panel ID="ProductUserPanel" runat="server" Height="100%" Width="100%" OnInit="ProductUserPanel_Init" ScrollBars="Horizontal" Wrap="False"> </asp:Panel> + <br /> + <asp:LinkButton ID="editAssignments" runat="server" CommandName="editAssignments" + OnCommand="editAssignments_Command">Edit Role Assignments</asp:LinkButton> </td> <td colspan="2" align="left" valign="top" width="34%" style="height: 132px"> <strong>Rights:</strong><br /> @@ -54,9 +59,9 @@ <tr> <td align="left" colspan="6"> <asp:LinkButton ID="New" runat="server" CommandName="new" OnInit="New_Init">New</asp:LinkButton><asp:Label - ID="newLbl" runat="server" Text=" | "></asp:Label><asp:LinkButton - ID="Edit" runat="server" CommandName="edit" OnInit="Edit_Init">Edit</asp:LinkButton><asp:Label ID="deleteLbl" - runat="server" Text=" | "></asp:Label><asp:LinkButton ID="Delete" + ID="newLbl" runat="server" Text=" | "></asp:Label><asp:LinkButton ID="Edit" + runat="server" CommandName="edit" OnInit="Edit_Init">Edit</asp:LinkButton><asp:Label + ID="deleteLbl" runat="server" Text=" | "></asp:Label><asp:LinkButton ID="Delete" runat="server" CommandName="deleteCmd" OnCommand="deleteCmd" OnLoad="Delete_Load">Delete</asp:LinkButton></td> </tr> </table> @@ -76,8 +81,8 @@ <tr> <td align="left" colspan="6"> <strong>Name:</strong> - <asp:TextBox ID="nameBox" runat="server" Text='<%# Bind("roleName") %>' Width="70%" OnLoad="nameBox_Load"></asp:TextBox> - <asp:Label ID="nameLbl" runat="server" Text='<%# Eval("roleName") %>' Visible="False"></asp:Label></td> + <asp:TextBox ID="nameBox" runat="server" Text='<%# Bind("roleName") %>' Width="70%"></asp:TextBox> + </td> </tr> <tr> <td class="hr" colspan="6"> @@ -90,8 +95,7 @@ Width="100%" Text='<%# Bind("roleDescription") %>' Height="200px" EnableHtmlMode="true" DisableIEBackButton="False"> </FTB:FreeTextBox> - <asp:Label ID="descriptionLbl" runat="server" Text='<%# Eval("roleDescription") %>' - Visible="False"></asp:Label></td> + </td> </tr> <tr> <td class="hr" colspan="6"> @@ -99,22 +103,16 @@ </tr> <tr> <td colspan="2" align="left" valign="top" width="33%"> - <strong>Products: <asp:DropDownList ID="productList" runat="server" AutoPostBack="True" - OnSelectedIndexChanged="productList_SelectedIndexChanged" OnInit="productList_Init"> - </asp:DropDownList></strong> </td> + </td> <td colspan="2" align="left" valign="top" width="33%"> - <strong>Users:<br /> - </strong> - <asp:ListBox ID="userList" runat="server" SelectionMode="Multiple" - Height="150px" Width="150px" OnInit="userList_Init"></asp:ListBox></td> + </td> <td colspan="2" align="left" valign="top" width="34%"> <strong>Rights:<br /> - <asp:LinkButton ID="newRight" runat="server" CommandName="newRight" OnCommand="newRight" - OnInit="newRight_Init">New Right</asp:LinkButton><br /> + <asp:LinkButton ID="newRight" runat="server" CommandName="newRight" OnCommand="newRight">New Right</asp:LinkButton><br /> </strong> <asp:ListBox ID="rightsList" runat="server" DataSourceID="RightsDataSource" DataTextField="rightsName" DataValueField="rightsID" SelectionMode="Multiple" - Height="150px" OnDataBound="rightsList_DataBound" Width="150px" OnInit="rightsList_Init"></asp:ListBox> - </td> + Height="150px" OnDataBound="rightsList_DataBound" Width="150px"> + </asp:ListBox> </td> </tr> <tr> <td class="hr" colspan="6"> @@ -167,15 +165,9 @@ </tr> <tr> <td colspan="2" align="left" valign="top" width="33%"> - <strong>Products: </strong><asp:DropDownList ID="productList" runat="server" - AutoPostBack="True" OnSelectedIndexChanged="productList_SelectedIndexChanged" OnInit="productList_Init"> - </asp:DropDownList> - </td> + </td> <td colspan="2" align="left" valign="top" width="33%"> - <strong>Users:<br /> - </strong> - <asp:ListBox ID="userList" runat="server" SelectionMode="Multiple" - Height="150px" Width="150px"></asp:ListBox></td> + </td> <td colspan="2" align="left" valign="top" width="34%"> <strong>Rights: <asp:LinkButton ID="newRight" runat="server" CommandName="newRight" OnCommand="newRight">New Right</asp:LinkButton><br /> Modified: Website/Includes/Roles.ascx.cs =================================================================== --- Website/Includes/Roles.ascx.cs 2006-08-08 20:56:12 UTC (rev 283) +++ Website/Includes/Roles.ascx.cs 2006-08-08 21:26:55 UTC (rev 284) @@ -11,17 +11,17 @@ using System.Web.UI.HtmlControls; using System.Data.SqlClient; using TCDB.Code; +using log4net; - namespace TCDB { public partial class TCDBRoles : SiteUserControl { - private static Logger m_logg = new Logger("TCDB.TCDBRoles"); + private static ILog m_logg = LogManager.GetLogger("Page:TCDBRoles"); int roleID = Convert.ToInt32(HttpContext.Current.Request.QueryString[Constants.CODE_ROLE]); Role role; String mode = HttpContext.Current.Request.QueryString["mode"]; - String productID_in = HttpContext.Current.Request.QueryString[Constants.CODE_PRODUCT]; + String productID = HttpContext.Current.Request.QueryString[Constants.CODE_PRODUCT]; protected void Page_Load(object sender, EventArgs e) { @@ -54,49 +54,31 @@ FormView1.ChangeMode(FormViewMode.Edit); } - protected void updateUserRoleProducts() + protected void updateProductUsers() { - DropDownList productList = (DropDownList)FormView1.FindControl("productList"); - ListBox userList = (ListBox)FormView1.FindControl("userList"); - Dictionary<String, ArrayList> ProductUsers = (Dictionary<String, ArrayList>)Session["ProductUsers"]; - if (ProductUsers == null) + // Init ProductUsers + Dictionary<int, ArrayList> ProductUsers = new Dictionary<int, ArrayList>(); + + if (FormView1.CurrentMode == FormViewMode.Insert) return; - tcdbDataSetTableAdapters.db_roleUserProductTableAdapter rupAdapter = new tcdbDataSetTableAdapters.db_roleUserProductTableAdapter(); - // Update ProductUsers - int[] indices = userList.GetSelectedIndices(); - ArrayList users = new ArrayList(); - foreach (int index in indices) - users.Add(userList.Items[index].Value); - if (ProductUsers.ContainsKey(productList.SelectedValue)) - ProductUsers[productList.SelectedValue] = users; - - foreach (ListItem product in productList.Items) + foreach (Product product in ProductDB.GetProductList(active)) { - /* - String productID = item.Value; + ArrayList users = new ArrayList(); + int productID = product.ID; - // Clear list - rupAdapter.upd_userRoleProduct(null,null,Convert.ToInt32(productID),false); + tcdbDataSetTableAdapters.db_roleProductUserTableAdapter roleProductUserAdapter = new tcdbDataSetTableAdapters.db_roleProductUserTableAdapter(); + tcdbDataSet.db_roleProductUserDataTable roleProductUserTable = roleProductUserAdapter.GetData(roleID, productID, true); - // update ProductUser roles - if (ProductUsers.ContainsKey(productID)) - { - foreach (String userID in ProductUsers[productID]) - rupAdapter.ins_userRoleProduct(Convert.ToInt32(userID),roleID,Convert.ToInt32(productID)); - } - */ - int productID = Convert.ToInt32(product.Value); - foreach (ListItem user in userList.Items) - { - int userID = Convert.ToInt32(user.Value); + foreach (tcdbDataSet.db_roleProductUserRow row in roleProductUserTable) + users.Add(row.userID.ToString()); - if (ProductUsers.ContainsKey(productID.ToString()) && ProductUsers[productID.ToString()].Contains(userID.ToString())) - rupAdapter.ins_userRoleProduct(userID, roleID, productID); - else - rupAdapter.upd_userRoleProduct(userID, roleID, productID, false); - } + if (ProductUsers.ContainsKey(product.ID)) + ProductUsers[product.ID] = users; + else + ProductUsers.Add(product.ID, users); } + Session["ProductUsers"] = ProductUsers; } protected void updateRoleRights() { @@ -104,30 +86,10 @@ // Clear roles tcdbDataSetTableAdapters.db_roleRightTableAdapter rrAdapter = new tcdbDataSetTableAdapters.db_roleRightTableAdapter(); - rrAdapter.DeleteRoleRights(roleID,null); + rrAdapter.DeleteRoleRights(roleID, null); - // Update roles - int[] indices = rightsList.GetSelectedIndices(); - foreach (int index in indices) - { - int rightsID = Convert.ToInt32(rightsList.Items[index].Value); - - rrAdapter.InsertRoleRights(roleID,rightsID); - } - /* - tcdbDataSetTableAdapters.db_roleRightTableAdapter rrAdapter = new tcdbDataSetTableAdapters.db_roleRightTableAdapter(); - foreach (ListItem item in rightsList.Items) - { - int rightsID = Convert.ToInt32(item.Value); - - if (item.Selected) - rrAdapter.InsertRoleRights(roleID, rightsID); - else - rrAdapter.DeleteRoleRights(roleID, rightsID); - } - * */ - } + protected void FormView1_ItemInserted(object sender, FormViewInsertedEventArgs e) { tcdbDataSetTableAdapters.db_roleTableAdapter roleAdapter = new tcdbDataSetTableAdapters.db_roleTableAdapter(); @@ -137,7 +99,6 @@ { roleID = roleTable[roleTable.Count - 1].roleID; - updateUserRoleProducts(); updateRoleRights(); Session.Remove("tableName"); Response.Redirect("~/Role.aspx?" + Constants.CODE_ROLE + "=" + roleID); @@ -151,7 +112,6 @@ } protected void FormView1_ItemUpdated(object sender, FormViewUpdatedEventArgs e) { - updateUserRoleProducts(); updateRoleRights(); Session.Remove("tableName"); Response.Redirect("~/Role.aspx?" + Constants.CODE_ROLE + "=" + roleID); @@ -169,29 +129,14 @@ { if (FormView1.CurrentMode == FormViewMode.Insert && e.CommandName == "Cancel") { - Session.Remove("tableName"); - Response.Redirect("~/Administration.aspx"); - } - } - - protected void userList_DataBound(object sender, EventArgs e) - { - Dictionary<String, ArrayList> ProductUsers = (Dictionary<String, ArrayList>)Session["ProductUsers"]; - - if (ProductUsers != null) - { - ListBox userList = (ListBox)sender; - DropDownList productList = (DropDownList)FormView1.FindControl("productList"); - String productID = productList.SelectedValue; - userList.ClearSelection(); - - if (ProductUsers.ContainsKey(productID)) + if (FormView1.CurrentMode == FormViewMode.Insert && e.CommandName == "Cancel") { - foreach (String userID in ProductUsers[productID]) - userList.Items.FindByValue(userID).Selected = true; + Session.Remove("tableName"); + Response.Redirect("~/Administration.aspx"); } } } + protected void rightsList_DataBound(object sender, EventArgs e) { ListBox rightsList = (ListBox)sender; @@ -207,98 +152,24 @@ item.Attributes.CssStyle.Add("text-decoration", "line-through"); } } - - protected void addUsers(object sender, CommandEventArgs e) - { - updateUserRoleProducts(); - } protected void newRight(object sender, CommandEventArgs e) { Response.Redirect("Right.aspx?mode=new&" + Constants.CODE_ROLE + "=" + roleID); } - protected void productList_SelectedIndexChanged(object sender, EventArgs e) - { - ListBox userList = (ListBox)FormView1.FindControl("userList"); - DropDownList productList = (DropDownList)sender; - - // Check for bad state - if (FormView1.CurrentMode == FormViewMode.Edit) - { - FreeTextBoxControls.FreeTextBox ftb = (FreeTextBoxControls.FreeTextBox)FormView1.FindControl("descriptionBox"); - if (ftb.Text == "") - FormView1.DataBind(); - } - - // Get Product Users - if (Session["ProductUsers"] == null) - updateProductUsers(); - Dictionary<String, ArrayList> ProductUsers = (Dictionary<String, ArrayList>)Session["ProductUsers"]; - - // update selected product - String productID; - if (Session["product"] != null) - { - productID = Session["product"].ToString(); - - // Update ProductUsers - int[] indices = userList.GetSelectedIndices(); - ArrayList users = new ArrayList(); - foreach (int index in indices) - users.Add(userList.Items[index].Value); - if (ProductUsers.ContainsKey(productID)) - ProductUsers[productID] = users; - } - - Session["product"] = productList.SelectedValue; - // Update userlist - userList_populate(); - } - protected void updateProductUsers() - { - // Init ProductUsers - if (Session["ProductUsers"] == null) - Session.Add("ProductUsers", new Dictionary<String, ArrayList>()); - Dictionary<String, ArrayList> ProductUsers = (Dictionary<String, ArrayList>)Session["ProductUsers"]; - ProductUsers.Clear(); - - if (FormView1.CurrentMode == FormViewMode.Insert) - return; - - tcdbDataSetTableAdapters.db_productsTableAdapter pAdapter = new tcdbDataSetTableAdapters.db_productsTableAdapter(); - tcdbDataSet.db_productsDataTable pTable = pAdapter.GetData(active, null, null); - - foreach (tcdbDataSet.db_productsRow pRow in pTable) - { - ArrayList users = new ArrayList(); - String productID = pRow.productID.ToString(); - - tcdbDataSetTableAdapters.db_roleProductUserTableAdapter roleProductUserAdapter = new tcdbDataSetTableAdapters.db_roleProductUserTableAdapter(); - tcdbDataSet.db_roleProductUserDataTable roleProductUserTable = roleProductUserAdapter.GetData(roleID, Convert.ToInt32(productID), true); - - foreach (tcdbDataSet.db_roleProductUserRow row in roleProductUserTable) - users.Add(row.userID.ToString()); - - if (ProductUsers.ContainsKey(productID)) - ProductUsers[productID] = users; - else - ProductUsers.Add(productID, users); - } - } - protected void ProductUserPanel_Init(object sender, EventArgs e) { Panel puPanel = (Panel)sender; - List<Product> products = ProductDB.GetProductList(active); + List<Product> products = ProductDB.GetProductList(active); - foreach (Product product in products) + foreach (Product product in products) { - Label ProductLbl = new Label(); - ProductLbl.Text = "<strong>"+product.CODENAME+": </strong>"; + Label ProductLbl = new Label(); + ProductLbl.Text = "<strong>" + product.CODENAME + ": </strong>"; tcdbDataSetTableAdapters.db_roleProductUserTableAdapter rpuAdapter = new tcdbDataSetTableAdapters.db_roleProductUserTableAdapter(); - tcdbDataSet.db_roleProductUserDataTable rpuTable = rpuAdapter.GetData(roleID, product.ID, true); + tcdbDataSet.db_roleProductUserDataTable rpuTable = rpuAdapter.GetData(roleID, product.ID, true); Label Users = new Label(); foreach (tcdbDataSet.db_roleProductUserRow row in rpuTable) @@ -313,7 +184,7 @@ if (Users.Text != "") { - puPanel.Controls.Add(ProductLbl); + puPanel.Controls.Add(ProductLbl); puPanel.Controls.Add(Users); puPanel.Controls.Add(html); } @@ -347,101 +218,28 @@ protected void Delete_Load(object sender, EventArgs e) { LinkButton deleteBtn = (LinkButton)sender; + LinkButton editBtn = (LinkButton)FormView1.FindControl("Edit"); Label deleteLbl = (Label)FormView1.FindControl("deleteLbl"); - Label activeLbl = (Label)FormView1.FindControl("activeLbl"); + Label newLbl = (Label)FormView1.FindControl("newLbl"); + Label activeLbl = (Label)FormView1.FindControl("activeLbl"); updateProductUsers(); - Dictionary<String, ArrayList> ProductUsers = (Dictionary<String, ArrayList>)Session["ProductUsers"]; + Dictionary<int, ArrayList> ProductUsers = (Dictionary<int, ArrayList>)Session["ProductUsers"]; - foreach (String productID in ProductUsers.Keys) + foreach (int productID in ProductUsers.Keys) { - if ( activeLbl.Visible == true || ((ProductUsers[productID].Count > 0) && !m_user.HasRight("delete_role", Convert.ToInt32(productID)))) + if (activeLbl.Visible == true || ((ProductUsers[productID].Count > 0) && !m_user.HasRight("delete_role", productID))) { deleteBtn.Visible = false; deleteLbl.Visible = false; } - } + if ((ProductUsers[productID].Count > 0) && !m_user.HasRight("edit_role", productID)) + { + editBtn.Visible = false; + newLbl.Visible = false; + } + } } - protected void rightsList_Init(object sender, EventArgs e) - { - ListBox rightsList = (ListBox)sender; - updateProductUsers(); - Dictionary<String, ArrayList> ProductUsers = (Dictionary<String, ArrayList>)Session["ProductUsers"]; - foreach (String productID in ProductUsers.Keys) - { - if (!m_user.HasRight("edit_role", Convert.ToInt32(productID))) - rightsList.Enabled = false; - } - } - protected void userList_Init(object sender, EventArgs e) - { - ListBox userList = (ListBox)sender; - - if (!m_user.HasRight("edit_role_users", Constants.PRODUCT_ANYID)) - userList.Enabled = false; - } - - protected void userList_populate() - { - ListBox userList = (ListBox)FormView1.FindControl("userList"); - int productID = Convert.ToInt32(Session["product"]); - - tcdbDataSetTableAdapters.db_usersTableAdapter uAdapter = new tcdbDataSetTableAdapters.db_usersTableAdapter(); - tcdbDataSet.db_usersDataTable uTable = uAdapter.GetData(null, null); - - updateProductUsers(); - Dictionary<String, ArrayList> ProductUsers = (Dictionary<String, ArrayList>)Session["ProductUsers"]; - - // Init selected user list - ArrayList users; - if (ProductUsers.ContainsKey(productID.ToString())) - users = ProductUsers[productID.ToString()]; - else - users = new ArrayList(); - - // populate user list - userList.Items.Clear(); - foreach (tcdbDataSet.db_usersRow row in uTable) - { - ListItem item = new ListItem(row.fullName, row.userID.ToString()); - if (users.Contains(row.userID.ToString())) - item.Selected = true; - userList.Items.Add(item); - } - } - protected void productList_Init(object sender, EventArgs e) - { - DropDownList productList = (DropDownList)sender; - - List<Product> products = ProductDB.GetProductList(active); - - foreach (Product product in products) - if (m_user.HasRight("edit_role_users", product.ID)) - productList.Items.Add(new ListItem(product.NAME, product.ID.ToString())); - - // Set selected value - if (FormView1.CurrentMode == FormViewMode.Edit && productList.Items.FindByValue(productID_in) != null && m_user.HasRight("edit_role_users", Convert.ToInt32(productID_in))) - productList.SelectedValue = productID_in; - Session["product"] = productList.SelectedValue; - - userList_populate(); - } - - protected void nameBox_Load(object sender, EventArgs e) - { - TextBox nameBox = (TextBox)FormView1.FindControl("nameBox"); - FreeTextBoxControls.FreeTextBox descriptionBox = (FreeTextBoxControls.FreeTextBox)FormView1.FindControl("descriptionBox"); - Label nameLbl = (Label)FormView1.FindControl("nameLbl"); - Label descriptionLbl = (Label)FormView1.FindControl("descriptionLbl"); - - if (!m_user.HasRight("edit_role", Constants.PRODUCT_ANYID)) - { - nameBox.Visible = false; - descriptionBox.Visible = false; - nameLbl.Visible = true; - descriptionLbl.Visible = true; - } - } protected void activeBox_Init(object sender, EventArgs e) { CheckBox activeBox = (CheckBox)sender; @@ -488,5 +286,10 @@ rightsList.Items.Add(item); } } + protected void editAssignments_Command(object sender, CommandEventArgs e) + { + Response.Redirect("~/RoleAssignments.aspx?" + Constants.CODE_PRODUCT + "=" + productID + "&" + Constants.CODE_ROLE + "=" + roleID); + } } } + Added: Website/RoleAssignments.aspx =================================================================== --- Website/RoleAssignments.aspx (rev 0) +++ Website/RoleAssignments.aspx 2006-08-08 21:26:55 UTC (rev 284) @@ -0,0 +1,12 @@ +<%@ Page Language="C#" MasterPageFile="~/TCDB.master" AutoEventWireup="true" Title="TCDB: Role Assignments" %> + +<%@ Register Src="~/Includes/AdministrationTree.ascx" TagPrefix="admin" TagName="Tree" %> +<%@ Register Src="~/Includes/RoleAssignments.ascx" TagPrefix="admin" TagName="Assignments" %> +<asp:Content ID="TreeContent" ContentPlaceHolderID="TreeContentPlaceHolder" runat="Server"> + <admin:Tree runat="server" ID="Tree" /> +</asp:Content> +<asp:Content ID="MainContent" ContentPlaceHolderID="MainContentPlaceHolder" runat="Server"> + <admin:Assignments ID="Assignments" runat="server" /> +</asp:Content> +<asp:Content ID="NotesContent" ContentPlaceHolderID="NotesContentPlaceHolder" runat="Server"> +</asp:Content> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |