Пример #1
0
 private void ComUsergroup_Click(object sender, EventArgs e)
 {
     if (base.CheckCookie())
     {
         if (this.sourceusergroup.SelectedIndex == 0 || this.targetusergroup.SelectedIndex == 0)
         {
             base.RegisterStartupScript("", "<script>alert('操作失败,请您选择有效的用户组!');</script>");
             return;
         }
         if (this.sourceusergroup.SelectedValue == this.targetusergroup.SelectedValue)
         {
             base.RegisterStartupScript("", "<script>alert('操作失败,同一个用户组不能够合并!');</script>");
             return;
         }
         UserGroup src = UserGroup.FindByID(int.Parse(this.sourceusergroup.SelectedValue));
         UserGroup des = UserGroup.FindByID(int.Parse(this.targetusergroup.SelectedValue));
         if (src.Creditslower != des.Creditshigher)
         {
             base.RegisterStartupScript("", "<script>alert('操作失败,要合并的用户组必须是积分相连的两个用户组!');</script>");
             return;
         }
         //var userGroupInfo = UserGroup.FindByID(int.Parse(this.targetusergroup.SelectedValue));
         des.Creditshigher = src.Creditshigher;
         //UserGroups.UpdateUserGroup(userGroupInfo);
         des.Save();
         //UserGroups.DeleteUserGroupInfo(int.Parse(this.sourceusergroup.SelectedValue));
         src.Delete();
         UserGroup.ChangeAllUserGroupId(int.Parse(this.sourceusergroup.SelectedValue), int.Parse(this.targetusergroup.SelectedValue));
         //XCache.Remove(CacheKeys.FORUM_USER_GROUP_LIST);
         AdminVisitLog.InsertLog(this.userid, this.username, this.usergroupid, this.grouptitle, this.ip, "合并用户组", "把组ID:" + this.sourceusergroup.SelectedIndex + " 合并到组ID:" + this.targetusergroup.SelectedIndex);
         base.RegisterStartupScript("PAGE", "window.location.href='usergroupgrid.aspx';");
     }
 }
        public HttpResponseMessage Delete(int id)
        {
            UserGroup group = new UserGroup();

            group.ID = id;
            return(Request.CreateResponse(HttpStatusCode.OK, group.Delete()));
        }
Пример #3
0
        private void DeleteUserGroupInf_Click(object sender, EventArgs e)
        {
            if (base.CheckCookie())
            {
                UserGroup ug = UserGroup.FindByID(WebHelper.RequestInt("groupid"));
                //if (AdminUserGroups.DeleteUserGroupInfo(DNTRequest.GetInt("groupid", -1)))
                if (ug != null)
                {
                    ug.Delete();

                    GeneralConfigInfo config = GeneralConfigInfo.Current;
                    string            text   = "";
                    string[]          array  = config.Reportusergroup.Split(',');
                    for (int i = 0; i < array.Length; i++)
                    {
                        string text2 = array[i];
                        if (text2 != this.userGroupInfo.ID.ToString())
                        {
                            if (String.IsNullOrEmpty(text))
                            {
                                text = text2;
                            }
                            else
                            {
                                text = text + "," + text2;
                            }
                        }
                    }
                    config.Reportusergroup = text;
                    text = "";
                    string[] array2 = config.Photomangegroups.Split(',');
                    for (int j = 0; j < array2.Length; j++)
                    {
                        string text3 = array2[j];
                        if (text3 != this.userGroupInfo.ID.ToString())
                        {
                            if (text == "")
                            {
                                text = text3;
                            }
                            else
                            {
                                text = text + "," + text3;
                            }
                        }
                    }
                    config.Photomangegroups = text;
                    config.Save();

                    AdminVisitLog.InsertLog(this.userid, this.username, this.usergroupid, this.grouptitle, this.ip, "后台删除管理组", "组ID:" + DNTRequest.GetInt("groupid", -1));
                    base.RegisterStartupScript("PAGE", "window.location.href='adminusergroupgrid.aspx';");
                    return;
                }
                base.RegisterStartupScript("", "<script>alert('操作失败');window.location.href='adminusergroupgrid.aspx';</script>");
            }
        }
        public ActionResult DeleteConfirmed(Guid id)
        {
            List <IdentityRole> RoleList  = db.Roles.Where(i => i.Id == id.ToString()).ToList <IdentityRole>();
            UserGroup           userGroup = new UserGroup();

            userGroup.UserGroupID   = new Guid(RoleList[0].Id);
            userGroup.UserGroupName = RoleList[0].Name;
            CurrentUserGroupName    = userGroup.UserGroupName;
            if (userGroup.Delete(CurrentUserGroupName))
            {
                return(RedirectToAction("UserGroup"));
            }
            return(View(userGroup));
        }
Пример #5
0
        protected void DeleteUserGroup(object sender, CommandEventArgs e)
        {
            string userGroupId = e.CommandArgument.ToString();

            if (!string.IsNullOrEmpty(userGroupId))
            {
                // delete user group
                UserGroup biz = new UserGroup();
                biz.Delete(int.Parse(userGroupId));

                // re-populate groups
                BuildUserGroups(int.Parse(UserIdField.Value));
            }
        }
Пример #6
0
        private void ComAdminUsergroup_Click(object sender, EventArgs e)
        {
            if (base.CheckCookie())
            {
                if (this.sourceadminusergroup.SelectedIndex == 0 || this.targetadminusergroup.SelectedIndex == 0)
                {
                    base.RegisterStartupScript("", "<script>alert('操作失败,请您选择有效的管理组!');</script>");
                    return;
                }
                if (Convert.ToInt32(this.sourceadminusergroup.SelectedValue) <= 3 || Convert.ToInt32(this.sourceadminusergroup.SelectedValue) <= 3)
                {
                    base.RegisterStartupScript("", "<script>alert('操作失败,您选择的组为系统初始化的管理组,这些组不允许合并!');</script>");
                    return;
                }
                if (this.sourceadminusergroup.SelectedValue == this.targetadminusergroup.SelectedValue)
                {
                    base.RegisterStartupScript("", "<script>alert('操作失败,同一个管理组不能够合并!');</script>");
                    return;
                }

                //AdminGroups.DeleteAdminGroupInfo(Convert.ToInt16(this.sourceadminusergroup.SelectedValue));
                AdminGroup adg = AdminGroup.FindByID(Convert.ToInt32(sourceadminusergroup.SelectedValue));
                if (adg != null)
                {
                    adg.Delete();
                }
                //UserGroups.DeleteUserGroupInfo(int.Parse(this.sourceadminusergroup.SelectedValue));
                UserGroup ug = UserGroup.FindByID(adg.ID);
                if (ug != null)
                {
                    ug.Delete();
                }
                UserGroup.ChangeAllUserGroupId(int.Parse(this.sourceusergroup.SelectedValue), int.Parse(this.targetadminusergroup.SelectedValue));
                //XCache.Remove(CacheKeys.FORUM_USER_GROUP_LIST);
                AdminVisitLog.InsertLog(this.userid, this.username, this.usergroupid, this.grouptitle, this.ip, "合并管理组", "把组ID:" + this.sourceusergroup.SelectedIndex + " 合并到组ID:" + this.targetusergroup.SelectedIndex);
                base.RegisterStartupScript("PAGE", "window.location.href='adminusergroupgrid.aspx';");
            }
        }
Пример #7
0
        /// <summary>
        /// Updates the list of Users in a group
        /// </summary>
        /// <param name="groupId"></param>
        private void SaveGroupUsers(int groupId)
        {
            foreach (RepeaterItem item in UsersRptr.Items)
            {
                HiddenField userIdField        = item.FindControl("UserIdField") as HiddenField;
                HiddenField userGroupIdField   = item.FindControl("UserGroupIdField") as HiddenField;
                CheckBox    associateUserField = item.FindControl("AssociateUserField") as CheckBox;

                // checked
                if (associateUserField.Checked)
                {
                    // add association
                    if (string.IsNullOrEmpty(userGroupIdField.Value))
                    {
                        UserGroup userGroup = new UserGroup();
                        int       userId    = int.Parse(userIdField.Value);
                        userGroup[BOL.UserGroup.UserId]  = userId;
                        userGroup[BOL.UserGroup.GroupId] = groupId;
                        userGroup.Save();

                        userGroupIdField.Value = userGroup[BOL.UserGroup.UserGroupId].ToString();
                    }
                }
                // unchecked
                else
                {
                    // delete assocaition
                    if (!string.IsNullOrEmpty(userGroupIdField.Value))
                    {
                        UserGroup userGroup   = new UserGroup();
                        int       userGroupId = int.Parse(userGroupIdField.Value);
                        userGroup.Delete(userGroupId);

                        userGroupIdField.Value = string.Empty;
                    }
                }
            }
        }
Пример #8
0
        protected void SaveClick(object sender, EventArgs e)
        {
            // important, capture state locally
            bool isNewUser = IsNew;

            // validate
            if (!isNewUser || ValidateUser())
            {
                int? userId = null;
                User user   = new User();
                // !important: password is a special case
                string clearPassword  = "";
                string hashedPassword = "";
                if (!isNewUser)
                {
                    userId = int.Parse(UserIdField.Value);
                    user.Get(userId.Value);
                    hashedPassword = user[BOL.User.UserPassword].ToString();
                }
                else
                {
                    clearPassword  = UserPassword.Text;
                    hashedPassword = GetHasedPassword(clearPassword);
                }
                // set field values
                CICHelper.SetBOValues(this.Controls, user, -1);
                // !important (persist password)
                user[BOL.User.UserPassword] = hashedPassword;

                // deactivated ?
                if (DeactivateUser.Checked)
                {
                    DateTime deactivateDate     = DateTime.Today;
                    string   deactivateDateText = DeactivateDate.Value;
                    // validate deactivate date
                    if (DateTime.TryParse(deactivateDateText, out deactivateDate))
                    {
                        user[BOL.User.DeactivatedTime] = deactivateDate;
                    }
                }
                else
                {
                    user[BOL.User.DeactivatedTime] = null;
                }

                // insert/update
                user.Save();
                userId = (int)user[user.PrimaryKeyName];

                // UDPATE GROUPS

                // determine which checkbox list is updating/inserting
                CheckBoxList groupsList = GroupsList;
                // get lookup of current user's GroupId -> UserGroupId
                Dictionary <int, int> currentGroups = new Dictionary <int, int>();
                if (!isNewUser)
                {
                    currentGroups = BOL.BusinessObject.GetByFields <UserGroup>(new Dictionary <string, object> {
                        { UserGroup.UserId, userId.Value }
                    }).ToDictionary(r => (int)r[UserGroup.GroupId], r => (int)r[UserGroup.UserGroupId]);
                }
                foreach (ListItem item in groupsList.Items)
                {
                    if (!string.IsNullOrEmpty(item.Value))
                    {
                        int groupId = int.Parse(item.Value);
                        // insert if checked and not currently assigned (or new)
                        if (item.Selected && (isNewUser || !currentGroups.ContainsKey(groupId)))
                        {
                            UserGroup biz = new UserGroup();
                            biz[UserGroup.UserId]  = userId.Value;
                            biz[UserGroup.GroupId] = groupId;
                            biz.Save();
                        }
                        // if unchecked and currently assigned, remove
                        else if (!isNewUser && !item.Selected && currentGroups.ContainsKey(groupId))
                        {
                            int       userGroupId = currentGroups[groupId];
                            UserGroup biz         = new UserGroup();
                            biz.Delete(userGroupId);
                        }
                    }
                }

                // reload page for new user
                //if (isNewUser)
                //{
                //    Response.Redirect("User_Edit.aspx?userId=" + userId.Value + (EmailUser.Checked ? "#EmailUserTab" : ""));
                //}
                // otherwise, re-populate
                //else
                //{
                // repopulate patient and groups
                PopulateUser(userId.Value);
                BuildUserGroups(userId);

                // email frame
                SetUserEmailFrame(userId, EmailUser.Checked ? clearPassword : "");
                if (isNewUser)
                {
                    if (EmailUser.Checked)
                    {
                        Page.ClientScript.RegisterStartupScript(this.GetType(), "setActiveTab", "setActiveTab('email');", true);
                    }
                    SetUpdatedMessage("User '" + Username.Value + "' has been created.");
                }
                else
                {
                    SetUpdatedMessage("User '" + Username.Value + "' has been updated.");
                }
                //}
            }
            else
            {
                SetUpdatedMessage("A user with this username already exists.");
            }

            // check if adding a new user attribute
            AddUserAttribute(sender, e);
        }