private void BindToolbar() { using (IDataReader reader = SecureGroup.GetGroup(GroupID)) { if (reader.Read()) { secHeader.Title = CommonHelper.GetResFileString((string)reader["GroupName"]); } } ComponentArt.Web.UI.MenuItem topMenuItem = new ComponentArt.Web.UI.MenuItem(); topMenuItem.Text = /*"<img border='0' src='../Layouts/Images/downbtn.gif' width='9px' height='5px' align='absmiddle'/> " + */ LocRM2.GetString("Actions"); topMenuItem.Look.LeftIconUrl = ResolveUrl("~/Layouts/Images/downbtn1.gif"); topMenuItem.Look.LeftIconHeight = Unit.Pixel(5); topMenuItem.Look.LeftIconWidth = Unit.Pixel(16); topMenuItem.LookId = "TopItemLook"; ComponentArt.Web.UI.MenuItem subItem; #region new group if (SecureGroup.CanCreate(GroupID)) { subItem = new ComponentArt.Web.UI.MenuItem(); subItem.Look.LeftIconUrl = "~/Layouts/Images/icons/newgroup.gif"; subItem.Look.LeftIconWidth = Unit.Pixel(16); subItem.Look.LeftIconHeight = Unit.Pixel(16); subItem.NavigateUrl = "~/Directory/AddGroup.aspx?Type=0&GroupID=" + GroupID.ToString(); subItem.Text = LocRM.GetString("AddGroup"); topMenuItem.Items.Add(subItem); } #endregion #region edit group if (SecureGroup.CanUpdate() && GroupID > 9) { subItem = new ComponentArt.Web.UI.MenuItem(); subItem.Look.LeftIconUrl = "~/Layouts/Images/icons/editgroup.gif"; subItem.Look.LeftIconWidth = Unit.Pixel(16); subItem.Look.LeftIconHeight = Unit.Pixel(16); subItem.NavigateUrl = "~/Directory/AddGroup.aspx?Type=0&Edit=1&GroupID=" + GroupID.ToString(); subItem.Text = LocRM.GetString("EditGroup"); topMenuItem.Items.Add(subItem); } #endregion #region move if (SecureGroup.CanMove(GroupID)) { subItem = new ComponentArt.Web.UI.MenuItem(); subItem.Look.LeftIconUrl = "~/Layouts/Images/icons/movegroup.gif"; subItem.Look.LeftIconWidth = Unit.Pixel(16); subItem.Look.LeftIconHeight = Unit.Pixel(16); subItem.NavigateUrl = "~/Directory/MoveGroup.aspx?GroupID=" + GroupID.ToString(); subItem.Text = LocRM.GetString("MoveGroup"); topMenuItem.Items.Add(subItem); } #endregion #region delete if (SecureGroup.CanDelete(GroupID)) { subItem = new ComponentArt.Web.UI.MenuItem(); subItem.Look.LeftIconUrl = "~/Layouts/Images/icons/deletegroup.gif"; subItem.Look.LeftIconWidth = Unit.Pixel(16); subItem.Look.LeftIconHeight = Unit.Pixel(16); subItem.ClientSideCommand = "javascript:DeleteGroup()"; subItem.Text = LocRM.GetString("DeleteGroup"); topMenuItem.Items.Add(subItem); } #endregion #region new user if (User.CanCreateExternal() || User.CanCreatePending() || User.CanCreate()) { subItem = new ComponentArt.Web.UI.MenuItem(); subItem.Look.LeftIconUrl = "~/Layouts/Images/icons/newuser.gif"; subItem.Look.LeftIconWidth = Unit.Pixel(16); subItem.Look.LeftIconHeight = Unit.Pixel(16); subItem.NavigateUrl = "~/Directory/MultipleUserEdit.aspx?GroupID=" + GroupID; subItem.Text = LocRM.GetString("AddUser"); topMenuItem.Items.Add(subItem); } #endregion if (topMenuItem.Items.Count > 0) { secHeader.ActionsMenu.Items.Add(topMenuItem); } }
private void BinddgUsers() { dgUsers.Columns[1].HeaderText = LocRM.GetString("LastName"); dgUsers.Columns[2].HeaderText = LocRM.GetString("FirstName"); dgUsers.Columns[3].HeaderText = LocRM.GetString("Email"); dgUsers.Columns[4].HeaderText = LocRM.GetString("Location"); dgUsers.Columns[5].HeaderText = LocRM.GetString("Phone"); foreach (DataGridColumn dgc in dgUsers.Columns) { if (dgc.SortExpression == pc["dgUsers_SortColumn"].ToString()) { dgc.HeaderText += " <img alt='' src='../layouts/images/upbtnF.jpg'/>"; } else if (dgc.SortExpression + " DESC" == pc["dgUsers_SortColumn"].ToString()) { dgc.HeaderText += " <img alt='' src='../layouts/images/downbtnF.jpg'/>"; } } DataTable dt = new DataTable(); dt.Columns.Add("ObjectId", typeof(int)); dt.Columns.Add("FirstName"); dt.Columns.Add("LastName"); dt.Columns.Add("Email"); dt.Columns.Add("Location"); dt.Columns.Add("Phone"); dt.Columns.Add("ActionView"); dt.Columns.Add("ActionEdit"); dt.Columns.Add(new DataColumn("sortFirstName", typeof(string))); dt.Columns.Add(new DataColumn("sortLastName", typeof(string))); dt.Columns.Add(new DataColumn("sortEMail", typeof(string))); dt.Columns.Add(new DataColumn("sortLocation", typeof(string))); dt.Columns.Add(new DataColumn("sortPhone", typeof(string))); bool UserCanDelete = User.CanDelete(); bool CanUpdate = User.CanUpdateUserInfo(); using (IDataReader reader = (Security.IsUserInGroup(InternalSecureGroups.Administrator)) ? User.GetListAll() : User.GetListUsersBySubstring(String.Empty)) { while (reader.Read()) { int iUserId = (int)reader["UserId"]; /// UserId, Login, FirstName, LastName, Email, IsActive, IMGroupId, CreatedBy, Comments, IsExternal, IsPending, OriginalId using (IDataReader UserReader = User.GetUserInfo(iUserId)) { if (UserReader.Read()) { DataRow dr = dt.NewRow(); dr["ObjectId"] = iUserId; string sUser = CommonHelper.GetUserStatus(iUserId); if (!(bool)UserReader["IsActive"]) { dr["FirstName"] = String.Format("<span style='color:#999999'>{0}</span>", UserReader["FirstName"].ToString()); dr["LastName"] = String.Format("<span style='color:#999999'>{0}</span>", UserReader["LastName"].ToString()); } else { dr["FirstName"] = UserReader["FirstName"].ToString(); dr["LastName"] = UserReader["LastName"].ToString(); } dr["sortFirstName"] = UserReader["FirstName"].ToString(); dr["sortLastName"] = UserReader["LastName"].ToString(); dr["Email"] = "<a href='mailto:" + (string)UserReader["Email"] + "'>" + (string)UserReader["Email"] + "</a>"; dr["sortEMail"] = (string)UserReader["Email"]; using (IDataReader UserProfile = User.GetUserProfile(iUserId)) { if (UserProfile.Read()) { dr["Location"] = UserProfile["location"].ToString(); dr["sortLocation"] = UserProfile["location"].ToString(); dr["Phone"] = UserProfile["phone"].ToString(); dr["sortPhone"] = UserProfile["phone"].ToString(); } } if (CanUpdate) { if ((bool)UserReader["IsExternal"]) { dr["ActionEdit"] = "<a href='../Directory/ExternalEdit.aspx?UserID=" + iUserId.ToString() + "' title='" + LocRM.GetString("tEdit") + "'>" + "<img alt='' src='../layouts/images/edit.GIF'/></a>"; } else if ((bool)UserReader["IsPending"]) { dr["ActionEdit"] = "<a href='../Directory/UserEdit.aspx?UserID=" + iUserId.ToString() + "' title='" + LocRM.GetString("tApprove") + "'>" + "<img alt='' src='../layouts/images/icon-key.GIF'/></a>"; } else { dr["ActionEdit"] = "<a href='../Directory/UserEdit.aspx?UserID=" + iUserId.ToString() + "' title='" + LocRM.GetString("tEdit") + "'>" + "<img alt='' src='../layouts/images/edit.GIF'/></a>"; } } dr["ActionView"] = "<a href='../Directory/UserView.aspx?UserID=" + iUserId.ToString() + "' title='" + LocRM.GetString("tViewDetails") + "'>" + "<img alt='' src='../layouts/images/Icon-Search.GIF'/></a>"; dt.Rows.Add(dr); } } } } DataRow[] drassets = null; try { drassets = dt.Select("", pc["dgUsers_SortColumn"]); } catch { pc["dgUsers_SortColumn"] = "sortFirstName"; drassets = dt.Select("", pc["dgUsers_SortColumn"]); } DataTable result = dt.Clone(); foreach (DataRow dr1 in drassets) { DataRow _dr = result.NewRow(); _dr.ItemArray = (Object[])dr1.ItemArray.Clone(); result.Rows.Add(_dr); } if (!SecureGroup.CanDelete()) { dgUsers.Columns[8].Visible = false; } if (pc["ds_PageSize"] != null) { dgUsers.PageSize = int.Parse(pc["ds_PageSize"]); } int pageindex = dgUsers.CurrentPageIndex; int ppi = dt.Rows.Count / dgUsers.PageSize; if (dt.Rows.Count % dgUsers.PageSize == 0) { ppi = ppi - 1; } if (pageindex > ppi) { dgUsers.CurrentPageIndex = 0; } dgUsers.DataSource = new DataView(result); dgUsers.DataBind(); foreach (DataGridItem dgi in dgUsers.Items) { int ID = int.Parse(dgi.Cells[0].Text); bool CanDelete = User.CanDelete(ID); ImageButton ib = (ImageButton)dgi.FindControl("ibDelete"); if (ib != null && CanDelete) { ib.Attributes.Add("onclick", String.Format("return DeleteUser({0})", ID)); ib.Visible = true; } } }
private void BinddgGroupsUsers() { dgGroupsUsers.Columns[2].HeaderText = LocRM.GetString("GroupUser"); dgGroupsUsers.Columns[3].HeaderText = LocRM.GetString("Email"); DataTable dt = new DataTable(); dt.Columns.Add("ObjectId", typeof(int)); dt.Columns.Add("Type"); dt.Columns.Add("Title"); dt.Columns.Add("Email"); dt.Columns.Add("sortTitle"); dt.Columns.Add("ActionView"); dt.Columns.Add("ActionEdit"); dt.Columns.Add("HasChildren", typeof(bool)); dt.Columns.Add("IsActive", typeof(bool)); bool CanUpdate = SecureGroup.CanUpdate(); DataRow dr; if (GroupID != 1) // [..] { int iParentId = SecureGroup.GetParentGroup(GroupID); dr = dt.NewRow(); dr["ObjectId"] = 0; dr["Type"] = "Group"; dr["Title"] = "<span style='padding-left:15px'> </span><a href='../Directory/directory.aspx?Tab=0&SGroupID=" + iParentId.ToString() + "'>[..]</a>"; dr["HasChildren"] = true; dr["IsActive"] = true; dt.Rows.Add(dr); } using (IDataReader reader = SecureGroup.GetListChildGroups(GroupID)) { while (reader.Read()) { dr = dt.NewRow(); dr["ObjectId"] = reader["GroupId"]; dr["Type"] = "Group"; int iGroupId = (int)reader["GroupId"]; dr["Title"] = CommonHelper.GetGroupLink(iGroupId, CommonHelper.GetResFileString((string)reader["GroupName"])); dr["sortTitle"] = CommonHelper.GetResFileString(reader["GroupName"].ToString()); dr["HasChildren"] = reader["HasChildren"]; dr["IsActive"] = true; if (CanUpdate && iGroupId > 9) { dr["ActionEdit"] = "<a href='../Directory/AddGroup.aspx?Type=0&Edit=1&GroupID=" + iGroupId.ToString() + "'>" + "<img alt='' src='../layouts/images/edit.GIF'/></a>"; } dt.Rows.Add(dr); } } if (dt.Rows.Count == 1 && GroupID == 6) // Partner { PartnerLabel.Text = LocRM.GetString("CreatePartnerGroup"); PartnerLabel.Visible = true; } else { PartnerLabel.Visible = false; } //SELECT PrincipalId AS UserId, Login, FirstName, LastName, Email, IsActive, IMGroupId CanUpdate = User.CanUpdateUserInfo(); bool bIsPartner = SecureGroup.IsPartner(GroupID); using (IDataReader reader = SecureGroup.GetListUsersInGroup(GroupID)) { while (reader.Read()) { byte Activity = (byte)reader["Activity"]; bool IsExternal = (bool)reader["IsExternal"]; dr = dt.NewRow(); dr["ObjectId"] = reader["UserId"]; dr["Type"] = "User"; dr["Title"] = CommonHelper.GetUserStatus((int)reader["UserId"]); dr["sortTitle"] = CommonHelper.GetUserStatusPureName((int)reader["UserId"]); dr["Email"] = "<a href='mailto:" + (string)reader["Email"] + "'>" + (string)reader["Email"] + "</a>"; if (CanUpdate) { if (Activity == (byte)User.UserActivity.Pending) { dr["ActionEdit"] = "<a href='../Directory/UserEdit.aspx?UserID=" + reader["UserId"].ToString() + "' title='" + LocRM.GetString("tApprove") + "'>" + "<img alt='' src='../layouts/images/icon-key.GIF'/></a>"; } else if (GroupID == (int)InternalSecureGroups.Partner || bIsPartner) { dr["ActionEdit"] = "<a href='../Directory/PartnerEdit.aspx?UserID=" + reader["UserId"].ToString() + "' title='" + LocRM.GetString("tEdit") + "'>" + "<img alt='' src='../layouts/images/edit.GIF'/></a>"; } else if (IsExternal) { dr["ActionEdit"] = "<a href='../Directory/ExternalEdit.aspx?UserID=" + reader["UserId"].ToString() + "' title='" + LocRM.GetString("tEdit") + "'>" + "<img alt='' src='../layouts/images/edit.GIF'/></a>"; } else { dr["ActionEdit"] = "<a href='../Directory/UserEdit.aspx?UserID=" + reader["UserId"].ToString() + "' title='" + LocRM.GetString("tEdit") + "'>" + "<img alt='' src='../layouts/images/edit.GIF'/></a>"; } } dr["ActionView"] = "<a href='../Directory/UserView.aspx?UserID=" + reader["UserId"].ToString() + "' title='" + LocRM.GetString("tViewDetails") + "'>" + "<img alt='' src='../layouts/images/Icon-Search.GIF'/></a>"; dr["HasChildren"] = false; dr["IsActive"] = (Activity > 1); dt.Rows.Add(dr); } } if (!SecureGroup.CanDelete()) { dgGroupsUsers.Columns[6].Visible = false; } DataView dv = dt.DefaultView; dv.Sort = "Type, IsActive DESC, sortTitle"; dgGroupsUsers.DataSource = dv; dgGroupsUsers.DataBind(); foreach (DataGridItem dgi in dgGroupsUsers.Items) { int ID = int.Parse(dgi.Cells[0].Text); bool UserCanDelete = User.CanDelete(ID); string type = dgi.Cells[1].Text; bool HasChildren = bool.Parse(dgi.Cells[7].Text); ImageButton ib = (ImageButton)dgi.FindControl("ibDelete"); if (type == "Group" && !HasChildren && ID >= 9) { ib.Attributes.Add("onclick", "return confirm('" + LocRM.GetString("Warning") + "')"); } else if (type != "Group" && UserCanDelete) { ib.Attributes.Add("onclick", String.Format("return DeleteUser({0}, {1})", ID, GroupID)); } else { ib.Visible = false; } } }
private void BinddgGroupsUsers() { dgGroupsUsers.Columns[2].HeaderText = LocRM.GetString("GroupUser"); dgGroupsUsers.Columns[3].HeaderText = LocRM.GetString("Email"); DataTable dt = new DataTable(); dt.Columns.Add("ObjectId", typeof(int)); dt.Columns.Add("Type"); dt.Columns.Add("Title"); dt.Columns.Add("SortTitle"); dt.Columns.Add("Email"); dt.Columns.Add("ActionView"); dt.Columns.Add("ActionEdit"); dt.Columns.Add("HasChildren", typeof(int)); bool CanUpdate = SecureGroup.CanUpdate(); bool UserCanDelete = User.CanDelete(); if (ddType.SelectedItem.Value == "0" || ddType.SelectedItem.Value == "2") { using (IDataReader reader = SecureGroup.GetListGroupsBySubstring((string)ViewState["SearchStr"])) { while (reader.Read()) { DataRow dr = dt.NewRow(); dr["ObjectId"] = reader["GroupId"]; dr["Type"] = "Group"; dr["Title"] = CommonHelper.GetGroupLink((int)reader["GroupId"], CommonHelper.GetResFileString((string)reader["GroupName"])); dr["SortTitle"] = (string)reader["GroupName"]; dr["HasChildren"] = reader["HasChildren"]; if (CanUpdate && (int)reader["GroupId"] >= 8) { dr["ActionEdit"] = "<a href='../Directory/AddGroup.aspx?Type=0&Edit=1&GroupID=" + reader["GroupId"].ToString() + "'>" + "<img alt='' src='../layouts/images/edit.GIF'/></a>"; } dt.Rows.Add(dr); } } } CanUpdate = User.CanUpdateUserInfo(); if (ddType.SelectedItem.Value == "0" || ddType.SelectedItem.Value == "1") { using (IDataReader reader = User.GetListUsersBySubstring((string)ViewState["SearchStr"])) { while (reader.Read()) { DataRow dr = dt.NewRow(); dr["ObjectId"] = reader["UserId"]; dr["Type"] = "User"; dr["Title"] = CommonHelper.GetUserStatus((int)reader["UserId"]); dr["SortTitle"] = (string)reader["LastName"] + " " + (string)reader["FirstName"]; dr["Email"] = "<a href='mailto:" + (string)reader["Email"] + "'>" + (string)reader["Email"] + "</a>"; if (CanUpdate) { if ((bool)reader["IsExternal"]) { dr["ActionEdit"] = "<a href='../Directory/ExternalEdit.aspx?UserID=" + reader["UserId"].ToString() + "' title='" + LocRM.GetString("tEdit") + "'>" + "<img alt='' src='../layouts/images/edit.GIF'/></a>"; } else if ((bool)reader["IsPending"]) { dr["ActionEdit"] = "<a href='../Directory/UserEdit.aspx?UserID=" + reader["UserId"].ToString() + "' title='" + LocRM.GetString("tApprove") + "'>" + "<img alt='' src='../layouts/images/icon-key.GIF'/></a>"; } else { dr["ActionEdit"] = "<a href='../Directory/UserEdit.aspx?UserID=" + reader["UserId"].ToString() + "' title='" + LocRM.GetString("tEdit") + "'>" + "<img alt='' src='../layouts/images/edit.GIF'/></a>"; } } dr["ActionView"] = "<a href='../Directory/UserView.aspx?UserID=" + reader["UserId"].ToString() + "' title='" + LocRM.GetString("tViewDetails") + "'>" + "<img alt='' src='../layouts/images/Icon-Search.GIF'/></a>"; dr["HasChildren"] = 0; dt.Rows.Add(dr); } } } if (!SecureGroup.CanDelete()) { dgGroupsUsers.Columns[6].Visible = false; } if (pc["ds_PageSize"] != null) { dgGroupsUsers.PageSize = int.Parse(pc["ds_PageSize"]); } int pageindex = dgGroupsUsers.CurrentPageIndex; int ppi = dt.Rows.Count / dgGroupsUsers.PageSize; if (dt.Rows.Count % dgGroupsUsers.PageSize == 0) { ppi = ppi - 1; } if (pageindex > ppi) { dgGroupsUsers.CurrentPageIndex = 0; } DataView dv = dt.DefaultView; dv.Sort = "SortTitle"; dgGroupsUsers.DataSource = dv; dgGroupsUsers.DataBind(); foreach (DataGridItem dgi in dgGroupsUsers.Items) { int ID = int.Parse(dgi.Cells[0].Text); bool CanDelete = User.CanDelete(ID); string type = dgi.Cells[1].Text; int HasChildren = int.Parse(dgi.Cells[7].Text); ImageButton ib = (ImageButton)dgi.FindControl("ibDelete"); if (ib != null) { if (type == "Group" && HasChildren == 0) { ib.Attributes.Add("onclick", "return confirm('" + LocRM.GetString("Warning") + "')"); } else if (type != "Group" && CanDelete) { ib.Attributes.Add("onclick", String.Format("return DeleteUser({0})", ID)); } else { ib.Visible = false; } } } }