private void btnReturn_Click(object sender, EventArgs e) { try { if (Form_Validation() != string.Empty) { MessageBox.Show(Form_Validation(), "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } else { ReturnBL ReturnBL = new ReturnBL(s, r); loan.StudentId = txtStudentId.Text; loan.DateReturned = DateTime.Now; if (ReturnBL.ReturnTransaction(txtStudentId.Text, resourcrId, DateTime.Now, (int)loanStatus)) { MessageBox.Show("Return worked!"); //loans.Remove(loanss); } else { MessageBox.Show("Return failed"); } ListsBL listsBL = new ListsBL(); dgvCurrentLoans.DataSource = listsBL.GetLoans(s.StudentId); } } catch (Exception ex) { MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
private void btnSearch_Click(object sender, EventArgs e) { try { if (txtSearchKeyword.Text == string.Empty) { MessageBox.Show("StudendID is empty", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } else if (txtSearchKeyword.Text.Length > 8) { MessageBox.Show("StudendID cannot exceed length of 8", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } else { ListsBL listBL = new ListsBL(); lstMatchingStudents.DataSource = listBL.GetStudents(txtSearchKeyword.Text); lstMatchingStudents.DisplayMember = "FullName"; lstMatchingStudents.ValueMember = "StudentId"; string msg = ""; foreach (ValidationError error in listBL.Errors) { msg += error.Description + Environment.NewLine; } if (msg != string.Empty) { MessageBox.Show(msg, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } } } catch (Exception ex) { MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
private void btnSearch_Click(object sender, EventArgs e) { try { if (txtSearchKeyword.Text == string.Empty) { MessageBox.Show("StudendID is empty", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } else if (txtSearchKeyword.Text.Length > 8) { MessageBox.Show("StudendID cannot exceed length of 8", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } else { ListsBL listBL = new ListsBL(); lstMatchingStudents.DataSource = listBL.GetStudents(txtSearchKeyword.Text); lstMatchingStudents.DisplayMember = "FullName"; lstMatchingStudents.ValueMember = "StudentId"; } } catch (Exception ex) { MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
private void LoadStudentList() { ListsBL listsBl = new ListsBL(); var l = listsBl.GetStudent(txtStudentSearchName.Text, txtStudentSearchId.Text); SelectionMode selectionMode = lstSearchResult.SelectionMode; lstSearchResult.SelectionMode = SelectionMode.None; lstSearchResult.DataSource = l; lstSearchResult.DisplayMember = "FullName"; lstSearchResult.ValueMember = "StudentId"; lstSearchResult.SelectionMode = selectionMode; }
private void lstMatchingStudents_Click(object sender, EventArgs e) { try { if (lstMatchingStudents.SelectedIndex == -1) { MessageBox.Show("Please search studend first then select", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } else { StudentBL studentBL = new StudentBL(); s = studentBL.GetStudent(lstMatchingStudents.SelectedValue.ToString()); string msg = ""; //Check Studend Status and overdueBalance foreach (ValidationError error in studentBL.Errors) { msg += error.Description + Environment.NewLine; } if (msg != string.Empty) { MessageBox.Show(msg, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } txtStudentId.Text = s.StudentId; txtProgramOption.Text = s.Program.ToString(); txtFirstName.Text = s.FirstName; txtLastName.Text = s.lastName; txtEndDate.Text = s.EndDate.ToString(); txtStartDate.Text = s.StartDate.ToString(); txtBalanceDue.Text = s.BalanceDue.ToString("c"); chkIsActive.Checked = s.IsActive; ListsBL listsBL = new ListsBL(); showDGV(listsBL.GetLoans(s.StudentId)); } } catch (Exception ex) { MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
private void btnSearchResource_Click(object sender, EventArgs e) { try { if (txtResourceIdEntry.Text == string.Empty) { MessageBox.Show("ResourceID is empty", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } else { ResourceBL resourceBL = new ResourceBL(); r = resourceBL.GetResourceOnLoan(Convert.ToInt32(txtResourceIdEntry.Text)); txtResourceId.Text = r.ResourceId.ToString(); txtStudentId.Text = r.StudentId.ToString(); txtResourceTitle.Text = r.Title; txtResourceType.Text = r.ResourceType.ToString(); txtResourceStatus.Text = r.ResourceStatus.ToString(); chkIsReserved.Checked = r.IsReserved; StudentBL studentBl = new StudentBL(); s = studentBl.GetStudent(txtStudentId.Text); txtFirstName.Text = s.FirstName; txtLastName.Text = s.lastName; txtBalanceDue.Text = s.BalanceDue.ToString(); txtEndDate.Text = s.EndDate.ToString(); txtStartDate.Text = s.StartDate.ToString(); txtProgramOption.Text = s.Program.ToString(); chkIsActive.Checked = s.IsActive; ListsBL listsBL = new ListsBL(); dgvCurrentLoans.DataSource = listsBL.GetLoans(txtStudentId.Text); cmbLoanStatus.DataSource = listsBL.GetLoans(txtStudentId.Text); cmbLoanStatus.DisplayMember = "LoanStatus"; } } catch (Exception ex) { MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
private void lstMatchingStudents_Click(object sender, EventArgs e) { try { StudentBL studentBL = new StudentBL(); s = studentBL.GetStudent(lstMatchingStudents.SelectedValue.ToString()); txtStudentId.Text = s.StudentId; txtProgramOption.Text = s.Program.ToString(); txtFirstName.Text = s.FirstName; txtLastName.Text = s.lastName; txtStartDate.Text = s.StartDate.ToString(); txtEndDate.Text = s.EndDate.ToString(); txtBalanceDue.Text = s.BalanceDue.ToString("c"); chkIsActive.Checked = s.IsActive; ListsBL listsBL = new ListsBL(); dgvCurrentLoans.DataSource = listsBL.GetLoans(s.StudentId); } catch (Exception ex) { MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
private void btnCheckout_Click(object sender, EventArgs e) { try { loan.StudentId = txtStudentId.Text; loan.ResourceId = Convert.ToInt32(txtResourceIdEntry.Text); loan.CheckOutDate = DateTime.Now; LoanBL loanBL = new LoanBL(); if (r.IsReserved != true && r.ResourceStatus.ToString() == "Available") { MessageBox.Show($"StudendID: {txtStudentId.Text}\n" + $"ResourceID: {txtResourceIdEntry.Text}\n" + $"CheckOut Date: {loan.CheckOutDate}\n" + $"Due Date: {loan.DueDate}"); if (loanBL.ResourceTransaction(loan.StudentId, loan.ResourceId, loan.CheckOutDate, loan.DueDate)) { MessageBox.Show("Transaction worked!"); } else { MessageBox.Show("Transaction Falied!"); } ListsBL listsBL = new ListsBL(); dgvCurrentLoans.DataSource = listsBL.GetLoans(s.StudentId); } else { MessageBox.Show("Resource is not available!"); } } catch (Exception ex) { MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
private void btnCheckout_Click(object sender, EventArgs e) { try { if (Form_Validation() != string.Empty) { MessageBox.Show(Form_Validation(), "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } else { if (loans.Count != 0) { foreach (LoanLookUp loan in loans.ToList()) { GetResource(loan.ResourceId); LoanBL loanBL = new LoanBL(s, r); if (loanBL.Errors.Count == 0) { loan.StudendId = s.StudentId; loan.ResourceId = r.ResourceId; loan.CheckOutDate = DateTime.Now; //Check Studend Status and overdueBalance if (loanBL.ResourceTransaction(loan.CheckOutDate, loan.DueDate)) { DeleteLoans(loan.ResourceId); if (loans.Count == 0) { dgvList.DataSource = null; MessageBox.Show("Checkout worked!"); } txtResourceStatus.Text = r.ResourceStatus.ToString(); } } else { string msg = ""; foreach (ValidationError error in loanBL.Errors) { msg += error.Description + Environment.NewLine; } MessageBox.Show(msg, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } } ListsBL listsBL = new ListsBL(); showDGV(listsBL.GetLoans(s.StudentId)); } else { MessageBox.Show("please add resources first", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } } } catch (Exception ex) { MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } }