Beispiel #1
0
        protected void ddlGroup_SelectedIndexChanged(object sender, EventArgs e)
        {
            int groupId = int.Parse(ddlGroup.SelectedValue);

            ddlUser.Items.Clear();
            ddlUser.Items.Add(new ListItem(LocRM.GetString("AnyUser"), "0"));
            using (IDataReader reader = IMGroup.GetListUsers(groupId))
            {
                while (reader.Read())
                {
                    ddlUser.Items.Add(new ListItem(reader["LastName"].ToString() + " " + reader["FirstName"].ToString(), reader["OriginalId"].ToString()));
                }
            }
        }
Beispiel #2
0
        private void BinddgGroupsUsers()
        {
            dgUsers.Columns[1].HeaderText = LocRM.GetString("GroupUser");
            dgUsers.Columns[2].HeaderText = LocRM.GetString("Email");

            if (GroupID == 0)
            {
                dgUsers.Columns[2].Visible = false;
            }

            DataTable dt = new DataTable();

            dt.Columns.Add(new DataColumn("ID", typeof(int)));
            dt.Columns.Add(new DataColumn("Type", typeof(int)));             //0-IMGroup, 1- User
            dt.Columns.Add(new DataColumn("GroupName", typeof(string)));
            dt.Columns.Add(new DataColumn("Email", typeof(string)));
            dt.Columns.Add(new DataColumn("ActionEdit", typeof(string)));
            dt.Columns.Add(new DataColumn("ActionDelete", typeof(string)));

            DataView dv;
            DataRow  dr;

            if (GroupID > 0)             // Bind Users
            {
                // [..]
                dr              = dt.NewRow();
                dr["ID"]        = 0;
                dr["Type"]      = 0;
                dr["GroupName"] = "<span style='padding-left:30px'>&nbsp;</span><a href='../Directory/directory.aspx?Tab=1&amp;IMGroupID=0'>[..]</a>";
                dt.Rows.Add(dr);

                using (IDataReader rdr = IMGroup.GetListUsers(GroupID))
                {
                    while (rdr.Read())
                    {
                        dr = dt.NewRow();
                        int iUserId = (int)rdr["UserId"];
                        dr["ID"]    = iUserId;
                        dr["Type"]  = 1;
                        dr["Email"] = rdr["Email"].ToString();
                        if (User.CanUpdateUserInfo(iUserId))
                        {
                            dr["ActionEdit"] = String.Format("<a href='../Directory/UserEdit.aspx?UserID={0}'><img alt='{1}' src='../Layouts/Images/edit.gif' title='{1}'/></a>", iUserId.ToString(), LocRM.GetString("Edit"));
                        }
                        if (User.CanDelete(iUserId))
                        {
                            dr["ActionDelete"] = String.Format("<a href='javascript:DeleteUser({0})'><img alt='{1}' src='../Layouts/Images/delete.gif' title='{1}'/></a>", iUserId.ToString(), LocRM.GetString("Delete"));
                        }
                        dt.Rows.Add(dr);
                    }
                }
                dv = dt.DefaultView;
            }
            else              // Bind IMGroups
            {
                int userIMGroupId = 0;

                if (!IMGroup.CanCreate())
                {
                    using (IDataReader rdr = User.GetUserInfo(Security.CurrentUser.UserID))
                    {
                        rdr.Read();
                        if (rdr["IMGroupId"] != DBNull.Value)
                        {
                            userIMGroupId = (int)rdr["IMGroupId"];
                        }
                    }

                    if (userIMGroupId > 0)
                    {
                        using (DataTable table = IMGroup.GetListIMGroupsYouCanSee(userIMGroupId))
                        {
                            foreach (DataRow row in table.Rows)
                            {
                                dr = dt.NewRow();

                                int groupId = (int)row["IMGroupId"];
                                dr["ID"]        = groupId;
                                dr["Type"]      = 0;
                                dr["GroupName"] = row["IMGroupName"].ToString();
                                if (IMGroup.CanUpdate())
                                {
                                    dr["ActionEdit"] = String.Format("<a href='../Directory/AddIMGroup.aspx?GroupID={0}'><img alt='{1}' src='../Layouts/Images/edit.gif' title='{1}'/></a>", groupId, LocRM.GetString("Edit"));
                                }
                                if (IMGroup.CanDelete(groupId))
                                {
                                    dr["ActionDelete"] = String.Format("<a href='javascript:DeleteGroup({0})'><img alt='{1}' src='../Layouts/Images/delete.gif' title='{1}'/></a>", groupId, LocRM.GetString("Delete"));
                                }

                                dt.Rows.Add(dr);
                            }
                        }

                        string imGroupName = IMGroup.GetIMGroupName(userIMGroupId, null);
                        if (imGroupName != null)
                        {
                            dr = dt.NewRow();

                            dr["ID"]        = userIMGroupId;
                            dr["Type"]      = 0;
                            dr["GroupName"] = imGroupName;
                            if (IMGroup.CanUpdate())
                            {
                                dr["ActionEdit"] = String.Format("<a href='../Directory/AddIMGroup.aspx?GroupID={0}'><img alt='{1}' src='../Layouts/Images/edit.gif' title='{1}'/></a>", userIMGroupId, LocRM.GetString("Edit"));
                            }

                            dt.Rows.Add(dr);
                        }
                    }
                }
                else
                {
                    using (DataTable table = IMGroup.GetListIMGroup())
                    {
                        foreach (DataRow row in table.Rows)
                        {
                            dr = dt.NewRow();

                            int groupId = (int)row["IMGroupId"];
                            dr["ID"]        = groupId;
                            dr["Type"]      = 0;
                            dr["GroupName"] = row["IMGroupName"].ToString();
                            if (IMGroup.CanUpdate())
                            {
                                dr["ActionEdit"] = string.Format("<a href='../Directory/AddIMGroup.aspx?GroupID={0}'><img alt='{1}' src='../Layouts/Images/edit.gif' title='{1}'/></a>", groupId, LocRM.GetString("Edit"));
                            }
                            if (IMGroup.CanDelete(groupId))
                            {
                                dr["ActionDelete"] = string.Format("<a href='javascript:DeleteGroup({0})'><img alt='{1}' src='../Layouts/Images/delete.gif' title='{1}'/></a>", groupId, LocRM.GetString("Delete"));
                            }

                            dt.Rows.Add(dr);
                        }
                    }
                }
                dv      = dt.DefaultView;
                dv.Sort = "GroupName";
            }

            dgUsers.DataSource = dv;
            dgUsers.DataBind();
        }