private void button2_Click(object sender, EventArgs e) { HttpClient client = new HttpClient(); client.BaseAddress = new Uri("http://localhost:4000/"); client.DefaultRequestHeaders.Accept.Add( new MediaTypeWithQualityHeaderValue("application/json")); HttpResponseMessage response = client.GetAsync("Alunos/" + textBox1.Text).Result; if (response.StatusCode.ToString().Equals("NotFound")) { MessageBox.Show("Aluno não encontrado.", "Erro", MessageBoxButtons.OK, MessageBoxIcon.Error); client.Dispose(); limparTela(); return; } response = client.GetAsync("Disciplina/" + textBox3.Text).Result; if (response.StatusCode.ToString().Equals("NotFound")) { MessageBox.Show("Disciplina não encontrada.", "Erro", MessageBoxButtons.OK, MessageBoxIcon.Error); client.Dispose(); limparTela(); return; } response = client.GetAsync("Matricula/" + textBox1.Text + "/" + textBox3.Text).Result; if (response.StatusCode.ToString().Equals("NotFound")) { MessageBox.Show("Matrícula não encontrada.", "Erro", MessageBoxButtons.OK, MessageBoxIcon.Error); client.Dispose(); limparTela(); return; } response = client.GetAsync("Resultado/" + textBox1.Text + "/" + textBox3.Text).Result; if (!response.StatusCode.ToString().Equals("NotFound")) { MessageBox.Show("Este resultado já foi cadastrado.", "Erro", MessageBoxButtons.OK, MessageBoxIcon.Error); client.Dispose(); limparTela(); return; } client.Dispose(); for (int i = 0; i < fila.GetQtd(); i++) { if (fila.Get(i).RA == short.Parse(textBox1.Text) && fila.Get(i).Cod == short.Parse(textBox3.Text)) { MessageBox.Show("O dado já foi inserido!", "Erro", MessageBoxButtons.OK, MessageBoxIcon.Error); limparTela(); return; } } dataGridView1.Rows.Add(); dataGridView1.Rows[dataGridView1.Rows.Count - 1].Cells[0].Value = textBox1.Text; dataGridView1.Rows[dataGridView1.Rows.Count - 1].Cells[1].Value = textBox3.Text; dataGridView1.Rows[dataGridView1.Rows.Count - 1].Cells[2].Value = textBox4.Text; dataGridView1.Rows[dataGridView1.Rows.Count - 1].Cells[3].Value = textBox2.Text; Resultados res = new Resultados(short.Parse(textBox1.Text), int.Parse(textBox3.Text), float.Parse(textBox4.Text), float.Parse(textBox2.Text)); fila.Enfileirar(res); limparTela(); button2.Enabled = false; button1.Enabled = true; }