public void Save(Seizure obj) { String query = "INSERT INTO seizures"; query += "(patientId,assessDate,frequency,episode,confidence)"; query += @" VALUES( " + obj.patientId + ",'" + obj.assessDate + "'," + obj.frequency + "," + obj.episode + "," + obj.confidence + ")"; this.ExecuteNonQuery(query); }
public List <Seizure> FetchAll() { List <Seizure> objs = new List <Seizure>(); this.ExecuteQuery("SELECT * FROM seizures ORDER BY assessDate ASC"); while (reader.Read()) { Seizure temp = new Seizure(); Int32.TryParse(reader["seizureId"].ToString(), out temp.seizureId); Int32.TryParse(reader["patientId"].ToString(), out temp.patientId); temp.assessDate = reader["assessDate"].ToString(); Int32.TryParse(reader["frequency"].ToString(), out temp.frequency); Int32.TryParse(reader["episode"].ToString(), out temp.episode); Int32.TryParse(reader["confidence"].ToString(), out temp.confidence); objs.Add(temp); } this.QueryClose(); return(objs); }
protected void Import(DataSet SpreadsheetTables) { foreach (DataTable Table in SpreadsheetTables.Tables) { if (Table.TableName == "Seizures$") { SeizureManager sm = new SeizureManager(); foreach (DataRow Row in Table.Rows) { if (!String.IsNullOrWhiteSpace(Row[0].ToString()) || !String.IsNullOrWhiteSpace(Row[1].ToString())) { Seizure s = new Seizure(); Int32.TryParse(Row[0].ToString(), out s.seizureId); Int32.TryParse(Row[1].ToString(), out s.patientId); DateTime dateTime = DateTime.Parse(Row[2].ToString()); s.assessDate = dateTime.ToString("MM/dd/yyyy"); Int32.TryParse(Row[3].ToString(), out s.frequency); if (String.IsNullOrEmpty(Row[4].ToString())) { s.episode = 0; } else { Int32.TryParse(Row[4].ToString(), out s.episode); } if (String.IsNullOrEmpty(Row[5].ToString())) { s.confidence = 0; } else { Int32.TryParse(Row[5].ToString(), out s.confidence); } sm.Save(s); } } } else if (Table.TableName == "Meds$") { PrescriptionManager pm = new PrescriptionManager(); foreach (DataRow Row in Table.Rows) { if (!String.IsNullOrWhiteSpace(Row[0].ToString()) || !String.IsNullOrWhiteSpace(Row[1].ToString())) { Prescription p = new Prescription(); Int32.TryParse(Row[0].ToString(), out p.prescriptionId); Int32.TryParse(Row[1].ToString(), out p.patientId); float.TryParse(Row[2].ToString(), out p.dose); p.unit = Row[3].ToString(); p.frequency = Row[4].ToString(); p.medName = Row[5].ToString(); DateTime dt = DateTime.Parse(Row[6].ToString()); p.assessDate = dt.ToString("MM/dd/yyyy"); Int32.TryParse(Row[7].ToString(), out p.noMedications); pm.Save(p); // Debug.WriteLine("adding meds " + Row[0].ToString() + " " + Row[1].ToString()); } } } else if (Table.TableName == "Surgery$") { SurgeryManager surm = new SurgeryManager(); foreach (DataRow Row in Table.Rows) { if (!String.IsNullOrWhiteSpace(Row[0].ToString()) || !String.IsNullOrWhiteSpace(Row[1].ToString())) { Surgery s = new Surgery(); Int32.TryParse(Row[0].ToString(), out s.surgeryId); Int32.TryParse(Row[1].ToString(), out s.patientId); DateTime dateTime = DateTime.Parse(Row[2].ToString()); s.surgeryDate = dateTime.ToString("MM/dd/yyyy"); s.surgeryType = Row[3].ToString(); surm.Save(s); //Debug.WriteLine("adding surgery " + Row[0].ToString() + " " + Row[1].ToString()); } } } else { throw new ApplicationException("Invalid Worksheet Name: Only Seizures, Meds and Surgery"); } } }