private void FormAddTypeOfBooks_Load(object sender, EventArgs e)
        {
            string kodeTerbaru = TipeBuku.GenerateKode();

            textBoxId.Text    = kodeTerbaru;
            textBoxId.Enabled = false;
            textBoxJenisBuku.Focus();
        }
        private void comboBoxTipe_SelectedIndexChanged(object sender, EventArgs e)
        {
            TipeBuku tipedipilih = (TipeBuku)comboBoxTipe.SelectedItem;

            string kodeBuku = Buku.GenerateKode(tipedipilih);

            textBoxId.Text    = kodeBuku;
            textBoxId.Enabled = false;
            textBoxJudul.Focus();
        }
 public void FormListBookType_Load(object sender, EventArgs e)
 {
     listOfTipeBuku = TipeBuku.BacaData("", "");
     comboBoxSearch.SelectedIndex = 0;
     if (listOfTipeBuku.Count > 0)
     {
         dataGridView1.DataSource = listOfTipeBuku;
     }
     else
     {
         dataGridView1.DataSource = null;
     }
 }
 private void buttonChange_Click(object sender, EventArgs e)
 {
     try
     {
         TipeBuku tipeiDipilih = (TipeBuku)comboBoxTipeBuku.SelectedItem;
         Penerbit penerbit     = (Penerbit)comboBoxPenerbit.SelectedItem;
         Buku     b            = new Buku(textBoxId.Text, textBoxJudul.Text, int.Parse(textBoxHarga.Text), int.Parse(textBoxStok.Text), tipeiDipilih, penerbit);
         Buku.UbahData(b);
         MessageBox.Show("Data Buku telah tersimpan", "Info");
     }
     catch (Exception ex)
     {
         MessageBox.Show("Penyimpanan gagal. Pesan Kesalahan : " + ex.Message, "Kesalahan");
     }
 }
        private void buttonChange_Click(object sender, EventArgs e)
        {
            try
            {
                TipeBuku t = new TipeBuku(textBoxId.Text, textBoxJenisBuku.Text);

                TipeBuku.UbahData(t);

                MessageBox.Show("Data Tipe Buku berhasil diubah", "Info");
            }
            catch (Exception ex)
            {
                MessageBox.Show("Pengubahan gagal. Pesan Kesalahan : " + ex.Message, "Kesalahan");
            }
        }
        private void buttonSave_Click(object sender, EventArgs e)
        {
            try
            {
                TipeBuku t = new TipeBuku(textBoxId.Text, textBoxJenisBuku.Text);

                TipeBuku.TambahData(t);

                MessageBox.Show("Data Tipe Buku telah tersimpan", "Info");
            }
            catch (Exception ex)
            {
                MessageBox.Show("Penympanan gagal. Pesan Kesalahan : " + ex.Message, "Kesalahan");
            }
        }
 private void textBoxId_TextChanged(object sender, EventArgs e)
 {
     if (textBoxId.Text.Length == textBoxId.MaxLength)
     {
         listOfTipeBuku = TipeBuku.BacaData("IdTipeBuku", textBoxId.Text);
         if (listOfTipeBuku.Count > 0)
         {
             textBoxJenisBuku.Text = listOfTipeBuku[0].JenisBuku;
             textBoxJenisBuku.Focus();
         }
         else
         {
             MessageBox.Show("Kode kategori tidak ditemukan", "Kesalahan");
             textBoxJenisBuku.Text = "";
             textBoxId.Text        = "";
             textBoxId.Focus();
         }
     }
 }
        private void textBoxSearch_TextChanged(object sender, EventArgs e)
        {
            if (comboBoxSearch.Text == "Id Tipe Buku")
            {
                listOfTipeBuku = TipeBuku.BacaData("idTipeBuku", textBoxSearch.Text);
            }
            else if (comboBoxSearch.Text == "Jenis Buku")
            {
                listOfTipeBuku = TipeBuku.BacaData("jenisBuku", textBoxSearch.Text);
            }

            if (listOfTipeBuku.Count > 0)
            {
                dataGridView1.DataSource = listOfTipeBuku;
            }
            else
            {
                dataGridView1.DataSource = null;
            }
        }
 private void buttonSave_Click(object sender, EventArgs e)
 {
     try
     {
         TipeBuku tipeBuku = (TipeBuku)comboBoxTipe.SelectedItem;
         Penerbit penerbit = (Penerbit)comboBoxPenerbit.SelectedItem;
         Buku     b        = new Buku(textBoxId.Text, textBoxJudul.Text, int.Parse(textBoxHarga.Text), int.Parse(textBoxStok.Text), tipeBuku, penerbit);
         Buku.TambahData(b);
         MessageBox.Show("Data buku berhasil ditambahkan", "informasi");
         textBoxJudul.Text = "";
         textBoxId.Text    = "";
         textBoxHarga.Text = "";
         textBoxStok.Text  = "";
         comboBoxTipe.Text = "";
         comboBoxTipe.Focus();
     }
     catch (Exception ex)
     {
         MessageBox.Show("Gagal menambah data. Pesan kesalahan : " + ex.Message, "Kesalahan");
     }
 }
        private void buttonDelete_Click(object sender, EventArgs e)
        {
            DialogResult konfirmasi = MessageBox.Show("Data Tipe Buku akan terhapus, Apakah anda yakin ?", "Konfirmasi", MessageBoxButtons.YesNo);

            if (konfirmasi == System.Windows.Forms.DialogResult.Yes)
            {
                TipeBuku t           = new TipeBuku(textBoxId.Text, textBoxJenisBuku.Text);
                string   hasilTambah = TipeBuku.HapusData(t);
                if (hasilTambah == "1")
                {
                    MessageBox.Show("Tipe Buku berhasil dihapus.", "Informasi");
                    textBoxId.Text        = "";
                    textBoxJenisBuku.Text = "";
                    textBoxId.Focus();
                }
                else
                {
                    MessageBox.Show("Gagal menghapus Tipe Buku, Pesan kesalahan : " + hasilTambah);
                }
            }
        }
        private void FormDeleteOfBook_Load(object sender, EventArgs e)
        {
            textBoxId.MaxLength    = 5;
            textBoxJudul.MaxLength = 45;

            listOfTipeBuku = TipeBuku.BacaData("", "");
            comboBoxTipeBuku.DataSource    = listOfTipeBuku;
            comboBoxTipeBuku.DisplayMember = "JenisBuku";
            comboBoxTipeBuku.DropDownStyle = ComboBoxStyle.DropDownList;

            listOfPenerbit = Penerbit.BacaData("", "");
            comboBoxPenerbit.DataSource    = listOfPenerbit;
            comboBoxPenerbit.DisplayMember = "NamaPenerbit";
            comboBoxPenerbit.DropDownStyle = ComboBoxStyle.DropDownList;

            comboBoxPenerbit.Enabled = false;
            comboBoxTipeBuku.Enabled = false;
            textBoxHarga.Enabled     = false;
            textBoxHarga.Enabled     = false;
            textBoxJudul.Enabled     = false;
            textBoxStok.Enabled      = false;
        }
示例#12
0
        private void FormChangeBook_Load(object sender, EventArgs e)
        {
            textBoxId.MaxLength    = 5;
            textBoxJudul.MaxLength = 45;

            listOfTipeBuku = TipeBuku.BacaData("", "");
            comboBoxTipeBuku.DataSource    = listOfTipeBuku;
            comboBoxTipeBuku.DisplayMember = "JenisBuku";
            comboBoxTipeBuku.DropDownStyle = ComboBoxStyle.DropDownList;

            listOfPenerbit = Penerbit.BacaData("", "");
            comboBoxPenerbit.DataSource    = listOfPenerbit;
            comboBoxPenerbit.DisplayMember = "NamaPenerbit";
            comboBoxPenerbit.DropDownStyle = ComboBoxStyle.DropDownList;

            textBoxJudul.Text = "";
            textBoxHarga.Text = "";
            textBoxStok.Text  = "";
            textBoxId.Text    = "";

            textBoxHarga.TextAlign = HorizontalAlignment.Right;
            textBoxStok.TextAlign  = HorizontalAlignment.Right;
        }
        private void buttonDelete_Click(object sender, EventArgs e)
        {
            try
            {
                DialogResult konfirmasi = MessageBox.Show("Data Buku akan terhapus, Apakah anda yakin ?", "Konfirmasi", MessageBoxButtons.YesNo);
                if (konfirmasi == System.Windows.Forms.DialogResult.Yes)
                {
                    TipeBuku tipeDipilih = (TipeBuku)comboBoxTipeBuku.SelectedItem;
                    Penerbit penerbit    = (Penerbit)comboBoxPenerbit.SelectedItem;
                    Buku     b           = new Buku(textBoxId.Text, textBoxJudul.Text, int.Parse(textBoxHarga.Text), int.Parse(textBoxStok.Text), tipeDipilih, penerbit);

                    Buku.HapusData(b);
                    MessageBox.Show("Data Buku telah terhapus", "Info");
                }
                else
                {
                    MessageBox.Show("Data Buku tidak jadi di hapus", "Info");
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("Penghapusan gagal. Pesan Kesalahan : " + ex.Message, "Kesalahan");
            }
        }