public List<DrugCount> getDrugCountById(Presc presc)
        {
            List<DrugCount> drugCounts = new List<DrugCount>();

            DataTable table = db.queryDataTable("select drug, count from drugcount where presc = '" + presc.id + "'");
            if (table.Rows.Count == 0)
            {
                return drugCounts;
            }

            DataRowCollection rows = table.Rows;
            for (int i = 0; i < rows.Count; i++)
            {
                object[] items = table.Rows[i].ItemArray;
                DrugCount drugCount = new DrugCount();

                String drugId = items[0].ToString();
                drugCount.count = Convert.ToInt32(items[1].ToString());

                drugCount.drug = drugDAO.getDrugById(drugId);
                drugCount.presc = presc;

                drugCounts.Add(drugCount);
            }

            return drugCounts;
        }
Exemple #2
0
        private void addDrug(Drug drug, int count)
        {
            int index = findDrug(drug);
            if (index != -1)
            {
                presc.drugCountList[index].count += count;
                presc.drugCountList[index].drug = drug;
            }
            else
            {
                DrugCount drugCount = new DrugCount(presc, drug, count);
                presc.drugCountList.Add(drugCount);
            }

            drugListToTable();
        }
 public bool insertDrugCount(DrugCount drugCount)
 {
     String cmd = "insert into drugcount values ('" + drugCount.presc.id + "', '" + drugCount.drug.id + "', '" + drugCount.count + "')";
     return db.update(cmd);
 }