/*****************ENGINE BUTTON***************/ private void BtEngine_Click(object sender, EventArgs e) { if (index != -1) { if (myListOfBikes[index].GetType() == typeof(MotorBikes)) { MotorBikes aBike = new MotorBikes(); aBike.SerialNumber = myListOfBikes[index].SerialNumber; aBike.Manufacturer = myListOfBikes[index].Manufacturer; aBike.MadeIn = myListOfBikes[index].MadeIn; aBike.BikeColor = myListOfBikes[index].BikeColor; aBike.BikeType = myListOfBikes[index].BikeType; aBike.ManufactureDate = myListOfBikes[index].ManufactureDate; aBike.startEngine(); myListOfBikes[index] = aBike; MessageBox.Show("Engine Started"); } else { MessageBox.Show("This bike does not have an engine"); } } else { MessageBox.Show("Select and item"); } }
/*****************ADD BUTTON***************/ private void BtAdd_Click(object sender, EventArgs e) { if ((EnumBikeType)this.cbType.SelectedItem == EnumBikeType.Speed) { SpeedBikes aBike = new SpeedBikes(); aBike.SerialNumber = Convert.ToInt32(this.tbSerialNumber.Text); aBike.Manufacturer = this.tbManufacturer.Text; aBike.MadeIn = this.tbMadeIn.Text; aBike.BikeType = (EnumBikeType)this.cbType.SelectedItem; aBike.BikeColor = (EnumBikeColor)this.cbColor.SelectedItem; aBike.ManufactureDate = Convert.ToString(this.dateManufacturer.Value); this.myListOfBikes.Add(aBike); mRefresh(); DisplayListView(); } else if ((EnumBikeType)this.cbType.SelectedItem == EnumBikeType.Road) { RoadBikes aBike = new RoadBikes(); aBike.SerialNumber = Convert.ToInt32(this.tbSerialNumber.Text); aBike.Manufacturer = this.tbManufacturer.Text; aBike.MadeIn = this.tbMadeIn.Text; aBike.BikeType = (EnumBikeType)this.cbType.SelectedItem; aBike.BikeColor = (EnumBikeColor)this.cbColor.SelectedItem; aBike.ManufactureDate = Convert.ToString(this.dateManufacturer.Value); this.myListOfBikes.Add(aBike); mRefresh(); DisplayListView(); } else if ((EnumBikeType)this.cbType.SelectedItem == EnumBikeType.Mountain) { MountainBikes aBike = new MountainBikes(); aBike.SerialNumber = Convert.ToInt32(this.tbSerialNumber.Text); aBike.Manufacturer = this.tbManufacturer.Text; aBike.MadeIn = this.tbMadeIn.Text; aBike.BikeType = (EnumBikeType)this.cbType.SelectedItem; aBike.BikeColor = (EnumBikeColor)this.cbColor.SelectedItem; aBike.ManufactureDate = Convert.ToString(this.dateManufacturer.Value); this.myListOfBikes.Add(aBike); mRefresh(); DisplayListView(); } else if ((EnumBikeType)this.cbType.SelectedItem == EnumBikeType.Motor) { MotorBikes aBike = new MotorBikes(); aBike.SerialNumber = Convert.ToInt32(this.tbSerialNumber.Text); aBike.Manufacturer = this.tbManufacturer.Text; aBike.MadeIn = this.tbMadeIn.Text; aBike.BikeType = (EnumBikeType)this.cbType.SelectedItem; aBike.BikeColor = (EnumBikeColor)this.cbColor.SelectedItem; aBike.ManufactureDate = Convert.ToString(this.dateManufacturer.Value); this.myListOfBikes.Add(aBike); mRefresh(); DisplayListView(); } else if ((EnumBikeType)this.cbType.SelectedItem == EnumBikeType.BMX) { BMXBikes aBike = new BMXBikes(); aBike.SerialNumber = Convert.ToInt32(this.tbSerialNumber.Text); aBike.Manufacturer = this.tbManufacturer.Text; aBike.MadeIn = this.tbMadeIn.Text; aBike.BikeType = (EnumBikeType)this.cbType.SelectedItem; aBike.BikeColor = (EnumBikeColor)this.cbColor.SelectedItem; aBike.ManufactureDate = Convert.ToString(this.dateManufacturer.Value); this.myListOfBikes.Add(aBike); mRefresh(); DisplayListView(); } }