Example #1
0
        private void Add_Click(object sender, RoutedEventArgs e)
        {
            CodeError.Visibility = Visibility.Hidden;
            NomeError.Visibility = Visibility.Hidden;

            //verificar base de dados
            String           name = NameTextBox.Text;
            String           code = CodigoTextBox.Text;
            AcompanhanteInfo at   = db.verifyAcompanhante(name, code);

            //adicionar a lista
            if (at != null)
            {
                acompanhantes.Add(at);
                ListViewAcompanhante.Items.Refresh();

                //adicionar a base de dados
                db.addAcompanhante(at, this.user.getCode());
                CodeInsert.Visibility = Visibility.Hidden;

                NameTextBox.Text   = "";
                CodigoTextBox.Text = "";
            }
            else
            {
                CodeError.Visibility = Visibility.Visible;
                NomeError.Visibility = Visibility.Visible;
            }
        }
Example #2
0
        private void Remove_Click(object sender, RoutedEventArgs e)
        {
            //verificar base de dados
            String           code = CodigoTextBox2.Text;
            AcompanhanteInfo at   = null;

            foreach (AcompanhanteInfo acomp in acompanhantes)
            {
                if (acomp.Code.Equals(code))
                {
                    at = acomp;
                    break;
                }
            }

            //adicionar a lista
            if (at != null)
            {
                acompanhantes.Remove(at);
                ListViewAcompanhante.Items.Refresh();
                //adicionar a base de dados
                db.removeAcompanhante(at, this.user.getCode());
                CodeRemove.Visibility = Visibility.Hidden;
            }
        }
Example #3
0
        /* Method used to verify if the tuple (name, code) represents an existing Paciente in the db and if it does, returns it
         * Parameter String name - name of the pacient
         * Parameter String code - code of the pacient
         * Returns An AcompanhanteInfo, which contains a pacients info*/
        public static AcompanhanteInfo verifyAcompanhante(string name, string code)
        {
            if (!VerifySGBDConnection())
            {
                return(null);
            }

            SqlCommand    cmd    = new SqlCommand("select * from Pulse.verifyAcompanhantes('" + code + "'); ", cn);
            SqlDataReader reader = cmd.ExecuteReader();


            if (!reader.Read())
            {
                cn.Close();
                return(null);
            }
            else if (!reader["Nome"].ToString().Equals(name))
            {
                cn.Close();
                return(null);
            }
            else
            {
                AcompanhanteInfo at = new AcompanhanteInfo(
                    reader["Codigo"].ToString(),
                    reader["Nome"].ToString(),
                    reader["Estado"].ToString(),
                    reader["Localizacao"].ToString()
                    );
                cn.Close();
                return(at);
            }
        }
Example #4
0
        //ACOMPANHANTES PAGE FUNCTIONS

        /* Method used to get a list of all the Patients a user accompanies
         * Parameter String code - code of the companion
         * Returns a list of AcompanhanteInfo, each containing a pacients info*/
        public static List <AcompanhanteInfo> getAcompanhantes(String code)
        {
            List <AcompanhanteInfo> acompanhantes = new List <AcompanhanteInfo>();

            if (!VerifySGBDConnection())
            {
                return(acompanhantes);
            }

            SqlCommand    cmd    = new SqlCommand("select * from Pulse.getAcompanhantes('" + code + "'); ", cn);
            SqlDataReader reader = cmd.ExecuteReader();


            while (reader.Read())
            {
                AcompanhanteInfo at = new AcompanhanteInfo(
                    reader["Codigo"].ToString(),
                    reader["Nome"].ToString(),
                    reader["Estado"].ToString(),
                    reader["Localizacao"].ToString()
                    );
                acompanhantes.Add(at);
            }
            cn.Close();
            return(acompanhantes);
        }
Example #5
0
        /* Method used to remove pacient - companion relationship of the db
         * Parameter AcompanhanteInfo at - pacient to accompanie;
         * Parameter String code - code of the user*/
        public static void removeAcompanhante(AcompanhanteInfo at, String Code)
        {
            if (!VerifySGBDConnection())
            {
                return;
            }

            SqlCommand cmd = new SqlCommand("DELETE FROM Pulse.Acompanha WHERE CodigoPacienteAcompanha = '" + at.Code + "' and CodigoAcompanhanteAcompanha = '" + Code + "';", cn);

            cmd.ExecuteNonQuery();

            cn.Close();
        }
Example #6
0
        /* Method used to add pacient - companion relationship to the db
         * Parameter AcompanhanteInfo at - pacient to accompanie;
         * Parameter String code - code of the user*/
        public static void addAcompanhante(AcompanhanteInfo at, String Code)
        {
            if (!VerifySGBDConnection())
            {
                return;
            }

            SqlCommand cmd = new SqlCommand("INSERT INTO Pulse.Acompanha(CodigoPacienteAcompanha, CodigoAcompanhanteAcompanha) VALUES ( '" + at.Code + "', '" + Code + "');", cn);

            cmd.ExecuteNonQuery();

            cn.Close();
        }