The document provides an overview of .NET technology and VB.NET programming. It discusses key aspects of .NET including the Common Language Runtime (CLR), Common Type System, Windows Forms, Web Forms, Web Services, ADO.NET, XML support, and multiple language support. It also covers VB.NET programming concepts like forms, events, databases, dialog boxes, menus, classes, and arrays of objects. The document is intended as teaching material for a course on .NET and VB.NET programming.
2. Today’s Discussion
What We Expect From Language?
What is new in .NET?
Comparisons with Previous Technologies /
JAVA / VB-6 etc.
First Look of VB .NET
3. What is in Language?
Interaction With Other Language
Platform Support
Programming Technique (structured ? Procedural? OOP?)
Databases Support
Database Handling Technique
Thread Model
Component Designing?
4. Network Support Programming? (Socket Programming)
Internet Programming ?
Future / Reliability?
5. What is new in .NET Technology
.NET Framework covers all the layers of software
development from the operating system up
6. .NET Framework
ASP.NET
Web Services Web Forms
ASP.NET Application Service
Windows Forms
Controls Drawing
Windows Application Service
.NET Framework Base Classes
ADO.NET XML Threading IO
Net Security Diagnoses Etc.
Common Language Runtime
Memory
Management
Common Type System
Lifecycle
Monitoring
7. Windows Forms (Winforms)
Windows Form are a new way to create Standard WIN32
Desktop Application based on the Windows Foundation
Classes(WFC)
8. Web Forms
Web Forms provide a powerful, form based user interface for
web, it also contains additional .net ASP controls which was
not present in previous versions, These controls provide
Sever based events facility so that our application can be
develop more easily and attractive.
9. Web Services
Provides a mechanism for programs to communicate over
the Internet using SOAP (Simple Object Access Protocol).
Web Services provide an analog of Com and DCOM for
object brokering and interfacing, but based on internet
technologies so that allowance is made for integration,
even with non Microsoft plateforms
10. CLR (Common Language Runtime)
Common Type System
Data Types / etc
Intermediate Language to
Native Code Compiler
Execution Support Security
Garbage Collection
Memory Management(Previous version it was done by OS)
11. Multiple Language Support
.Net Environment Provides Multiple language Integration
Support, se that we can use multiple Languages in single
program.
For Example we can C# function in ASP.NET as well as in
VB.NET
Cross language Inheritance is also Possible
So Mix Language development team can also participate to
develop program.
How IT is Possible ? Answer CLR
12. Common Type System
All Languages use same Data types, their Length, Size, Type
and specificaton will be same.
For example in Previous VB-6 use 16 bit Integer (2 bytes)
In Visual C integer was 4 Bytes.
Now For all .NET Support languages use int32 Integer for 4
Bytes.
14. Execution Support
JIT (Just in Time Compilation and Execution)
JIT Compiles with three methods:
1) Standard JIT: it Convert to exe code at the time of
execution
2) Pre JIT: it it convert to exe code at the time of
installation.
3) Econo JIT: it create low Optimization code, for low
memory resources
20. Today’s Discussion
VS.NET (Visual Studio.net Environment)
Working With WinForms & important
Properties
Working With Events in .NET
Data Base Creation with MS-SQL Server
Database Handling with VS.NET
27. Import System.Data
Import System.data.ADO
Create and set SQLConnection
Create and set SQL DataAdapter
Create and set Dataset
28. Steps to Create & Set
SqlConnection
1. Place SqlConnection To Form (from Data
toolBox)
2. Set its name property to con1
3. Set its Connection Property using connection
Wizard
29. Steps to Create & Set DataAdapter
1. Put DataAdapter Control to form
2. Right click on That Control
3. Select Configure
4. Follow Steps to complete Process
5. Right Click on DataAdapter Control, and
select Create DATASET
30. Put Following Code on Form’s Load
Event
Private Sub Form1_Load(ByVal sender As System.Object,
ByVal e As System.EventArgs) Handles MyBase.Load
da1.Fill(ds1, "ghufi")
End Sub
32. Private Sub cmdLast_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)
Handles cmdLast.Click
cnt = Me.ds1.Tables("ghufi").Rows.Count
Me.BindingContext(ds1, "ghufi").Position = Me.BindingContext(ds1, "ghufi").Count - 1
MsgBox(cnt.ToString)
End Sub
Private Sub cmdNext_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles cmdNext.Click
Me.BindingContext(ds1, "ghufi").Position = Me.BindingContext(ds1, "ghufi").Position
+ 1
End Sub
33. Private Sub cmdPrev_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)
Handles cmdPrev.Click
Me.BindingContext(ds1, "ghufi").Position = Me.BindingContext(ds1, "ghufi").Position -
1
End Sub
Private Sub cmdFirst_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles cmdFirst.Click
Me.BindingContext(ds1, "ghufi").Position = 0
End Sub
34. Todays Discussion
Few Language Tips
How To search
Working wit DataGrid
Add Records
Save Records
35. Few Language Changes
Data Types
Declaration Methods
Type Casting
Option keyword
Changes in Array
41. Find Records
On Load
txtfind.Text = ds1.ghufi.Columns.Count()
ComboBox1.Items.Add(ds1.ghufi.Columns(0).ColumnName)
ComboBox1.Items.Add(ds1.ghufi.Columns(1).ColumnName)
ComboBox1.Items.Add(ds1.ghufi.Columns(2).ColumnName)
ComboBox1.Items.Add(ds1.ghufi.Columns(3).ColumnName)
42.
43. Write Following Code under Find
Dim fldname As String
fldname = ComboBox1.SelectedItem()
ds1.Clear()
da1.SelectCommand.CommandText =
"select * from ghufi where " & fldname & "='" & txtfind.Text & "'“
da1.Fill(ds1, "ghufi")
If Me.BindingContext(ds1, "ghufi").Count <= 0 Then
MsgBox("Sorry No Record for your Search")
End If
44. Today’s Discussion (03/11/2002)
New Control “Notify Icon”
How to Navigate B/W Forms
Inheritance in Forms
How User Master Details
Add / Save
45. NotifyIcon Control
Notify Icon is a new control which put a link on System
Tray, it automatically creates a new panel in system tray and
shows Icon.
It’s Click Event Fires when we double click on that Icon.
We may use it for new form load, or terminate Application.
46. Steps to use NotifyTray
Drag and drop this control on Form
Set it’s Icon Property with any suitable Icon
Write “End” to its click event
50. Its coding is
Public Class Form4
Inherits System.Windows.Forms.Form
Private Sub Form4_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles
MyBase.Load
End Sub
End Class
51. Change this coding as
Public Class Form4
Inherits System.amin.form3
Private Sub Form4_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles
MyBase.Load
End Sub
End Class
Set form4 as Default For and Run Program
72. Steps To Design Menu
There are two Types of Menues
– Main Menu
– Context Menu
73. Main Menu
This Menu Appear Normally on the Top of the form, this is very
common menu for windows base applications.
ie. File, Edit, View etc
Context Menu
This menu is Small Menu Which appears when user right click
on Any Form Item
74. Steps To Design Main Menu
Drag and drop main menu from Toolbox
Write Menu Name
Use & for Access Keys
Set Properties of every menu
– Name
– Shortcut
75. Steps Context Menu
Drag and drop Context menu from ToolBox
Design some menu items
Every Control has Context menu property, we
bind context menu property to context menu,
so that menu will appear when user right click
on that menu
78. Declarations
Public Class Form2
Inherits System.Windows.Forms.Form
Public con As OleDbConnection = New
OleDbConnection("Provider=Microsoft.jet.
oledb.4.0; data
source=d:LibrarySystemlibrary.mdb")
Public da As OleDbDataAdapter
Public ds As DataSet
Public dw As DataView
Public cm As CurrencyManager
79. Initializations (call two functions)
'Add any initialization after the
InitializeComponent() call
FillData()
bindFields()
80. FillData Function
Private Sub FillData()
dw = Nothing
ds = New DataSet()
con.Open()
da = New OleDbDataAdapter("select *
from books", con)
da.Fill(ds, "books")
dw = New DataView(ds.Tables("books"))
cm = CType(Me.BindingContext(dw),
CurrencyManager)
con.Close()
End Sub
81. DataBinding Function
Private Sub bindFields()
TextBox1.DataBindings.Clear()
TextBox2.DataBindings.Clear()
TextBox1.DataBindings.Add("text", dw, "code")
TextBox2.DataBindings.Add("text", dw, "Name")
End Sub
83. Save Button
Dim pos As Integer
pos = cm.Position
Dim cmd As New OleDbCommand()
cmd.Connection = con
cmd.CommandText = "Insert into books (code,
name, author) values(?,?,?)“
cmd.CommandType = CommandType.Text
con.Open()
93. Today’s Discussion (Dec 02, 2002)
Concept Of OOP
What is Class
Simple Class
Methods
Constructors
Properties
Data Base Handling With Class
94. What is OOP
OOP is Programming technique in which we make programs
Flexible and Reusable.
Basic Concept of OOP is Designing Classes in Program.
95. What is Class
Class is Collection of Data / Properties and
Methods/Functions which operate on that data.
Methods and Data are Encapsulated in Class, is
called Encapsulation
We may Inherit functionality of one class to other class is
called Inheritance.
With class one object may work with different ways is
called Polymorphism
96. A Simple Class
Write Click On Project add Class to your project
Public Class Person
Public FName As String
Public LName As String
Public Age As Integer
End Class
99. Code for Insert Data / Show Data
Buttons
p1.FName = TextBox1.Text
p1.LName = TextBox2.Text
p1.Age = CInt(TextBox3.Text)
TextBox1.Text = p1.FName
TextBox2.Text = p1.LName
TextBox3.Text = p1.Age
100. Encapsulation (Private Data and
Access public Methods)
Public Class Person
Private FName As String
Private LName As String
Private Age As Integer
'setdata Method
Public Sub setData(ByVal Fnm As String, ByVal LNm As
String, ByVal ag As Integer)
FName = Fnm
LName = LNm
Age = ag
End Sub
101. Public Function getFName() As String
Return (FName)
End Function
Public Function getLName() As String
Return (LName)
End Function
Public Function getAge() As Integer
Return (Age)
End Function
End Class
102. Constructor
Constructor is Special Type of method which call
automatically when object creates, we may use constructor
for data initialization.
Public Sub New()
FName = "FName Not Set"
LName = "LName Not Set"
Age = 0
End Sub
105. Code for Set Data Button
p(cntr) = New Person()
p(cntr).setData(TextBox1.Text,
TextBox2.Text, CInt(TextBox3.Text))
MsgBox("Data Stored as index number : " & CStr(cntr))
cntr += 1
106. Code for Show Data Button
Dim xx As Integer
xx = txtIndex.text
TextBox1.Text = p(xx).getFName()
TextBox2.Text = p(xx).getLName()
TextBox3.Text = p(xx).getAge()
107. Properties For Class
Property FName() As String
Get
Return (XFName)
End Get
Set(ByVal Value As String)
XFName = Value
End Set
End Property
108. Use Properties
dim t1 as new Teacher() ‘ teacher is class
t1.FName = TextBox1.Text
t1.LName = TextBox2.Text
t1.Age = TextBox3.Text
109. Data base Handling with class
Public Class DataClass
Public con As OleDbConnection
Public da As OleDbDataAdapter
Public ds As DataSet
Public dw As DataView
Public cm As CurrencyManager
110. Method Open Connection
Public Sub openConnection(ByVal constr As String)
con = New OleDbConnection(constr)
con.Open()
End Sub
‘’’’’’’’’’’’’’’’’’’’’’’’’’’’
Private Sub setDa(ByVal sqlstr As String, ByVal cn As
OleDbConnection)
da = New OleDbDataAdapter(sqlstr, cn)
End Sub
111. Public Sub FillData(ByVal sqlstr As String, ByVal dbnm As
String, ByVal tblnm As String)
dw = Nothing
ds = New DataSet()
OpenConnection("Provider=Microsoft.jet.oledb.4.0; data
source=f:Inventory_VBNETInventorySystem" & dbnm)
setDa(sqlstr, con)
da.Fill(ds, tblnm)
dw = New DataView(ds.Tables(tblnm))
con.Close()
End Sub
112. Move Records
Public Sub MoveRecord(ByVal bc As
BindingContext, ByVal tblnm As String,
ByVal symbol As String)
If symbol = ">" Then
bc(ds, tblnm).Position += 1
ElseIf symbol = "<" Then
bc(ds, tblnm).Position -= 1
ElseIf symbol = "<<" Then
bc(ds, tblnm).Position = 0
ElseIf symbol = ">>" Then
bc(ds, tblnm).Position = bc(ds, tblnm).Count – 1
End If
113. Usage
‘Create Object
Dim obj As New DataClass()
'Add any initialization after the
InitializeComponent() call
obj.FillData("select * from items", "Inventory.mdb",
"Items")
showData()
114. Private Sub showData()
Dim pos As Integer
pos = Me.BindingContext(obj.ds,
"items").Position
TextBox1.Text =
obj.ds.Tables("items").Rows(pos).Item("itemName")
End Sub
Show Data Method
115. Code For Next Button_Click
obj.MoveRecord(Me.BindingContext, "Items", ">")
showData()