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 System.Text;
using System.Collections.Generic;

public partial class showNotes : System.Web.UI.Page
{

    public string codiceFiscale;
    public string codiceFiscaleReport;
    public string codiceRete;
    public string codicePB;
    public int noteId;
    public string textNote;
    public string token;
    public string idReportToLoadBack;
    public string tpReportLauncher;
    public string pathNav;

    private string dayDaQ;
    private string dayAQ;
    private string rsd;
    private string rsp;
    private string nomeQ;
    private string cognomeQ;
    private int _pdfC6;

   
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!Page.IsPostBack)
        {
            //codiceFiscale = Request.QueryString.Get("codcliente");
            //codiceFiscaleReport = Request.QueryString.Get("codclienteReport");
            //codiceRete = Request.QueryString.Get("tipoRete");
            //codicePB = Request.QueryString.Get("codPB");
            //token = Request.QueryString.Get("token");
            //_pdfC6 = Convert.ToInt32(Request.QueryString.Get("pdfC6"));

            //dayAQ = Request.QueryString.Get("dayA");
            //dayDaQ = Request.QueryString.Get("dayDa");
            //rsd = Request.QueryString.Get("rsd");
            //rsp = Request.QueryString.Get("rsp");
            //nomeQ = Request.QueryString.Get("nome");
            //cognomeQ = Request.QueryString.Get("cognome");

            ////// idReportToLoadBack = Request.QueryString.Get("idReportToLoad");
            ////int idtpReportLauncher = Convert.ToInt32(Request.QueryString.Get("tpoReport"));
            tpReportLauncher = Request.QueryString.Get("TipologiaReport");




            pathNav = Request.QueryString.Get("pathNav");

            //if (codiceFiscale == null)
            //{
            //    //prendo i valori dai cookies
            //    HttpCookie ck_codiceFiscale = new HttpCookie("codiceFiscale");
            //    ck_codiceFiscale = System.Web.HttpContext.Current.Request.Cookies["codiceFiscale"];
            //    if (ck_codiceFiscale != null)
            //    {
            //        codiceFiscale = ck_codiceFiscale.Value;
            //    }
            //}

            //if (codiceRete == null)
            //{
            //    HttpCookie ck_codiceRete = new HttpCookie("codiceRete");
            //    ck_codiceRete = System.Web.HttpContext.Current.Request.Cookies["codiceRete"];
            //    if (ck_codiceRete != null)
            //    {
            //        codiceRete = ck_codiceRete.Value;
            //    }
            //}

            //if (codicePB == null)
            //{
            //    HttpCookie ck_codicePB = new HttpCookie("codicePB");
            //    ck_codicePB = System.Web.HttpContext.Current.Request.Cookies["codicePB"];
            //    if (ck_codicePB != null)
            //    {
            //        codicePB = ck_codicePB.Value;
            //    }
            //}

            noteId = Convert.ToInt32(Request.QueryString.Get("noteId"));            
            lblData.Text = DateTime.Now.ToShortDateString();
            lblOra.Text = DateTime.Now.ToLongTimeString();

            getNoteFromDB();

            //getIdClienteFromCodFiscale();
            this.LabelReport.Text = tpReportLauncher.ToUpper();
            this.LabelCliente.Text = Request.QueryString.Get("nominativoCliente");

            //this.notePanel.InnerText = textNote;
        }
    }
   
    private void getNoteFromDB()
    {
        List<Parametro> parametri = new List<Parametro>();
        Parametro parametro = new Parametro();
        parametro.DbType = DbType.Int32;
        parametro.Value = noteId;
        parametro.ParameterName = "noteId";
        parametri.Add(parametro);

        Parametro pdfC6 = new Parametro();
        pdfC6.DbType = DbType.Int32;
        pdfC6.Value = _pdfC6;
        pdfC6.ParameterName = "pdfC6";
        parametri.Add(pdfC6);

        DataTable dt = DataAccess.ExecuteDataTableStoredProcedure(DBProvider.SqlServer, "sp_getNote_ByNoteId", parametri);

        DateTime date = DateTime.Now;

        if (dt.Rows.Count > 0)
        {
            textNote = dt.Rows[0]["Note"].ToString();
            date = Convert.ToDateTime(dt.Rows[0]["DtCreazione"]);
        }
        lblData.Text = date.ToShortDateString();
        lblOra.Text = date.ToShortTimeString();
    }

    protected void Button2_Click(object sender, EventArgs e)
    {
        Server.Transfer("archiviodocumenti.aspx", true);
    }
}