Ejemplo n.º 1
0
        public DataTable GetAll()
        {
            string  query = "SELECT nip,namaguru,jabatan FROM guru";
            AccesDB dd    = new AccesDB();

            return(dd.GetData(query));
        }
Ejemplo n.º 2
0
        public void Hapus(string nip)
        {
            string  query = "DELETE FROM guru WHERE nip=@kriteria";
            AccesDB dd    = new AccesDB();

            dd.Execute(query,
                       new OleDbParameter("@kriteria", nip));
        }
Ejemplo n.º 3
0
        public DataTable GetByName(string namaguru)
        {
            string  query = "SELECT nip,namaguru,jabatan FROM guru WHERE namaguru LIKE @kriteria";
            AccesDB dd    = new AccesDB();

            return(dd.GetData(query,
                              new OleDbParameter("@kriteria", "%" + namaguru + "%")));
        }
Ejemplo n.º 4
0
        public void Add(gurumodel data)
        {
            string  query = "INSERT INTO guru (nip,namaguru,jabatan) VALUES (@nip,@namaguru,@jabatan)";
            AccesDB dd    = new AccesDB();

            dd.Execute(query,
                       new OleDbParameter("@nip", data.nip),
                       new OleDbParameter("@namaguru", data.namaguru),
                       new OleDbParameter("@jabatan", data.jabatan));
        }
Ejemplo n.º 5
0
        public void Edit(string nip, gurumodel data)
        {
            string  query = "UPDATE guru SET nip=@nipbaru,namaguru=@namagurubaru WHERE nip=@nipLama";
            AccesDB dd    = new AccesDB();

            dd.Execute(query,
                       new OleDbParameter("@nisBaru", data.nip),
                       new OleDbParameter("@namaBaru", data.namaguru),
                       new OleDbParameter("@kelasBaru", data.jabatan),
                       new OleDbParameter("@nisLama", nip));
        }
Ejemplo n.º 6
0
        public gurumodel GetByNip(string nip)
        {
            gurumodel data   = null;
            string    query  = "SELECT nip,namaguru,jabatan FROM guru WHERE nip=@kriteria";
            AccesDB   dd     = new AccesDB();
            DataTable dtguru = dd.GetData(query,
                                          new OleDbParameter("@kriteria", nip));

            if (dtguru.Rows.Count == 1)
            {
                //ambil satu baris saja
                DataRow row = dtguru.Rows[0];
                //masukkan ke model siswa
                data          = new gurumodel();
                data.nip      = row["nip"].ToString();
                data.namaguru = row["namaguru"].ToString();
                data.jabatan  = row["jabatan"].ToString();
            }

            return(data);
        }
Ejemplo n.º 7
0
        public siswamodel GetByNis(string nis)
        {
            siswamodel data    = null;
            string     query   = "SELECT nis,nama,kelas FROM siswa WHERE nis=@kriteria";
            AccesDB    db      = new AccesDB();
            DataTable  dtSiswa = db.GetData(query,
                                            new OleDbParameter("@kriteria", nis));

            if (dtSiswa.Rows.Count == 1)
            {
                //ambil satu baris saja
                DataRow row = dtSiswa.Rows[0];
                //masukkan ke model siswa
                data       = new siswamodel();
                data.nis   = row["nis"].ToString();
                data.nama  = row["nama"].ToString();
                data.kelas = row["kelas"].ToString();
            }

            return(data);
        }