private async Task ExecuteCadastrarButtonCommand() { if (Nome.Length <= 3) { await _pageDialogService.DisplayAlertAsync("Erro", "Nome inválido", "OK"); } else { try { AlunoServiceClient servico = new AlunoServiceClient(); Aluno aluno = new Aluno() { Nome = this.Nome, Sexo = this.Sexo, Nascimento = DataNascimento, }; servico.AddAsync(aluno); await _pageDialogService.DisplayAlertAsync("Sucesso", "Cadastrado com sucesso", "OK"); Nome = ""; } catch (Exception) { await _pageDialogService.DisplayAlertAsync("Erro", "Servidor indisponivel", "OK"); } } }
protected void btnCarregar_Click(object sender, EventArgs e) { try { AlunoServiceClient client = new AlunoServiceClient(); GridViewAlunos.DataSource = client.ListAlunos(); GridViewAlunos.DataBind(); } catch (Exception ex) { } }
private void btnAddAluno_Click(object sender, EventArgs e) { AlunoServiceClient client = new AlunoServiceClient(); Aluno aluno = new Aluno(); aluno.CPF = textBoxCPF.Text; aluno.Nome = textBoxNome.Text; client.AddStudent(aluno); dataGridView1.DataSource = client.GetAlunos(true); }
protected void btnMedia_Click(object sender, EventArgs e) { try { var listFunc = new List <Aluno>(); AlunoServiceClient client = new AlunoServiceClient(); listFunc.Add(client.GetAluno(Convert.ToInt32(txtIDMedia.Text))); txtMedia.Text = Convert.ToString(client.GetMedia(Convert.ToInt32(txtIDMedia.Text))); GridViewAlunos.DataSource = listFunc; GridViewAlunos.DataBind(); } catch (Exception ex) { throw new Exception(ex.Message); } }
protected void btnSelecionar_Click(object sender, EventArgs e) { try { char[] separators = { ',', '.', '!', '?', ';', ':', ' ' }; List <string> lstr = new List <string>(); lstr.AddRange(txtBuscar.Text.Split(separators)); var listFunc = new List <Aluno>(); AlunoServiceClient client = new AlunoServiceClient(); foreach (var item in lstr) { listFunc.Add(client.GetAluno(Convert.ToInt32(item))); } GridViewAlunos.DataSource = listFunc; GridViewAlunos.DataBind(); } catch (Exception ex) { throw new Exception(ex.Message); } }