Exemplo n.º 1
0
        private void BtnEditar_Click(object sender, EventArgs e)
        {
            Rol rolSeleccionado = new Rol();

            if (DgRoles.SelectedRows.Count > 0)
            {
                BindingSource bs = DgRoles.DataSource as BindingSource;
                if (bs != null)
                {
                    rolSeleccionado = (Rol)bs.List[bs.Position];
                }
            }

            var altaRol = new AltaRol();

            altaRol.Text = Resources.EdicionRol;
            altaRol.Rol  = rolSeleccionado;

            var result = altaRol.ShowDialog();

            if (result.Equals(DialogResult.OK))
            {
                BindingList <Rol> dataSource = new BindingList <Rol>(RolesServices.GetAllData());
                BindingSource     bs         = new BindingSource {
                    DataSource = dataSource
                };

                DgRoles.DataSource = bs;
            }
        }
Exemplo n.º 2
0
        private void BtnAgregar_Click(object sender, EventArgs e)
        {
            var altaRol = new AltaRol();

            altaRol.Rol = Usuario.RolActivo != null ? Usuario.RolActivo : new Rol();
            var result = altaRol.ShowDialog();

            if (result.Equals(DialogResult.OK))
            {
                BindingList <Rol> dataSource = new BindingList <Rol>(RolesServices.GetAllData());
                BindingSource     bs         = new BindingSource {
                    DataSource = dataSource
                };

                DgRoles.DataSource = bs;
            }
        }