private void LoadIssueByUser() { string user_name = tb_user_name_issue.Text.Trim(); IssueControls issueControls = new IssueControls(); gv_info_issue.DataSource = issueControls.LoadIssuesByUser(user_name); }
private void btn_edit_issue_Click(object sender, EventArgs e) { int id = int.Parse(tb_issue_id_issue.Text.Trim()); string user_name = tb_user_name_issue.Text.Trim(); int book_id = int.Parse(tb_book_id_issue.Text.Trim()); string status = cb_status_issue.SelectedItem.ToString().Trim(); string issue_date = dtp_issue_date_issue.Value.ToString("dd/MM/yyyy").Trim(); string tobe_return_date = dtp_tobe_return_issue.Value.ToString("dd/MM/yyyy").Trim(); string return_date; if (status.Equals("Returned")) { return_date = dtp_tobe_return_issue.Value.ToString("dd/MM/yyyy").Trim(); } else { return_date = "nill"; } Issue issue = new Issue(id, user_name, book_id, status, issue_date, tobe_return_date, return_date); IssueControls issueControls = new IssueControls(issue); bool isEdited = issueControls.EditIssue(); if (isEdited) { DisableViews(); cb_search_issue.SelectedIndex = cb_search_issue.FindStringExact("User"); gv_info_issue.DataSource = issueControls.LoadIssuesByUser(user_name); MessageBox.Show("Issue Edited."); } else { MessageBox.Show("Issue can not be Edited."); } }
private void btn_user_name_enter_issue_Click(object sender, EventArgs e) { string user_name = tb_user_name_issue.Text.Trim(); if (isValidString(user_name)) { UserControls userControls = new UserControls(); User user = userControls.SearchUser(user_name, "user"); if (user != null) { IssueControls issueControls = new IssueControls(); List <Issue> issues = issueControls.LoadIssuesByUser(user_name); int issued = 0; int returned = 0; int expired = 0; foreach (Issue i in issues) { if (i.Status.Equals("Issued")) { issued++; } else if (i.Status.Equals("Rerturned")) { returned++; } else { expired++; } } lbl_user_info_issue.Text = "Returned: " + returned + " Issued: " + issued + " Expired: " + expired; if (expired == 0) { tb_book_id_issue.Enabled = true; btn_book_enter_issue.Enabled = true; tb_user_name_issue.Enabled = false; btn_user_name_enter_issue.Enabled = false; } } else { MessageBox.Show("User Doesn't Exist."); } } else { MessageBox.Show("Enter User Name."); } }
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."); } }
public void SearchIssue(int id) { IssueControls issueControls = new IssueControls(); Issue issue = issueControls.SearchIssue(id); if (issue != null) { string user_name = issue.UserName; int book_id = issue.BookId; UserControls userControls = new UserControls(); User user = userControls.SearchUser(user_name, "user"); BookControls bookControls = new BookControls(); Book book = bookControls.SearchBook(book_id); if (user != null && book != null) { tb_issue_id_issue.Text = issue.Id.ToString().Trim(); tb_user_name_issue.Text = issue.UserName.Trim(); tb_book_id_issue.Text = issue.BookId.ToString().Trim(); cb_status_issue.SelectedIndex = cb_status_issue.FindStringExact(issue.Status.Trim()); dtp_issue_date_issue.Value = DateTime.ParseExact(issue.IssueDate, "dd/MM/yyyy", CultureInfo.InvariantCulture); dtp_tobe_return_issue.Value = DateTime.ParseExact(issue.TobeRetunDate, "dd/MM/yyyy", CultureInfo.InvariantCulture); if (issue.ReturnDate.Equals("nill")) { dtp_return_date_issue.Value = DateTime.Now; } else { dtp_return_date_issue.Value = DateTime.ParseExact(issue.ReturnDate, "dd/MM/yyyy", CultureInfo.InvariantCulture); } EnableViews(); cb_search_issue.SelectedIndex = cb_search_issue.FindStringExact("User"); gv_info_issue.DataSource = issueControls.LoadIssuesByUser(user_name); } else { MessageBox.Show("User or Book Doesn't Exist."); } } else { MessageBox.Show("Issue Doesn't Exist."); } }
private void btn_delete_issue_Click(object sender, EventArgs e) { string user_name = tb_user_name_issue.Text.Trim(); int id = int.Parse(tb_issue_id_issue.Text.Trim()); IssueControls issueControls = new IssueControls(); bool isDeleted = issueControls.DeleteIssue(id); if (isDeleted) { DisableViews(); cb_search_issue.SelectedIndex = cb_search_issue.FindStringExact("User"); gv_info_issue.DataSource = issueControls.LoadIssuesByUser(user_name); MessageBox.Show("Issue Deleted."); } else { MessageBox.Show("Issue can not be Deleted."); } }
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; } }