Пример #1
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;
                }
            }
        }
Пример #2
0
        private void BtnBuscar_Click(object sender, EventArgs e)
        {
            Rol rolSeleccionado = ((Rol)ComboTipoDeUsuario.SelectedItem);

            if (rolSeleccionado.Descripcion.Equals(Resources.Empresa, StringComparison.CurrentCultureIgnoreCase))
            {
                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));
                BindingSource         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
            {
                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 {
                    DataSource = dataSource
                };

                DgUsuarios.Columns.Clear();

                #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;
            }
        }
Пример #3
0
        private void BtnBorrar_Click(object sender, EventArgs e)
        {
            Usuario usuarioSeleccionado = new Usuario();

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

            if (usuarioSeleccionado.Activo)
            {
                UsuariosService.DeleteUsuario(usuarioSeleccionado);

                Rol rolSeleccionado = ((Rol)ComboTipoDeUsuario.SelectedItem);

                if (rolSeleccionado.Descripcion.Equals(Resources.Empresa, StringComparison.CurrentCultureIgnoreCase))
                {
                    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));
                    BindingSource         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
                {
                    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 {
                        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;
                }

                MessageBox.Show(Resources.UsuarioBorrado, Resources.MercadoEnvio, MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
            else
            {
                MessageBox.Show(Resources.ErrorUsuarioBorrado, Resources.ErrorBorrado, MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }