Beispiel #1
0
        public DataTable ListaEncabezados(int tipo, String Texto, int idCliente, int Usuario, string Estado, int Caracter, String FechaDesde, String FechaHasta, int vRegPorPagina, bool Extranet)
        {
            String SQLWhere = "";

            if (tipo != -1)
            {
                SQLWhere = SQLWhere + "AND B.idTipoInforme = " + tipo.ToString();
            }

            if (Texto != "")
            {
                SQLWhere = SQLWhere + " AND (B.Nombre like '%" + Texto + "%' ";
                SQLWhere = SQLWhere + " OR B.Apellido like '%" + Texto + "%' ";
                SQLWhere = SQLWhere + " OR B.RazonSocial like '%" + Texto + "%' ";
                SQLWhere = SQLWhere + " OR B.RazonSocial like '%" + Texto + "%' ";
                SQLWhere = SQLWhere + " OR B.DescripcionInf like '%" + Texto + "%' )";
            }

            if (Usuario != -1)
            {
                SQLWhere = SQLWhere + " AND B.idUsuario = " + Usuario.ToString();
            }

            if (idCliente != -1)
            {
                SQLWhere = SQLWhere + " AND B.idCliente = " + idCliente.ToString();
            }

            if (Estado != "")
            {
                string[] Est = Estado.Split(",".ToCharArray());
                if (Est[0] != "-1")
                {
                    SQLWhere = SQLWhere + " AND ( ";
                    for (int i = 0; i < Est.Length; i++)
                    {
                        if (i < Est.Length && i > 0)
                        {
                            SQLWhere = SQLWhere + " OR ";
                        }
                        SQLWhere = SQLWhere + " B.Estado = " + Est[i].ToString();
                    }
                    SQLWhere = SQLWhere + ")";
                }
            }

            if (Caracter != -1)
            {
                SQLWhere = SQLWhere + " AND B.Caracter = " + Caracter.ToString();
            }

            /*else {
             *      if (Extranet) {
             *              SQLWhere = SQLWhere + " AND B.Estado in (1,5,9) ";
             *      }
             * }*/



            if (FechaDesde != "")
            {
                FechaDesde = "'" + FechaDesde + " 00:00:00.000'";
            }
            else
            {
                FechaDesde = DateTime.Today.AddMonths(-3).ToShortDateString();
                FechaDesde = "'" + FechaDesde + " 00:00:00.000'";
            }



            if (FechaHasta != "")
            {
                FechaHasta = "'" + FechaHasta + " 23:59:59.999'";
            }
            else
            {
                FechaHasta = DateTime.Today.ToShortDateString();
                FechaHasta = "'" + FechaHasta + " 23:59:59.999'";
            }

            if (vRegPorPagina != 0)
            {
                intRegPorPagina = vRegPorPagina;
            }

            SQLWhere = SQLWhere + " AND B.FechaCarga BETWEEN '" + FechaDesde + "' AND '" + FechaHasta + "'";

            BandejaEntradaDal bandeja = new BandejaEntradaDal();
            DataTable         Datos;

            if (Extranet)
            {
                Datos = bandeja.ListaEncabezadosExtranet(SQLWhere, Pagina, intRegPorPagina);
            }
            else
            {
                Datos = bandeja.ListaEncabezados(SQLWhere, Pagina, intRegPorPagina);
            }
            intTotalRegistros = bandeja.TotalRegistros;
            intPaginas        = ((int)(intTotalRegistros / intRegPorPagina)) + 1;
            return(Datos);
        }