Example #1
0
        public buku returnBuku(string idBuku)
        {
            buku temp = new buku();

            query = $"SELECT * FROM Booklist WHERE BookId='{idBuku}'";
            SqlDataReader sdr;
            SqlCommand    command = new SqlCommand(query, sqlConn);

            sqlConn.Open();
            sdr = command.ExecuteReader();

            //Get value
            sdr.Read();
            temp.bookId = sdr.GetString(0).Trim();
            temp.title  = sdr.GetString(1).Trim();
            temp.author = sdr.GetString(2).Trim();
            temp.year   = sdr.GetString(3).Trim();
            temp.genre  = sdr.GetString(4).Trim();
            temp.path   = sdr.GetString(5).Trim();
            temp.stock  = sdr.GetString(6).Trim();

            //return class
            sqlConn.Close();
            return(temp);
        }
Example #2
0
        public ShowBookForm(string idbuku)
        {
            buku       currentBook = new buku();
            koneksiSql sql         = new koneksiSql();

            currentBook = sql.returnBuku(idbuku);

            InitializeComponent();

            txtTitle.Text  = currentBook.title;
            txtAuthor.Text = currentBook.author;
            string[] temp = currentBook.path.Split('|');

            for (int i = 0; i < temp.Count(); i++)
            {
                temp[i] = utilitas.strukturFolder("buku") + temp[i];
            }

            listGambar = temp;

            kontrol.setFoto(pboxGambar, listGambar[0]);
        }
Example #3
0
        private void btnReturnBook_Click(object sender, EventArgs e)
        {
            koneksiSql koneksi = new koneksiSql();
            buku       temp    = new buku();

            temp = koneksi.returnBuku(dgvBooks.SelectedCells[3].Value.ToString());
            string fine = lblFineAmount.Text.Substring(4, lblFineAmount.Text.Length - 4);
            bool   yes  = koneksi.finishLend(dgvBooks.SelectedCells[0].Value.ToString());

            if (fined && yes)
            {
                DialogNormal denda = new DialogNormal($"Returned", $"You have been Fined {fine}", 43, 85);
                denda.ShowDialog();
                koneksi.updateFine(Program.userSekarang.user, fine);
                koneksi.updateStock(temp.bookId, temp.stock, "add");
            }
            else
            {
                koneksi.updateFine(Program.userSekarang.user, fine);
                koneksi.updateStock(temp.bookId, temp.stock, "add");
            }
            isiDgv(Program.userSekarang.user);
        }
Example #4
0
        private void dgvBooks_SelectionChanged(object sender, EventArgs e)
        {
            try
            {
                string     idBuku       = dgvBooks.SelectedCells[3].Value.ToString();
                koneksiSql koneksi      = new koneksiSql();
                buku       bukuTerpilih = koneksi.returnBuku(idBuku);
                isiBuku(bukuTerpilih);

                Peminjaman pinjam = koneksi.returnLend(dgvBooks.SelectedCells[1].Value.ToString(), dgvBooks.SelectedCells[0].Value.ToString());
                isiPeminjaman(pinjam);
                if (pinjam.fine > 0)
                {
                    fined = true;
                }
            }
            catch (Exception)
            {
            }



            btnReturnBook.Enabled = true;
        }
Example #5
0
        public FormAddEditBook(string bookId) //Overload Constructor utk Edit
        {
            buku       currentBook = new buku();
            koneksiSql sql         = new koneksiSql();

            currentBook = sql.returnBuku(bookId);

            InitializeComponent();
            lblWelcome.Text = "Edit Book";
            editExisting    = true;

            txtBookId.Enabled = false;
            txtBookId.Text    = currentBook.bookId;
            txtTitle.Text     = currentBook.title;
            txtAuthor.Text    = currentBook.author;
            txtGenre.Text     = currentBook.genre;
            txtYear.Text      = currentBook.year;
            nudStock.Value    = Convert.ToInt32(currentBook.stock);
            string[] temp = currentBook.path.Split('|');
            foreach (string x in temp)
            {
                listBoxGambar.Items.Add(x);
            }
        }
Example #6
0
 private void isiBuku(buku buku1)
 {
     txtBookTitle.Text = buku1.title;
     txtAuthor.Text    = buku1.author;
     txtGenre.Text     = buku1.genre;
 }