dotnet manual

Upload: elakkiya-karthic

Post on 25-Feb-2018

258 views

Category:

Documents


1 download

TRANSCRIPT

  • 7/25/2019 DOTNET Manual

    1/126

    Dot net Training Manual

  • 7/25/2019 DOTNET Manual

    2/126

    INTRODUCTION TO .NET

    .NET Framework

    Microsoft introduced the .NET framework to help developers create

    globally distributed software with Internet functionality and interoperability.

    It is the foundation on which you design, develop and deploy applications.

    Its consistent and simplified programming model makes it easier to build

    robust applications.

    Console !".NET

    #eb !ervices #eb$orms

    !".Net pplications !ervices

    #indows $orms

    %rawing

    #indows pplication!ervices

    Controls

    .NET $ramework &ase Classes

    Confirguration Messaging Threading I' (lobali)ation Code %'M

    #in$orms !ecurity

    %iagnostics %ata *M+ eflection

    Common +anguage untime

    Multipleanguage

    ntegration

    CommonType !ystem

    %ebugging and"rofiling

    (arbageCollection

    -ersion and%eploymentControl

    !ecurity

    Console pplication !ervices

  • 7/25/2019 DOTNET Manual

    3/126

    Advantages of .NET Framework

    . Consistent "rogramming Model

    /. Multi platform applications

    0. Multi +anguage Integration

    1. utomatic resource management

    2. Ease of deployment

    .NET Initiative

    Microsoft has introduced the .NET initiative with the intention of

    bridge the gap in interoperability between applications. It aims at integrating

    various programming languages and services.

    It is designed to make significant improvements in code reuse, code

    speciali)ation, resource management, multi language development, security,

    deployment and administration.

    The .NET Initiative offers a complete suite for developing and

    deploying applications. This suite consists of .NET products, .NET services,

    and the .NET framework.

    .NET rodu!ts

    Microsoft has already introduced -isual !tudio .NET, which is

    a tool for developing .NET application by using programming languages

    such as -isual &asic, C3 and -isual C44. In addition, Microsoft also intends

    to introduce .NET versions of the #indows operating system and 'ffice

    suite. These products aim at allowing developers to create applications that

  • 7/25/2019 DOTNET Manual

    4/126

    are capable of interacting seamlessly with each other. To ensure interaction

    between different applications, all .NET products use e*tensible Markup

    +anguage 5*M+6 for describing and e7changing data between applications.

    -isual &asic.NET

    -isual C44.NET

    !".Net

    C3

    83

    *M+

    .NET servi!es

    .NET delivers software as #eb !ervices. Therefore, users can

    subscribe to a web service and use it as long as they need it, regardless of the

    hardware and software platform.

    Microsoft is coming up with its own set of web services, known as My

    !ervices. These services are based on the Microsoft "assport authentication

    service, the same service that us used in 9otmail. They allow the consumers

    of the services to access data by linking calendars, phonebooks, address

    books, and personal references to the "assport uthentication service. In

    addition to the #eb services provided by Microsoft, third party products and

    services can also be integrated easily with the .NET environment

  • 7/25/2019 DOTNET Manual

    5/126

    Managed Code E"e!ution ro!ess

    . #hen you compile a program developed in a language that targets the

    C+, instead of compiling the sourcecode into machine level code, the

    compiler translates into Microsoft Intermediate +anguage 5M!I+6 or

    Intermediate +anguage 5I+6. No matter which language has been used to

    develop the applications, it always gets translated into I+. This ensures

    language Interperability.

    /. In addition to translating the code into I+, the compiler also produces

    metadata about the program during the process of compilation. Metadata

    contains the description of the program, such as the classes and interfaces,

    the dependencies and the versions of the components used inthe program.

    0. The I+, and the meta data are linked in assembly

    1. The compiler creates the .E*E or .%++ file

    2. #hen you e7ecute the .E*E or .%++ file, the code 5converted into I+6 and

    all the other relevant information from the base class library is sent to the

    class loader. The class loader loads the code inthe memory.

    :. before the code can be e7ecuted, the .NET framework needs to convert

    the I+ into native or C"; specific code. The 8ust In Time 58IT6 compiler

    translates the code from I+ into managed process of compilation, the 8IT

    compiler compiles only the code the code that is re

  • 7/25/2019 DOTNET Manual

    6/126

    invoked during e7ecution, the 8IT compiler converts the I+ for that method

    into native code. This process saves the time and memory reects are always accessed in a compatible way.

    Therefore, if you try to pass an ? byte value to a method that acceps 1 byte

    value as its parameter, the C+ will detect and trap such an attempt. Type

    safety also ensures that ob>ects are safely isolated from each other and are

    therefore same from any inadvertent or malicious corruption

    ?. fter translating the I+ into native code the converted code is sent to

    the .NET runtime manager.

    @. The .NET runtime manager e7ecutes the code. while e7ecuting the code, a

    security check is performed to ensure that the code has the appropriate

    permissions for accessing the available resources.

    ;nicode characters A / &ytes

    Features rovided C#R

    . utomatic memory management

    /. !tandard type system

    0. +anguage Interperability

    1. "latform Independence

    2. !ecurity Management

    :. Type safety

  • 7/25/2019 DOTNET Manual

    7/126

    A$.NET

    !"0.B and !"1.B

    ctive !erver "ages A !erver side scripting

    9TM+ A %esigning

    -&!cript, 8ava!cript, 8!cript A Client !ide -alidation

    !imple -alidation

    D "assword does not e7ceed ? characters

    D "assword and etype "assword must be similar

    D Checking for valid date

    D Email validation

    !erver !ide -alidation A !",8!", !ervlets

    Maintaining %atabase

    !ession Maintenance A Individual user details.

    !".NET A !erver !ide -alidations

    Integrated %evelopment Environment

    #eb !erver A Checking !erver !ide !cripting

    Internet Information !ervice 2.B 5#indows /BBB6

    II! :.B 5#indows *"6

    "ersonal #eb !erver 5#indows @2, #indows @?6

    Chilli!oft A #indows NT

  • 7/25/2019 DOTNET Manual

    8/126

    Microsoft !".NET is the ne7t generation technology for #eb

    application development. It takes the best from ctive !erver "ages 5!"6

    as well as the rich services and features provided by the Common +anguage

    untime 5C+6 and add many new features. The result is a robust, scalable,

    and fast #eb development e7perience that will give you great fle7ibility

    with little coding. To create dynamic web pages by using server side scripts,

    Microsoft has introduced !". !".NET is the .NET version of !".

    !".NET is a standard 9TM+ file that contains embedded serverAside

    scripts. !".NET provides the following advantages of server A side

    scripting.

    !".NET enables you to access information from data sources, such

    as backAend databases and te7t files that are stored on a #eb server or

    a computer thatFs accessible to a #eb server.

    !".NET enable us to use a set of programming code called templates

    to create 9TM+ documents. The advantage of using templates is that

    you can dynamically insert content retrieved from data sources, such

    as backAend database and te7t files, into 9TM+ document before the

    9TM+ document is displayed to users. Therefore, the information

    need not be changed manually as and when the contents retrieved

    from data source changed.

  • 7/25/2019 DOTNET Manual

    9/126

    !".NET also enable us to separate 9TM+ design from the data

    retrieval mechanism. Therefore, changing the 9TM+ design does not

    affect the programs that retrieve data from the databases. !imilarly,

    server side scripting ensures that changing data sources does not

    re

  • 7/25/2019 DOTNET Manual

    10/126

    %orking of an A$.NET a&&li!ation

    . web server sends a re

  • 7/25/2019 DOTNET Manual

    11/126

    Enriched Tool !upport G The !".NET $ramework provided with a

    rich toolbo7 and designer in -!.NET I%E 5-isual !tudio .NET

    integrated development environment6. !ome of the features of this

    powerful tools are the #H!I#H( 5#hat Hou !ee Is #hat Hou (et6

    editor, drag and drop server controls, and automatic deployment.

    "ower and $le7ibility G !".NET applications are based on Common

    +anguage untime 5C+6. Therefore, the power and fle7ibility of

    the .NET platform is available to !".NET application developers.

    !".NET applications enable you to ensure that the .NET $ramework

    class library, messaging, and data access solutions are seamlesslyaccessible over the #eb. !".NET is also language G independent.

    Therefore, Hou can choose any .NET language to develop your

    application.

    !implicity G !".NET enables you to build user interfaces that

    separate application logic from presentation content. In addition, C+

    simplifies application development by using managed code services,

    such as automatic reference counting and garbage collection.

    Therefore, !".NET makes it easy to perform common tasks ranging

    from form submission and client authentication to site configuration

    and deployment.

    Manageability G !".NET enables you to manage #eb applications

    by storing the configuration information in an *M+ file. Hou can open

    the *M+ file in the -isual !tudio .NET I%E.

    !calability G !".NET has been designed with scalability in mind. It

    has features that help improve performance in a multiprocessor

    environment.

  • 7/25/2019 DOTNET Manual

    12/126

    !ecurity G !".NET provides a number of options for implementing

    security and restricting user access to a #eb application. ll these

    options are configured within the configuration file.

    A$.NET $erver a&&li!ations are

    II! A Internet Information !erver 2.B 5Microsoft Networking6 A

    #indows NT1.B, #indows /BBB

    "#! A "ersonal #eb !erver 5"CF!6 A #indow @2,#indows @?

    Chilli!oft A #indows NT

    pache Tomcat A #indows NT, #indows /BBB

    &y using any one of the above mentioned servers, we can perform

    !".NET "age validations. If there is a !erver, we have to start the server.

    &ut !".NET !ervers 5both II! and "#!6 can automatically start and run

    when the system switched on.

    Introdu!ing %e' A&&li!ations

    #eb pplications are programs that can be e7ecuted either on a #eb

    server 5In case of server side scripting6 or in a #eb browser 5in case of client

    A side scripting6. They enable us to share and access information over the

    internet and corporate intranets.

  • 7/25/2019 DOTNET Manual

    13/126

    Com&onents of D(nami! %e' A&&li!ations

    dynamic web application can have client A side scripting, server A

    side scripting or both.

    Client side scripting enable us to develop web pages that can

    dynamically respond to user input without having interact with a #eb server.

    !cripting +anguages, such as -&!cript and 8ava!cript, are used to write

    client side scripts.

    !erver side scripting provides dynamic content to users base on the

    information stored in a remote location, such as a back A end database. It

    incudes code written in server A side scripting languages, such as ctive

    !erver "ages 5!"6 and 8ava !erver "ages 58!"6. serverAside script is

    e7ecuted on a web server. #hen a browser re

  • 7/25/2019 DOTNET Manual

    14/126

    %E) FORM$

    #eb $orms are the heart and soul of !".NET. #eb $orms

    are the ;ser Interface 5;I6 elements that give your #eb applications their

    look and feel. #eb $orms are similar to #indows $orms in that they provide

    properties, methods, and events for the controls that are placed onto them.

    9owever, these ;I elements render themselves in the appropriate markup

    language re

  • 7/25/2019 DOTNET Manual

    15/126

    T*e ur&ose of %e' Forms

    #eb $orms and !".NET were created to overcome some of the limitations

    of !". These new strengths include

    !eparation of 9TM+ interface from application logic

    rich set of serverAside controls that can detect the browser and send

    out appropriate markup language such as 9TM+

    +ess code to write due to the data binding capabilities of the newserverAside .NET controls

    EventAbased programming model that is familiar to Microsoft -isual

    &asic programmers

    Compiled code and support for multiple languages, as opposed to !"

    which was interpreted as Microsoft -isual &asic !cripting 5-&!cript6

    or Microsoft 8script

    #eb $orms enable us to create user interface for #eb pplications. #e use

    user controls to design the user interface of #eb pplications and then write

    code, which will be e7ecuted at the server side, to handle events triggered by

    these controls.

    %E) $ER+ICE$,

    #eb !ervices enable us to remotely access certain functionality at the server

    side. These services enable the e7change of data in a client G to G server or a

  • 7/25/2019 DOTNET Manual

    16/126

    server G to G server environment over the web by using !imple 'b>ect

    ccess "rotocol 5!'"6. To enable this data e7change, #eb services use

    standards such as 9TT" and e*tensible Markup +anguage 5*M+6

    messaging.

    Advantages

    #eb $orms can be designed and programmed using apid

    pplication %evelopment 5%6 tools.

    #eb $orms support a rich set of controls, including user

    defined and third party controls and make the application userfriendly.

    #eb $orms can be programmed using any of the .NET

    $ramework languages, such as C3 or -isual &asic .NET

    In !".NET #eb $orms consists of a user interface and application

    logic that is applied to the components of user interfaces.

    ;ser interface consists of static 9TM+ or *M+ elements, and

    !".NET server controls. #hen we create a #eb pplication, 9TM+ or

    *M+ elements and server controls are saved in a file with a .asp7 e7tension.

    This file is called a pagefile.

    pplication logic consists of code that is applied to the user interface

    elements of a #eb $orm page. #e can use any of the .NET programming

    languages, such as -isual &asic .NET or C3, to write the logic for a web

    page.

  • 7/25/2019 DOTNET Manual

    17/126

  • 7/25/2019 DOTNET Manual

    18/126

    Note,

    #e can also write the application logic for an !".NET application by

    using other .NET $ramework compatible languages, ranging from

    8script.NET, Managed E7tensions to C44, "ython, !mallTalk, and C'&'+.

    9owever, it is important to remember that we cannot include a -isual C3

    #eb $orms "age in a -isual &asic .NET #eb "ro>ect and vice versa.

    Introdu!ing %e' A&&li!ations,

    #eb pplications are programs that can be e7ecuted either on a #eb

    server 5In case of server side scripting6 or in a #eb browser 5in case of client

    A side scripting6. They enable us to share and access information over the

    internet and corporate intranets.

    Com&onents of D(nami! %e' A&&li!ations

    dynamic web application can have client A side scripting, server A

    side scripting or both.

    Client side scripting enable us to develop web pages that can

    dynamically respond to user input without having interact with a #eb server.

    !cripting +anguages, such as -&!cript and 8ava!cript, are used to write

    client side scripts.

    !erver side scripting provides dynamic content to users base on the

    information stored in a remote location, such as a back A end database. It

    incudes code written in server A side scripting languages, such as ctive

  • 7/25/2019 DOTNET Manual

    19/126

    !erver "ages 5!"6 and 8ava !erver "ages 58!"6. serverAside script is

    e7ecuted on a web server. #hen a browser re

  • 7/25/2019 DOTNET Manual

    20/126

    The #eb page with the processed output is sent back by the

    #eb !erver.

    In !".NET, each sever control is an instance of a particular class. $or

    e7ample, when you add a button control to a #eb page, we actually create

    an instance of the &utton Class. The base class of all server controls is the

    Control class that resides in the !ystem.#eb.;I namespace. The hierarchy

    of the server controls in !".NET

    Four t(&es of Controls,

    . !erver Controlsdotator%ata(rid Control%ata+ist Control

    /. -alidation ControlsCompare-alidator

    Custom-alidatorange-alidatoregularE7pression-alidatore

  • 7/25/2019 DOTNET Manual

    21/126

    A$.NET O'e!ts

    esponse A ;sed to send information to the client. 5!erver to

    &rowser6

    e

  • 7/25/2019 DOTNET Manual

    22/126

    esponse.dd9eader Method

    esponse.edirect Method

    esponse.!tatus "roperty

    esponse.End Method

    esponse.$lush Method

    esponse.#rite Method;sed to write data to client

    esponse.#rite5JKh alignLcenter 9ello #orld Kh6O

    esponse.Cookies Collection

    !torage of values temporarily. Peeping a variable values between the

    pages. !toring values between the pages is called maintaing state.

    esponse.CookiesQJvariableR .value L value

    esponse.dd9eader Method

    ;sed to add some 9eader values in the 9TT" 9eader

    Eg

    "ageS+oad56

    esponse.dd9eader5efresh,2OurlLredipage.asp76O

    esponse.#rite5This page has been redirected after Kspan idLF>timeF 2

    Kspan seconds6O

    Kscript languageLvbscript

    window.setTimeout changeval56,BBB,vbscript

    sub changeval56

  • 7/25/2019 DOTNET Manual

    23/126

    dim time

    time L document.all.item5>time6.innerTe7t

    time L time A

    document.all.item5>time6.innerTe7t L time

    if time B then

    window.setTimeout changeval56,BBB,vbscript

    End if

    End !ub

    Kscript

    esponse.edirect Method

    ;sed to redirect another file

    esponse.edirect5Jfilename.asp76O

    +ink&uttonSclickU

    esponse.edirect5httplocalhostMyspCookieMgmtInbo7.asp76OV

    esponse.!tatus "roperty

    Eg

    "ageS+oad56

    string ipaddrOipaddr L e

  • 7/25/2019 DOTNET Manual

    24/126

    esponse.!tatusL1B0 ccess $orbiddenO

    esponse.#rite5esponse.!tatus6O

    esponse.End56O

    V

    esponse.#rite5K9TM+6O

    esponse.#rite5K&'%HHou have accessed this page through the

    I" ddress of /=.B.B. K&'%H K9TM+6O

    Re/uest O'e!t

    The reect contains the information that the browser sends to

    the server. $or every re

  • 7/25/2019 DOTNET Manual

    25/126

    Re/uest.$erver+aria'les Colle!tion

    This contains standard information automatically sent by the browser

    for every re

  • 7/25/2019 DOTNET Manual

    26/126

    esponse.#rite5+ocal ddr 4

    e

  • 7/25/2019 DOTNET Manual

    27/126

    Codings

    ;sing !ystem.%ata.!

  • 7/25/2019 DOTNET Manual

    28/126

    !odings

    +ink&uttonSclick

    U

    esponse.edirect5httplocalhostMyspCookieMgmtInbo7.asp6O

    V

    +ink&utton/SClick

    U

    esponse.edirect5httplocalhostMyspCookieMgmtComp.asp76O

    V

    In'o".as&"

    "ageS+oad

    U

    esponse.#rite5Kh alignLcenter Inbo7 Kh6O

    esponse.#rite5;sername 4 e

  • 7/25/2019 DOTNET Manual

    29/126

    A&&li!ation O'e!t

    To store global data.

    pplication ob>ect provide our application with global data or

    information that applies to all users for our application.

    There is only one pplication ob>ect for all users of your pplication.

    Introdu!tion to T*reads

    #eb !ervers must handle simultaneous reect, but you need to ensure

    that only one session has permission to change values at any given time. To

    do that, Hou lock the pplication before changing the value and unlock it

    when you finished your modifications.

  • 7/25/2019 DOTNET Manual

    30/126

    Eg,

    global.asa7.cs

    pplicationS!tart56

    U

    pplicationQpageR L BO

    V

    %e'Form1.as&".!s

    esponse.dd9eader5efresh,26O

    int pagecountO

    pplication.+ock56O

    pplicationQpageR L Int0/."arse5pplicationQpageR.To!tring566 4 O

    pagecount L Int0/."arse5pplicationQpageR.To!tring566O

    pplication.;n+ock56O

    esponse.#rite5This page has been visited 4 pagecount 4 times6O

    $erver O'e!t

    This 'b>ect gives highAlevel access to the !erver.

    ;sing this properties and Methods we can

    . E7ecute other !" $iles

    /. Translate -irtual path to "hysical path

    0. "erform !erverA!ide edirects

    !erver.!criptTimeout "roperty

    !erver.9tmlEncode Method

    !erver.E7ecute Method

    !erver.Transfer Method

    !erver.Map"ath Method

  • 7/25/2019 DOTNET Manual

    31/126

    !erver.!criptTime'ut "roperty

    !pecifies the amount of runtime in seconds for a script before it

    terminates.

    esponse.#rite5%efault Timeout 4 !erver.!criptTimeout 4

    JKbr6O

    !erver.!criptTimeout L 2BO

    esponse.#rite5fter Changed 4 server.!criptTimeout6O

    !erver.9tmlEncode Method

    esponse.#rite5!erver.9tmlEncode5Khtml66O

    !erver.Map"ath Method

    This will map the "hysical path of the file.

    string physicalpp"athO

    physicalpp"ath L !erver.Map"ath5myasp6O

    esponse.#rite5The "hysical path is 4 physicalpp"ath 4 Kbr6O

    $ession O'e!t

    n !".NET !essions begins at a browserFs $irst re

  • 7/25/2019 DOTNET Manual

    32/126

    2lo'al.asa"

    pplication on!tart

    pplication onEnd

    !ession on!tart

    !ession onEnd

    $essionID Cookie

    The server gives the browser a uni

  • 7/25/2019 DOTNET Manual

    33/126

    1. Immediately after creates the new !ession ob>ect, !".NET Calls

    the !essionS'n!tart Event

    2. #hen the session times out or you issues the !ession.bandon

    command, the !".NET engine calls the !essionSonEnd event procedure.,

    then destroys the !ession 'b>ect

    :. fter the !" engine destroys the last session ob>ect, it calls the

    pplicationS'nEnd event procedure

    $ession.A'andon E"am&le

    glo'al.asa".!s

    pplication S!tart56

    U

    pplicationQcounterR L B

    V

    !essionS!tart56

    U

    pplicationQcounterR L

    Int0/.parse5pplicationQcounterR.To!tring566 4

    V

  • 7/25/2019 DOTNET Manual

    34/126

    %e'Form1.as&".!s

    esponse.#rite5Kh alignLcenter !ession bandon E7ample Kh6O

    esponse.#rite5Hour !ession I% is 4 !ession.!essionI% 4 Kbr6O

    esponse.#rite5pplicationQcounterR 4 pplicationQcounterR6O

    !ession.bandon56O

    esponse.#rite5Kp Hour session has been abandoned. Make a note of

    your !essionI%,then referesh your browser. Each time you referesh this

    page, you should get a new !essionI%.Kp6O

    %istributed Computing

    D Improve "erformance

    D Components are compiled separately A &usiness +ogic

    D Code eusability

    %istributed Technology

    . !ockets

    /. "C A emote "rocedure call

    0. MI

    1. C'&

    2. %C'M

    !ockets A &erkely !oftware %ivision

    Client !erver Technology model

    A Networking 5Chatting, $ile Transfering, %ata transferring6

    !ocket A Establish connection

    "acket A %ata Container 5byte %ata,si)e of data, destination I"

    ddress6

  • 7/25/2019 DOTNET Manual

    35/126

    Issues

    D !upports only primitive type5data types like integer, float, char6

    communication

    D Image, ob>ect and method invocation is not possible

    D %oesnFt have auto marshalling and demarshalling

    Marshalling A Convert 'b>ect to byte

    %emarshalling A Convert byte to ob>ect

    !erver Client

    +isten

    ccept

    !end

    eceive

    Connect

    eceive

    !end

  • 7/25/2019 DOTNET Manual

    36/126

    "C A emote "rocedure Call

    D "C is a layer

    D 'ne more layer in '!I model.

    D It supports Method invocation

    D The data are send and received as a string format

    D It doesnFt support ob>ect transfer.

    MIC'&%C'M

    D Enhancement of "C

    D 'b>ect transfer is possible.

    MI A emote Method Invocation

    D +anguage %ependent

    D "latform Independent

    D Communication between two ob>ects.

    D The two ob>ects must be developed in 8ava

    D !upports all type of communication

    DMI egistry

    8N%I A 8ava Naming and %irectory Inde7

    8M" A 8ava emote Method "rotocol

    Client 8ava !erver 8ava

    !tub !keleton

    Network

    MI egistry

  • 7/25/2019 DOTNET Manual

    37/126

    C'& A Common 'b>ect e

  • 7/25/2019 DOTNET Manual

    38/126

    %e' $ervi!es

    $OAA !imple 'b>ect access "rotocol

    D %eveloped by #0Consortium

    D &ased on *M+

    D Instead of C'M %C'M webservices are developed.

    3M#

    E7tensible Markup +anguage

    Meaning for content

    3$# A E7tensible !tyle sheet +anguage 5*M+ with C!! 5Cascading

    !tyle !heet66

    Eg

    %ocument 'b>ect Model 5%'M6

    "arsing *M+ document to -& or any other application

    D$OA %ata !ource 'b>ect 58avascript, -&!cript6

    7ml1>parser A 8ava

    Creating %e' $ervi!e

    . $ile A New A -isual &asic .NET A !".NET #eb !ervice A

    httplocalhostMysp!ervice

    /. Click the like !witch to code view

    0. dd Methods

  • 7/25/2019 DOTNET Manual

    39/126

    K#ebMethod "ublic $unction add5&y-al a as Integer,&y-al b as

    Integer6 as Integer

    eturn a 4 b

    End $unction

    K#ebMethod "ublic $unction add5&y-al a as Integer,&y-al b as

    Integer6 as Integer

    eturn a D b

    End $unction

    1. un the pplication by "ressing $2

    2. Copy the ;+ and "aste it in the notepad

    :. Close the !olution

    Adding %e' servi!e in C4

    . $ile A New A -isual C3 A Console application

    #eb!ervice

    /. "ro>ect Menu A dd #eb eference A "aste the ;+ A Click

    dd eference

    0. dd the following Codings

    static void Main5stringQR args6

    U

    localhost.!ervice ob> L new localhost.!ervice56O

    string str L ob>.9ello#orld56O

    Console.#rite+ine5str6O

  • 7/25/2019 DOTNET Manual

    40/126

    int c L ob>.add5B,/B6O

    int d L ob>.mul50,16O

    Console.#rite+ine5c L 4 c6O

    Console.#rite+ine5d L 4 d6O

    Console.ead+ine56O

    V

    Creating %e' $ervi!e

    . $ile A New A -isual &asic .NET A !".NET #eb !ervice A

    httplocalhostMysp!ervice

    /. Click the like !witch to code view

    0. dd Methods

    K#ebMethod56 "ublic $unction get%ata5&y-al pid s

    Integer6 s "roduct

    Try

    %im con s !

  • 7/25/2019 DOTNET Manual

    41/126

    If 5dr.ead566 Then

    pr.pid L dr.(etInt0/5B6

    pr.pname L dr.(et!tring56

    pr.

  • 7/25/2019 DOTNET Manual

    42/126

    3M#,

    dotator

    &anner.7ml

    AAAAAAAAAAAAAAA

    KZ7ml versionL.B encodingLutfA? Z

    Kdvertisements

    Kd

    KImage;rl httplocalhostshobadComponentseSB.gif KImage;rl

    KNavigate;rl httplocalhostshobaC!C#eb$orm.asp7 KNavigate;rl

    KlternateTe7t The 'rder 'nline $orm for #ebshoppe KlternateTe7tKImpressions KImpressions

    Kd

    Kd KImage;rl httplocalhostshobadComponent$lowers.gif

    KImage;rl

    KNavigate;rl httplocalhostshobaC!Cegistration.asp7

    KNavigate;rl

    KlternateTe7t This page is used for egistration KlternateTe7t

    KImpressions / KImpressions

    Kd

    Kdvertisements

  • 7/25/2019 DOTNET Manual

    43/126

    +).NET

    T(&es of A&&li!ation Ar!*ite!ture

    pplications are developed to support organi)ations in their business

    operations. pplication accept input, process the data based on business

    rules and provide data as output. The function performed by an application

    can be divided into three categories

    ;ser services

    &usiness services

    Each category is implemented as a layer in an application. The user

    services layer constitutes the front end of a solution. It is also called a

    presentation layer because it provides an interactive user interface

    The business services layer controls the enforcement of business rules

    on the data of an organi)ation. &usiness rules encompass those practices and

    activities that define the behavior of an organi)ation. The business services

    layer performs validations pertaining to business rules.

    The data services layer comprises the data and the functions for

    manipulating the data.

    A&&li!ation Ar!*ite!ture

    . !ingle Tier rchitecture A &ased on !ingle !oftware

    /. Two Tier rchitecture

    0. Three Tier rchitecture

  • 7/25/2019 DOTNET Manual

    44/126

    1. nATier rchitecture 59TM+ A -&!cript A !" A 'racle A

    *M+6

    M-C rchitecture

    Model -iew Controller rchitecture

    Model A &usiness +ogic A E8& A C'M4 5Component 'b>ect

    Model6

    -iew A 'utput A 8!" A !".NET 5or6 -&.Net

    Controller A Controlling "ages. A !".Net

    +isual )asi! .NET

    D !upports 'b>ect 'riented "rogramming full fledgely.

    D !upports !tructured E7ception 9andling

    D !upports Multithreaded "rogramming

    Features of .NET

    . Inheritance

    /. Constructor and %estructor

    0. 'verloading

    1. 'verriding

    2. !tructured E7ception 9andling

    :. Multithreading

    MultiThreading AI' "ackages

    Networkingssembly A %eployment purpose(arbage Collection A!ecurity

  • 7/25/2019 DOTNET Manual

    45/126

    Names&a!e

    Collection of classes and Interfaces are packed.

    In*eritan!e

    Inheritance is the ability of a class to derive its characteristics from an

    e7isting class

    $(nta",

    class base!tatements

    End classclass %erivedClass Inherits "arentClass

    ...........End Class

    It is possible to create a base class in any language and inherits its

    properties in a derived

    class created using another language. It provides the advantage of code

    reusability across languages.

    Constru!tors and Destru!tors

    Constructor A ;sed to initiali)e the members of the class%estructor A eleases the resources used by an ob>ect

    Overloadingfunction nane similar passing parameters are different

    $(nta",

    $unction 'verloads functionSname5parameter list6 as returntype

  • 7/25/2019 DOTNET Manual

    46/126

    Overriding

    class baseU

    virtual public void show56Opublic void fun56O

    V

    class derived publicbaseU

    public void show56Opublic void fun56O

    Vderived dO

    base bObase DbOb L YdObAshow56ObAfun56O

    $(nta",

    "ublic 'verrides $unction func56

    $tru!tured E"!e&tion -andling

    -&.Net !upports structured e7ception handling that consists of

    protected blocks of code and filters for the possible e7ceptions that can be

    raised by the program.

    tryU

    CodingsVcatch5E7ception6U

    E7ception 9andling codeV

  • 7/25/2019 DOTNET Manual

    47/126

    Multit*reading

    Multithreading enables an application contain one or more threads

    that can share workload in an application by e7ecuting one at a time.

    +isual $tudio .NET IDE

    1. roe!ts and $olutions

    "ro>ectsA Contains $orms and modules.

    !olutions A Contains one or more pro>ects.

    roe!t T(&es

    . -isual &asic "ro>ects

    /. -isual C3

    0. -isual C44

    1. !etup and %eployment pplication

    Tem&lates

    #indows pplication A !tand alone windows application

    Class +ibrary A Create reusable class library

    #indows Control +ibrary A Custom Control creation

    !".NET #eb pplication A Create #eb pplication

    !".NET #eb !ervice A 9TT" and *M+ to communicate with

    client applications.

    #eb Control +ibrary A Custom control used in web application

    Console application A create console application run in command

    line

  • 7/25/2019 DOTNET Manual

    48/126

    #indows !ervice A &ackground service such as monitoring

    Empty "ro>ect

    Empty #eb "ro>ect

    New "ro>ect in E7isting $older A dding E7isting files.

    User Interfa!e Elements of +isual $tudio .NET IDE

    . #indows $orm %esigner

    /. !olution E7plorer #indow

    0. "roperties #indow

    1. Toolbo7

    2. 'utput window

    :. The task list window

    =. !erver E7plorer window

    ?. %ynamic 9elp window

    @. Class view window

    B. Code and Te7t editor window

    O'e!t Orientation in +isual )asi!.NET

    OO$ 56 O'e!t oriented &rogramming s(stem

    . Classes and 'b>ect

    /. %ata bstraction and Encapsulation

    0. Inheritance

    1. "olymorphism

    2. 'verloading

  • 7/25/2019 DOTNET Manual

    49/126

    rrays A Collection of like datatypes.

    $tru!ture

    Collection of unlike variables, methods and constructors.

    $(nta",

    !tructure strucSname

    accessSspecifier varSname as %atatype F-ariables

    accessSspecifier !ub procSname5&y-al var as %atatype6 F!ub

    "rocedure

    !tatement

    End !ub

    accessSspecifier function funcSname5&y-al var as %atatype6 as

    %ataType

    return varSname

    End function

    !ub New56 FConstructor

    !tatements

    End sub

    .........

    End !tructure

    Eg,

    !tructure Emp

    %im Eno as Integer

    "ublic Ename as !tring

    "ublic !alary as !ingle

  • 7/25/2019 DOTNET Manual

    50/126

    "ublic !ub %isplayEmp56

    Msgbo7 Empno Y eno

    Msgbo7 Empname Y ename

    Msgbo7 !alary Y salary

    end sub

    End !tructure

    A!!ess7$&e!ifier

    u'li!A structure declared with the "ublic keyword is accessible from

    anywhere within or outside the application. This is the default access mode.

    rote!tedA structure declared with the "rotected keyword is accessible

    only from within its own class or from a derived class

    Friend A structure declared with the $riend keyword is accessible

    from within the program that contains the declaration and from anywhere

    else in the same program

    rote!ted FriendA structure declared with the "rotected $riend keyword

    is accessible from within the same assembly and in the derived class.

    rivateA structure declared with the "rivate Peyword is accessible only

    from within its declaration conte7t, including any nested procedures.

    8$tati!9$*ared +aria'les.

    D Initiali)ed with )ero when the first ob>ect is created. No other

    initiali)ation is permitted.

  • 7/25/2019 DOTNET Manual

    51/126

    D 'nly one copy of the member is created and shared by all ob>ects.

    D #ithout creating ob>ect the member can be accessed by using

    structure name.

    $*ared Met*ods

    D It access only shared variables.

    D #ithout creating ob>ect the method can be accessed by using

    structure name.

    Eg,

    !tructure !tudent

    sno as Integer

    sname as !tring

    shared count as integer

    End !tructure

    %im s5B6 as !tudent

    In!luding ro!edure

    !tructure orderSdetails

    "ublic InvSno as !tring

    "ublic 'rdSdt as %ate

    "ublic CustName as !tring

    "ublic "roduct as !tring

    "ublic Cost as %ouble

    "ublic dvanceSamt as %ouble

    "ublic %ueSamt as %ouble

  • 7/25/2019 DOTNET Manual

    52/126

    "ublic !ub CheckCost 5&y-al Cost as %ouble6

    if Cost K B then

    Cost L B

    End If

    End !ub

    !hared count as Integer

    End !tructure

    $toring data wit*in a $tru!ture

    %im ord as orderSdetails

    ord.count L ord.count 4

    %im ord/ as orderSdetails

    ord/.count L ord/.count 4

    ord.InvSno L IBBB

    ord.'rdSdt L 3B0@?B3

    ord.CustName L 8ack

    ord."roduct L &C

    ord.Cost L 12B.BB

    ord.dvanceSamt L /BB.BB

    ord.%ueSamt L /2B.BB

    A!!essing Data from a stru!ture

    if ord.InvSno L then

    Msgbo75"lease enter the invoice number6

    End if

  • 7/25/2019 DOTNET Manual

    53/126

    Eg,

    !tructure Emp

    %im eno s Integer

    %im ename s !tring

    %im salary s Integer

    !hared count s Integer

    !ub getEmp56

    eno L Integer."arse5Input&o75Enter Eno66

    ename L Input&o75Enter empname6

    salary L Integer."arse5Input&o75Enter !alary66

    count L count 4

    End !ub

    !ub displayemp56

    Msg&o75Empno Y eno6

    Msg&o75Empname Y ename6

    Msg&o75!alary Y salary6

    End !ub

    !hared !ub displayCount56

    Msg&o75No of 'b>ects Created is Y count6

    End !ub

    !ub New5&y-al no s Integer, &y-al name s !tring, &y-al sal s

    Integer6

    eno L no

    ename L name

    salary L sal

    count L count 4

  • 7/25/2019 DOTNET Manual

    54/126

    End !ub

    End !tructure

    "rivate !ub &uttonSClick5&y-al sender s !ystem.'b>ect, &y-al e s

    !ystem.Eventrgs6 9andles &utton.Click

    %im e5B6 s Emp

    %im e/ s Emp L New Emp5BBB, Pirthika, /BBB6

    e/.displayemp56

    %im n, i s Integer

    n L Integer."arse5Input&o75Enter how many employees66

    $or i L B To n A

    e5i6.getEmp56

    Ne7t

    $or i L B To n A

    e5i6.displayemp56

    Ne7t

    Emp.displayCount56

    End !ub

    End Class

    Classes +s $tru!tures

    Collection of member variables and methods

    $imilarities

    D &oth can have members, including constructors, properties and

    constants.

    D &oth can implement Interfaces 5!et of incomplete methods6

  • 7/25/2019 DOTNET Manual

    55/126

    D &oth can have shared constructors with parameters

    $*ared :e(word

    In a class or a structure, the !hared Peyword indicates that one

    or more programming elements are shared. The !hared programming

    elements are not associated with a specific instance of a class or structure. To

    access a shared element, we need to

  • 7/25/2019 DOTNET Manual

    56/126

    A'stra!t Class

    !et of complete and Incomplete methods. the derived class can

    implement the methods. In -&.Net the abstract class is created using

    MustInherit keyword in the class definition.

    Eg,

    "ublic class $orm Inherits !ystem.#indows.$orms.$orm

    %im emp as New EmpS%etails56

    "rivate !ub &uttonSClick5&y-al sender as !ystem.'b>ect,

    &y-al e as !ystem.Eventrgs6 9andles &utton.Click

    emp.nnualS!alary5Te7t&o7.Te7t6

    emp.disp56

    End !ub

    End Class

    "ublic MustInherit Class Employee%etails

    "ublic Must'verride !ub nnualS!alary5&y-al m s Integer6

    "ublic !ub disp56

    Msg&o75!ample Method6

    End !ub

    End Class

    "ublic Class EmpS%etails

    Inherits Employee%etails

  • 7/25/2019 DOTNET Manual

    57/126

    %im salary as Integer L 0BBBB

    %im months as Integer L :

    "ublic 'verrides !ub nnualS!alary5&y-al m as Integer6

    salary L salary D m

    Msgbo75The Total salary is Y salary6

    salary L 0BBBB

    End sub

    End Class

    Eg,

    "ublic MustInherit Class MybstractClass

    "ublic Must'verride !ub display5&y-al a s Integer6

    "ublic !ub Mybstractsub56

    Msg&o75bstract Class method6

    End !ub

    End Class

    "ublic Class %erivedClass

    Inherits MybstractClass

    "ublic 'verrides !ub display5&y-al a s Integer6

    Msg&o75The value of a L Y a6

    End !ub

    End Class

    "ublic Class %erivedClass

  • 7/25/2019 DOTNET Manual

    58/126

    Inherits MybstractClass

    "ublic 'verrides !ub display5&y-al a s Integer6

    Msg&o75!

  • 7/25/2019 DOTNET Manual

    59/126

    !et of incomplete methods. lternate for Multiple Inheritance

    $(nta",

    Interface IfaceSname

    ....

    End Interface

    Eg,

    Interface I'rder%etails

    "roperty CustName56 s !tring

    !ub ;pdateCust!tatus56

    $unction Calculate5&y-al m as integer6 as Integer

    Event ;pdateSComplete56

    End Interface

    Eg,

    Interface 'rder%etails

    !ub %isp56

    End Interface

    "ublic Class My'rder

    Implements 'rder%etails

    !ub disp56 Implements 'rder%etails.disp

    Msgbo7 My'rder disp method

    End !ub

    End Class

  • 7/25/2019 DOTNET Manual

    60/126

    "ublic Class nother'rder

    Implements 'rder%etails

    !ub disp56 Implements 'rder%etails.disp

    Msgbo7 nother 'rder disp method

    End !ub

    !ub MyMethod56

    Msgbo7 Non Interface Method

    End !ub

    End Class

    My'rder m

    m.disp

    nother'rder a

    a.disp

    a.MyMethod

    'rder%etails a/

    a/.disp

    a/.MyMethod56 FError

  • 7/25/2019 DOTNET Manual

    61/126

    Note

    #e can declare only methods, functions, properties and events in an

    interface. #e cannot declare a variable in an interface.

    Interfa!e In*eritan!e

    Interface -alidateSCust

    !ub -alidateSCustname56

    End Interface

    Interface I'rderdetails

    Inherits -alidateSCust

    "roperty CustName56 as !tring

    !ub ;pdateCust!tatus56

    Event ;pdateSComplete56

    End Interface

    Mem'ers of an Interfa!e!ub -alidateSCustname56"roperty CustName56 as !tring!ub ;pdateCust!tatus56Event ;pdateSComplete56

    Note,

    Interface statements are "ublic by default.

    Constru!torsutomatic initiali)ation of ob>ect

    Two t(&es of !onstru!tors

    . !hared constructors

    /. Instance Constructors

  • 7/25/2019 DOTNET Manual

    62/126

    $*ared +aria'le

    D Initiali)e with [ero, when the first ob>ect is created. No other

    initiali)ation is permitted.

    D 'nly one copy of the variable is created and can be accessed by all

    ob>ects.

    $*ared Met*ods

    D ccess only !hared -ariables

    D #ithout creating ob>ect the method can be accessed using class

    name.

    $*ared !onstru!tors

    ;sed to initiali)e shared variables of type. shared constructor will

    not run more than once during a single e7ecution of program.

    Eg,

    "ublic Class MyClass

    "ublic !hared 7 s Integer

    "ublic y s Integer

    !hared !ub New56

    7 L B

    F y L /B End !ub

    !ub New56

    y L /B

    End !ub

  • 7/25/2019 DOTNET Manual

    63/126

    !ub New5&y-al a s Integer, &y-al b s Integer6

    7 L a

    y L b

    End !ub

    "rotected 'verrides !ub $inali)e56 F%estructor

    Msg&o75%estructor Called6

    7 L B

    y L B

    End !ub

    End Class

    "rivate !ub &uttonSClick5&y-al sender s !ystem.'b>ect, &y-al e

    s !ystem.Eventrgs6 9andles &utton.Click

    %im m s New MyClass

    Msg&o75m.76

    Msg&o75m.y6

    %im m/ s MyClass

    m/ L New MyClass5:B, =B6

    Msg&o757 L Y m/.76

    Msg&o75y L Y m/.y6

    End !ub

    Instan!e Constru!tor;sed to initiali)e variables that are declared with %im, "ublic, "rivate,

    $riend, "rotected and "rotected $riend. lso access the shared variable

    within an instance constructor.

    !ub New5&y-al a as integer6

  • 7/25/2019 DOTNET Manual

    64/126

    end !ub

    Destru!tor

    ;sed to destroy 'b>ectsMet*ods Used

    $inali)e56 A To release the last reference ob>ect

    %ispose56 A To release resource, such as %atabase

    connection file closing etc.

    In*eritan!e

    D esuability of code

    D E7tensibility of code

    T(&es

    !ingle

    Multiple

    Multilevel

    9ybrid A Combination of multiple and multilevel

    9ierarchical

    Eg,

    1. FirstForm 8)ase9

    eset &utton cmdesetE7it &utton cmdE7it

    ;. Codings

  • 7/25/2019 DOTNET Manual

    65/126

    "ublic 'verridable !ub cmdesetSClick56Msgbo7

    End !ub

    "ublic 'verridable !ub cmdE7itSClick56Msgbo7

    End !ub

  • 7/25/2019 DOTNET Manual

    66/126

    End !ub

    ro!edure Overriding

    "rocedure name and passing arguments are similar

    )ase Class

    "ublic 'verridable !ub "rocedureSname56

    End !ub

    Derived Class

    "ublic 'verrides !ub "rocedureSname56

    End !ub

    Note, DoesnBt return an( value

    Calling $u' &ro!edure

    "rocedureSname5arguments65or6Call "rocedureSname5arguments6

    Fun!tion ro!edure

    ccessSspecifier $unction funcSname5arguments6 as eturnS%atatypefuncSname L return value

    5or6return retSval

    End $unction

    $unction 'verloading$unction 'verriding

    ro&ert( ro!edure

  • 7/25/2019 DOTNET Manual

    67/126

    &ackColor L red

    "ublic class Customer"rivate col as !ystem.%rawing.Color

    "ublic "roperty &ackColor56 as !ystem.%rawing.Color!et5&y-al col as !ystem.%rawing.Color6

    col L colEnd !et(et

    eturn colEnd (et

    End "ropertyEnd Class

    Event ro!edure

    &uttonSclick56+istS!electedInde7Changed56

    redefined ro!edures 8Dialog9

    Msgbo7 A Msgbo75Message,&utton !tyle,Title6

    Input&o7 A Input&o75Message,title,default -alue,* pos,H "os6

    CommonDialog Classes

    Color%ialog

    $ont%ialog

    $ile%ialog

    'pen$ile%ialog

    !ave$ile%ialog

    "rint%ialog

    "age!etup%ialog

    ro&ert( ro!edure

  • 7/25/2019 DOTNET Manual

    68/126

    &ackColor L red

    "ublic class Customer"rivate col as !ystem.%rawing.Color

    "ublic "roperty &ackColor56 as !ystem.%rawing.Color!et5&y-al col as !ystem.%rawing.Color6

    col L colEnd !et(et

    eturn colEnd (et

    End "roperty

    End Class

    Event ro!edure

    &uttonSclick56+istS!electedInde7Changed56

    redefined ro!edures 8Dialog9

    Msgbo7 A Msgbo75Message,&utton !tyle,Title6

    Input&o7 A Input&o75Message,title,default -alue,* pos,H "os6

    CommonDialog Classes

    Color%ialog

    $ont%ialog

    $ile%ialog

    'pen$ile%ialog

    !ave$ile%ialog

    "rint%ialog

    "age!etup%ialog

    C4 .NET

  • 7/25/2019 DOTNET Manual

    69/126

    OO$ Con!e&t

    AAAAAAAAAAAAAAAAAAAAA'b>ect 'riented "rogramming !ystem A !imula :=

    Five C*ara!teristi!s

    AAAAAAAAAAAAAAAAAAAAAAAAA. Classes and 'b>ects/. %ata abstraction and %ata Encapsulation0. Inheritance1. "olymorphism2. 'verloading

    Classes and 'b>ectsAAAAAAAAAAAAAAAAAAAAAAAAAAAA

    Classes A Collection member -ariables and $unctionsInstance or 'b>ects A To ccess the Class Member variables and

    functions.

    synta7AAAAAAAAAAclass classSnameU

    accessSspecifier datatype varSnameO

    accessSspecifier returntype functionSname5arguments6 UVV

    ccess specifierAAAAAAAAAAAAAAAAAAAAAAAA

    private A #ithin classpublic A any where of the program thru ob>ectprotected A Class and !ubclass

    %efining Class and 'b>ect"assing arguments and returning values

    passing ob>ect as argumentfunction overloadingConstructor and %estructorstatic variables and methodsabstract class

  • 7/25/2019 DOTNET Manual

    70/126

    %efining Class and 'b>ectAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAEgAAAAAclass !tudentsU

    private int snoOprivate string snameO

    public void getstud56U

    Console.#rite+ine5Enter sno and sname 6O

    sno L Int0/."arse5Console.ead+ine566Osname L Console.ead+ine56O

    V

    public void putstud56U

    Console.#rite+ine5!no 4 sno6OConsole.#rite+ine5sname 4 sname6O

    V

    Q!TThreadRstatic void Main5stringQR args6U

    !tudents s L new !tudents56Os.getstud56Os.putstud56OConsole.ead+ine56O

    VV

  • 7/25/2019 DOTNET Manual

    71/126

    rray of Class 'b>ectsAAAAAAAAAAAAAAAAAAAAAAAAAAAAAEgAAAAclass !tudentsU

    private int snoOprivate string snameO

    public void getstud56U

    Console.#rite+ine5Enter sno and sname 6Osno L Int0/."arse5Console.ead+ine566Osname L Console.ead+ine56O

    V

    public void putstud56U

    Console.#rite+ine5!no 4 sno 4 \t 4 sname 4sname6O

    V

    Q!TThreadRstatic void Main5stringQR args6U

    !tudentsQR s L new !tudentsQBROint i,nOConsole.#rite+ine5Enter how many students 6On L Int0/."arse5Console.ead+ine566Ofor5iLBOiKnOi446U

    sQiR L new !tudents56OsQiR.getstud56O

    VConsole.#rite+ine5The (iven !tudent -alues are 6Ofor5iLBOiKnOi446

    sQiR.putstud56OConsole.ead+ine56O

    VV

  • 7/25/2019 DOTNET Manual

    72/126

    "assing arguments and returning valuesAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAclass CircleU

    private int radiusO

    public void setradius5int r6U

    radius L rOV

    public float calculate56

    Ureturn 0.1f D radius D radiusO

    V

    Ksummary The main entry point for the application. KsummaryQ!TThreadRstatic void Main5stringQR args6U

    Circle c L new Circle56OConsole.#rite+ine5Enter the radius 6Oint r L Int0/."arse5Console.ead+ine566Oc.setradius5r6Ofloat area L c.calculate56OConsole.#rite+ine5The rea of Circle 4r 4 is 4

    area6OConsole.ead+ine56O

    V

    V

    "assing 'b>ect as rgumentsAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA

    class ectU

    private int length,breadthO

  • 7/25/2019 DOTNET Manual

    73/126

    public void setrect5int len,int bre6U

    length L lenObreadth L breO

    V

    public int totlen5ect r/6U

    return length 4 r/.lengthOV

    public int totbre5ect r/6U

    return breadth 4 r/.breadthOV

    public ect combine5ect r/6U

    ect temp L new ect56Otemp.length L length 4 r/.lengthOtemp.breadthLbreadth 4 r/.breadthOreturn tempO

    V

    public void disprect56U

    Console.#rite+ine5+ength 4 length 4 \t&readth 4breadth6O

    V

    Ksummary The main entry point for the application.

    KsummaryQ!TThreadRstatic void Main5stringQR args6U

    ect r L new ect56Oect r/ L new ect56Oect r0 L new ect56O

  • 7/25/2019 DOTNET Manual

    74/126

    r.setrect5/,16Or/.setrect52,:6Oint tlen L r.totlen5r/6Oint tbre L r.totbre5r/6Or0 L r.combine5r/6OConsole.#rite+ine5Total +ength 4 tlen6OConsole.#rite+ine5Total &readth 4 tbre6Or.disprect56Or/.disprect56Or0.disprect56OConsole.ead+ine56O

    VV

    $unction 'verloadingAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA

    $unction names are similar and passing arguments are different

    EgAAAAAclass ectangleU

    private int length,breadthOprivate int areaO

    public void getrect5int len,int bre6U

    length L lenObreadth L breO

    V

    public void getrect56U

    Console.#rite+ine5Enter +ength and &readth 6Olength L Int0/."arse5Console.ead+ine566O

    breadth L Int0/."arse5Console.ead+ine566OV

    public void calculate56U

  • 7/25/2019 DOTNET Manual

    75/126

    area L length D breadthOV

    public void disprect56U

    Console.#rite+ine5+ength 4 length 4 \t&readth 4breadth 4 \trea 4 area6O

    V Ksummary The main entry point for the application. KsummaryQ!TThreadRstatic void Main5stringQR args6U

    ectangle r L new ectangle56Oectangle r/ L new ectangle56Or.getrect5B,/B6Or/.getrect56Or.calculate56Or/.calculate56Or.disprect56Or/.disprect56OConsole.ead+ine56O

    VV

    ConstructorAAAAAAAAAAAAAAAAAA

    To Initiali)e the 'b>ect automatically.TypesAAAAAAAAAA

    . Normal constructor/. %efault Constructor0. 'verloading Constructor1. Copy Constructor A n 'b>ect Initiali)ed with another ob>ect

    !ynta7AAAAAAAAAAA

  • 7/25/2019 DOTNET Manual

    76/126

    class classSnameU

    classSname56 UV defaultclassSname5arg6 UVclassSname5ob>6 UV copy constructor

    V

    %estructorAAAAAAAAAAAAAAAclass classnameU

    ]classSname56 UVV

    EgAAAAAclass MarksU

    private int mark,mark/,totalOprivate string snameO

    Marks56 UV default constructorMarks5int m,int m/,string name6 constructor with argU

    mark L mOmark/ L m/Osname L nameOtotal L mark 4 mark/O

    VMarks5Marks m/6 copy constructorU

    mark L m/.markOmark/ L m/.mark/O

    sname L m/.snameOtotal L mark 4 mark/O

    V

    public void dispmarks56U

  • 7/25/2019 DOTNET Manual

    77/126

    Console.#rite+ine5!tudent Name 4 sname 4 \tMark 4mark 4 \t Mark/ 4 mark/ 4 \tTotal 4 total6O

    V]Marks56U

    mark LBOmark/ LBOsname LOtotal L BO

    V Ksummary The main entry point for the application. KsummaryQ!TThreadR

    static void Main5stringQR args6U

    Marks m L new Marks56O defaultMarks m/L new Marks5@B,?@,!hanthi6O constructor

    with argumentsMarks m0 L new Marks5m/6O copy constructorm.dispmarks56Om/.dispmarks56Om0.dispmarks56OConsole.ead+ine56O

    VV

    !tatic -ariablesAAAAAAAAAAAAAAAAAAAA

    D If the variable declared as static, the variable value isinitiali)ed with )ero

    D 'nly one copy of the variable is created and can be accessedby all ob>ects.

    !tatic MethodsAAAAAAAAAAAAAAAAAAAA

    D #ithout creating ob>ect, we can access the method using classname.

    D !tatic methods can access only static variableD Normal methods can access both static and normal variables.

  • 7/25/2019 DOTNET Manual

    78/126

    !tatic ConstructorAAAAAAAAAAAAAAAAAAAAAAA

    D Initiali)e only static variable

    EgAAAAclass ectangleU

    private int length,breadthOprivate static int counterO

    static ectangle56U

    counter44OVectangle56U

    length L BObreadth L BOcounter44O

    V

    ectangle5int len,int bre6U

    length L lenObreadth L breOcounter44O

    V

    public void disprect56U

    Console.#rite+ine5+ength 4 length 4 \t &readth

    4 breadth6OV

    Ksummary The main entry point for the application. KsummaryQ!TThreadR

  • 7/25/2019 DOTNET Manual

    79/126

    static void Main5stringQR args6U

    Console.#rite+ine5No of 'b>ects Created 4ectangle.counter6O

    ectangle r L new ectangle56OConsole.#rite+ine5No of 'b>ects Created 4

    ectangle.counter6Oectangle r/ L new ectangle5/B,0B6OConsole.#rite+ine5No of 'b>ects Created 4

    ectangle.counter6Oectangle r0 L new ectangle56Or.disprect56Or/.disprect56Or0.disprect56O

    Console.ead+ine56OV

    V

    InheritanceAAAAAAAAAAAAAAAAAA

    D eusability of codeD E7tensiblity of code

    TypesAAAAAAAAAAAA. !ingle/. Multiple A Not supported0. Multilevel1. 9eirarchical2. 9ybrid A Not !upported

    NoteAAAAAAAAAAAAAA. "rivate members are not inherited/. "ublic and "rotected members are inherited

  • 7/25/2019 DOTNET Manual

    80/126

    !ingle

    Multiple

    Multilevel

    &ase Class

    %erived Class

    &ase &ase/

    %erived

    &ase Class

    %erived Class

    %erived Class

  • 7/25/2019 DOTNET Manual

    81/126

    9ierarchical

    9ybridCombination of multiple and multilevel

    !ingle

    &ase ^%erived

    &ase

    %erived %erived/

    %erived %erived/ %erived/ %erived//

    &ase

    %erived &ase

    %erived

  • 7/25/2019 DOTNET Manual

    82/126

    EgAAAAAclass %eptU

    private int dnoOprivate !tring dnameO

    public %ept5int no,string name6U

    Console.#rite+ine5&ase constructor6Odno L noOdname L nameO

    V

    public void put%ept56U

    Console.#rite+ine5%eptno 4 dno 4 \t %eptname 4 dname6O

    VVclass Emp %eptU

    private int enoOprivate string enameO

    Emp5int en,string ena,int no,string name6 base5no,name6U

    Console.#rite+ine5%erived Constructor6Oeno L enOename L enaO

    V

    public void putEmp56

    UConsole.#rite+ine5Empno 4 eno 4 \t Empname

    4 ename6OV

    Q!TThreadRstatic void Main5stringQR args6

  • 7/25/2019 DOTNET Manual

    83/126

    UEmp e L new Emp5BB,aaaa,/B,sales6Oe.put%ept56Oe.putEmp56OConsole.ead+ine56O

    VV

    MultilevelAAAAAAAAAAAAAAA

    &ase ^%erived ^

    %erived/

    EgAAAAAclass !tudentsU

    private int snoOprivate string snameO

    public !tudents5int no,string name6U

    Console.#rite+ine5!tudent constructor6Osno L noOsname L nameO

    V

    public void putstud56U

    Console.#rite+ine5!tudent No 4 sno 4 \t !tudent

    Name 4 sname6OV

    V

    class Marks !tudentsU

    protected int mark,mark/O

  • 7/25/2019 DOTNET Manual

    84/126

    public Marks5int no,string name,int m,int m/6 base5no,name6U

    Console.#rite+ine5Marks constructor6Omark L mOmark/ L m/O

    V

    public void putmarks56U

    Console.#rite+ine5Mark 4 mark 4 \t Mark/ 4mark/6O

    VV

    class finaltot MarksU

    private int totalO

    public finaltot5int no,string name,int m,int m/6 base5no,name,m,m/6

    UConsole.#rite+ine5final constructor6Ototal L mark 4 mark/O

    V

    public void puttot56U

    Console.#rite+ine5Total 4 total6OV

    Ksummary The main entry point for the application.

    KsummaryQ!TThreadRstatic void Main5stringQR args6U

    finaltot f L new finaltot5BB,aaaa,@B,[email protected]

  • 7/25/2019 DOTNET Manual

    85/126

    f.puttot56OConsole.ead+ine56O

    V

    V

    9eirarchicalAAAAAAAAAAAAAAAAAAA

    &se A +evel Class ^

    AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA^ ^

    %ervied %erived/ A +evel/ Class ^

    AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA^ ^%er.0 %er.1 A +evel0 Class

    bstract Class A ;sed in Inheritance Concept.AAAAAAAAAAAAAAAAAAAAA

    !et of Complete and Incomplete methods

    EgAAAAabstract class &aseClassU

    public void completeMeth56U

  • 7/25/2019 DOTNET Manual

    86/126

    Console.#rite+ine5&ase Class Complete Method6OVabstract public void IncompleteMeth56O

    Vclass MyClass &aseClassU

    public override void IncompleteMeth56U

    Console.#rite+ine5!ample %efinition6O

    VV

    class %erivedClass &aseClass

    Upublic override void IncompleteMeth56U

    Console.#rite+ine5&ase Class IncompleteMethod6O

    V

    public void MyMethod56U

    Console.#rite+ine5%erived Class Method6OV

    Q!TThreadRstatic void Main5stringQR args6U

    %erivedClass d L new %erivedClass56Od.completeMeth56Od.IncompleteMeth56O

    d.MyMethod56OMyClass m L new MyClass56Om.IncompleteMeth56OConsole.ead+ine56O

    VV

  • 7/25/2019 DOTNET Manual

    87/126

    EgAAAAAabstract class bs!tackU

    abstract public void push5int a6Oabstract public int pop56O

    Vclass !tack bs!tackU

    private intQR stackOprivate int tosO

    public !tack5int si)e6U

    stack L new intQsi)eROtosLAO

    V

    public override void push5int a6U

    if5tos L stack.+engthA6U

    Console.#rite+ine5!tack 'verflow6OVelse

    stackQ44tosR L aOV

    public override int pop56U

    if5tos K B6U

    Console.#rite+ine5!tack ;nderflow6O

    return BOVelse

    return stackQtosAAROV

    Ksummary

  • 7/25/2019 DOTNET Manual

    88/126

    The main entry point for the application. KsummaryQ!TThreadRstatic void Main5stringQR args6U

    !tack mystack L new !tack526O!tack mystack/ L new !tack5?6O

    for5int iLOiKL:Oi446mystack.push5i6O

    for5int iLOiKL?Oi446mystack/.push5i6O

    Console.#rite+ine5Mystack value6Ofor5int iLOiKL2Oi446

    Console.#rite+ine5mystack.pop566O

    Console.#rite+ine5Mystack/ value6Ofor5int iLOiKL@Oi446

    Console.#rite+ine5mystack/.pop566OConsole.ead+ine56O

    V

    InterfaceAAAAAAAAAAAAAA

    !et of Incomplete methods

    synta7AAAAAAAAAAAinterface ifaceSnameU

    method declarationsO

    V

    class classSname IfaceSnameU

    %efinitions of interface methodsOV

  • 7/25/2019 DOTNET Manual

    89/126

    EgAAAAinterface CallbackU

    void call5int param6OVclass notherClient CallbackU

    3region Callback Members

    public void call5int param6U

    Console.#rite+ine5!

  • 7/25/2019 DOTNET Manual

    90/126

  • 7/25/2019 DOTNET Manual

    91/126

    public void second56U

    Console.#rite+ine5!econd Interface Method6OV

    3endregionV

    rrays and !tringsAAAAAAAAAAAAAAAAAAAAAAAAAAAArraysAAAAAAAAA

    Collection of !imilar data types.

    Two typesAAAAAAAAAAAAAAAA

    !ingle %imensionMulti dimension

    !ingle %imensionAAAAAAAAAAAAAAAAAAAAAAAAA%eclarationAAAAAAAAAAAAAAAA

    intQR a L new intQBRO

    Initiali)ationAAAAAAAAAAAAAAAA

    intQR a L U,/,0,1,2VO

    aQBR L ...aQ1R L 2

    EgAAAA

    static void Main5stringQR args6U

    intQR a L new intQBROint i,nO

  • 7/25/2019 DOTNET Manual

    92/126

    Console.#rite+ine5Enter the value of n 6On L Int0/."arse5Console.ead+ine566Ofor5iLBOiKnOi446U

    Console.#rite5Enter aQ 4 i 4 R 6OaQiR L Int0/."arse5Console.ead+ine566O

    VConsole.#rite+ine5The (iven -alues are6Ofor5iLBOiKnOi446U

    Console.#rite+ine5aQiR6OVConsole.ead+ine56O

    V

    EgAAAAA!ortingAAAAAAAAAAAstatic void Main5stringQR args6

    UintQR a L new intQ/BROint i,>,temp,nOConsole.#rite5Enter the value of n 6On L Int0/."arse5Console.ead+ine566Ofor5iLBOiKnOi446U

    Console.#rite5Enter aQ 4 i 4 R 6OaQiRLInt0/."arse5Console.ead+ine566O

    Vfor5iLBOiKnOi446U

    for5>Li4O>KnO>446

    Uif5aQiR aQ>R6U

    temp L aQiROaQiRLaQ>ROaQ>R L tempO

    V

  • 7/25/2019 DOTNET Manual

    93/126

    VVConsole.#rite+ine5!orted -alues are6Ofor5iLBOiKnOi446

    Console.#rite+ine5aQiR6OConsole.ead+ine56O

    V

    Two %imensional rrayAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA%eclarationAAAAAAAAAAAAAA

    datatypeQ,R varSname L new datatypeQrow,colRO

    EgAAAA

    intQ,R a L new intQ2,2RO

    aQB,BR L aQB,R L /

    EgAAAAintQ,R a Lnew intQ2,2RO

    int i,>,row,colOConsole.#rite+ine5Enter row and Column value6Orow L Int0/."arse5Console.ead+ine566Ocol L Int0/."arse5Console.ead+ine566Ofor5iLBOiKrowOi446U

    for5>LBO>KcolO>446U

    Console.#rite5Enter aQ 4 i 4 RQ 4 > 4

    R 6OaQi,>R L Int0/."arse5Console.ead+ine566O

    VV

    Console.#rite+ine5The (iven rray values are6Ofor5iLBOiKrowOi446

  • 7/25/2019 DOTNET Manual

    94/126

    Ufor5>LBO>KcolO>446U

    Console.#rite5aQi,>R 4 \t6OVConsole.#rite+ine56O

    VConsole.ead+ine56O

    V

    string classAAAAAAAAAAAAAAAA

    Collection of characters

    string s L 9elloO

    MethodsAAAAAAAAAAAAAstatic void Main5stringQR args6

    Ustring str L 9ello #orldOstring str/ L 9elloOstring str0 L !ample Oint iOcharQR c L new CharQstr.+ength40ROcQBR L FaFOcQR L FbFOcQ/R L FcFOConsole.#rite+ine5+ength 4 str.+ength6OConsole.#rite+ine5Compare To 4

    str/.CompareTo5str66OConsole.#rite+ine5Copy to Character rray 6O

    str.CopyTo5B,c,/,str.+ength6Ofor5iLBOiKc.+engthOi446

    Console.#rite5cQiR 4 6OConsole.#rite+ine56OConsole.#rite+ine5Ends with 4 str.Ends#ith5a66OConsole.#rite+ine5!tarts #ith 4

    str.!tarts#ith5966O

  • 7/25/2019 DOTNET Manual

    95/126

    Console.#rite+ine5Eect Model

  • 7/25/2019 DOTNET Manual

    96/126

    AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA"rovider A The %ata residing in a database is retrieved through data

    provider.%ataset A The %ata is cached in a dataset and the application accesses

    the data from the dataset.%ataeader A In this method, a %ataeader ob>ect, which is

    component of the data provider, uses the connection ob>ect to connect to thedatabase, uses the command ob>ect to retrieves data, and provides data to theapplication in a readAonly and forward only mode.

    %ata "rovidersAAAAAAAAAAAAAAAAAAAA

    Two types of %ata "roviders

    '+E %& %ata "rovider#orks with all type of '+E%& "roviders.namespace A !ystem.%ata.'le%b

    !X+ !erver %ata "rovider#orking with !X+ !ervernamespace A !ystem.%ata.!

  • 7/25/2019 DOTNET Manual

    97/126

    !

  • 7/25/2019 DOTNET Manual

    98/126

    UConsole.#rite+ine5Enter pid,pname,

  • 7/25/2019 DOTNET Manual

    99/126

    cmd.Connection.Close56OConsole.#rite+ine5ecord %eleted6O

    V

    public void view%ata56U

  • 7/25/2019 DOTNET Manual

    100/126

    #IN%'#! $'MC'NT'+C'NT'+/C'NT'+0

    &IN%IN(C'NTE*T'&8ECT

    C;ENCHMN(E

    C;ENCHMN(E/

    C;ENCHMN(E0

    %T !';CE

    %T !';CE /

    %T !';CE 0

    'b>ect

    &inary#riter

    &inaryeader

    Marshal&yef'b>ect

    !tream $ile!tream

    Te7teader !treameader

    Te7t#riter !tream#riter

    %irectory

  • 7/25/2019 DOTNET Manual

    101/126

    ADO.NET

    A!tive3 Data O'e!t 8ADO9

    .NET pplication to communicate with a database for

    inserting,updating and retrieving data.

    Features

    1. Dis!onne!ted Ar!*ite!ture

    pplications connect to the database only while retrieving and

    updating data. fter data is retrieved, the connection with the database is

    closed.

    ;. Data !a!*ed in Datasets

    dataset is a cached set of database records. #e can work with

    the records stored in a dataset as we work with real dataO the only difference

    being that the dataset is independent of data source and we remain

    disconnected from the data source. s a result, resources are saved and the

    database can meet the increasing demands of users more efficiently.

  • 7/25/2019 DOTNET Manual

    102/126

    ADO.NET O'e!t Model

    rovider 56The %ata residing in a database is retrieved through data

    provider.

    Dataset 56 The %ata is cached in a dataset and the application

    accesses the data from the dataset.

    DataReader 56 In this method, a %ataeader ob>ect, which is

    component of the data provider, uses the connection ob>ect to connect to the

    database, uses the command ob>ect to retrieves data, and provides data to the

    application in a readAonly and forward only mode.

    -&.NETpplication5#indows#eb$orms6

    %T!ET

    C'NNECTI'N

    %TE%E

    C'MMN%

    %T %"TE

    %T&!E

    "'-I%E!

  • 7/25/2019 DOTNET Manual

    103/126

    Data roviders

    Two types of %ata "roviders

    O#E D) Data rovider

    #orks with all type of '+E%& "roviders.namespace A !ystem.%ata.'le%b

    $# $erver Data rovider

    #orking with !X+ !ervernamespace A !ystem.%ata.!ect, &y-al e s

    !ystem.Eventrgs6 9andles My&ase.+oad

    %im con s !

  • 7/25/2019 DOTNET Manual

    104/126

    con.'pen56

    Msg&o75Connection 'pened6

    con.Close56

    End !ub

    Conne!ting wit* M$ 5 A!!ess

    Imports !ystem.%ata.'le%b

    %im con s 'le%bConnection

    con L New

    'le%bConnection5"roviderLMicrosoft.8et.'+E%&.1.BO%ata

    !ourceLddemovb.netsample%&.mdb6

    con.'pen56

    Msg&o75%atabase Connected6

    con.Close56

    Data Ada&ter

    %ata is transfered to and from a database through a data adapter.

    !

  • 7/25/2019 DOTNET Manual

    105/126

    DeleteCommand 56 efers to a data command to delete from a

    database

    Fill89 Met*od 56$ills the dataset with the records from a database

    U&date89 Met*od 56 E7ecutes the correspoding InsertCommand,

    ;pdateCommand or %eleteCommand row to reflect the changes in the

    database.

    Eg,

    %rag a !

  • 7/25/2019 DOTNET Manual

    106/126

    Eg,

    %im con s New !

  • 7/25/2019 DOTNET Manual

    107/126

    %im command s New !

  • 7/25/2019 DOTNET Manual

    108/126

    Dataset O'e!t Model

    DATA$ET

    %TC'+;MNC'++ECTI'N

    "IMHPEH%T-IE#%T'#C'++ECTI'N

    %TT&+E%TE+TI'N

    E*TEN%E%"'"ETIE!

    %TT&+EC'++ECTI'N

    %TE+TI'NC'++ECTI'N

    %ataow%ataColumn

  • 7/25/2019 DOTNET Manual

    109/126

    The %ataset is present as a %ataset class in the !ystem.%ata namespace. The

    Components of the dataset ob>ect model are

    Component %escriptionAAAAAAAAAAAAAAA AAAAAAAAAAAAAAAA%ataTableCollection It Contains all the tables retrievedfrom the data source

    %ataelationCollection It contains relationships and the linksbetween tables in a dataset

    E7tended"roperties It contains additional information,

    such as the !X+ statement for retrievingdata and the date time stamp for the retrieveddata

    %ataTable It represents a table in the%ataTableCollection of a dataset

    %ataelation It represents a relationship in the%ataelationCollection of a dataset

    %ataowCollection It contains all the rows in a %ataTable

    %ata-iew It represents a fi7ed customi)ed view of a%ataTable

    "rimaryPey It represents the column that uni

  • 7/25/2019 DOTNET Manual

    110/126

    D ManuallyD Through a #i)ardD ;sing the !erver E7plorer #indow

    Types of %atasetsAAAAAAAAAAAAAAAAAAAAAAAA

    %atasets are of two types.

    . Typed/. ;ntyped.

    Typed %atasetAAAAAAAAAAAAAAAAAA

    typed dataset is derived from the %ataset class and has an associated

    *M+ schema, which is created at the time of the creation of the dataset. The*M+ schema contains information about the dataset structure, such as thetables, columns and rows. %ata is transferred from a database into a datasetand from the dataset to another component in *M+ format.

    *M+ !chema %efinition 5C!%6 language is used to define theelements and attributes of *M+ documents. !ince a typed dataset structureis stored in an *M+ format, the dataset is saved as an *!% file. Thisstructure of a typed dataset is decided at the time of its creation. #hen atyped dataset is created, the data commands are generated automatically byusing the column names from the data source. Tables and their columns can

    be accessed by their names while programming.

    %im custid as stringcustid L %!Cust.CustomerTracking5B6.CustI%

    ;ntyped %atasetAAAAAAAAAAAAAAAAAAAAAAA

    n untyped dataset does not have any associated *M+ schema. In anuntyped dataset, the tables and columns are represented as collections. !incean *M+ schema is not created for an untyped dataset, the structure of anuntyped dataset is not known during compilation.

    %im custid as !tring'le%b%Cust.$ill5%!Cust6

  • 7/25/2019 DOTNET Manual

    111/126

    custid LCType5%!Cust.Tables5CustomerTracking6.ows5B6.Item5CustI%6,!tring6

    D ;sing %ata dapterD Comple7 %ata &inding A %ata (rid

    Implementing !imple %ata &indingAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA

    Navigating &etween ecordsAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA

    $or every data source that is bound to a #indows $orm, there e7ists aCurrencyManager ob>ect. The CurrencyManager ob>ect handles the bindingto the data source by keeping a pointer to the current item in the record list.

    The Currencymanager class is derived from the &indingManager&ase class.If all the #indows $orm controls are bound to a single %ata source, the formwill have one CurrencyManager ob>ect associated with it. &indingConte7tob>ect, #hich is a #indows $orm ob>ect, is usd to keep track of the e7istingCurrencyManager ob>ects in a form.

    %iagram

    Connecting to a %atabase through #i)ardAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA. %rag a 'le%& or !

  • 7/25/2019 DOTNET Manual

    112/126

    %ata &indingAAAAAAAAAAAAAAAA. !imple %ata &inding/. Comple7 %ata &inding

    Comple7 %ata bindingAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA

    &inding with +istbo7, %atagrid Control with multiple values ormultiple columns

    $or %atagrid ControlAAAAAAAAAAAAAAAAAAAAAAAAAAAAA"roperties

    AAAAAAAAAAAAAA%ata!ource A %ataset name%ataMember A Table Name

    +ist&o7AAAAAAAAAAAAA

    %atasource A %ataset name%isplayMember A Column name

    !imple %ata &indingAAAAAAAAAAAAAAAAAAAAAAAAAA

    &inding with a single column and single value. ;sed forTe7tbo7.

    Te7t&o7 "ropertiesAAAAAAAAAAAAAAAAAAAAAAAAA

    %ata&indingsTe7t A Column name

    $ormS+oadAAAAAAAAAAAAAAAAAAA

    !

  • 7/25/2019 DOTNET Manual

    113/126

    /. Create dataset0. &inding with controls.

    CodingsAAAAAAAAAAAAAAA(eneral %eclarationAAAAAAAAAAAAAAAAAAAAAAAA%im bm s &indingManager&ase

    $ormS+oadAAAAAAAAAAAAAAAAAA !

  • 7/25/2019 DOTNET Manual

    114/126

    $iltering and !orting %ataAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA

    Two types of $ilteringAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA. "arameteri)ed Xueries/. $ilter the %ataset

    "arameteri)ed XueriesAAAAAAAAAAAAAAAAAAAAAAAAAAAAA. Create a !ect, &y-al e s!ystem.Eventrgs6 9andles cmd!earch.Click !

  • 7/25/2019 DOTNET Manual

    115/126

    sort L custid asc %im result56 s %ataow result L dt.!elect5cond, sort6 %im ctr s Integer $or ctr L B To result.+ength A lst"rodid.Items.dd5result5ctr65custid6.To!tring6 Ne7t End !ub

    "rivate !ub $ormS+oad5&y-al sender s !ystem.'b>ect, &y-al e s!ystem.Eventrgs6 9andles My&ase.+oad !

  • 7/25/2019 DOTNET Manual

    116/126

    +abel CustomerI%+abel $irstname+abel ddress

    %ata(rid %(%etail A %ata!ource A %!Master%etail%ataMember A CustomerTracking A

    CustomerTrackingCust'rder

    Te7t&o7 t7tCustid A %ata&indings A Te7t ACustomerTracking A CustI%Te7t&o7 t7t$name A %ata&indings A Te7t ACustomerTracking A $nameTe7t&o7 t7tddress A %ata&indings A Te7t ACustomerTracking A ddress

    CodingsAAAAAAAAAAA

    %im bm s &indingManager&ase$ormS+oad56AAAAAAAAAAAAAAAAAA!

  • 7/25/2019 DOTNET Manual

    117/126

    ddress -archar5BB6,phoneno numeric526,Email varchar52B6,regdatedatetime6

    /. %esign the $orm and &ind the Control

    0. CodingsAAAAAAAAAAAAA(eneral %eclarationAAAAAAAAAAAAAAAAAAAAAAAAAAAA %im bm s &indingManager&ase %im flag s Integer L B

    %im dt s %ataTable %im dr s %ataow %im custid s !tring

    $ormS+oadAAAAAAAAAAAAAAAAAAA!

  • 7/25/2019 DOTNET Manual

    118/126

    flag L %im cid, cidval s !tring %im ctr, len s Integer dt L %sCustomer.Tables5Customer%etails6 len L dt.ows.Count A If 5len K B6 Then cid L CBB Else dr L dt.ows5len6 cidval L dr5Custid6 cidval L Mid5cidval, /, 06 ctr L CInt5cidval6 If 5ctr B nd ctr K @6 Then ctr L ctr 4

    cid L CBB Y ctr ElseIf 5ctr L @ nd ctr K @@6 Then ctr L ctr 4 cid L CB Y ctr Else ctr L ctr 4 cid L C Y ctr End If End If t7tCustid.Te7t L cid t7tCustname.$ocus56

    ClearTe7tAAAAAAAAAAAAAAA"rivate !ub ClearTe7t56

    t7tCustid.Te7t L t7tCustname.Te7t L t7tddr.Te7t L t7t"hno.Te7t L

    t7tEmail.Te7t L t7tdate.Te7t L End !ub

    btnModifySClickAAAAAAAAAAAAAAAAAAAAAAAcustid L t7tCustid.Te7t

  • 7/25/2019 DOTNET Manual

    119/126

    flag L /

    btn%eleteSClickAAAAAAAAAAAAAAAAAAAAAcustid L t7tCustid.Te7t

    flag L 0

    btn!aveSClickAAAAAAAAAAAAAAAAAAAAIf flag L Then

    dt L %sCustomer.Tables5Customer%etails6 dr L dt.Newow56 dr5B6 L t7tCustid.Te7t dr56 L t7tCustname.Te7t

    dr5/6 L t7tddr.Te7t dr506 L t7t"hno.Te7t dr516 L t7tEmail.Te7t dr526 L t7tdate.Te7t dt.ows.dd5dr6 ElseIf flag L / Then dt L %sCustomer.Tables5Customer%etails6 dr L dt.ows.$ind5custid6 dr.&eginEdit56 dr56 L t7tCustname.Te7t dr5/6 L t7tddr.Te7t dr506 L t7t"hno.Te7t dr516 L t7tEmail.Te7t dr526 L t7tdate.Te7t dr.EndEdit56 ElseIf flag L 0 Then dt L %sCustomer.Tables5Customer%etails6 dr L dt.ows.$ind5custid6 dr.%elete56

    End If !

  • 7/25/2019 DOTNET Manual

    120/126

    t7tdate.Te7t L !ystem.%ateTime.Today

    Crystal eportAAAAAAAAAAAAAAAAAAA

    $or Creating eports and Charts

    Three MethodsAAAAAAAAAAAAAAAAAAAA. Manually/. ;sing !tandard E7pert0. $rom an e7isting eport ManuallyAAAAAAAAAAAAA. Create a #indows $orm

    /. $rom "ro>ect Menu A dd New Item A Crystaleport0. Name A evenueeport.rpt A Click 'pen button1. Crystal eport (allery A !elect s a blank eport A Click 'k2. In the $ield E7plorer #indow A %atabase $ields A ight Click A

    ddemove %atabase:. !elect '+E%& 5%'6 A Microsoft '+E%& for !X+ server=. ;!er id L saOpasswordLkillerOserverLsystem?OdatabaseLmaster?. !elect Table CustomerTracking A Insert Table A Click $inish@. $rom $ield E7plorer #indow A %rag the e

  • 7/25/2019 DOTNET Manual

    121/126

    ?. !elect %isplay $ields A Click ne7t@ !elect (roup $ield A Click Ne7tB. !elect !ummari)ed $ield A Click Ne7t. Chart A !elect chart type A Te7t A Title 5evenue eport6 A

    Click Ne7t/. Click ne7t0. Click Ne7t1. Click $inish

    2. In the $orm #indow A "lace one crystaleport-iewer Control A"roperties A eport!ource A &rowser and !elect the A evenueeport.rpt

    $iltering %ata report

    AAAAAAAAAAAAAAAAAAAAAAAAAA. Create a #indows $orm/. Create a !X+%atadapter A !elect Cust'rder and !et the

    condition as Cost0BBB0. (enerate a %ata!et with the Name of %!eport1. "ro>ect Menu A dd New Item A Crystaleport2. Name A evenueeport/.rpt A Click 'pen:. Crystal (allery eport A !elect s a blank eport=. In the $ield E7plorer #indow A %atabase $ields A dd emove

    %atabase?. !elect "ro>ect %ata A %'.NET A %atastet A %!eport A

    Custorder@. $rom $ield E7plorer A %rag the e

  • 7/25/2019 DOTNET Manual

    122/126

    AAAAAAAAAAAAAAA!

  • 7/25/2019 DOTNET Manual

    123/126

    M%I $orms A Multiple %ocument InterfaceEg M! A #ord

    %rag MainMenu from Toolbar and set the Name and Caption "roperty$orm A IsMdiContainer A !et to True

    Conte7t MenuAAAAAAAAAAAAAAAAAA%rag Conte7t Menu $rom toolbarCreate MenuItems with Itemname$orm A Conte7tMenu "roperty A Conte7tMenu

    Toolbar

    AAAAAAAAAAA%rag a Image+ist Control A "roperty A Images A dd some Images

    %rag a Toolbar Control A"ropertyAAAAAAAAAAImage+ist Image+ist&utton collection dd &uttons with Name and

    ImageInde7

    #rite Codings

    !tatubarAAAAAAAAAAAAA%rag a !tatusbar Control

    "ropertyAAAAAAAAAAA!how"anels True"anels dd "anel and !et the Name "roperty

    #rite Codings

    CodingsAAAAAAAAAAA

  • 7/25/2019 DOTNET Manual

    124/126

    "rivate !ub mnuNewSClick5&y-al sender s !ystem.'b>ect, &y-al es !ystem.Eventrgs6 9andles mnuNew.Click %im myform s New !econd myform.Mdi"arent L Me myform.!how56 End !ub

    "rivate !ub mnu!aveSClick5&y-al sender s !ystem.'b>ect, &y-al e s!ystem.Eventrgs6 9andles mnu!ave.Click Msg&o75!ave Clicked6 End !ub

    "rivate !ub mnuE7itSClick5&y-al sender s !ystem.'b>ect, &y-al e s!ystem.Eventrgs6 9andles mnuE7it.Click

    End End !ub

    "rivate !ub $ormS+oad5&y-al sender s !ystem.'b>ect, &y-al e s!ystem.Eventrgs6 9andles My&ase.+oad #indow!tate L $orm#indow!tate.Ma7imi)ed !&"anel/.Te7t L !ystem.%ateTime.Now56 End !ub

    "rivate !ub mnu-erticalSClick5&y-al sender s !ystem.'b>ect, &y-al es !ystem.Eventrgs6 9andles mnu-ertical.Click Me.+ayoutMdi5Mdi+ayout.Tile-ertical6 End !ub

    "rivate !ub mnu9ori)ontalSClick5&y-al sender s !ystem.'b>ect, &y-ale s !ystem.Eventrgs6 9andles mnu9ori)ontal.Click Me.+ayoutMdi5Mdi+ayout.Tile9ori)ontal6 End !ub

    "rivate !ub mnuCascadeSClick5&y-al sender s !ystem.'b>ect, &y-al es !ystem.Eventrgs6 9andles mnuCascade.Click Me.+ayoutMdi5Mdi+ayout.Cascade6 End !ub

    "rivate !ub mnurrIconsSClick5&y-al sender s !ystem.'b>ect, &y-al es !ystem.Eventrgs6 9andles mnurrIcons.Click

  • 7/25/2019 DOTNET Manual

    125/126

    Me.+ayoutMdi5Mdi+ayout.rrangeIcons6 End !ub

    "rivate !ub mnNewSClick5&y-al sender s !ystem.'b>ect, &y-al e s!ystem.Eventrgs6 9andles mnNew.Click %im myform s New !econd myform.Mdi"arent L Me myform.!how56 End !ub

    "rivate !ub mn9oriSClick5&y-al sender s !ystem.'b>ect, &y-al e s!ystem.Eventrgs6 9andles mn9ori.Click Me.+ayoutMdi5Mdi+ayout.Tile9ori)ontal6 End !ub

    "rivate !ub mn-ertSClick5&y-al sender s !ystem.'b>ect, &y-al e s!ystem.Eventrgs6 9andles mn-ert.Click Me.+ayoutMdi5Mdi+ayout.Tile-ertical6 End !ub

    "rivate !ub Tool&arS&uttonClick5&y-al sender s !ystem.'b>ect,&y-al e s !ystem.#indows.$orms.Tool&ar&uttonClickEventrgs69andles Tool&ar.&uttonClick !elect Case Tool&ar.&uttons.Inde7'f5e.&utton6 Case B %im myform s New !econd myform.Mdi"arent L Me myform.!how56 sb"anel.Te7t L New $ormCase Msg&o75!ave ClickedF6 sb"anel.Te7t L !ave $orm Case /

    sb"anel.Te7t L E7it $orm End End !elect End !ub

  • 7/25/2019 DOTNET Manual

    126/126

    DDDDDDDDDDDDll the &est DDDDDDDDDD