protected void Page_Load(object sender, EventArgs e)
    {
        if (Session["entry"] == null || !bool.Parse(Session["entry"].ToString()) || Request.QueryString["merchantId"] == null ||
            Session["token"] == null || Request.QueryString["token"] == null ||
            Session["token"].ToString() != Request.QueryString["token"].ToString() ||
            Session["Utente"] == null || Session["settings"] == null)
        {
            Session.Abandon();
            Response.Redirect("login.aspx?path=amzfindcode");
        }

        Year     = (int)Session["year"];
        u        = (UtilityMaietta.Utente)Session["Utente"];
        settings = (UtilityMaietta.genSettings)Session["settings"];

        LavClass.MafraInit folder = LavClass.MAFRA_INIT(Server.MapPath(""));
        if (folder.mafraPath == "")
        {
            folder.mafraPath = Server.MapPath("\\");
        }
        settings.ReplacePath(@folder.mafraInOut1[0], @folder.mafraInOut1[1]);
        settings.ReplacePath(@folder.mafraInOut2[0], @folder.mafraInOut2[1]);
        amzSettings = new AmzIFace.AmazonSettings(settings.lavAmazonSettingsFile, Year);
        amzSettings.ReplacePath(@folder.mafraInOut1[0], @folder.mafraInOut1[1]);
        amzSettings.ReplacePath(@folder.mafraInOut2[0], @folder.mafraInOut2[1]);

        /*string folder = LavClass.MAFRA_FOLDER(Server.MapPath(""));
         * if (folder == "")
         *  folder = Server.MapPath("\\");
         * settings.ReplacePath(@"G:\", @"\\10.0.0.80\c$\");
         * settings.ReplacePath(@"F:\", @"\\10.0.0.2\c$\");
         * amzSettings = new AmzIFace.AmazonSettings(settings.lavAmazonSettingsFile, Year);
         * amzSettings.ReplacePath(@"G:\", @"\\10.0.0.80\c$\");
         * amzSettings.ReplacePath(@"F:\", @"\\10.0.0.2\c$\");*/

        Session["settings"]    = settings;
        Session["amzSettings"] = amzSettings;
        Session["Utente"]      = u;
        aMerchant = new AmzIFace.AmazonMerchant(int.Parse(Request.QueryString["merchantId"].ToString()), amzSettings.Year, amzSettings.marketPlacesFile, amzSettings);
        COUNTRY   = Year + " - " + aMerchant.nazione + "  " + aMerchant.ImageUrlHtml(25, 40, "inherit");

        imgTopLogo.ImageUrl = amzSettings.WebLogo;

        labReturn.Text = "<a href='amzPanoramica.aspx?token=" + Request.QueryString["token"].ToString() +
                         MakeQueryParams() + "' target='_self'>" + labReturn.Text + "</a>";


        if (!Page.IsPostBack && Request.QueryString["findCode"] != null)
        {
            rdbFindByCodiceMa.Checked = true;
            rdbFindBySku.Checked      = false;
            txFindCode.Text           = Request.QueryString["findCode"].ToString();
            btnFindCode_Click(sender, e);
        }
    }
예제 #2
0
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!Page.IsPostBack)
        {
            LavClass.MafraInit folder = LavClass.MAFRA_INIT(Server.MapPath("~"));
            if (folder.mafraPath == "")
            {
                folder.mafraPath = Server.MapPath("\\");
            }
            this.settings = new UtilityMaietta.genSettings(folder.mafraPath);
            settings.ReplacePath(@folder.mafraInOut1[0], @folder.mafraInOut1[1]);
            //settings.ReplacePath(@folder.mafraInOut2[0], @folder.mafraInOut2[1]);

            /*string folder = LavClass.MAFRA_FOLDER(Server.MapPath("~"));
             * if (folder == "")
             *  folder = Server.MapPath("\\");
             * this.settings = new UtilityMaietta.genSettings(folder + "files\\mafra_conf.xml");
             * settings.ReplacePath(@"G:\", @"\\10.0.0.80\c$\");*/
            Session["settings"] = settings;

            if (Request.Cookies["authcookie"] != null)
            {
                txUserName.Text = sDecrypt(Request.Cookies["authcookie"]["username"].ToString());
                txPassword.Attributes["value"] = sDecrypt(Request.Cookies["authcookie"]["password"].ToString());
            }
        }
        else
        {
            if (Request.Form["chkAmazon"] != null && Request.Form["chkAmazon"].ToString() == "on" && Request.Form["rdgMerchant"] == null)
            {
                Response.Redirect("login.aspx");
            }
            else if (Request.Form["chkAmazon"] != null && Request.Form["chkAmazon"].ToString() == "on" && Request.Form["rdgMerchant"] != null)
            {
                amid = int.Parse(Request.Form["rdgMerchant"].ToString());
            }
            else if (Request.Form["chkAmazon"] == null)
            {
                amid = 1;
            }
            this.settings = (UtilityMaietta.genSettings)Session["settings"];
        }

        if (!File.Exists(settings.userFile))
        {
            Response.Write("File Utente inesistente:  " + settings.userFile);
        }

        fillMerchants(settings);
        fillYear();
    }
    protected void Page_Load(object sender, EventArgs e)
    {
        Year = (int)Session["year"];
        if (!Page.IsPostBack)
        {
            LavClass.MafraInit folder = LavClass.MAFRA_INIT(Server.MapPath(""));
            if (folder.mafraPath == "")
            {
                folder.mafraPath = Server.MapPath("\\");
            }
            this.settings = new UtilityMaietta.genSettings(folder.mafraPath);
            settings.ReplacePath(@folder.mafraInOut1[0], @folder.mafraInOut1[1]);
            settings.ReplacePath(@folder.mafraInOut2[0], @folder.mafraInOut2[1]);
            amzSettings = new AmzIFace.AmazonSettings(settings.lavAmazonSettingsFile, Year);
            amzSettings.ReplacePath(@folder.mafraInOut1[0], @folder.mafraInOut1[1]);
            amzSettings.ReplacePath(@folder.mafraInOut2[0], @folder.mafraInOut2[1]);

            /*string folder = LavClass.MAFRA_FOLDER(Server.MapPath(""));
             * if (folder == "")
             *  folder = Server.MapPath("\\");
             * this.settings = new UtilityMaietta.genSettings(folder + "files\\mafra_conf.xml");
             * settings.ReplacePath(@"G:\", @"\\10.0.0.80\c$\");
             * amzSettings = new AmzIFace.AmazonSettings(settings.lavAmazonSettingsFile, Year);
             * amzSettings.ReplacePath(@"G:\", @"\\10.0.0.80\c$\");
             * amzSettings.ReplacePath(@"F:\", @"\\10.0.0.2\c$\");*/
            Session["settings"]    = settings;
            Session["amzSettings"] = amzSettings;

            FillMerchants(settings);
            dropMerchant.SelectedIndex = 0;
        }
        else
        {
            settings    = (UtilityMaietta.genSettings)Session["settings"];
            amzSettings = (AmzIFace.AmazonSettings)Session["amzSettings"];

            aMerchant = new AmzIFace.AmazonMerchant(int.Parse(dropMerchant.SelectedValue.ToString()), amzSettings.Year, settings.amzMarketPlacesFile, amzSettings);
        }

        OPERAZIONE = "Comunicazioni";
    }
    protected void Page_Load(object sender, EventArgs e)
    {
        if (Page.IsPostBack && Request.Form["btnLogOut"] != null)
        {
            ///POSTBACK PER LOGOUT
            btnLogOut_Click(sender, e);
        }

        if (Session["entry"] == null || !bool.Parse(Session["entry"].ToString()) || Request.QueryString["merchantId"] == null ||
            Session["token"] == null || Request.QueryString["token"] == null ||
            Session["token"].ToString() != Request.QueryString["token"].ToString() ||
            Session["Utente"] == null || Session["settings"] == null)
        {
            Session.Abandon();
            Response.Redirect("login.aspx?path=amzShipDownload");
        }

        u                  = (UtilityMaietta.Utente)Session["Utente"];
        settings           = (UtilityMaietta.genSettings)Session["settings"];
        labGoLav.Text      = "<a href='lavorazioni.aspx?token=" + Request.QueryString["token"].ToString() + "&merchantId=" + Request.QueryString["merchantId"] + "' target='_self'>Lavorazioni</a>";
        imbNextPag.Visible = false;
        //workYear = DateTime.Today.Year;
        Year = (int)Session["year"];

        if (!Page.IsPostBack && CheckQueryParams())
        {
            Session["shipmentColumns"] = Session["shipOrderlist"] = Session["gvCsv"] = null;
            /// PAGINA PRIMO LOAD CON RITORNO DA ALTRA PAGINA, PARAMETRI INIZIALI SU QUERYSTRING
            LavClass.MafraInit folder = LavClass.MAFRA_INIT(Server.MapPath(""));
            if (folder.mafraPath == "")
            {
                folder.mafraPath = Server.MapPath("\\");
            }
            settings.ReplacePath(@folder.mafraInOut1[0], @folder.mafraInOut1[1]);
            settings.ReplacePath(@folder.mafraInOut2[0], @folder.mafraInOut2[1]);
            amzSettings = new AmzIFace.AmazonSettings(settings.lavAmazonSettingsFile, Year);
            amzSettings.ReplacePath(@folder.mafraInOut1[0], @folder.mafraInOut1[1]);
            amzSettings.ReplacePath(@folder.mafraInOut2[0], @folder.mafraInOut2[1]);

            /*string folder = LavClass.MAFRA_FOLDER(Server.MapPath(""));
             * if (folder == "")
             *  folder = Server.MapPath("\\");
             * settings.ReplacePath(@"G:\", @"\\10.0.0.80\c$\");
             * settings.ReplacePath(@"F:\", @"\\10.0.0.2\c$\");
             * amzSettings = new AmzIFace.AmazonSettings(settings.lavAmazonSettingsFile, Year);
             * amzSettings.ReplacePath(@"G:\", @"\\10.0.0.80\c$\");
             * amzSettings.ReplacePath(@"F:\", @"\\10.0.0.2\c$\");*/
            Session["amzSettings"] = amzSettings;
            Session["settings"]    = settings;
            DateTime stDate  = DateTime.Parse(Request.QueryString["sd"].ToString());
            DateTime endDate = DateTime.Parse(Request.QueryString["ed"].ToString());

            calFrom.SelectedDate = new DateTime(stDate.Year, stDate.Month, stDate.Day);
            calTo.SelectedDate   = new DateTime(endDate.Year, endDate.Month, endDate.Day);
            rdbTuttiLav.Checked  = true;

            fillDropStati();
            dropStato.SelectedIndex = int.Parse(Request.QueryString["status"].ToString());
            fillDropOrdina();
            dropOrdina.SelectedIndex  = int.Parse(Request.QueryString["order"].ToString());
            dropResults.SelectedIndex = int.Parse(Request.QueryString["results"].ToString());
            //dataModifica = bool.Parse(Request.QueryString["concluso"].ToString());
            dataModifica = int.Parse(Request.QueryString["concluso"].ToString()) == ((int)AmazonOrder.Order.SEARCH_DATA.Data_Concluso);
            fillVettori(settings, amzSettings);

            OleDbConnection cnn = new OleDbConnection(settings.OleDbConnString);
            cnn.Open();
            fillVettoriFiltro(cnn, amzSettings);
            cnn.Close();

            imbNextPag.Visible = false;

            if (u.OpCount() == 1)
            {
                op = new LavClass.Operatore(u.Operatori()[0]);
            }
            else
            {
                dropTypeOper.Visible    = true;
                dropTypeOper.DataSource = null;
                dropTypeOper.DataBind();

                dropTypeOper.DataSource     = u.Operatori();
                dropTypeOper.DataTextField  = "tipo";
                dropTypeOper.DataValueField = "id";
                dropTypeOper.DataBind();

                dropTypeOper.SelectedIndex = 0;
                if (Session["opListN"] != null)
                {
                    dropTypeOper.SelectedIndex = (int)Session["opListN"];
                    op = new LavClass.Operatore(u.Operatori()[dropTypeOper.SelectedIndex]);
                }
                else
                {
                    dropTypeOper.SelectedIndex = 0;
                    op = new LavClass.Operatore(u.Operatori()[0]);
                }
            }
            soloLav  = (rdbConLav.Checked);
            soloAuto = (rdbSoloPartenza.Checked);

            fillListaFiltro(amzSettings);

            btnShowSped_Click(sender, e);
        }
        else if (!Page.IsPostBack)
        {
            /// PAGINA PRIMO LOAD
            Session["shipmentColumns"] = Session["shipOrderlist"] = Session["gvCsv"] = null;
            LavClass.MafraInit folder = LavClass.MAFRA_INIT(Server.MapPath(""));
            if (folder.mafraPath == "")
            {
                folder.mafraPath = Server.MapPath("\\");
            }
            settings.ReplacePath(@folder.mafraInOut1[0], @folder.mafraInOut1[1]);
            settings.ReplacePath(@folder.mafraInOut2[0], @folder.mafraInOut2[1]);
            amzSettings = new AmzIFace.AmazonSettings(settings.lavAmazonSettingsFile, Year);
            amzSettings.ReplacePath(@folder.mafraInOut1[0], @folder.mafraInOut1[1]);
            amzSettings.ReplacePath(@folder.mafraInOut2[0], @folder.mafraInOut2[1]);

            /*string folder = LavClass.MAFRA_FOLDER(Server.MapPath(""));
             * if (folder == "")
             *  folder = Server.MapPath("\\");
             * settings.ReplacePath(@"G:\", @"\\10.0.0.80\c$\");
             * settings.ReplacePath(@"F:\", @"\\10.0.0.2\c$\");
             * amzSettings = new AmzIFace.AmazonSettings(settings.lavAmazonSettingsFile, Year);
             * amzSettings.ReplacePath(@"G:\", @"\\10.0.0.80\c$\");
             * amzSettings.ReplacePath(@"F:\", @"\\10.0.0.2\c$\");*/
            Session["amzSettings"] = amzSettings;
            Session["settings"]    = settings;

            calTo.SelectedDate   = (DateTime.Today.Year == Year) ? DateTime.Today : (new DateTime(Year, 12, 31));
            calFrom.SelectedDate = (calTo.SelectedDate.AddDays(-15).Year == Year) ? calTo.SelectedDate.AddDays(-15) : (new DateTime(calTo.SelectedDate.Year, 1, 1));
            calFrom.VisibleDate  = calFrom.SelectedDate;
            calTo.VisibleDate    = calTo.SelectedDate;

            fillDropStati();
            fillDropOrdina();
            fillVettori(settings, amzSettings);
            OleDbConnection cnn = new OleDbConnection(settings.OleDbConnString);
            cnn.Open();
            fillVettoriFiltro(cnn, amzSettings);
            cnn.Close();

            imbNextPag.Visible = false;

            if (u.OpCount() == 1)
            {
                op = new LavClass.Operatore(u.Operatori()[0]);
            }
            else
            {
                dropTypeOper.Visible    = true;
                dropTypeOper.DataSource = null;
                dropTypeOper.DataBind();

                dropTypeOper.DataSource     = u.Operatori();
                dropTypeOper.DataTextField  = "tipo";
                dropTypeOper.DataValueField = "id";
                dropTypeOper.DataBind();

                if (Session["opListN"] != null)
                {
                    dropTypeOper.SelectedIndex = (int)Session["opListN"];
                    op = new LavClass.Operatore(u.Operatori()[dropTypeOper.SelectedIndex]);
                }
                else
                {
                    dropTypeOper.SelectedIndex = 0;
                    op = new LavClass.Operatore(u.Operatori()[0]);
                }
            }

            Session["operatore"] = op;
            soloLav      = (rdbConLav.Checked);
            soloAuto     = (rdbSoloPartenza.Checked);
            dataModifica = (rdbDataMod.Checked);
            fillListaFiltro(amzSettings);
        }
        else if (Page.IsPostBack && Request.QueryString["amzToken"] != null)
        {
            /// POSTBACK DA AMAZON TOKEN PAGINA SUCCESSIVA
            if (u.OpCount() == 1)
            {
                op = new LavClass.Operatore(u.Operatori()[0]);
            }
            else
            {
                op = new LavClass.Operatore(u.Operatori()[dropTypeOper.SelectedIndex]);
            }

            amzToken         = (Request.QueryString["amzToken"].ToString());
            this.amzSettings = (AmzIFace.AmazonSettings)Session["amzSettings"];
            this.settings    = (UtilityMaietta.genSettings)Session["settings"];
            aMerchant        = new AmzIFace.AmazonMerchant(int.Parse(Request.QueryString["merchantId"].ToString()), amzSettings.Year, amzSettings.marketPlacesFile, amzSettings);

            DateTime stDate  = new DateTime(calFrom.SelectedDate.Year, calFrom.SelectedDate.Month, calFrom.SelectedDate.Day, 0, 0, 0);
            DateTime endDate = new DateTime(calTo.SelectedDate.Year, calTo.SelectedDate.Month, calTo.SelectedDate.Day, 23, 59, 59);
            if (endDate > DateTime.Now)
            {
                endDate = DateTime.Now.AddMinutes(-10);
            }

            int res  = int.Parse(dropResults.SelectedValue.ToString());
            int stIn = dropStato.SelectedIndex;
            dataModifica = (Request.Form["rdgData"] != null && Request.Form["rdgData"].ToString() == "rdbDataMod");

            bool isPrime = (Request.Form["chkPrime"] != null && Request.Form["chkPrime"].ToString() == "on");

            useFilters = true;
            amzQueryToken(stDate, endDate, res, amzToken, stIn, dataModifica, isPrime, op.tipo, settings);

            if (u.OpCount() == 1)
            {
                op = new LavClass.Operatore(u.Operatori()[0]);
            }
            else
            {
                op = new LavClass.Operatore(u.Operatori()[dropTypeOper.SelectedIndex]);
            }

            soloLav  = (Request.Form["rdgLav"] != null && Request.Form["rdgLav"].ToString() == "rdbConLav");
            soloAuto = (Request.Form["rdgLav"] != null && Request.Form["rdgLav"].ToString() == "rdbSoloPartenza");

            if (Page.IsPostBack && Session["shipmentColumns"] != null && Session["gvCsv"] != null)
            {
                fillCsvGridColumns((ArrayList)Session["shipmentColumns"]);
                fillCsvGrid();
            }
        }
        else if (Page.IsPostBack && Request.Form["btnAddOrderList"] != null)
        {
            this.amzSettings = (AmzIFace.AmazonSettings)Session["amzSettings"];
            this.settings    = (UtilityMaietta.genSettings)Session["settings"];

            if (u.OpCount() == 1)
            {
                op = new LavClass.Operatore(u.Operatori()[0]);
            }
            else
            {
                op = new LavClass.Operatore(u.Operatori()[dropTypeOper.SelectedIndex]);
            }

            fillGridColumns((ArrayList)Session["shipmentColumns"]);
            gvShips.DataSource = Session["shipOrderlist"] as ArrayList;
            gvShips.DataBind();

            dataModifica = (Request.Form["rdgData"] != null && Request.Form["rdgData"].ToString() == "rdbDataMod");
            soloLav      = (Request.Form["rdgLav"] != null && Request.Form["rdgLav"].ToString() == "rdbConLav");
            soloAuto     = (Request.Form["rdgLav"] != null && Request.Form["rdgLav"].ToString() == "rdbSoloPartenza");
        }
        else if (Page.IsPostBack && (Request.Form["btnFindSingleOrder"] != null || Request.Form["btnFindInvoice"] != null || Request.Form["btnFindOrderFile"] != null))
        {
            this.useFilters  = false;
            this.singleOrder = true;
            this.amzSettings = (AmzIFace.AmazonSettings)Session["amzSettings"];
            this.settings    = (UtilityMaietta.genSettings)Session["settings"];

            if (u.OpCount() == 1)
            {
                op = new LavClass.Operatore(u.Operatori()[0]);
            }
            else
            {
                op = new LavClass.Operatore(u.Operatori()[dropTypeOper.SelectedIndex]);
            }

            dataModifica = (Request.Form["rdgData"] != null && Request.Form["rdgData"].ToString() == "rdbDataMod");
            soloLav      = (Request.Form["rdgLav"] != null && Request.Form["rdgLav"].ToString() == "rdbConLav");
            soloAuto     = (Request.Form["rdgLav"] != null && Request.Form["rdgLav"].ToString() == "rdbSoloPartenza");
        }
        else
        {
            this.amzSettings = (AmzIFace.AmazonSettings)Session["amzSettings"];
            this.settings    = (UtilityMaietta.genSettings)Session["settings"];

            if (u.OpCount() == 1)
            {
                op = new LavClass.Operatore(u.Operatori()[0]);
            }
            else
            {
                op = new LavClass.Operatore(u.Operatori()[dropTypeOper.SelectedIndex]);
            }

            dataModifica = (Request.Form["rdgData"] != null && Request.Form["rdgData"].ToString() == "rdbDataMod");
            soloLav      = (Request.Form["rdgLav"] != null && Request.Form["rdgLav"].ToString() == "rdbConLav");
            soloAuto     = (Request.Form["rdgLav"] != null && Request.Form["rdgLav"].ToString() == "rdbSoloPartenza");

            if (Page.IsPostBack && Page.Request.Params["__EVENTTARGET"] != null &&
                (Page.Request.Params["__EVENTTARGET"].ToString() == "dropTypeOper" || Page.Request.Params["__EVENTTARGET"].ToString() == "calFrom" || Page.Request.Params["__EVENTTARGET"].ToString() == "calTo"))
            {
                gvShips.DataSource = null;
                gvShips.DataBind();
                chkSetInTime.Visible = chkSetShipped.Visible = btnMakeFile.Visible = btnAddOrderList.Visible = false;
            }

            if (Page.IsPostBack && Session["shipmentColumns"] != null && Session["gvCsv"] != null)
            {
                fillCsvGridColumns((ArrayList)Session["shipmentColumns"]);
                fillCsvGrid();
            }
        }


        aMerchant            = new AmzIFace.AmazonMerchant(int.Parse(Request.QueryString["merchantId"].ToString()), amzSettings.Year, amzSettings.marketPlacesFile, amzSettings);
        invPrefix            = aMerchant.invoicePrefix(amzSettings);
        COUNTRY              = Year + "&nbsp;-&nbsp;" + aMerchant.nazione + "&nbsp;&nbsp;" + aMerchant.ImageUrlHtml(25, 40, "inherit");
        Account              = op.ToString();
        TipoAccount          = op.tipo.nome;
        labGoPanoramica.Text = "<a href='amzPanoramica.aspx?token=" + Request.QueryString["token"].ToString() + MakeQueryParams() + "&merchantId=" + aMerchant.id + "' target='_self'>Panoramica</a>";
        Session["opListN"]   = dropTypeOper.SelectedIndex;
    }
예제 #5
0
    protected void Page_Load(object sender, EventArgs e)
    {
        if (Session["entry"] == null || !bool.Parse(Session["entry"].ToString()) || Request.QueryString["merchantId"] == null ||
            Session["token"] == null || Request.QueryString["token"] == null ||
            Session["token"].ToString() != Request.QueryString["token"].ToString() ||
            Session["Utente"] == null || Session["settings"] == null || Request.QueryString["amzOrd"] == null)
        {
            Session.Abandon();
            Response.Redirect("login.aspx?path=amzPanoramica");
        }

        Year     = (int)Session["year"];
        u        = (UtilityMaietta.Utente)Session["Utente"];
        settings = (UtilityMaietta.genSettings)Session["settings"];

        LavClass.MafraInit folder = LavClass.MAFRA_INIT(Server.MapPath(""));
        if (folder.mafraPath == "")
        {
            folder.mafraPath = Server.MapPath("\\");
        }
        settings.ReplacePath(@folder.mafraInOut1[0], @folder.mafraInOut1[1]);
        settings.ReplacePath(@folder.mafraInOut2[0], @folder.mafraInOut2[1]);
        amzSettings = new AmzIFace.AmazonSettings(settings.lavAmazonSettingsFile, Year);
        amzSettings.ReplacePath(@folder.mafraInOut1[0], @folder.mafraInOut1[1]);
        amzSettings.ReplacePath(@folder.mafraInOut2[0], @folder.mafraInOut2[1]);

        /*string folder = LavClass.MAFRA_FOLDER(Server.MapPath(""));
         * if (folder == "")
         *  folder = Server.MapPath("\\");
         * settings.ReplacePath(@"G:\", @"\\10.0.0.80\c$\");
         * settings.ReplacePath(@"F:\", @"\\10.0.0.2\c$\");
         * amzSettings = new AmzIFace.AmazonSettings(settings.lavAmazonSettingsFile, Year);
         * amzSettings.ReplacePath(@"G:\", @"\\10.0.0.80\c$\");
         * amzSettings.ReplacePath(@"F:\", @"\\10.0.0.2\c$\");*/
        Session["settings"]    = settings;
        Session["amzSettings"] = amzSettings;

        aMerchant        = new AmzIFace.AmazonMerchant(int.Parse(Request.QueryString["merchantId"].ToString()), amzSettings.Year, amzSettings.marketPlacesFile, amzSettings);
        AmzInvoicePrefix = aMerchant.invoicePrefix(amzSettings);
        COUNTRY          = Year + "&nbsp;-&nbsp;" + aMerchant.nazione + "&nbsp;&nbsp;" + aMerchant.ImageUrlHtml(25, 40, "inherit");

        imgTopLogo.ImageUrl = amzSettings.WebLogo;
        AmazonOrder.Order o;
        txNumOrd.Text = Request.QueryString["amzOrd"].ToString();
        string errore = "";

        if (!Page.IsPostBack)
        {
            if (Session[Request.QueryString["amzOrd"].ToString()] != null)
            {
                o = (AmazonOrder.Order)Session[Request.QueryString["amzOrd"].ToString()];
            }
            else
            {
                o = AmazonOrder.Order.ReadOrderByNumOrd(txNumOrd.Text, amzSettings, aMerchant, out errore);
            }

            if (o == null || errore != "")
            {
                Response.Write("Impossibile contattare amazon, riprova più tardi!<br />Errore: " + errore);
                btnMakePdf.Enabled = false;
                return;
            }
            else
            {
                btnMakePdf.Enabled = true;
            }

            Session[Request.QueryString["amzOrd"].ToString()] = o;
            fillRisposte(amzSettings, aMerchant);
            dropRisposte.SelectedValue = ((Request.QueryString["tiporisposta"] != null) ? int.Parse(Request.QueryString["tiporisposta"].ToString()) : amzSettings.amzDefaultRispID).ToString();
            OleDbConnection cnn = new OleDbConnection(settings.OleDbConnString);
            cnn.Open();
            fillVettori(cnn);
            cnn.Close();

            calDataInvoice.SelectedDate = new DateTime(DateTime.Today.Year, DateTime.Today.Month, DateTime.Today.Day);


            if (Request.QueryString["amzInv"] != null && int.Parse(Request.QueryString["amzInv"].ToString()) > 0)
            {
                txInvoiceNum.Text = Request.QueryString["amzInv"].ToString();
            }

            if (Request.QueryString["noMov"] != null && bool.Parse(Request.QueryString["noMov"].ToString()))
            {
                chkMovimenta.Checked = false;
                chkMovimenta.Enabled = false;
            }
            else if (!amzSettings.amzPrimeLocalScarico && o.canaleOrdine.Index == AmazonOrder.FulfillmentChannel.LOGISTICA_AMAZON)
            {
                chkMovimenta.Checked = false;
                chkMovimenta.Enabled = false;
            }

            chkMakeEcmScheda.Checked = chkMovimenta.Checked;
            chkMakeEcmScheda.Enabled = chkMovimenta.Enabled;
        }
        else
        {
            o = (AmazonOrder.Order)Session[Request.QueryString["amzOrd"].ToString()];
        }

        if (o != null)
        {
            calDataInvoice.SelectedDate = calDataInvoice.VisibleDate = o.InvoiceDate;
        }

        if (chkMovimenta.Enabled)
        {
            chkMovimenta.Checked = true;
        }

        if (Request.QueryString["vector"] != null && bool.Parse(Request.QueryString["vector"].ToString()))
        {
            chkMakeEcmScheda.Checked  = chkMovimenta.Checked = chkRegalo.Checked = chkSendRisp.Checked = false;
            chkMakeEcmScheda.Enabled  = chkMovimenta.Enabled = chkRegalo.Enabled = chkSendRisp.Enabled = false;
            txInvoiceNum.Enabled      = txNumOrd.Enabled = false;
            calDataInvoice.Enabled    = dropRisposte.Enabled = false;
            dropVettori.Enabled       = true;
            dropVettori.SelectedIndex = dropVettori.Items.IndexOf(dropVettori.Items.FindByText(o.GetSiglaVettoreStatus()));
            btnMakePdf.Text           = "Aggiorna Vettore";
        }
        labDataScelta.Text   = calDataInvoice.SelectedDate.ToShortDateString();
        chkMovimenta.Checked = false; // inserito momentaneamente per cambio anno
    }
예제 #6
0
    protected void Page_Load(object sender, EventArgs e)
    {
        Page.Form.DefaultButton = this.FindControl("btnFindShips").UniqueID;
        if (Page.IsPostBack && Request.Form["btnLogOut"] != null)
        {
            btnLogOut_Click(sender, e);
        }

        if (Session["entry"] == null || !bool.Parse(Session["entry"].ToString()) || Request.QueryString["merchantId"] == null ||
            Session["token"] == null || Request.QueryString["token"] == null ||
            Session["token"].ToString() != Request.QueryString["token"].ToString() ||
            Session["Utente"] == null || Session["settings"] == null)
        {
            Session.Abandon();
            Response.Redirect("login.aspx?path=amzBarCode" +
                              ((Request.QueryString["shipid"] != null)? "&shipid=" + Request.QueryString["shipid"].ToString() : ""));
        }
        u        = (UtilityMaietta.Utente)Session["Utente"];
        op       = (LavClass.Operatore)Session["operatore"];
        settings = (UtilityMaietta.genSettings)Session["settings"];
        //workYear = DateTime.Today.Year;
        Year = (int)Session["year"];

        LavClass.MafraInit folder = LavClass.MAFRA_INIT(Server.MapPath(""));
        if (folder.mafraPath == "")
        {
            folder.mafraPath = Server.MapPath("\\");
        }
        settings.ReplacePath(@folder.mafraInOut1[0], @folder.mafraInOut1[1]);
        settings.ReplacePath(@folder.mafraInOut2[0], @folder.mafraInOut2[1]);
        amzSettings = new AmzIFace.AmazonSettings(settings.lavAmazonSettingsFile, Year);
        amzSettings.ReplacePath(@folder.mafraInOut1[0], @folder.mafraInOut1[1]);
        amzSettings.ReplacePath(@folder.mafraInOut2[0], @folder.mafraInOut2[1]);

        /*string folder = LavClass.MAFRA_FOLDER(Server.MapPath(""));
         * if (folder == "")
         *  folder = Server.MapPath("\\");
         * settings.ReplacePath(@"G:\", @"\\10.0.0.80\c$\");
         * settings.ReplacePath(@"F:\", @"\\10.0.0.2\c$\");
         * amzSettings = new AmzIFace.AmazonSettings(settings.lavAmazonSettingsFile, Year);
         * amzSettings.ReplacePath(@"G:\", @"\\10.0.0.80\c$\");
         * amzSettings.ReplacePath(@"F:\", @"\\10.0.0.2\c$\");*/

        Session["settings"]    = settings;
        Session["amzSettings"] = amzSettings;
        Session["Utente"]      = u;
        Session["operatore"]   = op;
        aMerchant   = new AmzIFace.AmazonMerchant(int.Parse(Request.QueryString["merchantId"].ToString()), amzSettings.Year, amzSettings.marketPlacesFile, amzSettings);
        Account     = op.ToString();
        TipoAccount = op.tipo.nome;

        if (op.tipo.id == settings.lavDefMagazzID)
        {
            OPERAZIONE         = "Genera BarCode";
            dropLabels.Visible = labLabs.Visible = printcode = true;
        }
        else
        {
            OPERAZIONE         = "Gestione Spedizione";
            dropLabels.Visible = labLabs.Visible = printcode = false;
        }

        if (!Page.IsPostBack && printcode)
        {
            fillLabels(amzSettings);
        }
        if (!Page.IsPostBack && Request.QueryString["shipid"] != null)
        {
            txShipCode.Text = Request.QueryString["shipid"].ToString();
            btnFindShips_Click(sender, e);
        }
    }
예제 #7
0
    protected void Page_Load(object sender, EventArgs e)
    {
        if (Page.IsPostBack && Request.Form["btnLogOut"] != null)
        {
            btnLogOut_Click(sender, e);
        }

        if (Session["entry"] == null || !bool.Parse(Session["entry"].ToString()) || Request.QueryString["merchantId"] == null ||
            Session["token"] == null || Request.QueryString["token"] == null ||
            Session["token"].ToString() != Request.QueryString["token"].ToString() ||
            Session["Utente"] == null || Session["settings"] == null)
        {
            Session.Abandon();
            Response.Redirect("login.aspx?path=amzMultilabelPrint" + ((Request.QueryString["amzOrd"] != null) ? "&amzOrd=" + Request.QueryString["amzOrd"].ToString():""));
        }

        Year     = (int)Session["year"];
        u        = (UtilityMaietta.Utente)Session["Utente"];
        settings = (UtilityMaietta.genSettings)Session["settings"];

        LavClass.MafraInit folder = LavClass.MAFRA_INIT(Server.MapPath(""));
        if (folder.mafraPath == "")
        {
            folder.mafraPath = Server.MapPath("\\");
        }
        settings.ReplacePath(@folder.mafraInOut1[0], @folder.mafraInOut1[1]);
        settings.ReplacePath(@folder.mafraInOut2[0], @folder.mafraInOut2[1]);
        amzSettings = new AmzIFace.AmazonSettings(settings.lavAmazonSettingsFile, Year);
        amzSettings.ReplacePath(@folder.mafraInOut1[0], @folder.mafraInOut1[1]);
        amzSettings.ReplacePath(@folder.mafraInOut2[0], @folder.mafraInOut2[1]);

        /*string folder = LavClass.MAFRA_FOLDER(Server.MapPath(""));
         * if (folder == "")
         *  folder = Server.MapPath("\\");
         * settings.ReplacePath(@"G:\", @"\\10.0.0.80\c$\");
         * settings.ReplacePath(@"F:\", @"\\10.0.0.2\c$\");
         * amzSettings = new AmzIFace.AmazonSettings(settings.lavAmazonSettingsFile, Year);
         * amzSettings.ReplacePath(@"G:\", @"\\10.0.0.80\c$\");
         * amzSettings.ReplacePath(@"F:\", @"\\10.0.0.2\c$\");*/

        Session["settings"]    = settings;
        Session["amzSettings"] = amzSettings;
        labGoLav.Text          = "<a href='amzPanoramica.aspx?token=" + Request.QueryString["token"].ToString() + "&merchantId=" + Request.QueryString["merchantId"].ToString() + "' target='_self'>Home</a>";
        aMerchant = new AmzIFace.AmazonMerchant(int.Parse(Request.QueryString["merchantId"].ToString()), amzSettings.Year, amzSettings.marketPlacesFile, amzSettings);
        COUNTRY   = Year + "&nbsp;-&nbsp;" + aMerchant.nazione + "&nbsp;&nbsp;&nbsp;" + aMerchant.ImageUrlHtml(25, 40, "inherit");

        imgTopLogo.ImageUrl = amzSettings.WebLogo;
        if (!Page.IsPostBack)
        {
            fillLabels(amzSettings);
            if (Request.QueryString["labCode"] != null)
            {
                dropLabels.SelectedValue = Request.QueryString["labCode"].ToString();
                labGoLav.Text            = "<a href='amzPanoramica.aspx?token=" + Request.QueryString["token"].ToString() + "&merchantId=" + Request.QueryString["merchantId"].ToString() +
                                           "&labCode=" + Request.QueryString["labCode"].ToString() + "' target='_self'>Home</a>";
            }
            else
            {
                dropLabels.SelectedIndex = 0;
            }
        }
        paperLab = new AmzIFace.AmazonInvoice.PaperLabel(0, 0, amzSettings.amzPaperLabelsFile, dropLabels.SelectedValue.ToString());

        string errore = "";

        if (!Page.IsPostBack && Request.QueryString["amzBCSku"] != null && Request.QueryString["labQt"] != null && Request.QueryString["descBC"] != null &&
            Request.QueryString["status"] != null && Request.QueryString["labCode"] != null)
        {
            // STAMPA BARCODE
            int    numLabels = int.Parse(Request.QueryString["labQt"].ToString());
            string sku       = Request.QueryString["amzBCSku"].ToString();
            string descBC    = HttpUtility.HtmlDecode(HttpUtility.UrlDecode(Request.QueryString["descBC"].ToString()));
            string status    = Request.QueryString["status"].ToString();
            if (numLabels >= paperLab.rows * paperLab.cols) // occupano intera pagina o più
            {
                Response.Redirect("download.aspx?token=" + Request.QueryString["token"].ToString() + "&merchantId=" + Request.QueryString["merchantId"].ToString() +
                                  "&amzBCSku=" + Request.QueryString["amzBCSku"].ToString() + "&labQt=" + numLabels.ToString() + "&descBC=" + HttpUtility.UrlEncode(descBC) +
                                  "&status=" + status + "&labCode=" + Request.QueryString["labCode"].ToString());
            }
            else // SI PUO' SCEGLIERE POSIZIONE SUL FOGLIO
            {
                numAddr = numLabels.ToString();
                if (u.OpCount() == 1)
                {
                    op = new LavClass.Operatore(u.Operatori()[0]);
                }
                else
                {
                    dropTypeOper.Visible    = true;
                    dropTypeOper.DataSource = null;
                    dropTypeOper.DataBind();

                    dropTypeOper.DataSource     = u.Operatori();
                    dropTypeOper.DataTextField  = "tipo";
                    dropTypeOper.DataValueField = "id";
                    dropTypeOper.DataBind();

                    dropTypeOper.SelectedIndex = 0;
                    op = new LavClass.Operatore(u.Operatori()[0]);
                }
                Session["operatore"] = op;
                labOrderID.Text      = "";
                labAddress.Text      = "";
                makeBarCode(sku);
                MakeTable(paperLab.cols, paperLab.rows, true);
                btnPrint.OnClientClick = "return (checkNum());";
                labDest.Text           = "Codice a barre: ";
            }
        }
        else if (!Page.IsPostBack && Request.QueryString["amzAddr"] != null && bool.Parse(Request.QueryString["amzAddr"].ToString()))
        {
            // STAMPA ETICHETTE MULTIPLE
            if (u.OpCount() == 1)
            {
                op = new LavClass.Operatore(u.Operatori()[0]);
            }
            else
            {
                dropTypeOper.Visible    = true;
                dropTypeOper.DataSource = null;
                dropTypeOper.DataBind();

                dropTypeOper.DataSource     = u.Operatori();
                dropTypeOper.DataTextField  = "tipo";
                dropTypeOper.DataValueField = "id";
                dropTypeOper.DataBind();

                dropTypeOper.SelectedIndex = 0;
                op = new LavClass.Operatore(u.Operatori()[0]);
            }
            Session["operatore"] = op;
            labOrderID.Text      = "";
            labAddress.Text      = "";

            if (((ArrayList)Session["addresses"]).Count > (paperLab.cols * paperLab.rows))
            {
                tabAddr.Visible = tabPaperSize.Visible = tabPaper.Visible = false;
            }
            else
            {
                MakeAddress((ArrayList)Session["addresses"]);
                MakeTable(paperLab.cols, paperLab.rows, true);

                btnPrint.OnClientClick = "return (checkNum());";
                labDest.Text           = "Destinatario: ";
            }

            numAddr = ((ArrayList)Session["addresses"]).Count.ToString();
            labInfoBollino.Visible = txDownloadList.Visible = labDownloadList.Visible = hylDownloadList.Visible = true;
            labInfoBollino.Text    = "Ultime " + VARNUM + " cifre variano";
        }
        else if (!Page.IsPostBack && Request.QueryString["amzOrd"] != null)
        {
            if (u.OpCount() == 1)
            {
                op = new LavClass.Operatore(u.Operatori()[0]);
            }
            else
            {
                dropTypeOper.Visible    = true;
                dropTypeOper.DataSource = null;
                dropTypeOper.DataBind();

                dropTypeOper.DataSource     = u.Operatori();
                dropTypeOper.DataTextField  = "tipo";
                dropTypeOper.DataValueField = "id";
                dropTypeOper.DataBind();

                dropTypeOper.SelectedIndex = 0;
                op = new LavClass.Operatore(u.Operatori()[0]);
            }
            Session["operatore"] = op;

            labOrderID.Text = "Ordine #: " + Request.QueryString["amzOrd"].ToString();

            AmazonOrder.Order order;
            if (Session[Request.QueryString["amzOrd"].ToString()] != null)
            {
                order = (AmazonOrder.Order)Session[Request.QueryString["amzOrd"].ToString()];
            }
            else
            {
                order = AmazonOrder.Order.ReadOrderByNumOrd(Request.QueryString["amzOrd"].ToString(), amzSettings, aMerchant, out errore);
            }

            if (order == null || errore != "")
            {
                Response.Write("Impossibile contattare Amazon, riprovare più tardi!<br />Errore: " + errore);
                chkSetInTime.Enabled = chkSetShipped.Enabled = btnPrint.Enabled = false;
                return;
            }

            labAddress.Text         = order.destinatario.ToStringLabelHtml();
            Session["destinatario"] = order.destinatario;
            MakeTable(paperLab.cols, paperLab.rows, false);
            numAddr      = "1";
            labDest.Text = "Destinatario: ";
        }
        else if (Page.IsPostBack && Request.Form["btnPrint"] != null)
        {
            if (u.OpCount() == 1)
            {
                op = new LavClass.Operatore(u.Operatori()[0]);
            }
            else
            {
                op = new LavClass.Operatore(u.Operatori()[dropTypeOper.SelectedIndex]);
            }
            hypHome.NavigateUrl  = "amzPanoramica.aspx?token=" + Session["token"].ToString() + MakeQueryParams();
            hypHome.Visible      = true;
            chkSetInTime.Enabled = chkSetShipped.Enabled = btnPrint.Enabled = false;
        }
        else if (Page.IsPostBack)
        {
            if ((Request.QueryString["amzBCSku"] != null && Request.QueryString["labQt"] != null && Request.QueryString["descBC"] != null && Request.QueryString["status"] != null))
            { // STAMPA CODICI BARRE
                multipleSel = true;
                makeBarCode(Request.QueryString["amzBCSku"].ToString());
                numAddr = Request.QueryString["labQt"].ToString();
            }
            else if (Request.QueryString["amzAddr"] != null && bool.Parse(Request.QueryString["amzAddr"].ToString()))
            {// STAMPA ETICHETTE MULTIPLE
                multipleSel = true;
                //MakeAddress((ArrayList)Session["addresses"], (ArrayList)Session["orderList"]);
                MakeAddress((ArrayList)Session["addresses"]);
                numAddr = ((ArrayList)Session["addresses"]).Count.ToString();
            }
            else
            {// STAMPA ETICHETTA SINGOLA
                multipleSel = false;
                AmazonOrder.Order order;
                if (Session[Request.QueryString["amzOrd"].ToString()] != null)
                {
                    order = (AmazonOrder.Order)Session[Request.QueryString["amzOrd"].ToString()];
                }
                else
                {
                    order = AmazonOrder.Order.ReadOrderByNumOrd(Request.QueryString["amzOrd"].ToString(), amzSettings, aMerchant, out errore);
                }

                if (order == null || errore != "")
                {
                    Response.Write("Impossibile contattare Amazon, riprovare più tardi!<br />Errore: " + errore);
                    chkSetInTime.Enabled = chkSetShipped.Enabled = btnPrint.Enabled = false;
                    return;
                }
                numAddr         = "1";
                labAddress.Text = order.destinatario.ToStringLabelHtml();
            }

            if (u.OpCount() == 1)
            {
                op = new LavClass.Operatore(u.Operatori()[0]);
            }
            else
            {
                op = new LavClass.Operatore(u.Operatori()[dropTypeOper.SelectedIndex]);
            }
            hypHome.NavigateUrl = "amzPanoramica.aspx?token=" + Session["token"].ToString() + MakeQueryParams();
            hypHome.Visible     = true;
        }
        else
        {
            Response.Redirect("amzPanoramica.aspx?token=" + Request.QueryString["token"]);
        }

        hypHome.NavigateUrl = "amzPanoramica.aspx?token=" + Session["token"].ToString() + MakeQueryParams();
        Account             = op.ToString();
        TipoAccount         = op.tipo.nome;

        /*SetInfo(amzSettings.amzLabelW, amzSettings.amzLabelH, amzSettings.amzLabelTopM, amzSettings.amzLabelLeftM, amzSettings.amzLabelColonna, amzSettings.amzLabelRiga,
         *  amzSettings.amzLabelInfraRiga, amzSettings.amzLabelInfraColonna);*/
        SetInfo(paperLab);
    }
    protected void Page_Load(object sender, EventArgs e)
    {
        if (Session["entry"] == null || !bool.Parse(Session["entry"].ToString()) || Request.QueryString["merchantId"] == null ||
            Session["token"] == null || Request.QueryString["token"] == null ||
            Session["token"].ToString() != Request.QueryString["token"].ToString() || Session["operatore"] == null ||
            Session["Utente"] == null || Session["settings"] == null || Request.QueryString["amzOrd"] == null)
        {
            Session.Abandon();
            Response.Redirect("login.aspx?path=amzPanoramica");
        }

        u        = (UtilityMaietta.Utente)Session["Utente"];
        settings = (UtilityMaietta.genSettings)Session["settings"];
        op       = (LavClass.Operatore)Session["operatore"];
        Year     = (int)Session["year"];

        LavClass.MafraInit folder = LavClass.MAFRA_INIT(Server.MapPath(""));
        if (folder.mafraPath == "")
        {
            folder.mafraPath = Server.MapPath("\\");
        }
        settings.ReplacePath(@folder.mafraInOut1[0], @folder.mafraInOut1[1]);
        settings.ReplacePath(@folder.mafraInOut2[0], @folder.mafraInOut2[1]);
        amzSettings = new AmzIFace.AmazonSettings(settings.lavAmazonSettingsFile, Year);
        amzSettings.ReplacePath(@folder.mafraInOut1[0], @folder.mafraInOut1[1]);
        amzSettings.ReplacePath(@folder.mafraInOut2[0], @folder.mafraInOut2[1]);

        /*string folder = LavClass.MAFRA_FOLDER(Server.MapPath(""));
         * if (folder == "")
         *  folder = Server.MapPath("\\");
         * settings.ReplacePath(@"G:\", @"\\10.0.0.80\c$\");
         * settings.ReplacePath(@"F:\", @"\\10.0.0.2\c$\");
         * amzSettings = new AmzIFace.AmazonSettings(settings.lavAmazonSettingsFile, Year);
         * amzSettings.ReplacePath(@"G:\", @"\\10.0.0.80\c$\");
         * amzSettings.ReplacePath(@"F:\", @"\\10.0.0.2\c$\");*/
        Session["settings"]    = settings;
        Session["amzSettings"] = amzSettings;
        aMerchant = new AmzIFace.AmazonMerchant(1, amzSettings.Year, amzSettings.marketPlacesFile, amzSettings);
        freeProds = Request.QueryString["freeProds"] != null && int.Parse(Request.QueryString["freeProds"].ToString()) > 0;

        OleDbConnection cnn = new OleDbConnection(settings.OleDbConnString);
        OleDbConnection wc  = new OleDbConnection(settings.lavOleDbConnection);

        wc.Open();
        cnn.Open();
        string errore = "";

        AmazonOrder.Order o;
        if (!CheckNomeLavoro(wc, Request.QueryString["amzOrd"].ToString(), amzSettings.AmazonMagaCode)) // ENTRA SE LAVORAZIONE NON ESISTENTE
        {
            if (Session[Request.QueryString["amzOrd"].ToString()] != null)
            {
                o = (AmazonOrder.Order)Session[Request.QueryString["amzOrd"].ToString()];
            }
            else
            {
                o = AmazonOrder.Order.ReadOrderByNumOrd(Request.QueryString["amzOrd"].ToString(), amzSettings, aMerchant, out errore);
            }

            if (o == null || errore != "")
            {
                Response.Write("Impossibile contattare amazon, riprova più tardi!<br />Errore: " + errore);
                cnn.Close();
                wc.Close();
                return;
            }

            string invnumb = (Request.QueryString["invnumb"] != null && Request.QueryString["invnumb"].ToString() != "") ?
                             "Ricevuta nr.:@ " + Request.QueryString["invnumb"].ToString() + " @": "";
            if (o.Items == null)
            {
                o.RequestItemsAndSKU(amzSettings, aMerchant, settings, cnn, wc);
            }

            AmazonOrder.Order.lavInfo info = OpenLavorazioneFromAmz(o, wc, cnn, amzSettings, settings, invnumb);
            InsertPrimoStorico(info.lavID, wc, op, settings);
            LavClass.SchedaLavoro.MakeFolder(settings, info.rivID, info.lavID, info.userID);
        }
        wc.Close();
        cnn.Close();

        Response.Redirect("amzPanoramica.aspx?token=" + Request.QueryString["token"].ToString() +
                          "&amzOrd=" + Request.QueryString["amzOrd"].ToString() + MakeQueryParams());
    }
    protected void Page_Load(object sender, EventArgs e)
    {
        if (Session["entry"] == null || !bool.Parse(Session["entry"].ToString()) || Request.QueryString["merchantId"] == null ||
            Session["token"] == null || Request.QueryString["token"] == null ||
            Session["token"].ToString() != Request.QueryString["token"].ToString() ||
            Session["Utente"] == null || Session["settings"] == null ||
            (Request.QueryString["amzOrd"] == null && Request.QueryString["amzSku"] == null && Request.QueryString["amzSingleSku"] == null))
        {
            Session.Abandon();
            Response.Redirect("login.aspx?path=amzPanoramica");
        }

        u        = (UtilityMaietta.Utente)Session["Utente"];
        settings = (UtilityMaietta.genSettings)Session["settings"];
        //workYear = DateTime.Today.Year;
        Year = (int)Session["year"];


        LavClass.MafraInit folder = LavClass.MAFRA_INIT(Server.MapPath(""));
        if (folder.mafraPath == "")
        {
            folder.mafraPath = Server.MapPath("\\");
        }
        settings.ReplacePath(@folder.mafraInOut1[0], @folder.mafraInOut1[1]);
        settings.ReplacePath(@folder.mafraInOut2[0], @folder.mafraInOut2[1]);
        amzSettings = new AmzIFace.AmazonSettings(settings.lavAmazonSettingsFile, Year);
        amzSettings.ReplacePath(@folder.mafraInOut1[0], @folder.mafraInOut1[1]);
        amzSettings.ReplacePath(@folder.mafraInOut2[0], @folder.mafraInOut2[1]);

        /*string folder = LavClass.MAFRA_FOLDER(Server.MapPath(""));
         * settings.ReplacePath(@"G:\", @"\\10.0.0.80\c$\");
         * settings.ReplacePath(@"F:\", @"\\10.0.0.2\c$\");
         * amzSettings = new AmzIFace.AmazonSettings(settings.lavAmazonSettingsFile, Year);
         * amzSettings.ReplacePath(@"G:\", @"\\10.0.0.80\c$\");
         * amzSettings.ReplacePath(@"F:\", @"\\10.0.0.2\c$\");*/

        Session["settings"]    = settings;
        Session["amzSettings"] = amzSettings;
        Session["Utente"]      = u;

        aMerchant     = new AmzIFace.AmazonMerchant(int.Parse(Request.QueryString["merchantId"].ToString()), amzSettings.Year, amzSettings.marketPlacesFile, amzSettings);
        COUNTRY_TITLE = aMerchant.nazione;
        COUNTRY       = Year + "&nbsp;-&nbsp;" + aMerchant.nazione + "&nbsp;&nbsp;" + aMerchant.ImageUrlHtml(25, 40, "inherit");

        if (Page.IsPostBack)
        {
        }
        else if (Request.QueryString["amzOrd"] != null) // VENGO DA PANORAMICA VADO IN INVOICE
        {
            OPERAZIONE = " Inserimento da ordine";
            string amzOrd = Request.QueryString["amzOrd"].ToString();
            labOrderID.Text = "Ordine n#: " + amzOrd;

            string errore = "";

            if (Session[amzOrd] != null)
            {
                order = (AmazonOrder.Order)Session[Request.QueryString["amzOrd"].ToString()];
            }
            else
            {
                order = AmazonOrder.Order.ReadOrderByNumOrd(amzOrd, amzSettings, aMerchant, out errore);
            }
            Session[Request.QueryString["amzOrd"].ToString()] = order;

            if (order == null || errore != "")
            {
                Response.Write("Impossibile contattare amazon, riprova più tardi!<br />Errore: " + errore);
                return;
            }

            OleDbConnection cnn = new OleDbConnection(settings.OleDbConnString);
            cnn.Open();
            if (order.Items == null)
            {
                System.Threading.Thread.Sleep(1500);
                OleDbConnection wc = new OleDbConnection(settings.lavOleDbConnection);
                wc.Open();
                order.RequestItemsAndSKU(amzSettings, aMerchant, settings, cnn, wc);
                wc.Close();
            }
            FillTableCodes(order, cnn);
            cnn.Close();

            labRedCode.Text = "";
        }
        else if (Request.QueryString["amzSingleSku"] != null)
        {
            OPERAZIONE = " Inserimento singolo";
            string amzSingleSku = Request.QueryString["amzSingleSku"].ToString();
            labOrderID.Text = "";

            OleDbConnection cnn = new OleDbConnection(settings.OleDbConnString);
            cnn.Open();
            FillTableSingleSku(amzSingleSku, cnn);
            cnn.Close();

            if (amzSingleSku.Contains(" "))
            {
                btnSaveCodes.Enabled = false;
            }
        }
        else if (Request.QueryString["amzSku"] != null) /// MODIFICO SKU ESISTENTE
        {
            OPERAZIONE = " Modifica";
            string amzSku = Request.QueryString["amzSku"].ToString();
            labOrderID.Text = "";

            OleDbConnection cnn = new OleDbConnection(settings.OleDbConnString);
            OleDbConnection wc  = new OleDbConnection(settings.lavOleDbConnection);
            cnn.Open();
            wc.Open();
            ArrayList items = AmazonOrder.SKUItem.SkuItems(amzSku, wc, cnn, settings, amzSettings);
            FillTableSKU(items, cnn);
            cnn.Close();
            wc.Close();
            labRedCode.Text = "I codici con sfondo rosso sono già movimentati.<br />Non è possibile quindi modificare l'associazione.";
        }
    }
    protected void Page_Load(object sender, EventArgs e)
    {
        if (Session["entry"] == null || !bool.Parse(Session["entry"].ToString()) || Request.QueryString["merchantId"] == null ||
            Session["token"] == null || Request.QueryString["token"] == null ||
            Session["token"].ToString() != Request.QueryString["token"].ToString() ||
            Session["Utente"] == null || Session["settings"] == null || Request.QueryString["amzOrd"] == null)
        {
            Session.Abandon();
            Response.Redirect("login.aspx?path=amzPanoramica");
        }
        ScriptManager1.RegisterPostBackControl(btnMakePdf);
        Year = (int)Session["year"];

        if (!IsPostBack)
        {
            LavClass.MafraInit folder = LavClass.MAFRA_INIT(Server.MapPath(""));
            if (folder.mafraPath == "")
            {
                folder.mafraPath = Server.MapPath("\\");
            }
            this.settings = new UtilityMaietta.genSettings(folder.mafraPath);
            settings.ReplacePath(@folder.mafraInOut1[0], @folder.mafraInOut1[1]);
            settings.ReplacePath(@folder.mafraInOut2[0], @folder.mafraInOut2[1]);
            amzSettings = new AmzIFace.AmazonSettings(settings.lavAmazonSettingsFile, Year);
            amzSettings.ReplacePath(@folder.mafraInOut1[0], @folder.mafraInOut1[1]);
            amzSettings.ReplacePath(@folder.mafraInOut2[0], @folder.mafraInOut2[1]);

            /*string folder = LavClass.MAFRA_FOLDER(Server.MapPath(""));
             * if (folder == "")
             *  folder = Server.MapPath("\\");
             * this.settings = new UtilityMaietta.genSettings(folder + "files\\mafra_conf.xml");
             * settings.ReplacePath(@"G:\", @"\\10.0.0.80\c$\");
             * settings.ReplacePath(@"F:\", @"\\10.0.0.2\c$\");
             * amzSettings = new AmzIFace.AmazonSettings(settings.lavAmazonSettingsFile, Year);
             * amzSettings.ReplacePath(@"G:\", @"\\10.0.0.80\c$\");
             * amzSettings.ReplacePath(@"F:\", @"\\10.0.0.2\c$\");*/
            aMerchant              = new AmzIFace.AmazonMerchant(int.Parse(Request.QueryString["merchantId"].ToString()), amzSettings.Year, amzSettings.marketPlacesFile, amzSettings);
            Session["settings"]    = settings;
            Session["amzSettings"] = amzSettings;

            imgTopLogo.ImageUrl         = amzSettings.WebLogo;
            calInvoiceData.SelectedDate = DateTime.Today;
            calInvoiceData.VisibleDate  = DateTime.Today;

            labDefinitiveData.Text = DateTime.Today.ToShortDateString();
            labDescSelected.Text   = "";

            if (Request.QueryString["amzInv"] != null && int.Parse(Request.QueryString["amzInv"].ToString()) > 0)
            {
                txInvoiceNum.Text = Request.QueryString["amzInv"].ToString();
            }
            AmazonOrder.Order o;
            if (Session[Request.QueryString["amzOrd"].ToString()] != null)
            {
                o = (AmazonOrder.Order)Session[Request.QueryString["amzOrd"].ToString()];
                calInvoiceData.SelectedDate = calInvoiceData.VisibleDate = o.InvoiceDate;
            }

            OleDbConnection cnn = new OleDbConnection(settings.OleDbConnString);
            cnn.Open();
            fillVettori(cnn, amzSettings);
            fillDropCodes(settings, cnn);
            cnn.Close();
            fillRisposte(amzSettings, aMerchant);
            dtProds            = creaDataTable();
            Session["dtProds"] = dtProds;

            gridProducts.DataSource = dtProds;
            gridProducts.DataBind();
        }
        else
        {
            settings    = (UtilityMaietta.genSettings)Session["settings"];
            amzSettings = (AmzIFace.AmazonSettings)Session["amzSettings"];
            aMerchant   = new AmzIFace.AmazonMerchant(int.Parse(Request.QueryString["merchantId"].ToString()), amzSettings.Year, amzSettings.marketPlacesFile, amzSettings);
            dtProds     = (DataTable)Session["dtProds"];
        }

        txNumOrd.Text = Request.QueryString["amzOrd"].ToString();


        AmzInvoicePrefix = aMerchant.invoicePrefix(amzSettings);
        COUNTRY          = Year + "&nbsp;-&nbsp;" + aMerchant.nazione + "&nbsp;&nbsp;" + aMerchant.ImageUrlHtml(25, 40, "inherit");


        //AmazonOrder.Order o = (AmazonOrder.Order)Session[txNumOrd.Text];

        /*if (!Page.IsPostBack && Session[txNumOrd.Text] != null)
         * {
         *  OleDbConnection wc = new OleDbConnection(settings.lavOleDbConnection);
         *  wc.Open();
         *  AmazonOrder.Order o = (AmazonOrder.Order)Session[txNumOrd.Text];
         *  AmazonOrder.Order.lavInfo idlav = (o.canaleOrdine.Index == AmazonOrder.FulfillmentChannel.LOGISTICA_AMAZON)? idlav = AmazonOrder.Order.lavInfo.EmptyLav() : o.GetLavorazione(wc);
         *
         *  if (idlav.lavID == 0 && o.HasOneLavorazione() && o.canaleOrdine.Index != AmazonOrder.FulfillmentChannel.LOGISTICA_AMAZON) // POSSIBILE APRI LAVORAZIONE
         *      chkOpenLav.Checked = chkOpenLav.Enabled = true;
         *  else
         *      chkOpenLav.Checked = chkOpenLav.Enabled = false;
         *  wc.Close();
         * }*/
    }