Você está na página 1de 53

Latha Mathavan Polytechnic College

Computer Engineering

LATHA MATHAVAN POLYTECHNIC COLLEGE


KIDARIPATTI, MADURAI.

DEPARTMENT OF COMPUTER ENGINEERING


III YEAR/ V- SEM
(K-Scheme)

.NET PROGRAMMING MANUAL

Prepared By,
M. Suganthi B.Tech.,
Lecturer/ CT.

.Net Programming

(V-Sem)

Latha Mathavan Polytechnic College

Computer Engineering

CONSOLE APPLICATION

Ex.No: 1
Date:
Aim:

To accept a character from console and to check the case of the character.

Apparatus Required:
Software Required: 1. DotNet Framework
2. VB.Net
Hardware Required: Computer with Pentium IV/ Dual core processors.

Procedure:
1. Click StartProgramsMicrosoftVisualStudio 2005 MicrosoftVisualStudio 2005 to
open the Microsoft VisualStudio (IDE).

2. Select File New Project console application.

3. Open the console application form.

4. After opening the console application form write the source code.

5. Then convert the Uppercase to Lowercase and Lowercase to Uppercase with the function
of Ucase and Lcase.

6. Finally run the console application.


.Net Programming

(V-Sem)

Latha Mathavan Polytechnic College

Computer Engineering

Source Code:
Module Module1
Sub Main()
Dim c As Char
Console.WriteLine("Enter the character")
c = Console.ReadLine
If Asc(c) > 64 And Asc(c) < 91 Then
Console.WriteLine("UPPERCASE")
ElseIf Asc(c) > 96 And Asc(c) < 122 Then
Console.WriteLine("LOWERCASE")
Else
Console.WriteLine("Other character")
End If
Console.ReadLine()
End Sub
End Module

RESULT:
Thus the above program for checking the case of the character was executed successfully and the
output was verified.
.Net Programming

(V-Sem)

Latha Mathavan Polytechnic College

Computer Engineering

VOWELS

Ex.No: 2
Date:
Aim:

Write a program to accept a character from keyboard and display whether it is a


vowel or not.

Apparatus Required:
Software Required: 1. DotNet Framework
2. VB.Net
Hardware Required: Computer with Pentium IV/ Dual core processors.

Procedure:
1. Click StartProgramsMicrosoftVisualStudio 2005 MicrosoftVisualStudio 2005 to
open the Microsoft VisualStudio (IDE).

2. Select File New Project Window application.

3. Open the window application form, and then place the label, Textbox and button in the

form.

4. Insert the code for Button Click Event procedure using IF statement to check whether the
character is vowel or not.

5. Finally run the window application.

.Net Programming

(V-Sem)

Latha Mathavan Polytechnic College

Computer Engineering

Source Code:
Public Class exp2
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)
Handles Button1.Click
Dim d As Char
d = UCase(TextBox1.Text)
If d = "A" Or d = "E" Or d = "I" Or d = "O" Or d = "U" Then
TextBox2.Text = "Its a vowel"
Else
TextBox2.Text = "Not a vowel"
End If
End Sub
End Class

RESULT:
Thus the above program for displaying whether the given character is vowel or not was executed
successfully and the output was verified.
.Net Programming

(V-Sem)

Latha Mathavan Polytechnic College

Computer Engineering

CASE CONVERSION

Ex.No: 3
Date:
Aim:

Write a VB.Net program to accept a string and convert the case of the characters.

Apparatus Required:
Software Required: 1. DotNet Framework
2. VB.Net
Hardware Required: Computer with Pentium IV/ Dual core processors.

Procedure:
1. Click StartProgramsMicrosoftVisualStudio 2005 MicrosoftVisualStudio 2005 to
open the Microsoft VisualStudio (IDE).

2. Select File New Project window application.

3. Open the window application form, and then place the label, Textbox and button in the

form from tool box.

4. Insert the code to convert the Uppercase to Lowercase and Lowercase to Uppercase with
the function of Ucase and Lcase.

5. Finally run the window application.


.Net Programming

(V-Sem)

Latha Mathavan Polytechnic College

Computer Engineering

Source Code:
Public Class exno3
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)
Handles Button1.Click
Dim st As Integer
st = String.Compare(TextBox1.Text, UCase(TextBox1.Text))
If st = 0 Then
TextBox2.Text = LCase(TextBox1.Text)
MsgBox("The Lower case is:" & TextBox2.Text)
Else
TextBox2.Text = UCase(TextBox1.Text)
MsgBox("The Upper case is:" & TextBox2.Text)
End If
End Sub
End Class

RESULT:
Thus the above program for converting the case of the string was executed successfully and the
output was verified.
.Net Programming

(V-Sem)

Latha Mathavan Polytechnic College

Computer Engineering

FILE MENU OPERATION

Ex.No: 4
Date:
Aim:

Develop a menu based VB.Net application to implement a text editor with cut, copy,
paste, save and close operations.
Apparatus Required:
Software Required: 1. DotNet Framework
2. VB.Net
3. ASP.Net
4. SQL Server 2000.
Hardware Required: Computer with Pentium IV/ Dual core processors.
Procedure:
1. Click StartProgramsMicrosoftVisualStudio 2005 MicrosoftVisualStudio 2005 to

open the Microsoft VisualStudio (IDE).


2. Select File New Project window application.
3. Open the window application form, and then place the main menu in the form from tool
box.
4. Maim menu is constructed with number of sub menus named as open, close, save, cut,

copy, paste, undo, redo, color, font etc.,


5. Drag and place a Richtextbox in the form.
6. Insert the source code for appropriate menu items and finally run the application.

.Net Programming

(V-Sem)

Latha Mathavan Polytechnic College

Computer Engineering

Source Code:
Public Class Form1
Private Sub OpenToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles OpenToolStripMenuItem.Click
OpenFileDialog1.DefaultExt = "*.txt"
OpenFileDialog1.Filter = "Text Files|*.txt"
If (OpenFileDialog1.ShowDialog = DialogResult.OK) And
OpenFileDialog1.FileName.Length > 0 Then
RichTextBox1.LoadFile(OpenFileDialog1.FileName,
RichTextBoxStreamType.PlainText)
End If
End Sub
Private Sub CutToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles CutToolStripMenuItem.Click
RichTextBox1.Cut()
End Sub
Private Sub CopyToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles CopyToolStripMenuItem.Click
RichTextBox1.Copy()
End Sub
Private Sub PasteToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles PasteToolStripMenuItem.Click
RichTextBox1.Paste()
End Sub
Private Sub SelectAllToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles SelectAllToolStripMenuItem.Click
RichTextBox1.SelectAll()
End Sub
Private Sub UndoToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles UndoToolStripMenuItem.Click
RichTextBox1.Undo()
End Sub
Private Sub RedoToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles RedoToolStripMenuItem.Click
RichTextBox1.Redo()
End Sub
.Net Programming

(V-Sem)

Latha Mathavan Polytechnic College

Computer Engineering

Private Sub SaveToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As


System.EventArgs) Handles SaveToolStripMenuItem.Click
SaveFileDialog1.DefaultExt = "*.txt"
SaveFileDialog1.Filter = "Text Files|*.txt"
If (SaveFileDialog1.ShowDialog = DialogResult.OK) And
(SaveFileDialog1.FileName.Length > 0) Then
RichTextBox1.SaveFile(SaveFileDialog1.FileName,
RichTextBoxStreamType.PlainText)
End If
End Sub
Private Sub CloseToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles CloseToolStripMenuItem.Click
End
End Sub
Private Sub CloseToolStripMenuItem1_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles CloseToolStripMenuItem1.Click
PrintDialog1.Document = printdocument1
PrintDialog1.PrinterSettings = PrintDocument1.PrinterSettings
If PrintDialog1.ShowDialog = DialogResult.OK Then
PrintDocument1.PrinterSettings = PrintDialog1.PrinterSettings
End If
End Sub
Private Sub FontToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles FontToolStripMenuItem.Click
If FontDialog1.ShowDialog = DialogResult.OK Then
RichTextBox1.Font = FontDialog1.Font
RichTextBox1.ForeColor = FontDialog1.Color
End If
End Sub
Private Sub ColorToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles ColorToolStripMenuItem.Click
ColorDialog1.ShowDialog()
RichTextBox1.ForeColor = ColorDialog1.Color
End Sub
End Class
RESULT:
Thus the above program for implementing file menu operation was executed successfully and the
output was verified.
.Net Programming

(V-Sem)

Latha Mathavan Polytechnic College

Computer Engineering

CALCULATOR

Ex.No: 5
Date:
Aim:

Write a VB.Net program to implement a calculator with memory and recall


operations.

Apparatus Required:
Software Required: 1. DotNet Framework
2. VB.Net
Hardware Required: Computer with Pentium IV/ Dual core processors.

Procedure:
1. Click StartProgramsMicrosoftVisualStudio 2005 MicrosoftVisualStudio 2005 to

open the Microsoft VisualStudio (IDE).

2. Select File New Project window application.

3. Open the window application form.

4. Construct the form with ten buttons for digits, four buttons for operator, one button for

memory recalling, one button for save to memory, one button for unsaved to memory.

5. Then insert the separate source code for digits, operator, memory recalling, memory
saved, unsaved and calculations.

6. Finally run the window application.


.Net Programming

(V-Sem)

Latha Mathavan Polytechnic College

Computer Engineering

Source Code:
Public Class Form1
Dim a, m As Integer
Dim op As Char
Dim kk As String
Private Sub Button15_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)
Handles Button15.Click
TextBox1.Clear()
End Sub
Private Sub Button16_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)
Handles Button16.Click
m = Val(TextBox1.Text)
TextBox1.Clear()
End Sub
Private Sub Button17_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)
Handles Button17.Click
TextBox1.Text = m
End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)
Handles Button1.Click
TextBox1.AppendText("1")
End Sub
Private Sub Button2_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles
Button2.Click
TextBox1.AppendText("2")
End Sub
Private Sub Button3_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles
Button3.Click
TextBox1.AppendText("3")
End Sub
Private Sub Button4_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles
Button4.Click
TextBox1.AppendText("4")
End Sub

.Net Programming

(V-Sem)

Latha Mathavan Polytechnic College

Computer Engineering

Private Sub Button5_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles


Button5.Click
TextBox1.AppendText("5")
End Sub
Private Sub Button6_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles
Button6.Click
TextBox1.AppendText("6")
End Sub
Private Sub Button7_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles
Button7.Click
TextBox1.AppendText("7")
End Sub
Private Sub Button8_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles
Button8.Click
TextBox1.AppendText("8")
End Sub
Private Sub Button9_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles
Button9.Click
TextBox1.AppendText("9")
End Sub
Private Sub Button10_Click(ByVal sender As Object, ByVal e As System.EventArgs)
Handles Button10.Click
TextBox1.AppendText("0")
End Sub
Private Sub Button11_Click(ByVal sender As Object, ByVal e As System.EventArgs)
Handles Button11.Click
a = Val(TextBox1.Text)
op = "+"
TextBox1.Clear()
End Sub
Private Sub Button12_Click(ByVal sender As Object, ByVal e As System.EventArgs)
Handles Button12.Click
a = Val(TextBox1.Text)
op = "-"
TextBox1.Clear()
End Sub

.Net Programming

(V-Sem)

Latha Mathavan Polytechnic College

Computer Engineering

Private Sub Button13_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles


Button13.Click
a = Val(TextBox1.Text)
op = "*"
TextBox1.Clear()
End Sub
Private Sub Button14_Click(ByVal sender As Object, ByVal e As System.EventArgs)
Handles Button14.Click
a = Val(TextBox1.Text)
op = "/"
TextBox1.Clear()
End Sub
Private Sub Button18_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)
Handles Button18.Click
Select Case op
Case "+"
TextBox1.Text = a + Val(TextBox1.Text)
Case "-"
TextBox1.Text = a - Val(TextBox1.Text)
Case "*"
TextBox1.Text = a * Val(TextBox1.Text)
Case "/"
TextBox1.Text = a / Val(TextBox1.Text)
End Select
End Sub
End Class

RESULT:
Thus the above program for calculator control was executed successfully and the output was
verified.
.Net Programming

(V-Sem)

Latha Mathavan Polytechnic College

Computer Engineering

CALENDAR

Ex.No: 6
Date:
Aim:

Develop a form in VB.NET to pick a date from calendar control and display the day,
month and year details in separate text boxes.

Apparatus Required:
Software Required: 1. DotNet Framework
2. VB.Net
Hardware Required: Computer with Pentium IV/ Dual core processors.

Procedure:
1. Click StartProgramsMicrosoftVisualStudio 2005 MicrosoftVisualStudio 2005 to

open the Microsoft VisualStudio (IDE).


2. Select File New Project window application.
3. Open the window application form.
4. Place the DataTimePicker control in the form Window from the Toolbox.

5. Construct form with labels, textboxes and button.


6. Then Insert the code in the click event procedure of Button control as well as insert code
in the change event procedure of DateTimePicker control.
7. Finally run the window application.

.Net Programming

(V-Sem)

Latha Mathavan Polytechnic College

Computer Engineering

Source Code:
Public Class Form1
Private Sub DateTimePicker1_ValueChanged(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles DateTimePicker1.ValueChanged
TextBox1.Text = DateTimePicker1.Value.Day
TextBox2.Text = DatePart(DateInterval.Month, DateTimePicker1.Value)
TextBox3.Text = DateTimePicker1.Value.Year
TextBox4.Text = DateTimePicker1.Value.Hour
End Sub
End Class

RESULT:
Thus the above program for displaying the date, time using calendar control was executed
successfully.
.Net Programming

(V-Sem)

Latha Mathavan Polytechnic College

Computer Engineering

TIME BASED QUIZ PROGRAM

Ex.No: 7
Date:
Aim:

Develop a form in VB.NET application to perform timer based quiz of 10 questions.


Apparatus Required:
Software Required: 1. DotNet Framework
2. VB.Net
Hardware Required: Computer with Pentium IV/ Dual core processors.
Procedure:
1. Click StartProgramsMicrosoftVisualStudio 2005 MicrosoftVisualStudio 2005 to
open the Microsoft VisualStudio (IDE).
2. Select File New Project window application.

3. Open the window application form.


4. Place three command buttons, three radio buttons, Labels, Timer control and Group box
from the Toolbox.
5. Insert the code in the Timer click event using case statement.
6. Then Insert the code in the button click event for next questions using Case statement.
7. Finally run the window application.

Source Code:
.Net Programming

(V-Sem)

Latha Mathavan Polytechnic College

Computer Engineering

Public Class quiz


Public cnt As Integer = 0
Public tot As Integer = 0
Private Sub quiz_Load(ByVal sender As System.Object, ByVal e As System.EventArgs)
Handles MyBase.Load
RadioButton1.Checked = False
RadioButton2.Checked = False
Label1.Text = "Who is the leading contributer for java?"
RadioButton1.Text = "James Gosling"
RadioButton2.Text = " Denis Ritchie"
End Sub
Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs)
Handles Timer1.Tick
cnt = cnt + 1
Select Case cnt
Case 1
If (RadioButton1.Checked = True) Then
tot = tot + 10
End If
RadioButton1.Checked = False
RadioButton2.Checked = False
Label1.Text = "Who is the CEO of Wipro?"
RadioButton1.Text = "Narayana Moorthy"
RadioButton2.Text = " Asim premji"
Case 2
If (RadioButton2.Checked = True) Then
tot = tot + 10
End If
RadioButton1.Checked = False
RadioButton2.Checked = False
Label1.Text = "Who is our college chairman?"
RadioButton1.Text = "latha"
RadioButton2.Text = " mathavan"
Case 3
If (RadioButton2.Checked = True) Then
tot = tot + 10
End If
RadioButton1.Checked = False
RadioButton2.Checked = False
Label1.Text = "What is the first OS used in mobile?"
RadioButton1.Text = "Symbion"
.Net Programming

(V-Sem)

Latha Mathavan Polytechnic College

Computer Engineering

RadioButton2.Text = " android"


Case 4
If (RadioButton1.Checked = True) Then
tot = tot + 10
End If
RadioButton1.Checked = False
RadioButton2.Checked = False
Label1.Text = "Which is the leading IT industry in India?"
RadioButton1.Text = "Infosys"
RadioButton2.Text = " TCS"
Case 5
If (RadioButton2.Checked = True) Then
tot = tot + 10
End If
RadioButton1.Checked = False
RadioButton2.Checked = False
Label1.Text = "Who is the founder of apple?"
RadioButton1.Text = "Steve balmer"
RadioButton2.Text = "Steve jobs"
Case 6
If (RadioButton2.Checked = True) Then
tot = tot + 10
End If
RadioButton1.Checked = False
RadioButton2.Checked = False
Label1.Text = ""
RadioButton1.Text = ""
RadioButton2.Text = ""
RadioButton2.Enabled = False
RadioButton1.Enabled = False
MsgBox("your Total Score is " & tot)
End Select
End Sub
End Class

RESULT:
Thus the above program for timer based quiz was executed successfully and the output was
verified .
Ex.No: 8
.Net Programming

FILE, DIRECTORY AND DRIVE OPERATIONS


(V-Sem)

Latha Mathavan Polytechnic College

Computer Engineering

Date:
Aim:
Develop a VB.NET application using the File, Directory and drive controls to
implement a common dialog box.

Apparatus Required:
Software Required: 1. DotNet Framework
2. VB.Net
Hardware Required: Computer with Pentium IV/ Dual core processors.

Procedure:
1. Click StartProgramsMicrosoftVisualStudio 2005 MicrosoftVisualStudio 2005 to
open the Microsoft VisualStudio (IDE).
2. Select File New Project window application.Open the window application form.
3. Place the Drive List Box, Directory List Box, File List Box, Textbox, Button from the

Toolbox.
4. Insert the code for selected Index Changed event in the Drive, Directory, File listbox.
5. Then place the image at run time for Button click event.
6. Finally run the window application.

Source Code:
Public Class expno8
.Net Programming

(V-Sem)

Latha Mathavan Polytechnic College

Computer Engineering

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)


Handles Button1.Click
Dim pstr As String
pstr = ComboBox1.SelectedItem + "\" + ComboBox2.SelectedItem + "\" +
ComboBox3.SelectedItem
MsgBox(pstr)
PictureBox1.ImageLocation = pstr
End Sub
End Class

RESULT:
Thus the above program for implementing file, directory and drive control was executed
successfully and the output was verified.
Ex.No: 9

DISPLAY THE STUDENT INFORMATION USING ADO.NET

Date:
.Net Programming

(V-Sem)

Latha Mathavan Polytechnic College

Computer Engineering

Aim:
Develop a database application to store the details of students using ADO.NET.
Apparatus Required:
Software Required: DotNet Framework,VB.Net, ASP.Net, SQL Server 2000.
Hardware Required: Computer with Pentium IV/ Dual core processors.
Procedure:
1. Open the window application form.
2. Construct the form with labels, textboxes and button from toolbox.
3. First add new record to the existing table for click event. That is all the textboxes are set
to clear.
4. Then insert the new record using Data Bindings method to text property of the textbox
control and to fetch the data from the field in the table.
5. With the use of ExecuteNonQuery method of OleDb Command to insert new record to
the table and after inserting, databindings related to all textboxes are cleared.
6. The ExecuteNonQuery() method sends the SQL command to the Database server.
7. Then call in our My dataset dataset object.
8. After inserting the new record then identify the current position with the help of
mybind.position.
9. Then delete the existing record from the table with the help of ExecuteNonQuery string
command, updated from the table with the OleDbDataAdapter.
10. Finally run the application.

Source Code:
Imports System.Data.SqlClient
Public Class Form1
Dim bm As BindingManagerBase
.Net Programming

(V-Sem)

Latha Mathavan Polytechnic College

Computer Engineering

Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs)


Handles MyBase.Load
Dim con As New SqlConnection
Dim ada As New SqlDataAdapter
Dim ds As New DataSet
Dim cmd As New SqlCommand
Try
con.ConnectionString = "Data Source=PRAKASH-A6DC00A;Initial
Catalog=stu;Integrated Security=true"
con.Open()
ada = New SqlDataAdapter("select * from stud", con)
ada.Fill(ds, "stud")
TextBox1.DataBindings.Add("text", ds, "stud.name")
TextBox2.DataBindings.Add("text", ds, "stud.rollno")
TextBox3.DataBindings.Add("text", ds, "stud.branch")
TextBox4.DataBindings.Add("text", ds, "stud.year")
bm = Me.BindingContext(ds, "stud")
Catch ex As Exception
MsgBox(ex.Message)
End Try
End Sub
Private Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles
Button1.Click
bm.Position = 0
End Sub
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)
Handles Button2.Click
bm.Position += 1
End Sub
Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)
Handles Button3.Click
bm.Position -= 1
End Sub
Private Sub Button4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)
Handles Button4.Click
bm.Position = bm.Count - 1
End Sub
End Class
SQL Commands:
Procedure:
.Net Programming

(V-Sem)

Latha Mathavan Polytechnic College

Computer Engineering

1. Open the SQL server 2000 Enterprise manager SQL server group local windows

NT database.
2. Create a new database with the name stu to store the student information.
3. Right click the database, and select new table to create a new table named as stud.

Create
Create table stud(name varchar(15), rollno int, branch varchar(10), year int)
Insert
Insert into stud values(amar,1501,cse,2)
Display
Select * from stud

RESULT:
Thus the above program for displaying the records using ADO.NET was executed successfully
and the output was verified.

.Net Programming

(V-Sem)

Latha Mathavan Polytechnic College

Computer Engineering

STUDENT DATABASE USING ADO.NET

Ex.No: 10
Date:

Aim:
Develop a database application using ADO.NET to insert, modify, update and delete
operations.
Apparatus Required:
Software Required: DotNet Framework,VB.Net, ASP.Net, SQL Server 2000.
Hardware Required: Computer with Pentium IV/ Dual core processors.
Procedure:
1. Open the window application form.
2. Construct the form with labels, textboxes and button from toolbox.
3. First add new record to the existing table for click event. That is all the textboxes are set
to clear.
4. Then insert the new record using Data Bindings method to text property of the textbox
control and to fetch the data from the field in the table.
5. With the use of ExecuteNonQuery method of OleDb Command to insert new record to
the table and after inserting, databindings related to all textboxes are cleared.
6. The ExecuteNonQuery() method sends the SQL command to the Database server.
7. Then call in our My dataset dataset object.
8. After inserting the new record then identify the current position with the help of
mybind.position.
9. Then delete the existing record from the table with the help of ExecuteNonQuery string
command, updated from the table with the OleDbDataAdapter.
10. Finally run the application.
.Net Programming

(V-Sem)

Latha Mathavan Polytechnic College

Computer Engineering

DataAdapter Configuration Wizard and Connection:


1. In the Toolbox, select the data tab, Drag an OleDb DataAdapter on to the design interface
of the component.
2. Now open the DataAdapter configuration wizard then choose your new Data Connection
then click Next button.
3. Then Data Link properties window appeared.
4. In Data Link properties, First tab select the name of the provider, second tab select the
connection, i.e., select the name of the server, user name, database name.
5. Then press the test connection button to check if we have correctly configured the
connection.
6. Then press Ok button to create the connection.
7. Then the Query type window will appear, we have to select the data adapter by using
SQL statements or stored procedures.
8. Then press the Next button, the screen appears called as generate the SQL statements.
9. In this window, the SQL command can be typed manually or we can form command
through the SQL Query Builder(Select the Query builder button).
10. On the first dialog that appears, select the table name and press the Add button, and then
press close.
11. After selecting OK button, the resulting screen appears i.e., top of the box in the Query
builder window, list the columns in the table, then check all the columns, then press OK
button.
12. After the completion of Query Builder, press the Next button, then appears the View
Wizard results to generate the OleDb DataAdapter was configured successfully.

DataSet:
1. To generate the dataset, right click the Oledb DataAdapter
2. Then appear the generate DataSet window then choose the table to be added with the
DataSet then press OK button.
3. Then place the new dataset in the form.
.Net Programming

(V-Sem)

Latha Mathavan Polytechnic College

Computer Engineering

Source Code:
Imports System.Data.SqlClient
Public Class exno10
Dim con As New SqlConnection
Dim ada As New SqlDataAdapter
Dim ds As New DataSet
Dim cmd As New SqlCommand
Dim bm As BindingManagerBase
Dim dr As SqlDataReader
Private Sub exno10_Load(ByVal sender As System.Object, ByVal e As System.EventArgs)
Handles MyBase.Load
con.ConnectionString = "Data Source=PRAKASH-A6DC00A;Initial
Catalog=stu;Integrated Security=true"
con.Open()
ada = New SqlDataAdapter("select * from stud", con)
ada.Fill(ds, "stud")
TextBox1.DataBindings.Add("text", ds, "stud.name")
TextBox2.DataBindings.Add("text", ds, "stud.rollno")
TextBox3.DataBindings.Add("text", ds, "stud.branch")
TextBox4.DataBindings.Add("text", ds, "stud.year")
bm = Me.BindingContext(ds, "stud")
End Sub
Private Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles
Button1.Click
cmd = New SqlCommand("insert into stud values('" + TextBox1.Text + "'," +
TextBox2.Text + ",'" + TextBox3.Text + "'," + TextBox4.Text + ")", con)
cmd.ExecuteNonQuery()
MsgBox("Record added successfully!!!")
End Sub
Private Sub Button2_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles
Button2.Click
cmd = New SqlCommand("delete from stud where rollno=" + TextBox2.Text + " ", con)
cmd.ExecuteNonQuery()
MsgBox("Record deleted successfully")
End Sub
Private Sub Button3_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles
Button3.Click
cmd = New SqlCommand(" update stud set name='" + TextBox1.Text + "',branch='" +
TextBox3.Text + "', year=" + TextBox4.Text + "where rollno=" + TextBox2.Text + "", con)
.Net Programming

(V-Sem)

Latha Mathavan Polytechnic College

Computer Engineering

cmd.ExecuteNonQuery()
MsgBox("Record Is updated")
End Sub
Private Sub Button4_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles
Button4.Click
Try
cmd = New SqlCommand("select * from stud where rollno=" + TextBox2.Text + "", con)
dr = cmd.ExecuteReader
dr.Read()
TextBox1.Text = dr(0)
TextBox3.Text = dr(2)
TextBox4.Text = dr(3)
dr.Close()
Catch ex As Exception
MsgBox("Record not found")
dr.Close()
End Try
End Sub
Private Sub Button5_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)
Handles Button5.Click
TextBox1.Text = ""
TextBox2.Text = ""
TextBox3.Text = ""
TextBox4.Text = ""
End Sub
End Class

RESULT:
Thus the above program for performing insert, delete, update and search operations using
ADO.NET was executed successfully and the output was verified.
.Net Programming

(V-Sem)

Latha Mathavan Polytechnic College

Ex.No: 11

Computer Engineering

DISPLAY THE RECORDS USING DATAGRID

Date:

Aim:
Develop a VB.Net application using Datagrid to display records.
Apparatus Required:
Software Required: DotNet Framework,VB.Net, ASP.Net, SQL Server 2000.
Hardware Required: Computer with Pentium IV/ Dual core processors.
Procedure:
1. Open the window application form.
2. Place the DtaGrid from toolbox.
3. Then create OleDb DataAdapter, connection and DataSet.
4. After creation of Adapter then open the property of the DataGrid , we can set the Data
source and Data member.
5. Then insert the code in the Form load event.
6. Then run the application to give student information through the grid.
DataAdapter Configuration Wizard and Connection:
1. In the Toolbox, select the data tab, Drag an OleDb DataAdapter on to the design interface
of the component.
2. Now open the DataAdapter configuration wizard then choose your new Data Connection
then click Next button.
3. Then Data Link properties window appeared.
4. In Data Link properties, First tab select the name of the provider, second tab select the
connection, i.e., select the name of the server, user name, database name.
5. Then press the test connection button to check if we have correctly configured the
connection.
.Net Programming
(V-Sem)

Latha Mathavan Polytechnic College

Computer Engineering

6. Then press Ok button to create the connection.


7. Then the Query type window will appear, we have to select the data adapter by using
SQL statements or stored procedures.
8. Then press the Next button, the screen appears called as generate the SQL statements.
9. In this window, the SQL command can be typed manually or we can form command
through the SQL Query Builder(Select the Query builder button).
10. On the first dialog that appears, select the table name and press the Add button, and then
press close.
11. After selecting OK button, the resulting screen appears i.e., top of the box in the Query
builder window, list the columns in the table, then check all the columns, then press OK
button.
12. After the completion of Query Builder, press the Next button, then appears the View
Wizard results to generate the OleDb DataAdapter was configured successfully.

DataSet:
1. To generate the dataset, right click the Oledb DataAdapter
2. Then appear the generate DataSet window then choose the table to be added with the
DataSet then press OK button.
3. Then place the new dataset in the form.

.Net Programming

(V-Sem)

Latha Mathavan Polytechnic College

Computer Engineering

Source Code:
Imports System.Data.SqlClient
Public Class Form1
Dim con As New SqlConnection
Dim ada As New SqlDataAdapter
Dim ds As New DataSet
Dim cmd As New SqlCommand
Dim bm As BindingManagerBase
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs)
Handles MyBase.Load
con.ConnectionString = "Data Source=PRAKASH-A6DC00A;Initial
Catalog=stu;Integrated Security=true"
con.Open()
ada = New SqlDataAdapter("select * from stud", con)
ada.Fill(ds, "stud")
DataGridView1.DataSource = ds.Tables(0)
bm = Me.BindingContext(ds, "stud")
End Sub
End Class

RESULT:
Thus the above program for displaying records using DataGrid view was executed successfully
and the output was verified.

.Net Programming

(V-Sem)

Latha Mathavan Polytechnic College


Ex.No: 12

Computer Engineering

UPDATION OF STUDENT INFORMATION USING DATAGRID

Date:
Aim:
Develop a VB.Net application using Datagrid to add, edit and modify records.
Apparatus Required:
Software Required: DotNet Framework,VB.Net, ASP.Net, SQL Server 2000.
Hardware Required: Computer with Pentium IV/ Dual core processors.
Procedure:
1. Open the window application form.
2. Place the DtaGrid, button from toolbox.
3. Then create OleDb DataAdapter, connection and DataSet.
4. After creation of Adapter then open the property of the DataGrid , we can set the Data
source and Data member.
5. Then insert the code in the Form load event.
6. Then run the application to edit, delete the student information through the grid.
DataAdapter Configuration Wizard and Connection:
1. In the Toolbox, select the data tab, Drag an OleDb DataAdapter on to the design interface
of the component.
2. Now open the DataAdapter configuration wizard then choose your new Data Connection
then click Next button.
3. Then Data Link properties window appeared.
4. In Data Link properties, First tab select the name of the provider, second tab select the
connection, i.e., select the name of the server, user name, database name.
5. Then press the test connection button to check if we have correctly configured the
connection.
6. Then press Ok button to create the connection.
.Net Programming

(V-Sem)

Latha Mathavan Polytechnic College

Computer Engineering

7. Then the Query type window will appear, we have to select the data adapter by using
SQL statements or stored procedures.
8. Then press the Next button, the screen appears called as generate the SQL statements.
9. In this window, the SQL command can be typed manually or we can form command
through the SQL Query Builder(Select the Query builder button).
10. On the first dialog that appears, select the table name and press the Add button, and then
press close.
11. After selecting OK button, the resulting screen appears i.e., top of the box in the Query
builder window, list the columns in the table, then check all the columns, then press OK
button.
12. After the completion of Query Builder, press the Next button, then appears the View
Wizard results to generate the OleDb DataAdapter was configured successfully.

DataSet:
1. To generate the dataset, right click the Oledb DataAdapter
2. Then appear the generate DataSet window then choose the table to be added with the
DataSet then press OK button.
3. Then place the new dataset in the form.

.Net Programming

(V-Sem)

Latha Mathavan Polytechnic College

Computer Engineering

Source Code:
Imports System.Data.SqlClient
Public Class Form1
Dim con As New SqlConnection
Dim ada As New SqlDataAdapter
Dim ds As New DataSet
Dim cmd As New SqlCommand
Dim bm As BindingManagerBase
Dim dr As SqlDataReader
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs)
Handles MyBase.Load
Try
con.ConnectionString = "Data Source=PRAKASH-A6DC00A;Initial
Catalog=stu;Integrated Security=true"
con.Open()
ada = New SqlDataAdapter("select * from stud", con)
ada.Fill(ds, "stud")
DataGridView1.DataSource = ds.Tables(0)
TextBox1.DataBindings.Add("text", ds, "stud.name")
TextBox2.DataBindings.Add("text", ds, "stud.rollno")
TextBox3.DataBindings.Add("text", ds, "stud.branch")
TextBox4.DataBindings.Add("text", ds, "stud.year")
bm = Me.BindingContext(ds, "stud")
Catch ex As Exception
MsgBox(ex.Message)
End Try
End Sub
Private Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles
Button1.Click
cmd.Connection = con
cmd = New SqlCommand("insert into stud values('" + TextBox1.Text + "'," +
TextBox2.Text + ",'" + TextBox3.Text + "'," + TextBox4.Text + ")", con)
cmd.ExecuteNonQuery()
MsgBox("Record added successfully!!!")
End Sub

.Net Programming

(V-Sem)

Latha Mathavan Polytechnic College

Computer Engineering

Private Sub Button2_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles


Button2.Click
cmd.Connection = con
cmd = New SqlCommand("delete from stud where rollno=" + TextBox2.Text + " ", con)
cmd.ExecuteNonQuery()
MsgBox("Record deleted successfully")
End Sub
Private Sub Button3_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles
Button3.Click
cmd.Connection = con
cmd = New SqlCommand(" update stud set name='" + TextBox1.Text + "',branch='" +
TextBox3.Text + "', year=" + TextBox4.Text + "where rollno=" + TextBox2.Text + "", con)
cmd.ExecuteNonQuery()
MsgBox("Record Is updated")
End Sub
Private Sub Button4_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles
Button4.Click
Try
cmd.Connection = con
cmd = New SqlCommand("select * from stud where rollno=" + TextBox2.Text + "", con)
dr = cmd.ExecuteReader
dr.Read()
TextBox1.Text = dr(0)
TextBox3.Text = dr(2)
TextBox4.Text = dr(3)
dr.Close()
Catch ex As Exception
MsgBox("Record not found")
dr.Close()
End Try
End Sub
End Class

RESULT:
Thus the above program for updating records using DataGrid view was executed successfully
and the output was verified.
.Net Programming

(V-Sem)

Latha Mathavan Polytechnic College

Computer Engineering

CLICK EVENT CREATION

Ex.No: 13
Date:
Aim:

Create a simple ASP.NET page to output Text with a form, two HTML textboxes, a
HTML button, and an HTML<span> element. Create an event procedure for the button.
Apparatus Required:
Software Required: DotNet Framework,
ASP.Net

Hardware Required: Computer with Pentium IV/ Dual core processors.

Procedure:
1. Click StartProgramsMicrosoftVisualStudio 2005 MicrosoftVisualStudio 2005 to

open the Microsoft VisualStudio (IDE).

2. Select File New Project web application.

3. Construct form with button, textboxes, List Box and Drop Down List from toolbox.

4. Set the property Autopostback as true for List Box and Drop down list.

.
5. Then insert the code in the View code Window for appropriate click event program

6. Finally run the web application.


.Net Programming

(V-Sem)

Latha Mathavan Polytechnic College

Computer Engineering

Source Code:
Public Class _Default
Inherits System.Web.UI.Page
Private Sub Button1_Click(ByVal sender As Object, ByVal e As EventArgs) Handles
Button1.Click
TextBox1.Text = "Welcome to Temple City"
End Sub
Private Sub DropDownList1_SelectedIndexChanged(ByVal sender As Object, ByVal e As
System.EventArgs) Handles DropDownList1.SelectedIndexChanged
TextBox2.Text = "You have selected the color:" &
_DropDownList1.SelectedItem.Value.ToString
End Sub
Private Sub ListBox1_SelectedIndexChanged(ByVal sender As Object, ByVal e As
System.EventArgs) Handles ListBox1.SelectedIndexChanged
TextBox2.Text = "You have selected the subject:" &
_ListBox1.SelectedItem.Value.ToString
End Sub
End Class

RESULT:
Thus the above program for creating a simple ASP.NET page was executed successfully and the
output was verified.

.Net Programming

(V-Sem)

Latha Mathavan Polytechnic College

Ex.No: 14

Computer Engineering

RESERVING ROOMS USING WEBCONTROLS

Date:
Aim:
Create a web controls to a page with three different controls to the ASP.NET page for
reserving rooms in hotel. The three controls are a button control, a label control, and a
drop-down list control.
Apparatus Required:

Software Required: 1. DotNet Framework


2. ASP.Net

Hardware Required: Computer with Pentium IV/ Dual core processors.

Procedure:
1. Click StartProgramsMicrosoftVisualStudio 2005 MicrosoftVisualStudio 2005 to

open the Microsoft VisualStudio (IDE).

2. Select File New Project web application.

3. Construct form with button, Label and Drop Down List boxes from toolbox.

4. Then insert the code in the View code Window for appropriate click event program

5. Finally run the web application.

.Net Programming

(V-Sem)

Latha Mathavan Polytechnic College

Computer Engineering

Source Code:
Public Partial Class WebForm2
Inherits System.Web.UI.Page
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles
Me.Load
Label1.Visible = False
End Sub
Private Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles
Button1.Click
Label1.Visible = True
Label1.Text = DropDownList1.SelectedItem.Text + "is Reserved for you :-)"
DropDownList1.Items.Remove(DropDownList1.SelectedItem.Text)
If DropDownList1.Items.Count = 0 Then
Button1.Enabled = False
End If
End Sub
End Class

RESULT:
Thus the above program for reserving hotel rooms using ASP.NET was executed successfully
and the output was verified.
.Net Programming

(V-Sem)

Latha Mathavan Polytechnic College

Ex.No: 15

Computer Engineering

REPEATER CONTROL USING ADO.NET

Date:
Aim:
Create an application for accessing a SQL Database by using ADO.NET by
connecting to the SQL server database and call a stored procedure. Then to display the data in a
repeater control.
Apparatus Required:
Software Required: DotNet Framework,VB.Net, ASP.Net, SQL Server 2000.
Hardware Required: Computer with Pentium IV/ Dual core processors.
Procedure:
1. Open the Web application form.
2. Place the Repeater control from toolbox.
3. Then create OleDb DataAdapter, connection and DataSet.
4. After creation of Adapter then open the property of the DataGrid , we can set the Data
source and Data member.
5. Then insert the code in the Form load event.
6. Then run the application to give student information through the Repeater control.
DataAdapter Configuration Wizard and Connection:
1. In the Toolbox, select the data tab, Drag an OleDb DataAdapter on to the design interface
of the component.
2. Now open the DataAdapter configuration wizard then choose your new Data Connection
then click Next button.
3. Then Data Link properties window appeared.
4. In Data Link properties, First tab select the name of the provider, second tab select the
connection, i.e., select the name of the server, user name, database name.

.Net Programming

(V-Sem)

Latha Mathavan Polytechnic College

Computer Engineering

5. Then press the test connection button to check if we have correctly configured the
connection.
6. Then press Ok button to create the connection.
7. Then the Query type window will appear, we have to select the data adapter by using
SQL statements or stored procedures.
8. Then press the Next button, the screen appears called as generate the SQL statements.
9. In this window, the SQL command can be typed manually or we can form command
through the SQL Query Builder(Select the Query builder button).
10. On the first dialog that appears, select the table name and press the Add button, and then
press close.
11. After selecting OK button, the resulting screen appears i.e., top of the box in the Query
builder window, list the columns in the table, then check all the columns, then press OK
button.
12. After the completion of Query Builder, press the Next button, then appears the View
Wizard results to generate the OleDb DataAdapter was configured successfully.

DataSet:
1. To generate the dataset, right click the Oledb DataAdapter
2. Then appear the generate DataSet window then choose the table to be added with the
DataSet then press OK button.
3. Then place the new dataset in the form.

Source Code:
.Net Programming

(V-Sem)

Latha Mathavan Polytechnic College

Computer Engineering

Double click the web.config file and write following code in it:
<connectionStrings>
<add name="constr" connectionString="initial catalog=puran; data source=MCN002;
integrated security=sspi"/>
</connectionStrings>
Default.aspx file code
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs"
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">
<link rel="Stylesheet" type="text/css" href="StyleSheet.css" />
<title>Repeater Controls in ASP.NET</title>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:Repeater ID="RepeatInformation" runat="server">
<HeaderTemplate>
<table class="tblcolor">
<tr>
<b>
<td>
Roll No
</td>
<td>
Student Name
</td>
<td>
Total Fees
</td>
</b>
</tr>
</HeaderTemplate>
<ItemTemplate>
<tr class="tblrowcolor">
.Net Programming

(V-Sem)

Latha Mathavan Polytechnic College

Computer Engineering

<td>
<%#DataBinder.Eval(Container,"DataItem.RollNo")%>
</td>
<td>
<%#DataBinder.Eval(Container,"DataItem.Name")%>
</td>
<td>
<%#DataBinder.Eval(Container,"DataItem.Fees")%>
</td>
</tr>
</ItemTemplate>
<SeparatorTemplate>
<tr>
<td>
<hr />
</td>
<td>
<hr />
</td>
<td>
<hr />
</td>
</tr>
</SeparatorTemplate>
<AlternatingItemTemplate>
<tr>
<td>
<%#DataBinder.Eval(Container,"DataItem.RollNo")%>
</td>
<td>
<%#DataBinder.Eval(Container,"DataItem.Name")%>
</td>
<td>
<%#DataBinder.Eval(Container,"DataItem.Fees")%>
</td>
</tr>
</AlternatingItemTemplate>
<SeparatorTemplate>
<tr>
<td>
.Net Programming

(V-Sem)

Latha Mathavan Polytechnic College

Computer Engineering

<hr />
</td>
<td>
<hr />
</td>
<td>
<hr />
</td>
</tr>
</SeparatorTemplate>
<FooterTemplate>
<tr>
<td>
School Records displayed
</td>
</tr>
</table>
</FooterTemplate>
</asp:Repeater>
</div>
</form>
</body>
</html>
Code behind file code
using System;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using System.Data.SqlClient;
public partial class _Default : System.Web.UI.Page
.Net Programming

(V-Sem)

Latha Mathavan Polytechnic College

Computer Engineering

{
SqlConnection con;
SqlCommand cmd = new SqlCommand();
protected void Page_Load(object sender, EventArgs e)
{
con = new
SqlConnection(ConfigurationManager.ConnectionStrings["constr"].ConnectionString);
cmd.Connection = con;
cmd.CommandText = "select * from student";
con.Open();
RepeatInformation.DataSource = cmd.ExecuteReader();
RepeatInformation.DataBind();
con.Close();
}
}

RESULT:
Thus the above program for updating records using ASP.NET was executed successfully and the
output was verified.
Ex.No: 16
.Net Programming

HOTEL MANAGEMENT USING WEB SERVICES


(V-Sem)

Latha Mathavan Polytechnic College

Computer Engineering

Date:
Aim:
Create a web service application for calling a Web service for a hotel named full, and
call another web service for a hotel named Empty, and then retrieve information regarding room
availability. The web service for full hotel is named Hotel_Full.dll. the web service for the hotel
Empty is Hotel_Empty.dll. There are five methods in each service.
1. Reserve takes room types and start and end dates and returns a Boolean value that
indicates whether a room is available. <WebMethod()>public Function Reserve
(strRoomType1 As String, strRoomType2 As String, dtmStartDate As Date, dtmEndDate
As Date) As Boolean
2. Price returns a double value that is the cost of the rent for one day <WebMethod()>public
Function Price(strRoomType1 As String) As Double
3. Description returns a string that describes the hotel. <WebMethod()>public Function
Description() As String
4. Room returns a string that describes the rooms of the hotel. <WebMethod()>public
Function Room() As String
5. Food returns a string that describes the food available at the hotel. <WebMethod()>public
Function Food() As String.
Apparatus Required:
Software Required: DotNet Framework,VB.Net, ASP.Net, SQL Server 2000.
Hardware Required: Computer with Pentium IV/ Dual core processors.
Procedure:
1. Open the Visual Basic .NET IDE.
2. Select File New Project Web application to open the new aspx.web service file.

3. Create various functions for performing the operation of Reserve, Price, Rooms,
Description and Food.
4. Then write the code in the coding window.
5. Finally, run the web service to produce output.

Web Service:
.Net Programming

(V-Sem)

Latha Mathavan Polytechnic College

Computer Engineering

1. Open a new ASP.NET web service then click OK.


2. Create a new project folder name as WebServices.asm and then click OK.
3. Write the web method Functions in current WebService.asm
4. Then run the WebService.
5. Then give the URL address of the previous WebService.asmx
6. Finally give the Web Reference Name and click the AddReference Button.
7. Write the code for the appropriate web service methods
8. Run the program and verify the output.

Source Code:
.Net Programming

(V-Sem)

Latha Mathavan Polytechnic College

Computer Engineering

Public class Service1


Inherits System.Web.Services.WebService
Public Function price(By Val strroomtype1 As String) As Double
If strroomtype1=Single Then
Return 1000
ElseIf strroomtype1=Double Then
Return 2000
ElseIf strroomtype1=Luxury Then
Return 4000
ElseIf strroomtype1=Gold Then
Return 5000
ElseIf strroomtype1=Diamond Then
Return 10000
End If
Return 0
End Function
Public Function Room() As String()
Dim roomtype As String = {Single,Double,Luxury,Gold,Diamond}
Return roomtype
End Function
Public Function Food () As String()
Dim foodtype() As String={Chinese,Indian,Thai}
Return foodtype
End Function
Public Function description() As String
.Net Programming

(V-Sem)

Latha Mathavan Polytechnic College

Computer Engineering

Dim s As String
s=IT IS A 3-STAR HOTEL. WE HAVE DIFFERENT TYPES OF ROOMS WITH ALL
FACILITY
Return s
Public Function reserve(By Val roomnumber As String) As Boolean
Select case roomnumber
Case room1
Return True
End Select
End Function
End Class Function

WEB APPLICATION:
.Net Programming

(V-Sem)

Latha Mathavan Polytechnic College

Computer Engineering

Public class WebForm1


Inherits System.Wen.UI.Page
Dim h as localhost.Service1 = New localhost.Service1
Dim i as localhost.Service1 = New localhost.Service1
Private Sub Page_Load(By Val sender As System.Object, By Val e As System.EventArgs)
Handles Mybase.Load
Count= True
Label2.Text=
If Not IsPostBack Then
Dim str As String
Dim st As String
For Each str In h.Room()
DropDownList1.Items.Add(str)
Next
Label1.Text=h.description()
End If
End Sub
Private Sub DropDownList3_SelectedIndexChanged(By Val sender As System.Object, By Val e
As System.EventArgs) Handles DropDownList3.SelectedIndexChanged
If DropDownList3.SelectedIndex = 1 Then
If Not IsPostBack Then
Dim str As String
Dim st As String
For Each str In h.Room()
DropDownList1.Items.Remove(str)
DropDownList1.Items.Add(str)
.Net Programming

(V-Sem)

Latha Mathavan Polytechnic College

Computer Engineering

Next
For Each st In h.Food()
DropDownList2.Items.Remove(st)
DropDownList2.Items.Add(st)
Next
Label1.Text= h.description()
End If
ElseIf DropDownList3.SelectedIndex = 2 Then
If Not IsPostBack Then
Dim str As String
Dim st As String
For Each str In h.Room()
DropDownList1.Items.Remove(str)
DropDownList1.Items.Add(str)
Next
For Each st In h.Food()
DropDownList2.Items.Remove(st)
DropDownList2.Items.Add(st)
Next
Label1.Text= h.description()
End If
Elself DropDownList3.SelectedIndex = 2 Then
If No IsPostBack Then
Dim str1 As String
Dim st1 As String
.Net Programming

(V-Sem)

Latha Mathavan Polytechnic College

Computer Engineering

For Each str1 In i.Room()


DropDownList1.Items.Remove(str1)
DropDownList1.Items.Add(str1)
Next
For Each st1 In h.Food()
DropDownList2.Items.Remove(st1)
DropDownList2.Items.Add(st1)
Next
Label1.Text= i.description()
End If
End Sub
Private Sub DropDownList1_SelectedIndexChanged(By Val sender As System.Object, By Val e
As System.EventArgs) Handles DropDownList1.SelectedIndexChanged
If DropDownList1.SelectedIndex >=0 Then
Label3. Text= h.price(DropDownList2.SelectedItem. ToString()).ToString() +
Label2. Text= h.price(DropDownList1.SelectedItem. ToString()).ToString() +
End If
Private Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles
Button1.Click
Response. Write(count)
Textbox1.Text = Calender1. SelectedDate. ToShortDateString()
Textbox2.Text = Calender2. SelectedDate. ToShortDateString()
If TextBox1.Text = 1/1/0001 Then
Response. Write(Fill Correctly)
Go To l1
End If
.Net Programming

(V-Sem)

Latha Mathavan Polytechnic College

Computer Engineering

If TextBox2.Text = 1/1/0001 Then


Response. Write(Fill Correctly)
Else
Response.Write(Ok)
End If
l1:
If count= True Then
If DropDownList3.SelectedItem. ToString() = room1 Then
count= False
Response. Write(count)
Response. Write(Room Reserved)
DropDownList4.Items.Add(DropDownList3.SelectedItem.Text)
DropDownList4.Items.Remove(DropDownList3.SelectedItem.Text)
End If
Else
Response. Write(count)
MsgBox(Count &count)
Response. Write(Room is alreadyReserved)
End If
End Sub
End Class
RESULT:
Thus the above program for Hotel management using ASP.NET web service was executed
successfully and the output was verified.

.Net Programming

(V-Sem)

Você também pode gostar