-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathAddItemDialog.cs
69 lines (60 loc) · 1.78 KB
/
AddItemDialog.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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
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 ShoppingListApp
{
public partial class AddItemDialog : Form
{
private int catSelected;
private string newItemName;
private string catName;
public int CatSelected
{
get { return catSelected; }
set { catSelected = value; }
}
public string NewItemName
{
get { return newItemName; }
set { newItemName = value; }
}
public string CatName
{
get { return catName; }
}
public AddItemDialog()
{
InitializeComponent();
// Populate the combo box with all of the categories
for (int i = 0; i < ShoppingListForm.categories.Quantity(); i++)
{
comboCategory.Items.Add(ShoppingListForm.categories.CatList[i].Name);
}
// Set the default category
comboCategory.SelectedIndex = 0;
}
private void btnCancel_Click(object sender, EventArgs e)
{
// Set the class fields to error values
catSelected = -666;
newItemName = null;
catName = null;
Close();
}
private void btnOK_Click(object sender, EventArgs e)
{
// Set the class fields to the contents of the dialog and close it
catSelected = comboCategory.SelectedIndex;
newItemName = txtName.Text;
catName = comboCategory.Text;
// TODO: Need some sort of error handling here...
Close();
}
}
}