using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace QW2021C.Reporting
{
    public partial class Reporting : System.Web.UI.Page
    {
        Helper.Log log = new Helper.Log();

        protected void Page_Load(object sender, EventArgs e)
        {
            if (Page.IsPostBack==false)
            {

                log.insert_entry(2, Convert.ToInt32(Session["UserID"]), "Report: " + Session["xmldata"].ToString());
                show_report(Session["Reportname"].ToString(), Session["xmldata"].ToString());
                //show_report(Session["Reportname"].ToString(), Session["xmldata"].ToString());
                //show_report(Session["Reportname"].ToString(), Session["xmldata"].ToString());
                WebReport1.Visible = true;
                WebReport1.Zoom = 1;
                log.insert_entry(2, Convert.ToInt32(Session["UserID"]), "Report erstellt");
            }
        }

        public void show_report(string reportname, string xmldata)
        {
            DataSet ds = new DataSet();
            ds.ReadXml(Server.MapPath("~/Downloads") + "\\" + xmldata);
            ds.Tables[0].TableName = "Daten";
            WebReport1.ReportFile = Server.MapPath("~/Reports") + "\\" + reportname;
            WebReport1.RegisterData(ds);
            WebReport1.DataBind();
            WebReport1.Prepare();
            //WebReport.Report.RegisterData(ds);
        }

        protected void WebReport_StartReport(object sender, EventArgs e)
        {
            WebReport1.Report.SetParameterValue("Param1", Session["Vereinnr"].ToString());
        }
    }
}