Ejemplo n.º 1
0
        private void Mostrar(bool a_pantalla)
        {
            Sesion          sesion        = (Sesion)Session["Sesion" + Session.SessionID];
            SerRutaServicio rutaServicio  = new SerRutaServicio();
            int             error         = 0;
            double          cliente1      = txtCliente.Value != null ? txtCliente.Value.Value : 0;
            double          cliente2      = txtCliente2.Value != null ? txtCliente2.Value.Value : 0;
            string          sCliente1     = string.Empty;
            string          sFechaInicial = string.Empty;
            string          sFechaFinal   = string.Empty;
            DateTime        FechaInicial  = new DateTime();
            DateTime        FechaFinal    = new DateTime();

            rutaServicio.Id_Cd = sesion.Id_Cd_Ver;
            if (string.IsNullOrEmpty(txtFechaini.SelectedDate.Value.ToString()))
            {
                error = 1;
            }
            if (string.IsNullOrEmpty(txtFechafin.SelectedDate.Value.ToString()))
            {
                error = 1;
            }
            if (txtFechaini.SelectedDate > txtFechafin.SelectedDate)
            {
                Alerta("La fecha inicial no debe ser mayor a la fecha final");
                return;
            }
            else
            {
                if (cliente2 < cliente1)
                {
                    Alerta("El cliente final no debe ser menor al cliente inicial");
                    return;
                }
                else
                {
                    if (!string.IsNullOrEmpty(txtFechaini.SelectedDate.ToString()))
                    {
                        FechaInicial  = txtFechaini.SelectedDate.Value;
                        sFechaInicial = txtFechaini.SelectedDate.Value.ToString("dd/MM/yyy");
                    }
                    if (!string.IsNullOrEmpty(txtFechafin.SelectedDate.ToString()))
                    {
                        FechaFinal  = txtFechafin.SelectedDate.Value;
                        sFechaFinal = txtFechafin.SelectedDate.Value.ToString("dd/MM/yyy");
                    }
                    else
                    {
                        sFechaFinal = "Actual";
                    }
                }
            }

            if (cliente1 == 0)
            {
                sCliente1 = "0";
            }
            else
            {
                sCliente1 = "De " + cliente1.ToString();
            }

            if (cliente2 == 0)
            {
                if (cliente1 == 0)
                {
                    sCliente1 = "Todos";
                }
                else
                {
                    sCliente1 += " en adelante";
                }
            }
            else
            {
                if (cliente1 == cliente2)
                {
                    sCliente1 = cliente2.ToString();
                }
                else
                {
                    sCliente1 += " a " + cliente2.ToString();
                }
            }
            ArrayList ALValorParametrosInternos = new ArrayList();

            string nombreEmpresa  = sesion.Emp_Nombre;
            string nombreSucursal = sesion.Cd_Nombre;

            DateTime Fechalocal = DateTime.Now;

            //datos de filtros
            ALValorParametrosInternos.Add(FechaInicial);
            ALValorParametrosInternos.Add(FechaFinal);
            ALValorParametrosInternos.Add(cliente1);
            ALValorParametrosInternos.Add(cliente2);
            ALValorParametrosInternos.Add(sCliente1);
            ALValorParametrosInternos.Add(sFechaInicial);
            ALValorParametrosInternos.Add(sFechaFinal);
            //parametros para el cuerpo del reporte
            ALValorParametrosInternos.Add(sesion.Id_Emp);
            ALValorParametrosInternos.Add(sesion.Id_Cd_Ver);
            ALValorParametrosInternos.Add(sesion.U_Nombre);
            ALValorParametrosInternos.Add(Fechalocal);
            ALValorParametrosInternos.Add(nombreEmpresa);
            ALValorParametrosInternos.Add(nombreSucursal);
            //conexion
            ALValorParametrosInternos.Add(sesion.Emp_Cnx);
            Type instance = null;

            if (a_pantalla)
            {
                instance = typeof(LibreriaReportes.Rep_FacturacionxCte);
            }
            else
            {
                instance = typeof(LibreriaReportes.ExpRep_FacturacionxCte);
            }

            if (error == 0)
            {
                if (a_pantalla)
                {
                    Session["InternParameter_Values" + Session.SessionID + HF_ClvPag.Value] = null;
                    Session["InternParameter_Values" + Session.SessionID + HF_ClvPag.Value] = ALValorParametrosInternos;
                    Session["assembly" + Session.SessionID + HF_ClvPag.Value] = instance.AssemblyQualifiedName;
                    RAM1.ResponseScripts.Add("AbrirReporteCve('" + HF_ClvPag.Value + "');");
                }
                else
                {
                    ImprimirXLS(ALValorParametrosInternos, instance);
                }
            }
        }
Ejemplo n.º 2
0
        private void Mostrar(bool a_pantalla)
        {
            Sesion          sesion       = (Sesion)Session["Sesion" + Session.SessionID];
            SerRutaServicio rutaServicio = new SerRutaServicio();
            int             error        = 0;

            rutaServicio.Id_Cd = sesion.Id_Cd_Ver;
            if (string.IsNullOrEmpty(txtFechaini.SelectedDate.Value.ToString()))
            {
                error = 1;
            }
            if (string.IsNullOrEmpty(txtFechafin.SelectedDate.Value.ToString()))
            {
                error = 1;
            }
            if (txtFechaini.SelectedDate > txtFechafin.SelectedDate)
            {
                Alerta("La fecha inicial no debe ser mayor a la fecha final");
                return;
            }
            else
            {
                if (!string.IsNullOrEmpty(txtFechaini.SelectedDate.ToString()))
                {
                    rutaServicio.FechaInicial  = txtFechaini.SelectedDate.Value;
                    rutaServicio.SfechaInicial = txtFechaini.SelectedDate.Value.ToString("dd/MM/yyy");
                }
                if (!string.IsNullOrEmpty(txtFechafin.SelectedDate.ToString()))
                {
                    rutaServicio.FechaFinal  = txtFechafin.SelectedDate.Value;
                    rutaServicio.SfechaFinal = txtFechafin.SelectedDate.Value.ToString("dd/MM/yyy");
                }
                else
                {
                    rutaServicio.SfechaFinal = "Actual";
                }
            }
            if (!string.IsNullOrEmpty(txtRuta.Text))
            {
                boton(txtRuta.Text, ref error);
                rutaServicio.Ruta  = txtRuta.Text;
                rutaServicio.Sruta = txtRuta.Text;
            }
            else
            {
                rutaServicio.Sruta = "Todas";
            }

            if (!string.IsNullOrEmpty(txtTerr.Text))
            {
                boton(txtTerr.Text, ref error);
                rutaServicio.Territorio  = txtTerr.Text;
                rutaServicio.Sterritorio = txtTerr.Text;
            }
            else
            {
                rutaServicio.Sterritorio = "Todos";
            }

            if (!string.IsNullOrEmpty(txtCliente.Text))
            {
                boton(txtCliente.Text, ref error);
                rutaServicio.Cliente  = txtCliente.Text;
                rutaServicio.Scliente = txtCliente.Text;
            }
            else
            {
                rutaServicio.Scliente = "Todos";
            }

            rutaServicio.Orden   = Convert.ToInt32(cmbOrden.SelectedValue);
            rutaServicio.Sorden  = cmbOrden.SelectedItem.Text;
            rutaServicio.Detalle = chkDetalle.Checked;
            if (rutaServicio.Detalle)
            {
                rutaServicio.Reporte1 = 1;
            }
            else
            {
                rutaServicio.Reporte1 = 2;
            }

            ArrayList ALValorParametrosInternos = new ArrayList();

            CN_SerRutaServicio serRuta        = new CN_SerRutaServicio();
            string             nombreEmpresa  = sesion.Emp_Nombre;
            string             nombreSucursal = sesion.Cd_Nombre;

            DateTime Fechalocal = DateTime.Now;

            //datos de filtros
            ALValorParametrosInternos.Add(rutaServicio.FechaInicial);
            ALValorParametrosInternos.Add(rutaServicio.FechaFinal);
            ALValorParametrosInternos.Add(rutaServicio.Ruta);
            ALValorParametrosInternos.Add(rutaServicio.Sruta);
            ALValorParametrosInternos.Add(rutaServicio.Territorio);
            ALValorParametrosInternos.Add(rutaServicio.Sterritorio);
            ALValorParametrosInternos.Add(rutaServicio.Cliente);
            ALValorParametrosInternos.Add(rutaServicio.Scliente);
            ALValorParametrosInternos.Add(rutaServicio.Orden);
            ALValorParametrosInternos.Add(rutaServicio.Sorden);
            ALValorParametrosInternos.Add(rutaServicio.SfechaInicial);
            ALValorParametrosInternos.Add(rutaServicio.SfechaFinal);
            ALValorParametrosInternos.Add(rutaServicio.Reporte1);
            //parametros para el cuerpo del reporte
            ALValorParametrosInternos.Add(sesion.Id_Emp);
            ALValorParametrosInternos.Add(rutaServicio.Id_Cd);
            ALValorParametrosInternos.Add(sesion.U_Nombre);
            ALValorParametrosInternos.Add(Fechalocal);
            ALValorParametrosInternos.Add(nombreEmpresa);
            ALValorParametrosInternos.Add(nombreSucursal);
            //conexion
            ALValorParametrosInternos.Add(sesion.Emp_Cnx);
            Type instance = null;

            if (rutaServicio.Detalle)
            {//formato1
                if (a_pantalla)
                {
                    instance = typeof(LibreriaReportes.Rep_SerRutaServicio1);
                }
                else
                {
                    instance = typeof(LibreriaReportes.ExpRep_SerRutaServicio1);
                }
            }
            else
            {//formato2
                if (a_pantalla)
                {
                    instance = typeof(LibreriaReportes.Rep_SerRutaServicio2);
                }
                else
                {
                    instance = typeof(LibreriaReportes.ExpRep_SerRutaServicio2);
                }
            }
            //NOTA: El estatus de impresión, lo pone cuando el reporte se carga

            if (error == 0)
            {
                if (a_pantalla)
                {
                    Session["InternParameter_Values" + Session.SessionID + HF_ClvPag.Value] = null;
                    Session["InternParameter_Values" + Session.SessionID + HF_ClvPag.Value] = ALValorParametrosInternos;
                    Session["assembly" + Session.SessionID + HF_ClvPag.Value] = instance.AssemblyQualifiedName;
                    RAM1.ResponseScripts.Add("AbrirReporteCve('" + HF_ClvPag.Value + "');");
                }
                else
                {
                    ImprimirXLS(ALValorParametrosInternos, instance);
                }
            }
        }