Monday, November 15, 2010

Registration Class

Public Class Registration

Private _intNumber As Integer
Private _intExpiryMonth As Integer

_intNumber=Number
_intExpiryMonth=ExpiryMonth

Public Function getRegNumber() As Integer
_intNumber=RegNumber
End Sub

Public Sub setRegNumber as

Car AND MotorBike Classes

Remember : A Child cannot exist without a parent!!

Public Class Car

InheritsVehicle

Private _intNumberOfPassengers As Integer

Public Sub New(Make As String, Model As String, RegNumber As Integer,RegExpiryDate As Integer)

MyBase.New(make,model,RegNumber,RegExpiryDate)

_intNumberOfPassengers=NumberOfPassengers

Public Sub New(Make As String, Model As String, RegNumber As Integer,RegExpiryDate As Integer,GeneralNotes As String, NumberOfPassengers As Integer)

MyBase.New(make,model,RegNumber,RegExpiryaDate,GeneralNotes)

int_NumberOfPassengers=NumberOfPassengers

Public Function getNumberOfPassengers()AsInteger
Return_intNumberOfPassengers
End Function

Public Sub setNumberOfPassengers(NumberOfPassengers As Integer)
_intNumberOfPassengers=NumberOfPassengers

End Sub

Public Sub AddToPassengers(NumberOfPassengers As Integer)
_intNumberOfPassengers +=NumberOfPassengers

End Class

____________________________________________________

Public Class MotorBike

InheritsVehicle

Public Sub New(Make As String, Model As String, RegNumber As Integer,RegExpiryDate As Integer)

Public Sub New(Make As String, Model As String, RegNumber As Integer,RegExpiryDate As Integer,GeneralNotes As String, NumberOfPassengers As Integer)

Task Three

Public MustInherit Class Vehicle

Protected _strName As String
Protected _strModel As String
Protected _strGeneralNotes As String
Protected _VechicleRegistration As Registration(RegNumber,RegExpiryDate)


Public Sub New(Make As String, Model As String, RegNumber As Integer,RegExpiryDate As Integer)

_strMake = Make
_strModel=Model
_VechicleRegistration = New Registration

Public Sub New(Make As String, Model As String, RegNumber As Integer,RegExpiryDate As Integer,GeneralNotes As String)

_strMake = Make
_strModel=Model
_strGeneralNotes=GeneralNotes
_VechicleRegistration = New Registration

Public Function getMake()As String
Return_strMake
End Function

Public Sub setMake(Make As String)
_strMake=Make

End Sub

Public Function getMocel()As String
Return_strModel

End Function

Public Sub setModel(Model As String)
_strModel=Model

End Sub

Public Function getGeneralNotes()As String
Return_strGeneralNotes 
End Function

Public Sub setGeneralNotes(GeneralNotes As String)
_strGeneralNotes=GeneralNotes

End Sub

Public Function getVechicleRegistration()As Registration
Return_strVechicleRegistration 
End Function

Public Sub setVechicleRegistration(ARegistration As Registration)
_strVechicleRegistration=ARegistration

End Sub

Public Sub AddToGeneralNotes(Notes As String)
_strGeneralNotes &=Notes
End Sub

Task Two

Week 4 and 5 and Week 10 = Resources

Coded in the WRITE Button

"WE PUT A TRY HERE SO THAT WE CAN CATCH AN EXCEPTION WHEN IT OCCURS"

Try

"IF STATMENT BEGINS"

If IO .File.Exists("Numbers.txt") Then

"DECLARE A STRING FOR MYNUMBERS WITH AN UPPERBOUND OF 4 AS IN THE ARRAY THERE ARE 5 ITEMS BUT AN ARRAY BEGINS FROM 0"

Dim MyNumbers (4) As String

"DECLARE THE STREAMREADER WHICH IS GOING TO READ OUR FILE NUMBERS.TXT"

Dim inFile As IO.StreamReader

inFile=IO.File.OpenText("Numbers.txt")

Dim intCount As Integer = 0

While InFile.Peek<>-1

MyNumbers(intcount)=inFile.ReadLine

inCount +=1

End While

inFile.Close()

Else

"A MESSAGE BOX WILL APPEAR SAYING FILE DOES NOT EXIST IF THE FILE CANNOT BE FOUND

MsgBox("File does not exist")

"WE END OUR END IF STATMENT"

End If

"HERE WE CATCH OUR EXCEPTION"

Catch AnyTypeOfException As Exception

"OUR MESSAGE BOX THAT APPEARS WHEN SOMETHING GOES WRONG AND 

MsgBox("Sorry,something went wrong!")

"HERE WE END OUR TRY STATEMENT"

End Try

________________________________________
Try

If IO.File.Exists ("Numbers.txt")Then

Dim Outfile As IO.StreamWriter
outfile=IO.File.AppendText("Number.txt")

For intCount = 0 to MyNumbers.Length - 1
outfile.WriteLine(MyNumbers(intCount))

Next

outfile.Close()

Else

MsgBox("File Not Found!")

End If

Catch AnyTpyeOfException As Exception

End Try

Task One

Coded in the READ button

Try

If IO .File.Exists("Numbers.txt") Then

Dim MyNumbers (4) As String

Dim inFile As IO.StreamReader

inFile=IO.File.OpenText("Numbers.txt")

Dim intCount As Integer = 0

While InFile.Peek<>-1

MyNumbers(intcount)=inFile.ReadLine

inCount +=1

End While

inFile.Close()

Else

MsgBox("File does not exist")

End If

Catch AnyTypeOfException As Exception

MsgBox("Sorry,something went wrong!")

End Try

Tuesday, October 19, 2010

Content Management Systems

Joomla = makes websites, manages sites, blogs and polls, flexibility, easy to use.

Drupal = same as above

Word Press = mainly blogging but also same as the two above

Moodle = education based, interactive, classes students

Zen Cart = shopping and e commerce

Monday, October 18, 2010

Select Operation

Public Class Form1

    'START OF DATABASE OPERATION!!!!!!

    Private Sub btnGetCustomerNames_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnGetCustomerNames.Click

        Dim strConnectionString As String = "Provider = Microsoft.Ace.OLEDB.12.0;" & _
        "Data Source = F:/MyFolder/Filters.accdb "

        Dim MyConnection As New OleDb.OleDbConnection(strConnectionString)

        MyConnection.Open()

        Dim MyCommand As New OleDb.OleDbCommand("SELECT * FROM customers", MyConnection)

        Dim MyDataSet As New Data.DataSet

        Dim MyDataAdapter As New OleDb.OleDbDataAdapter(MyCommand)

        MyDataAdapter.Fill(MyDataSet, "QueryResults")

        MyConnection.Close()

        'END OF DATABASE OPERATION!!

        LstCustomerNames.DataSource = MyDataSet.Tables("QueryResults")

        LstCustomerNames.DisplayMember = "FirstName"

        LstCustomerNames.ValueMember = "CustomerID"

    End Sub
End Class

Blog Task: Warning

Using the NullReferenceExceptionDemo project:

    1. What warning does the Visual Studio IDE provide with regards to using variables before they have been assigned a value? What does the warning look like? What does it say?
    2. Comment out the incorrect code and uncomment the correct code. Substitute the string parameter “Rach” with your own name.
    3. Post a screen shot of the resulting message box.

Connection String to a Database String

Applications and Databases

We keep them separate

1 Connection string -Address of the supermarket

DB Drivers
Path to DB

2 Connection Object - Car/Road
Using the connection string

3 Command Object-Shopping List
SQL statement to be executed
Using the connection object

4 Data Adapter- The Shopper
Uses the connection object
Retrieves Items

5 Data set- The Pantry
Select- No Mod
Insert- creates a new record
Update- Edit
Delete

4 and 5 only used during the SELECT process

Sunday, October 10, 2010



Database Questions Blog Task 1

1. What does a column in a table represent?FIELD

  1. Field
  2. Record

2. What does a row in a table represent?RECORD
  1. Field
  2. Record
3. What does DBMS stand for? Database Management Systems
4. What is a primary key in a table used for?

It is is a field that uniquely identifies each record. This field can be used to link records across multiple tables.
5. Why is the ID column such a useful field? ID IS KING, “If you know the ID of a record, you can do anything you want with that record”
6. What Access data type would you use to store the string “18 Segway Drive, Moonville” ?TEXT
7. What Access data type would you use to record True/False values?YES/NO
8. What Access data type would you use to store a number?NUMBER
9. What Access data type would you use to store a long string such as an essay or 
report?MEMO
10. A database is a collection of what? RELATED DATA THAT IS STORED IN A STRUCTURED FORMAT
11. A table is made up of what? ROWS AND COLUMNS
12. What is a record? THE ROWS IN A TABLE
A record is a group of related fields containing all of the information about a specific person, place or thing. 
13. Are spaces allowed in field names? NO THEY ARE NOT

Create A Database

My Databases





Monday, October 4, 2010

IO-Input and Output

Stream Reader
Stream Writer

File Object

OutFile = IO.File.AppendText ("x.txt")

Append Text = Open a file for Append so that we can add text to it and this is also a writer

Create Text = This is a writer

Read Line = Will read one line

Peak = Method that peeks inside the files that is associated with the Peek File, if there are no more lines to write the peek function will return a negative one, if there are no more items in the list

Sunday, October 3, 2010

BLOG TASK 2

Answer the following questions:


1. Which of the following procedures can be used to read information from a sequential access file? ALL OF THEM?
  1. AppendText
  2. CreateText
  3. OpenText


2. Which of the following reads a line of text from the file associated with the inFile variable and assigns the line of text (excluding the newline character) to the msg variable? MY ANSWER: msg = inFile.ReadLine
  1. msg = inFile.Read
  2. msg = inFile.ReadLine
  3. inFile.ReadLine(msg)


3. Write the statement required to close the file associated with the inFile variable.
inFile.Close()


4. If a sequential access file contains another character to read, what does the Peek method return?
The Peek method returns the character


5. If a sequential access file does not contain another character to read, what does the Peek method return?
it will return the number -1 (negative 1)

BLOG TASK 1

Answer the following questions:


1. Which of the following methods can be used to open a sequential access file? ALL OF THE ABOVE
  1. AppendText
  2. CreateText
  3. OpenText
  4. all of the above


2. Which of the following writes the contents of the favouriteTuneTextBox’s Text property, followed by the newline character, to the sequential access file associated with the outFile variable?

MY ANSWER IS : outFile.Write(favouriteTuneTextBox.Text)
  1. outFile.Write(favouriteTuneTextBox.Text)
  2. outFile.WriteLine(favouriteTuneTextBox.Text)
  3. outFile.WriteNext(favouriteTuneTextBox.Text)
  4. none of the above


3. What does IO in the syntax stand for?

INPUT OUTPUT!

Monday, August 9, 2010