Beispiel #1
0
        public string AddDataKelas(Kelas dp)
        {
            SqlCommand cmd = new SqlCommand("insert into kelas(ID_Kelas,Nama_Kelas) values(" +
                                            "'" + dp.id_kelas + "'," +
                                            "'" + dp.nama_kelas + "')", conn);

            try
            {
                conn.Open();
                cmd.ExecuteNonQuery();
                conn.Close();
                return("Data Berhasil Di Simpan");
            }
            catch (Exception ex)
            {
                return("Data Gagal Di Simpan : " + ex);
            }
        }
Beispiel #2
0
        public List <Kelas> GetKelas()
        {
            //string query = String.Format("Update pesanan set pesanan")
            List <Kelas> dp  = new List <Kelas>();
            SqlCommand   cmd = new SqlCommand("select * from kelas", conn);

            conn.Open();
            SqlDataReader reader = cmd.ExecuteReader();

            while (reader.Read())
            {
                Kelas pesan = new Kelas();
                pesan.id_kelas   = reader["ID_Kelas"].ToString();
                pesan.nama_kelas = reader["Nama_Kelas"].ToString();
                dp.Add(pesan);
            }
            conn.Close();
            return(dp);
        }