コード例 #1
0
        // Return all medicines for a prescription
        public static List<Medicine> GetPrescriptionMedicines(int prescriptionID)
        {
            Database db = Database.Instance();

            List<Medicine> _medicine = new List<Medicine>();

            String query = "SELECT * FROM prescriptions_medicine pm " +
                    "INNER JOIN medicine m ON pm.medicineID=m.medicineID " +
                    "WHERE pm.prescriptionID=" + prescriptionID + ";";

            DbDataReader dr = db.Select(query);

            // Create the staff data
            // Read the data and store them in the list
            while (dr.Read())
            {
                Medicine newMedicine = new Medicine();
                newMedicine.MedicineID = dr.GetInt32(3);
                newMedicine.MedicineName = dr.GetString(4);
                newMedicine.Dosage = dr.GetString(5);
                newMedicine.Extendable = dr.GetBoolean(6);
                _medicine.Add(newMedicine);
            }

            dr.Close();

            return _medicine;
        }
コード例 #2
0
        // Get a list of all stored medicines
        public static List<Medicine> GetAllMedicines()
        {
            Database db = Database.Instance();
            List<Medicine> _medicines = new List<Medicine>();

            if (db.OpenConnection())
            {
                //Build the query String
                String newMedicineQuery;

                //Create the query to be inserted
                newMedicineQuery = "SELECT * FROM Medicine";

                DbDataReader dr = db.Select(newMedicineQuery);
                while (dr.Read())
                {
                    Medicine medicine = new Medicine();
                    medicine.MedicineID = dr.GetInt32(0);
                    medicine.MedicineName = dr.GetString(1);
                    medicine.Dosage = dr.GetString(2);

                    _medicines.Add(medicine);
                }

                db.CloseConnection();

            }
            return _medicines;
        }