public void add(object sender, CommandEventArgs e)
        {
            // sane

            if ((int)Application["config_registrazione"] > 0 && ((simplestecommerce.Cart)Session["Cart"]).User.Anonimo)
            {
                Response.Redirect("~/shop/login.aspx");
            }

            int idArt = Convert.ToInt32(e.CommandArgument);

            simplestecommerce.Listino  Currentlistino = ((simplestecommerce.Cart)Session["Cart"]).Listino;
            simplestecommerce.User     Currentuser    = ((simplestecommerce.Cart)Session["Cart"]).User;
            simplestecommerce.articolo articolo       = new articolo(idArt, Currentlistino.Id, Currentlistino.Sconto, Currentuser.Sconto);


            int     riga     = Convert.ToInt32(e.CommandName);
            TextBox txt      = (TextBox)((listaarticoli.Items[riga]).FindControl("tBoxQuantita"));
            int     quantita = 0;


            if (articolo.Variations.Count > 0)
            {
                string msg = simplestecommerce.lingua.getforfrontendbypseudo("preview.alert.this.article.has.variations");

                System.Web.UI.ScriptManager.RegisterStartupScript(this.Page, Page.GetType(), "text", "alert('" + msg + "'); document.location='" + ResolveUrl(articolo.Linkart) + "';", true);


                return;
            }
            else if (!Int32.TryParse(txt.Text, out quantita) || quantita < 1)
            {
                string msg = simplestecommerce.lingua.getforfrontendbypseudo("preview.alert.inappropriate.quantity");
                simplestecommerce.common.alert(msg, this.Page);
            }
            else
            {
                string errore = simplestecommerce.lingua.getforfrontendbypseudo(Cart.pseudoerravailability(articolo.Idart, quantita));
                if (errore != "")
                {
                    string msg = simplestecommerce.sicurezza.xss.getreplacedencoded(errore);
                    simplestecommerce.common.alert(msg, this.Page);
                    return;
                }



                ((simplestecommerce.Cart)Session["cart"]).addToCart(new simplestecommerce.cartItem(articolo, quantita, new List <simplestecommerce.Choosedvariation>()));



                string msgbis = String.Format(
                    simplestecommerce.lingua.getforfrontendbypseudo("preview.alert.product.added.to.cart"),
                    simplestecommerce.sicurezza.xss.getreplacedencoded(simplestecommerce.lingua.getforfrontendfromdb(articolo.Name)));



                simplestecommerce.common.alert(msgbis, this.Page);
            }
        }
        void dataListCat_dataBound(object sender, DataListItemEventArgs e)
        {
            if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem)
            {
                DataRowView drv = (DataRowView)e.Item.DataItem;


                simplestecommerce.Listino  Currentlistino = ((simplestecommerce.Cart)Session["Cart"]).Listino;
                simplestecommerce.User     Currentuser    = ((simplestecommerce.Cart)Session["Cart"]).User;
                simplestecommerce.articolo articolo       = new articolo((int)drv["art_id"], Currentlistino.Id, Currentlistino.Sconto, Currentuser.Sconto);


                l += 1;

                if ((Math.Ceiling((double)l / 2) == Convert.ToDouble(l / 2)))
                {
                    //((HtmlTableCell)e.Item.FindControl("td1")).Width= "14";
                }


                if (l == 1)
                {
                    // ((HtmlTableCell)e.Item.FindControl("td2")).Attributes["style"] = "background-color:#ffffff; border-bottom: dotted 1px #BDCDD9; border-top: dotted 1px #BDCDD9";
                    // ((HtmlTableCell)e.Item.FindControl("td3")).Attributes["style"] = "background-color:#ffffff; border-bottom: dotted 1px #BDCDD9; border-top: dotted 1px #BDCDD9";
                }
                else if (l > 2)
                {
                    ((HtmlTableCell)e.Item.FindControl("td2")).Attributes["style"] = "background-color:#ffffff; border-top: dotted 1px #BDCDD9;";
                    ((HtmlTableCell)e.Item.FindControl("td3")).Attributes["style"] = "background-color:#ffffff; border-top: dotted 1px #BDCDD9;";
                }

                ((HyperLink)e.Item.FindControl("hLinkArt")).Text        = simplestecommerce.lingua.getforfrontendfromdb(articolo.Name);
                ((HyperLink)e.Item.FindControl("hLinkArt")).NavigateUrl = articolo.Linkart;

                ((HtmlAnchor)e.Item.FindControl("linkImage")).HRef = articolo.Linkart;

                Image img = (Image)e.Item.FindControl("imgArt");

                if (articolo.Preview == "")
                {
                    img.ImageUrl = "~/immagini/non_disponibile.gif";
                }
                else
                {
                    img.ImageUrl = articolo.Preview;
                }

                img.ToolTip = simplestecommerce.lingua.getforfrontendfromdb(articolo.Name);

                Label lblPrezzoArticolo = ((Label)e.Item.FindControl("lblPrezzoArticolo"));



                lblPrezzoArticolo.Text = currencies.tostrusercurrency(articolo.Prezzodoposcontoprodottoutentelistino);
            }
        }
        void Page_Load()
        {
            simplestecommerce.User Currentuser = ((simplestecommerce.Cart)Session["Cart"]).User;
            if (!Currentuser.Anonimo)
            {
                Response.Redirect("~/shop/updateprofile.aspx");
            }


            pHolderEsito.Visible    = false;
            pHolderRegister.Visible = true;

            if (!Page.IsPostBack)
            {
                listaSoggetti.Items.Add(new ListItem(simplestecommerce.lingua.getforfrontendbypseudo(simplestecommerce.common.arrPseudoLegalSubject[0]), "0"));
                listaSoggetti.Items.Add(new ListItem(simplestecommerce.lingua.getforfrontendbypseudo(simplestecommerce.common.arrPseudoLegalSubject[1]), "1"));

                listaSoggetti.Items[0].Selected = true;

                DataTable dtRegioni = simplestecommerce.regioni.getAll();


                listaRegioni.DataSource     = dtRegioni;
                listaRegioni.DataTextField  = "r_nome";
                listaRegioni.DataValueField = "r_id";
                listaRegioni.DataBind();

                dlistspidregion.DataSource     = dtRegioni;
                dlistspidregion.DataTextField  = "r_nome";
                dlistspidregion.DataValueField = "r_id";
                dlistspidregion.DataBind();

                showhidemandatoryfields();
            }

            if (listaSoggetti.SelectedValue == "1")
            {
                pHolderRagSoc.Visible = true;
            }
            else
            {
                pHolderRagSoc.Visible = false;
            }
        }
        public void listaarticoli_databound(object sender, ListViewItemEventArgs e)
        {
            // sane
            b++;
            if (e.Item.ItemType == ListViewItemType.DataItem)
            {
                DataRowView drv = (DataRowView)(e.Item.DataItem);

                ((Button)e.Item.FindControl("buttAdd")).CommandName     = Server.HtmlEncode(n.ToString());
                ((Button)e.Item.FindControl("buttAdd")).CommandArgument = drv["art_id"].ToString();
                n++;



                int idArt = (int)drv["art_id"];


                simplestecommerce.Listino  Currentlistino = ((simplestecommerce.Cart)Session["Cart"]).Listino;
                simplestecommerce.User     Currentuser    = ((simplestecommerce.Cart)Session["Cart"]).User;
                simplestecommerce.articolo articolo       = new articolo((int)drv["art_id"], Currentlistino.Id, Currentlistino.Sconto, Currentuser.Sconto);


                Image imgPreview = ((Image)e.Item.FindControl("articoloImgPreview"));
                if (articolo.Preview == "")
                {
                    imgPreview.ImageUrl = "~/immagini/non_disponibile.gif";
                    imgPreview.Width    = 90;
                }
                else
                {
                    imgPreview.ImageUrl =
                        "autoresize.aspx?path=" + Server.UrlEncode(Page.ResolveUrl(articolo.Preview));
                    imgPreview.ImageUrl = ResolveUrl(articolo.Preview);
                    imgPreview.Width    = 48;
                }
                imgPreview.ToolTip = String.Format(
                    simplestecommerce.lingua.getforfrontendbypseudo("preview.products.tooltip.see.details"),
                    simplestecommerce.sicurezza.xss.getreplacedencoded(simplestecommerce.lingua.getforfrontendfromdb(articolo.Name)))

                ;

                ((Label)e.Item.FindControl("lblMarca")).Text = simplestecommerce.articoli.strMarca(articolo.Marca);
                Label lblDispArticolo = ((Label)e.Item.FindControl("lblDisp"));

                ((HtmlAnchor)e.Item.FindControl("linkartimg")).HRef = ResolveUrl(articolo.Linkart);

                ((HyperLink)e.Item.FindControl("linkartname")).Text        = simplestecommerce.lingua.getforfrontendfromdb(articolo.Name);
                ((HyperLink)e.Item.FindControl("linkartname")).NavigateUrl = ResolveUrl(articolo.Linkart);
                ((HyperLink)e.Item.FindControl("linkartname")).ToolTip     = String.Format(
                    simplestecommerce.lingua.getforfrontendbypseudo("preview.products.tooltip.see.details"),
                    simplestecommerce.sicurezza.xss.getreplacedencoded(simplestecommerce.lingua.getforfrontendfromdb(articolo.Name)));



                // sdisplay availability
                // show hide placeholder addtocart and display availability
                if (articolo.Disponibilita == 0)
                {
                    if (articolo.Stock < 1)
                    {
                        lblDispArticolo.Text = lingua.getforfrontendbypseudo("preview.products.label.not.in.stock");
                    }
                    else
                    {
                        lblDispArticolo.Text = lingua.getforfrontendbypseudo(common.arrPseudoDisponibilita[articolo.Disponibilita]);
                    }
                }
                else if (articolo.Disponibilita == 1)
                {
                    lblDispArticolo.Text = lingua.getforfrontendbypseudo(common.arrPseudoDisponibilita[articolo.Disponibilita]);
                }
                else if (articolo.Disponibilita == 2)
                {
                    lblDispArticolo.Text = lingua.getforfrontendbypseudo(common.arrPseudoDisponibilita[articolo.Disponibilita]);
                }
                //**************************************************************



                if (articolo.Consegna != -1)
                {
                    lblDispArticolo.Text += ", " +
                                            String.Format(
                        simplestecommerce.lingua.getforfrontendbypseudo("preview.products.label.delivery.in.days"),
                        articolo.Consegna.ToString());
                }



                Label lblPrezzoArticolo = ((Label)e.Item.FindControl("lblPrezzo"));



                if (articolo.Prezzobase == articolo.Prezzodoposcontoprodottoutentelistino)
                {
                    // non c'è sconto
                    lblPrezzoArticolo.Text = currencies.tostrusercurrency(articolo.Prezzobase);
                }
                else
                {
                    //c'è sconto
                    lblPrezzoArticolo.Text = "<strike>"
                                             + currencies.tostrusercurrency(articolo.Prezzobase).Replace(" ", "&nbsp;")
                                             + "</strike>" +
                                             "<br><font color=red><b>"
                                             + currencies.tostrusercurrency(articolo.Prezzodoposcontoprodottoutentelistino) +
                                             "</b></font>";
                }
            }
        }
Пример #5
0
        void dataListCat_dataBound(object sender, DataListItemEventArgs e)
        {
            if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem)
            {
                DataRowView drv = (DataRowView)e.Item.DataItem;


                simplestecommerce.Listino  Currentlistino = ((simplestecommerce.Cart)Session["Cart"]).Listino;
                simplestecommerce.User     Currentuser    = ((simplestecommerce.Cart)Session["Cart"]).User;
                simplestecommerce.articolo articolo       = new articolo((int)drv["art_id"], Currentlistino.Id, Currentlistino.Sconto, Currentuser.Sconto);



                ((HyperLink)e.Item.FindControl("hLinkArt")).Text        = simplestecommerce.lingua.getforfrontendfromdb(articolo.Name);
                ((HyperLink)e.Item.FindControl("hLinkArt")).NavigateUrl = articolo.Linkart;

                ((HtmlAnchor)e.Item.FindControl("linkImage")).HRef = articolo.Linkart;


                Image img = (Image)e.Item.FindControl("imgArt");

                if (articolo.Preview == "")
                {
                    img.ImageUrl = "~/immagini/non_disponibile.gif";
                }
                else
                {
                    img.ImageUrl = articolo.Preview;
                }

                img.ToolTip = simplestecommerce.lingua.getforfrontendfromdb(articolo.Name);

                Label lblPrezzoArticolo = ((Label)e.Item.FindControl("lblPrezzoArticolo"));



                if (articolo.Prezzobase == articolo.Prezzodoposcontoprodottoutentelistino)
                {
                    // non c'è sconto
                    lblPrezzoArticolo.Text = currencies.tostrusercurrency(articolo.Prezzobase);
                }
                else
                {
                    //c'è sconto
                    lblPrezzoArticolo.Text = "<strike>"
                                             + currencies.tostrusercurrency(articolo.Prezzobase).Replace(" ", "&nbsp;")
                                             + "</strike>" +
                                             "<br><font color=red><b>"
                                             + currencies.tostrusercurrency(articolo.Prezzodoposcontoprodottoutentelistino) +
                                             "</b></font>";
                }


                double sconto =
                    (articolo.Prezzobase - articolo.Prezzodoposcontoprodottoutentelistino) / articolo.Prezzobase * 100;

                if (sconto > 0)
                {
                    ((Label)e.Item.FindControl("lblSconto")).Text += "<br>- " + Math.Round(sconto, 2) + "%";
                }
            }
        }
        void Page_Load()
        {

            currentcart = (Cart)Session["Cart"];
            currentuser = currentcart.User;
            
            if ((int)Application["config_registrazione"] > 0 && currentuser.Anonimo ) Response.Redirect("login.aspx");

            if ( currentuser.Anonimo)
            {
                pHolderVuoiRegistrati.Visible = true;

            }

            


            if (!Page.IsPostBack)
            {
                dlistsubject.Items.Add(new ListItem(simplestecommerce.lingua.getforfrontendbypseudo(simplestecommerce.common.arrPseudoLegalSubject[0]), "0"));
                dlistsubject.Items.Add(new ListItem(simplestecommerce.lingua.getforfrontendbypseudo(simplestecommerce.common.arrPseudoLegalSubject[1]), "1"));
                dlistsubject.Items[0].Selected = true;

                DataTable dtRegioniAccettate = simplestecommerce.regioni.getAll();
                dlistregion.DataSource = dtRegioniAccettate;
                dlistregion.DataTextField = "r_nome";
                dlistregion.DataValueField = "r_id";
                dlistregion.DataBind();

                dlistspregion.DataSource = dtRegioniAccettate;
                dlistspregion.DataTextField = "r_nome";
                dlistspregion.DataValueField = "r_id";
                dlistspregion.DataBind();


                DataTable dt = simplestecommerce.modeofpayment.tableTipPagam;
                foreach (DataRow dr in dt.Rows)
                {
                    if ((int)dr["attivo"] == 1)
                    {
                        double sovrapprezzo;
                        string strSovrapprezzo = "";


                        sovrapprezzo = simplestecommerce.spedizione.getSovrapprezzo((int)dr["id"], currentcart.Subtotal);
                        if (sovrapprezzo != 0) strSovrapprezzo = " +" + currencies.tostrusercurrency(sovrapprezzo);

                        dlistmodeofpayment.Items.Add(new ListItem(simplestecommerce.sicurezza.xss.getreplacedencoded(lingua.getforfrontendfromdb(dr["nome"].ToString()) + " " + strSovrapprezzo), dr["id"].ToString()));
                    }
                }

                // corriere
                {
                    DataTable dtCorrieri = simplestecommerce.corrieri.getenabledcarrier();
                    foreach (DataRow dr in dtCorrieri.Rows)
                    {
                        string strSovrapprezzo = "";
                        double sovrapprezzo;
                        sovrapprezzo = (double)dr["c_prezzo"];
                        if (sovrapprezzo != 0) strSovrapprezzo = " +" + currencies.tostrusercurrency(sovrapprezzo);
                        dlistcarrier.Items.Add(new ListItem(simplestecommerce.sicurezza.xss.getreplacedencoded(lingua.getforfrontendfromdb(dr["c_nome"].ToString()) + strSovrapprezzo), dr["c_id"].ToString()));
                    }
                }

                bindControls();
                showhidemandatoryfields();

            }



            

  

            
         
            
         
        
        }
        void Page_Load()
        {
            currentcart = (Cart)Session["Cart"];
            currentuser = currentcart.User;

            if ((int)Application["config_registrazione"] > 0 && currentuser.Anonimo)
            {
                Response.Redirect("login.aspx");
            }

            if (currentuser.Anonimo)
            {
                pHolderVuoiRegistrati.Visible = true;
            }



            if (!Page.IsPostBack)
            {
                dlistsubject.Items.Add(new ListItem(simplestecommerce.lingua.getforfrontendbypseudo(simplestecommerce.common.arrPseudoLegalSubject[0]), "0"));
                dlistsubject.Items.Add(new ListItem(simplestecommerce.lingua.getforfrontendbypseudo(simplestecommerce.common.arrPseudoLegalSubject[1]), "1"));
                dlistsubject.Items[0].Selected = true;

                DataTable dtRegioniAccettate = simplestecommerce.regioni.getAll();
                dlistregion.DataSource     = dtRegioniAccettate;
                dlistregion.DataTextField  = "r_nome";
                dlistregion.DataValueField = "r_id";
                dlistregion.DataBind();

                dlistspregion.DataSource     = dtRegioniAccettate;
                dlistspregion.DataTextField  = "r_nome";
                dlistspregion.DataValueField = "r_id";
                dlistspregion.DataBind();


                DataTable dt = simplestecommerce.modeofpayment.tableTipPagam;
                foreach (DataRow dr in dt.Rows)
                {
                    if ((int)dr["attivo"] == 1)
                    {
                        double sovrapprezzo;
                        string strSovrapprezzo = "";


                        sovrapprezzo = simplestecommerce.spedizione.getSovrapprezzo((int)dr["id"], currentcart.Subtotal);
                        if (sovrapprezzo != 0)
                        {
                            strSovrapprezzo = " +" + currencies.tostrusercurrency(sovrapprezzo);
                        }

                        dlistmodeofpayment.Items.Add(new ListItem(simplestecommerce.sicurezza.xss.getreplacedencoded(lingua.getforfrontendfromdb(dr["nome"].ToString()) + " " + strSovrapprezzo), dr["id"].ToString()));
                    }
                }

                // corriere
                {
                    DataTable dtCorrieri = simplestecommerce.corrieri.getenabledcarrier();
                    foreach (DataRow dr in dtCorrieri.Rows)
                    {
                        string strSovrapprezzo = "";
                        double sovrapprezzo;
                        sovrapprezzo = (double)dr["c_prezzo"];
                        if (sovrapprezzo != 0)
                        {
                            strSovrapprezzo = " +" + currencies.tostrusercurrency(sovrapprezzo);
                        }
                        dlistcarrier.Items.Add(new ListItem(simplestecommerce.sicurezza.xss.getreplacedencoded(lingua.getforfrontendfromdb(dr["c_nome"].ToString()) + strSovrapprezzo), dr["c_id"].ToString()));
                    }
                }

                bindControls();
                showhidemandatoryfields();
            }
        }
        void sendMail(simplestecommerce.Cart emailcart, int emailnewidcart)
        {
            simplestecommerce.User emailuser = emailcart.User;

            string body;
            string subject;
            string from;
            string to;

            subject = String.Format(lingua.getforfrontendbypseudo("cartconfirm.order.email.subject"), emailnewidcart, (string)Application["config_nomeSito"]);


            body = "<html>" +
                   "<head><style>" +
                   "body { font-family:Calibri, Tahoma; font-size:13px}" +
                   "td.headeruser {background-color:#6666ff; padding:3px; font-family:Calibri, Tahoma; font-size:13px; color:white}" +
                   "td.user {background-color:#a5cbe5; padding:3px; font-family:Calibri, Tahoma; font-size:13px}" +
                   "td.headercart {background-color:#6666ff; padding:3px; font-family:Calibri, Tahoma; font-size:13px; color:white}" +
                   "td.cartdark {background-color:#a5cbe5; padding:3px; font-family:Calibri, Tahoma; font-size:13px}" +
                   "td.cart {background-color:#b7d6eb; padding:3px; font-family:Calibri, Tahoma; font-size:13px}" +

                   "</style>" +
                   "</head>" +
                   "<body>";



            DataRow drmodeofpayment = simplestecommerce.tipiPagamento.getById(emailcart.Idmodeofpayment);

            body += simplestecommerce.lingua.getforfrontendfromdb((string)drmodeofpayment["messaggio"]);

            body += "<table cellpadding=1 cellspacing=2>";

            body += "<tr><td class=headeruser colspan=2>" + simplestecommerce.lingua.getforfrontendbypseudo("cartconfirm.order.email.body.label.billing.data") + "</td>";

            if (!emailuser.Anonimo)
            {
                body += "<tr><td class=user>USERNAME</td><td class=user>" + simplestecommerce.sicurezza.xss.getreplacedencoded(emailuser.Id) + "</td></tr>";
            }

            body += "<tr><td class=user width='150' >" + lingua.getforfrontendbypseudo("cartconfirm.order.email.body.legal.subject") + "</td><td class=user width='500'>" + simplestecommerce.sicurezza.xss.getreplacedencoded(lingua.getforfrontendbypseudo(simplestecommerce.common.arrPseudoLegalSubject[emailuser.Subject])) + "</td></tr>";

            body += "<tr><td class=user>" + lingua.getforfrontendbypseudo("cartconfirm.order.email.body.first.name") + "</td><td class=user>" + simplestecommerce.sicurezza.xss.getreplacedencoded(emailuser.Firstname) + "</td></tr>";

            body += "<tr><td class=user>" + lingua.getforfrontendbypseudo("cartconfirm.order.email.body.second.name") + "</td><td class=user>" + simplestecommerce.sicurezza.xss.getreplacedencoded(emailuser.Secondname) + "</td></tr>";

            if (emailuser.Subject == 1)
            {
                body += "<tr><td class=user>" + lingua.getforfrontendbypseudo("cartconfirm.order.email.body.name.of.firm") + "</td><td class=user> " + simplestecommerce.sicurezza.xss.getreplacedencoded(emailcart.User.Nameoffirm) + "</td></tr>";
            }

            body +=
                "<tr><td class=user>" + lingua.getforfrontendbypseudo("cartconfirm.order.email.body.email") + "</td><td class=user>" + simplestecommerce.sicurezza.xss.getreplacedencoded(emailuser.Email) + "</td></tr>" +
                "<tr><td class=user>" + lingua.getforfrontendbypseudo("cartconfirm.order.email.body.telephone") + "</td><td class=user>" + simplestecommerce.sicurezza.xss.getreplacedencoded(emailuser.Telephone) + "</td></tr>" +
                "<tr><td class=user>" + lingua.getforfrontendbypseudo("cartconfirm.order.email.body.fiscal.code") + "</td><td class=user>" + simplestecommerce.sicurezza.xss.getreplacedencoded(emailuser.Fiscalcode) + "</td></tr>" +
                "<tr><td class=user>" + lingua.getforfrontendbypseudo("cartconfirm.order.email.body.vat.number") + "</td><td class=user>" + simplestecommerce.sicurezza.xss.getreplacedencoded(emailuser.Vatnumber) + "</td></tr>" +
                "<tr><td class=user>" + lingua.getforfrontendbypseudo("cartconfirm.order.email.body.address") + "</td><td class=user>" + simplestecommerce.sicurezza.xss.getreplacedencoded(emailuser.Address) + "</td></tr>" +
                "<tr><td class=user>" + lingua.getforfrontendbypseudo("cartconfirm.order.email.body.postal.code") + "</td><td class=user>" + simplestecommerce.sicurezza.xss.getreplacedencoded(emailuser.Postalcode) + "</td></tr>" +
                "<tr><td class=user>" + lingua.getforfrontendbypseudo("cartconfirm.order.email.body.city") + "</td><td class=user>" + simplestecommerce.sicurezza.xss.getreplacedencoded(emailuser.City) + "</td></tr>" +
                "<tr><td class=user>" + lingua.getforfrontendbypseudo("cartconfirm.order.email.body.country") + "</td><td class=user>" + simplestecommerce.sicurezza.xss.getreplacedencoded(simplestecommerce.regioni.rowregionbyid(emailuser.Idregion)["r_nome"].ToString()) + "</td></tr>";

            body += "<tr><td class=headeruser colspan=2>" + simplestecommerce.lingua.getforfrontendbypseudo("cartconfirm.order.email.body.label.shipping.data") + "</td>" +
                    "<tr><td class=user>" + lingua.getforfrontendbypseudo("cartconfirm.order.email.body.shipping.first.name") + "</td><td class=user>" + simplestecommerce.sicurezza.xss.getreplacedencoded(emailuser.Spfirstname) + "</td></tr>" +
                    "<tr><td class=user>" + lingua.getforfrontendbypseudo("cartconfirm.order.email.body.shipping.second.name") + "</td><td class=user>" + simplestecommerce.sicurezza.xss.getreplacedencoded(emailuser.Spsecondname) + "</td></tr>" +
                    "<tr><td class=user>" + lingua.getforfrontendbypseudo("cartconfirm.order.email.body.shipping.address") + "</td><td class=user>" + simplestecommerce.sicurezza.xss.getreplacedencoded(emailuser.Spaddress) + "</td></tr>" +
                    "<tr><td class=user>" + lingua.getforfrontendbypseudo("cartconfirm.order.email.body.shipping.postal.code") + "</td><td class=user>" + simplestecommerce.sicurezza.xss.getreplacedencoded(emailuser.Sppostalcode) + "</td></tr>" +
                    "<tr><td class=user>" + lingua.getforfrontendbypseudo("cartconfirm.order.email.body.shipping.city") + "</td><td class=user>" + simplestecommerce.sicurezza.xss.getreplacedencoded(emailuser.Spcity) + "</td></tr>" +
                    "<tr><td class=user>" + lingua.getforfrontendbypseudo("cartconfirm.order.email.body.shipping.country") + "</td><td class=user>" + simplestecommerce.sicurezza.xss.getreplacedencoded(simplestecommerce.regioni.rowregionbyid(emailuser.Spidregion)["r_nome"].ToString()) + "</td></tr>";

            body += "<tr><td class=headeruser colspan=2>" + simplestecommerce.lingua.getforfrontendbypseudo("cartconfirm.order.email.body.label.final.info") + "</td>";

            body += "<tr><td class=user>" + lingua.getforfrontendbypseudo("cartconfirm.order.email.body.carrier") + "</td><td class=user>" + simplestecommerce.sicurezza.xss.getreplacedencoded(simplestecommerce.lingua.getforfrontendfromdb(simplestecommerce.corrieri.rowcarrierbyid(emailcart.Idcarrier)["c_nome"].ToString())) + "</td></tr>";

            body +=
                "<tr><td class=user>" + lingua.getforfrontendbypseudo("cartconfirm.order.email.body.mode.of.payment") + "</td><td class=user>" + simplestecommerce.sicurezza.xss.getreplacedencoded(lingua.getforfrontendfromdb(simplestecommerce.modeofpayment.nomeTipPagamById(emailcart.Idmodeofpayment))) + "</td></tr>" +
                "<tr><td class=user>" + lingua.getforfrontendbypseudo("cartconfirm.order.email.body.notes") + "</td><td class=user>" + simplestecommerce.sicurezza.xss.getreplacedencoded(emailcart.Note) + "</td></tr>";

            body += "</table>";

            body +=
                "<br><br>" +
                "<table cellspacing=2 cellpadding=1 >" +
                "<tr>" +
                "<td width=183 class=headercart><b>" + lingua.getforfrontendbypseudo("cartconfirm.order.email.body.cart.product.code") + "</b></td>" +
                "<td width=183 class=headercart><b>" + lingua.getforfrontendbypseudo("cartconfirm.order.email.body.cart.product.name") + "</b></td>" +
                "<td width=80 class=headercart><b>" + lingua.getforfrontendbypseudo("cartconfirm.order.email.body.cart.price") + "</b></td>" +
                "<td width=40 class=headercart><b>" + lingua.getforfrontendbypseudo("cartconfirm.order.email.body.cart.discount") + "</b></td>" +
                "<td width=40 class=headercart><b>" + lingua.getforfrontendbypseudo("cartconfirm.order.email.body.cart.quantity") + "</b></td>" +
                "<td width=80 class=headercart><b>" + lingua.getforfrontendbypseudo("cartconfirm.order.email.body.cart.amount") + "</b></td>" +
                "</tr>";


            foreach (simplestecommerce.cartItem ripCartItem in emailcart.lista)
            {
                body += "<tr>";

                //art  code
                body += "<td class=cart>" + simplestecommerce.sicurezza.xss.getreplacedencoded(ripCartItem.Articolo.Code) + "</td>";

                //art name
                string artname = simplestecommerce.sicurezza.xss.getreplacedencoded(simplestecommerce.lingua.getforfrontendfromdb(ripCartItem.Articolo.Name));
                foreach (simplestecommerce.Choosedvariation v in ripCartItem.Choosedvariations)
                {
                    artname += "<br>" + simplestecommerce.sicurezza.xss.getreplacedencoded(simplestecommerce.lingua.getforfrontendfromdb(v.Nome)) + "  " + simplestecommerce.sicurezza.xss.getreplacedencoded(simplestecommerce.lingua.getforfrontendfromdb(v.Choosedoption.Testo));
                }
                body += "<td class=cart>" + artname + "</td>";


                // price
                body += "<td class=cart>" + currencies.tostrusercurrency(ripCartItem.Articolo.Prezzobase + ripCartItem.Variationssum) + "</td>";
                body += "<td class=cart>" + Math.Round(ripCartItem.Totaldiscount, 2).ToString() + "%" + "</td>";
                body += "<td class=cart>" + simplestecommerce.sicurezza.xss.getreplacedencoded(ripCartItem.Quantita.ToString()) + "</td>";
                body += "<td class=cart>" + currencies.tostrusercurrency(ripCartItem.Finalprice * ripCartItem.Quantita) + "</td>";
            }

            body += "<tr>" +
                    "<td class=cartdark>" + lingua.getforfrontendbypseudo("cartconfirm.order.email.body.cart.subtotal") + "</td>" +
                    "<td class=cartdark>&nbsp;</td>" +
                    "<td class=cartdark>&nbsp;</td>" +
                    "<td class=cartdark>&nbsp;</td>" +
                    "<td  class=cartdark align=center><b>" + emailcart.getTotQuantita().ToString() + "</b></td>" +
                    "<td class=cartdark><b>" + currencies.tostrusercurrency(emailcart.Subtotal) + "</b></td>" +
                    "</tr>";

            if (emailcart.Coupononsubtotal > 0)
            {
                body +=
                    "<td class=cart>" + lingua.getforfrontendbypseudo("cartconfirm.order.email.body.cart.coupon.discount") + "</td>" +
                    "<td class=cart>&nbsp;</td>" +
                    "<td class=cart>&nbsp;</td>" +
                    "<td class=cart>&nbsp;</td>" +
                    "<td class=cart>&nbsp;</td>" +
                    "<td class=cart>" + currencies.tostrusercurrency(emailcart.Coupononsubtotal) + "</td>" +
                    "</tr>";
            }

            body +=
                "<td class=cart>" + simplestecommerce.lingua.getforfrontendbypseudo(simplestecommerce.common.arrtaxnameinpseudo[emailcart.Taxtype]) + "</td>" +
                "<td class=cart>&nbsp;</td>" +
                "<td class=cart>&nbsp;</td>" +
                "<td class=cart>&nbsp;</td>" +
                "<td class=cart>&nbsp;</td>" +
                "<td class=cart>" + currencies.tostrusercurrency(emailcart.Taxamount) + "</td>" +
                "</tr>";



            body +=
                "<td class=cart>" + lingua.getforfrontendbypseudo("cartconfirm.order.email.body.cart.label.shipping.costs.and.other") + "</td>" +
                "<td class=cart>&nbsp;</td>" +
                "<td class=cart>&nbsp;</td>" +
                "<td class=cart>&nbsp;</td>" +
                "<td class=cart>&nbsp;</td>" +
                "<td class=cart>" + currencies.tostrusercurrency(emailcart.Shippingcosts) + "</td>" +
                "</tr>";



            if ((bool)Application["config_applytaxonshipping"])
            {
                body +=
                    "<td class=cart>" + simplestecommerce.lingua.getforfrontendbypseudo(simplestecommerce.common.arrtaxnameinpseudo[emailcart.Taxtype]) + "&nbsp;" + lingua.getforfrontendbypseudo("cartconfirm.order.email.body.cart.label.(tax.on).shipping.costs.and.other") + "</td>" +
                    "<td class=cart>&nbsp;</td>" +
                    "<td class=cart>&nbsp;</td>" +
                    "<td class=cart>&nbsp;</td>" +
                    "<td class=cart>&nbsp;</td>" +
                    "<td class=cart>" + currencies.tostrusercurrency(emailcart.Taxontransportcosts) + "</td>" +
                    "</tr>";
            }

            if (emailcart.Couponaftertaxes > 0)
            {
                body +=
                    "<td class=cart>" + lingua.getforfrontendbypseudo("cartconfirm.order.email.body.cart.coupon.discount.after.taxes") + "</td>" +
                    "<td class=cart>&nbsp;</td>" +
                    "<td class=cart>&nbsp;</td>" +
                    "<td class=cart>&nbsp;</td>" +
                    "<td class=cart>&nbsp;</td>" +
                    "<td class=cart>" + currencies.tostrusercurrency(emailcart.Couponaftertaxes) + "</td>" +
                    "</tr>";
            }

            body +=
                "<td class=cartdark><b>" + lingua.getforfrontendbypseudo("cartconfirm.order.email.body.cart.total") + "</b></td>" +
                "<td class=cartdark>&nbsp;</td>" +
                "<td class=cartdark>&nbsp;</td>" +
                "<td class=cartdark>&nbsp;</td>" +
                "<td class=cartdark>&nbsp;</td>" +
                "<td class=cartdark><b>" + currencies.tostrusercurrency(emailcart.Tot) + "</b></td>" +
                "</tr>";


            body += "</table></body></html>";



            //  Response.Write(body);



            from = (string)Application["config_emailSito"];

            bool okNegoziante = true;

            // email al negoziante
            string eccezione1 = "";

            try
            {
                to = (string)Application["config_emailSito"];
                simplestecommerce.email.send(from, to, subject, body, true);
            }
            catch (Exception E)
            {
                okNegoziante = false;
                eccezione1   = E.ToString();
            }


            if (!okNegoziante)
            {
                lblEsito.Text +=
                    "<font color='red'>" +
                    String.Format(
                        lingua.getforfrontendbypseudo("cartconfirm.order.warning.problem.in.sending.order.email.to.merchant"),
                        eccezione1.ToString()
                        ) +
                    "</font>";
            }



            // email all'acquirente
            to = emailcart.User.Email;

            try
            {
                simplestecommerce.email.send(from, to, subject, body, true);
            }
            catch (Exception exc)
            {
            }
        }
        void Page_Load()
        {
            simplestecommerce.Cart currentcart = (simplestecommerce.Cart)Session["Cart"];
            simplestecommerce.User currentuser = currentcart.User;


            if ((int)Application["config_registrazione"] > 0 && currentuser.Anonimo)
            {
                Response.Redirect("~/shop/login.aspx");
            }



            if (currentuser.Firstname == null)
            {
                Response.Redirect("~/shop/cart.aspx");
            }
            if (currentcart.Idcarrier == 0)
            {
                Response.Redirect("~/shop/cart.aspx");
            }



            if (!Page.IsPostBack)
            {
                if (currentcart.isempty)
                {
                    lblEsito.Text = "<font color='red'>" + lingua.getforfrontendbypseudo("cartconfirm.warning.empty.cart") + "</font>";
                    return;
                }


                foreach (simplestecommerce.cartItem ci in currentcart.lista)
                {
                    //Response.Write("<br>-" + Cart.pseudoerravailability(ci.Articolo.Idart, ci.Quantita));
                    string err = simplestecommerce.lingua.getforfrontendbypseudo(Cart.pseudoerravailability(ci.Articolo.Idart, ci.Quantita));
                    if (err != "")
                    {
                        lblEsito.Text = err + "<br>" +
                                        simplestecommerce.lingua.getforfrontendbypseudo("cartconfirm.warning.some.products.in.cart.not.available.anymore");
                        return;
                    }
                }

                int newidcart;
                currentcart.save(out newidcart);

                // update stock **********************************************************************
                List <cartItem> lista = currentcart.lista;
                SqlConnection   cnn   = new SqlConnection((string)HttpContext.Current.Application["strcnn"]);
                cnn.Open();

                for (int a = 0; a < lista.Count; a++)
                {
                    int ripIdArt = lista[a].Articolo.Idart;
                    int ripQuant = lista[a].Quantita;

                    string     strSql;
                    SqlCommand cmd;

                    strSql = "UPDATE tarticoli SET art_stock = art_stock - @quantOrd" +
                             " WHERE art_id=@idart";
                    cmd = new SqlCommand(strSql, cnn);
                    cmd.Parameters.Add(new SqlParameter("@quantOrd", ripQuant));
                    cmd.Parameters.Add(new SqlParameter("@idArt", ripIdArt));
                    cmd.ExecuteNonQuery();
                }
                cnn.Close();

                // end updatestock **************************************************************************************


                sendMail(currentcart, newidcart);


                lblEsito.Text =
                    "<b>" +
                    String.Format(
                        lingua.getforfrontendbypseudo("cartconfirm.order.sent.with.number"),
                        newidcart
                        ) +
                    "</b>";

                if (currentcart.Idmodeofpayment == 4)
                {
                    // is paypal
                    pholderpaypal.Visible = true;

                    paypalbusiness = simplestecommerce.config.getCampoByApplication("config_emailpaypal").ToString();
                    paypalitemname =
                        String.Format(
                            simplestecommerce.lingua.getforfrontendbypseudo("cartconfirm.paypalform.itemname"),
                            newidcart.ToString()
                            );
                    paypalpamount = (Math.Round(currentcart.Tot, 2)).ToString().Replace(",", ".");

                    DataTable dtcurrencies      = simplestecommerce.currencies.getAvailable();
                    DataRow   rowcurrencymaster = dtcurrencies.Rows.Find((int)simplestecommerce.config.getCampoByApplication("config_idmastercurrency"));
                    if (rowcurrencymaster == null)
                    {
                        simplestecommerce.problema.redirect("master currency not found in table currencies");
                    }
                    paypalcurrencycode = rowcurrencymaster["nome"].ToString();
                }
                else
                {
                    // ripristinareeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee!!  Session["Cart"] = new simplestecommerce.Cart();
                }
            }
        }
        void Page_Load()
        {
            simplestecommerce.User Currentuser = ((simplestecommerce.Cart)Session["Cart"]).User;
            if (Currentuser.Anonimo)
            {
                Response.Redirect("~/shop/registrazione.aspx");
            }



            if (!Page.IsPostBack)
            {
                string id = Currentuser.Id;


                // prepare **********************************************************************************************************
                listaSoggetti.Items.Add(new ListItem(simplestecommerce.lingua.getforfrontendbypseudo(simplestecommerce.common.arrPseudoLegalSubject[0]), "0"));
                listaSoggetti.Items.Add(new ListItem(simplestecommerce.lingua.getforfrontendbypseudo(simplestecommerce.common.arrPseudoLegalSubject[1]), "1"));

                listaSoggetti.Items[0].Selected = true;

                DataTable dtRegioni = simplestecommerce.regioni.getAll();


                dlistregioni.DataSource     = dtRegioni;
                dlistregioni.DataTextField  = "r_nome";
                dlistregioni.DataValueField = "r_id";
                dlistregioni.DataBind();

                dlistspregion.DataSource     = dtRegioni;
                dlistspregion.DataTextField  = "r_nome";
                dlistspregion.DataValueField = "r_id";
                dlistspregion.DataBind();



                // fill fields *********************************************************************************************************
                SqlConnection cnn = new SqlConnection((string)HttpContext.Current.Application["strcnn"]);
                cnn.Open();

                string     strSql = "SELECT * FROM tutenti WHERE ut_id=@id AND ut_bloccato=0";
                SqlCommand cmd    = new SqlCommand(strSql, cnn);
                cmd.Parameters.Add(new SqlParameter("@id", id));
                SqlDataReader reader = cmd.ExecuteReader();
                if (!reader.Read())
                {
                    reader.Close(); cnn.Close(); simplestecommerce.problema.redirect("no such user in db", "registrazione.aspx");
                }

                listaSoggetti.SelectedValue = reader["ut_subject"].ToString();
                foreach (ListItem li in listaSoggetti.Items)
                {
                    li.Enabled = false;
                }


                textBoxNome.Text = simplestecommerce.sicurezza.xss.getreplacedencoded(reader["ut_firstname"].ToString());

                textBoxCognome.Text = simplestecommerce.sicurezza.xss.getreplacedencoded(reader["ut_secondname"].ToString());

                textBoxRagSoc.Text = simplestecommerce.sicurezza.xss.getreplacedencoded(reader["ut_nameoffirm"].ToString());

                textBoxIndirizzo.Text = simplestecommerce.sicurezza.xss.getreplacedencoded(reader["ut_address"].ToString());

                textBoxCap.Text = simplestecommerce.sicurezza.xss.getreplacedencoded(reader["ut_postalcode"].ToString());

                textBoxLocalita.Text = simplestecommerce.sicurezza.xss.getreplacedencoded(reader["ut_city"].ToString());

                dlistregioni.SelectedValue = reader["ut_idregion"].ToString();

                // shipping data

                tboxspfirstname.Text        = simplestecommerce.sicurezza.xss.getreplacedencoded(reader["ut_spfirstname"].ToString());
                tboxspsecondname.Text       = simplestecommerce.sicurezza.xss.getreplacedencoded(reader["ut_spsecondname"].ToString());
                tboxspaddress.Text          = simplestecommerce.sicurezza.xss.getreplacedencoded(reader["ut_spaddress"].ToString());
                tboxsppostalcode.Text       = simplestecommerce.sicurezza.xss.getreplacedencoded(reader["ut_sppostalcode"].ToString());
                tboxspcity.Text             = simplestecommerce.sicurezza.xss.getreplacedencoded(reader["ut_spcity"].ToString());
                dlistspregion.SelectedValue = reader["ut_spidregion"].ToString();

                // end shipping data


                lblEmail.Text = simplestecommerce.sicurezza.xss.getreplacedencoded(reader["ut_email"].ToString());

                textBoxTelefono.Text = simplestecommerce.sicurezza.xss.getreplacedencoded(reader["ut_telephone"].ToString());

                textBoxCodFisc.Text = simplestecommerce.sicurezza.xss.getreplacedencoded(reader["ut_fiscalcode"].ToString());

                tboxvatnumber.Text = simplestecommerce.sicurezza.xss.getreplacedencoded(reader["ut_vatnumber"].ToString());

                cBoxNewsletter.Checked = (bool)reader["ut_newsletter"];

                reader.Close();
                cnn.Close();
            }


            // show / hide *******************************************************************
            buttUpdate.Visible  = true;
            pHolderPass.Visible = true;


            // show hide vat number;
            int soggetto = int.Parse(listaSoggetti.SelectedValue);

            if (soggetto == 1)
            {
                int           result;
                SqlConnection cnn = new SqlConnection((string)HttpContext.Current.Application["strcnn"]);
                cnn.Open();
                SqlCommand cmd;
                cmd             = new SqlCommand("gettaxtype", cnn);
                cmd.CommandType = CommandType.StoredProcedure;
                cmd.Parameters.Add(new SqlParameter("@idregionbilling", int.Parse(dlistregioni.SelectedValue)));
                cmd.Parameters.Add(new SqlParameter("@idmerchantregion", simplestecommerce.config.getCampoByApplication("config_idmerchantregion")));

                SqlDataReader reader = cmd.ExecuteReader(CommandBehavior.CloseConnection);
                reader.Read();
                result = (int)reader[0];
                reader.Close();
                cnn.Close();

                if (result == 1)
                {
                    pholdervatnumber.Visible = true;
                }
                else
                {
                    pholdervatnumber.Visible = false;
                }
            }
            else
            {
                pholdervatnumber.Visible = false;
            }


            // show hide fiscal code
            if (pholdervatnumber.Visible)
            {
                pHolderCodiceFiscale.Visible = true;
            }
            else
            {
                if ((bool)simplestecommerce.config.getCampoByApplication("config_askalwaysforfiscalcode"))
                {
                    pHolderCodiceFiscale.Visible = true;
                }
                else
                {
                    pHolderCodiceFiscale.Visible = false;
                }
            }



            //  show hide name of firm
            if (soggetto == 1)
            {
                pHolderRagSoc.Visible = true;
            }
            else
            {
                pHolderRagSoc.Visible = false;
            }



            // show hide telefono
            if ((bool)simplestecommerce.config.getCampoByApplication("config_askfortelephone"))
            {
                pHolderTelefono.Visible = true;
            }
            else
            {
                pHolderTelefono.Visible = false;
            }
        }