Exemplo n.º 1
0
        void loadData()
        {
            Database1Entities database1Entities = new Database1Entities();

            var data = (from d in database1Entities.t_matakuliah
                        select new
            {
                id = d.Id,
                kode_matkul = d.kode_matkul,
                nama_matkul = d.nama_matkul
            });

            dataGridView1.DataSource            = data.ToList();
            dataGridView1.Columns[0].Visible    = false;
            dataGridView1.Columns[1].HeaderText = "Kode Matkul";
            dataGridView1.Columns[2].HeaderText = "Nama Matkul";
        }
Exemplo n.º 2
0
        private void button1_Click(object sender, EventArgs e)
        {
            Database1Entities database1Entities = new Database1Entities();

            t_matakuliah matakuliah = new t_matakuliah();

            matakuliah.kode_matkul = textBox1.Text;
            matakuliah.nama_matkul = textBox2.Text;

            database1Entities.t_matakuliah.Add(matakuliah);

            database1Entities.SaveChanges();

            loadData();

            MessageBox.Show("Data Sukses Di input");

            resetFrom();
        }
Exemplo n.º 3
0
        private void button3_Click(object sender, EventArgs e)
        {
            try
            {
                int idMatkul = int.Parse(id.Text);

                Database1Entities db = new Database1Entities();

                var data = (from d in db.t_matakuliah
                            where d.Id == idMatkul
                            select d).FirstOrDefault();
                db.t_matakuliah.Remove(data);
                db.SaveChanges();
                loadData();
                MessageBox.Show("Data Telah Dihapus");
                resetFrom();
            }
            catch (Exception)
            {
                MessageBox.Show("Pilih Data Terlebih Dahulu");
            }
        }