private void LoadIssueByStatus() { string status = cb_search_issue.SelectedItem.ToString().Trim(); IssueControls issueControls = new IssueControls(); if (status.Equals("Expired")) { List <Issue> allIssue = issueControls.LoadIssuesByStatus("Expired"); List <Issue> expiredIssue = new List <Issue>(); foreach (Issue i in allIssue) { if (i.Status.Equals("Expired")) { expiredIssue.Add(i); } } gv_info_issue.DataSource = expiredIssue; } else if (status.Equals("Returned")) { gv_info_issue.DataSource = issueControls.LoadIssuesByStatus(status); } else { List <Issue> allIssue = issueControls.LoadIssuesByStatus(status); List <Issue> issuedIssue = new List <Issue>(); foreach (Issue i in allIssue) { if (i.Status.Equals("Issued")) { issuedIssue.Add(i); } } gv_info_issue.DataSource = issuedIssue; } }
private void btn_book_enter_issue_Click(object sender, EventArgs e) { string sid = tb_book_id_issue.Text.ToString().Trim(); if (isValidString(sid)) { int id = int.Parse(sid); BookControls bookControls = new BookControls(); Book book = bookControls.SearchBook(id); if (book != null) { IssueControls issueControls = new IssueControls(); List <Issue> allIssue = issueControls.LoadIssuesByStatus("Issued"); List <Issue> issuedIssue = new List <Issue>(); foreach (Issue i in allIssue) { if (i.Status.Equals("Issued")) { issuedIssue.Add(i); } } int count = 0; foreach (Issue i in issuedIssue) { if (i.BookId == id) { count++; } } int total = book.Stock - count; lbl_book_info_issue.Text = "Total Book Remained: " + total; if (total > 0) { btn_add_issue.Enabled = true; tb_book_id_issue.Enabled = false; btn_book_enter_issue.Enabled = false; } } else { MessageBox.Show("No Book Found."); } } else { MessageBox.Show("Please Enter Book Id."); } }