public void readResults(SqlDataReader reader) { if (reader.HasRows) { Prescription tmpScript = new Prescription(); Dictionary <int, int> dictScriptId = new Dictionary <int, int>(); while (reader.Read()) { this.name = reader.GetString(0); this.age = reader.GetInt32(1); this.address = reader.GetString(2); int idScript = reader.GetInt32(3); if (tmpScript == null || tmpScript.id == -1 || !dictScriptId.ContainsKey(idScript)) { //6 d.id, 7 d.name //8 disease.id, 9 disease.notice tmpScript = new Prescription(this, reader.GetString(6), reader.GetString(8)); tmpScript.doctor.name = reader.GetString(7); tmpScript.disease.notice = reader.GetString(9); tmpScript.id = reader.GetInt32(3); dictScriptId.Add(tmpScript.id, prescriptions.Count); tmpScript.fromDate = reader.GetDateTime(4); tmpScript.ToDate = reader.GetDateTime(5); prescriptions.Add(tmpScript); } tmpScript = (Prescription)prescriptions[dictScriptId[idScript]]; //10 pill.name //11 pp.time, 12 pp.amount String tokenTime = reader.GetString(11); bool[] timeToTake; if (tokenTime.Equals("000")) { timeToTake = new bool[3] { false, false, false } } ; else if (tokenTime.Equals("001")) { timeToTake = new bool[3] { false, false, true } } ; else if (tokenTime.Equals("010")) { timeToTake = new bool[3] { false, true, false } } ; else if (tokenTime.Equals("011")) { timeToTake = new bool[3] { false, true, true } } ; else if (tokenTime.Equals("100")) { timeToTake = new bool[3] { true, false, false } } ; else if (tokenTime.Equals("101")) { timeToTake = new bool[3] { true, false, true } } ; else if (tokenTime.Equals("110")) { timeToTake = new bool[3] { true, true, false } } ; else { timeToTake = new bool[3] { true, true, true } }; Pill aDrug = new Pill(reader.GetString(10), reader.GetInt32(12), timeToTake); tmpScript.getPills().Add(aDrug); } } else { Console.WriteLine("No rows found."); } }
public void addPrescription(Prescription script) { prescriptions.Add(script); }