} // fim Excluir /* Atualização do cadastro do paciente */ public static bool Alterar(dto_cad_paciente paciente) { AcessoBancoDados bd; bool resultado = false; try { bd = AcessoBancoDados.GetInstance; bd.conectar(); string comando = "update paciente set NOME= '" + paciente.Nome + "', CPF= '" + paciente.CPF + "', GENERO= '" + paciente.Genero + "', DATA_NASCIMENTO = '" + (paciente.DataNascimento).ToString("yyyy-MM-dd H:mm:ss") + "', Cidade_id = " + paciente.Cidade + " where Id = " + paciente.Codigo; bd.ExecutarComandoSQL(comando); resultado = true; } catch (Exception ex) { MessageBox.Show("Erro ao alterar o cadastro do paciente! \n" + Convert.ToString(ex), "Erro na operação de cancelamento!", MessageBoxButtons.OK); } // fim catch excluir bd = null; return(resultado); }
public static dto_cad_paciente Selecionar(string cpf) { dto_cad_paciente paciente = null; AcessoBancoDados bd; try { bd = AcessoBancoDados.GetInstance; bd.conectar(); string comando = $"Select * from Paciente Where CPF = '{cpf}'"; var dtPaciente = bd.RetDataTable(comando); foreach (DataRow linha in dtPaciente.Rows) { paciente = new dto_cad_paciente(); paciente.Codigo = Convert.ToInt32(linha["Id"]); paciente.Nome = linha["Nome"].ToString(); paciente.CPF = linha["CPF"].ToString(); paciente.DataNascimento = Convert.ToDateTime(linha["DATA_NASCIMENTO"].ToString()); paciente.Genero = Convert.ToChar(linha["GENERO"].ToString()); paciente.Cidade = Convert.ToInt32(linha["Cidade_id"]); } } catch (Exception ex) { throw new Exception("Erro ao Selecionar o Paciente!" + ex.Message); } bd = null; return(paciente); }
public static bool SelecionarObito(dto_cad_paciente paciente) { var resultado = false; AcessoBancoDados bd; try { bd = AcessoBancoDados.GetInstance; bd.conectar(); string comando = $@"Select * from internacao Where Paciente_Id = {paciente.Codigo} and Situacao = 'O' Order By Id desc Limit 1"; var dtInternacao = bd.RetDataTable(comando); resultado = dtInternacao.Rows.Count > 0; } catch (Exception ex) { MessageBox.Show("Erro ao selecionar a internacao do paciente! \n" + Convert.ToString(ex), "Erro na operação de seleção!", MessageBoxButtons.OK); } bd = null; return(resultado); }
private void dgvPaciente_DoubleClick(object sender, EventArgs e) { if (dgvPaciente.Rows.Count > 0) { string cpf = dgvPaciente.CurrentRow.Cells["CPF"].Value.ToString(); Paciente = bll_cad_paciente.Selecionar(cpf); DialogResult = DialogResult.OK; this.Close(); } }
private void LimparTela() { edtNome.Text = ""; edtCPF.Text = ""; cbGenero.SelectedIndex = 0; dtNascimento.Value = DateTime.Now.Date; edtNomeCidade.Text = ""; Paciente = null; Cidade = null; }
private void AtualizarDadosPaciente() { if (Paciente == null) { Paciente = new dto_cad_paciente(); } Paciente.Nome = edtNome.Text; Paciente.CPF = edtCPF.Text; Paciente.DataNascimento = dtNascimento.Value.Date; Paciente.Genero = Convert.ToChar(cbGenero.Text.Substring(0, 1)); Paciente.Cidade = Cidade.Codigo; }
private void LocalizarPaciente(string cpf) { dto_cad_paciente paciente = null; if (String.IsNullOrEmpty(cpf)) { form_loc_paciente frmLocPaciente = new form_loc_paciente(); frmLocPaciente.ShowDialog(); if (frmLocPaciente.DialogResult == DialogResult.OK) { paciente = frmLocPaciente.Paciente; } else { return; } } else { paciente = bll_cad_paciente.Selecionar(cpf); } if (paciente == null) { MessageBox.Show("Não foi Possível Localizar o Paciente!", "Aviso", MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } else { edtNome.Text = paciente.Nome; edtCPF.Text = paciente.CPF; switch (paciente.Genero) { case 'M': cbGenero.SelectedIndex = 0; break; case 'F': cbGenero.SelectedIndex = 1; break; case 'O': cbGenero.SelectedIndex = 2; break; case 'N': cbGenero.SelectedIndex = 3; break; default: cbGenero.SelectedIndex = 0; break; } dtNascimento.Value = paciente.DataNascimento; Cidade = bll_cad_cidade.Selecionar(paciente.Cidade); edtNomeCidade.Text = Cidade.Nome; Paciente = paciente; } }
private void LimparTela() { edtCPF.Text = ""; lbNome.Text = ""; edtCidade.Text = ""; lbSituacao.Text = ""; rbNormal.Checked = true; rbUTI.Checked = false; Paciente = null; Cidade = null; Internacao = null; Leito = null; cbMotivoLiberacao.SelectedIndex = 0; cbMotivoLiberacao.Visible = false; lbMotivoLiberacao.Visible = false; btnConfirmar.Enabled = false; DtHospitaisLeitos.Rows.Clear(); }
private void LocalizarPaciente(string cpf) { dto_cad_paciente paciente = null; if (String.IsNullOrEmpty(cpf)) { form_loc_paciente frmLocPaciente = new form_loc_paciente(); frmLocPaciente.ShowDialog(); if (frmLocPaciente.DialogResult == DialogResult.OK) { paciente = frmLocPaciente.Paciente; edtCPF.Text = paciente.CPF; } else { return; } } else { paciente = bll_cad_paciente.Selecionar(cpf); } if (paciente == null) { MessageBox.Show("Não foi Possível Localizar o Paciente!", "Aviso", MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } if (bll_cad_internacao.SelecionarObito(paciente)) { MessageBox.Show("O paciente informado possui um óbito, o mesmo não pode ser carregado! Selecione outro paciente.", "Aviso", MessageBoxButtons.OK, MessageBoxIcon.Warning); LimparTela(); edtCPF.Focus(); return; } Paciente = paciente; CarregarInternacao(); PreencherTela(); }
public static dto_cad_internacao SelecionarInternacaoPaciente(dto_cad_paciente paciente) { dto_cad_internacao internacao = null; AcessoBancoDados bd; try { bd = AcessoBancoDados.GetInstance; bd.conectar(); string comando = $@"select i.*, h.Cidade_id from internacao i inner join leito l on l.Id = i.Leito_id inner join hospital h on h.Id = l.Hospital_id Where i.Paciente_Id = {paciente.Codigo} and i.Situacao = 'I' Order By Id desc Limit 1"; var dtInternacao = bd.RetDataTable(comando); foreach (DataRow linha in dtInternacao.Rows) { internacao = new dto_cad_internacao(); internacao.Id = Convert.ToInt32(linha["Id"]); internacao.Data_Inicio = Convert.IsDBNull(linha["Data_Inicio"]) ? new DateTime() : Convert.ToDateTime(linha["Data_Inicio"]); internacao.Situacao = Convert.ToChar(linha["Situacao"]); internacao.Paciente_Id = Convert.ToInt32(linha["Paciente_Id"]); internacao.Leito_Id = Convert.ToInt32(linha["Leito_Id"]); internacao.Cidade_Id = Convert.ToInt32(linha["Cidade_id"]); } } catch (Exception ex) { MessageBox.Show("Erro ao selecionar a internacao do paciente! \n" + Convert.ToString(ex), "Erro na operação de seleção!", MessageBoxButtons.OK); } bd = null; return(internacao); }
public static bool Incluir(dto_cad_paciente paciente) { AcessoBancoDados bd; bool resultado = false; try { bd = AcessoBancoDados.GetInstance; bd.conectar(); string comando = $"INSERT INTO Paciente(NOME, CPF, GENERO, DATA_NASCIMENTO, Cidade_id) VALUES('{paciente.Nome}', '{paciente.CPF}', '{paciente.Genero}', '{paciente.DataNascimento.ToString("yyyy-MM-dd H:mm:ss")}', {paciente.Cidade})"; bd.ExecutarComandoSQL(comando); resultado = true; } catch (Exception ex) { MessageBox.Show("Erro ao incluir o cadastro do paciente! \n" + Convert.ToString(ex), "Erro na operação de cancelamento!", MessageBoxButtons.OK); } bd = null; return(resultado); }