예제 #1
0
        public static List<Empresa> GetAllBusinessByParametersLike(EmpresaFilters filters)
        {
            var param = new List<SPParameter> { new SPParameter("Razon_Social", filters.RazonSocial ?? (object)DBNull.Value),
                                                new SPParameter("Cuit", filters.Cuit ?? (object)DBNull.Value),
                                                new SPParameter("Email", filters.Email ?? (object)DBNull.Value)};

            var sp = new StoreProcedure(DataBaseConst.Empresa.SPGetAllBusinessByParametersLike, param);

            return sp.ExecuteReader<Empresa>();
        }
예제 #2
0
        private void LblBuscar_Click(object sender, EventArgs e)
        {
            try
            {
                #region Validations

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

                if (!TypesHelper.IsEmpty(TxtRazonSocial.Text))
                    filtersSetted = true;

                if (!TypesHelper.IsEmpty(TxtCuit.Text))
                {
                    filtersSetted = true;
                    if (!TypesHelper.IsCUITValid(TxtCuit.Text))
                        exceptionMessage += Environment.NewLine + "El cuit no es un cuit válido.";
                }

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

                if (!filtersSetted)
                    exceptionMessage = "No se puede realizar la busqueda ya que no se informó ningún filtro";

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

                #endregion

                var filters = new EmpresaFilters
                {

                    RazonSocial = (!TypesHelper.IsEmpty(TxtRazonSocial.Text)) ? TxtRazonSocial.Text : null,
                    Cuit = (!TypesHelper.IsEmpty(TxtCuit.Text)) ? TxtCuit.Text : null,
                    Email = (!TypesHelper.IsEmpty(TxtEmail.Text)) ? TxtEmail.Text : null
                    };

                var empresas = (ChkBusquedaExacta.Checked) ? EmpresaPersistance.GetAllBusinessByParameters(filters) : EmpresaPersistance.GetAllBusinessByParametersLike(filters);

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

                RefreshSources(empresas);
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "Atención");
            }
        }