Пример #1
0
        public static List <Cliente> GetAllClientsByParametersLike(ClienteFilters filters)
        {
            var param = new List <SPParameter> {
                new SPParameter("Nombre", filters.Nombre ?? (object)DBNull.Value),
                new SPParameter("Apellido", filters.Apellido ?? (object)DBNull.Value),
                new SPParameter("Tipo_Documento", filters.TipoDocumento ?? (object)DBNull.Value),
                new SPParameter("Nro_Documento", filters.NroDocumento ?? (object)DBNull.Value),
                new SPParameter("Email", filters.Email ?? (object)DBNull.Value)
            };

            var sp = new StoreProcedure(DataBaseConst.Cliente.SPGetAllClientsByParametersLike, param);

            return(sp.ExecuteReader <Cliente>());
        }
Пример #2
0
        private void LblBuscar_Click(object sender, EventArgs e)
        {
            try
            {
                #region Validations

                var filtersSetted    = false;
                var exceptionMessage = string.Empty;

                if (!TypesHelper.IsEmpty(TxtNombre.Text))
                {
                    filtersSetted = true;
                }

                if (!TypesHelper.IsEmpty(TxtApellido.Text))
                {
                    filtersSetted = true;
                }

                if (!TypesHelper.IsEmpty(CboTipoDocumento.Text))
                {
                    filtersSetted = true;
                }

                if (!TypesHelper.IsEmpty(TxtDocumento.Text))
                {
                    filtersSetted = true;
                }

                int document;
                if (int.TryParse(TxtDocumento.Text, out document))
                {
                    filtersSetted = true;
                }

                if (!TypesHelper.IsEmpty(TxtEmail.Text))
                {
                    filtersSetted = true;
                }

                if (!filtersSetted)
                {
                    exceptionMessage = "No se puede realizar la búsqueda. Verifique que haya ingresado algún filtro y que los mismos sean válidos.";
                }

                if (!TypesHelper.IsEmpty(exceptionMessage))
                {
                    throw new Exception(exceptionMessage);
                }

                #endregion

                //Cargar los filtros ingresados en el objeto de tipo ClienteFilters
                var filters = new ClienteFilters
                {
                    Nombre        = (!TypesHelper.IsEmpty(TxtNombre.Text)) ? TxtNombre.Text : null,
                    Apellido      = (!TypesHelper.IsEmpty(TxtApellido.Text)) ? TxtApellido.Text : null,
                    TipoDocumento = (!TypesHelper.IsEmpty(CboTipoDocumento.Text)) ? (int)CboTipoDocumento.SelectedValue : (int?)null,
                    NroDocumento  = (!TypesHelper.IsEmpty(TxtDocumento.Text)) ? Convert.ToInt32(TxtDocumento.Text) : (int?)null,
                    Email         = (!TypesHelper.IsEmpty(TxtEmail.Text)) ? TxtEmail.Text : null
                };

                var clientes = (ChkBusquedaExacta.Checked) ? ClientePersistance.GetAllClientsByParameters(filters) : ClientePersistance.GetAllClientsByParametersLike(filters);

                if (clientes == null || clientes.Count == 0)
                {
                    throw new Exception("No se encontraron clientes según los filtros informados.");
                }

                //Refrescar la grilla, cargando los Clientes que se obtuvieron como resultado de los filtros
                RefreshSources(clientes);
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "Atención");
            }
        }