//button add private void ButtonAdd_Click(object sender, EventArgs e) { if (radioButtonMountain.Checked == true) { MountainBikes M1 = new MountainBikes() { SerialNumber = Convert.ToInt32(textBoxSn.Text), Model = textBoxModel.Text, Band = textBoxBrand.Text, Weight = Convert.ToInt32(textBoxWeight.Text), Color = (EnumColor)this.comboBoxColor.SelectedItem, Wheel = (EnumWheel)this.comboBoxWheel.SelectedItem, Speed = (EnumSpeed)this.comboBoxSpeed.SelectedItem, Height_from_ground = Convert.ToInt32(textBoxHFG.Text), Suspension = (EnumSuspension)this.comboBoxTFS.SelectedItem, }; Date madedate = new Date { Year = Convert.ToInt32(textBoxYear.Text), Month = Convert.ToInt32(textBoxMonth.Text), Day = Convert.ToInt32(textBoxDay.Text) }; M1.MadeDate = madedate; Bikes B1 = M1; Bikelist.Add(B1); Mountainlist.Add(M1); } else if (radioButtonRoad.Checked == true) { RoadBikes R1 = new RoadBikes() { SerialNumber = Convert.ToInt32(textBoxSn.Text), Model = textBoxModel.Text, Band = textBoxBrand.Text, Weight = Convert.ToInt32(textBoxWeight.Text), Color = (EnumColor)this.comboBoxColor.SelectedItem, Wheel = (EnumWheel)this.comboBoxWheel.SelectedItem, Speed = (EnumSpeed)this.comboBoxSpeed.SelectedItem, SeatHight = Convert.ToInt32(textBoxSeatH.Text) }; Date madedate = new Date { Year = (Convert.ToInt32(textBoxYear.Text)), Month = (Convert.ToInt32(textBoxMonth.Text)), Day = (Convert.ToInt32(textBoxDay.Text)) }; R1.MadeDate = madedate; Bikes B1 = R1; Bikelist.Add(B1); Roadlist.Add(R1); } }
//button search private void ButtonSearch_Click(object sender, EventArgs e) { if (radioButtonMountain.Checked == true) { int temp = Convert.ToInt32(textBoxSearch.Text); bool found = false; MountainBikes searchedM = new MountainBikes(); foreach (MountainBikes item in this.Mountainlist) { if (item.SerialNumber == temp) { found = true; searchedM = item; break; } } if (found) { MessageBox.Show("Mountianbike Found....\n" + searchedM); } else { MessageBox.Show("Mountainbike Not Found"); } } else if (radioButtonRoad.Checked == true) { int temp = Convert.ToInt32(textBoxSearch.Text); bool found = false; RoadBikes searchedR = new RoadBikes(); foreach (RoadBikes item in this.Roadlist) { if (item.SerialNumber == temp) { found = true; searchedR = item; break; } } if (found) { MessageBox.Show("Roadbike Found....\n" + searchedR); } else { MessageBox.Show("Roadbike Not Found"); } } }
private void buttonBrake_Click(object sender, EventArgs e) { if (radioButtonMountain.Checked == true) { IBikes m1 = new MountainBikes(); String inter = m1.Brake(); MessageBox.Show(inter); } else if (radioButtonRoad.Checked == true) { IBikes r1 = new RoadBikes(); String inter = r1.Brake(); MessageBox.Show(inter); } }
/*****************SUSPENSION BUTTON***************/ private void BtSuspension_Click(object sender, EventArgs e) { if (myListOfBikes[index].GetType() == typeof(MountainBikes)) { MountainBikes aBike = new MountainBikes(); 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.installSuspension(); myListOfBikes[index] = aBike; MessageBox.Show("New Suspension Installed"); DisplayListView(); } else { MessageBox.Show("This bike does not use suspension"); } }
private void buttonAdd_Click(object sender, EventArgs e) { //Bikes newBike = new Bikes(); RoadBikes newRoadBikes = new RoadBikes(); MountainBikes newMountainBikes = new MountainBikes(); //Validation bool correct = false; if (Validator.Is12Digit(textBoxSrNum.Text)) { correct = true; } if (!correct) { MessageBox.Show("you must input 12 digit for serial number", "WARNING", MessageBoxButtons.OK, MessageBoxIcon.Warning); } ; correct = false; if (Validator.IsAlphabetNumber(textBoxMd.Text)) { correct = true; } if (!correct) { MessageBox.Show("you must input character for made", "WARNING", MessageBoxButtons.OK, MessageBoxIcon.Warning); } ; correct = false; if (Validator.IsEmpty(textBoxSrNum.Text) || Validator.IsEmpty(textBoxMd.Text) || Validator.IsEmpty(textBoxYear.Text) || Validator.IsEmpty(textBoxSpd.Text) || Validator.IsEmpty(textBoxPrice.Text)) { correct = true; } if (!correct) { MessageBox.Show("you must not leave empty", "WARNING", MessageBoxButtons.OK, MessageBoxIcon.Warning); } ; if (radioButtonRdBikes.Checked == true) { if (!String.IsNullOrEmpty(textBoxSrNum.Text) && !String.IsNullOrEmpty(textBoxMd.Text) && !String.IsNullOrEmpty(textBoxSpd.Text) && !String.IsNullOrEmpty(textBoxYear.Text) && !String.IsNullOrEmpty(comboBoxClr.Text)) { newRoadBikes.SerNum = Convert.ToInt64(this.textBoxSrNum.Text); newRoadBikes.Make = this.textBoxMd.Text; newRoadBikes.Speed = Convert.ToInt32(this.textBoxSpd.Text); newRoadBikes.Color = (EnumColor)positionColor; newRoadBikes.Year = Convert.ToInt32(this.textBoxYear.Text); newRoadBikes.Price = Convert.ToInt32(this.textBoxPrice.Text); newRoadBikes.SeatHeight = Convert.ToInt32(this.textBoxStHght.Text); newRoadBikes.Weight = Convert.ToInt32(this.textBoxWght.Text); rdList.Add(newRoadBikes); listBoxDisplay.Items.Add(newRoadBikes); myList.AddRange(rdList); } } else if (radioButtonMtnBikes.Checked == true) { if (!String.IsNullOrEmpty(textBoxSrNum.Text) && !String.IsNullOrEmpty(textBoxMd.Text) && !String.IsNullOrEmpty(textBoxSpd.Text) && !String.IsNullOrEmpty(textBoxYear.Text) && !String.IsNullOrEmpty(comboBoxClr.Text)) { newMountainBikes.SerNum = Convert.ToInt64(this.textBoxSrNum.Text); newMountainBikes.Make = this.textBoxMd.Text; newMountainBikes.Speed = Convert.ToInt32(this.textBoxSpd.Text); newMountainBikes.Color = (EnumColor)positionColor; newMountainBikes.Year = Convert.ToInt32(this.textBoxYear.Text); newMountainBikes.Price = Convert.ToInt32(this.textBoxPrice.Text); newMountainBikes.Height = Convert.ToInt32(this.textBoxHght.Text); newMountainBikes.Suspension = (EnumSuspension)positionSuspension; newMountainBikes.Headlight = (EnumHeadlight)positionHdLight; mtList.Add(newMountainBikes); listBoxDisplay.Items.Add(newMountainBikes); myList.AddRange(mtList); } } else if (String.IsNullOrEmpty(textBoxSrNum.Text) && String.IsNullOrEmpty(textBoxMd.Text) && String.IsNullOrEmpty(textBoxSpd.Text) && String.IsNullOrEmpty(textBoxYear.Text)) { MessageBox.Show("NO DATA...", "WARNING", MessageBoxButtons.OK, MessageBoxIcon.Warning); } else { MessageBox.Show("Select the Bike Type !", "WARNING", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
/*****************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(); } }