Example #1
0
        private void bRoleEdit_Click(object sender, EventArgs e)
        {
            FormCreateRole crRole = new FormCreateRole();

            RoleRepository             roleRep    = new RoleRepository();
            Roles                      role       = bindingSourceUserinRoles.Current as Roles;
            List <BusinessUserInRoles> busUsinRol = new List <BusinessUserInRoles>();

            crRole.Rolename = role.RoleName;
            crRole.UEForm   = this;
            this.Visible    = false;
            if (crRole.ShowDialog() == DialogResult.OK)
            {
                busUsinRol = DeleteUserinRoles(role); // Удаляем связи роли с пользователями
                roleRep.Delete(role);
                role          = new Roles();
                role.RoleName = crRole.tbRoleName.Text;
                roleRep.Create(role);
                MessageBox.Show("Role Edit");
                GetRoles();

                if (busUsinRol.Count > 0)
                {
                    BusinessUserInRoles           obj  = new BusinessUserInRoles();
                    BusinessUserInRolesRepository brep = new BusinessUserInRolesRepository();
                    obj.RoleId = role.RoleId;
                    for (int i = 0; i < busUsinRol.Count; i++)
                    {
                        obj.UserId   = busUsinRol[i].UserId;
                        obj.HireDate = busUsinRol[i].HireDate;
                        brep.Create(obj);
                    }
                }
            }
        }
Example #2
0
        private void bUserEdit_Click(object sender, EventArgs e)
        {
            FormCreateUser crUser = new FormCreateUser();

            UserRepository             userRep    = new UserRepository();
            Users                      user       = bindingSourceUserinRoles.Current as Users;
            List <BusinessUserInRoles> busUsinRol = new List <BusinessUserInRoles>();

            crUser.UserName     = user.UserName;
            crUser.UserPassword = user.UserPassword;
            crUser.DateBirthday = user.DateBirthday;
            crUser.FirstName    = user.FirstName;
            crUser.LastName     = user.LastName;
            crUser.Telephon     = user.Telephon;
            crUser.UEForm       = this;
            this.Visible        = false;
            if (crUser.ShowDialog() == DialogResult.OK)
            {
                busUsinRol = DeleteUserinRoles(user);// Удаляем связи пользователя с ролями
                userRep.Delete(user);
                user              = new Users();
                user.UserName     = crUser.tbUserName.Text;
                user.UserPassword = crUser.tbUserPassword.Text;
                user.DateBirthday = crUser.dtpDateBirthday.Value.Date;
                user.FirstName    = crUser.tbFirstName.Text;
                user.LastName     = crUser.tbLastName.Text;
                user.Telephon     = crUser.tbTelephon.Text;
                userRep.Create(user);
                MessageBox.Show("User Edit");
                GetUsers();

                if (busUsinRol.Count > 0)
                {
                    BusinessUserInRoles           obj  = new BusinessUserInRoles();
                    BusinessUserInRolesRepository brep = new BusinessUserInRolesRepository();
                    obj.UserId = user.UserId;

                    for (int i = 0; i < busUsinRol.Count; i++)
                    {
                        obj.RoleId   = busUsinRol[i].RoleId;
                        obj.HireDate = busUsinRol[i].HireDate;
                        brep.Create(obj);
                    }
                }
            }
        }
Example #3
0
        private void bCreate_Click(object sender, EventArgs e)
        {
            BusinessUserInRoles obj = new BusinessUserInRoles();

            obj.UserId = Convert.ToInt32(cbUsers.SelectedValue);

            FormEditUserInRoles feuir = new FormEditUserInRoles();

            feuir.UEForm = this;
            this.Visible = false;
            if (feuir.ShowDialog() == DialogResult.OK)
            {
                obj.RoleId   = Convert.ToInt32(feuir.cbRoles.SelectedValue);
                obj.HireDate = feuir.dtpHireDate.Value.Date;
                BusinessUserInRolesRepository brep = new BusinessUserInRolesRepository();
                brep.Create(obj);
                GetUserRoles(obj.UserId, 0);
            }
        }