Example #1
0
        //deleteById
        public void deleteUtente(Utente oUtente)
        {
            DataTable dt = new DataTable();
            DbEntity  db = new DbEntity();

            SqlCommand cmd = new SqlCommand();

            cmd.CommandType = CommandType.Text;
            cmd.CommandText = "DELETE Utenti WHERE idutente = " + oUtente.ID + ";";
            db.eseguiQueryNOreturn(cmd);
        }
Example #2
0
        public void DeleteRelazione(int IDUtente, int IDPostazione)
        {
            DataTable dt = new DataTable();
            DbEntity  db = new DbEntity();

            SqlCommand cmd = new SqlCommand();

            cmd.CommandType = CommandType.Text;
            cmd.CommandText = String.Format(@"DELETE dbo.Utenti_postazioni
                                                WHERE fk_utente ={0} AND fk_postazione = {1}", IDUtente, IDPostazione);

            db.eseguiQueryNOreturn(cmd);
        }
Example #3
0
        public void AddRelazione(int IDUtente, int IDPostazione)
        {
            DataTable dt = new DataTable();
            DbEntity  db = new DbEntity();

            SqlCommand cmd = new SqlCommand();

            cmd.CommandType = CommandType.Text;
            cmd.CommandText = String.Format(@"INSERT dbo.Utenti_postazioni (fk_utente, fk_postazione)VALUES(   {0},{1})", IDUtente, IDPostazione);
            int a = 3;

            db.eseguiQueryNOreturn(cmd);
        }
Example #4
0
        //insertByItem
        public void insertUtente(Utente oUtente)
        {
            DataTable dt = new DataTable();
            DbEntity  db = new DbEntity();

            SqlCommand cmd = new SqlCommand();

            cmd.CommandType = CommandType.Text;
            cmd.CommandText = "INSERT INTO Utenti (username, password, fk_ruolo) VALUES ('" +
                              oUtente.Username + "', '" + oUtente.Password + "', " + oUtente.Ruolo + ");";

            db.eseguiQueryNOreturn(cmd);
        }
Example #5
0
        //updateByItem
        public void updateUtente(Utente oUtente)
        {
            DataTable dt = new DataTable();
            DbEntity  db = new DbEntity();

            SqlCommand cmd = new SqlCommand();

            cmd.CommandType = CommandType.Text;
            cmd.CommandText = "UPDATE Utenti SET username = '******', password = '******', fk_ruolo = '" + oUtente.Ruolo +
                              "'WHERE idutente = " + oUtente.ID + ";";

            db.eseguiQueryNOreturn(cmd);
        }
Example #6
0
        public void AddPostazione(Postazione P)
        {
            DataTable dt = new DataTable();
            DbEntity  db = new DbEntity();

            SqlCommand cmd = new SqlCommand();

            cmd.CommandType = CommandType.Text;
            cmd.CommandText = String.Format(@"INSERT Postazioni
                                        (
                                            tag,
                                            fk_tipo
                                        )
                                        VALUES
                                        (   '{0}', -- tag - varchar(55)
                                            {1}   -- fk_tipo - int
                                        )", P.Tag, P.TipoID);

            db.eseguiQueryNOreturn(cmd);
        }
Example #7
0
        public void AggiornaStato(Lavorazione L, int PostazioneID)
        {
            DbEntity db = new DbEntity();

            SqlCommand cmd = new SqlCommand();

            cmd.CommandType = CommandType.Text;

            if (PostazioneID == -1)
            {
                cmd.CommandText = String.Format(@"UPDATE Lavorazioni
                                                SET stato = {0}, fk_postazione = NULL
                                                WHERE idlavorazione = {1}", L.ID, L.Stato);
            }
            else
            {
                string query = "UPDATE Lavorazioni ";
                if (L.Inizio.Equals(default(DateTime)) && !L.Fine.Equals(default(DateTime)))
                {
                    query += String.Format("SET stato = {0}, fk_postazione = {1}, fine = CAST('{2}' AS DATETIME) ", L.Stato, PostazioneID, L.Fine);
                }
                else if (!L.Inizio.Equals(default(DateTime)) && L.Fine.Equals(default(DateTime)))
                {
                    query += String.Format("SET stato = {0}, fk_postazione = {1}, inizio = CAST('{2}' AS DATETIME) ", L.Stato, PostazioneID, L.Inizio);
                }
                else if (!L.Inizio.Equals(default(DateTime)) && !L.Fine.Equals(default(DateTime)))
                {
                    query += String.Format("SET stato = {0}, fk_postazione = {1}, inizio = CAST('{2}' AS DATETIME), fine = CAST('{3}' AS DATETIME) ", L.Stato, PostazioneID, L.Inizio, L.Fine);
                }
                else
                {
                    query += String.Format("SET stato = {0}, fk_postazione = {1}", L.Stato, PostazioneID);
                }
                query += String.Format("WHERE idlavorazione = {0}", L.ID);

                cmd.CommandText = query;
            }

            db.eseguiQueryNOreturn(cmd);
        }