Esempio n. 1
0
        public static List <Grid> listaGrid(int idversao)
        {
            var conn  = ConexaoDao.conexao();
            var query = new SqlCommand("select * from grid_dll where id_vesao = @ID_VERSAO", conn);

            query.Parameters.AddWithValue("@ID_VERSAO", idversao);

            SqlDataReader dr   = query.ExecuteReader();
            var           grid = new List <Grid>();


            if (dr.HasRows)
            {
                while (dr.Read())
                {
                    grid.Add(new Grid(Convert.ToInt32(dr[0]), Convert.ToInt32(dr[1]), new JavaScriptSerializer().Serialize(dr[2])));
                }

                dr.Close();
                conn.Close();

                return(grid);
            }
            else
            {
                return(grid);
            }
        }
Esempio n. 2
0
        public static void Update(int idVersao, string valorJson)
        {
            var        conn = ConexaoDao.conexao();
            SqlCommand query;

            query = new SqlCommand($"UPDATE grid_dll SET resultado = '{valorJson}' WHERE id_vesao = {idVersao}", conn);
            query.ExecuteNonQuery();
            conn.Close();
        }
        public static void AdicionarLinhaGrid(int idversao, string valorJson)
        {
            if (ListarGridDao.listaGrid(idversao).Count < 1)
            {
                var        conn = ConexaoDao.conexao();
                SqlCommand query;

                query = new SqlCommand($"INSERT INTO grid_dll (id_vesao, resultado) VALUES ({idversao},'{valorJson}')", conn);
                query.ExecuteNonQuery();
                conn.Close();
            }
            else
            {
                UpdateDao.Update(idversao, valorJson);
            }
        }