Exemplo n.º 1
0
        //J
        public static void verifyLogin(string u, string p)
        {
            string user  = u;
            string pass  = p;
            string query = "SELECT username FROM staff WHERE username=@User and password=@Password";

            DBConnection connection = DBConnection.getDBConnectionInstance();
            DataSet      DataLogin  = connection.login(query, user, pass);

            int count = DataLogin.Tables[0].Rows.Count;

            //open main window
            if (count == 1)
            {
                MessageBox.Show("Login Successful!");
                main_screen ms = new main_screen();
                ms.Show();
            }
            else
            {
                MessageBox.Show("Invalid credentials, please enter registered username and passsword!");
                login lg = new login();
                lg.Show();
            }
        }
Exemplo n.º 2
0
        //G
        public static void searchPatientName(string[] name, bool main)
        {
            //create sql statement
            DBConnection connection = DBConnection.getDBConnectionInstance();

            if (name[2].Contains('/'))
            {
                string  sqlQuery    = @"SELECT * FROM Patients WHERE Patient_name = @Name AND Patient_surname = @Surname AND Patient_date_of_birth = @DobOrAddress;";
                DataSet patientData = connection.searchPatientByName(sqlQuery, name[0], name[1], name[2]);
                //checks that the query returned exactly one result
                int count = patientData.Tables[0].Rows.Count;

                if (count == 1)
                {
                    individual_patient patient = new individual_patient(patientData.Tables[0].Rows[0].Field <int>("Patient_Id").ToString(), patientData);
                    patient.Show();
                }
                else
                {
                    MessageBox.Show("No patient found.");
                    if (main)
                    {
                        main_screen frm = new main_screen();
                        frm.Show();
                    }
                    else
                    {
                        Patients frm = new Patients();
                        frm.Show();
                    }
                }
            }
            else
            {
                string  query = @"SELECT * FROM Patients WHERE Patient_name = @Name AND Patient_surname = @Surname AND Patient_postcode = @DobOrAddress;";
                DataSet patientDataPostcode = connection.searchPatientByName(query, name[0], name[1], name[2]);
                //checks that the query returned exactly one result
                int count = patientDataPostcode.Tables[0].Rows.Count;

                if (count == 1)
                {
                    individual_patient patient = new individual_patient(patientDataPostcode.Tables[0].Rows[0].Field <int>("Patient_Id").ToString(), patientDataPostcode);
                    patient.Show();
                }
                else
                {
                    MessageBox.Show("No patient found.");
                    if (main)
                    {
                        main_screen frm = new main_screen();
                        frm.Show();
                    }
                    else
                    {
                        Patients frm = new Patients();
                        frm.Show();
                    }
                }
            }
        }
Exemplo n.º 3
0
        //G
        public static void searchPatient(string id, bool main)
        {
            //creates the SQL query
            string       query       = @"SELECT * FROM Patients WHERE Patient_Id = @ID;";
            DBConnection connection  = DBConnection.getDBConnectionInstance();
            DataSet      patientData = connection.getDataById(query, id);
            //checks that the query returned exactly one result
            int count = patientData.Tables[0].Rows.Count;

            if (count == 1)
            {
                individual_patient patient = new individual_patient(id, patientData);
                patient.Show();
            }
            else
            {
                MessageBox.Show("No patient found.");
                if (main)
                {
                    main_screen frm = new main_screen();
                    frm.Show();
                }
                else
                {
                    Patients frm = new Patients();
                    frm.Show();
                }
            }
        }
Exemplo n.º 4
0
        private void bt_home_Click(object sender, RoutedEventArgs e)
        {
            this.Hide();
            main_screen frm = new main_screen();

            frm.Show();
            this.Close();
        }