private void btnEliminaVendita_Click(object sender, EventArgs e)
 {
     if (cmbbxCodiceProdotto.Text == "")
     {
         MessageBox.Show("Devi scegliere un codice prodotto!", "Errore codice prodotto",
                         MessageBoxButtons.OK, MessageBoxIcon.Error);
     }
     else
     {
         var prodotto = from p in db.PRODOTTIs
                        where p.codiceProdotto == Int32.Parse(cmbbxCodiceProdotto.Text)
                        select p;
         foreach (var prod in prodotto)
         {
             prod.venduto = false;
         }
         ;
         try
         {
             db.SubmitChanges();
             this.updateProducts();
             MessageBox.Show("Prodotto cancellato con successo!", "Successo cancellazione vendita prodotto",
                             MessageBoxButtons.OK, MessageBoxIcon.Information);
         }
         catch (Exception e1)
         {
             Console.WriteLine(e1);
             MessageBox.Show("C'è stato qualche errore con la cancellazione del prodotto!", "Errore cancellazione vendita prodotto",
                             MessageBoxButtons.OK, MessageBoxIcon.Error);
         }
     }
 }
        private void btnCrea_Click(object sender, EventArgs e)
        {
            SocialNetworkVenditeDbDataContext db = new SocialNetworkVenditeDbDataContext();
            var sezione = from s in db.SEZIONIs
                          where s.nome == txtNomeSezione.Text
                          select s;

            if (sezione.Count() != 0)
            {
                MessageBox.Show("Questo nome di sezione è già utilizzato!", "Errore sezione",
                                MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            else if (txtNomeSezione.Text == "")
            {
                MessageBox.Show("La sezione deve avere un nome!", "Errore sezione",
                                MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            else if (txtDescrizione.Text == "")
            {
                MessageBox.Show("Devi scegliere una descrizione!", "Errore descrizione",
                                MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            else
            {
                SEZIONI newSection = new SEZIONI
                {
                    nome          = txtNomeSezione.Text,
                    descrizione   = txtDescrizione.Text,
                    dataCreazione = DateTime.Now,
                    emailUtente   = this.email
                };
                if (!imageLocation.Equals(""))
                {
                    byte[]       bytesImage = null;
                    FileStream   Stream     = new FileStream(imageLocation, FileMode.Open, FileAccess.Read);
                    BinaryReader brs        = new BinaryReader(Stream);
                    bytesImage          = brs.ReadBytes((int)Stream.Length);
                    newSection.immagine = bytesImage;
                }
                db.SEZIONIs.InsertOnSubmit(newSection);
                try
                {
                    db.SubmitChanges();
                    txtNomeSezione.Text      = "";
                    txtDescrizione.Text      = "";
                    imageLocation            = "";
                    pictureBox.ImageLocation = "";
                    MessageBox.Show("Sezione creata con successo!", "Successo creazione sezione",
                                    MessageBoxButtons.OK, MessageBoxIcon.Information);
                }
                catch (Exception e1)
                {
                    Console.WriteLine(e1);
                    MessageBox.Show("C'è stato qualche errore con la crezione della sessione!", "Errore creazione sessione",
                                    MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }
        }
 private void resultFriendRequest(Boolean accept)
 {
     if (cmbbxEmailUtente.Text == "")
     {
         MessageBox.Show("Devi scegliere una email di un utente!", "Errore email utente",
                         MessageBoxButtons.OK, MessageBoxIcon.Information);
     }
     else
     {
         var user = from r in db.RICHIESTE_AMICIZIEs
                    where r.emailMittente == cmbbxEmailUtente.Text && r.emailDestinatario == this.email && r.dataRisposta == null
                    select r;
         foreach (var u in user)
         {
             u.accettata    = accept;
             u.dataRisposta = DateTime.Now;
             u.timeRisposta = DateTime.Now.TimeOfDay;
         }
         ;
         if (accept)
         {
             AMICIZIE newFriend = new AMICIZIE
             {
                 dataInizio   = DateTime.Now,
                 timeInizio   = DateTime.Now.TimeOfDay,
                 emailUtente1 = cmbbxEmailUtente.Text,
                 emailUtente2 = this.email
             };
             db.AMICIZIEs.InsertOnSubmit(newFriend);
         }
         try
         {
             db.SubmitChanges();
             this.updateUsers();
             if (accept)
             {
                 MessageBox.Show("Utente aggiunto con successo!", "Successo aggiunta utente",
                                 MessageBoxButtons.OK, MessageBoxIcon.Information);
             }
             else
             {
                 MessageBox.Show("Utente rifiutato con successo!", "Successo rifiuto utente",
                                 MessageBoxButtons.OK, MessageBoxIcon.Information);
             }
         }
         catch (Exception e1)
         {
             Console.WriteLine(e1);
             MessageBox.Show("C'è stato qualche errore!", "Errore",
                             MessageBoxButtons.OK, MessageBoxIcon.Error);
         }
     }
 }
Example #4
0
 private void btnCompra_Click(object sender, EventArgs e)
 {
     if (cmbbxSezione.Text == "")
     {
         MessageBox.Show("Devi scegliere una sezione!", "Errore sezione",
                         MessageBoxButtons.OK, MessageBoxIcon.Error);
     }
     else if (cmbbxCategoria.Text == "")
     {
         MessageBox.Show("Devi scegliere una categoria!", "Errore categoria",
                         MessageBoxButtons.OK, MessageBoxIcon.Error);
     }
     else if (cmbbxCodiceProdotto.Text == "")
     {
         MessageBox.Show("Devi scegliere un codice prodotto!", "Errore codice prodotto",
                         MessageBoxButtons.OK, MessageBoxIcon.Error);
     }
     else
     {
         var prodotto = from p in db.PRODOTTIs
                        where p.codiceProdotto == Int32.Parse(cmbbxCodiceProdotto.Text)
                        select p;
         foreach (var prod in prodotto)
         {
             prod.emailUtenteAcquisto = this.email;
             prod.dataAcquisto        = DateTime.Now;
             prod.venduto             = true;
         }
         ;
         try
         {
             db.SubmitChanges();
             cmbbxSezione.Text        = "";
             cmbbxCategoria.Text      = "";
             cmbbxCodiceProdotto.Text = "";
             cmbbxCategoria.Items.Clear();
             cmbbxCodiceProdotto.Items.Clear();
             cmbbxCategoria.Enabled      = false;
             cmbbxCodiceProdotto.Enabled = false;
             MessageBox.Show("Prodotto acquistato con successo!", "Successo acquisto prodotto",
                             MessageBoxButtons.OK, MessageBoxIcon.Information);
         }
         catch (Exception e1)
         {
             Console.WriteLine(e1);
             MessageBox.Show("C'è stato qualche errore con l'acquisto del prodotto!", "Errore acquisto prodotto",
                             MessageBoxButtons.OK, MessageBoxIcon.Error);
         }
     }
 }
        private void btnCrea_Click(object sender, EventArgs e)
        {
            SocialNetworkVenditeDbDataContext db = new SocialNetworkVenditeDbDataContext();
            var categoria = from c in db.CATEGORIEs
                            where c.nome == txtNomeCategoria.Text
                            select c;

            if (categoria.Count() != 0)
            {
                MessageBox.Show("Questo nome di categoria è già utilizzato!", "Errore sezione",
                                MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            else if (txtNomeCategoria.Text == "")
            {
                MessageBox.Show("La categoria deve avere un nome!", "Errore sezione",
                                MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            else if (txtDescrizione.Text == "")
            {
                MessageBox.Show("Devi scegliere una descrizione!", "Errore descrizione",
                                MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            else
            {
                CATEGORIE newCategory = new CATEGORIE
                {
                    nome        = txtNomeCategoria.Text,
                    descrizione = txtDescrizione.Text,
                    emailUtente = this.email
                };
                db.CATEGORIEs.InsertOnSubmit(newCategory);
                try
                {
                    db.SubmitChanges();
                    txtNomeCategoria.Text = "";
                    txtDescrizione.Text   = "";
                    MessageBox.Show("Categoria creata con successo!", "Successo creazione categoria",
                                    MessageBoxButtons.OK, MessageBoxIcon.Information);
                }
                catch (Exception e1)
                {
                    Console.WriteLine(e1);
                    MessageBox.Show("C'è stato qualche errore con la crezione della categoria!", "Errore creazione categoria",
                                    MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }
        }
 private void btnInvia_Click(object sender, EventArgs e)
 {
     if (cmbbxSezione.Text == "")
     {
         MessageBox.Show("Devi scegliere una sezione!", "Errore sezione",
                         MessageBoxButtons.OK, MessageBoxIcon.Error);
     }
     else if (txtTitolo.Text == "")
     {
         MessageBox.Show("Devi scegliere un titolo!", "Errore titolo",
                         MessageBoxButtons.OK, MessageBoxIcon.Error);
     }
     else if (txtMessaggio.Text == "")
     {
         MessageBox.Show("Non puoi lasciare la descrizione vuota!", "Errore descrizione",
                         MessageBoxButtons.OK, MessageBoxIcon.Error);
     }
     else
     {
         POST newPost = new POST
         {
             data        = DateTime.Now,
             time        = DateTime.Now.TimeOfDay,
             titolo      = txtTitolo.Text,
             descrizione = txtMessaggio.Text,
             emailUtente = this.email,
             nomeSezione = cmbbxSezione.Text
         };
         db.POSTs.InsertOnSubmit(newPost);
         try
         {
             db.SubmitChanges();
             cmbbxSezione.Text = "";
             txtTitolo.Text    = "";
             txtMessaggio.Text = "";
             MessageBox.Show("Post creato con successo!", "Successo invio messaggio",
                             MessageBoxButtons.OK, MessageBoxIcon.Information);
         }
         catch (Exception e1)
         {
             Console.WriteLine(e1);
             MessageBox.Show("C'è stato qualche errore con la creazione del post!", "Errore creazione post",
                             MessageBoxButtons.OK, MessageBoxIcon.Error);
         }
     }
 }
Example #7
0
 private void btnInvia_Click(object sender, EventArgs e)
 {
     if (txtMessaggio.Text == "")
     {
         MessageBox.Show("Non puoi inviare un messaggio vuoto!", "Errore messaggio",
                         MessageBoxButtons.OK, MessageBoxIcon.Error);
     }
     else if (cmbbxEmail.Text == "")
     {
         MessageBox.Show("Devi scegliere il destinatario del messaggio!", "Errore email",
                         MessageBoxButtons.OK, MessageBoxIcon.Error);
     }
     else
     {
         MESSAGGI newMessage = new MESSAGGI
         {
             data              = DateTime.Now,
             time              = DateTime.Now.TimeOfDay,
             descrizione       = txtMessaggio.Text,
             emailMittente     = this.email,
             emailDestinatario = cmbbxEmail.Text
         };
         db.MESSAGGIs.InsertOnSubmit(newMessage);
         try
         {
             db.SubmitChanges();
             cmbbxEmail.Text   = "";
             txtMessaggio.Text = "";
             MessageBox.Show("Messaggio inviato con successo!", "Successo invio messaggio",
                             MessageBoxButtons.OK, MessageBoxIcon.Information);
         }
         catch (Exception e1)
         {
             Console.WriteLine(e1);
             MessageBox.Show("C'è stato qualche errore con l'invio del messaggio!", "Errore invio messaggio",
                             MessageBoxButtons.OK, MessageBoxIcon.Error);
         }
     }
 }
 private void updateFriend(IQueryable <AMICIZIE> friend)
 {
     foreach (var f in friend)
     {
         f.dataFine = DateTime.Now;
         f.timeFine = DateTime.Now.TimeOfDay;
     }
     ;
     try
     {
         db.SubmitChanges();
         MessageBox.Show("Cancellazione amicizia avvenuta con successo!", "Successo cancellazione amicizia",
                         MessageBoxButtons.OK, MessageBoxIcon.Information);
         this.updateUsers();
     }
     catch (Exception e1)
     {
         Console.WriteLine(e1);
         MessageBox.Show("C'è stato qualche errore con la cancellazione dell'amicizia!", "Errore cancelazione amicizia",
                         MessageBoxButtons.OK, MessageBoxIcon.Error);
     }
 }
Example #9
0
 private void btnInvia_Click(object sender, EventArgs e)
 {
     if (cmbbxPost.Text == "")
     {
         MessageBox.Show("Devi scegliere un codice post!", "Errore codice post",
                         MessageBoxButtons.OK, MessageBoxIcon.Error);
     }
     else if (txtMessaggio.Text == "")
     {
         MessageBox.Show("Non puoi inviare un messaggio vuoto!", "Errore messaggio",
                         MessageBoxButtons.OK, MessageBoxIcon.Error);
     }
     else
     {
         COMMENTI newComment = new COMMENTI
         {
             codicePost  = Int32.Parse(cmbbxPost.Text),
             data        = DateTime.Now,
             time        = DateTime.Now.TimeOfDay,
             descrizione = txtMessaggio.Text,
             emailUtente = this.email
         };
         db.COMMENTIs.InsertOnSubmit(newComment);
         try
         {
             db.SubmitChanges();
             cmbbxPost.Text    = "";
             txtMessaggio.Text = "";
             MessageBox.Show("Commento inviato con successo!", "Successo invio commento",
                             MessageBoxButtons.OK, MessageBoxIcon.Information);
         }
         catch (Exception e1)
         {
             Console.WriteLine(e1);
             MessageBox.Show("C'è stato qualche errore con l'invio del commento!", "Errore invio commento",
                             MessageBoxButtons.OK, MessageBoxIcon.Error);
         }
     }
 }
 private void btnAssocia_Click(object sender, EventArgs e)
 {
     if (cmbbxSezione.Text == "")
     {
         MessageBox.Show("Devi scegliere una sezione!", "Errore sezione",
                         MessageBoxButtons.OK, MessageBoxIcon.Error);
     }
     else if (cmbbxCategoria.Text == "")
     {
         MessageBox.Show("Devi scegliere una categoria!", "Errore categoria",
                         MessageBoxButtons.OK, MessageBoxIcon.Error);
     }
     else
     {
         ASSOCIAZIONI newAssociation = new ASSOCIAZIONI
         {
             nomeSezione   = cmbbxSezione.Text,
             nomeCategoria = cmbbxCategoria.Text
         };
         db.ASSOCIAZIONIs.InsertOnSubmit(newAssociation);
         try
         {
             db.SubmitChanges();
             cmbbxSezione.Text   = "";
             cmbbxCategoria.Text = "";
             cmbbxCategoria.Items.Clear();
             cmbbxCategoria.Enabled = false;
             MessageBox.Show("Categoria aggiunta con successo alla sezione!", "Successo associazione categoria-sezione",
                             MessageBoxButtons.OK, MessageBoxIcon.Information);
         }
         catch (Exception e1)
         {
             Console.WriteLine(e1);
             MessageBox.Show("C'è stato qualche errore con l'associazione della categoria alla sessione!",
                             "Errore associazione categoria-sessione", MessageBoxButtons.OK, MessageBoxIcon.Error);
         }
     }
 }
Example #11
0
        private void btnInvia_Click(object sender, EventArgs e)
        {
            SocialNetworkVenditeDbDataContext db = new SocialNetworkVenditeDbDataContext();
            var friends = from a in db.AMICIZIEs
                          where (a.emailUtente1 == this.email && a.emailUtente2 == txtEmailUtente.Text) ||
                          (a.emailUtente1 == txtEmailUtente.Text && a.emailUtente2 == this.email)
                          select a;
            var r1 = from r in db.RICHIESTE_AMICIZIEs
                     where r.emailMittente == this.email && r.emailDestinatario == txtEmailUtente.Text && r.dataRisposta == null
                     select r;
            var r2 = from r in db.RICHIESTE_AMICIZIEs
                     where r.emailMittente == txtEmailUtente.Text && r.emailDestinatario == this.email && r.dataRisposta == null
                     select r;
            var searchUser = from u in db.UTENTIs
                             where u.email == txtEmailUtente.Text
                             select u;

            if (txtEmailUtente.Text == "")
            {
                MessageBox.Show("Devi inserire la email di un utente!", "Errore email utente",
                                MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            else if (friends.Count() != 0)
            {
                MessageBox.Show("Sei già amico con questo utente!", "Errore richiesta amicizia",
                                MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            else if (r1.Count() != 0)
            {
                MessageBox.Show("Hai già inviato la richiesta di amicizia a questo utente!", "Errore richiesta amicizia",
                                MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            else if (r2.Count() != 0)
            {
                MessageBox.Show(txtEmailUtente.Text + " ti ha già inviato la richiesta di amicizia!", "Errore richiesta amicizia",
                                MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            else if (searchUser.Count() == 0)
            {
                MessageBox.Show(txtEmailUtente.Text + " non trovata!", "Errore ricerca email",
                                MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            else
            {
                RICHIESTE_AMICIZIE newFriendRequest = new RICHIESTE_AMICIZIE
                {
                    emailMittente     = this.email,
                    emailDestinatario = txtEmailUtente.Text,
                    dataRichiesta     = DateTime.Now,
                    timeRichiesta     = DateTime.Now.TimeOfDay
                };
                db.RICHIESTE_AMICIZIEs.InsertOnSubmit(newFriendRequest);
                try
                {
                    db.SubmitChanges();
                    txtEmailUtente.Text = "";
                    MessageBox.Show("Richiesta amicizia inviata con successo!", "Successo invio richiesta amicizia",
                                    MessageBoxButtons.OK, MessageBoxIcon.Information);
                }
                catch (Exception e1)
                {
                    Console.WriteLine(e1);
                    MessageBox.Show("C'è stato qualche errore con l'invio della richiesta di amicizia!",
                                    "Errore invio richiesta amicizia", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }
        }
        private void btnVendi_Click(object sender, EventArgs e)
        {
            int productPrice;

            if (cmbbxSezione.Text == "")
            {
                MessageBox.Show("Devi scegliere una sezione!", "Errore sezione",
                                MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            else if (cmbbxCategoria.Text == "")
            {
                MessageBox.Show("Devi scegliere una categoria!", "Errore categoria",
                                MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            else if (txtPrezzo.Text == "")
            {
                MessageBox.Show("Devi inserire un prezzo per il prodotto!", "Errore prezzo prodotto",
                                MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            else if (!Int32.TryParse(txtPrezzo.Text, out productPrice))
            {
                MessageBox.Show("Devi inserire un prezzo valido composto da soli numeri!", "Errore prezzo prodotto",
                                MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            else
            {
                PRODOTTI newProduct = new PRODOTTI
                {
                    dataVendita        = DateTime.Now,
                    emailUtenteVendita = this.email,
                    nomeSezione        = cmbbxSezione.Text,
                    nomeCategoria      = cmbbxCategoria.Text,
                    prezzo             = productPrice
                };
                if (txtDescrizione.Text != "")
                {
                    newProduct.descrizione = txtDescrizione.Text;
                }
                if (!imageLocation.Equals(""))
                {
                    byte[]       bytesImage = null;
                    FileStream   Stream     = new FileStream(imageLocation, FileMode.Open, FileAccess.Read);
                    BinaryReader brs        = new BinaryReader(Stream);
                    bytesImage          = brs.ReadBytes((int)Stream.Length);
                    newProduct.immagine = bytesImage;
                }
                db.PRODOTTIs.InsertOnSubmit(newProduct);
                try
                {
                    db.SubmitChanges();
                    cmbbxSezione.Text        = "";
                    cmbbxCategoria.Text      = "";
                    txtPrezzo.Text           = "";
                    txtDescrizione.Text      = "";
                    cmbbxCategoria.Enabled   = false;
                    imageLocation            = "";
                    pictureBox.ImageLocation = "";
                    cmbbxCategoria.Items.Clear();
                    MessageBox.Show("Prodotto messo in vendita con successo!", "Successo vendita prodotto",
                                    MessageBoxButtons.OK, MessageBoxIcon.Information);
                }
                catch (Exception e1)
                {
                    Console.WriteLine(e1);
                    MessageBox.Show("C'è stato qualche errore con la messa in vendita del prodotto!", "Errore vendita prodotto",
                                    MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }
        }
        private void btnIscriviti_Click(object sender, EventArgs e)
        {
            SocialNetworkVenditeDbDataContext db = new SocialNetworkVenditeDbDataContext();
            long telephoneNumber;
            var  query = from u in db.UTENTIs
                         where u.email == txtEmail.Text
                         select u.email;
            Boolean emailOk = query.Count() == 0 ? true: false;

            if (!emailOk)
            {
                MessageBox.Show("La seguente email: " + txtEmail + "è già presente!", "Email esistente",
                                MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            else if (txtNumeroTelefono.Text.Length != 10)
            {
                MessageBox.Show("Il numero di telefono deve essere composto da 10 numeri", "Numero di telefono errato",
                                MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            else if (!long.TryParse(txtNumeroTelefono.Text, out telephoneNumber))
            {
                MessageBox.Show("Il numero di telefono deve essere composto da soli numeri!", "Numero di telefono errato",
                                MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            else if (txtEmail.Text == "" || txtPassword.Text == "" || txtNome.Text == "" || txtCognome.Text == "" ||
                     txtLuogoNascita.Text == "" || txtVia.Text == "" || txtCitta.Text == "" || cmbbxSesso.Text == "" ||
                     cmbbxDataGiorno.Text == "" || cmbbxDataMese.Text == "" || cmbbxDataAnno.Text == "" ||
                     cmbbxNumeroCivico.Text == "" || cmbbxAmministratore.Text == "")
            {
                MessageBox.Show("Ci sono uno o più campi non compilati!", "Campo/i non compilato/i",
                                MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            else if ((cmbbxDataMese.Text == "4" || cmbbxDataMese.Text == "6" || cmbbxDataMese.Text == "9" || cmbbxDataMese.Text == "11") && cmbbxDataGiorno.Text == "31")
            {
                MessageBox.Show("Il giorno di nascita non può essere 31!", "Data Errata",
                                MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            else if (cmbbxDataMese.Text == "2" && (cmbbxDataGiorno.Text == "29" || cmbbxDataGiorno.Text == "30" || cmbbxDataGiorno.Text == "31"))
            {
                MessageBox.Show("Il giorno di nascita non può essere maggiore di 28!", "Data Errata",
                                MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            else
            {
                UTENTI newUser;
                newUser = new UTENTI
                {
                    email                 = txtEmail.Text,
                    password              = txtPassword.Text,
                    nome                  = txtNome.Text,
                    cognome               = txtCognome.Text,
                    sesso                 = cmbbxSesso.Text.Equals("Maschio") ? "M" : "F",
                    dataNascita           = new DateTime(Int32.Parse(cmbbxDataAnno.Text), Int32.Parse(cmbbxDataMese.Text), Int32.Parse(cmbbxDataGiorno.Text)),
                    luogoNascita          = txtLuogoNascita.Text,
                    viaResidenza          = txtVia.Text,
                    numeroCivicoResidenza = Int16.Parse(cmbbxNumeroCivico.Text),
                    cittaResidenza        = txtCitta.Text,
                    numeroTelefono        = txtNumeroTelefono.Text,
                    amministratore        = cmbbxAmministratore.Text.Equals("True") ? true : false
                };
                if (!imageLocation.Equals(""))
                {
                    byte[]       bytesImage = null;
                    FileStream   Stream     = new FileStream(imageLocation, FileMode.Open, FileAccess.Read);
                    BinaryReader brs        = new BinaryReader(Stream);
                    bytesImage       = brs.ReadBytes((int)Stream.Length);
                    newUser.immagine = bytesImage;
                }
                db.UTENTIs.InsertOnSubmit(newUser);
                try
                {
                    db.SubmitChanges();
                    txtEmail.Text            = "";
                    txtPassword.Text         = "";
                    txtNome.Text             = "";
                    txtCognome.Text          = "";
                    cmbbxSesso.Text          = "";
                    cmbbxDataGiorno.Text     = "";
                    cmbbxDataMese.Text       = "";
                    cmbbxDataAnno.Text       = "";
                    txtLuogoNascita.Text     = "";
                    txtVia.Text              = "";
                    cmbbxNumeroCivico.Text   = "";
                    txtCitta.Text            = "";
                    txtNumeroTelefono.Text   = "";
                    cmbbxAmministratore.Text = "";
                    imageLocation            = "";
                    pictureBox.ImageLocation = "";
                    MessageBox.Show("Iscrizione avvenuta con successo!", "Successo iscrizione",
                                    MessageBoxButtons.OK, MessageBoxIcon.Information);
                    returnLogin();
                }  catch (Exception e1) {
                    Console.WriteLine(e1);
                    MessageBox.Show("C'è stato qualche errore con l'iscrizione!", "Errore iscrizione",
                                    MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }
        }