Exemplo n.º 1
0
        public int EditaSetor(Setor s)
        {
            string sql    = "UPDATE setor SET nome = @nome WHERE codSetor = @codigo;";
            int    result = 0;

            SqlConnection conn   = new SqlConnection(strConnection);
            SqlCommand    sqlcmd = new SqlCommand(sql, conn);

            sqlcmd.Parameters.AddWithValue("@codigo", s.GetCodSetor());
            sqlcmd.Parameters.AddWithValue("@nome", s.GetNome());

            try
            {
                conn.Open();
                result = sqlcmd.ExecuteNonQuery();
            }
            catch (Exception)
            {
                throw;
            }
            finally
            {
                conn.Close();
            }
            return(result);
        }
Exemplo n.º 2
0
        public int ExcluiSetor(Setor s)
        {
            string sql    = "DELETE FROM setor WHERE codSetor = @codigo";
            int    result = 0;

            SqlConnection conn   = new SqlConnection(strConnection);
            SqlCommand    sqlcmd = new SqlCommand(sql, conn);

            sqlcmd.Parameters.AddWithValue("@codigo", s.GetCodSetor());

            try
            {
                conn.Open();
                result = sqlcmd.ExecuteNonQuery();
            }
            catch (Exception)
            {
                throw;
            }
            finally
            {
                conn.Close();
            }
            return(result);
        }