Ejemplo n.º 1
0
        public List <PivotInfo> getPivot()
        {
            Koneksi          kon     = new Koneksi();
            SqlConnection    sqlcon  = kon.getConnection();
            List <PivotInfo> objList = new List <PivotInfo>();

            using (sqlcon)
            {
                string     sql    = "select * from pivot_kelas";
                SqlCommand sqlcom = new SqlCommand(sql, sqlcon);

                using (sqlcon)
                {
                    SqlDataReader dr = sqlcom.ExecuteReader();
                    while (dr.Read())
                    {
                        PivotInfo objPivot = new PivotInfo();
                        objPivot.ID        = dr.GetString(0);
                        objPivot.KodeKelas = dr.GetString(1);
                        objPivot.NIS       = dr.GetInt32(2);

                        objList.Add(objPivot);
                    }
                }
                sqlcon.Close();
            }
            return(objList);
        }
Ejemplo n.º 2
0
        public int updatePivot(PivotInfo data)
        {
            Koneksi       kon    = new Koneksi();
            SqlConnection sqlcon = kon.getConnection();
            int           result = 0;

            using (sqlcon)
            {
                sqlcon.Open();

                string     sql    = "update barang set kode_kelas = @kode_kelas, nis = @nis where id_pivot = @id_pivot";
                SqlCommand sqlcom = new SqlCommand(sql, sqlcon);

                using (sqlcom)
                {
                    sqlcom.Parameters.AddWithValue("@id_pivot", data.ID);
                    sqlcom.Parameters.AddWithValue("@kode_kelas", data.KodeKelas);
                    sqlcom.Parameters.AddWithValue("@nis", data.NIS);

                    result = sqlcom.ExecuteNonQuery();
                }
                sqlcon.Close();
            }
            return(result);
        }
Ejemplo n.º 3
0
        public List <PivotInfo> getPivotByID(string id)
        {
            Koneksi          kon      = new Koneksi();
            SqlConnection    sqlcon   = kon.getConnection();
            List <PivotInfo> objList  = new List <PivotInfo>();
            PivotInfo        objPivot = new PivotInfo();

            using (sqlcon)
            {
                sqlcon.Open();

                string     sql    = "select*from pivot_kelas where id = @id_pivot";
                SqlCommand sqlcom = new SqlCommand(sql, sqlcon);

                using (sqlcom)
                {
                    sqlcom.Parameters.AddWithValue("@id_pivot", id);
                    SqlDataReader dr = sqlcom.ExecuteReader();

                    if (dr.Read())
                    {
                        objPivot.ID        = dr.GetString(0);
                        objPivot.KodeKelas = dr.GetString(1);
                        objPivot.NIS       = dr.GetInt32(2);

                        objList.Add(objPivot);
                    }
                }
                sqlcon.Close();
            }
            return(objList);
        }
Ejemplo n.º 4
0
        public int insertPivot(PivotInfo data)
        {
            Koneksi       kon    = new Koneksi();
            SqlConnection sqlcon = kon.getConnection();
            int           result = 0;

            using (sqlcon)
            {
                string     sql    = "insert into pivot_kelas values(@id_pivot, @kode_kelas, @nis)";
                SqlCommand sqlcom = new SqlCommand(sql, sqlcon);
                sqlcon.Open();

                using (sqlcom)
                {
                    sqlcom.Parameters.AddWithValue("@id_pivot", data.ID);
                    sqlcom.Parameters.AddWithValue("@kode_kelas", data.KodeKelas);
                    sqlcom.Parameters.AddWithValue("@nis", data.NIS);

                    result = sqlcom.ExecuteNonQuery();
                }
                sqlcon.Close();
            }
            return(result);
        }