示例#1
0
        private void btnAdd_Click(object sender, EventArgs e)
        {
            if (txtHarga.Text == "" || txtJudul.Text == "" || txtKode.Text == "" || txtPengarang.Text == "" || txtTahun.Text == "")
            {
                MetroMessageBox.Show(this, "Semua Form Harus Diisi", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning);
            }
            else
            {
                Buku newBuku = new Buku();
                newBuku.kode_buku  = txtKode.Text;
                newBuku.nama_buku  = txtJudul.Text;
                newBuku.harga      = Convert.ToInt32(txtHarga.Text);
                newBuku.thn_terbit = Convert.ToInt32(txtTahun.Text);
                newBuku.pengarang  = txtPengarang.Text;

                DataClassDataContext dbCtx = new DataClassDataContext();
                dbCtx.Bukus.InsertOnSubmit(newBuku);

                try
                {
                    dbCtx.SubmitChanges();

                    MetroMessageBox.Show(this, "Data Berhasil Ditambahkan", "Successfull", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    txtKode.Clear();
                    txtJudul.Clear();
                    txtHarga.Clear();
                    txtPengarang.Clear();
                    txtTahun.Clear();
                }
                catch (Exception ex)
                {
                    MetroMessageBox.Show(this, "Gagal", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }
        }
示例#2
0
 partial void UpdateBuku(Buku instance);
示例#3
0
 partial void DeleteBuku(Buku instance);
示例#4
0
 partial void InsertBuku(Buku instance);