Ejemplo n.º 1
0
        private bool verifica()
        {
            bool esito = false;

            string risultato = String.Empty;

            /* seleziona dalla tabella inquinanti tutti gli elementi con il nome passato e li conta */
            sql = "SELECT COUNT(*) AS TOTALE " +
                  "FROM Generi " +
                  "WHERE UPPER(NomeGenere) = '" + _nome.ToUpper() + "' ";

            try
            {
                //risultato contiene il numero di record che soddisfano la condizione indicata
                //in questo caso, il numero di aziende con lo stesso nome
                risultato = sqlGenere.eseguiScalar(sql, CommandType.Text);

                //se risultato vale 0, non ci altre aziende con quel nome
                if (Convert.ToInt32(risultato) == 0)
                {
                    esito = true;
                }
            }
            catch (Exception e)
            {
                MessageBox.Show("ATTENZIONE: " + e.Message);
            }

            //se la funziona restituisce falso, esiste già un inquinante con quel nome
            return(esito);
        }
Ejemplo n.º 2
0
        public int getNuovoCodice()
        {
            int    nuovoCodice = -1;
            string risultato   = string.Empty;


            sql = "SELECT MAX(CodUtente) AS MAXCODICE " +
                  "FROM Utenti";

            try
            {
                risultato   = sqlUtente.eseguiScalar(sql, CommandType.Text);
                nuovoCodice = Convert.ToInt32(risultato) + 1;
            }
            catch (Exception e)
            {
                MessageBox.Show("ATTENZIONE: " + e.Message);
            }

            return(nuovoCodice);
        }
Ejemplo n.º 3
0
        public string nuovaTessera()
        {
            string nuovoCodice    = string.Empty;
            string risultato      = string.Empty;
            string valoreNumerico = string.Empty;


            sql = "SELECT MAX(CodLettore) AS MAXCODICE " +
                  "FROM Lettori";

            try
            {
                risultato      = sqlLettore.eseguiScalar(sql, CommandType.Text);
                valoreNumerico = risultato.Substring(1);
                nuovoCodice    = "NT2020_" + (Convert.ToInt32(valoreNumerico) + 1);
            }
            catch (Exception e)
            {
                MessageBox.Show("ATTENZIONE: " + e.Message);
            }

            return(nuovoCodice);
        }