-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathChartDateProductListWindow.cs
53 lines (42 loc) · 1.71 KB
/
ChartDateProductListWindow.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace GroceryExpenseTracker
{
public partial class ChartDateProductListWindow : Form
{
private Form parent;
public ChartDateProductListWindow(Form parent, Model.PurchaseList purchaseList)
{
this.parent = parent;
//this.parent.Hide();
InitializeComponent();
float grandTotal = 0;
for(int i=0; i < purchaseList.ProductList.Count; i++)
{
Model.Product product = purchaseList.ProductList[i];
float productTotalPrice = product.QTY * product.UnitPrice;
if(dgPurchaseList.Rows.GetRowCount(DataGridViewElementStates.Displayed) - 1 != purchaseList.ProductList.Count)
dgPurchaseList.Rows.Add();
var row = dgPurchaseList.Rows[i];
row.Cells[0].Value = product.Name;
row.Cells[1].Value = product.QTY.ToString();
row.Cells[2].Value = product.UnitPrice.ToString();
row.Cells[3].Value = productTotalPrice.ToString();
grandTotal += productTotalPrice;
}
lblDate.Text = purchaseList.Date.ToShortDateString();
lblGrandTotal.Text = "Grand Total: " + grandTotal.ToString() + SettingsUtil.GetCurrencySymbol();
}
private void ChartDateProductListWindow_FormClosed(object sender, FormClosedEventArgs e)
{
parent.Show();
}
}
}