コード例 #1
0
ファイル: SQL.cs プロジェクト: Hetzendorfer/SEW
        static public List <Patient> ReadPatienten()
        {
            List <Patient> patienten = new List <Patient>();
            Datenbank      db        = Datenbank.GetInstance();

            try
            {
                OleDbCommand cmd = new OleDbCommand("SELECT id, vorname, nachname, svnr FROM patient;");
                cmd.Connection = db.Connection;
                if (!db.isOpen())
                {
                    db.Open();
                }
                OleDbDataReader reader = cmd.ExecuteReader();

                while (reader.Read())
                {
                    Patient p = new Patient(reader.GetInt32(0), reader.GetString(1), reader.GetString(2), reader.GetString(3));
                    p.Behandlungen = ReadBehandlungen(p.ID);
                    patienten.Add(p);
                }
            }
            catch (Exception ex)
            {
            }

            return(patienten);
        }
コード例 #2
0
ファイル: SQL.cs プロジェクト: Hetzendorfer/SEW
        static public bool DeleteAll()
        {
            Datenbank db = Datenbank.GetInstance();

            try
            {
                OleDbCommand cmd  = new OleDbCommand("DELETE FROM patient;");
                OleDbCommand cmd2 = new OleDbCommand("DELETE FROM behandlung;");
                OleDbCommand cmd3 = new OleDbCommand("DELETE FROM patientbehandlungen;");
                if (!db.isOpen())
                {
                    db.Open();
                }
                cmd.Connection  = db.Connection;
                cmd2.Connection = db.Connection;
                cmd3.Connection = db.Connection;

                cmd.ExecuteNonQuery();
                cmd2.ExecuteNonQuery();
                cmd3.ExecuteNonQuery();

                return(true);
            }
            catch (Exception e)
            {
                return(false);
            }
        }