예제 #1
0
        private void button_save_Click(object sender, EventArgs e)
        {
            var contex                 = new perpustakaanEntities239();
            var id_peminjaman          = Convert.ToInt32(comboBox_id_peminjaman.SelectedValue);
            var transaksi              = (from a in contex.tabel_transaksi_peminjaman where a.id_peminjaman == id_peminjaman select a).Single();
            int id_buku                = transaksi.id_buku;
            var buku                   = (from a in contex.tabel_buku where a.id_buku == id_buku select a).Single();
            tabel_pengembalian kembali = new tabel_pengembalian();

            if (transaksi.status == 0)
            {
                transaksi.status        = 1;
                buku.stok_buku          = buku.stok_buku + 1;
                kembali.id_peminjaman   = Convert.ToInt32(comboBox_id_peminjaman.SelectedValue);
                kembali.tanggal_kembali = dateTimePicker_tanggal_kembali.Value.Date;
                kembali.denda           = Convert.ToInt32(label_denda.Text);
                contex.tabel_pengembalian.Add(kembali);
                MessageBox.Show("Transaksi Berhasil");
            }
            else
            {
                MessageBox.Show("Maaf, buku sudah dikembalikan");
            }
            contex.SaveChanges();
            FormPengembalian kembalian = new FormPengembalian();

            this.Hide();
            kembalian.Show();
        }
        private void bunifuFlatButton_transaksi_pengembalian_Click(object sender, EventArgs e)
        {
            FormPengembalian kembali = new FormPengembalian();

            kembali.MdiParent = this;
            kembali.Show();
            kembali.Focus();
        }