Thursday, April 29, 2010

ADO Phase One

Here is the Default.aspx page
<%@ Page Language="VB" AutoEventWireup="false" CodeFile="Default.aspx.vb" Inherits="_Default" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title>New Donation</title>
</head>
<body>
<form id="form1" runat="server">
<div>
<h1>New Donation</h1>
<p>
<asp:Label ID="Label1" runat="server" >Last name</asp:Label>
<asp:TextBox ID="txtLastName" runat="server"></asp:TextBox> <br />
<asp:Label ID="Label2" runat="server" Text="First Name"></asp:Label><asp:TextBox ID="txtFirstName"
runat="server"></asp:TextBox><br />

<asp:Label ID="Label3" runat="server" Text="Street"></asp:Label><asp:TextBox ID="txtStreet"
runat="server"></asp:TextBox><br />

<asp:Label ID="Label4" runat="server" Text="City"></asp:Label><asp:TextBox ID="txtCity"
runat="server"></asp:TextBox><br />

<asp:Label ID="Label5" runat="server" Text="State"></asp:Label><asp:TextBox ID="txtState"
runat="server"></asp:TextBox><br />

<asp:Label ID="Label6" runat="server" Text="Zip Code"></asp:Label><asp:TextBox ID="txtZip"
runat="server"></asp:TextBox><br />

<asp:Label ID="Label7" runat="server" Text="Donation Amount"></asp:Label><asp:TextBox ID="txtDonation"
runat="server"></asp:TextBox><br />
<asp:Button ID="Button1" runat="server" Text="Submit donation" />
</p>

</div>
</form>
</body>
</html


Here is the code for the person class


Imports Microsoft.VisualBasic

Public Class Person

Private first As String
Private last As String
Private street As String
Private city As String
Private state As String
Private zip As String

Public Property FirstName() As String
Get
Return first
End Get
Set(ByVal value As String)
first = value
End Set
End Property

Public Property LastName() As String
Get
Return last
End Get
Set(ByVal value As String)
last = value
End Set
End Property

Public Property Address() As String
Get
Return street
End Get
Set(ByVal value As String)
street = value
End Set
End Property

Public Property PersonCity() As String
Get
Return city
End Get
Set(ByVal value As String)
city = value
End Set
End Property

Public Property PersonState() As String
Get
Return state
End Get
Set(ByVal value As String)
state = value
End Set
End Property

Public Property Zipcode() As String
Get
Return zip
End Get
Set(ByVal value As String)
zip = value
End Set
End Property

End Class

Here is the Donor class



Imports Microsoft.VisualBasic

Public Class Donor : Inherits Person
Private ID As String
'this class encapsulates the donor
'it inherits from Person'

Public Sub New(ByVal donorKey As String)
DonorID = donorKey
End Sub


Public Property DonorID() As String
Get
Return ID
End Get
Set(ByVal value As String)
ID = value
End Set
End Property
End Class



Here is the donation class

Imports Microsoft.VisualBasic

Public Class Donation
Private amount As Double
Private dDate As DateTime

Sub New(ByVal dAmount As Double)
amount = dAmount
dDate = DateTime.Now
End Sub

Public Property DonationAmount() As Double
Get
Return amount
End Get
Set(ByVal value As Double)
amount = value
End Set
End Property

Public ReadOnly Property DonationDate() As DateTime
Get
Return dDate
End Get
End Property

End Class





Here is the beginning of the Datalayer Class


Imports System.Data
Imports System.Data.SqlClient

Public Class DataLayer

Private don As Donor
Private gift As Donation
Private connect As SqlConnection

Sub New(ByVal d As Donor, ByVal dn As Donation)
don = d
gift = dn
connect = New SqlConnection("Data Source=localhost;initial catalog=Communityassist;integrated security=true")
End Sub

Public Function WriteDonation() As Boolean

End Function


End Class

Thursday, April 22, 2010

LINQ to SQL

Here is the code. Remember to do this you need to go to WebSite/Add New Item/LINQ SQL/ and drag the Person and Donor tables onto the LINQ Designers

Default.aspx
<%@ Page Language="VB" AutoEventWireup="false" CodeFile="Default.aspx.vb" Inherits="_Default" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
</head>
<body>
<form id="form1" runat="server">
<div>

<asp:DropDownList ID="DropDownList1" runat="server" AutoPostBack="True">
</asp:DropDownList>
<br />
<!--Here is the beginning of the datalist -->
<asp:DataList ID="DataList1" runat="server">
<ItemTemplate>
<asp:Label ID="Label1" runat="server" Text="Donor Name"></asp:Label>
<asp:Label ID="Label2"
runat="server" Text='<%#Eval("LastName") %>'></asp:Label><br />

<asp:Label ID="Label3" runat="server" Text="Date"></asp:Label>
<asp:Label ID="Label4"
runat="server" Text='<%#Eval("DonationDate") %>'></asp:Label><br />

<asp:Label ID="Label5" runat="server" Text="Amount"></asp:Label>
<asp:Label ID="Label6"
runat="server" Text='<%#Eval("DonationAmount") %>'></asp:Label>

</ItemTemplate>
</asp:DataList>



</div>
</form>
</body>
</html>

Default.Aspx.vb


Partial Class _Default
Inherits System.Web.UI.Page

Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load If Not IsPostBack Then
Dim dc As New DataClassesDataContext
Dim donor = (From p In dc.Donations _
Order By p.Person.LastName Ascending _
Select p.PersonKey, p.Person.LastName).Distinct

DropDownList1.DataSource = donor
DropDownList1.DataTextField = "LastName"
DropDownList1.DataValueField = "PersonKey"
DropDownList1.DataBind()
End If


End Sub

Protected Sub DropDownList1_SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles DropDownList1.SelectedIndexChanged
Dim dc As New DataClassesDataContext
Dim contributions = From d In dc.Donations _
Order By d.DonationDate Ascending _
Where d.PersonKey = DropDownList1.SelectedValue _
Select d.Person.LastName, d.DonationDate, d.DonationAmount

DataList1.DataSource = contributions
DataList1.DataBind()

End Sub
End Class

Tuesday, April 13, 2010

April 13, Ajax code

Ajax code



Here is the default aspx

<%@ Page Language="VB" AutoEventWireup="false" CodeFile="Default.aspx.vb" Inherits="_Default" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
</head>
<body>
<form id="form1" runat="server">
<asp:ScriptManager ID="ScriptManager1" runat="server">
</asp:ScriptManager>
<div>
<p>Do you want to submit your information</p>
<asp:UpdatePanel ID="UpdatePanel1" runat="server">
<ContentTemplate>
<asp:RadioButtonList ID="RadioButtonList1" runat="server" AutoPostBack="True">
<asp:ListItem Text="yes"></asp:ListItem>
<asp:ListItem Text="no"></asp:ListItem>
</asp:RadioButtonList>
<asp:Panel ID="Panel1" runat="server" Visible="False">
<asp:Label ID="Label1" runat="server" Text="Enter your name"></asp:Label><asp:TextBox
ID="TextBox1" runat="server"></asp:TextBox> <br />
<asp:Label ID="Label2" runat="server" Text="Enter your Address"></asp:Label><asp:TextBox
ID="TextBox2" runat="server"></asp:TextBox>
</asp:Panel>
</ContentTemplate>

</asp:UpdatePanel>
</div>
</form>
</body>
</html>

Here is the VB Code

Partial Class _Default
Inherits System.Web.UI.Page

Protected Sub RadioButtonList1_SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles RadioButtonList1.SelectedIndexChanged
If RadioButtonList1.SelectedIndex = 0 Then
Panel1.Visible = True
Else
Panel1.Visible = False
End If
End Sub
End Class

Controls example



<%@ Page Language="VB" AutoEventWireup="false" CodeFile="Default.aspx.vb" Inherits="_Default" trace="false" EnableViewState="true" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:DropDownList ID="DropDownList1" runat="server">

</asp:DropDownList>
<asp:Button ID="Button1" runat="server" Text="Button" />
<asp:LinkButton ID="LinkButton1" runat="server">Get Choices</asp:LinkButton>

<asp:Calendar ID="Calendar1" runat="server" BackColor="White"
BorderColor="Black" BorderStyle="Solid" CellSpacing="1" Font-Names="Verdana"
Font-Size="9pt" ForeColor="Black" Height="250px" NextPrevFormat="ShortMonth"
Width="330px">
<SelectedDayStyle BackColor="#333399" ForeColor="White" />
<TodayDayStyle BackColor="#999999" ForeColor="White" />
<OtherMonthDayStyle ForeColor="#999999" />
<DayStyle BackColor="#CCCCCC" />
<NextPrevStyle Font-Bold="True" Font-Size="8pt" ForeColor="White" />
<DayHeaderStyle Font-Bold="True" Font-Size="8pt" ForeColor="#333333"
Height="8pt" />
<TitleStyle BackColor="#333399" BorderStyle="Solid" Font-Bold="True"
Font-Size="12pt" ForeColor="White" Height="12pt" />
</asp:Calendar>
<asp:CheckBoxList ID="CheckBoxList1" runat="server">
<asp:ListItem Text="Oranges" Value="1.98"></asp:ListItem>
<asp:ListItem Text="Apples" Value="2.89"></asp:ListItem>
<asp:ListItem Text="Bananas" Value=".79"></asp:ListItem>
</asp:CheckBoxList>
<asp:Label ID="lblSelected" runat="server" Text="Label"></asp:Label>
</div>
</form>
</body>
</html>

VB Code

Partial Class _Default
Inherits System.Web.UI.Page
'***********************************
'This page is a mish mash of various controls
'4/13/2010
'steve conger
'**********************************

Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
'this keeps it from reloading every time the page
'come back from the server
REM this is also a comment
If Not IsPostBack Then
DropDownList1.Items.Add("One")
DropDownList1.Items.Add("Two")
DropDownList1.Items.Add("Three")
End If

' Dim test As String = "This is a long string" & _
' "Here is more of it"

End Sub

Protected Sub LinkButton1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles LinkButton1.Click
Dim fruit As String = Nothing
Dim item As ListItem
For Each item In CheckBoxList1.Items
If item.Selected Then
fruit += item.Text & ", " & item.Value & "
"
End If
Next
lblSelected.Text = fruit
End Sub
End Class

How to turn in assignments

Several have asked me how to turn in assignments. There are a couple of ways. One, you can copy the code and source code directly into the email and send it to me at sconge@sccd.ctc.edu. Secondly, you can copy it into Word, Word Pad or Notepad and attach the document to an email. Thirdly, if you wish to zip the file you can, but you must change the zip extenstion to something else, like ".piz" The school's exchange server strips out all zip files and I never see them.

Finally put ITC172 somewhere in the subject line. That will guarantee that the file is copied to the ITC172 folder in my inbox

Sunday, April 11, 2010

Agile programming

Bertine sent this link to a pdf that has a good synopsis of agile programming
http://www.pmforum.org/library/tips/2007/PDFs/Hass-5-07.pdf

Thursday, April 8, 2010

April 8th Class samples

Here is what we did in class
Default.aspx source
<%@ Page Language="VB" AutoEventWireup="false" CodeFile="Default.aspx.vb" Inherits="_Default" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title>Fruit flies</title>
<link href="fruit.css" rel="stylesheet" type="text/css" />
</head>
<body>
<form id="form1" runat="server">
<div>
<h1>Fruit</h1>
<asp:BulletedList ID="BulletedList1" runat="server">


</asp:BulletedList>

</div>
<asp:Label ID="Label1" runat="server" Text="Enter Price"></asp:Label>
<asp:TextBox ID="txtPrice" runat="server"></asp:TextBox><br />
<asp:Label ID="Label2" runat="server" Text="Enter Quantity"></asp:Label><asp:TextBox
ID="txtquantity" runat="server"></asp:TextBox> <br />
<asp:Button ID="Button1" runat="server" Text="Calculate" /> <br />
<asp:Label ID="Label3" runat="server" Text="Label"></asp:Label>
</form><br />

</body>
</html>

Default.aspx.vb

Option Strict On
Partial Class _Default
Inherits System.Web.UI.Page

Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
Dim fruit() As String = {"apple", "pear", "mango", "banana", "starfruit", "strawberry"}
BulletedList1.DataSource = fruit
BulletedList1.DataBind()




End Sub

Protected Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim price As Double
Dim quantity As Integer
If Not Double.TryParse(txtPrice.Text, price) Then
Label3.Text = "invalid Price"
Return
End If
If Not Integer.TryParse(txtquantity.Text, quantity) Then
Label3.Text = "Invalid Quantity"
Return
End If
Label3.Text = (price * quantity).ToString("$#,###.00")
End Sub
End Class

Fruit.css
body {
}
li
{
font-size:150%;
color:Purple;
}

Wednesday, April 7, 2010

Use Cases

One way to show requirements is to do use case diagrams. Here are the ones I did in class for a fraction software


You don't have to do use cases. You can just list the requirements

Tuesday, April 6, 2010

ITC 255 Resources

Here are a couple of books. first is the Head First Object Oriented Analysis and Design from O'Reilly the ISBN is 0-596-00867-8.

Another book is Applying UML and Patterns An Introduction to Object Oriented Analysis and Design by Craig Larman, Prentice Hall ISBN 9-13-748880-7. This is a bit older and may be hard to find.

I will try to keep adding additional resources throughout the quarter.-

Monday, April 5, 2010

Statement of Work

Here is an example of a simple statement of work.

STATEMENT OF WORK: TUTORING DATABASE PROJECT
HISTORY
For a long time the tutoring program has used a paper schedule to sign students up for tutoring. Tutors identify their schedule for a two week period and then a schedule is printed and placed in the computer lab. Students look through the schedule for sessions that match courses they are taking and the times they have available. This system has worked and continues to work, but it has several significant problems. For one, it can be difficult for students to find appropriate tutoring sessions. The paper forms are difficult to navigate and understand. Additionally, it is very difficult for the tutoring program to track the students using the tutoring. It is difficult or impossible to track demographic information. It is also difficult to assure that students are enrolled in the courses they receive tutoring in. Even tracking tutors’ hours can be difficult.
A database with a client application could significantly improve the situation, by providing a flexible, searchable schedule for students, better tracking of demographics and eligibility, and better tracking of hours tutored.
SCOPE
The tutoring database will manage data for the tutoring program at the college. It will track available tutors and the courses they can tutor. It will also track each tutor’s tutoring schedule. The database will store demographic information for students who register for tutoring. This information will be private and used only generate general reports which include no personal information. Students, who have registered, will be able to sign up for available tutoring sessions for courses in which they are enrolled. The database will track whether students attended their scheduled sessions. It will also track student requests for tutoring in additional course and subjects.
Constraints
The database can be used to get the hours worked for each tutor, but it will not process pay or payroll information. The database will not validate student information against the school’s registration database.
OBJECTIVES
• Streamline the process by which the tutors enter their schedules and students sign up for them
• Improve tracking of demographic data of students using the tutoring program
• Improve tracking of tutor’s hours and students use of tutoring sessions
• Track Student requests for additional tutoring
TASKS AND TIMELINE
1. Gathering Data: This task will consist in a number of interviews, questionnaires and observations. Time allotted 3 weeks.
Deliverable: A list of scheduled interviews and observations, text of the questionnaires.
2. Analyzing Data: The data gathered will be analyzed to determine business rules and preliminary data modeling. Time allotted 2 weeks.
Deliverable: List of business rules to be reviewed, basic entities and attributes.
3. Normalization: the data model will be completed with entities and relationships normalized. Time allotted 1 week.
Deliverables: Entity Relation Diagram for Review.
4. Building the physical database: The data model will be translated to the Relational Database Management system. Tables, Columns with specific data types and Relational and other constraints created. Time allotted 3 days.
Deliverables: The Schema of the database for review.
5. Testing and security; Sample data will be entered and each of the business rules and requirements will be tested. General database security and security related to business rules will also be tested. Time allotted 3 weeks.
Deliverables: Documented test results.
6. Database Completion and installation: final changes and corrections are made. Sample data will be removed and the database installed on a server. Final testing for server access and connections. Time allotted 2 weeks.
Deliverables: The working database.
Total time between beginning of project and end: 11 weeks, 3 days.

Hello to Capstone Project

This class is all about developing and managing a project. You want to create a project that makes a good show piece when you are out looking for work. It should be something that shows potential employers what you can do.

I will use this blog to post documents, examples and instructions for you during the quarter.