private void btnRemove_Click(object sender, EventArgs e) { if (gdvConvenio.SelectedRows.Count > 0) { Convenio medico; var rep = new Fiap.Persistencia.Hospital.DAO.Repositorio<Convenio>(); var id = gdvConvenio.SelectedRows[0].Cells[0].Value.ToString().CInt(); medico = rep.Buscar(id); //if (medico != null) // rep.Remover(medico); medico.dataExclusao =DateTime.Now; rep.Salvar(); btnConsulta_Click(sender, e); gdvConvenio.ClearSelection(); //txtCRM.GetTodosControles(); var txts = groupBox1.GetTodosControles(typeof(TextBox)); foreach (var item in txts) { item.Text = ""; item.Enabled = true; } } }
private void btnBuscarAgendamento_Click(object sender, EventArgs e) { try { if (Convert.ToString(cboAgendamento.SelectedValue) != "0") { var repH = new Fiap.Persistencia.Hospital.DAO.Repositorio<AgendamentoPaciente>(); var agendamento = repH.Buscar(Convert.ToInt32(cboAgendamento.SelectedValue)); var repP = new Fiap.Persistencia.Hospital.DAO.Repositorio<Prontuario>(); gdvProntuarios.DataSource = repP.Listar(a => a.IdAgendamento.Equals(agendamento.IdAgendamento)) .OrderBy(a => a.DatInc) .Select(x => new { x.CPF, x.CRM, x.Descricao, x.DatInc }) .ToList(); } else { MessageBox.Show("Por favor selecione um agendamento.", "Consulta Prontuario", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); cboAgendamento.Focus(); return; } } catch (Exception) { MessageBox.Show("Erro na busca de agendamento", "Consulta Prontuario", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); throw; } }
private void btnRemove_Click(object sender, EventArgs e) { if (gdvPaciente.SelectedRows.Count > 0) { Paciente medico; var repP = new Fiap.Persistencia.Hospital.DAO.Repositorio<Paciente>(); var cpf = gdvPaciente.SelectedRows[0].Cells[0].Value.ToString(); medico = repP.Buscar(cpf); if (medico != null) // repP.Remover(medico); medico.dataExclusao = DateTime.Now; repP.Salvar(); btnConsulta_Click(sender, e); gdvPaciente.ClearSelection(); var txts = groupBox1.GetTodosControles(typeof(TextBox)); foreach (var item in txts) { item.Text = ""; item.Enabled = true; } txtCPF.Focus(); } }
private void btnRemove_Click(object sender, EventArgs e) { if (gdvTratamento.SelectedRows.Count > 0) { Tratamento tratamento; var rep = new Fiap.Persistencia.Hospital.DAO.Repositorio<Tratamento>(); var crm = int.Parse(gdvTratamento.SelectedRows[0].Cells[1].Value.ToString()); tratamento = rep.Buscar(crm); //if (tratamento != null) // rep.Remover(tratamento); tratamento.dataExclusao= DateTime.Now; rep.Salvar(); btnConsulta_Click(sender, e); gdvTratamento.ClearSelection(); //txtCRM.GetTodosControles(); var txts = groupBox1.GetTodosControles(typeof(TextBox)); foreach (var item in txts) { item.Text = ""; item.Enabled = true; } txtNome.Focus(); } }
private void btnBuscarAgendamento_Click_1(object sender, EventArgs e) { try { if (Convert.ToString(cboAgendamento.SelectedValue) != "0") { var repH = new Fiap.Persistencia.Hospital.DAO.Repositorio<AgendamentoPaciente>(); int idAgenda = Convert.ToInt32(cboAgendamento.SelectedValue); cpfAgendamento = repH.Buscar(a => a.IdAgendamento == idAgenda).CPF; var agendamento = repH.Buscar(a => a.CPF == cpfAgendamento && a.codstatus == 1); if (agendamento != null) { txtCPF.Text = agendamento.CPF; txtDataHoraConsulta.Text = Convert.ToString(agendamento.DataAgenda); //CarregaCRM(string CPF) txtCrm.Text = agendamento.MedicoEspecializacao.CRM; } } else { MessageBox.Show("Por favor selecione um agendamento.", "Cadastro Prontuario", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); cboAgendamento.Focus(); return; } } catch (Exception) { MessageBox.Show("Erro na busca de agendamento", "Cadastro Prontuario", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); throw; } }
private void gdvEnfermeiro_CellClick(object sender, DataGridViewCellEventArgs e) { if (e.RowIndex >= 0) { try { Enfermeiro enf; var repM = new Fiap.Persistencia.Hospital.DAO.Repositorio<Enfermeiro>(true); var coren = gdvEnfermeiro.Rows[e.RowIndex].Cells[0].Value.ToString(); enf = repM.Buscar(coren); CarregaTelaEdit(enf); } catch (Exception) { MessageBox.Show("Erro ao Carregar", "Cadastro Médico", MessageBoxButtons.OK, MessageBoxIcon.Error); } } }
private void btnSalvar_Click(object sender, EventArgs e) { try { Enfermeiro enfermeiro; var repM = new Fiap.Persistencia.Hospital.DAO.Repositorio<Enfermeiro>(); if (txtCoren.IsEmpty() || !txtCoren.Text.IsNumeric()) { MessageBox.Show("Por favor digite um Coren válido", "Cadastro Enfermeiro", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); txtCoren.Focus(); return; } enfermeiro = repM.Buscar(txtCoren.Text); if (enfermeiro == null) { enfermeiro = new Enfermeiro(); enfermeiro.Coren = txtCoren.Text; if (txtNome.IsEmpty()) { MessageBox.Show("Por favor digite um Nome", "Cadastro Enfermeiro", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); txtNome.Focus(); return; } else enfermeiro.Nome = txtNome.Text; ; if (txtCPF.IsEmpty()) { MessageBox.Show("Por favor digite um email", "Cadastro Enfermeiro", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); txtCPF.Focus(); return; } else { if (Valida.IsCpf(txtCPF.Text)) enfermeiro.CPF = txtCPF.Text; else { MessageBox.Show("Por favor digite um CPF válido", "Cadastro Enfermeiro", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); txtCPF.Focus(); return; } } enfermeiro.DatInc = DateTime.Now; repM.Adicionar(enfermeiro); } else { if (txtNome.IsEmpty()) { MessageBox.Show("Por favor digite um Nome", "Cadastro Enfermeiro", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); txtNome.Focus(); return; } else enfermeiro.Nome = txtNome.Text; if (txtCPF.IsEmpty()) { MessageBox.Show("Por favor digite um email", "Cadastro Enfermeiro", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); txtCPF.Focus(); return; } else { if (Valida.IsCpf(txtCPF.Text)) enfermeiro.CPF = txtCPF.Text; else { MessageBox.Show("Por favor digite um CPF válido", "Cadastro Enfermeiro", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); txtCPF.Focus(); return; } } } repM.Salvar(); if (gdvEnfermeiro.SelectedRows.Count == 0 && txtCoren.Enabled) { MessageBox.Show(string.Format("Enfermeiro {0} adicionado com sucesso", enfermeiro.Nome)); gdvEnfermeiro.DataSource = repM.Listar() .OrderByDescending(x => x.DatInc) .Take(10) .Select(x => new { x.Coren, x.Nome,x.CPF }) .ToList(); } else { MessageBox.Show(string.Format("Enfermeiro {0} alterado com sucesso", enfermeiro.Nome)); btnConsulta_Click(sender, e); } btnNovo_Click(sender, e); } catch (Exception ex) { MessageBox.Show("Erro ao Salvar", "Cadastro Enfermeiro", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
private void btnSalvar_Click(object sender, EventArgs e) { try { var rep = new Fiap.Persistencia.Hospital.DAO.Repositorio<MaterialMedicamento>(); var material = new MaterialMedicamento(); if (gdvMateriais.SelectedRows.Count > 0) { var id = int.Parse(gdvMateriais.SelectedRows[0].Cells[0].Value.ToString()); material = rep.Buscar(id); } if (material == null) material = new MaterialMedicamento(); if (txtNome.IsEmpty()) { MessageBox.Show("Por favor digite um nome", "Cadastro Materiais e Medicamentos", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); txtNome.Focus(); return; } else material.Nome = txtNome.Text; if (txtSaldo.IsEmpty()) { MessageBox.Show("Por favor digite um Saldo", "Cadastro Materiais e Medicamentos", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); txtSaldo.Focus(); return; } else material.Saldo = Convert.ToInt32(txtSaldo.Text); if (txtValorUnitario.IsEmpty()) { MessageBox.Show("Por favor digite um Valor Unitario", "Cadastro Materiais e Medicamentos", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); txtValorUnitario.Focus(); return; } else { material.ValorUnit = Convert.ToDecimal(txtValorUnitario.Text); } if (cboTipo.SelectedValue.ToString().CInt() > 0) { material.Tipo = short.Parse(cboTipo.SelectedValue.ToString()); //material.TipoMaterialMedicamento = new TipoMaterialMedicamento() //{ // IdTipo = Convert.ToInt16(cboTipo.SelectedValue), // Descricao = cboTipo.Text //}; } else { MessageBox.Show("Por favor selecione um tipo.", "Cadastro Materiais e Medicamentos", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); cboTipo.Focus(); return; } //novo tratamento if (material.IdMaterialMedicamento == 0) { material.DatInc = DateTime.Now; rep.Adicionar(material); } rep.Salvar(); if (gdvMateriais.SelectedRows.Count == 0) MessageBox.Show(string.Format("Material/Medicamento {0} adicionado com sucesso", material.Nome)); else MessageBox.Show(string.Format("Material/Medicamento {0} alterado com sucesso", material.Nome)); gdvMateriais.DataSource = rep.Listar().OrderByDescending(x => x.DatInc) .Take(10) .Select(x => new { ID = x.IdMaterialMedicamento, Material = x.Nome, Tipo = x.TipoMaterialMedicamento.Descricao, x.Saldo, x.ValorUnit, ValorTotal = x.Saldo * x.ValorUnit }) .ToList(); gdvMateriais.ClearSelection(); var txts = this.GetTodosControles(typeof(TextBox)); foreach (var item in txts) { item.Text = ""; item.Enabled = true; } cboTipo.SelectedIndex = 0; } catch (Exception) { MessageBox.Show("Erro ao Salvar", "Cadastro Materiais e Medicamentos", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
private void txtCPF_Leave(object sender, EventArgs e) { if (!string.IsNullOrWhiteSpace(txtCPF.Text)) { var repP = new Fiap.Persistencia.Hospital.DAO.Repositorio<Paciente>(); if (repP.Existe(a => a.CPF.Equals(txtCPF.Text))) { txtNome.Text = repP.Buscar(txtCPF.Text).Nome; } else { MessageBox.Show("CPF: " + txtCPF.Text + " não encontrado", "Cadastro Agendamento", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); txtCPF.Text = ""; txtCPF.Focus(); return; } } }
private void gdvPaciente_CellClick(object sender, DataGridViewCellEventArgs e) { if (e.RowIndex >= 0) { try { Paciente paciente; var repP = new Fiap.Persistencia.Hospital.DAO.Repositorio<Paciente>(); var crm = gdvPaciente.Rows[e.RowIndex].Cells[0].Value.ToString(); paciente = repP.Buscar(crm); if (paciente != null) CarregaTelaEdit(paciente); } catch (Exception ex) { MessageBox.Show("Erro ao Consultar", "Cadastro Paciente", MessageBoxButtons.OK, MessageBoxIcon.Error); } } }
private void CarregaCRM(string CPF) { try { var cpfMedico = CPF; var repL = new Fiap.Persistencia.Hospital.DAO.Repositorio<Medico>(); var medico = repL.Buscar(a => a.CPF.Equals(cpfMedico)); if (medico != null) txtCrm.Text = medico.CRM; } catch (Exception) { MessageBox.Show("Erro ao carregar CRM do medico", "Cadastro prontuario", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
private void CarregaCoren(string CPF) { try { var cpfMedico = CPF; var repL = new Fiap.Persistencia.Hospital.DAO.Repositorio<Enfermeiro>(); var enfer = repL.Buscar(a => a.CPF.Equals(cpfMedico)); if (enfer != null) coren = enfer.Coren; } catch (Exception) { MessageBox.Show("Erro ao carregar CRM do medico", "Cadastro prontuario", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
private void gdvAgendamento_CellClick(object sender, DataGridViewCellEventArgs e) { if (gdvAgendamento.Columns[e.ColumnIndex].Name == "Liberar" && e.RowIndex >= 0) { try { var result = MessageBox.Show("Deseja disponibilizar " + gdvAgendamento.Rows[e.RowIndex].Cells[gdvAgendamento.Columns["Nome"].Index].Value.ToString() + " para a consulta.", "Agendamento", MessageBoxButtons.YesNo, MessageBoxIcon.Question); if (result.ToString() == "Yes") { var rep = new Fiap.Persistencia.Hospital.DAO.Repositorio<AgendamentoPaciente>(); var id = int.Parse(gdvAgendamento.Rows[e.RowIndex].Cells[gdvAgendamento.Columns["IdAgendamento"].Index].Value.ToString()); var agenda = rep.Buscar(id); agenda.codstatus= 1; agenda.dataStatus= DateTime.Now; rep.Salvar(); btnConsulta_Click(sender,e); } } catch (Exception) { MessageBox.Show("Essa especialidade não pode ser excluída", "Especialidade", MessageBoxButtons.OK, MessageBoxIcon.Information); } } }
private void gdvTratamento_CellClick(object sender, DataGridViewCellEventArgs e) { if (e.RowIndex >= 0) { try { Tratamento tratamento; var repM = new Fiap.Persistencia.Hospital.DAO.Repositorio<Tratamento>(); var id = int.Parse(gdvTratamento.Rows[e.RowIndex].Cells[1].Value.ToString()); tratamento = repM.Buscar(id); if (tratamento != null) CarregaTelaEdit(tratamento); } catch (Exception ex) { throw ex; } } }
private void btnSalvar_Click(object sender, EventArgs e) { try { var rep = new Fiap.Persistencia.Hospital.DAO.Repositorio<Tratamento>(); var tratamento = new Tratamento(); if (gdvTratamento.SelectedRows.Count > 0) { var id = int.Parse(gdvTratamento.SelectedRows[0].Cells[1].Value.ToString()); tratamento = rep.Buscar(id); } if (tratamento == null) tratamento = new Tratamento(); if (txtNome.IsEmpty()) { MessageBox.Show("Por favor digite um nome", "Cadastro Tratamento", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); txtNome.Focus(); return; } else tratamento.Nome = txtNome.Text; if (txtValor.IsEmpty()) { MessageBox.Show("Por favor digite um Valor", "Cadastro Tratamento", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); txtValor.Focus(); return; } else tratamento.Valor = Convert.ToDecimal(txtValor.Text); if (cboEspecialidade.SelectedValue != "" && cboEspecialidade.SelectedValue != null) { tratamento.IdEspecialidade = Convert.ToInt32(cboEspecialidade.SelectedValue); //tratamento.Especializacao = new Especializacao() //{ // IdEspecializacao = Convert.ToInt32(cboEspecialidade.SelectedValue), // Nome = cboEspecialidade.Text //}; } else { MessageBox.Show("Por favor selecione um tipo de especialidade.", "Cadastro Tratamento", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); cboEspecialidade.Focus(); return; } //novo tratamento if (tratamento.IdTratamento==0) { tratamento.DatInc = DateTime.Now; rep.Adicionar(tratamento); } rep.Salvar(); MessageBox.Show(string.Format("Tratamento {0} adicionado com sucesso", tratamento.Nome)); gdvTratamento.DataSource = rep.Listar(x=> x.dataExclusao==null) .Take(10) .OrderByDescending(x => x.DatInc) .Select(x => new { Especialização = x.Especializacao.Nome, x.IdTratamento, x.Nome, x.Valor }) .ToList(); gdvTratamento.ClearSelection(); var txts = this.groupBox1.GetTodosControles(typeof(TextBox)); foreach (var item in txts) { item.Text = ""; item.Enabled = true; } } catch (Exception) { MessageBox.Show("Erro ao Salvar", "Cadastro Tratamento", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
private void btnRemove_Click(object sender, EventArgs e) { try { if (gdvEnfermeiro.SelectedRows.Count > 0) { Enfermeiro medico; var repM = new Fiap.Persistencia.Hospital.DAO.Repositorio<Enfermeiro>(); var coren = gdvEnfermeiro.SelectedRows[0].Cells[0].Value.ToString(); medico = repM.Buscar(coren); //if (medico != null) // repM.Remover(medico); medico.dataExclusao = DateTime.Now; repM.Salvar(); btnConsulta_Click(sender, e); gdvEnfermeiro.ClearSelection(); //txtCRM.GetTodosControles(); var txts = groupBox1.GetTodosControles(typeof(TextBox)); foreach (var item in txts) { item.Text = ""; item.Enabled = true; } txtCoren.Focus(); } } catch (Exception) { MessageBox.Show("Esse médico não pode ser excluído pois possui atividades cadastradas", "Cadastro Médico", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
private void btnSalvar_Click(object sender, EventArgs e) { try { Paciente paciente; var repP = new Fiap.Persistencia.Hospital.DAO.Repositorio<Paciente>(); if (txtCPF.IsEmpty()) { MessageBox.Show("Por favor digite um email", "Cadastro Médico", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); txtCPF.Focus(); return; } else { if (!Valida.IsCpf(txtCPF.Text)) { MessageBox.Show("Por favor digite um CPF válido", "Cadastro Médico", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); txtCPF.Focus(); return; } } paciente = repP.Buscar(txtCPF.Text); if (paciente == null) { paciente = new Paciente(); paciente.CPF = txtCPF.Text; if (txtNome.IsEmpty()) { MessageBox.Show("Por favor digite um Nome", "Cadastro Médico", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); txtNome.Focus(); return; } else paciente.Nome = txtNome.Text; paciente.Endereco = txtEndereco.Text; paciente.Numero = txtNumero.Text; paciente.Cep = txtCEP.Text; paciente.Uf = txtUf.Text; paciente.Cidade = txtCidade.Text; paciente.Telefone = txtTelefone.Text; paciente.TelefoneCelular = txtCelular.Text; paciente.DatInc = DateTime.Now; repP.Adicionar(paciente); } else { if (txtNome.IsEmpty()) { MessageBox.Show("Por favor digite um Nome", "Cadastro Médico", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); txtNome.Focus(); return; } else paciente.Nome = txtNome.Text; paciente.Endereco = txtEndereco.Text; paciente.Numero = txtNumero.Text; paciente.Cep = txtCEP.Text; paciente.Uf = txtUf.Text; paciente.Cidade = txtCidade.Text; paciente.Telefone = txtTelefone.Text; paciente.TelefoneCelular = txtCelular.Text; } repP.Salvar(); if (gdvPaciente.SelectedRows.Count == 0 && txtCPF.Enabled) { MessageBox.Show(string.Format("Paciente {0} adicionado com sucesso", paciente.Nome)); gdvPaciente.DataSource = repP.Listar(x => x.dataExclusao == null) .OrderByDescending(x => x.DatInc) .Take(10) .Select(x => new { x.CPF, x.Nome, x.Cep, x.Uf, x.Cidade, x.Endereco, x.Telefone }) .ToList(); } else { MessageBox.Show(string.Format("Médico {0} alterado com sucesso", paciente.Nome)); btnConsulta_Click(sender, e); } var txts = this.GetTodosControles(typeof(TextBox)); foreach (var item in txts) { item.Text = ""; } } catch (Exception) { MessageBox.Show("Erro ao Salvar", "Cadastro Paciente", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
private void btnSalvar_Click(object sender, EventArgs e) { try { Prontuario prontuario = new Prontuario(); var repM = new Fiap.Persistencia.Hospital.DAO.Repositorio<Prontuario>(); if (txtCPF.IsEmpty() || txtDataHoraConsulta.IsEmpty()) { MessageBox.Show("Por favor escolha um agendamento e clique em buscar", "Cadastro Prontuario", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); txtCPF.Focus(); return; } else prontuario.CPF = txtCPF.Text; if (txtCrm.IsEmpty()) { MessageBox.Show("Erro ao buscar o CRM do médico", "Cadastro Prontuario", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); txtCrm.Focus(); return; } else prontuario.CRM = txtCrm.Text; if (coren != "") { prontuario.Coren = coren; coren=""; } if (cboTratamento.SelectedValue.ToString() != "0") { prontuario.IdTratamento = Convert.ToInt32(cboTratamento.SelectedValue.ToString()); //prontuario.Tratamento = new Tratamento() //{ // IdTratamento = Convert.ToInt32(cboTratamento.SelectedValue.ToString()) //}; } else { MessageBox.Show("Por favor selecione um tipo de tratamento.", "Cadastro Prontuario", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); cboTratamento.Focus(); return; } if (txtDescricao.IsEmpty()) { MessageBox.Show("Por favor digite uma Descrição", "Cadastro Prontuario", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); txtDescricao.Focus(); return; } else prontuario.Descricao = txtDescricao.Text; prontuario.DatInc = DateTime.Now; if (ckcListaMedicamentos.CheckedItems.Count > 0) { prontuario.ProntuarioMaterialMedicamento = new List<ProntuarioMaterialMedicamento>(); foreach (MaterialMedicamento item in ckcListaMedicamentos.CheckedItems) { prontuario.ProntuarioMaterialMedicamento.Add( new ProntuarioMaterialMedicamento() { IdMaterialMedicamento = item.IdMaterialMedicamento }); } } var idAgendamento = cboAgendamento.SelectedValue.ToString().CInt(); prontuario.IdAgendamento = idAgendamento; var repA = new Fiap.Persistencia.Hospital.DAO.Repositorio<AgendamentoPaciente>(); var agendamento = repA.Buscar(idAgendamento); agendamento.codstatus = 3; agendamento.dataStatus = DateTime.Now; repA.Salvar(); //repA.Dispose(); repM.Adicionar(prontuario); repM.Salvar(); repM.Dispose(); MessageBox.Show("Prontuario Cadastrado com sucesso.", "Cadastro Prontuario", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); this.Close(); } catch (Exception) { MessageBox.Show("Erro no Cadastro de prontuario", "Cadastro Prontuario", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); throw; } }
private void txtCPF_Validated(object sender, EventArgs e) { try { if (txtCPF.IsEmpty(true)) { Paciente paciente; var repP = new Fiap.Persistencia.Hospital.DAO.Repositorio<Paciente>(true); var crm = txtCPF.Text; paciente = repP.Buscar(crm); if (paciente != null) CarregaTelaEdit(paciente); } } catch (Exception) { MessageBox.Show("Erro ao Consultar CPF", "Cadastro Paciente", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
private void btnSalvar_Click(object sender, EventArgs e) { try { var rep = new Fiap.Persistencia.Hospital.DAO.Repositorio<Convenio>(); Convenio convenio = new Convenio(); if (gdvConvenio.SelectedRows.Count > 0) { var id = gdvConvenio.SelectedRows[0].Cells[0].Value.ToString().CInt(); convenio = rep.Buscar(id); if (convenio == null) { MessageBox.Show("O elemento seleciona não foi encontrado", "Cadastro convênio", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); return; } } if (txtOperadora.IsEmpty()) { MessageBox.Show("Por favor digite uma operadora", "Cadastro Convenio", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); txtOperadora.Focus(); return; } else convenio.Operadora = txtOperadora.Text; if (cboAcomodacao.SelectedIndex <= 0) { MessageBox.Show("Por favor selecione uma acomodação", "Cadastro Convenio", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); cboAcomodacao.Focus(); return; } else convenio.Acomodacao = cboAcomodacao.Text; if (txtPlano.IsEmpty()) { MessageBox.Show("Por favor digite um plano", "Cadastro Convenio", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); txtPlano.Focus(); return; } else convenio.Plano = txtPlano.Text; if (txtDesconto.IsEmpty()) { MessageBox.Show("Por favor digite o desconto do Convênio", "Cadastro Convenio", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); txtDesconto.Focus(); return; } else convenio.Desconto = decimal.Parse(txtDesconto.Text); convenio.TelefoneOperadora = txtTelefone.Text; if (convenio.IdConvenio == 0) rep.Adicionar(convenio); rep.Salvar(); if (gdvConvenio.SelectedRows.Count > 0) MessageBox.Show(string.Format("Convenio {0} adicionado com sucesso", convenio.Operadora)); else MessageBox.Show(string.Format("Convenio {0} alterado com sucesso", convenio.Operadora)); gdvConvenio.DataSource = rep.Listar().OrderByDescending(x => x.IdConvenio) .Take(10) .Select(x => new { x.IdConvenio, x.Operadora, x.Plano, x.Acomodacao, x.Desconto }) .ToList(); gdvConvenio.ClearSelection(); var txts = this.GetTodosControles(typeof(TextBox)); foreach (var item in txts) { item.Text = ""; item.Enabled=true; } cboAcomodacao.SelectedIndex = 0; } catch (Exception) { MessageBox.Show("Erro ao salvar convenio", "Cadastro Convênio", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
private void gdvEspecializacao_CellClick(object sender, DataGridViewCellEventArgs e) { if (e.ColumnIndex == 0 && e.RowIndex >= 0) { try { var result = MessageBox.Show("Deseja remover a Espcialidade " + gdvEspecializacao.Rows[e.RowIndex].Cells[2].Value.ToString(), "Especialidade", MessageBoxButtons.YesNo, MessageBoxIcon.Question); if (result.ToString() == "Yes") { var rep = new Fiap.Persistencia.Hospital.DAO.Repositorio<Especializacao>(); var id = int.Parse(gdvEspecializacao.Rows[e.RowIndex].Cells[1].Value.ToString()); rep.Remover(rep.Buscar(id)); rep.Salvar(); gdvEspecializacao.DataSource = rep.Listar().Select(x => new { x.IdEspecializacao, x.Nome }).ToList(); } } catch (Exception) { MessageBox.Show("Essa especialidade não pode ser excluída","Especialidade",MessageBoxButtons.OK,MessageBoxIcon.Information); } } }
private void gdvConvenio_CellClick(object sender, DataGridViewCellEventArgs e) { if (e.RowIndex >= 0) { try { Convenio medico; var rep = new Fiap.Persistencia.Hospital.DAO.Repositorio<Convenio>(); var id = gdvConvenio.Rows[e.RowIndex].Cells[0].Value.ToString().CInt(); medico = rep.Buscar(id); CarregaTelaEdit(medico); } catch (Exception ex) { throw ex; } } }
private void btnSalvar_Click(object sender, EventArgs e) { try { AgendamentoPaciente ag = new AgendamentoPaciente(); var rep = new Fiap.Persistencia.Hospital.DAO.Repositorio<AgendamentoPaciente>(true); if (txtCPF.IsEmpty()) { MessageBox.Show("Por favor digite um CPF válido", "Cadastro Agendamento", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); txtCPF.Focus(); return; } else ag.CPF = txtCPF.Text; if (cboConvenio.SelectedValue.ToString() == "0") { MessageBox.Show("Por favor escolha um convênio", "Cadastro Agendamento", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); txtCPF.Focus(); return; } else ag.IdConvenio = cboConvenio.SelectedValue.ToString().CInt(); if (cboMedicoEspecialidade.SelectedValue == null) { MessageBox.Show("Por favor escolha uma especialização", "Cadastro Agendamento", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); txtCPF.Focus(); return; } else { if (cboMedicoEspecialidade.SelectedValue.ToString() != "0") { ag.IdMedicoEspecializacao = cboMedicoEspecialidade.SelectedValue.ToString().CInt(); } else { MessageBox.Show("Por favor escolha um medico", "Cadastro Agendamento", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); txtCPF.Focus(); return; } } var date = DateTime.Parse(dtAgenda.Text); if (date < DateTime.Now.AddMinutes(-1)) { MessageBox.Show("A data de agendamento menor que a data atual.", "Cadastro Agendamento", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); dtAgenda.Focus(); return; } ag.DataAgenda = date; ag.DatInc = DateTime.Now; ag.codstatus = 0; ag.dataStatus=DateTime.Now; var idmedicoespecialidade = cboMedicoEspecialidade.SelectedValue.ToString().CInt(); var verificaAgenda = rep.Buscar(x => x.IdMedicoEspecializacao == idmedicoespecialidade); if (verificaAgenda != null) { var crm = verificaAgenda.MedicoEspecializacao.CRM; var dataFinal = date.AddMinutes(30); verificaAgenda = rep.Buscar(x => x.DataAgenda >= date && x.DataAgenda <= dataFinal && x.MedicoEspecializacao.CRM == crm); } if (verificaAgenda == null) { rep.Adicionar(ag); rep.Salvar(); rep.Dispose(); MessageBox.Show("Agendamento Cadastrado com sucesso.", "Cadastro Agendamento", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); this.Close(); } else { MessageBox.Show("Já existe um agendamento nessa data e hora com esse médico.", "Cadastro Agendamento", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); } } catch (Exception) { MessageBox.Show("Erro no cadastro de agendamento", "Cadastro Agendamento", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); } }
private void gdvMateriais_CellClick(object sender, DataGridViewCellEventArgs e) { if ( e.RowIndex >= 0) { try { MaterialMedicamento material; var repM = new Fiap.Persistencia.Hospital.DAO.Repositorio<MaterialMedicamento>(); var id = int.Parse(gdvMateriais.Rows[e.RowIndex].Cells[0].Value.ToString()); material = repM.Buscar(id); if (material != null) CarregaTelaEdit(material); } catch (Exception) { MessageBox.Show("Erro ao", "Cadastro Materiais e Medicamentos", MessageBoxButtons.OK, MessageBoxIcon.Error); } } }