//--------------------------------------------------------------------------------------- //Base Tea Change Button private void CoboBaseTea_SelectionChangeCommitted_1(object sender, EventArgs e) { var selectedItemPrice = (coboBaseTea.SelectedItem as BaseTea).price; var selectedItemName = (coboBaseTea.SelectedItem as BaseTea).name; //Item List BaseTea listItem1 = ListCopy.MyList.Find(x => (x.name == "Green Tea")); BaseTea listItem2 = ListCopy.MyList.Find(x => (x.name == "Black Tea")); BaseTea listItem3 = ListCopy.MyList.Find(x => (x.name == "Milk Tea")); //Checking Base Tea Box for adding price to currentItemTotal if (coboBaseTea.Text == listItem1.name || coboBaseTea.Text == listItem2.name || coboBaseTea.Text == listItem3.name) { //Increament Item Cost Value currentTotalItemCost = selectedItemPrice; } //Update CurrentTotal Text CurrentTotal.Text = "$" + currentTotalItemCost.ToString(); }
//Form1 Loading Objs Function private void Form1_Load(object sender, EventArgs e) { //Assign textbox to int val CurrentTotal.Text = "$" + currentTotalItemCost.ToString(); //New Lists (BaseTea + Flavours) List <BaseTea> list = new List <BaseTea>(); List <Flavour> list2 = new List <Flavour>(); //Ref to Base Tea List Instance ListCopy.MyList = list; ListCopy.MyList2 = list2; //DataTableSetup table.Columns.Add("Size", typeof(string)); table.Columns.Add("Base", typeof(string)); table.Columns.Add("Tea", typeof(string)); table.Columns.Add("Toppings", typeof(string)); table.Columns.Add("Price", typeof(string)); //Assign Table DataSource dataGridView1.DataSource = table; //Button Col (EDIT) DataGridViewButtonColumn Btn1 = new DataGridViewButtonColumn(); Btn1.HeaderText = "Edit"; Btn1.Text = "Edit"; Btn1.UseColumnTextForButtonValue = true; dataGridView1.Columns.Add(Btn1); //Button Col (Delete) DataGridViewButtonColumn Btn2 = new DataGridViewButtonColumn(); Btn2.HeaderText = "Delete"; Btn2.Text = "Delete"; Btn2.UseColumnTextForButtonValue = true; dataGridView1.Columns.Add(Btn2); //Adding List Items to base tea list.Add(new BaseTea() { id = 0, name = "Green Tea", price = 1 }); list.Add(new BaseTea() { id = 1, name = "Black Tea", price = 1 }); list.Add(new BaseTea() { id = 2, name = "Milk Tea", price = 2 }); //Assigning combobox the list coboBaseTea.DataSource = list; //Assigning Vals coboBaseTea.ValueMember = "id"; coboBaseTea.DisplayMember = "Name"; //Adding List Items to flav list2.Add(new Flavour() { id = 0, name = "- None -", price = 0 }); list2.Add(new Flavour() { id = 1, name = "Lemon", price = 1 }); list2.Add(new Flavour() { id = 2, name = "Passionfruit", price = 2 }); list2.Add(new Flavour() { id = 3, name = "Yogurt", price = 2 }); //Assigning combo the list coboFlav.DataSource = list2; //Assigning Vals coboFlav.ValueMember = "id"; coboFlav.DisplayMember = "Name"; BaseTea listItem1 = ListCopy.MyList.Find(x => (x.name == "Green Tea")); //StartUp Check Checking Base Tea Box for adding price to currentItemTotal if (coboBaseTea.Text == listItem1.name) { //Increament Item Cost Value currentTotalItemCost += listItem1.price; CurrentTotal.Text = "$" + currentTotalItemCost.ToString(); } }