示例#1
0
    protected void btn_Conferma(object sender, EventArgs e)
    {
        DataTable table = ViewState["CurrentTable"] as DataTable;

        try
        {
            help.connetti();
            help.assegnaComando("INSERT INTO Vendite(Acquirente,Totale,Data) VALUES(" + ID_U + ",'" + tot + "','" + System.DateTime.Today.ToShortDateString() + "')");
            help.eseguicomando();
            help.disconnetti();
            int i = 0;
            foreach (DataRow row in table.Rows)
            {
                help.connetti();
                help.assegnaComando("INSERT INTO Dettagli_Vendita VALUES((SELECT MAX(ID_Vendita) FROM Vendite),'" + articoli[i, 0] + "'," + articoli[i, 1] + ",'" + articoli[i, 2] + "','" + articoli[i, 3] + "')");
                help.eseguicomando();
                help.disconnetti();
                i++;
            }
            help.connetti();
            help.assegnaComando("DELETE FROM Carrello WHERE Cod_Utente=" + ID_U + " AND Ordinato='si'");
            help.eseguicomando();
            help.disconnetti();
            MessageBox.Show("Ordine confermato");
        }
        catch (Exception ex)
        {
            help.disconnetti();
            Response.Write(ex.ToString());
        }
    }
示例#2
0
    protected void btnOrdina_Click(object sender, EventArgs e)
    {
        try
        {
            articoli[] listaarticoli = (articoli[])Session["listaarticoli"];
            foreach (articoli art in listaarticoli)
            {
                if (art.GetQta() > 0)
                {
                    help.connetti();
                    help.assegnaComando("INSERT INTO Carrello VALUES(" + Session["Utente"].ToString()
                                        + ",'" + art.GetCodice()
                                        + "','" + art.GetTaglia()
                                        + "'," + art.GetQta()
                                        + ",'" + art.GetPrezzo() + "','si')");
                    help.eseguicomando();
                    help.disconnetti();
                    help.connetti();
                    help.assegnaComando("UPDATE Taglie_Quantità SET QUantità_Magazzino=Quantità_Magazzino-" + art.GetQta() + " WHERE Cod_Prod='" +
                                        art.GetCodice() + "' AND Taglie='" + art.GetTaglia() + "'");
                    help.eseguicomando();
                    help.disconnetti();
                }
            }

            /* SmtpClient client = new SmtpClient("smtp.gmail.com", 587);
             * client.EnableSsl = true;
             * client.UseDefaultCredentials = false;
             * client.Timeout = 1000;
             * client.DeliveryMethod = SmtpDeliveryMethod.Network;
             * client.Credentials = new NetworkCredential("*****@*****.**", "P4ssw0rd");
             *
             * MailMessage email = new MailMessage();
             *
             * email.To.Add("*****@*****.**");
             * help.connetti();
             * help.assegnaComando("SELECT Email,Nome,Cognome,Ragione_Sociale FROM Utenti WHERE ID_Utente=" + Session["Utente"].ToString());
             * rs = help.estraiDati();
             * rs.Read();
             * string Nome = rs["Nome"].ToString();
             * string Cognome = rs["Cognome"].ToString();
             * string rag_soc = rs["Ragione_Sociale"].ToString();
             * string mail = rs["Email"].ToString();
             * help.disconnetti();
             * email.From = new MailAddress(mail);
             * email.Subject = "Nuovo ordine da psm.promostile.it";
             * email.Body = "Ordine ricevuto da: " + Nome + " " + Cognome + " per conto di " + rag_soc + ", visualizzalo nel pannello di controllo di psm.promostile.it !";
             * client.Send(email);*/
            MessageBox.Show("Ordine inviato");
            Response.AppendHeader("Refresh", "0;url=Articoli.aspx");
        }
        catch
        {
            MessageBox.Show("C'è stato un errore nell'invio dell'ordine");
        }
    }
示例#3
0
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            help.connetti();
            help.assegnaComando("DELETE FROM Appoggio_Campagna");
            help.eseguicomando();
            help.disconnetti();
            drpArticoli.Items.Add("------");
            help.connetti();
            help.assegnaComando("SELECT DISTINCT(Codice) FROM Articoli");
            rs = help.estraiDati();
            while (rs.Read())
            {
                drpArticoli.Items.Add(rs["Codice"].ToString());
            }
            help.disconnetti();

            drpDeal.Items.Add("------");
            help.connetti();
            help.assegnaComando("SELECT DISTINCT(Deal) FROM Deal");
            rs = help.estraiDati();
            while (rs.Read())
            {
                drpDeal.Items.Add(rs["Deal"].ToString());
            }

            help.disconnetti();
        }
    }
示例#4
0
    protected void btnConferma_Click(object sender, EventArgs e)
    {
        int num;

        if (int.TryParse(txtQta.Text, out num))
        {
            help.connetti();
            help.assegnaComando("UPDATE Dettagli_Campagna SET Quantità=Quantità-" + txtQta.Text.Trim() + " WHERE cod_Articolo ='" + lblCod.Text + "' AND Cod_Campagna=" + Session["Campagna"].ToString() +
                                " AND Taglia = '" + drpTaglie.SelectedValue + "'");
            help.eseguicomando();
            help.disconnetti();
            lblQta.Text = Convert.ToString(int.Parse(lblQta.Text) - int.Parse(txtQta.Text));
            txtQta.Text = "0";
        }
    }
示例#5
0
    protected void Button4_Click(object sender, EventArgs e)
    {
        try
        {
            int    app   = 0;
            string email = txtEmailReg.Text;
            string psw   = txtPswReg.Text;
            help.connetti();
            help.assegnaComando("SELECT MAX (ID_Utente) AS massimo FROM Utenti");
            rs = help.estraiDati();
            rs.Read();
            app = int.Parse(rs["massimo"].ToString()) + 1;
            help.disconnetti();

            help.connetti();
            help.assegnaComando("INSERT INTO Utenti VALUES('" + app + "','" + email + "','" + psw + "')");
            help.eseguicomando();
            help.disconnetti();
            Response.Redirect("Default.aspx");
            Session["Utente"] = app.ToString();
        }
        catch
        {
            lblErr0.Text = "Compila tutti i campi";
        }
    }
示例#6
0
    protected void btnSave_Click(object sender, EventArgs e)
    {
        try
        {
            SetRowData();
            DataTable table = ViewState["CurrentTable"] as DataTable;

            if (table != null)
            {
                foreach (DataRow row in table.Rows)
                {
                    string[] qtaArray;
                    string[] taglieArray;
                    string   Codice      = row.ItemArray[1] as string;
                    string   Descrizione = row.ItemArray[2] as string;
                    string   Prezzo      = row.ItemArray[3] as string;
                    string   Qta         = row.ItemArray[4] as string;
                    string   Marca       = row.ItemArray[5] as string;
                    string   Taglie      = row.ItemArray[6] as string;
                    string   Immagine    = row.ItemArray[7] as string;

                    qtaArray    = Qta.Split(',');
                    taglieArray = Taglie.Split(',');

                    help.connetti();
                    help.assegnaComando("INSERT INTO Prodotti(Codice,Descrizione,Prezzo,Marca,Immagine) VALUES('" + Codice + "','" + Descrizione + "'," + Prezzo + ",'" + Immagine + "')");
                    help.eseguicomando();
                    help.disconnetti();

                    for (int i = 0; i <= qtaArray.Length; i++)
                    {
                        help.connetti();
                        help.assegnaComando("INSERT INTO Taglie(Cod_Prod,Qta,Taglia) VALUES('" + Codice + "','" + qtaArray[i] + "','" + taglieArray[i] + "'");
                        help.eseguicomando();
                        help.disconnetti();
                    }
                }
                Response.Redirect(Request.Url.AbsoluteUri);
            }
        }
        catch (Exception ex)
        {
            MessageBox.Show(ex.Message);
        }
    }
示例#7
0
    protected void Button1_Click(object sender, EventArgs e)
    {
        try
        {
            bool   presente = false;
            string nome     = txtNome.Text;
            string cognome  = txtCognome.Text;
            string email    = txtEmail.Text;
            string psw      = txtPass.Text;
            string codfisc  = txtCodFisc.Text;
            string piva     = txtIva.Text;
            string ind      = txtIndirizzo.Text;
            string ragsoc   = txtRagSoc.Text;
            string numtel   = txtNum.Text;

            if (nome.Trim() != string.Empty ||
                cognome.Trim() != string.Empty ||
                email.Trim() != string.Empty ||
                psw.Trim() != string.Empty ||
                codfisc.Trim() != string.Empty ||
                piva.Trim() != string.Empty ||
                ind.Trim() != string.Empty ||
                ragsoc.Trim() != string.Empty ||
                numtel.Trim() != string.Empty)
            {
                help.connetti();
                help.assegnaComando("SELECT Email FROM Utenti");
                rs = help.estraiDati();
                while (rs.Read() && presente == false)
                {
                    if (rs["Email"].ToString() == email)
                    {
                        lblErr.Text = "Email già presente";
                        presente    = true;
                    }
                }
                help.disconnetti();
                if (!presente)
                {
                    help.connetti();
                    help.assegnaComando("INSERT INTO Utenti(Nome,Cognome,Email,RagSociale,PartitaIva,Codfisc,IndFatturazione,NumTelefono,Psw)" +
                                        " VALUES('" + nome + "','" + cognome + "','" + email + "','" + ragsoc + "','" + piva + "','" + codfisc + "','" + ind + "','" + numtel + "','" + System.Web.Security.FormsAuthentication.HashPasswordForStoringInConfigFile(psw, "md5") + "')");
                    help.eseguicomando();
                    help.disconnetti();
                    MessageBox.Show("operazione completata");
                }
            }
            else
            {
                lblErr.Text = "Compila tutti i campi";
            }
        }
        catch (Exception ex)
        {
            Response.Write(ex.ToString());
        }
    }
示例#8
0
    protected void GridView1_RowCommand(object sender, GridViewCommandEventArgs e)
    {
        int         id  = Convert.ToInt32(e.CommandArgument);
        GridViewRow row = GridView1.Rows[id];

        help.connetti();
        help.assegnaComando("DELETE FROM Utenti WHERE Nome='" + row.Cells[0].Text + "' AND Cognome='" + row.Cells[1].Text + "' AND Ragione_Sociale='" + row.Cells[2].Text + "'");
        help.eseguicomando();
        help.disconnetti();
        tabella();
    }
示例#9
0
    public void tabella()
    {
        help.connetti();
        help.assegnaComando("CREATE VIEW Vista AS SELECT Immagine,Codice,Marca,Descrizione,Categoria,Colore,Prezzo_Cartellino,Prezzo_Vendita,SUM(Quantità_Magazzino) AS Somma FROM Articoli,Taglie_Quantità " +
                            "WHERE Codice=Cod_Prod GROUP BY Immagine,Codice,Marca,Descrizione,Categoria,Colore,Prezzo_Cartellino,Prezzo_Vendita");
        help.eseguicomando();
        help.disconnetti();

        help.connetti();
        help.assegnaComando("SELECT * " +
                            "FROM Vista ORDER BY Codice");
        rs = help.estraiDati();
        DataTable dt = new DataTable();

        dt.Columns.AddRange(new DataColumn[12]
        {
            new DataColumn("Immagine"),
            new DataColumn("Codice"),
            new DataColumn("Marca"),
            new DataColumn("Descrizione"),
            new DataColumn("Categoria"),
            new DataColumn("Colore"),
            new DataColumn("Prezzo_Cartellino"),
            new DataColumn("Prezzo_Vendita"),
            new DataColumn("Quantità_Campagne"),
            new DataColumn("QtaMag"),
            new DataColumn("prova"),
            new DataColumn("Modifica")
        });

        while (rs.Read())
        {
            string img = "";
            if (rs["Immagine"].ToString().Substring(0, 4).ToLower() != "http")
            {
                img = "~/Immagini/" + rs["Immagine"];
            }
            else
            {
                img = rs["Immagine"].ToString();
            }
            dt.Rows.Add(ResolveUrl(img),
                        rs["Codice"].ToString(),
                        rs["Marca"].ToString(),
                        rs["Descrizione"].ToString(),
                        rs["Categoria"].ToString(),
                        rs["Colore"].ToString(),
                        rs["Prezzo_Cartellino"].ToString() + " €",
                        rs["Prezzo_Vendita"].ToString() + " €",
                        rs["Somma"].ToString(), rs["Somma"].ToString());
        }
        ViewState["tabella"]   = dt;
        grdArticoli.DataSource = dt;
        grdArticoli.DataBind();
        help.disconnetti();
        help.connetti();
        help.assegnaComando("DROP VIEW Vista");
        help.eseguicomando();
        help.disconnetti();
    }
示例#10
0
 protected void Button1_Click(object sender, EventArgs e)
 {
     help.connetti();
     help.assegnaComando("DELETE FROM Appoggio_Campagna");
     help.eseguicomando();
     help.disconnetti();
     help.connetti();
     help.assegnaComando("DELETE FROM Carrello");
     help.eseguicomando();
     help.disconnetti();
     help.connetti();
     help.assegnaComando("DELETE FROM Taglie_Quantità");
     help.eseguicomando();
     help.disconnetti();
     help.connetti();
     help.assegnaComando("DELETE FROM Vendite");
     help.eseguicomando();
     help.disconnetti();
     help.connetti();
     help.assegnaComando("DELETE FROM Articoli");
     help.eseguicomando();
     help.disconnetti();
     help.connetti();
     help.assegnaComando("DELETE FROM Campagne");
     help.eseguicomando();
     help.disconnetti();
     help.connetti();
     help.assegnaComando("DELETE FROM Dettagli_Campagna");
     help.eseguicomando();
     help.disconnetti();
     help.connetti();
     help.assegnaComando("DELETE FROM Dettagli_Vendita");
     help.eseguicomando();
     help.disconnetti();
     Response.Redirect("Login.aspx");
 }
示例#11
0
    protected void Button1_Click(object sender, EventArgs e)
    {
        try
        {
            string prodotto = Session["Prodotto"].ToString();
            string qta      = Session["qta"].ToString();

            int nuovaQta;
            help.connetti();
            help.assegnaComando("SELECT Quantità FROM Prodotti WHERE ID_Prodotto='" + prodotto + "'");
            rs = help.estraiDati();
            rs.Read();
            nuovaQta = int.Parse(rs["Quantità"].ToString()) - int.Parse(qta);
            help.disconnetti();

            help.connetti();
            help.assegnaComando("UPDATE Prodotti SET Quantità = '" + nuovaQta + "' WHERE ID_Prodotto='" + prodotto + "'");
            help.eseguicomando();
            help.disconnetti();

            help.connetti();
            help.assegnaComando("SELECT Prezzo FROM Prodotti WHERE ID_Prodotto='" + prodotto + "'");
            rs = help.estraiDati();
            rs.Read();
            int spesatot = int.Parse(rs["Prezzo"].ToString()) * int.Parse(qta);
            help.disconnetti();

            string oggi = DateTime.Today.ToString();
            help.connetti();
            help.assegnaComando("SELECT Nome FROM Prodotti WHERE ID_Prodotto='" + prodotto + "'");
            rs = help.estraiDati();
            rs.Read();
            string nome  = rs["Nome"].ToString();
            string descr = "Acquisto di " + qta + " " + nome;
            help.disconnetti();

            help.connetti();
            help.assegnaComando("INSERT INTO Acquisti(Spesatot,DataAcquisto,Descr,Cod_Utente) VALUES(" + spesatot + ",#" + oggi + "#,'" + descr + "','" + Session["Utente"].ToString() + "')");
            help.eseguicomando();
            help.disconnetti();
            if (DropDownList1.Text == "")
            {
                string nomecognome = TxtEmail.Text;
                string indirizzo   = TxtIndirizzo.Text;
                string città       = txtCittà.Text;
                string messaggio   = txtMsg.Text;
                string utente      = Session["Utente"].ToString();
                help.connetti();
                help.assegnaComando("INSERT INTO Destinatario (CognomeNome,Indirizzo,Città,Messaggio,Cod_Utente) VALUES ('" + nomecognome + "','" + indirizzo + "','" + città + "','" + messaggio + "','" + utente + "')");
                help.eseguicomando();
                help.disconnetti();
                Session["Grazie"] = "Grazie";
                Response.Redirect("Grazie.aspx");
            }
            else
            {
                Session["Grazie"] = "Grazie";
                Response.Redirect("Grazie.aspx");
            }
        }
        catch
        {
            Response.Write("Qualcosa non va");
        }
    }
示例#12
0
    protected void btn_Acquista(object sender, EventArgs e)
    {
        if (txtColore.Text != string.Empty)
        {
            help.connetti();
            help.assegnaComando("UPDATE Articoli SET Colore='" + txtColore.Text + "' WHERE Codice='" + codice + "'");
            help.eseguicomando();
            help.disconnetti();
        }
        if (txtCat.Text != string.Empty)
        {
            help.connetti();
            help.assegnaComando("UPDATE Articoli SET Categoria='" + txtCat.Text + "' WHERE Codice='" + codice + "'");
            help.eseguicomando();
            help.disconnetti();
        }
        if (txtCod.Text != string.Empty)
        {
            help.connetti();
            help.assegnaComando("UPDATE Articoli SET Codice='" + txtCod.Text + "' WHERE Codice='" + codice + "'");
            help.eseguicomando();
            help.disconnetti();
            help.connetti();
            help.assegnaComando("UPDATE Taglie_Quantità SET cod_Prod='" + txtCod.Text + "' WHERE Cod_Prod='" + codice + "'");
            help.eseguicomando();
            help.disconnetti();
        }
        if (txtDesc.Text != string.Empty)
        {
            help.connetti();
            help.assegnaComando("UPDATE Articoli SET Descrizione='" + txtDesc.Text + "' WHERE Codice='" + codice + "'");
            help.eseguicomando();
            help.disconnetti();
        }
        if (txtMarca.Text != string.Empty)
        {
            help.connetti();
            help.assegnaComando("UPDATE Articoli SET Marca='" + txtMarca.Text + "' WHERE Codice='" + codice + "'");
            help.eseguicomando();
            help.disconnetti();
        }
        if (txtPrezCart.Text != string.Empty)
        {
            help.connetti();
            help.assegnaComando("UPDATE Articoli SET Prezzo_Cartellino='" + txtPrezCart.Text + "' WHERE Codice='" + codice + "'");
            help.eseguicomando();
            help.disconnetti();
        }
        if (txtPrezVen.Text != string.Empty)
        {
            help.connetti();
            help.assegnaComando("UPDATE Articoli SET Prezzo_Vendita='" + txtPrezVen.Text + "' WHERE Codice='" + codice + "'");
            help.eseguicomando();
            help.disconnetti();
        }
        if (txtNuovaTagliaSped.Text != "Nuova taglia spedizione")
        {
            help.connetti();
            help.assegnaComando("UPDATE Articoli SET Taglia_Sped='" + txtNuovaTagliaSped.Text + "' WHERE Codice='" + codice + "'");
            help.eseguicomando();
            help.disconnetti();
        }
        else
        {
            if (drpTagliaSpedizione.SelectedValue != string.Empty)
            {
                help.connetti();
                help.assegnaComando("UPDATE Articoli SET Taglia_Sped='" + drpTagliaSpedizione.SelectedValue + "' WHERE Codice='" + codice + "'");
                help.eseguicomando();
                help.disconnetti();
            }
        }
        if (txtNuovoPrdSped.Text != "Nuovo prodotto spedizione")
        {
            help.connetti();
            help.assegnaComando("UPDATE Articoli SET Prod_Sped='" + txtNuovoPrdSped.Text + "' WHERE Codice='" + codice + "'");
            help.eseguicomando();
            help.disconnetti();
        }
        else
        {
            if (drpProdSPedizione.SelectedValue != string.Empty)
            {
                help.connetti();
                help.assegnaComando("UPDATE Articoli SET Prod_Sped='" + drpProdSPedizione.SelectedValue + "' WHERE Codice='" + codice + "'");
                help.eseguicomando();
                help.disconnetti();
            }
        }
        if (flpImmagine.HasFile)
        {
            string[] exten = { ".jpg", ".png", ".gif", ".jpeg" };

            string fileExten = flpImmagine.FileName.Substring(flpImmagine.FileName.IndexOf('.')).ToLower();

            if (flpImmagine.HasFile)
            {
                for (int i = 0; i < exten.Length - 1; i++)
                {
                    if (exten[i] == fileExten)
                    {
                        flpImmagine.PostedFile.SaveAs(Server.MapPath("~/Immagini/" + flpImmagine.FileName));
                        help.connetti();
                        help.assegnaComando("UPDATE Articoli SET Immagine='" + flpImmagine.FileName + "' WHERE ID_Articolo='" + Session["ID_Articolo"].ToString() + "'");
                        help.eseguicomando();
                        help.disconnetti();
                    }
                }
            }
        }
        if (drpTaglie.SelectedValue != string.Empty)
        {
            if (txtQtaMag.Text != string.Empty)
            {
                help.connetti();
                help.assegnaComando("UPDATE Taglie_Quantità SET Quantità_Magazzino=" + txtQtaMag.Text + " WHERE Cod_Prod='" + codice + "' AND Taglie='" + drpTaglie.SelectedValue + "'");
                help.eseguicomando();
                help.disconnetti();
            }
        }
        else
        {
            if (txtTaglie.Text != string.Empty)
            {
                string[] nuoveTaglie = txtTaglie.Text.Split(',');
                string[] nuoveQta    = txtQtaMag.Text.Split(',');
                if (nuoveQta.Length == nuoveTaglie.Length)
                {
                    for (int i = 0; i < nuoveTaglie.Length; i++)
                    {
                        help.connetti();
                        help.assegnaComando("INSERT INTO Taglie_Quantità VALUES('" + codice + "','" + nuoveTaglie[i] + "'," + nuoveQta[i] + ")");
                        help.eseguicomando();
                        help.disconnetti();
                    }
                }
                else
                {
                    MessageBox.Show("Taglie e quantità non corrispondono");
                }
            }
        }
        MessageBox.Show("Modifiche effettuate");
        Response.AppendHeader("Refresh", "1;url=Default.aspx");
    }
示例#13
0
    protected void btn_Salva(object sender, EventArgs e)
    {
        string prodSped   = "";
        string tagliaSped = "";

        if (drpProdSPedizione.SelectedValue == "Seleziona una taglia" || txtNuovoPrdSped.Text == "Nuovo prodotto spedizione")
        {
            if (drpProdSPedizione.SelectedValue != "Seleziona una taglia")
            {
                prodSped = drpProdSPedizione.SelectedValue;
            }
            else
            {
                if (txtNuovoPrdSped.Text != "Nuova taglia spedizione")
                {
                    prodSped = txtNuovoPrdSped.Text;
                }
                else
                {
                    prdsped = false;
                }
            }
        }
        if (drpTagliaSpedizione.SelectedValue == "Seleziona una taglia" || txtNuovaTagliaSped.Text == "Nuova taglia spedizione")
        {
            if (drpTagliaSpedizione.SelectedValue != "Seleziona una taglia")
            {
                tagliaSped = drpTagliaSpedizione.SelectedValue;
            }
            else
            {
                if (txtNuovaTagliaSped.Text != "Nuova taglia spedizione")
                {
                    tagliaSped = txtNuovaTagliaSped.Text;
                }
                else
                {
                    tagliasped = false;
                }
            }
        }

        if (txtCodice.Text == string.Empty ||
            txtCat.Text == string.Empty ||
            txtColore.Text == string.Empty ||
            txtDescr.Text == string.Empty ||
            txtMarca.Text == string.Empty ||
            txtPrezzoCartellino.Text == string.Empty ||
            txtPrezzoVenita.Text == string.Empty ||
            txtQta.Text == string.Empty ||
            txtTaglie.Text == string.Empty ||
            !prdsped ||
            !tagliasped ||
            !flpImmagine.HasFile)
        {
            MessageBox.Show("Compilare tutti i campi!");
        }
        else
        {
            continua = true;
        }

        try
        {
            string[] exten = { ".jpg", ".png", ".gif", ".jpeg" };

            string fileExten = flpImmagine.FileName.Substring(flpImmagine.FileName.IndexOf('.')).ToLower();

            bool fileOK = false;

            if (flpImmagine.HasFile)
            {
                for (int i = 0; i < exten.Length - 1; i++)
                {
                    if (exten[i] == fileExten)
                    {
                        fileOK = true;
                    }
                }
            }

            if (fileOK && continua)
            {
                string[] taglie = txtTaglie.Text.Split(',');
                string[] qta    = txtQta.Text.Split(',');
                help.connetti();
                help.assegnaComando("INSERT INTO Articoli (Codice,Prezzo_Cartellino,Prezzo_Vendita,Categoria,Colore,Marca,Descrizione,Taglia_Sped,Prod_Sped,Immagine)" +
                                    " VALUES ('" + txtCodice.Text + "','"
                                    + txtPrezzoCartellino.Text + "','"
                                    + txtPrezzoVenita.Text + "','"
                                    + txtCat.Text + "','"
                                    + txtColore.Text + "','"
                                    + txtMarca.Text + "','"
                                    + txtDescr.Text + "','"
                                    + tagliaSped + "','"
                                    + prodSped + "','"
                                    + flpImmagine.FileName + "')");
                help.eseguicomando();
                help.disconnetti();
                for (int i = 0; i < taglie.Length; i++)
                {
                    help.connetti();
                    help.assegnaComando("INSERT INTO taglie_quantità VALUES ('" + txtCodice.Text + "','" + taglie[i].ToString() + "'," + qta[i].ToString() + ")");
                    help.eseguicomando();
                    help.disconnetti();
                }

                flpImmagine.PostedFile.SaveAs(Server.MapPath("~/Immagini/" + flpImmagine.FileName));
                MessageBox.Show("Prodotto caricato correttamenete");
                Response.AppendHeader("Refresh", "1;url=AggiungiArticoli.aspx");
            }
        }
        catch (Exception ex)
        {
            Response.Write(ex.ToString());
        }
    }
示例#14
0
    protected void GridView1_RowCommand(object sender, GridViewCommandEventArgs e)
    {
        double      prezzotot = 0;
        int         qtatot    = 0;
        int         id        = Convert.ToInt32(e.CommandArgument);
        GridViewRow row       = GridView1.Rows[id];

        if (e.CommandName == "Elimina")
        {
            help.connetti();
            help.assegnaComando("DELETE FROM Dettagli_Vendita WHERE Codice_Vendita=" + ID_Vendita[id]);
            help.eseguicomando();
            help.disconnetti();
            help.connetti();
            help.assegnaComando("DELETE FROM Vendite WHERE ID_Vendita=" + ID_Vendita[id]);
            help.eseguicomando();
            help.disconnetti();
            tabella();
        }
        else
        {
            help.connetti();
            help.assegnaComando("SELECT * FROM Dettagli_Vendita,Articoli WHERE Codice_Vendita=" + ID_Vendita[id] + " AND Cod_Articolo=Codice");
            rs = help.estraiDati();
            string html = "<style>" +
                          "#customers {" +
                          "font - family: \"Trebuchet MS\", Arial, Helvetica, sans - serif;" +
                          "border - collapse: collapse;" +
                          "width: 100 %;" +
                          "}" +

                          "#customers td, #customers th {" +
                          "border: 1px solid #ddd;" +
                          "padding: 8px;" +
                          "}" +

                          "#customers tr:nth-child(even){background-color: #f2f2f2;}" +

                          "# customers tr:hover {background-color: #ddd;}" +

                          "# customers th {" +
                          "padding-top: 12px;" +
                          "padding-bottom: 12px;" +
                          "text-align: left;" +
                          "background-color: #4CAF50;" +
                          "color: white;" +
                          "}" +
                          "</style>" + "<p  style=\"text-align:center; margin-top:2%; margin-bottom:2%; font-size:40px\">PSM.IT</p></br><table id=\"customers\" style=\"margin-top:3%\"><tr>";
            html += "<th>Codice articolo</th><th>Descrizione</th><th>Colore</th><th>Taglia</th><th>Quantità</th><th>Prezzo</th>";
            html += "</tr>";
            while (rs.Read())
            {
                html      += "<tr>";
                html      += "<td>" + rs["Codice"].ToString() + "</td>";
                html      += "<td>" + rs["Descrizione"].ToString() + "</td>";
                html      += "<td>" + rs["Colore"].ToString() + "</td>";
                html      += "<td>" + rs["Taglia"].ToString() + "</td>";
                html      += "<td>" + rs["Quantità"].ToString() + "</td>";
                html      += "<td>" + rs["Prezzo_Vendita"].ToString() + " €</td>";
                html      += "</tr>";
                prezzotot += double.Parse(rs["Prezzo_Vendita"].ToString()) * int.Parse(rs["Quantità"].ToString());
                qtatot    += int.Parse(rs["Quantità"].ToString());
            }
            html += "</table>";
            html += "<p style=\"text-align:right\">Quantità aticoli " + qtatot + " &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Prezzo totale " + prezzotot + " €</p>";
            PdfDocument pdf = PdfGenerator.GeneratePdf(html, PageSize.A4);
            pdf.Save(Server.MapPath("~/App_Data/ReportHtml/Report.pdf"));
            Response.ContentType = "application/octet-stream";
            Response.AppendHeader("Content-Disposition", "attachment;filename=Fattura " + ID_Vendita[id] + " per " + row.Cells[0].Text + ".pdf");
            Response.TransmitFile(Server.MapPath("~/App_Data/ReportHtml/Report.pdf"));
            Response.End();
            System.IO.File.Delete("~/App_Data/ReportHtml/Report.pdf");
        }
    }
示例#15
0
    protected void Button1_Click(object sender, EventArgs e)
    {
        try
        {
            bool   presente = false;
            string nome     = txtNome.Text;
            string cognome  = txtCognome.Text;
            string email    = txtEmail.Text;
            string psw      = txtPass.Text;
            string codfisc  = txtCodF.Text;
            string piva     = txtIva.Text;
            string ind      = txtIndirizzo.Text;
            string ragsoc   = txtRagSoc.Text;
            string numtel   = txtNum.Text;

            if (nome != string.Empty &&
                cognome != string.Empty &&
                email != string.Empty &&
                psw != string.Empty &&
                codfisc != string.Empty &&
                piva != string.Empty &&
                ind != string.Empty &&
                ragsoc != string.Empty &&
                numtel != string.Empty)
            {
                double n;
                if (double.TryParse(numtel, out n))
                {
                    help.connetti();
                    help.assegnaComando("SELECT Email FROM Utenti");
                    rs = help.estraiDati();
                    while (rs.Read() && presente == false)
                    {
                        if (rs["Email"].ToString() == email)
                        {
                            lblErr.Text = "Email già presente";
                            presente    = true;
                        }
                    }
                    help.disconnetti();
                    if (!presente)
                    {
                        help.connetti();
                        help.assegnaComando("INSERT INTO Utenti(Nome,Cognome,Email,Ragione_Sociale,Partita_iva,Cod_Fisc,Indirizzo_Fatt,Num_Tel,Psw)" +
                                            " VALUES('" + nome + "','" + cognome + "','" + email + "','" + ragsoc + "','" + piva + "','" + codfisc + "','" + ind + "','" + numtel + "','" + System.Web.Security.FormsAuthentication.HashPasswordForStoringInConfigFile(psw, "md5") + "')");
                        help.eseguicomando();
                        help.disconnetti();
                        MessageBox.Show("operazione completata");
                        Response.Redirect("Login.aspx");
                    }
                }
                else
                {
                    lblErr.Text = "Inserire un numero di telefono corretto";
                }
            }
            else
            {
                lblErr.Text = "Compila tutti i campi";
            }
        }
        catch (Exception ex)
        {
            Response.Write(ex.ToString());
        }
    }