0% found this document useful (0 votes)
16 views12 pages

VB Assignment 5

This document contains code snippets from an assignment for an Advanced Visual Basic .NET Programming course at Ghana Communication Technology University. The code examples demonstrate how to create menu navigation, display data from a database in a GridView, implement search and paging functionality, and display call history data. Functions like sorting, selecting records, and paging are demonstrated through code examples using GridView properties and data source controls.

Uploaded by

oforikelvin71
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
16 views12 pages

VB Assignment 5

This document contains code snippets from an assignment for an Advanced Visual Basic .NET Programming course at Ghana Communication Technology University. The code examples demonstrate how to create menu navigation, display data from a database in a GridView, implement search and paging functionality, and display call history data. Functions like sorting, selecting records, and paging are demonstrated through code examples using GridView properties and data source controls.

Uploaded by

oforikelvin71
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 12

GHANA COMMUNICATION TECHNOLOGY UNIVERSITY (GCTU)

FACULTY OF COMPUTING AND INFORMATION SYSTEMS

DEPARTMENT OF INFORMATION SYSTEMS

ASSIGNMENT FIVE

CICS 314: ADVANCED VISUAL BASIC .NET PROGRAMMING

STUDENT INFORMATION
INDEX NUMBER: 4211210073
FULL NAME: SERKINA BASHIRU NTSE
PROGRAMME: BSC INFORMATION TECHNOLOGY
LEVEL: 300
SESSION: MORNING GROUP B
LECTURER: DR. FORGOR LEMPOGO

MENU/NAVIGATION ITEMS
CODES:
<div class="navbar navbar-inverse navbar-fixed-top">
<div class="container">
<div class="navbar-header">
<button type="button" class="navbar-toggle" data-toggle="collapse" data-
target=".navbar-collapse">
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
<a class="navbar-brand" runat="server" href="~/">Application name</a>
</div>
<div class="navbar-collapse collapse">
<ul class="nav navbar-nav">
<li><a runat="server" href="~/">Home</a></li>
<li><a runat="server" href="~/About">About</a></li>
<li><a runat="server" href="~/Contact">Contact</a></li>
<li><a runat="server" href="~/Person">Person</a></li>
<li><a runat="server" href="~/Call">Call History</a></li>
</ul>
</div>
</div>
</div>
PERSON MENU/NAVIGATION ITEM CLICKED TO VIEW PERSON PAGE

CODES: PERSON AND DATABASE (CONTACT_DB) AND THE WHOLE GRIDVIEW


<%@ Page Language="vb" MasterPageFile="~/Site.Master" AutoEventWireup="false"
CodeBehind="Person.aspx.vb" Inherits="Person.Person" %>

<asp:Content ID="BodyContent" ContentPlaceHolderID="MainContent" runat ="server">


<asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$
ConnectionStrings:Contact_DBConnectionString %>" ProviderName="<%$
ConnectionStrings:Contact_DBConnectionString.ProviderName %>"
SelectCommand="SELECT * FROM [Person_TB]"></asp:SqlDataSource>
<asp:SqlDataSource ID="SqlDataSource2" runat="server" ConnectionString="<%$
ConnectionStrings:Contact_DBConnectionString %>" ProviderName="<%$
ConnectionStrings:Contact_DBConnectionString.ProviderName %>"
SelectCommand="SELECT * FROM [Person_TB] WHERE ([P_ID] = ?)">
<SelectParameters>
<asp:SessionParameter DefaultValue="2" Name="P_ID" SessionField="Person_ID"
Type="Int32" />
</SelectParameters>
</asp:SqlDataSource>
<br />
<br />
<br />
<asp:Label ID="lblSearch" runat="server"
AssociatedControlID="txtIDSearch" Text="Enter ID To Search"></asp:Label>
<asp:TextBox ID="txtIDSearch" runat="server"></asp:TextBox>
<asp:Button ID="btnSearch" runat="server" Text="Search" />

<br />
<h3>My Contacts</h3>

<asp:GridView ID="GridView1" runat="server" AllowPaging="True"


BackColor="#CCCCCC"
BorderColor="#999999" BorderStyle="Solid" BorderWidth="3px" CellPadding="4"
CellSpacing="2" GridLines="Vertical" PageSize="5" DataSourceID="SqlDataSource1"
ForeColor="Black" Width="463px" AllowSorting="True"
AutoGenerateColumns="False"
DataKeyNames="P_ID">
<FooterStyle BackColor="#CCCCCC" />
<HeaderStyle BackColor="Black" Font-Bold="True" ForeColor="White" />
<PagerStyle BackColor="#CCCCCC" ForeColor="Black" HorizontalAlign="Left" />
<RowStyle BackColor="White" />
<SelectedRowStyle BackColor="#000099" Font-Bold="True" ForeColor="White" />
<SortedAscendingCellStyle BackColor="#F1F1F1" />
<SortedAscendingHeaderStyle BackColor="#808080" />
<SortedDescendingCellStyle BackColor="#CAC9C9" />
<SortedDescendingHeaderStyle BackColor="#383838" />

<AlternatingRowStyle BackColor="#CCCCCC"/>
<Columns>

<asp:CommandField ShowSelectButton="True" />


<asp:BoundField DataField="P_ID" HeaderText="P_ID" InsertVisible="False"
ReadOnly="True" SortExpression="P_ID" />
<asp:BoundField DataField="FirstName" HeaderText="FirstName"
SortExpression="FirstName" />
<asp:BoundField DataField="LastName" HeaderText="LastName"
SortExpression="LastName" />
<asp:BoundField DataField="Gender" HeaderText="Gender"
SortExpression="Gender" />
<asp:BoundField DataField="DataOfBirth" HeaderText="DataOfBirth"
SortExpression="DataOfBirth" />
<asp:BoundField DataField="eMail" HeaderText="eMail"
SortExpression="eMail" />
<asp:BoundField DataField="PhoneNumber" HeaderText="PhoneNumber"
SortExpression="PhoneNumber" />
<asp:BoundField DataField="Address" HeaderText="Address"
SortExpression="Address" />
<asp:BoundField DataField="Details" HeaderText="Details"
SortExpression="Details" />

</Columns>
<FooterStyle />
<HeaderStyle BackColor="Black" Font-Bold="True" ForeColor="White" />
<PagerSettings FirstPageText="First" LastPageText="Last"
Mode="NextPreviousFirstLast"
NextPageText="Next " PreviousPageText="Prev" />
<PagerStyle BackColor="#999999" BorderStyle="Groove" ForeColor="Black"
HorizontalAlign="Center" />

</asp:GridView>

</asp:Content>

SEARCH AND SEARCH RESULTS FUNCTIONALITY

CODES: FOR SEARCH BUTTON


Protected Sub btnSearch_Click(sender As Object, e As EventArgs) Handles btnSearch.Click
Dim Person_ID As Integer = CInt(txtIDSearch.Text)
'Create a Session variable and pass the Value of Person_lD to it
Session("Person_ID") = Person_ID
Response.Redirect("SearchResults.aspx")
End Sub

CODE FOR SEARCH RESULTS PAGE:


<%@ Page Language="vb" MasterPageFile="~/Site.Master" AutoEventWireup="false"
CodeBehind="SearchResults.aspx.vb"
Inherits="Person.SearchResults" %>
<asp:Content ID="BodyContent" ContentPlaceHolderID="MainContent" runat="server">
<h1>Search Results </h1>
<asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$
ConnectionStrings:Contact_DBConnectionString %>"
ProviderName="<%$ ConnectionStrings:Contact_DBConnectionString.ProviderName
%>"
SelectCommand="SELECT * FROM [Person_TB]"></asp:SqlDataSource>
<asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False"
DataKeyNames="P_ID"
DataSourceID="SqlDataSource1" AllowPaging="True" CellPadding="4"
CellSpacing="2" ForeColor="#333333" GridLines="Vertical" PageSize="5">
<AlternatingRowStyle BackColor="White" />
<Columns>
<asp:BoundField DataField="P_ID" HeaderText="P_ID" InsertVisible="False"
ReadOnly="True"
SortExpression="P_ID" />
<asp:BoundField DataField="FirstName" HeaderText="FirstName"
SortExpression="FirstName" />
<asp:BoundField DataField="LastName" HeaderText="LastName"
SortExpression="LastName" />
<asp:BoundField DataField="Gender" HeaderText="Gender"
SortExpression="Gender" />
<asp:BoundField DataField="DataOfBirth" HeaderText="DataOfBirth"
SortExpression="DataOfBirth" />
<asp:BoundField DataField="eMail" HeaderText="eMail" SortExpression="eMail" >
<HeaderStyle HorizontalAlign="Center" />
</asp:BoundField>
<asp:BoundField DataField="PhoneNumber" HeaderText="PhoneNumber"
SortExpression="PhoneNumber" />
<asp:BoundField DataField="Address" HeaderText="Address"
SortExpression="Address" />
<asp:BoundField DataField="Details" HeaderText="Details"
SortExpression="Details" />

</asp:Content>

SORT FUNCTION:
CODE:
AllowSorting="True"

SELECT FUNCTION
CODES:
AllowSection=”True”

PAGING FUNCTION.
CODE:
AllowPaging=”True” PageSize=”5”
<PagerSettings FirstPageText="First" LastPageText="Last" Mode="NextPreviousFirstLast"
NextPageText="Next " PreviousPageText="Prev" />

CALL HISTORY PAGE:


CODES:
<%@ Page Language="vb" MasterPageFile="~/Site.Master" AutoEventWireup="false"
CodeBehind="Call.aspx.vb" Inherits="Person._Call" %>

<asp:Content ID="BodyContent" ContentPlaceHolderID="MainContent" runat ="server">


<asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$
ConnectionStrings:Contact_DBConnectionString %>" ProviderName="<%$
ConnectionStrings:Contact_DBConnectionString.ProviderName %>"
SelectCommand="SELECT * FROM [Call_TB]"></asp:SqlDataSource>
<asp:SqlDataSource ID="SqlDataSource2" runat="server" ConnectionString="<%$
ConnectionStrings:Contact_DBConnectionString %>" ProviderName="<%$
ConnectionStrings:Contact_DBConnectionString.ProviderName %>"
SelectCommand="SELECT * FROM [Call_TB] WHERE ([C_ID] = ?)">
<SelectParameters>
<asp:SessionParameter DefaultValue="3" Name="C_ID" SessionField="Caller_ID"
Type="Int32" />
</SelectParameters>
</asp:SqlDataSource>
<br />
<asp:Label ID="lblCID" runat="server" AssociatedControlID="txtIDSearch2"
Text="Enter ID To Search"></asp:Label>
<asp:TextBox ID="txtIDSearch2" runat="server"></asp:TextBox>
<asp:Button ID="btnSearch" runat="server" Text="Search" />
<br />
<h2>Call History</h2>
<asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False"
BackColor="#CCCCCC"
BorderColor="#999999" BorderStyle="Solid" BorderWidth="3px" CellPadding="4"
CellSpacing="2"
DataKeyNames="C_ID" DataSourceID="SqlDataSource1" ForeColor="Black"
AllowPaging="True"
AllowSorting="True">
<Columns>
<asp:BoundField DataField="C_ID" HeaderText="C_ID" InsertVisible="False"
ReadOnly="True" SortExpression="C_ID" />
<asp:BoundField DataField="Caller_ID" HeaderText="Caller_ID"
SortExpression="Caller_ID" />
<asp:BoundField DataField="StartTime" HeaderText="StartTime"
SortExpression="StartTime" />
<asp:BoundField DataField="EndTime" HeaderText="EndTime"
SortExpression="EndTime" />
<asp:BoundField DataField="CallDate" HeaderText="CallDate"
SortExpression="CallDate" />
<asp:ButtonField CommandName="Select" HeaderText="View Call"
ShowHeader="True" Text="View Call" ButtonType="Button" />
</Columns>
<FooterStyle BackColor="#CCCCCC" />
<HeaderStyle BackColor="Black" Font-Bold="True" ForeColor="White" />
<PagerSettings FirstPageText="First" LastPageText="Last"
Mode="NextPreviousFirstLast "
NextPageText="Next " PreviousPageText="Prev" />
<PagerStyle BackColor="#CCCCCC" ForeColor="Black" HorizontalAlign="Center" />

<RowStyle BackColor="White" />


<SelectedRowStyle BackColor="#000099" Font-Bold="True" ForeColor="White" />
<SortedAscendingCellStyle BackColor="#F1F1F1" />
<SortedAscendingHeaderStyle BackColor="#808080" />
<SortedDescendingCellStyle BackColor="#CAC9C9" />
<SortedDescendingHeaderStyle BackColor="#383838" />
</asp:GridView>

</asp:Content>

CALL HISTORY SEARCH RESULT PAGE.


CODES:
Protected Sub btnSearch_Click(sender As Object, e As EventArgs) Handles btnSearch.Click
Dim Caller_ID As Integer = CInt(txtIDSearch2.Text)
'Create a Session variable and pass the Value of Person_lD to it
Session("C_ID") = Caller_ID
Response.Redirect("ShowCallHistory.aspx")
End Sub

VIEWCALL BUTTON FUNCTIONALITY PAGE


CODES:
Protected Sub btnSearch_Click(sender As Object, e As EventArgs) Handles btnSearch.Click
'Create a Session variable and pass the Value of Person_lD to it
Session("C_ID") = Caller_ID
Response.Redirect("ViewCall.aspx")
End Sub

You might also like