Esempio n. 1
0
        public ArranModel read(long id)
        {
            openConnection();
            ArranModel   arrangement = new ArranModel();
            MySqlCommand cmd         = new MySqlCommand();

            cmd.Connection  = connection;
            cmd.CommandText = string.Format("select arrangementId, arrangementBeskrivelse, createTs, arrangementWeb, arrangementDt, arrangemnetTid, spiseSted, spiseTid from Arrangement where arrangementId={0}", id);

            MySqlDataReader reader = cmd.ExecuteReader();

            if (reader.Read())
            {
                arrangement.arrangementId          = reader.GetInt64("arrangementId");
                arrangement.arrangementBeskrivelse = reader.GetString("arrangementBeskrivelse");
                arrangement.createTs       = reader.GetDateTime("createTs");
                arrangement.arrangementWeb = reader.GetString("arrangementWeb");
                arrangement.arrangementDt  = reader.GetDateTime("arrangementDt");
                arrangement.arrangemnetTid = DateTime.Parse(reader.GetString("arrangemnetTid"));
                arrangement.spiseSted      = reader.GetString("spiseSted");
                arrangement.spiseTid       = DateTime.Parse(reader.GetString("spiseTid"));
            }

            closeConnection();
            return(arrangement);
        }
Esempio n. 2
0
        public List <ArranModel> readList()
        {
            List <ArranModel> arrangementer = new List <ArranModel>();

            openConnection();

            MySqlCommand cmd = new MySqlCommand();

            cmd.Connection  = connection;
            cmd.CommandText = string.Format("select arrangementId, arrangementBeskrivelse, createTs, arrangementWeb, arrangementDt, arrangemnetTid, spiseSted, spiseTid from Arrangement");

            MySqlDataReader reader = cmd.ExecuteReader();

            while (reader.Read())
            {
                ArranModel arrangement = new ArranModel();
                arrangement.arrangementId          = reader.GetInt64("arrangementId");
                arrangement.arrangementBeskrivelse = reader.GetString("arrangementBeskrivelse");
                arrangement.createTs       = reader.GetDateTime("createTs");
                arrangement.arrangementWeb = reader.GetString("arrangementWeb");
                arrangement.arrangementDt  = reader.GetDateTime("arrangementDt");
                arrangement.arrangemnetTid = DateTime.Parse(reader.GetString("arrangemnetTid"));
                arrangement.spiseSted      = reader.GetString("spiseSted");
                arrangement.spiseTid       = DateTime.Parse(reader.GetString("spiseTid"));
                arrangementer.Add(arrangement);
            }

            closeConnection();
            return(arrangementer);
        }
Esempio n. 3
0
        public void update(ArranModel arrangement)
        {
            openConnection();

            MySqlCommand cmd = new MySqlCommand();

            cmd.Connection  = connection;
            cmd.CommandText = string.Format(
                "update Arrangement set arrangementBeskrivelse='{0}', arrangementWeb='{1}', arrangementDt='{2}', arrangemnetTid='{3}', spiseSted='{4}', spiseTid='{5}' where arrangementId={6} ",
                arrangementBeskrivelse, arrangementWeb, arrangementDt.ToString("yyyy-MM-dd"), arrangemnetTid.ToString("HH:mm:ss"), spiseSted, spiseTid.ToString("HH:mm:ss"), arrangementId);
            int cnt = cmd.ExecuteNonQuery();

            closeConnection();
        }
Esempio n. 4
0
        public void create(ArranModel arrangement)
        {
            openConnection();

            MySqlCommand cmd = new MySqlCommand();

            cmd.Connection  = connection;
            cmd.CommandText = string.Format(
                "insert into Arrangement(arrangementBeskrivelse, createTs, arrangementWeb, arrangementDt, arrangemnetTid, spiseSted, spiseTid) " +
                "values('{0}', current_timestamp,'{1}','{2}','{3}','{4}','{5}');",
                arrangementBeskrivelse, arrangementWeb, arrangementDt.ToString("yyyy-MM-dd"), arrangemnetTid.ToString("HH:mm:ss"), spiseSted, spiseTid.ToString("HH:mm:ss"));
            int cnt = cmd.ExecuteNonQuery();

            closeConnection();
        }