private void AddPhoneButton_Click(object sender, EventArgs e) { // create a cellphone object CellPhoneInventory myphone = new CellPhoneInventory(); // get the phone data getdata(myphone); //Add the cell phone object to the list phoneList.Add(myphone); // add the entry to the list box PhoneListBox.Items.Add(myphone.Brand + " " + myphone.Model); // clear the contents of the textbox BrandTextBox.Clear(); ModelTextBox.Clear(); PriceTextBox.Clear(); BrandTextBox.Focus(); }
private void createVehicleButton_Click(object sender, EventArgs e) { if (MakeTextBox.Text == null || ModelTextBox.Text == null || yearTextBox.Text == null || mileageTextBox.Text == null || comboBox1.Text == null) { MessageBox.Show("Fill in All Values", "ERROR"); } else { string Make = MakeTextBox.Text; string Model = ModelTextBox.Text; string year = yearTextBox.Text; string mileage = mileageTextBox.Text; string type = comboBox1.Text; Vehicle newvehicle = new Vehicle(Model, Make, year, mileage, type); Form1.vehicles = Vehicle.loadVehicles(); var local_vehicles = Form1.vehicles; local_vehicles.Add(newvehicle); //System.IO.StreamReader file = new System.IO.StreamReader(@"C:\\Users\\J Aldo\\source\\Car_Rental_Service\\Car_Rental_Service\\vehicle.txt"); StreamWriter sw = new StreamWriter(@"C:\\Users\\J Aldo\\source\\Car_Rental_Service\\Car_Rental_Service\\vehicles.txt"); string outline; ////////////////////// Check ///////////////////////// foreach (Vehicle vehicle in local_vehicles) { bool refer = true; outline = vehicle.make + ", " + vehicle.model + ", " + vehicle.year + ", " + vehicle.mileage + ", " + vehicle.type; if (refer == true) { sw.WriteLine(outline); } else { MessageBox.Show("Invalid, vehicle duplicate"); } } sw.Close(); MessageBox.Show("vehicle Added"); MakeTextBox.Clear(); ModelTextBox.Clear(); yearTextBox.Clear(); mileageTextBox.Clear(); } }
//Writing method private void _SaveInfo() { //makes sure user is ready to save DialogResult UserResult = MessageBox.Show("Are You Sure?", "Confirm", MessageBoxButtons.YesNo); if (UserResult == DialogResult.Yes) { // Open a writer and Write to the file _writer = new StreamWriter("Product.txt", true); _writer.WriteLine(ProductIDTextbox.Text + _DELIMETER + ConditionTextbox.Text + _DELIMETER + CostTextbox.Text + _DELIMETER + PlatformTextBox.Text + _DELIMETER + ManufactuerTextbox.Text + _DELIMETER + OSTextbox.Text + _DELIMETER + ModelTextBox + _DELIMETER + MemoryTextBox.Text + _DELIMETER + LCDTextbox.Text + _DELIMETER + HDDTextbox.Text + _DELIMETER + CPUBrandTextbox.Text + _DELIMETER + CPUNumberTextbox.Text + _DELIMETER + CPUSpeedTextbox.Text + _DELIMETER + GPUTextbox.Text + _DELIMETER + WebcamTextbox.Text); //Close the file _writer.Close(); // Resets all boxes ProductIDTextbox.Clear(); ConditionTextbox.Clear(); CostTextbox.Clear(); PlatformTextBox.Clear(); ManufactuerTextbox.Clear(); OSTextbox.Clear(); ModelTextBox.Clear(); MemoryTextBox.Clear(); LCDTextbox.Clear(); HDDTextbox.Clear(); CPUBrandTextbox.Clear(); CPUNumberTextbox.Clear(); CPUTypeTextbox.Clear(); GPUTextbox.Clear(); CPUSpeedTextbox.Clear(); WebcamTextbox.Clear(); } }
// reset the form; private void ResetForm() { ProductIDTextBox.Clear(); ConditionTextBox.Clear(); CostTextBox.Clear(); PlatformTextBox.Clear(); OSTextBox.Clear(); ManufacturerTextBox.Clear(); ModelTextBox.Clear(); MemoryTextBox.Clear(); LCDSizeTextBox.Clear(); HDDTextBox.Clear(); CPUBrandTextBox.Clear(); CPUNumberTextBox.Clear(); GPUTypeTextBox.Clear(); CPUTypeTextBox.Clear(); CPUSpeedTextBox.Clear(); WebCamTextBox.Clear(); }
private void ResetForm() { ProductTextBox.Clear(); ConditionTextBox.Clear(); CostTextBox.Clear(); PlatFormTextBox.Clear(); OsTextBox.Clear(); ManuFacTextBox.Clear(); ModelTextBox.Clear(); MemoryTextBox.Clear(); LCDTextBox.Clear(); HDDTextBox.Clear(); CPUBTextBox.Clear(); CPUNumTextBox.Clear(); GPUTTextBox.Clear(); CPUTTextBox.Clear(); CPUspeedTextBox.Clear(); WebCamTextBox.Clear(); }