Ejemplo n.º 1
0
        public Boolean InsertSiswa(Entity.EntSiswa es)
        {
            status = false;
            try
            {
                query = "insert into Siswa values ('" + es.getNIS() +
                        "','" + es.getNama() + "','" + es.getGender() +
                        "','" + es.getTemLahir() + "','" + es.getTglLahir() +
                        "','" + es.getAlamat() + "','" + es.getKelas() +
                        "','" + es.getPoint() + "')";

                OpenConnection();

                command             = koneksi.CreateCommand();
                command.CommandText = query;
                command.ExecuteNonQuery();
                status = true;
            }
            catch (SqlException se)
            {
                Console.WriteLine("Error" + se);
            }
            finally
            {
                CloseConnection();
            }

            return(status);
        }
Ejemplo n.º 2
0
        public Boolean UpdateSiswa(Entity.EntSiswa es)
        {
            status = false;
            try
            {
                query = "Update Siswa set NamaSiswa = '" + es.getNama() + "', Gender = '" + es.getGender() +
                        "', TempatLahir ='" + es.getTemLahir() + "', TanggalLahir = '" + es.getTglLahir() +
                        "', Alamat ='" + es.getAlamat() + "',Kelas = '" + es.getKelas() +
                        "',Point = '" + es.getPoint() + "' where NIS = '" + es.getNIS() + "'";

                OpenConnection();
                command             = koneksi.CreateCommand();
                command.CommandText = query;
                command.ExecuteNonQuery();
                status = true;
                koneksi.Close();
            }
            catch (SqlException se)
            {
                Console.WriteLine("Error" + se);
            }
            finally
            {
                CloseConnection();
            }

            return(status);
        }