private void buttonSearch_Click(object sender, EventArgs e) { if (radioButtonMountain.Checked == true) { int temp = Convert.ToInt32(textBoxSearch.Text); bool found = false; Mountainbike searchedMountain = new Mountainbike(); foreach (Mountainbike item in this.Mountainlist) { if (item.Sn == temp) { found = true; searchedMountain = item; break; } } if (found) { MessageBox.Show("Mountianbike Found....\n" + searchedMountain); } else { MessageBox.Show("Mountainbike Not Found"); } } else if (radioButtonRoad.Checked == true) { int temp = Convert.ToInt32(textBoxSearch.Text); bool found = false; Roadbike searchedRoad = new Roadbike(); foreach (Roadbike item in this.Roadlist) { if (item.Sn == temp) { found = true; searchedRoad = item; break; } } if (found) { MessageBox.Show("Roadbike Found....\n" + searchedRoad); } else { MessageBox.Show("Roadbike Not Found"); } } }
private void buttonAdd_Click(object sender, EventArgs e) { if (radioButtonMountain.Checked == true) { Mountainbike M1 = new Mountainbike(); M1.Biketype = radioButtonMountain.Text; M1.Sn = (Convert.ToInt32(textBoxSn.Text)); M1.Model = textBoxModel.Text; M1.Price = (Convert.ToDouble(textBoxPrice.Text)); M1.Brand = textBoxBrand.Text; M1.Color = ((EnumColor)this.comboBoxColor.SelectedItem); M1.Style = ((EnumStyle)this.comboBoxStyle.SelectedItem); M1.Speed = ((EnumSpeed)this.comboBoxColor.SelectedItem); M1.Typefs = ((EnumType)this.comboBoxTypeofsuspension.SelectedItem); M1.Heightfg = (Convert.ToDouble(textBoxHeightfromground.Text)); Date madedate = new Date(); madedate.Year = (Convert.ToInt32(textBoxYear.Text)); madedate.Month = (Convert.ToInt32(textBoxMonth.Text)); madedate.Day = (Convert.ToInt32(textBoxDay.Text)); M1.Madedate = madedate; Bike b1 = M1; Bikelist.Add(b1); Mountainlist.Add(M1); } else if (radioButtonRoad.Checked == true) { Roadbike R1 = new Roadbike(); R1.Biketype = radioButtonRoad.Text; R1.Sn = (Convert.ToInt32(textBoxSn.Text)); R1.Model = textBoxModel.Text; R1.Price = (Convert.ToDouble(textBoxPrice.Text)); R1.Brand = textBoxBrand.Text; R1.Color = ((EnumColor)this.comboBoxColor.SelectedItem); R1.Style = ((EnumStyle)this.comboBoxStyle.SelectedItem); R1.Speed = ((EnumSpeed)this.comboBoxColor.SelectedItem); R1.Seatheight = (Convert.ToDouble(textBoxSeat.Text)); Date madedate = new Date(); madedate.Year = (Convert.ToInt32(textBoxYear.Text)); madedate.Month = (Convert.ToInt32(textBoxMonth.Text)); madedate.Day = (Convert.ToInt32(textBoxDay.Text)); R1.Madedate = madedate; Bike b2 = R1; Bikelist.Add(b2); Roadlist.Add(R1); } }