public Boolean RegistrarPaciente(clsPaciente Paciente)
        {
            SqlCommand cmd = new SqlCommand("PA_IngresarPaciente", cnx);
            cmd.CommandType = CommandType.StoredProcedure;
            SqlParameter paramId = new SqlParameter("IdPersona", SqlDbType.Int, 8);
            paramId.Direction = ParameterDirection.Output;
            cmd.Parameters.Add(paramId);
            cmd.Parameters.AddWithValue("NombrePersona", Paciente.Nombre);
            cmd.Parameters.AddWithValue("ApellidoPaterno", Paciente.ApellidoMaterno);
            cmd.Parameters.AddWithValue("ApellidoMaterno", Paciente.ApellidoPaterno);
            cmd.Parameters.AddWithValue("DNI", Paciente.DNI);
            cmd.Parameters.AddWithValue("Direccion", Paciente.Direccion);
            cmd.Parameters.AddWithValue("Correo", Paciente.Correo);
            cmd.Parameters.AddWithValue("Telefono", Paciente.Telefono);

            cnx.Open();

            Int32 i = cmd.ExecuteNonQuery();

            cnx.Close();

            if (i == 1) return true;

            Paciente.Codigo = Convert.ToInt32(paramId.Value);

            return false;
        }
        public List<clsPaciente> BuscarNombrePaciente(String nombre)
        {
            SqlCommand cmd = new SqlCommand("PA_BuscarNombrePaciente", cnx);
            cmd.CommandType = CommandType.StoredProcedure;
            cmd.Parameters.AddWithValue("Nombre", nombre);

            cnx.Open();

            SqlDataReader dr = cmd.ExecuteReader();
            List<clsPaciente> col = new List<clsPaciente>();
            while (dr.Read())
            {
                clsPaciente obj = new clsPaciente();

                obj.Codigo = Convert.ToInt32(dr["IdPaciente"]);
                obj.Nombre = dr["NombrePersona"].ToString();
                obj.ApellidoPaterno = dr["ApellidoPaterno"].ToString();
                obj.ApellidoMaterno = dr["ApellidoMaterno"].ToString();
                obj.DNI = dr["DNI"].ToString();
                obj.Direccion = dr["Direccion"].ToString();
                obj.Correo = dr["Correo"].ToString();
                obj.Telefono = dr["Telefono"].ToString();

                col.Add(obj);
            }

            cnx.Close();
            return col;
        }
Exemplo n.º 3
0
 public IEntidad buscarPorId(int id)
 {
     DataTable aux = new DataTable();
     clsPaciente P = new clsPaciente();
     try
     {
         aux =manejar.Consultar("select * from paciente where idPaciente="+id);
         P.Id = Convert.ToInt32(aux.Rows[0]["idPaciente"]);
         P.Nombre = aux.Rows[0]["nombre"].ToString();
         P.Apellido = aux.Rows[0]["apellido"].ToString();
         P.Dni = Convert.ToInt64(aux.Rows[0]["dni"]);
         P.Telefono = Convert.ToInt64(aux.Rows[0]["telefono"]);
     }
     catch(SqlException ex)
     {
         throw ex;
     }
     return P;
 }
Exemplo n.º 4
0
 public List<IEntidad> Todo()
 {
     List<IEntidad> list= new List<IEntidad>();
     DataTable dt = new DataTable();
     try
     {
         dt = DBManager.Consultar("select * from paciente");
         foreach(DataRow x in dt.Rows)
         {
             clsPaciente P = new clsPaciente();
             P.Id = Convert.ToInt32(x["idpaciente"]);
             P.Nombre = x["nombre"].ToString();
             P.Apellido = x["apellido"].ToString();
             P.Dni = Convert.ToInt64(x["dni"]);
             P.Telefono = Convert.ToInt64(x["telefono"]);
             list.Add(P);
         }
     }
     catch (SqlException ex)
     {
        throw ex;
     }
     return list;
 }
Exemplo n.º 5
0
        /// <summary>
        /// PACIENTE BAJA
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void eliminarToolStripMenuItem3_Click(object sender, EventArgs e)
        {
            DialogResult elim = MessageBox.Show("¿Desea eliminar a " + dgvPacientes.Rows[dgvPacientes.CurrentRow.Index].Cells[1].Value.ToString() + " " + dgvPacientes.Rows[dgvPacientes.CurrentRow.Index].Cells[2].Value.ToString(), "Verificar", MessageBoxButtons.OKCancel, MessageBoxIcon.Question);
            if (elim == DialogResult.OK)
            {
                IEntidad ent = new clsPaciente();
                ent.Id = Convert.ToInt32(dgvPacientes.Rows[dgvPacientes.CurrentRow.Index].Cells[0].Value);
                try
                {
                    metodosPacientes.Baja(ent);
                    pacientes.Clear();
                    foreach (IEntidad enti in metodosPacientes.Todo())
                    {
                        pacientes.Add((clsPaciente)enti);
                    }
                    dgvPacientes.DataSource = null;
                    dgvPacientes.DataSource = pacientes;
                    dgvPacientes.Columns[0].Visible = false;

                }
                catch (Exception ex)
                {
                    MessageBox.Show("Se produjo el sgte. error " + ex.Message);
                }
            }
        }
Exemplo n.º 6
0
        /// <summary>
        /// TURNOS abre formulario de carga de turnos
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btnGenerarTurno_Click(object sender, EventArgs e)
        {
            if (dgvPacientes.Focus() && dgvPacientes.SelectedRows.Count>0)
            {
                try
                {
                    int idPaciente = Convert.ToInt32(dgvPacientes.Rows[dgvPacientes.CurrentRow.Index].Cells[0].Value);
                    long dni = Convert.ToInt64(dgvPacientes.Rows[dgvPacientes.CurrentRow.Index].Cells[3].Value);
                    string nombre = dgvPacientes.Rows[dgvPacientes.CurrentRow.Index].Cells[1].Value.ToString();
                    string apellido = dgvPacientes.Rows[dgvPacientes.CurrentRow.Index].Cells[2].Value.ToString();
                    long telefono = Convert.ToInt64(dgvPacientes.Rows[dgvPacientes.CurrentRow.Index].Cells[3].Value);

                    clsPaciente oClsPacienteTurno = new clsPaciente(idPaciente, dni, nombre, apellido, telefono);
                    actualizar();

                    frmTurno oFrmTurno = new frmTurno(oClsPacienteTurno, this);

                    oFrmTurno.ShowDialog();
                }
                catch(NullReferenceException ex)
                {
                    dgvTurnos.Focus();
                }
            }
            else
            {
                MessageBox.Show("Seleccione un paciente", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
Exemplo n.º 7
0
 /// <summary>
 /// PACIENTE ALTA
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void btnCargarP_Click(object sender, EventArgs e)
 {
     if(verificarPaciente())
     {
         clsPaciente pac=new clsPaciente(Convert.ToInt64(tbDniP.Text), tbNombreP.Text, tbApellidoP.Text, Convert.ToInt64(tbTelefonoP.Text));
         try
         {
             metodosPacientes.Alta((IEntidad)pac);
             pacientes.Clear();
             foreach(IEntidad ent in metodosPacientes.Todo())
             {
                 pacientes.Add((clsPaciente)ent);
             }
             dgvPacientes.DataSource = null;
             dgvPacientes.DataSource = pacientes;
             limpiarPaciente();
         }
         catch(Exception ex)
         {
             MessageBox.Show("Error de conexion con la base de datos: " + ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
         }
     }
 }
Exemplo n.º 8
0
        /// <summary>
        /// PACIENTE busca un paciente por Documento
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btnBuscarP_Click(object sender, EventArgs e)
        {
            bool existe = false;
            if (tbBuscarP.Text.Length == 8)
            {
                foreach (IEntidad pac in pacientes)
                {
                    if (((clsPaciente)pac).Dni == Convert.ToInt64(tbBuscarP.Text))
                    {
                        List<clsPaciente> lista = new List<clsPaciente>();

                        clsPaciente oClsPaciente = new clsPaciente(((clsPaciente)pac).Dni, ((clsPaciente)pac).Nombre, ((clsPaciente)pac).Apellido, ((clsPaciente)pac).Telefono);

                        lista.Clear();
                        lista.Add(oClsPaciente);

                        dgvPacientes.DataSource = lista;
                        existe = true;
                    }
                }
            }
            else
                MessageBox.Show("Formato de Documento incorrecto", "Alerta.", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
            if (!existe)
                MessageBox.Show("No se registra paciente con dicho documento.", "Alerta.", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
        }