Пример #1
0
        private void BtnAgregar_Click(object sender, EventArgs e)
        {
            var altaUsuario = new AltaUsuario(new Usuario());

            altaUsuario.ShowDialog();
        }
Пример #2
0
        private void BtnEditar_Click(object sender, EventArgs e)
        {
            Rol rolSeleccionado = ((Rol)ComboTipoDeUsuario.SelectedItem);

            if (rolSeleccionado.Descripcion.Equals(Resources.Empresa, StringComparison.CurrentCultureIgnoreCase))
            {
                Empresa       empresaSeleccionada = new Empresa();
                BindingSource bs;

                if (DgUsuarios.SelectedRows.Count > 0)
                {
                    bs = DgUsuarios.DataSource as BindingSource;
                    if (bs != null)
                    {
                        empresaSeleccionada = (Empresa)bs.List[bs.Position];
                    }
                }

                var altaUsuario = new AltaUsuario(empresaSeleccionada)
                {
                    Text = Resources.EdicionUsuario
                };
                var result = altaUsuario.ShowDialog();

                if (!result.Equals(DialogResult.OK))
                {
                    return;
                }

                string filtroRazonSocial = TxtFiltroNombre.Text.Trim();
                string filtroCuit        = TxtFiltroCuit.Text.Trim();
                string filtroEmail       = TxtFiltroEmail.Text;

                BindingList <Empresa> dataSource = new BindingList <Empresa>(UsuariosService.FindEmpresas(filtroRazonSocial, filtroCuit, filtroEmail));
                bs = new BindingSource {
                    DataSource = dataSource
                };

                DgUsuarios.Columns.Clear();

                #region rearmadoDeGrilla
                DgUsuarios.Columns.Add(new DataGridViewTextBoxColumn
                {
                    DataPropertyName = "RazonSocial",
                    HeaderText       = Resources.RazonSocial,
                    Name             = "RazonSocial"
                });
                DgUsuarios.Columns.Add(new DataGridViewTextBoxColumn
                {
                    DataPropertyName = "Cuit",
                    HeaderText       = Resources.CUIT,
                    Name             = "Cuit"
                });
                DgUsuarios.Columns.Add(new DataGridViewTextBoxColumn
                {
                    DataPropertyName = "Email",
                    HeaderText       = Resources.Email,
                    Name             = "Email"
                });
                #endregion

                DgUsuarios.DataSource = bs;
            }
            else
            {
                Cliente clienteSeleccionado = new Cliente();

                if (DgUsuarios.SelectedRows.Count > 0)
                {
                    BindingSource bs = DgUsuarios.DataSource as BindingSource;
                    if (bs != null)
                    {
                        clienteSeleccionado = (Cliente)bs.List[bs.Position];
                    }
                }

                var altaUsuario = new AltaUsuario(clienteSeleccionado)
                {
                    Text = Resources.EdicionUsuario
                };
                var result = altaUsuario.ShowDialog();

                if (result.Equals(DialogResult.OK))
                {
                    string filtroNombre   = TxtFiltroNombre.Text.Trim();
                    string filtroDni      = TxtFiltroDNI.Text.Trim();
                    string filtroApellido = TxtFiltroApellido.Text.Trim();
                    string filtroEmail    = TxtFiltroEmail.Text.Trim();

                    BindingList <Cliente> dataSource =
                        new BindingList <Cliente>(UsuariosService.FindClientes(filtroNombre, filtroApellido, filtroDni,
                                                                               filtroEmail));
                    BindingSource bs = new BindingSource();
                    bs.DataSource = dataSource;

                    #region rearmadoDeGrilla
                    DgUsuarios.Columns.Add(new DataGridViewTextBoxColumn
                    {
                        DataPropertyName = "Nombre",
                        HeaderText       = Resources.Nombre,
                        Name             = "Nombre"
                    });
                    DgUsuarios.Columns.Add(new DataGridViewTextBoxColumn
                    {
                        DataPropertyName = "Apellido",
                        HeaderText       = Resources.Apellido,
                        Name             = "Apellido"
                    });
                    DgUsuarios.Columns.Add(new DataGridViewTextBoxColumn
                    {
                        DataPropertyName = "Email",
                        HeaderText       = Resources.Email,
                        Name             = "Email"
                    });
                    DgUsuarios.Columns.Add(new DataGridViewTextBoxColumn
                    {
                        DataPropertyName = "NumeroDoc",
                        HeaderText       = Resources.NoDoc,
                        Name             = "NumeroDoc"
                    });
                    #endregion

                    DgUsuarios.DataSource = bs;
                }
            }
        }