コード例 #1
0
ファイル: FormLending.cs プロジェクト: AndreHrs/Library
        private void isiDgv(string username)
        {
            dgvBooks.Rows.Clear();
            koneksiSql     koneksi = new koneksiSql();
            SqlConnection  conn    = new SqlConnection(koneksi.getSqlConn());
            SqlCommand     cmd     = new SqlCommand($"SELECT * from Lendings where Username = '******'", conn);
            SqlDataAdapter sda     = new SqlDataAdapter(cmd);

            ds = new DataSet();
            sda.Fill(ds, "Lendings");
            try
            {
                for (int i = 0; i < ds.Tables["Lendings"].Rows.Count; i++)
                {
                    string lendId = ds.Tables["Lendings"].Rows[i][0].ToString();
                    string user   = ds.Tables["Lendings"].Rows[i][1].ToString();
                    string idBuku = ds.Tables["Lendings"].Rows[i][2].ToString();
                    string lend   = ds.Tables["Lendings"].Rows[i][3].ToString();
                    string due    = ds.Tables["Lendings"].Rows[i][4].ToString();
                    dgvBooks.Rows.Add(lendId, user, "0", idBuku, lend, due);
                }
                conn.Close();
            }
            catch (Exception e)
            {
                MessageBox.Show(e.ToString());
            }
        }
コード例 #2
0
        private void btnSubmit_Click(object sender, EventArgs e)
        {
            if (validasiInput())
            {
                string pathFile = "";
                string filename = "";

                if (!String.IsNullOrEmpty(this.path))
                {
                    pathFile = fungsi.returnDestPath(this.path, "profil");
                    filename = Path.GetFileName(pathFile);
                }

                string user = txtUsername.Text, pass = txtPassword.Text, tipe = "User", nama = txtName.Text,
                       alamat = rtbAddress.Text, telp = mtbTelephone.Text.Replace("+62", "0"), gender = cBoxGender.Text, fine = "0";
                koneksiSql koneksi = new koneksiSql();
                if (koneksi.InsertIntoUser(user, pass, tipe, nama, alamat, telp, gender, filename, fine))
                {
                    fungsi.copyKe(path, "profil");
                    this.Close();
                }
                else
                {
                    txtUsername.Focus();
                }
            }
            else
            {
                FormKosong dialog = new FormKosong();
                dialog.loadUC(new UcNotif1(dialog));
                dialog.ShowDialog();
            }
        }
コード例 #3
0
ファイル: FormMain.cs プロジェクト: AndreHrs/Library
        private void loadHotList()
        {
            koneksi = new koneksiSql();
            SqlConnection  conn = new SqlConnection(koneksi.getSqlConn());
            SqlCommand     cmd  = new SqlCommand("SELECT Booklist.BookId, Booklist.PicturePath, Stock ,count(Lendings.BookID) AS jumlah FROM Booklist left join Lendings ON Booklist.BookId = Lendings.BookID GROUP BY Booklist.BookId, PicturePath, Stock ORDER BY jumlah DESC", conn);
            SqlDataAdapter sda  = new SqlDataAdapter(cmd);

            sda.Fill(dsOverdue, "Hotlist");
            panelHotlist.Controls.Add(new hotBook(dsOverdue));
        }
コード例 #4
0
ファイル: FormMain.cs プロジェクト: AndreHrs/Library
        private void loadLowStock()
        {
            koneksi = new koneksiSql();
            SqlConnection  conn = new SqlConnection(koneksi.getSqlConn());
            SqlCommand     cmd  = new SqlCommand($"SELECT BookId, PicturePath, Stock FROM Booklist ORDER BY Stock", conn);
            SqlDataAdapter sda  = new SqlDataAdapter(cmd);

            sda.Fill(dsOverdue, "LowStock");
            panelSupport.Controls.Add(new NoOverdue(dsOverdue));
        }
コード例 #5
0
        private void btnRemove_Click(object sender, EventArgs e)
        {
            koneksiSql koneksi = new koneksiSql();

            try
            {
                koneksi.removeUser(dgvAccounts.SelectedCells[0].Value.ToString());
            }
            catch (Exception)
            {
            }
        }
コード例 #6
0
 private void btnLend_Click(object sender, EventArgs e)
 {
     if ((Convert.ToInt32(Program.userSekarang.fine) <= 0))
     {
         if ((Convert.ToInt32(dgvBooks.SelectedCells[5].Value) > 0))
         {
             Peminjaman lend   = new Peminjaman();
             Random     rand   = new Random();
             string     user   = Program.userSekarang.user,
                        idBuku = dgvBooks.SelectedCells[0].Value.ToString();
             bool success      = false;
             lend.lendId   = randomDigit();
             lend.username = user;
             lend.bookId   = idBuku;
             lend.addLendDate();
             lend.addDueDate();
             lend.convertToString();
             koneksiSql koneksi = new koneksiSql();
             do
             {
                 try
                 {
                     koneksi.makeLend(lend.lendId, lend.username, lend.bookId, lend.strLendDate, lend.strDueDate);
                     koneksi.updateStock(idBuku, dgvBooks.SelectedCells[5].Value.ToString(), "remove");
                     success = true;
                 }
                 catch
                 {
                     lend.lendId = randomDigit();
                 }
             } while (!success);
         }
         else
         {
             DialogNormal dialog = new DialogNormal("Notice", "The stock currently Empty", 70, 85);
             dialog.ShowDialog();
         }
     }
     else
     {
         DialogNormal dialog = new DialogNormal("Notice", "You have unpaid Fine \n Please pay your fine first!", 70, 65);
         dialog.ShowDialog();
     }
     isiDgv(txtSearch.Text);
 }
コード例 #7
0
        private void isiDgv(string teks)
        {
            dgvAccounts.Rows.Clear();
            koneksiSql     koneksi = new koneksiSql();
            SqlConnection  conn    = new SqlConnection(koneksi.getSqlConn());
            SqlCommand     cmd     = new SqlCommand($"SELECT * FROM Userlist Where Username LIKE '%{teks}%' or PasswordAkun LIKE '%{teks}%' or TipeAkun LIKE '%{teks}%'", conn);
            SqlDataAdapter sda     = new SqlDataAdapter(cmd);
            DataSet        ds      = new DataSet();

            sda.Fill(ds, "Userlist");

            for (int i = 0; i < ds.Tables["Userlist"].Rows.Count; i++)
            {
                string username = ds.Tables["Userlist"].Rows[i][0].ToString();
                string password = ds.Tables["Userlist"].Rows[i][1].ToString();
                string tipeAkun = ds.Tables["Userlist"].Rows[i][2].ToString();
                dgvAccounts.Rows.Add(username, password, tipeAkun);
            }
            conn.Close();
        }
コード例 #8
0
ファイル: FormLogin.cs プロジェクト: AndreHrs/Library
        private void button1_Click(object sender, EventArgs e)
        {
            if (String.IsNullOrEmpty(txtUsername.Text) || String.IsNullOrEmpty(txtPassword.Text))
            {
                cekNull(txtPassword);
                cekNull(txtUsername);
                DialogError dialog = new DialogError();
                dialog.BackgroundImage = Properties.Resources.blank;
                dialog.ShowDialog();
            }
            else
            {
                koneksiSql koneksi = new koneksiSql();
                string     username = txtUsername.Text.Trim(), password = txtPassword.Text.Trim();
                koneksi.validasiLogin(username, password);

                if (koneksi.validasiLogin(username, password))
                {
                    CurrentUser user = koneksi.returnUser(username);
                    if (txtUsername.Text == user.user && txtPassword.Text == user.pass)
                    {
                        Program.userSekarang = user;
                        this.Hide();

                        formMain form = new formMain(user);
                        form.Show();
                    }
                    else
                    {
                        DialogError dialog = new DialogError();
                        dialog.ShowDialog();
                    }
                }
                else
                {
                    DialogError dialog = new DialogError();
                    dialog.ShowDialog();
                }
            }
        }
コード例 #9
0
ファイル: FormMain.cs プロジェクト: AndreHrs/Library
        private bool checkOverdue()
        {
            if (Program.userSekarang.tipe == "Guest")
            {
                return(false);
            }
            bool overdue = false;

            koneksi = new koneksiSql();
            SqlConnection  conn = new SqlConnection(koneksi.getSqlConn());
            SqlCommand     cmd  = new SqlCommand($"SELECT * from Lendings INNER JOIN Booklist on Lendings.BookId = Booklist.BookID where Username = '******'", conn);
            SqlDataAdapter sda  = new SqlDataAdapter(cmd);

            sda.Fill(dsOverdue, "Lendings");
            try
            {
                for (int i = 0; i < dsOverdue.Tables["Lendings"].Rows.Count; i++)
                {
                    Peminjaman temp = new Peminjaman();
                    temp.username    = dsOverdue.Tables["Lendings"].Rows[i]["Username"].ToString();
                    temp.bookId      = dsOverdue.Tables["Lendings"].Rows[i]["BookId"].ToString();
                    temp.lendId      = dsOverdue.Tables["Lendings"].Rows[i]["LendId"].ToString();
                    temp.strLendDate = dsOverdue.Tables["Lendings"].Rows[i]["LendDate"].ToString();
                    temp.strDueDate  = dsOverdue.Tables["Lendings"].Rows[i]["DueDate"].ToString();
                    temp.fineCount();
                    if (temp.fine > 0)
                    {
                        overdue = true;
                        break;
                    }
                }
                conn.Close();
            }
            catch (Exception e)
            {
                MessageBox.Show(e.ToString());
            }
            return(overdue);
        }
コード例 #10
0
ファイル: FormManageBooks.cs プロジェクト: AndreHrs/Library
        private void isiDgv(string teks)
        {
            dgvBooks.Rows.Clear();
            koneksiSql     koneksi = new koneksiSql();
            SqlConnection  conn    = new SqlConnection(koneksi.getSqlConn());
            SqlCommand     cmd     = new SqlCommand($"SELECT * FROM Booklist Where Title LIKE '%{teks}%' or Author LIKE '%{teks}%' or Genre LIKE '%{teks}%' or YearReleased LIKE '%{teks}%'", conn);
            SqlDataAdapter sda     = new SqlDataAdapter(cmd);
            DataSet        ds      = new DataSet();

            sda.Fill(ds, "Booklist");

            for (int i = 0; i < ds.Tables["Booklist"].Rows.Count; i++)
            {
                string idBuku = ds.Tables["Booklist"].Rows[i][0].ToString();
                string title  = ds.Tables["Booklist"].Rows[i][1].ToString();
                string author = ds.Tables["Booklist"].Rows[i][2].ToString();
                string year   = ds.Tables["Booklist"].Rows[i][3].ToString();
                string genre  = ds.Tables["Booklist"].Rows[i][4].ToString();
                dgvBooks.Rows.Add(idBuku, title, author, year, genre);
            }
            conn.Close();
        }
コード例 #11
0
ファイル: ShowBook.cs プロジェクト: AndreHrs/Library
        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]);
        }
コード例 #12
0
ファイル: FormLending.cs プロジェクト: AndreHrs/Library
        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);
        }
コード例 #13
0
ファイル: FormLending.cs プロジェクト: AndreHrs/Library
        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;
        }
コード例 #14
0
ファイル: FormAddEditBook.cs プロジェクト: AndreHrs/Library
        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);
            }
        }