コード例 #1
0
 protected void dropComs_SelectedIndexChanged(object sender, EventArgs e)
 {
     AmazonOrder.Comunicazione com = new AmazonOrder.Comunicazione(int.Parse(dropComs.SelectedValue.ToString()), amzSettings, aMerchant);
     labIDCom.Text      = "ID Comunicazione: " + com.id;
     labTesto.Text      = com.testo;
     labSubject.Text    = com.Subject("123-4567890-1234567");
     chkAttach.Checked  = com.hasCommonAttach;
     chkInvoice.Checked = com.selectedAttach;
     chkInvoice.Visible = chkAttach.Visible = true;
 }
コード例 #2
0
    //private int workYear;

    protected void Page_Load(object sender, EventArgs e)
    {
        if (Session["amzSettings"] == null || Session["settings"] == null || Request.QueryString["merchantId"] == null || Request.QueryString["tiporisposta"] == null ||
            Request.QueryString["from"] == null || Request.QueryString["to"] == null || Request.QueryString["ordid"] == null || Request.QueryString["dest"] == null || Request.QueryString["nomeB"] == null)
        //Request.QueryString["subject"] == null ||
        {
            Response.Write("Sessione scaduta");
            return;
        }
        amzSettings = (AmzIFace.AmazonSettings)Session["amzSettings"];
        settings    = (UtilityMaietta.genSettings)Session["settings"];
        UtilityMaietta.Utente u = (UtilityMaietta.Utente)Session["Utente"];
        //workYear = DateTime.Today.Year;
        aMerchant = new AmzIFace.AmazonMerchant(int.Parse(Request.QueryString["merchantId"].ToString()), amzSettings.Year, amzSettings.marketPlacesFile, amzSettings);


        int    risposta = int.Parse(Request.QueryString["tiporisposta"].ToString());
        string toMail   = Request.QueryString["to"].ToString();
        //string subject = Request.QueryString["subject"].ToString();
        string fromMail = Request.QueryString["from"].ToString();
        string ordid    = Request.QueryString["ordid"].ToString();
        string dest     = HttpUtility.UrlDecode(Request.QueryString["dest"].ToString());
        string nomeB    = HttpUtility.UrlDecode(Request.QueryString["nomeB"].ToString());

        string attach = "";

        AmazonOrder.Comunicazione com = new AmazonOrder.Comunicazione(risposta, amzSettings, aMerchant);
        string subject = com.Subject(ordid);

        if (Request.QueryString["attach"] != null && com.selectedAttach && File.Exists(Request.QueryString["attach"].ToString()))
        {
            attach = Request.QueryString["attach"].ToString();
        }
        if (com.hasCommonAttach)
        {
            attach = (attach == "") ? String.Join(",", com.commonAttaches) : attach + "," + String.Join(",", com.commonAttaches);
        }
        //string attach = (Request.QueryString["attach"] != null && com.selectedAttach && File.Exists(Request.QueryString["attach"].ToString())) ? Request.QueryString["attach"].ToString() : "";

        //toMail = "*****@*****.**";
        bool send = UtilityMaietta.sendmail(attach, fromMail, toMail, subject, com.GetHtml(ordid, dest, nomeB), false, "", "", settings.clientSmtp,
                                            settings.smtpPort, settings.smtpUser, settings.smtpPass, false, null);

        if (send)
        {
            Response.Write("Messaggio inviato.");
        }

        Response.Write("<script>window.close();</script>");
    }
コード例 #3
0
    //private int Year;

    protected void Page_Load(object sender, EventArgs e)
    {
        if (Request.QueryString["bprefix"] != null && Request.QueryString["start"] != null && Request.QueryString["vettID"] != null && Session["addresses"] != null && Session["orderList"] != null)
        {
            amzSettings = (AmzIFace.AmazonSettings)Session["amzSettings"];
            settings    = (UtilityMaietta.genSettings)Session["settings"];
            string        csv     = "";
            string        bprefix = Request.QueryString["bprefix"].ToString();
            int           start   = int.Parse(Request.QueryString["start"].ToString());
            int           vettID  = int.Parse(Request.QueryString["vettID"].ToString());
            string        code;
            int           c     = 0;
            List <string> lines = new List <string>();
            for (c = 0; c < ((ArrayList)Session["addresses"]).Count; c++)
            {
                code = bprefix + (start + c).ToString().PadLeft(2, '0');
                //csv = ((AmazonOrder.Order)((ArrayList)Session["orderIDS"])[c]).orderid + "\t" + DateTime.Today.ToString("ddMMyy") + "\t" + code.ToUpper();
                csv = (((ArrayList)Session["orderIDS"])[c]).ToString() + "\t" + DateTime.Today.ToString("ddMMyy") + "\t" + code.ToUpper();
                lines.Add(csv);
            }

            Shipment.ShipRead sr    = new Shipment.ShipRead(vettID, amzSettings.amzShipReadColumns);
            string[]          array = Shipment.ShipRead.AmazonLoadTable(lines, sr, '\t');
            csv = "";
            foreach (string s in array)
            {
                csv = (csv == "") ? s : csv + '\n' + s;
            }

            Response.Clear();
            Response.Buffer = true;
            Response.AddHeader("content-disposition", "attachment;filename=" + bprefix + start + "_" + c + ".txt");
            Response.Charset     = "";
            Response.ContentType = "application/text";
            Response.Output.Write(csv);
            Response.Flush();
            Response.End();
        }
        else if (Request.QueryString["shipment"] != null && Session["shipmentTable"] != null)
        {
            string vettName = Request.QueryString["shipment"].ToString();
            System.Data.DataTable csvTable =
                (System.Data.DataTable)Session["shipmentTable"];
            string csv = "";

            int i;
            foreach (DataRow dr in csvTable.Rows)
            {
                for (i = 0; i < csvTable.Columns.Count - 1; i++)
                {
                    csv += dr[i].ToString() + ";";
                }
                csv += dr[i].ToString() + Environment.NewLine;
            }

            Response.Clear();
            Response.Buffer = true;
            Response.AddHeader("content-disposition", "attachment;filename=" + vettName + "_" + csvTable.Rows.Count.ToString() + ".csv");
            Response.Charset     = "";
            Response.ContentType = "application/text";
            Response.Output.Write(csv);
            Response.Flush();
            Response.End();
        }
        else if (Request.QueryString["csvPackage"] != null && Session[Request.QueryString["csvPackage"].ToString()] != null)
        {
            amzSettings = (AmzIFace.AmazonSettings)Session["amzSettings"];
            string     shipid     = Request.QueryString["csvPackage"].ToString();
            FileUpload fup        = ((FileUpload)Session["fupPackage"]);
            string     sourceFile = fup.FileName;
            ((FileUpload)Session["fupPackage"]).SaveAs(Path.Combine(Server.MapPath("temp"), "model_" + sourceFile));
            string            localFile = Path.Combine(Server.MapPath("temp"), "model_" + sourceFile);
            List <string>     lines     = File.ReadLines(localFile).ToList();
            int               colSt     = SHIP_MODEL_COL_START;
            int               rowSt     = SHIP_MODEL_ROW_START;
            string[]          linea;
            string            fnsku;
            boxSets.shipsInfo ship = (boxSets.shipsInfo)Session["ship_" + shipid];
            boxSets.Box       box;
            List <int>        boxlistIndexes;
            List <string[]>   finalRows = new List <string[]>();
            DateTime?         scad;
            int               hPos;
            // PER OGNI SKU CERCO I BOX
            for (int i = rowSt; i < lines.Count; i++)
            {
                linea          = lines[i].Split('\t');
                fnsku          = linea[SHIP_MODEL_FNSKU_COL];
                boxlistIndexes = ship.BoxContainsNames(fnsku);

                // PER OGNI BOX IN CUI SKU è PRESENTE SCRIVO QUANTITA
                foreach (int index in boxlistIndexes)
                {
                    //box = ship.GetBox(bid);
                    box  = ship.GetBox(index);
                    scad = box.GetScadenza(fnsku);
                    hPos = (index * 2) + colSt;
                    //hPos = (box.id * 2) + colSt;
                    linea[hPos] = box.GetItemsQtBySku(fnsku).ToString();
                    //if (hPos + 1 < linea.Length && linea[hPos + 1].Trim() == "")
                    if (scad.HasValue && hPos + 1 < linea.Length && linea[hPos + 1].Trim() == "")
                    {
                        //linea[hPos + 1] = DateTime.Today.AddYears(1).ToShortDateString();
                        linea[hPos + 1] = scad.Value.ToShortDateString();
                    }
                }
                // CONSERVO LA LINEA CON LE QUANTITA
                finalRows.Add(linea);
            }

            List <string> finalFile = new List <string>();
            // RICOSTRUISCO IL FILE: INTESTAZIONE
            for (int i = 0; i < rowSt; i++)
            {
                finalFile.Add(lines[i]);
            }
            string res;
            // RICOSTRUISCO IL FILE: PRODOTTI
            foreach (string [] skuRow in finalRows)
            {
                res = String.Join('\t'.ToString(), skuRow);
                finalFile.Add(res);
            }
            string file = String.Join('\n'.ToString(), finalFile);
            Response.Clear();
            Response.Buffer = true;
            Response.AddHeader("content-disposition", "attachment;filename=" + sourceFile);
            Response.Charset     = "";
            Response.ContentType = "application/text";
            Response.Output.Write(file);
            Response.Flush();
            Response.End();
        }
        else if (Request.QueryString["csvFull"] != null && Session[Request.QueryString["csvFull"].ToString()] != null)
        {
            string shipid = Request.QueryString["csvFull"].ToString();
            //string[] cods, qts;
            string csv = "codicemaietta;qt;descrizione;sku";
            foreach (AmzIFace.AmzonInboundShipments.ShipItem si in (List <AmzIFace.AmzonInboundShipments.ShipItem>)Session[shipid])
            {
                csv += Environment.NewLine + " ;" + si.quantita + ";" + si.title + ";" + si.FNSKU;
            }
            Response.Clear();
            Response.Buffer = true;
            Response.AddHeader("content-disposition", "attachment;filename=" + shipid + "_full.csv");
            Response.Charset     = "";
            Response.ContentType = "application/text";
            Response.Output.Write(csv);
            Response.Flush();
            Response.End();
        }
        else if (Request.QueryString["csv"] != null && Session[Request.QueryString["csv"].ToString()] != null)
        {
            string   shipid = Request.QueryString["csv"].ToString();
            string   csv    = "";
            string[] cods, qts;
            csv += "codicemaietta;qt";
            foreach (AmzIFace.AmzonInboundShipments.ShipItem si in (List <AmzIFace.AmzonInboundShipments.ShipItem>)Session[shipid])
            {
                if (si.codmaie == "" || si.qtSca == "")
                {
                    csv += Environment.NewLine + si.codmaie + ";" + si.quantita;
                    continue;
                }

                cods = si.codmaie.Split(';');
                qts  = si.qtSca.Split(';');
                for (int i = 0; i < cods.Length; i++)
                {
                    csv += Environment.NewLine + cods[i].Trim() + ";" + (si.quantita * int.Parse(qts[i].Trim())).ToString();
                }
            }
            Response.Clear();
            Response.Buffer = true;
            Response.AddHeader("content-disposition", "attachment;filename=" + shipid + ".csv");
            Response.Charset     = "";
            Response.ContentType = "application/text";
            Response.Output.Write(csv);
            Response.Flush();
            Response.End();
        }
        else if (Request.QueryString["path"] != null)
        {
            string filePath = Request.QueryString["path"].ToString();
            Response.Buffer  = true;
            Response.Charset = "";
            Response.Cache.SetCacheability(HttpCacheability.NoCache);
            Response.ContentType = "image/jpg";
            Response.AddHeader("content-disposition", "attachment;filename=" + Path.GetFileName(HttpUtility.HtmlDecode(HttpUtility.UrlDecode(filePath))).Replace(" ", "_"));
            Response.TransmitFile(HttpUtility.HtmlDecode(HttpUtility.UrlDecode(filePath)));
            Response.End();
        }
        else if (Request.QueryString["zip"] != null && Request.QueryString["id"] != null && Request.QueryString["tipo"] != null)
        {
            string dir    = Request.QueryString["zip"].ToString();
            string idLav  = Request.QueryString["id"].ToString();
            string tipo   = Request.QueryString["tipo"].ToString();
            string outZip = tipo + "_" + idLav + ".zip";
            StreamCompressDirectory(dir, outZip);
        }
        else if (Request.QueryString["rtfId"] != null)
        {
            int idLav = int.Parse(Request.QueryString["rtfId"].ToString());
            StreamConvertHtml(idLav);
        }
        else if (Request.QueryString["pdf"] != null && Request.QueryString["amzOrd"] != null && Session[Request.QueryString["amzOrd"].ToString()] != null && Request.QueryString["merchantId"] != null)
        {
            amzSettings = (AmzIFace.AmazonSettings)Session["amzSettings"];
            string            orderID = Request.QueryString["amzOrd"].ToString();
            AmazonOrder.Order order   = (AmazonOrder.Order)Session[orderID];
            int      invoiceNum       = order.InvoiceNum;
            DateTime invoiceDate      = order.InvoiceDate;
            string   siglaV           = order.GetSiglaVettoreStatus();
            aMerchant = new AmzIFace.AmazonMerchant(int.Parse(Request.QueryString["merchantId"].ToString()), amzSettings.Year, amzSettings.marketPlacesFile, amzSettings);
            AmzIFace.AmazonInvoice.makeInvoicePdf(amzSettings, aMerchant, order, invoiceNum, true, invoiceDate, siglaV, false);
            //string fixedFileRegalo = Path.Combine(amzSettings.invoicePdfFolder(aMerchant), aMerchant.invoicePrefix(amzSettings) + invoiceNum.ToString().PadLeft(2, '0') + "_regalo.pdf");
            string fixedFileRegalo = order.GetGiftFile(amzSettings, aMerchant);
            //if (File.Exists(fixedFileRegalo))
            if (order.ExistsGiftFile(amzSettings, aMerchant))
            {
                Response.Buffer  = true;
                Response.Charset = "";
                Response.Cache.SetCacheability(HttpCacheability.NoCache);
                Response.ContentType = "application/pdf";
                Response.AddHeader("content-disposition", "inline;filename=" + Path.GetFileName(HttpUtility.HtmlDecode(HttpUtility.UrlDecode(fixedFileRegalo))).Replace(" ", "_"));
                Response.TransmitFile(HttpUtility.HtmlDecode(HttpUtility.UrlDecode(fixedFileRegalo)));
            }
            else
            {
                Response.Write("File " + fixedFileRegalo + " non trovato!");
            }
            Response.End();
        }
        else if (Request.QueryString["pdf"] != null)
        {
            string filePath = Request.QueryString["pdf"].ToString();
            if (File.Exists(filePath))
            {
                Response.Buffer  = true;
                Response.Charset = "";
                Response.Cache.SetCacheability(HttpCacheability.NoCache);
                Response.ContentType = "application/pdf";
                Response.AddHeader("content-disposition", "inline;filename=" + Path.GetFileName(HttpUtility.HtmlDecode(HttpUtility.UrlDecode(filePath))).Replace(" ", "_"));
                Response.TransmitFile(HttpUtility.HtmlDecode(HttpUtility.UrlDecode(filePath)));
            }
            else
            {
                Response.Write("File " + filePath + " non trovato!");
            }
            Response.End();
        }
        else if (Request.QueryString["amzOrd"] != null && Request.QueryString["amzInv"] != null && Request.QueryString["merchantId"] != null)
        {
            int invN = 0;
            //if (Session["amzSettings"] == null || !int.TryParse(Request.QueryString["amzInv"].ToString(), out invN) || invN < 1)
            if (Session["amzSettings"] == null || !int.TryParse(Request.QueryString["amzInv"].ToString(), out invN))// || invN < 1)
            {
                Response.Write("Sessione scaduta");
                return;
            }
            //string invoiceNum = Request.QueryString["amzInv"].ToString();
            string amzOrd   = Request.QueryString["amzOrd"].ToString();
            int    risposta = (Request.QueryString["tiporisposta"] != null) ? int.Parse(Request.QueryString["tiporisposta"].ToString()) : 0;
            amzSettings = (AmzIFace.AmazonSettings)Session["amzSettings"];
            settings    = (UtilityMaietta.genSettings)Session["settings"];
            UtilityMaietta.Utente u = (UtilityMaietta.Utente)Session["Utente"];
            //Year = DateTime.Today.Year;
            aMerchant = new AmzIFace.AmazonMerchant(int.Parse(Request.QueryString["merchantId"].ToString()), amzSettings.Year, amzSettings.marketPlacesFile, amzSettings);
            COUNTRY   = amzSettings.Year + "&nbsp;-&nbsp;" + aMerchant.nazione + "&nbsp;" + aMerchant.ImageUrlHtml(25, 40, "inherit");

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

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

            DateTime invoiceDate;
            if (Request.QueryString["invDate"] != null)
            {
                invoiceDate = DateTime.Parse(Request.QueryString["invDate"].ToString());
            }
            else
            {
                invoiceDate = DateTime.Today;
            }

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

            if (order.Items == null)
            {
                order.RequestItemsAndSKU(amzSettings, aMerchant, settings, cnn, wc);
            }

            int vettS = 0;
            if (Request.QueryString["vettS"] != null)
            {
                int.TryParse(Request.QueryString["vettS"].ToString(), out vettS);
            }
            vettS = (vettS == 0) ? order.GetVettoreID(amzSettings) : vettS;

            int invoiceNum;
            /// IMPORTO DEFINITIVAMENTE L'ORDINE CON I VALORI della precedente schermata. ///
            ///
            if (int.Parse(Request.QueryString["amzInv"].ToString()) > 0)
            {
                // ORDINE GIA' COMPLETAMENTE IMPORTATO E CON RICEVUTA, SOLO NUOVE MOVIMENTAZIONI
                invoiceNum = int.Parse(Request.QueryString["amzInv"].ToString());
                if (order.GetVettoreID(amzSettings) != vettS) // NUOVO VETTORE, AGGIORNO
                {
                    order.UpdateVettore(cnn, wc, vettS);
                }
            }
            else if (order.IsFullyImported() || order.IsImported())
            {
                // ORDINE COMPLETAMENTE IMPORTATO, CREO NUMERO RICEVUTA e MOVIMENTAZIONI
                invoiceNum = order.UpdateFullStatus(wc, cnn, amzSettings, aMerchant, invoiceDate, vettS, true);
            }

            else
            {
                // ORDINE DA IMPORTARE,  CREO NUMERO RICEVUTA E MOVIMENTAZIONI
                invoiceNum = order.SaveFullStatus(wc, cnn, amzSettings, aMerchant, invoiceDate, vettS, true);
            }
            ///

            //string fixedFile = Path.Combine(amzSettings.invoicePdfFolder(aMerchant), aMerchant.invoicePrefix(amzSettings) + invoiceNum.ToString().PadLeft(2, '0') + ".pdf");
            string fixedFile = AmazonOrder.Order.GetInvoiceFile(amzSettings, aMerchant, invoiceNum);
            //string fixedFileRegalo = Path.Combine(amzSettings.invoicePdfFolder(aMerchant), aMerchant.invoicePrefix(amzSettings) + invoiceNum.ToString().PadLeft(2, '0') + "_regalo.pdf");
            string fixedFileRegalo = order.GetGiftFile(amzSettings, aMerchant);

            if (File.Exists(fixedFile))
            {
                Response.Write("Impossibile sovrascrivere il file " + fixedFile + "<br />" +
                               "Devi cancellarlo prima di poterlo sovrascrivere!");
                return;
            }
            //else if (File.Exists(fixedFileRegalo))
            else if (order.ExistsGiftFile(amzSettings, aMerchant))
            {
                Response.Write("Impossibile sovrascrivere il file " + fixedFileRegalo + "<br />" +
                               "Devi cancellarlo prima di poterlo sovrascrivere!");
                return;
            }

            if (Request.QueryString["movimenta"] != null && bool.Parse(Request.QueryString["movimenta"].ToString()))
            {
                string inv = aMerchant.invoicePrefix(amzSettings) + invoiceNum.ToString().PadLeft(2, '0');
                if (!order.HasDispItems(cnn, invoiceDate))
                {
                    cnn.Close();
                    wc.Close();
                    Response.Write("Disponibilità negative per uno o più Item dell'ordine. Impossibile eseguire lo scarico.<br />" +
                                   "Puoi solo creare il pdf.");
                    return;
                }
                List <AmzIFace.ProductMaga> pm = order.MakeMovimentaAllItems(cnn, amzSettings, u, inv, invoiceDate, order.dataUltimaMod, aMerchant, settings);
                UtilityMaietta.writeMagaOrder(pm, amzSettings.AmazonMagaCode, settings, 'F');
            }

            if (Request.QueryString["schedaecm"] != null && bool.Parse(Request.QueryString["schedaecm"].ToString()))
            {
                OleDbConnection ecmScn = new OleDbConnection(settings.EcmOleDbConnString);
                ecmScn.Open();
                EcmUtility.EcmScheda es = new EcmUtility.EcmScheda(order, true, EcmUtility.categoria);
                es.makeSchedaEcm(ecmScn);
                ecmScn.Close();
            }

            string siglaV = (vettS == 0) ? order.GetSiglaVettore(cnn, amzSettings) : order.GetSiglaVettoreStatus();
            //AmzIFace.AmazonInvoice.makeInvoicePdf(amzSettings, aMerchant, order, invN, false, invoiceDate, siglaV, false);
            AmzIFace.AmazonInvoice.makeInvoicePdf(amzSettings, aMerchant, order, invoiceNum, false, invoiceDate, siglaV, false);
            if (Request.QueryString["regalo"] != null && bool.Parse(Request.QueryString["regalo"].ToString()))
            {
                fixedFile = fixedFileRegalo;
                //AmzIFace.AmazonInvoice.makeInvoicePdf(amzSettings, aMerchant, order, invN, true, invoiceDate, siglaV, false);
                AmzIFace.AmazonInvoice.makeInvoicePdf(amzSettings, aMerchant, order, invoiceNum, true, invoiceDate, siglaV, false);
            }
            cnn.Close();
            wc.Close();

            if (risposta != 0)
            {
                AmazonOrder.Comunicazione com = new AmazonOrder.Comunicazione(risposta, amzSettings, aMerchant);
                string subject = com.Subject(order.orderid);
                string attach  = (com.selectedAttach && File.Exists(fixedFile)) ? fixedFile : "";
                bool   send    = UtilityMaietta.sendmail(attach, amzSettings.amzDefMail, order.buyer.emailCompratore, subject,
                                                         com.GetHtml(order.orderid, order.destinatario.ToHtmlFormattedString(), order.buyer.nomeCompratore), false, "", "", settings.clientSmtp,
                                                         settings.smtpPort, settings.smtpUser, settings.smtpPass, false, null);
            }

            /*Response.Buffer = true;
             * Response.Charset = "";
             * Response.Cache.SetCacheability(HttpCacheability.NoCache);
             * Response.ContentType = "application/pdf";
             * Response.AddHeader("content-disposition", "attachment;filename=" + Path.GetFileName(fixedFile));
             * Response.TransmitFile(fixedFile);*/

            /*
             *
             */
            /*if (Request.QueryString["amzToken"] != null)
             * {
             *  string nexttoken = Request.QueryString["amzToken"].ToString();
             *  //imbNextPag.PostBackUrl = "amzPanoramica.aspx?token=" + Session["token"].ToString() + "&merchantId=" + Request.QueryString["merchantId"].ToString() + "&amzToken=" + HttpUtility.UrlEncode(nexttoken);
             *
             *  ClientScript.RegisterStartupScript(this.GetType(), "amzTokenPb",
             *      "<script type='text/javascript' language='javascript'>" +
             *      "window.open('download.aspx?pdf=" + HttpUtility.UrlEncode(fixedFile) + "&token=" + Session["token"].ToString() + "', '_blank');" +
             *      "__doPostBack('imbNextPag','OnClick');</script>");
             * }
             * else*/
            //{
            Response.Write(@"<script lang='text/javascript'>window.open('download.aspx?pdf=" + HttpUtility.UrlEncode(fixedFile) + "&token=" + Session["token"].ToString() + "', '_blank');" +
                           "window.top.location.href = 'amzPanoramica.aspx?token=" + Session["token"].ToString() + MakeQueryParams() + "';</script>)");
            //}

            /*if (Session["token"] != null)
             *  Response.Redirect("amzPanoramica.aspx?token=" + Session["token"].ToString() + MakeQueryParams());
             * else
             *  Response.Redirect("login.aspx?path=amzPanoramica");
             * Response.End();*/
        }
        else if (Request.QueryString["amzBCSku"] != null && Request.QueryString["labQt"] != null && Request.QueryString["descBC"] != null &&
                 Request.QueryString["status"] != null && Request.QueryString["labCode"] != null)
        {
            amzSettings = (AmzIFace.AmazonSettings)Session["amzSettings"];
            settings    = (UtilityMaietta.genSettings)Session["settings"];

            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();
            AmzIFace.AmazonInvoice.PaperLabel pl = new AmzIFace.AmazonInvoice.PaperLabel(0, 0, amzSettings.amzPaperLabelsFile, Request.QueryString["labCode"].ToString());

            string file = "barcode_" + sku + "_" + numLabels.ToString() + ".pdf";
            Response.ContentType = "application/pdf";
            Response.AppendHeader("Content-Disposition", "attachment; filename=" + file);
            AmzIFace.AmzonInboundShipments.MakeBarCodeFullPages(sku, descBC, status, numLabels, Response.OutputStream, amzSettings,
                                                                amzSettings.amzBarCodeWpx, amzSettings.amzBarCodeHpx, amzSettings.amzBarCodeWmm, amzSettings.amzBarCodeHmm, pl);

            Response.End();
            return;
        }
        else if (Request.QueryString["printAll"] != null && Request.QueryString["labCode"] != null && Session["printAll"] != null && Request.QueryString["status"] != null)
        {
            amzSettings = (AmzIFace.AmazonSettings)Session["amzSettings"];
            settings    = (UtilityMaietta.genSettings)Session["settings"];
            string status = Request.QueryString["status"].ToString();
            string shipid = Request.QueryString["printAll"].ToString();
            AmzIFace.AmazonInvoice.PaperLabel pl = new AmzIFace.AmazonInvoice.PaperLabel(0, 0, amzSettings.amzPaperLabelsFile, Request.QueryString["labCode"].ToString());
            List <AmzIFace.AmzonInboundShipments.FullLabel> printAll = (List <AmzIFace.AmzonInboundShipments.FullLabel>)Session["printAll"];

            int forPage  = pl.rows * pl.cols;
            int numpages = ((printAll.Count % forPage) == 0) ? printAll.Count / forPage : (printAll.Count / forPage) + 1;

            List <AmzIFace.AmzonInboundShipments.FullLabel[][]> document = new List <AmzIFace.AmzonInboundShipments.FullLabel[][]>();
            AmzIFace.AmzonInboundShipments.FullLabel[][]        page;

            int count = 0;
            for (int p = 0; p < numpages; p++)
            {
                if (count >= printAll.Count)
                {
                    break;
                }

                page = new AmzIFace.AmzonInboundShipments.FullLabel[pl.rows][];
                for (int r = 0; r < pl.rows; r++)
                {
                    if (count >= printAll.Count)
                    {
                        break;
                    }

                    page[r] = new AmzIFace.AmzonInboundShipments.FullLabel[pl.cols];
                    for (int c = 0; c < pl.cols; c++)
                    {
                        if (count >= printAll.Count)
                        {
                            break;
                        }

                        page[r][c]      = new AmzIFace.AmzonInboundShipments.FullLabel();
                        page[r][c].sku  = printAll[count].sku;
                        page[r][c].desc = printAll[count].desc;
                        page[r][c].qt   = printAll[count].qt;

                        count++;
                    }
                }
                document.Add(page);
            }

            /*int count = 0, pag = 0;
             * int c = 1, r = 1;
             * ArrayList labels = new ArrayList();
             *
             * //////////// ERRORE AUMENTO R E C
             * while (count < printAll.Count)
             * {
             *  labels.Add(new AmzIFace.AmazonInvoice.PaperLabel(c++, r++, amzSettings.amzPaperLabelsFile, Request.QueryString["labCode"].ToString()));
             *  count++;
             * }
             * for (int r = 0; r < pl.rows; r++)
             * {
             *  if (count >= printAll.Count)
             *      break;
             *  for (int c = 0; c < pl.cols; c++)
             *  {
             *      if (count >= printAll.Count)
             *          break;
             *
             *      labels.Add(new AmzIFace.AmazonInvoice.PaperLabel(c, r, amzSettings.amzPaperLabelsFile, Request.QueryString["labCode"].ToString()));
             *      count++;
             *  }
             * }*/
            string file = "barcode_" + shipid + "_" + printAll.Count.ToString() + ".pdf";
            Response.ContentType = "application/pdf";
            Response.AppendHeader("Content-Disposition", "attachment; filename=" + file);
            AmzIFace.AmzonInboundShipments.MakeMultiBarCodeGrid(document, Response.OutputStream, status, amzSettings, amzSettings.amzBarCodeWpx, amzSettings.amzBarCodeHpx,
                                                                amzSettings.amzBarCodeWmm, amzSettings.amzBarCodeHmm, pl);
            Response.End();
            return;
        }
        Response.Write("Sessione scaduta");
        return;
    }
コード例 #4
0
    private void FillTableSKU(ArrayList items, OleDbConnection cnn)
    {
        AddFirstRow();
        TableRow    tr;
        TableCell   tc;
        Label       labSku;
        Label       labCodMaie;
        HiddenField hidSku;
        HiddenField hidCodMaie;
        TextBox     txCodMaga;
        //TextBox txTipoR;
        DropDownList dropTipoR;
        CheckBox     chklav;
        TextBox      txQtS;
        CheckBox     chkMCS;
        ImageButton  imgB;
        DropDownList dropVett;
        DataTable    vettori  = UtilityMaietta.Vettore.GetVettori(cnn);
        ArrayList    risposte = AmazonOrder.Comunicazione.GetAllRisposte(amzSettings.amzComunicazioniFile, aMerchant);

        AmazonOrder.Comunicazione com;

        int count = 0;

        foreach (AmazonOrder.SKUItem si in items)
        {
            tr = new TableRow();
            //SKU
            tc           = new TableCell();
            labSku       = new Label();
            labSku.ID    = "labSku#" + si.SKU;
            labSku.Text  = si.SKU;
            hidSku       = new HiddenField();
            hidSku.ID    = "hidSku#" + si.SKU;
            hidSku.Value = si.SKU;
            tc.Controls.Add(labSku);
            tc.Controls.Add(hidSku);
            tr.Cells.Add(tc);

            //CODICE MAGA
            tc = new TableCell();
            if (si.MovimentazioneChecked && 0 == 1) // GIA MOVIMENTATO METTO LABEL
            {
                labCodMaie      = new Label();
                labCodMaie.ID   = "labCodMaga#" + si.SKU;
                labCodMaie.Text = si.prodotto.codmaietta;
                tc.Controls.Add(labCodMaie);
                hidCodMaie       = new HiddenField();
                hidCodMaie.ID    = "hidCodMaie#" + si.SKU + "#si" + count;
                hidCodMaie.Value = si.prodotto.codmaietta;
                tc.Controls.Add(hidCodMaie);
            }
            else
            {
                txCodMaga      = new TextBox();
                txCodMaga.ID   = "txCodMaga#" + si.SKU + "#si" + count;
                txCodMaga.Text = si.prodotto.codmaietta;
                tc.Controls.Add(txCodMaga);
            }
            tr.Cells.Add(tc);

            //TIPO RISPOSTA
            tc                       = new TableCell();
            dropTipoR                = new DropDownList();
            dropTipoR.ID             = "dropTpr#" + si.SKU + "#si" + count;
            dropTipoR.Width          = 160;
            dropTipoR.DataSource     = risposte;
            dropTipoR.DataTextField  = "nome";
            dropTipoR.DataValueField = "id";
            dropTipoR.DataBind();
            com = new AmazonOrder.Comunicazione(si.idrisposta, amzSettings, aMerchant);
            dropTipoR.SelectedIndex = com.Index(risposte);
            tc.Controls.Add(dropTipoR);

            /*txTipoR = new TextBox();
             * txTipoR.ID = "txTpr#" + si.SKU + "#si" + count;
             * txTipoR.Width = 30;
             * txTipoR.Text = si.idrisposta.ToString();
             * tc.Controls.Add(txTipoR);*/
            tr.Cells.Add(tc);

            //LAVORAZIONE
            tc             = new TableCell();
            chklav         = new CheckBox();
            chklav.ID      = "chkLav#" + si.SKU + "#si" + count;
            chklav.Checked = si.lavorazione;
            tc.Controls.Add(chklav);
            tr.Cells.Add(tc);

            //QT SCARICARE
            tc          = new TableCell();
            txQtS       = new TextBox();
            txQtS.ID    = "txQtS#" + si.SKU + "#si" + count;
            txQtS.Width = 30;
            txQtS.Text  = si.qtscaricare.ToString();
            tc.Controls.Add(txQtS);
            tr.Cells.Add(tc);

            //OFFERTA
            tc             = new TableCell();
            chkMCS         = new CheckBox();
            chkMCS.ID      = "chkMCS#" + si.SKU + "#si" + count;
            chkMCS.Checked = si.isMCS;
            tc.Controls.Add(chkMCS);
            tr.Cells.Add(tc);

            //VETTORE
            tc                      = new TableCell();
            dropVett                = new DropDownList();
            dropVett.ID             = "dropVett#" + si.SKU + "#si" + count;
            dropVett.DataSource     = vettori;
            dropVett.DataTextField  = "sigla";
            dropVett.DataValueField = "id";
            dropVett.DataBind();
            dropVett.SelectedValue = si.vettoreID.ToString();
            tc.Controls.Add(dropVett);
            tr.Cells.Add(tc);

            // AGGIUNGI RIGA
            tc = new TableCell();
            if (!si.MovimentazioneChecked)
            {
                imgB               = new ImageButton();
                imgB.ID            = "add_" + si.SKU;
                imgB.ImageUrl      = "pics/add.png";
                imgB.Width         = 35;
                imgB.Height        = 35;
                imgB.OnClientClick = "return addRow(this);";
                tc.Controls.Add(imgB);
            }
            tr.Cells.Add(tc);

            if (si.MovimentazioneChecked) // PRODOTTO CON MOVIMENTAZIONI
            {
                tr.BackColor = System.Drawing.ColorTranslator.FromHtml("#FF9882");
            }
            else if ((count % 2) != 0)
            {
                tr.BackColor = System.Drawing.Color.LightGray;
            }
            tabCodes.Rows.Add(tr);
            count++;
        }
    }
コード例 #5
0
    protected void btnMakePdf_Click(object sender, EventArgs e)
    {
        string errore = "";

        UtilityMaietta.Utente u = (UtilityMaietta.Utente)Session["Utente"];
        //string amzOrd = Request.Form["txNumOrd"].ToString();
        string amzOrd = Request.QueryString["amzOrd"].ToString();

        bool regalo = (Request.Form["chkRegalo"] != null && Request.Form["chkRegalo"].ToString() == "on");
        bool mov    = (Request.Form["chkMovimenta"] != null && Request.Form["chkMovimenta"].ToString() == "on") ? true : false;
        bool comm   = (Request.Form["chkSendRisp"] != null && Request.Form["chkSendRisp"].ToString() == "on") ? true : false;

        DateTime invoiceDate = calInvoiceData.SelectedDate;

        UtilityMaietta.infoProdotto ip;
        int             count = 0;
        string          pos;
        string          codprod;
        int             codforn, qt;
        double          costo;
        OleDbConnection cnn = new OleDbConnection(settings.OleDbConnString);
        OleDbConnection wc  = new OleDbConnection(settings.lavOleDbConnection);

        wc.Open();
        cnn.Open();

        // CHECK DISPONIBILITA
        if (mov)
        {
            foreach (GridViewRow gvr in gridProducts.Rows)
            {
                pos     = (count + 2).ToString().PadLeft(2, '0');
                codprod = gvr.Cells[colCodProd].Text;
                codforn = int.Parse(gvr.Cells[colCodForn].Text);
                costo   = double.Parse(Request.Form["gridProducts$ctl" + pos + "$txCosto_" + count.ToString().Replace(",", ".")].ToString());
                qt      = int.Parse(Request.Form["gridProducts$ctl" + pos + "$txQt_" + count.ToString()].ToString());
                ip      = new UtilityMaietta.infoProdotto(codprod, codforn, cnn, settings);
                if (ip.getDispDate(cnn, DateTime.Now, false) < qt || ip.getDispDate(cnn, invoiceDate, true) - (qt) < 0)
                {
                    wc.Close();
                    cnn.Close();
                    btnMakePdf.Enabled = false;
                    Response.Write("Quantità indicata non disponibile!");
                    return;
                }
                count++;
            }
        }

        // RECUPERA ORDINE
        AmazonOrder.Order order;
        if (Session[amzOrd] == null)
        {
            order = AmazonOrder.Order.ReadOrderByNumOrd(amzOrd, amzSettings, aMerchant, out errore);
        }
        else
        {
            order = (AmazonOrder.Order)Session[amzOrd];
        }
        if (order == null || errore != "")
        {
            Response.Write("Impossibile contattare amazon, riprova più tardi!<br />Errore: " + errore);
            return;
        }
        if (order.Items == null || order.Items.Count == 0)
        {
            order.RequestItems(amzSettings, aMerchant);
        }

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

        int vettS = int.Parse(dropVettori.SelectedValue.ToString());
        int invoiceNum;

        /// IMPORTO DEFINITIVAMENTE L'ORDINE CON I VALORI della precedente schermata.

        if (Request.QueryString["amzInv"] != null && int.Parse(Request.QueryString["amzInv"].ToString()) > 0)
        {
            // ORDINE GIA' COMPLETAMENTE IMPORTATO E CON RICEVUTA, SOLO NUOVE MOVIMENTAZIONI
            invoiceNum = int.Parse(Request.QueryString["amzInv"].ToString());
        }
        else if (order.IsFullyImported() || order.IsImported())
        {
            // ORDINE COMPLETAMENTE IMPORTATO, CREO NUMERO RICEVUTA e MOVIMENTAZIONI
            invoiceNum = order.UpdateFullStatus(wc, cnn, amzSettings, aMerchant, invoiceDate, vettS, false);
        }
        else
        {
            // ORDINE DA IMPORTARE,  CREO NUMERO RICEVUTA E MOVIMENTAZIONI
            invoiceNum = order.SaveFullStatus(wc, cnn, amzSettings, aMerchant, invoiceDate, vettS, false);
        }

        string siglaV = dropVettori.SelectedItem.Text;

        // EMETTI FATTURA
        AmzIFace.AmazonInvoice.makeInvoicePdf(amzSettings, aMerchant, order, invoiceNum, regalo, invoiceDate, siglaV, chkOpenLav.Checked);
        string inv = aMerchant.invoicePrefix(amzSettings) + invoiceNum.ToString().PadLeft(2, '0');

        // MOVIMENTA SINGOLO CODICE

        count = 0;
        List <AmzIFace.CodiciDist>  lip = new List <AmzIFace.CodiciDist>();
        List <AmzIFace.ProductMaga> pm  = new List <AmzIFace.ProductMaga>();

        AmzIFace.ProductMaga prod;
        AmzIFace.CodiciDist  cd;

        int cdpos;

        foreach (GridViewRow gvr in gridProducts.Rows)
        {
            pos     = (count + 2).ToString().PadLeft(2, '0');
            codprod = gvr.Cells[colCodProd].Text;
            codforn = int.Parse(gvr.Cells[colCodForn].Text);
            costo   = double.Parse(Request.Form["gridProducts$ctl" + pos + "$txCosto_" + count.ToString()].ToString().Replace(",", "."));
            qt      = int.Parse(Request.Form["gridProducts$ctl" + pos + "$txQt_" + count.ToString()].ToString());
            ip      = new UtilityMaietta.infoProdotto(codprod, codforn, cnn, settings);

            if (mov)
            {
                ip.AmzMovimenta(cnn, inv, order.orderid, invoiceDate, costo, qt, order.dataUltimaMod, amzSettings, u);

                prod = new AmzIFace.ProductMaga();
                prod.codicemaietta = ip.codmaietta;
                //prod.price = costo / 1.22;
                prod.price = costo / settings.IVA_MOLT;
                prod.qt    = qt;
                pm.Add(prod);
            }

            cd = new AmzIFace.CodiciDist(ip, qt, costo);
            if (!lip.Contains(cd))
            {
                lip.Add(cd);
            }
            else
            {
                cdpos = lip.IndexOf(cd);
                lip[cdpos].AddQuantity(qt, costo);
            }
            count++;
        }
        cnn.Close();
        Session["freeProds"] = lip;

        if (mov)
        {
            UtilityMaietta.writeMagaOrder(pm, amzSettings.AmazonMagaCode, settings, 'F');
        }

        if (comm && Request.Form["dropRisposte"] != null && Request.Form["dropRisposte"].ToString() != "0")
        {
            int risposta = int.Parse(Request.Form["dropRisposte"].ToString());
            if (risposta != 0)
            {
                string fixedFile = AmazonOrder.Order.GetInvoiceFile(amzSettings, aMerchant, invoiceNum);
                AmazonOrder.Comunicazione com = new AmazonOrder.Comunicazione(risposta, amzSettings, aMerchant);
                string subject = com.Subject(order.orderid);
                string attach  = (com.selectedAttach && File.Exists(fixedFile)) ? fixedFile : "";
                bool   send    = UtilityMaietta.sendmail(attach, amzSettings.amzDefMail, order.buyer.emailCompratore, subject,
                                                         com.GetHtml(order.orderid, order.destinatario.ToHtmlFormattedString(), order.buyer.nomeCompratore), false, "", "", settings.clientSmtp,
                                                         settings.smtpPort, settings.smtpUser, settings.smtpPass, false, null);
            }
        }

        if (chkOpenLav.Checked)
        {
            /// APRI LAVORAZIONE
            Response.Redirect("lavAmzOpen.aspx?token=" + Request.QueryString["token"].ToString() +
                              "&amzOrd=" + order.orderid + "&invnumb=" + inv + "&freeProds=" + lip.Count.ToString() +
                              MakeQueryParams());
        }
        else
        {
            /// TORNA IN HOME
            Response.Redirect("amzPanoramica.aspx?token=" + Session["token"].ToString() + MakeQueryParams());
        }
    }