Ejemplo n.º 1
0
        private void obtenerAplicarFiltro()
        {
            try
            {
                IEnumerable <tbDocumento> fact = factIns.getListAllDocumentos();
                fact = fact.Where(x => x.estado == true && x.tipoDocumento == (int)Enums.TipoDocumento.Proforma);


                if (txtFactura.Text != string.Empty)
                {
                    fact = fact.Where(x => x.id == int.Parse(txtFactura.Text.Trim()));
                }

                if (txtCedula.Text != string.Empty)
                {
                    fact = fact.Where(x => x.idCliente != null && x.idCliente.Trim() == txtCedula.Text.Trim());
                }

                if (txtNombre.Text != string.Empty)
                {
                    fact = fact.Where(x => x.idCliente != null && x.tbClientes.tbPersona.nombre.ToUpper().Contains(txtNombre.Text.ToUpper().Trim()));
                }


                if (txtApell1.Text != string.Empty)
                {
                    fact = fact.Where(x => x.idCliente != null && x.tbClientes.tbPersona.apellido1 != null && x.tbClientes.tbPersona.apellido1.ToUpper().Contains(txtApell1.Text.ToUpper().Trim()));
                }
                if (txtApell2.Text != string.Empty)
                {
                    fact = fact.Where(x => x.idCliente != null && x.tbClientes.tbPersona.apellido2 != null && x.tbClientes.tbPersona.apellido2.ToUpper().Contains(txtApell2.Text.ToUpper().Trim()));
                }

                fact = fact.OrderByDescending(x => x.id);
                cargarLista(fact);
            }
            catch (Exception ex)
            {
                MessageBox.Show("Error al consultar datos, favor verificar los datos ingresdos.", "Datos errones", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
Ejemplo n.º 2
0
        private void obtenerAplicarFiltro()
        {
            bool bandera = true;

            try
            {
                IEnumerable <tbDocumento> fact = null;
                fact = factIns.getListAllDocumentos();



                bool estado = (int)cboEstado.SelectedValue == 0 ? false : true;
                fact = fact.Where(x => x.estado == estado);
                fact = fact.OrderByDescending(x => x.id);



                if ((int)cboTipoDoc.SelectedValue != (int)Enums.TipoDocumento.Todos)
                {
                    if (cboTipoDoc.Text != string.Empty)
                    {
                        fact = fact.Where(x => x.tipoDocumento == (int)cboTipoDoc.SelectedValue);
                    }
                }

                if (txtFactura.Text != string.Empty)
                {
                    fact = fact.Where(x => x.id == int.Parse(txtFactura.Text.Trim()));
                }

                if (txtConsecutivo.Text != string.Empty)
                {
                    fact = fact.Where(x => x.consecutivo != null & x.consecutivo == txtConsecutivo.Text.Trim());
                }

                if (txtClave.Text != string.Empty)
                {
                    fact = fact.Where(x => x.clave != null && x.clave == txtClave.Text.Trim());
                }

                if (txtCedula.Text != string.Empty)
                {
                    fact = fact.Where(x => x.idCliente != null && x.idCliente.Trim() == txtCedula.Text.Trim());
                }

                if (txtNombre.Text != string.Empty)
                {
                    fact = fact.Where(x => x.idCliente != null && x.tbClientes.tbPersona.nombre.ToUpper().Contains(txtNombre.Text.ToUpper().Trim()));
                }


                if (txtApell1.Text != string.Empty)
                {
                    fact = fact.Where(x => x.idCliente != null && x.tbClientes.tbPersona.apellido1 != null && x.tbClientes.tbPersona.apellido1.ToUpper().Contains(txtApell1.Text.ToUpper().Trim()));
                }
                if (txtApell2.Text != string.Empty)
                {
                    fact = fact.Where(x => x.idCliente != null && x.tbClientes.tbPersona.apellido2 != null && x.tbClientes.tbPersona.apellido2.ToUpper().Contains(txtApell2.Text.ToUpper().Trim()));
                }


                if (chkFechas.Checked)
                {
                    if (dtpInicio.Value.Date > dtpFin.Value.Date)
                    {
                        MessageBox.Show("La fecha de inicio no puede ser mayor que la fecha final", "Datos fechas", MessageBoxButtons.OK, MessageBoxIcon.Error);

                        bandera = false;
                    }
                    else
                    {
                        DateTime fechaInicio = dtpInicio.Value.Date;
                        DateTime fechaFin    = dtpFin.Value.Date.AddDays(1);

                        fact = fact.Where(x => x.fecha >= fechaInicio && x.fecha <= fechaFin);
                    }
                }
                if (bandera)
                {
                    cargarLista(fact);
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("Error al consultar datos, favor verificar los datos ingresdos.", "Datos errones", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }