public string updateNilaiRapot(Rapot dp) { SqlCommand cmd = new SqlCommand("update rapot set Nilai='" + dp.nilai + "'" + ", Semester='" + dp.semester + "', ID_kelas='" + dp.id_kelas + "', ID_mapel='" + dp.id_mapel + "'" + ", ID_siswa='" + dp.id_siswa + "' where ID_rapot = " + "'" + dp.id_rapot + "'" + " and ID_mapel = " + "'" + dp.id_mapel + "'" + " and Semester = " + "'" + dp.semester + "'", conn); try { conn.Open(); cmd.ExecuteNonQuery(); conn.Close(); return("Data Berhasil Di Update"); } catch (Exception ex) { return("Data Gagal Di Update : " + ex); } }
public List <Rapot> FilterSemester(string id) { List <Rapot> dp = new List <Rapot>(); SqlCommand cmd = new SqlCommand("select * from rapot where Semester = " + "'" + id + "'", conn); conn.Open(); SqlDataReader reader = cmd.ExecuteReader(); while (reader.Read()) { Rapot pesan = new Rapot(); pesan.nilai = reader["Nilai"].ToString(); pesan.semester = reader["Semester"].ToString(); pesan.id_kelas = reader["ID_kelas"].ToString(); pesan.id_mapel = reader["ID_mapel"].ToString(); pesan.id_siswa = reader["ID_siswa"].ToString(); pesan.id_rapot = reader["ID_rapot"].ToString(); dp.Add(pesan); } conn.Close(); return(dp); }
public string AddDataRapot(Rapot dp) { SqlCommand cmd = new SqlCommand("insert into rapot(Nilai,Semester,ID_kelas,ID_mapel,ID_siswa,ID_rapot) values(" + "'" + dp.nilai + "'," + "'" + dp.semester + "'," + "'" + dp.id_kelas + "'," + "'" + dp.id_mapel + "'," + "'" + dp.id_siswa + "'," + "'" + dp.id_rapot + "')", conn); try { conn.Open(); cmd.ExecuteNonQuery(); conn.Close(); return("Data Berhasil Di Simpan"); } catch (Exception ex) { return("Data Gagal Di Simpan : " + ex); } }
public List <Rapot> GetRapot() { //string query = String.Format("Update pesanan set pesanan") List <Rapot> dp = new List <Rapot>(); SqlCommand cmd = new SqlCommand("select * from rapot", conn); conn.Open(); SqlDataReader reader = cmd.ExecuteReader(); while (reader.Read()) { Rapot pesan = new Rapot(); pesan.nilai = reader["Nilai"].ToString(); pesan.semester = reader["Semester"].ToString(); pesan.id_kelas = reader["ID_kelas"].ToString(); pesan.id_mapel = reader["ID_mapel"].ToString(); pesan.id_siswa = reader["ID_siswa"].ToString(); pesan.id_rapot = reader["ID_rapot"].ToString(); dp.Add(pesan); } conn.Close(); return(dp); }