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 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 btnConsulta_Click(object sender, EventArgs e) { try { var rep = new Fiap.Persistencia.Hospital.DAO.Repositorio<Convenio>(); if (txtConsultaOperadora.IsEmpty(true)) { gdvConvenio.DataSource = rep.Listar() .Where(x => x.Operadora.Contains(txtConsultaOperadora.Text) && x.dataExclusao==null) .OrderByDescending(x => x.IdConvenio) .Select(x => new { x.IdConvenio, x.Operadora , x.Plano, x.Acomodacao, x.Desconto}) .ToList(); } else gdvConvenio.DataSource = rep.Listar(x=> x.dataExclusao==null) .OrderByDescending(x => x.IdConvenio) .Take(10) .Select(x => new { x.IdConvenio, x.Operadora, x.Plano, x.Acomodacao, x.Desconto }) .ToList(); gdvConvenio.ClearSelection(); } catch (Exception) { MessageBox.Show("Erro ao Consultar", "Cadastro Convênio", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
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 btnSalvar_Click(object sender, EventArgs e) { try { Especializacao esp = new Especializacao(); if (txtEspecialização.IsEmpty()) { MessageBox.Show("Por favor digite uma especialização", "Cadastro Especialização", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); txtEspecialização.Focus(); return; } else esp.Nome = txtEspecialização.Text; var rep = new Fiap.Persistencia.Hospital.DAO.Repositorio<Especializacao>(); rep.Adicionar(esp); rep.Salvar(); MessageBox.Show(string.Format("A especialização {0} \n\t adicionado com sucesso", esp.Nome)); gdvEspecializacao.DataSource = rep.Listar().Select(x => new { x.IdEspecializacao, x.Nome }).ToList(); var txts = this.GetTodosControles(typeof(TextBox)); foreach (var item in txts) { item.Text = ""; } } catch (Exception) { MessageBox.Show("Erro ao Salvar", "Cadastro Especialização", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
private void CarregaCombos() { try { var repA = new Fiap.Persistencia.Hospital.DAO.Repositorio<AgendamentoPaciente>(true); var agendamento = repA.Listar(a => a.codstatus == 1) .Select(x => new { x.IdAgendamento, Nome = x.Paciente.Nome, x.DataAgenda }) .ToList(); var agenda = agendamento.Select(x => new { x.IdAgendamento, Descricao = x.DataAgenda.ToString("dd/MM/yyyy") + " - " + x.Nome }).ToList(); agenda.Insert(0, new { IdAgendamento = 0, Descricao = "Selecione" }); cboAgendamento.Carrega(agenda.OrderBy(x => x.IdAgendamento).ToList(), "Descricao", "IdAgendamento"); repA.Dispose(); cboAgendamento.SelectedIndex = 0; } catch (Exception) { MessageBox.Show("Erro ao carregar combo de Agendamentos", "Cadastro prontuario", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
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 btnConsulta_Click(object sender, EventArgs e) { var rep = new Fiap.Persistencia.Hospital.DAO.Repositorio<Tratamento>(); try { IQueryable<Tratamento> query = rep.Listar(x=> x.dataExclusao==null); if (cboConsultaEspecialidade.SelectedValue.ToString() != "") { int id = int.Parse(cboConsultaEspecialidade.SelectedValue.ToString()); query = query.Where(x => x.IdEspecialidade == id); } if (txtConsultaNome.Text != "") query = query.Where(x => x.Nome.Contains(txtConsultaNome.Text)); gdvTratamento.DataSource = query.OrderByDescending(x => x.DatInc) .Select(x => new { Especialização = x.Especializacao.Nome, x.IdTratamento, x.Nome, x.Valor }) .ToList(); gdvTratamento.ClearSelection(); } catch (Exception) { throw; } }
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 btnConsulta_Click(object sender, EventArgs e) { try { var repM = new Fiap.Persistencia.Hospital.DAO.Repositorio<Paciente>(); if (txtConsultaCPF.IsEmpty(true)) { gdvPaciente.DataSource = repM.Listar(x=> x.dataExclusao==null) .Where(x => x.CPF == txtConsultaCPF.Text) .OrderByDescending(x => x.DatInc) .Select(x => new { x.CPF, x.Nome, x.Cep, x.Uf, x.Cidade, x.Endereco, x.Telefone }) .ToList(); } else if (txtConsultaNome.IsEmpty(true)) gdvPaciente.DataSource = repM.Listar(x => x.dataExclusao == null) .Where(x => x.Nome.Contains(txtConsultaNome.Text.ToString())) .OrderByDescending(x => x.DatInc) .Select(x => new { x.CPF, x.Nome, x.Cep, x.Uf, x.Cidade, x.Endereco, x.Telefone }) .ToList(); else gdvPaciente.DataSource = repM.Listar(x => x.dataExclusao == null) .OrderByDescending(x => x.DatInc) .Select(x => new { x.CPF, x.Nome, x.Cep, x.Uf, x.Cidade, x.Endereco, x.Telefone }) .ToList(); } catch (Exception) { MessageBox.Show("Erro ao Consultar", "Cadastro Paciente", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
private void btnConsulta_Click(object sender, EventArgs e) { try { var repM = new Fiap.Persistencia.Hospital.DAO.Repositorio<Enfermeiro>(); if (txtConsultaCoren.IsEmpty(true)) { gdvEnfermeiro.DataSource = repM.Listar(x => x.dataExclusao == null) .Where(x => x.Coren == txtConsultaCoren.Text) .OrderByDescending(x => x.DatInc) .Select(x => new { x.Coren, x.Nome, x.CPF }) .ToList(); } else if (txtConsultaNome.IsEmpty(true)) gdvEnfermeiro.DataSource = repM.Listar(x => x.dataExclusao == null) .Where(x => x.Nome.Contains(txtConsultaNome.Text.ToString())) .OrderByDescending(x => x.DatInc) .Select(x => new { x.Coren, x.Nome, x.CPF }) .ToList(); else gdvEnfermeiro.DataSource = repM.Listar(x => x.dataExclusao == null) .OrderByDescending(x => x.DatInc) .Take(10) .Select(x => new { x.Coren, x.Nome, x.CPF }) .ToList(); gdvEnfermeiro.ClearSelection(); } catch (Exception) { MessageBox.Show("Erro ao Consultar", "Cadastro Enfermeiro", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
private void btnConsulta_Click(object sender, EventArgs e) { try { var repM = new Fiap.Persistencia.Hospital.DAO.Repositorio<AgendamentoPaciente>(); var lista = repM.Listar(x=> x.codstatus==0); if (!txtCPF.IsEmpty()) { lista = lista.Where(x => x.CPF == txtCPF.Text); } else { var dataInicial = DateTime.Parse(dtAgendaInicial.Text); var dataFinal= DateTime.Parse(dtAgendaFinal.Text); lista = lista.Where(x => x.DataAgenda >= dataInicial && x.DataAgenda<= dataFinal); var idConvenio = cboConvenio.SelectedValue.ToString().CInt(); if (idConvenio > 0) { lista = lista.Where(x => x.IdConvenio == idConvenio); } if (!txtNome.IsEmpty()) { lista = lista.Where(x => x.Paciente.Nome.Contains(txtCPF.Text)); } var idMediEsp = cboMedicoEspecialidade.SelectedValue.ToString().CInt(); if (idMediEsp > 0) { lista = lista.Where(x => x.IdMedicoEspecializacao == idMediEsp); } } gdvAgendamento.DataSource = lista.Select(x => new { x.IdAgendamento, x.Paciente.Nome, x.DataAgenda, Medico = x.MedicoEspecializacao.Medico.Nome, Especialide=x.MedicoEspecializacao.Especializacao.Nome, Convenio=x.Convenio.Operadora + "-"+x.Convenio.Plano + "-" + x.Convenio.Acomodacao }) .OrderBy(x=> x.DataAgenda) .ToList(); gdvAgendamento.ClearSelection(); } catch (Exception) { MessageBox.Show("Erro ao Consultar", "Cadastro Médico", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
private void btnConsulta_Click(object sender, EventArgs e) { try { var rep = new Fiap.Persistencia.Hospital.DAO.Repositorio<Prontuario>(); var dataInicial = DateTime.Parse(dtInicial.Text); var dataFinal = DateTime.Parse(dtFinal.Text); var faturamento =rep.Listar(x => x.DatInc >= dataInicial && x.DatInc <= dataFinal); var idConvenio =cboConvenio.SelectedValue.ToString().CInt(); if (idConvenio > 0) { faturamento = faturamento.Where(x => x.AgendamentoPaciente.IdConvenio == idConvenio); } else if (cboMedico.SelectedValue.ToString() != "") { faturamento= faturamento.Where(x=> x.CRM==cboMedico.SelectedValue.ToString()); } var result = faturamento.Select(x => new { Médico = x.AgendamentoPaciente.MedicoEspecializacao.Medico.Nome, Tratamento = x.Tratamento.Nome, Convênio = x.AgendamentoPaciente.Convenio.Operadora + " - " + x.AgendamentoPaciente.Convenio.Plano + " - " + x.AgendamentoPaciente.Convenio.Acomodacao, Desconto =x.AgendamentoPaciente.Convenio.Desconto, Valor = x.Tratamento.Valor * (1 - x.AgendamentoPaciente.Convenio.Desconto/100), valorMaterial = x.ProntuarioMaterialMedicamento.Sum(y=> y.MaterialMedicamento.ValorUnit), Total = x.Tratamento.Valor * (1 - x.AgendamentoPaciente.Convenio.Desconto / 100) + x.ProntuarioMaterialMedicamento.Sum(y => y.MaterialMedicamento.ValorUnit) }).ToList(); gdvFaturamento.DataSource = result; } catch (Exception ex) { MessageBox.Show(ex.Message); } }
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 CarregaCombos() { try { var repC = new Fiap.Persistencia.Hospital.DAO.Repositorio<Convenio>(); var convenio = repC.Listar() .Select(x => new { x.IdConvenio, Descricao = x.Operadora + " - " + x.Plano + " - " + x.Acomodacao }) .OrderBy(x => x.Descricao) .ToList(); convenio.Insert(0, new { IdConvenio = 0, Descricao = "Selecione" }); cboConvenio.Carrega(convenio.OrderBy(x => x.IdConvenio).ToList(), "Descricao", "IdConvenio"); repC.Dispose(); cboConvenio.SelectedIndex = 0; //_____________________ var repE = new Fiap.Persistencia.Hospital.DAO.Repositorio<Medico>(); var esp = repE.Listar() .OrderBy(x => x.Nome) .Select(x => new { x.CRM, Descricao = x.Nome }) .ToList(); esp.Insert(0, new { CRM = "", Descricao = "Selecione" }); cboMedico.Carrega(esp, "Descricao", "CRM"); repE.Dispose(); cboMedico.SelectedIndex = 0; } catch (Exception) { MessageBox.Show("Erro ao carregar combo", "Cadastro agenda", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
private void btnConsulta_Click(object sender, EventArgs e) { var rep = new Fiap.Persistencia.Hospital.DAO.Repositorio<MaterialMedicamento>(); try { IQueryable<MaterialMedicamento> query = rep.Listar(); if (cboConsultaTipo.SelectedValue.ToString().CInt() > 0) { int id = short.Parse(cboConsultaTipo.SelectedValue.ToString()); query = query.Where(x => x.Tipo == id); } if (txtConsultaMaterial.Text != "") query = query.Where(x => x.Nome.Contains(txtConsultaMaterial.Text)); gdvMateriais.DataSource = query.OrderByDescending(x => x.DatInc) .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(); } catch (Exception) { MessageBox.Show("Erro ao consultar", "Cadastro Materiais e Medicamentos", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
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 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 cboEspecialidade_SelectedIndexChanged(object sender, EventArgs e) { try { int id = Convert.ToString(cboEspecialidade.SelectedValue).CInt(); if (id > 0) { var repE = new Fiap.Persistencia.Hospital.DAO.Repositorio<MedicoEspecializacao>(true); var esp = repE.Listar(x => x.IdEspecializacao == id) .OrderBy(x => x.Medico.Nome) .Select(x => new { x.IdMedicoEspecializacao, Descricao = x.Medico.Nome }) .ToList(); if (esp != null) { esp.Insert(0, new { IdMedicoEspecializacao = 0, Descricao = "Selecione" }); cboMedicoEspecialidade.Carrega(esp, "Descricao", "IdMedicoEspecializacao"); } } } catch (Exception) { MessageBox.Show("Erro ao carregar encontrado", "Cadastro Agendamento", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); } }
private void CarregaCombos() { try { var repC = new Fiap.Persistencia.Hospital.DAO.Repositorio<Convenio>(); var convenio = repC.Listar(x=> x.dataExclusao==null) .Select(x => new { x.IdConvenio, Descricao = x.Operadora + " - " + x.Plano + " - " + x.Acomodacao }) .OrderBy(x => x.Descricao) .ToList(); convenio.Insert(0, new { IdConvenio = 0, Descricao = "Selecione" }); cboConvenio.Carrega(convenio.OrderBy(x => x.IdConvenio).ToList(), "Descricao", "IdConvenio"); repC.Dispose(); cboConvenio.SelectedIndex = 0; //_____________________ cboEspecialidade.SelectedIndexChanged -= cboEspecialidade_SelectedIndexChanged; var repE = new Fiap.Persistencia.Hospital.DAO.Repositorio<Especializacao>(); var esp = repE.Listar(x => x.dataExclusao == null) .OrderBy(x => x.IdEspecializacao) .Select(x => new { x.IdEspecializacao, Descricao = x.Nome }) .ToList(); esp.Insert(0, new { IdEspecializacao = 0, Descricao = "Selecione" }); cboEspecialidade.Carrega(esp, "Descricao", "IdEspecializacao"); repE.Dispose(); cboEspecialidade.SelectedIndex = 0; cboEspecialidade.SelectedIndexChanged += cboEspecialidade_SelectedIndexChanged; } catch (Exception) { MessageBox.Show("Erro ao carregar combo", "Cadastro agenda", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
private void CarregaGrid() { var rep = new Fiap.Persistencia.Hospital.DAO.Repositorio<Especializacao>(); gdvEspecializacao.DataSource = rep.Listar().Select(x => new { x.IdEspecializacao, x.Nome }).ToList(); }
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 { 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 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 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 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); } }
/// <summary> /// Carregas the tipo. /// </summary> private void CarregaTipo() { try { var rep = new Fiap.Persistencia.Hospital.DAO.Repositorio<TipoAcesso>(); var dados = rep.Listar().ToList(); cboTipo.Carrega(dados, "Descricao", "IdTipoAcesso"); } catch (Exception) { MessageBox.Show("Por favor digite uma senha válida ou confirme", "Cadastro Usuário", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); } }
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 { var usuario = new Usuario(); if (txtNome.IsEmpty()) { MessageBox.Show("Por favor digite um nome", "Cadastro Usuário", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); txtNome.Focus(); return; } else usuario.Nome = txtNome.Text; if (txtLogin.IsEmpty()) { MessageBox.Show("Por favor digite um Login", "Cadastro Usuário", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); txtLogin.Focus(); return; } else usuario.Login = txtLogin.Text; if (txtEmail.IsEmpty()) { MessageBox.Show("Por favor digite um email", "Cadastro Usuário", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); txtEmail.Focus(); return; } else { if (txtEmail.Text.RegexValida(@"\w+([-+.']\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*")) usuario.Email = txtEmail.Text; else { MessageBox.Show("Por favor digite um email válido", "Cadastro Usuário", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); txtEmail.Focus(); return; } } if (txtCPF.IsEmpty()) { MessageBox.Show("Por favor digite um CPF", "Cadastro Usuário", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); txtCPF.Focus(); return; } else { if (Valida.IsCpf(txtCPF.Text)) usuario.CPF = txtCPF.Text; else { MessageBox.Show("Por favor digite um cpf válido", "Cadastro Usuário", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); txtCPF.Focus(); return; } } if (cboTipo.SelectedValue.ToString() != "") { usuario.TipoAcesso =short.Parse(cboTipo.SelectedValue.ToString()); } else { MessageBox.Show("Por favor selecione o tipo.","Cadastro Usuário", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); cboTipo.Focus(); return; } if (!txtSenha.IsEmpty() && (txtSenha.Text == txtCsenha.Text)) usuario.Senha = txtSenha.Text; else { MessageBox.Show("Por favor digite uma senha válida ou confirme", "Cadastro Usuário", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); return; } var rep = new Fiap.Persistencia.Hospital.DAO.Repositorio<Usuario>(); rep.Adicionar(usuario); rep.Salvar(); MessageBox.Show(string.Format("Usuário {0} adicionado com sucesso", usuario.Nome)); this.Close(); } catch (Exception) { MessageBox.Show("Erro ao Salvar", "Cadastro Usuário", 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); } }