コード例 #1
0
ファイル: MainRol.cs プロジェクト: TamiBerrocal/MercadoEnvio
        private void BtnBuscar_Click(object sender, EventArgs e)
        {
            string filtroNombre        = TxtFiltroNombre.Text;
            int    filtroFuncionalidad = ((Funcionalidad)ComboFuncionalidad.SelectedItem).IdFuncionalidad;
            string filtroEstado        = ((Estado)ComboEstado.SelectedItem).Descripcion;

            BindingList <Rol> dataSource = new BindingList <Rol>(RolesServices.FindRoles(filtroNombre, filtroFuncionalidad, filtroEstado));
            BindingSource     bs         = new BindingSource {
                DataSource = dataSource
            };

            DgRoles.DataSource = bs;
        }
コード例 #2
0
ファイル: MainRol.cs プロジェクト: TamiBerrocal/MercadoEnvio
        private void BtnBorrar_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];
                }
            }

            if (rolSeleccionado.Activo)
            {
                string message = RolesServices.DeleteRol(rolSeleccionado);

                if (string.IsNullOrEmpty(message))
                {
                    BindingList <Rol> dataSource = new BindingList <Rol>(RolesServices.FindRoles(string.Empty, 0, string.Empty));
                    BindingSource     bs         = new BindingSource {
                        DataSource = dataSource
                    };

                    DgRoles.DataSource = bs;

                    MessageBox.Show(Resources.RolBorrado, Resources.MercadoEnvio, MessageBoxButtons.OK, MessageBoxIcon.Information);
                }
                else
                {
                    MessageBox.Show(message, Resources.ErrorBorrado, MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }
            else
            {
                MessageBox.Show(Resources.ErrorRolBorrado3, Resources.ErrorBorrado, MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }