private void searchButton_Click(object sender, EventArgs e) { int memberId = (int)nameComboBox.SelectedValue; string date = DateTime.Now.Month.ToString(); List <MemberWithDeposit> depositList = aDepositManager.MemberdDeposits(memberId, date); List <MemberWithMeal> memberWithMealList = aMealManager.GetMeals(memberId, date); int depositAmount = 0; double totalMeal = 0; foreach (var deposit in depositList) { depositAmount = depositAmount + deposit.Amount; } foreach (var meal in memberWithMealList) { totalMeal += meal.TotalMeal; } totalDepositAmountLabel.Text = depositAmount.ToString(); totalMealMemberlabel.Text = totalMeal.ToString(); double totalCost = totalMeal * GetPerMealCost(); totalMealCostLabel.Text = (totalCost).ToString(); remainingAmountLabel.Text = (depositAmount - totalCost).ToString(); }
private void searchButton_Click(object sender, EventArgs e) { depositReportListView.Items.Clear(); int row = 1; int subTotal = 0; DepositManager aDepositManager = new DepositManager(); int memberId = (int)nameComboBox.SelectedValue; string date = DateTime.Now.Month.ToString(); List <MemberWithDeposit> memberWithDeposit = aDepositManager.MemberdDeposits(memberId, date); foreach (var deposit in memberWithDeposit) { ListViewItem item = new ListViewItem(); item.Text = row++.ToString(); item.SubItems.Add(deposit.Date.ToString()); item.SubItems.Add(deposit.Amount.ToString()); item.SubItems.Add((subTotal = subTotal + deposit.Amount).ToString()); depositReportListView.Items.Add(item); } }