示例#1
0
        private void btn_Login_Click(object sender, EventArgs e)
        {
            SqlCommand sqlCommand = new SqlCommand("[dbo].[sp_LogIn]", acceso.getConnection());

            sqlCommand.CommandType = CommandType.StoredProcedure;
            sqlCommand.Parameters.Add(new SqlParameter("@ID_profesional", SqlDbType.Int));
            sqlCommand.Parameters.Add(new SqlParameter("@email", SqlDbType.VarChar, 30));
            sqlCommand.Parameters.Add(new SqlParameter("@pass", SqlDbType.VarChar, 10));
            sqlCommand.Parameters["@ID_profesional"].Direction = ParameterDirection.Output;
            sqlCommand.Parameters["@email"].Value = txt_Email.Text;
            sqlCommand.Parameters["@pass"].Value  = txt_Password.Text;

            try
            {
                acceso.conectar();

                sqlCommand.ExecuteNonQuery();

                id_Profesional = (int)sqlCommand.Parameters["@ID_profesional"].Value;
            }
            catch (Exception ex)
            {
                MessageBox.Show("No se ha podido conectar: " + ex.Message);
            }
            finally
            {
                acceso.desconectar();
            }

            if (id_Profesional != id_ProfesionalInvalido)
            {
                MessageBox.Show("Loggin válido, bienvenido usuario " + id_Profesional);
                PantallaProfesional pantalla = new PantallaProfesional(this, id_Profesional);
                this.Hide();
                pantalla.Show();
            }
            else
            {
                MessageBox.Show("Loggin inválido, vuelva a inentarlo, por favor");
            }
        }
示例#2
0
        public PantallaAdmin(Login login, PantallaProfesional pantallaProfesional, int id_Profesional)
        {
            this.login = login;
            this.pantallaProfesional = pantallaProfesional;
            this.id_Profesional      = id_Profesional;

            InitializeComponent();

            string     query   = "select ID_paciente as idPaciente, concat(nombre , ' ' , apellidos) as nombrePaciente from dbo.pacientes";
            SqlCommand command = new SqlCommand(query, acceso.getConnection());

            //Mostrarlos en la grid
            try
            {
                //Abrir la conexión
                acceso.conectar();
                //Ejecutar comando
                SqlDataReader dr = command.ExecuteReader();
                DataTable     dt = new DataTable();
                dt.Load(dr);

                for (int i = 0; i < dt.Rows.Count; i++)
                {
                    cmb_Paciente.Items.Add(dt.Rows[i].ItemArray[1].ToString());
                    cmb_IdPaciente.Items.Add(dt.Rows[i].ItemArray[0].ToString());
                }
                //Cerrar el Datareader
                dr.Close();
            }
            catch (Exception ex)
            {
                MessageBox.Show("No se ha podido conectar" +
                                ex.Message);
            }
            finally
            {
                acceso.desconectar();
            }
        }