using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using CrystalDecisions.CrystalReports.Engine;
using CrystalDecisions.Shared;
using CrystalDecisions.Web.Design;
using System.IO;
using DL;

using System.Reflection;

public partial class rpt_EstadoCuenta : System.Web.UI.Page
{
    ReportDocument reportDocument = new ReportDocument();
    ParameterField paramField = new ParameterField();
    ParameterFields paramFields = new ParameterFields();
    ParameterDiscreteValue paramDiscreteValue = new ParameterDiscreteValue();

    string reportPath;


    protected void Page_Load(object sender, EventArgs e)
    {

    }

    private void Page_Init(object sender, EventArgs e)
    {
        btnShowReport();
    }
    protected void btnShowReport()
    {

        String strServidor = "";
        String strBaseDatos = "";
        String strUsuario = "";
        String strClave = "";

        reportPath = Server.MapPath(ConfigurationManager.AppSettings.Get("rptEstadoCuenta"));

        if (ConfigurationSettings.AppSettings.Get("TipoConexion").ToString() == "1")
        {
            strServidor = Encriptador.Encriptador.f_desencriptar(ConfigurationSettings.AppSettings.Get("Servidor"));
            strBaseDatos = Encriptador.Encriptador.f_desencriptar(ConfigurationSettings.AppSettings.Get("BaseDatos"));
            strUsuario = Encriptador.Encriptador.f_desencriptar(ConfigurationSettings.AppSettings.Get("Usuario"));
            strClave = Encriptador.Encriptador.f_desencriptar(ConfigurationSettings.AppSettings.Get("Clave"));
        }

        reportDocument.Load(reportPath);

        reportDocument.DataSourceConnections[0].SetConnection(strServidor, strBaseDatos, strUsuario, strClave);

        reportDocument.SetParameterValue("@EmpresaID", Request.QueryString["ep"]);
        reportDocument.SetParameterValue("@Ejercicio", Request.QueryString["ej"]);
        reportDocument.SetParameterValue("@WhereCondition", Session["wc"]);
        reportDocument.SetParameterValue("@OrderByExpression", Session["ob"]);
        reportDocument.SetParameterValue("@mes", Request.QueryString["mes"]);

        //if (Request.QueryString["MON"].Trim() == "1")
        //{
        //    reportDocument.SetParameterValue("@Expresado", "Soles");
        //}
        //else
        //{
        //    reportDocument.SetParameterValue("@Expresado", "Dolares");
        //}
        //reportDocument.SetParameterValue("@CodigoCuenta", "10111 - Caja General - Soles");

        CrystalReportViewer1.ReportSource = reportDocument;
        CrystalReportViewer1.DataBind();
    }


}
