Sunday, June 21, 2009

Nomadic Hands - Volunteer Required for a Website

Hi guys

I just bumped into this webdesign ad and wanted to share it with you.

The person needs a complete re-design for her website, and it would help you enhance your HTML/CSS skills if you apply for this job.

I have donated a template, but she might want to do changes on it.

The website to be changed is

http://nomadichands.com

Please let me know if you are interested :)

Wednesday, June 17, 2009

Just for Laughs

Is it just me or ... ?

Thursday, June 4, 2009

Pretest - Allan's Store

Class as follows:



using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace AllanStore
{
public class ComputerSystem
{
//fields
private int barcode;
private string description;
private string model;
private double price;
private Brand brand;

//properties
public int Barcode
{
get { return barcode; }
set { barcode = value; }
}
public string Description
{
get { return description; }
set { description = value; }
}
public string Model
{
get { return model; }
set { model = value; }
}
public double Price
{
get { return price; }
set { price = value; }
}
public Brand Brand
{
get { return brand; }
set { brand = value; }
}

//constructors
public ComputerSystem()
{
}

public ComputerSystem(int _barcode, string _description, Brand _brand, string _model, double _price)
{
this.barcode = _barcode;
this.description = _description;
this.brand = _brand;
this.model = _model;
this.price = _price;
}

//methods
public override string ToString()
{
return "" + barcode.ToString() + ", " + description.ToString() + ", " + brand.ToString() + ", " + model.ToString() + ", $" + price.ToString() + "\n";
}


}
}


Enum as follow:


public enum Brand
{
Asus=0,
Dell=1,
Hp=2,
Acer=3
}


Form as follows:


using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace AllanStore
{
public partial class Form1 : Form
{
//fields
private ComputerSystem[] computerArray = new ComputerSystem[10];

//properties
public ComputerSystem[] ComputerArray
{
get { return computerArray; }
set { computerArray = value; }
}

//constructors
public Form1()
{
InitializeComponent();
}

//methods - EVENTS
private void exitToolStripMenuItem_Click(object sender, EventArgs e)
{
DialogResult msg = MessageBox.Show("Are you sure?", "Exit", MessageBoxButtons.YesNo);
if (msg == DialogResult.Yes)
{
Close();
}
}

private void btnExit_Click(object sender, EventArgs e)
{
exitToolStripMenuItem_Click(sender, e);
}

private void addToolStripMenuItem_Click(object sender, EventArgs e)
{
if (checkAllFields() == true) //valid
{
ComputerSystem addObj = new ComputerSystem();
addObj.Barcode = int.Parse(txtBarcode.Text);
addObj.Price = double.Parse(txtPrice.Text);
addObj.Brand = (Brand)cmbBrand.SelectedItem;
addObj.Description = txtDescription.Text;
addObj.Model = txtModel.Text;

bool result = addSystem(addObj);

if (result == true)
{
MessageBox.Show("Computer System added!", "Added");
}
else
{
MessageBox.Show("Cannot Add, Array full!", "Cannot Add");
}

}
}

//methods - User defined
public void clearAllFields()
{
txtBarcode.Text = "";
cmbBrand.Text = "";
txtDescription.Text = "";
txtModel.Text = "";
txtPrice.Text = "";
}

public bool checkAllFields()
{
try
{
//fields errors
string errormessage = "";

if ((txtBarcode.Text == "") || (cmbBrand.Text == "") || (txtDescription.Text == "") || (txtModel.Text == "") || (txtPrice.Text == ""))
{
errormessage = "Please enter all fields";
}

//type errors
ComputerSystem testObj = new ComputerSystem();

testObj.Barcode = int.Parse(txtBarcode.Text);
testObj.Price = double.Parse(txtPrice.Text);
testObj.Brand = (Brand)cmbBrand.SelectedItem;

if (errormessage != "")
{
MessageBox.Show(errormessage, "Error occurred");
return false;
}
else
return true;


}
catch //catch type errors
{
MessageBox.Show("Please enter correct values in fields", "Error occurred");
return false;
}
}
public bool addSystem(ComputerSystem addObj)
{
for (int i = 0; i < computerArray.Length; i++)
{
if (computerArray[i] == null)
{
//perform add
computerArray[i] = addObj;
return true;
}
}
return false;
}

private void btnAdd_Click(object sender, EventArgs e)
{
addToolStripMenuItem_Click(sender, e);
}

private void Form1_Load(object sender, EventArgs e)
{
cmbBrand.Items.Add(Brand.Acer);
cmbBrand.Items.Add(Brand.Asus);
cmbBrand.Items.Add(Brand.Dell);
cmbBrand.Items.Add(Brand.Hp);
}

private void btnSearch_Click(object sender, EventArgs e)
{
searchToolStripMenuItem_Click(sender, e);
}

private void searchToolStripMenuItem_Click(object sender, EventArgs e)
{
try
{
ComputerSystem foundObj = new ComputerSystem();
foundObj = searchSystem(txtBarcode.Text);

if (foundObj == null)
{
MessageBox.Show("Cannot find Computer System", "No search found");
}
else
{
MessageBox.Show("System found");
txtBarcode.Text = foundObj.Barcode.ToString();
txtDescription.Text = foundObj.Description;
txtModel.Text = foundObj.Model;
txtPrice.Text = foundObj.Price.ToString();
cmbBrand.Text = foundObj.Brand.ToString();
}


}
catch
{
MessageBox.Show ("Barcode not valid", "Error");
}

}

public ComputerSystem searchSystem(string sbarcode)
{
try
{
int barcode = int.Parse(sbarcode);

for (int i = 0; i < computerArray.Length; i++)
{
if ((computerArray[i] != null) && (computerArray[i].Barcode == barcode)) //found match
{
return computerArray[i];
}

}
return null;
}
catch
{
return null;

}
}

private void btnUpdate_Click(object sender, EventArgs e)
{
updateToolStripMenuItem_Click(sender, e);
}

public bool updateSystem(string sbarcode, ComputerSystem updateObj)
{
try
{
int barcode = int.Parse(sbarcode);
for (int i = 0; i < computerArray.Length; i++)
{
if ((computerArray[i] != null) && (computerArray[i].Barcode == barcode))
{
computerArray[i] = updateObj;
return true;
}
}
return false;
}
catch
{
return false;
}
}

private void updateToolStripMenuItem_Click(object sender, EventArgs e)
{
if (checkAllFields() == true)
{
ComputerSystem updateObj = new ComputerSystem();
updateObj.Barcode = int.Parse(txtBarcode.Text);
updateObj.Price = double.Parse(txtPrice.Text);
updateObj.Brand = (Brand)cmbBrand.SelectedItem;
updateObj.Description = txtDescription.Text;
updateObj.Model = txtModel.Text;

bool updateresult = updateSystem(txtBarcode.Text, updateObj);

if (updateresult == true)
{
MessageBox.Show("System successfully updated");
}
else
{
MessageBox.Show("Cannot update system", "Error");
}
}
}

private void deleteToolStripMenuItem_Click(object sender, EventArgs e)
{
bool deleteresult = deleteSystem(txtBarcode.Text);
if (deleteresult == true)
{
MessageBox.Show("System deleted");
clearAllFields();
}
else
{
MessageBox.Show("Cannot find system", "Delete failed");
}
}

public bool deleteSystem(string sbarcode)
{
try
{
int barcode = int.Parse(sbarcode);

for (int i = 0; i < computerArray.Length; i++)
{
if ((computerArray[i] != null) && (computerArray[i].Barcode == barcode))
{
computerArray[i] = null;
return true;
}
}
return false;
}
catch
{
return false;
}
}

private void btnDelete_Click(object sender, EventArgs e)
{
deleteToolStripMenuItem_Click(sender, e);
}

private void btnDisplayAll_Click(object sender, EventArgs e)
{
displayAllToolStripMenuItem_Click(sender, e);
}

private void displayAllToolStripMenuItem_Click(object sender, EventArgs e)
{
string myComputers = "";
for (int i = 0; i < computerArray.Length; i++)
{
if (computerArray[i] != null)
{
myComputers += computerArray[i].ToString();
}
}

MessageBox.Show(myComputers, "Computer Lists");
}

private void btnAbout_Click(object sender, EventArgs e)
{
AboutBox1 about = new AboutBox1();
about.Show();
}

private void aboutToolStripMenuItem1_Click(object sender, EventArgs e)
{
btnAbout_Click(sender, e);
}

}
}

Wednesday, June 3, 2009

Incomplete Entry : Exam - Tips for Programming with Classes

Hi guys

I'm compiling some tips, or a 'cheat-sheet', that could help all of us to get great marks for the C# exam due on Thursday 11th June.

You might want to check it from time to time as I will update this entry frequently. Please do not hesitate to ask questions or suggestions, this place is also a discussion area :)

A step-by-step tutorial on how to get 70%+ for the exam!

Contents
1. Getting started - writing the class!
2. Creating the Graphical User Interface - Form Level
3. Creating your array of objects writing your methods for add, delete, update, display and search!

Checklist


1. Writing the Class
After creating a class file with the appropriate name from the Solution Explorer, immediately change the class MODIFIER. You want the MODIFIER to be PUBLIC.


public class MyProperty


1.1. Separate your class file into following sections

1.1.1. Fields
This contains all the fields or elements that are innate to the object, i.e. required to define this object.
As a matter of fact, you ALWAYS want them to be PRIVATE, so that no other objects from other classes can 'see' the fields. That's what we call encapsulation.


private string suburb;
private int bedrooms;
private int price;


1.1.2. Properties
Properties are the 'getters' and 'setters' of the fields described in 2.1. They access those fields and modify their value.
You might want to use the 're-factor' function in Visual Studio to do this quickly.

Right-click on the private field (e.g. suburb), hover on Refactor, and click on Encapsulate field. Click OK on the following message boxes to use the default properties name.


public string Suburb
{
get { return suburb; }
set { suburb = value; }
}


1.1.3. Constructors
Usually, you will require to implement at least 2 constructors, the first one being the null constructor. In the exam, the other constructor will be stated, for example, asking you to use 3 fields to pass in the constructor.
Writing the null constructor is a good practice, even if not explicitly asked during examination. Your constructors will ALWAYS be PUBLIC.


public MyProperty()
{
}

public MyProperty(string _suburb, int _bedrooms, int _price)
{
this.suburb = _suburb;
this.bedrooms = _bedrooms;
this.price = _price;
}


1.1.4. Methods
This section will implement the functions, or methods, that will be required to accomplish a certain task.
You might be ask to override the ToString() method, which means that you will have to re-define the passing parameters of the ToString(), and change its code to adapt to a situation.
Note: You ALWAYS write your methods with PUBLIC modifiers.


//override ToString() method
public override string ToString()
{
string msg = "";
msg = suburb.ToString() + ", " + bedrooms.ToString() + ", " + price.ToString() + "\n";
return msg;
}


Done with classes!

Back to the Table of Contents

2. Graphical User Interface - Form
Do as you are told in the exam, not too fancy design, but you will need those functions:
Add
Delete
Update
Display
Search

Note: Additional functions might be required, but you essentially need those.

Back to the Table of Contents

3. Creating your array of objects writing your methods for add, delete, update, display and search!
This is my favourite part!
You might want to know that we are done working with the class file, so everything that is being explained as from this section, is done in the FORM file or class.

3.1. Declaring your array
The first question would be to create an array of objects. Some students might be confused when declaring an array of objects. Just follow this rule of thumb:


ClassName[] arrayofObjects = new ClassName[10];


Of course, you might want to modify the length of the array to whatever figure required for the exam. I used 10. For those who didn't notice. :)

3.2. Add method (PUBLIC)
Return type: boolean
Passing parameters: the object to be added
Method signature: public bool addMethod(ClassName objectName)


public bool addProperty(MyProperty propObj)
{
for (int i = 0; i < propertyArray.Length; i++)
{
if (propertyArray[i] == null)
{
propertyArray[i] = propObj;
return true;
}
}
return false;
}


How it works:
Before you can add an object to your array, you need to check if there is a free space or slot for the object to be added.
You loop through ALL items in the array.
If null (meaning that this space is unoccupied), you assign this array position to the object to be added.
You need to return a boolean to tell the caller that the method has been successful.

Combining the Add method with the form:
i. Create an instance of the class, also known as the object of the class.
ii. Assign all the values that have been entered by the user to the object's properties.
iii. Call the method and store it in a boolean variable.
iv. Do the necessary validation if addition has been successful or not.



MyProperty propObj = new MyProperty(); //create an object

//assign fields to user entered values
propObj.Suburb = txtSuburb.Text;
propObj.Bedrooms = int.Parse(txtBedrooms.Text);
propObj.Price = int.Parse(txtPrice.Text);

//call add function and store result in a boolean variable
bool bool_add = addProperty(propObj);

//do the validations
if (bool_add == true)
{
MessageBox.Show("Property added!");
clearAllFields(); //clears fields
}
else
{
MessageBox.Show("No more property can be stored in the array");
}



Back to the Table of Contents


Checklist
1) Only the fields defined in your class are PRIVATE. All other entries are PUBLIC.

Allan's Pre-test MyProperty

Below is the Property class.



using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace BASIC
{
public class MyProperty
{
//fields
private string suburb;
private int bedrooms;
private int price;

//properties
public string Suburb
{
get { return suburb; }
set { suburb = value; }
}

public int Bedrooms
{
get { return bedrooms; }
set { bedrooms = value; }
}

public int Price
{
get { return price; }
set { price = value; }
}

//constructors
public MyProperty()
{
}

public MyProperty(string _suburb, int _bedrooms, int _price)
{
this.suburb = _suburb;
this.bedrooms = _bedrooms;
this.price = _price;
}


//methods
//override ToString() method
public override string ToString()
{
string msg = "";
msg = suburb.ToString() + ", " + bedrooms.ToString() + ", " + price.ToString() + "\n";
return msg;
}
}
}


Below is the form class:



using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace BASIC
{
public partial class Form1 : Form
{
//fields
private MyProperty[] propertyArray = new MyProperty[10];

//properties
public MyProperty[] PropertyArray
{
get { return propertyArray; }
set { propertyArray = value; }
}

//constructors
public Form1()
{
InitializeComponent();
}

#region methods
//methods

//check for valid fields
public bool checkAllFields()
{
try
{
if ((txtSuburb.Text != "") && (txtPrice.Text != "") && (txtBedrooms.Text != "") ) //check for empty fields
{
int testInt = int.Parse(txtPrice.Text);
testInt = int.Parse(txtBedrooms.Text); //if cannot parse, goto catch section and handle error

return true;
}
else
{
return false; //error occurred
}
}
catch
{
return false; //error occurred
}
}

//adds property
public bool addProperty(MyProperty propObj)
{
for (int i = 0; i < propertyArray.Length; i++)
{
if (propertyArray[i] == null)
{
propertyArray[i] = propObj;
return true;
}
}
return false;
}

//updates property
public bool updateProperty(MyProperty updatedObj)
{
for (int i = 0; i < PropertyArray.Length; i++)
{
if ((propertyArray[i] != null) && (propertyArray[i].Suburb == updatedObj.Suburb) && (propertyArray[i].Bedrooms == updatedObj.Bedrooms))
{
propertyArray[i] = updatedObj;
return true;
}
}

return false; //cannot find object
}

//delete property
public bool deleteProperty(string propName)
{
for (int i = 0; i < propertyArray.Length; i++)
{
if ((propertyArray[i].Suburb == propName) && (propertyArray[i] != null))
{
propertyArray[i] = null;
return true;
}
}
return false; //object not found
}

//get sum
public double getSum()
{
double sum = 0;
for (int i = 0; i < propertyArray.Length; i++)
{
if (propertyArray[i] != null)
{
sum += propertyArray[i].Price;
}
}
return sum;
}

//get average
public double getAverage()
{
double sum = 0;
double propitem = 0;
for (int i = 0; i < propertyArray.Length; i++)
{
if (propertyArray[i] != null)
{
sum += propertyArray[i].Price;
propitem++;
}
}
return (sum/propitem);//average
}

//get max
public double getMax()
{
double dMax = 0;

for (int i = 0; i < propertyArray.Length; i++)
{
if (propertyArray[i] != null)
{
if (propertyArray[i].Price >= dMax)
dMax = propertyArray[i].Price;
}
}
return (dMax);//Max
}

//get min
public double getMin()
{
bool arrayExist = false;
double dMin = 999999999;

for (int i = 0; i < propertyArray.Length; i++)
{
if (propertyArray[i] != null)
{
if (propertyArray[i].Price <= dMin)
dMin = propertyArray[i].Price;
arrayExist = true;
}
}
if (arrayExist == true)
{
return (dMin);//Min
}
else
{
return 0;
}
}

public void clearAllFields()
{
txtBedrooms.Text = "";
txtPrice.Text = "";
txtSuburb.Text = "";
}

#endregion

#region events
private void Form1_Load(object sender, EventArgs e)
{

}

private void addNewPropertyToolStripMenuItem_Click(object sender, EventArgs e)
{
if (checkAllFields() == true)
{
MyProperty propObj = new MyProperty();

propObj.Suburb = txtSuburb.Text;
propObj.Bedrooms = int.Parse(txtBedrooms.Text);
propObj.Price = int.Parse(txtPrice.Text);

bool bool_add = addProperty(propObj);

if (bool_add == true)
{
MessageBox.Show("Property added!");
clearAllFields(); //clears fields
}
else
{
MessageBox.Show("No more property can be stored in the array");
}

}
else
{
MessageBox.Show("Fields are not valid");
}
}

private void updatePropertyToolStripMenuItem_Click(object sender, EventArgs e)
{
if (checkAllFields() == true)
{
MyProperty updateProp = new MyProperty();

updateProp.Suburb = txtSuburb.Text;
updateProp.Price = int.Parse(txtPrice.Text);
updateProp.Bedrooms = int.Parse(txtBedrooms.Text);

if (updateProperty(updateProp)) //true
{
MessageBox.Show("Property updated!");
clearAllFields(); //clears fields
}
else //false
{
MessageBox.Show("Cannot find property for update!");
}

}
else
{
MessageBox.Show("Fields are not valid");
}
}

private void deletePropertyToolStripMenuItem_Click(object sender, EventArgs e)
{
bool deleteProp;
if (txtSuburb.Text != "")
{
deleteProp = deleteProperty(txtSuburb.Text);

if (deleteProp == true)
{
MessageBox.Show("Property deleted!");
clearAllFields(); //clears fields
}
else
{
MessageBox.Show("Cannot find property to delete");
}
}
else
{
MessageBox.Show("Please enter a Suburb name");
txtSuburb.Focus();
}
}

private void displayPropertiesToolStripMenuItem_Click(object sender, EventArgs e)
{
string allPropList = "";
for (int i = 0; i < propertyArray.Length; i++)
{
if (propertyArray[i] != null)
{
allPropList += propertyArray[i].ToString();
}
}

if (allPropList == "")
{
MessageBox.Show("No property found");
}
else
{
MessageBox.Show(allPropList);
}
}

private void exitToolStripMenuItem_Click(object sender, EventArgs e)
{
Close();
}

private void aboutToolStripMenuItem_Click(object sender, EventArgs e)
{
MessageBox.Show("Property Application. Pre-test example");
}

private void displayTotalToolStripMenuItem_Click(object sender, EventArgs e)
{
double sum = getSum();
MessageBox.Show("Total Property Price : $ " + sum.ToString());
}

private void displayAverageToolStripMenuItem_Click(object sender, EventArgs e)
{
double average = getAverage();
MessageBox.Show("Total Average Price : $ " + average.ToString());
}

private void displayMaxToolStripMenuItem_Click(object sender, EventArgs e)
{
double max = getMax();
MessageBox.Show("Max Price : $ " + max.ToString());
}

private void displayMinToolStripMenuItem_Click(object sender, EventArgs e)
{
double min = getMin();
MessageBox.Show("Min Price : $ " + min.ToString());
}

#endregion

}
}

Monday, June 1, 2009

Car Object, Using array of 10 objects

The Enum is as follows:




public enum Built
{
Hatch=0,
Sedan=1,
Wagon=2,
Coupe=3
}



The Car Class is as follows:




using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace MyCarProject
{
public class MyCar
{
//fields
#region fields
private string model;
private int year;
private string color;
private Built built;
#endregion

//properties
#region properties
public string Model
{
get { return model; }
set { model = value; }
}
public int Year
{
get { return year; }
set { year = value; }
}
public string Color
{
get { return color; }
set { color = value; }
}
public Built Built
{
get { return built; }
set { built = value; }
}
#endregion

//constructors
#region constructors
public MyCar()
{
}

public MyCar(string _model, int _year, string _color, Built _built)
{
this.model = _model;
this.year = _year;
this.color = _color;
this.built = _built;
}
#endregion

//methods
#region methods

public override string ToString()
{
string msg = "";
msg = "Model : " + this.model + "\n" +
"Year : " + this.year + "\n" +
"Color : " + this.color + "\n" +
"Built : " + this.built;
return msg;
}
#endregion

}
}


The Form is as follows:




using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace MyCarProject
{
public partial class Form1 : Form
{
//fields
#region fields
private MyCar[] carArray = new MyCar[10];
#endregion

//properties
#region properties
public MyCar[] CarArray
{
get { return carArray; }
set { carArray = value; }
}

#endregion

//constructors
#region constructors
public Form1()
{
InitializeComponent();
}
#endregion

//methods-events
#region methods-events
private void Form1_Load(object sender, EventArgs e)
{
//add Built items into combobox
cmbBuilt.Items.Add(Built.Coupe);
cmbBuilt.Items.Add(Built.Hatch);
cmbBuilt.Items.Add(Built.Sedan);
cmbBuilt.Items.Add(Built.Wagon);
}

public bool addCar(MyCar obj)
{
for (int i = 0; i < carArray.Length; i++)
{
if (carArray[i] == null)
{
carArray[i] = obj;
return true;
}
}

return false;
}

public MyCar searchByModel(string _model)
{
for (int i = 0; i < carArray.Length; i++)
{
if (_model == carArray[i].Model)
{
return carArray[i];
}
}
return null;
}

public bool updateCar(string _model, MyCar obj)
{
for (int i = 0; i < carArray.Length; i++)
{
if ((_model == carArray[i].Model) && (carArray[i] != null))
{
carArray[i] = obj; //update car object
return true;
}
}
return false;
}

public bool deleteCar(string _model)
{
for (int i = 0; i < carArray.Length; i++)
{
if ((carArray[i].Model == _model) && (carArray[i] != null))
{
carArray[i] = null;
return true;
}
}
return false;
}

public string displayAllCars()
{
string msg = "";
for (int i = 0; i < carArray.Length; i++)
{
if (carArray[i] != null)
{
msg += carArray[i].ToString() + "\n\n";
}
}
return msg;
}

private void btnAdd_Click(object sender, EventArgs e)
{
//read gui
MyCar carObj = new MyCar();

try
{
carObj.Model = txtModel.Text;
carObj.Year = int.Parse(txtYear.Text);
carObj.Color = txtColor.Text;
carObj.Built = (Built)cmbBuilt.SelectedItem;

bool boolAdd = addCar(carObj);
if (boolAdd == true)
{
MessageBox.Show("Car successfully added.");
}
else
{
MessageBox.Show("Car NOT added. Car Array might be full.");
}
}
catch //parsing error
{
MessageBox.Show("Please fill all appropriate fields with correct values");
}

}

private void btnSearch_Click(object sender, EventArgs e)
{
try
{
MyCar obj = searchByModel(txtModel.Text);

if (obj != null) //car found
{
txtYear.Text = "" + obj.Year;
txtColor.Text = "" + obj.Color;
cmbBuilt.SelectedItem = obj.Built;
MessageBox.Show("Car found");
}
else
{
MessageBox.Show("Car not found");
}

}
catch
{
MessageBox.Show("Please enter a valid model name");
txtModel.Focus();
}
}

private void btnUpdate_Click(object sender, EventArgs e)
{

try
{
MyCar car = new MyCar();
car.Model = txtModel.Text;
car.Year = int.Parse(txtYear.Text);
car.Color = txtColor.Text;
car.Built = (Built)cmbBuilt.SelectedItem;

bool boolUpdate = updateCar(car.Model, car);

if (boolUpdate == true)
{
MessageBox.Show("Update Completed");
}
else
{
MessageBox.Show("Update Failed");
}
}
catch
{
MessageBox.Show("Could not perform update");
}

}

private void btnDelete_Click(object sender, EventArgs e)
{
try
{
bool boolDelete = deleteCar(txtModel.Text);

if (boolDelete == true)
MessageBox.Show("Delete Completed");
else
MessageBox.Show("Delete Failed");
}
catch
{
MessageBox.Show("Could not perform delete");
}



}

private void btnDisplayAll_Click(object sender, EventArgs e)
{
string carList = displayAllCars();

if (carList != "")
{
MessageBox.Show(carList);
}
else
{
MessageBox.Show("No cars available to display");
}
}
#endregion
}
}