public override void Cadastrar() { this.txtPesquisa.Clear(); //Direcionando para tela de cadastro Object sessao, int id, Boolean visualizar, object objFisioterapeuta FormPacienteCadastro form = new FormPacienteCadastro(nSessao, 0, false, null); form.ShowDialog(); //Atualiza grid this.preencherGrid(); }
/// <summary> /// Este método recebe os dados do Data Grid para um objeto /// do tipo Paciente para o Formulário que será aberto. /// </summary> public override void Alterar() { //Verifica se o Data grid possui linha this.txtPesquisa.Clear(); if (this.dgDados.Rows.Count > 0) { //Verifica de sé alguma linha selecionada if (this.dgDados.CurrentRow.Cells[2].Selected | this.dgDados.CurrentRow.Cells[3].Selected | this.dgDados.CurrentRow.Cells[4].Selected) { //Tratamento de exceções try { Clinica nClinica = new Clinica(); //Inserindo dados da grid no objeto nPaciente. this.nPaciente.id = Convert.ToInt32(this.dgDados.CurrentRow.Cells[0].Value.ToString()); nClinica.id = Convert.ToInt32(this.dgDados.CurrentRow.Cells[1].Value.ToString()); this.nPaciente.clinica = nClinica; this.nPaciente.nome = this.dgDados.CurrentRow.Cells[2].Value.ToString(); this.nPaciente.cpf = this.dgDados.CurrentRow.Cells[3].Value.ToString(); this.nPaciente.rg = this.dgDados.CurrentRow.Cells[4].Value.ToString(); this.nPaciente.sexo = this.dgDados.CurrentRow.Cells[5].Value.ToString(); this.nPaciente.dataDeNascimento = Convert.ToDateTime(this.dgDados.CurrentRow.Cells[6].Value.ToString()); this.nPaciente.estadoCivil = this.dgDados.CurrentRow.Cells[7].Value.ToString(); this.nPaciente.profissao = this.dgDados.CurrentRow.Cells[8].Value.ToString(); this.nPaciente.logradouro = this.dgDados.CurrentRow.Cells[9].Value.ToString(); this.nPaciente.numero = Convert.ToInt32(this.dgDados.CurrentRow.Cells[10].Value.ToString()); this.nPaciente.complemento = this.dgDados.CurrentRow.Cells[11].Value.ToString(); this.nPaciente.bairro = this.dgDados.CurrentRow.Cells[12].Value.ToString(); this.nPaciente.cep = this.dgDados.CurrentRow.Cells[13].Value.ToString(); this.nPaciente.cidade = this.dgDados.CurrentRow.Cells[14].Value.ToString(); this.nPaciente.uf = this.dgDados.CurrentRow.Cells[15].Value.ToString(); this.nPaciente.telefone = this.dgDados.CurrentRow.Cells[16].Value.ToString(); this.nPaciente.celular = this.dgDados.CurrentRow.Cells[17].Value.ToString(); this.nPaciente.email = this.dgDados.CurrentRow.Cells[18].Value.ToString(); this.nPaciente.observacao = this.dgDados.CurrentRow.Cells[19].Value.ToString(); this.nPaciente.dataDoCadastro = Convert.ToDateTime(this.dgDados.CurrentRow.Cells[20].Value.ToString()); FormPacienteCadastro formPaciente = new FormPacienteCadastro(nSessao, this.nPaciente.id, false, this.nPaciente); formPaciente.ShowDialog(); //Atualiza a grid this.preencherGrid(); } catch (Exception ex) { MessageBox.Show(ex.Message, "Erro!", MessageBoxButtons.OK, MessageBoxIcon.Error); } } else { MessageBox.Show("Nenhum paciente selecionado. Para alterar selecione uma linha!", "Aviso!", MessageBoxButtons.OK, MessageBoxIcon.Information); } } else { MessageBox.Show("Não há pacientes cadastrados!", "Aviso!", MessageBoxButtons.OK, MessageBoxIcon.Information); this.preencherGrid(); } }