jawaharlal nehru engineering college vb

Upload: alexis-john-rubio

Post on 03-Jun-2018

234 views

Category:

Documents


0 download

TRANSCRIPT

  • 8/12/2019 Jawaharlal Nehru Engineering College VB

    1/34

  • 8/12/2019 Jawaharlal Nehru Engineering College VB

    2/34

    2

    FORWARD

    It is my great pleasure to present this laboratory manual for S.Y (M.C.A)students for the subject of VB.NET (Visual Basic .NET).Subject name itself is

    expecting what are the advance tools that might be Visual Studio to developand build rich .NET applications. In this manual we have dealt with VB.NET.

    As a student, many of you may be wondering with some of the questions inyour mind regarding the subject and exactly what has been tried is to answer

    through this manual.

    As you may be aware that MGM has already been awarded with ISO 9000certification and it is our endure to technically equip our students taking theadvantage of the procedural aspects of ISO 9000 Certification.

    Faculty members are also advised that covering these aspects in initial stageitself, will greatly relived them in future as much of the load will be taken careby the enthusiasm energies of the students once they are conceptually clear.

    Dr. S.D.DESHMUKHPrincipal

  • 8/12/2019 Jawaharlal Nehru Engineering College VB

    3/34

    3

    LABORATORY MANUAL CONTENTS

    This manual is intended for the students S.Y (M.C.A) engineering for the

    subject of VB.NET. Subject name itself is expecting what are the advance toolsthat might be Visual Studio to develop and build rich .NET applications. In thesubject of this manual typically contains practical/Lab Sessions we have dealt

    with VB.NET.

    Students are advised to thoroughly go through this manual rather than onlytopics mentioned are the key to understanding and conceptual visualization oftheoretical aspects covered in the books.

    Good Luck for your Enjoyable Laboratory Sessions

    Lect. V.V Shaga

  • 8/12/2019 Jawaharlal Nehru Engineering College VB

    4/34

    4

    SUBJECT INDEX:

    1. Create and Validate Login Form.

    2. Program to design an ACCOUNT Class.3. Program to demonstrate Inheritance, Polymorphism and Interfaces.4. Advance Controls.5. Common Dialog Controls.6. ADO.NET Code to show records in DataGridView Control.

    7. ADO.NET Code to perform Insert, Delete, Update and Select operations.8. Crystal Reports9. Web Application using ASP.NET that uses validation controls.10. Web Application with ADO.NET to perform Insert, Delete, Update andSelect Operations.

    DOs and DONT DOs in Laborary:

    1. Do not handle any equipment before reading the instructions/Instruction manuals

    2. Read carefully the power ratings of the equipment before it is switched on whether ratings 230V/50

    Hz or 115V/60 Hz. For Indian equipments, the power ratings are normally 230V/50Hz. If youhave equipment with 115/60 Hz ratings, do not insert power plug, as our normal supply is230V/50 Hz, which will damage the equipment.

    3. Observe type of sockets of equipment power to avoid mechanical damage

    4. Do not forcefully place connectors to avoid the damage

    5. Strictly observe the instructions given by the teacher/Lab Instructor

    Instruction for Laboratory Teachers::

    1. Submission related to whatever lab work has been completed should be done during the next labsession. The immediate arrangements for printouts related to submission on the day of practical

    assignments.

    2. Students should be taught for taking the printouts under the observation of lab teacher.

    3. The promptness of submission should be encouraged by way of marking and evaluation patternsthat will benefit the sincere students.

  • 8/12/2019 Jawaharlal Nehru Engineering College VB

    5/34

    5

    WARMUP EXCERCISES:

    What is .NET?

    Explain execution of .any .NET application.

    What is difference between VB.NET and VB?

    Explain .NET Framework?

    What are CLR, CTS, and CLS?

    What is Console?

    What are Inheritance, Polymorphism and Interfaces?

    Features of .NET

    What is assembly? Explain different types of assemblies.

    What is namespace?

    What is ADO.NET? Explain ADO.NET architecture.

    Explain ADO.NET objects.

    What is Dataset? Difference between Dataset and DataReader object.

    What are the methods of Command object?

    What is connected and disconnected architecture?

    What is stream? What is the use of StreamReader and StreamWriter?

    What is Crystal report?

    What is ASP.NET?

    Compare .NET with other technologies.

  • 8/12/2019 Jawaharlal Nehru Engineering College VB

    6/34

  • 8/12/2019 Jawaharlal Nehru Engineering College VB

    7/34

    7

    txtUsername.Focus()EndIf

    CaseElseMsgBox("Login fails..")

    txtUsername.Text = ""txtPassword.Text = ""txtUsername.Focus()

    EndSelectEndSub

    PrivateSubbtnCancel_Click(ByValsender AsSystem.Object, ByVale AsSystem.EventArgs)HandlesbtnCancel.Click

    EndEndSub

    EndClass

  • 8/12/2019 Jawaharlal Nehru Engineering College VB

    8/34

    8

    2. Lab Exercises:

    [Purpose of this exercise is to define a Class ACCOUNT .Include following

    Data members: Name of depositor, Account no, type of Account, balance amount.

    Member Functions: To Deposit an amount, to withdraw an amount after checking balance, to

    show balance.

    Also provide proper validations wherever necessary. Write a main program to test above

    class]

    Steps to follow:

    1) In FILE menu select NEW PROJECT. Then select Console Application.

    2) Give the name for Project AccountInformation and click OK. Window with

    Module1.vb gets generated.

    3) From Project Menu select Add Class. Give name to the class i.e. ACCOUNT.

    4) Write the code and execute by pressing F5.

    Exercise No2: ( 2 Hours) 1 PracticalPublicClassAccount

    Privatename_Of_Customer, accountNo, accountType AsStringPrivatebalance_Amount AsDouble

    PublicSubNew() 'Default constructorConsole.WriteLine("Customers Account Information")

    EndSub'Parameterized constructorPublicSubNew(ByValname AsString, ByValacNo AsString, ByValacType AsString, ByValbal

    AsDouble)

    name_Of_Customer = nameaccountNo = acNoaccountType = acTypebalance_Amount = bal

    EndSub'Deposite methodPublicSubdeposite(ByValamt AsDouble)

    balance_Amount += amtEndSub'Withdraw methodPublicSubwithdraw(ByValamt AsDouble)

    SelectCaseaccountTypeCase"S"

    If(balance_Amount > amt) Thenbalance_Amount -= amt

    Else

    Console.WriteLine("Insufficient balance")EndIf

    Case"C"If(balance_Amount > 500) Then

    balance_Amount -= amt

  • 8/12/2019 Jawaharlal Nehru Engineering College VB

    9/34

    9

    ElseConsole.WriteLine("Insufficient balance")

    EndIfCaseElse

    Console.WriteLine("Invalid transaction")EndSelect

    EndSub

    'Displays Customers informationPublicSubshowDetails()

    Console.WriteLine(" Name : "& name_Of_Customer)Console.WriteLine(" Account No : "& accountNo)Console.WriteLine(" Account type : "& accountType)Console.WriteLine(" Balance Amount : "& balance_Amount)

    EndSubEndClass

    ModuleModule1SubMain()

    DimO1 AsNewAccount 'Calling Default constructorDimA1 AsNewAccount("Harry Potter", "A101", "C", 1200.33) 'Calling parameterized

    constructorsA1.showDetails()A1.deposite(200.34)A1.showDetails()A1.withdraw(700)A1.showDetails()Console.Read()

    EndSubEndModule

  • 8/12/2019 Jawaharlal Nehru Engineering College VB

    10/34

    10

    3. Lab Exercises:

    [Purpose of this exercise is to implement Inheritance, Polymorphism and Interfaces.]

    Steps to follow:

    1) In FILE menu select NEW PROJECT. Then select Console Application.2) Give the name for Project EmployeeInformation and click OK. Window with

    Module1.vb gets generated.

    3) From Project Menu select Add Class. Give name to the class i.e. Employee and

    define its functions .This class will be BASE Class.

    4) From Project Menu again select Add Class. Give name to the class i.e. Manager

    .This class should be derived class.

    5) From Project Menu again select Add Class. Give name to the class i.e. Engineer .This

    class also should be a derived class.

    6) Then Right Click on EmployeeInformation in solution explorer window and select

    ADD, then select New Item. Then select Interface and give name as ITaxInterface.

    Declare the methods in interface and implement interface methods in derived classes.

    7) Write the code and execute by pressing F5.

    Exercise No3: ( 2 Hours) 1 Practical

    [Base Class]

    PublicClassEmployeePublicempCode AsStringPublicempName AsStringPublicbasic, netSalary AsDoublePublichra, da AsDouble

    PublicSubgetEmpDetails()Console.WriteLine("Enter Code :")empCode = Console.ReadLine()Console.WriteLine("Enter Name :")empName = Console.ReadLine()

    EndSub

    PublicSubgetSalaryDetails()Console.WriteLine("Enter Basic :")basic = Console.ReadLine()Console.WriteLine("Enter HRA :")

    hra = Console.ReadLine()Console.WriteLine("Enter DA:")da = Console.ReadLine()

    EndSub

    'Called by Manager ClassPublicFunctioncalculateSalary() AsDouble

    Returnbasic + hra + daEndFunction

  • 8/12/2019 Jawaharlal Nehru Engineering College VB

    11/34

    11

    'Called by Engineer class

    PublicFunctioncalculateSalary(ByValbonusAmt AsDouble) AsDoubleReturnbasic + hra + da + bonusAmt

    EndFunction

    EndClass

    [Interface]

    PublicInterfaceITaxInterfaceFunctioncalculateITax() AsDouble

    EndInterface

    [Derived Class 1]

    PublicClassManagerInheritsEmployee

    ImplementsITaxInterface

    PublicFunctioncalculateITax() AsDoubleImplementsITaxInterface.calculateITaxReturn(basic * 0.05)

    EndFunctionEndClass

    [Derived Class 2]

    PublicClassEngineerInheritsEmployeeImplementsITaxInterface

    PublicFunctioncalculateITax() AsDoubleImplementsITaxInterface.calculateITaxReturn(basic * 0.02)

    EndFunctionEndClass

    [Main Program]

    ModuleModule1SubMain()

    Dimch AsInteger

    Console.WriteLine("1:Manager")Console.WriteLine("2:Engineer")Console.WriteLine("0:Exit")

    Console.WriteLine("Enter your choice:")ch = Convert.ToInt32(Console.ReadLine())DoWhilech 0

    SelectCasechCase1Dimm AsNewManager ' Creating an instance of Derived class

  • 8/12/2019 Jawaharlal Nehru Engineering College VB

    12/34

    12

    m.getEmpDetails() ' Calling members of Base class Employeem.getSalaryDetails()Console.WriteLine("Net Salary :"& m.calculateSalary()) Implementing Polymorphism

    Console.WriteLine("Income Tax :"& m.calculateITax()) 'Calling Interface method

    Case2Dime AsNewEngineer 'Creating an instance of Derived class

    e.getEmpDetails() ' Calling members of Base class Employeee.getSalaryDetails()

    Console.WriteLine("Net Salary :"& e.calculateSalary(4500)) ' ImplementingPolymorphism

    Console.WriteLine("Income Tax :"& e.calculateITax()) 'Calling Interface methodEndSelectConsole.WriteLine("1:Manager")Console.WriteLine("2:Engineer")Console.WriteLine("0:Exit")Console.WriteLine("Enter your choice:")ch = Convert.ToInt32(Console.ReadLine())

    LoopEndSub

    EndModule

  • 8/12/2019 Jawaharlal Nehru Engineering College VB

    13/34

    13

    4. Lab Exercises:

    [Purpose of this exercise is to use advance controls]

    Steps to follow:

    1) In FILE menu select NEW PROJECT.

    2) Give the name for Project AdvanceControls and click OK. Window with Form1.vbgets generated. Add second form Form2.vb also.

    3) Add the advance controls from toolbox.

    4) Set the properties of controls as below:

    Sr no Controls Properties Values

    1 Form1 Name

    Text

    frmAdvanceControls

    Advance Controls

    2 Form2 Name

    Text

    frmCricket

    Cricket Information

    3 TabControl1 Name TabControl1

    4 StatusStrip1 Name StatusStrip1

    5 Timer1 Name

    Interval

    Enabled

    Timer1

    100

    False

    6 TreeView1 Name TreeView1

    7 ProgressBar1 Name ProgressBar1

    5) Write code :

    To display date and time in status bar

    To show the progress in progress bar

    To show the full path of parent and child nodes of tree view.

    6) Build the Project and Execute by Start Debugging or by pressing F5.

    Exercise No4: ( 2 Hours) 1 Practical[Form 1]

    PublicClassfrmAdvanceControlsPrivateSubCricketToolStripMenuItem_Click(ByValsender AsSystem.Object, ByVale As

    System.EventArgs) HandlesCricketToolStripMenuItem.ClickfrmCricket.Show()

    EndSub

    PrivateSubfrmAdvanceControls_Load(ByValsender AsSystem.Object, ByVale AsSystem.EventArgs) HandlesMyBase.LoadTimer1.Enabled = True

    EndSub

    PrivateSubTimer1_Tick(ByValsender AsSystem.Object, ByVale AsSystem.EventArgs)HandlesTimer1.Tick

    TSSLblDateTime.Text = System.DateTime.Now 'displays date and time on status barEndSub

    EndClass

  • 8/12/2019 Jawaharlal Nehru Engineering College VB

    14/34

    14

    [Form 2]

    PublicClassfrmCricket

    PrivateSubTreeView1_AfterSelect(ByValsender AsSystem.Object, ByVale AsSystem.Windows.Forms.TreeViewEventArgs) HandlesTreeView1.AfterSelect

    txtPath.Text = TreeView1.SelectedNode.FullPath 'Shows the full path of node

    EndSub

    PrivateSubbtnShow_Click(ByValsender AsSystem.Object, ByVale AsSystem.EventArgs)HandlesbtnShow.Click

    ProgressBar1.Value = 1ProgressBar1.Maximum = 10000WhileProgressBar1.Value

  • 8/12/2019 Jawaharlal Nehru Engineering College VB

    15/34

    15

    5. Lab Exercises:

    [Purpose of this exercise is to use common dialog controls]

    Steps to follow:

    1) In FILE menu select NEW PROJECT.

    2) Give the name for Project CommonControls and click OK. Window with Form1.vb

    gets generated.

    3) Add Menu strip and Rich Textbox Controls from toolbox.

    4) Add the common dialog controls from toolbox.

    5) Set the properties of controls as below:

    Sr no Controls Properties Values

    1 Form1 Name

    Text

    frmCommonControls

    Common dialog Controls

    2 RichTextBox1 Name rtbContents

    6) Build the Project and Execute by Start Debugging or by pressing F5.

    Exercise No5: ( 2 Hours) 1 PracticalImportsSystem.IO

    PublicClassfrmCommonControlsInheritsSystem.Windows.Forms.Form

    Privatefilename AsStringDimsr AsStreamReader

    PrivateSubOpenToolStripMenuItem_Click(ByValsender AsSystem.Object, ByVale AsSystem.EventArgs) HandlesOpenToolStripMenuItem.Click

    TryWithOpenFileDialog1

    .Filter = "Text files(*.txt)|*.txt|"& "All files|*.*"If.ShowDialog() = DialogResult.OK Then

    filename = .FileName

    sr = NewStreamReader(.OpenFile)rtbContents.Text = sr.ReadToEnd()

    EndIfEndWith

    Catchex AsExceptionMsgBox(ex.Message)

    FinallyIfNot(sr IsNothing) Then

    sr.Close()EndIf

    EndTryEndSub

    PrivateSubSaveAsToolStripMenuItem_Click(ByValsender AsSystem.Object, ByVale AsSystem.EventArgs) HandlesSaveAsToolStripMenuItem.Click

    Dimsw AsStreamWriter

  • 8/12/2019 Jawaharlal Nehru Engineering College VB

    16/34

  • 8/12/2019 Jawaharlal Nehru Engineering College VB

    17/34

    17

    EndIfColorDialog1.Reset()'resetting all colors in the dialog box

    EndWith

    Catches AsExceptionMessageBox.Show(es.Message)

    EndTry

    EndSubEndClass

  • 8/12/2019 Jawaharlal Nehru Engineering College VB

    18/34

    18

    6. Lab Exercises:

    [Purpose of this exercise is show records from database to datagridview control]

    Steps to follow:

    1) In FILE menu select NEW PROJECT.

    2) Give the name for Project DataGridViewApplication and click OK. Window with

    Form1.vb gets generated.

    3) Add DataGridView and command button control from toolbox.

    4) Set the properties of controls as below:

    Sr no Controls Properties Values

    1 Form1 Name

    Text

    frmDataGrid

    DataGrid Application

    2 DataGridView1 Name dtgEmployee

    3 Button1 Name

    Text

    btnShow

    Show

    5) Build the Project and Execute by Start Debugging or by pressing F5.

    Exercise No6: ( 2 Hours) 1 Practical

    ImportsSystem.DataImportsSystem.Data.OleDb

    PublicClassfrmDataGrid

    Publiccon AsOleDbConnectionPublicda AsOleDbDataAdapterPublicds AsNewDataSet

    PrivateSubbtnShow_Click(ByValsender AsSystem.Object, ByVale AsSystem.EventArgs)HandlesbtnShow.Click

    Try'Establish connectioncon = NewOleDbConnection("Provider=MSDAORA;Data Source=XE;User

    ID=vikrant;Password=shaga")'Execute SQL Queryda = NewOleDbDataAdapter("Select * from Emp", con)'Fill datasetda.Fill(ds, "Emp")

    'Put data from dataset to datagridviewdtgEmployee.DataSource = ds.Tables(0)Catchex AsException

    MsgBox(ex.Message)EndTry

    EndSubEndClass

  • 8/12/2019 Jawaharlal Nehru Engineering College VB

    19/34

    19

    7. Lab Exercises:

    [Purpose of this exercise is Inserting, delete ting, update and Searching records from database]

    Steps to follow:

    1) In FILE menu select NEW PROJECT.2) Give the name for Project DatabaseApplication and click OK. Window with Form1.vb

    gets generated.

    3) Add Textboxes and command buttons from toolbox.

    4) Set the properties of controls as below:

    Sr no Controls Properties Values

    1 Form1 Name

    Text

    frmDepartment

    Database application

    2 TextBox1 Name txtDeptId

    3 TextBox2 Name txtDeptName

    4 Button1 Name

    Text

    btnAdd

    Add

    5 Button2 Name

    Text

    btnSave

    Save

    6 Button3 Name

    Text

    btnDelete

    Delete

    7 Button4 Name

    Text

    btnUpdate

    Update

    8 Button5 Name

    Text

    btnSearch

    Search

    5) Build the Project and Execute by Start Debugging or by pressing F5.

    Exercise No7: ( 2 Hours) 1 Practical

    ImportsSystem.DataImportsSystem.Data.OleDb

    PublicClassfrmDepartmentPubliccon AsOleDbConnectionPubliccmd AsOleDbCommandPublicdr AsOleDbDataReader

    Dimcount AsInteger= 100DimdeptNo AsStringPrivateSubfrmDepartment_Load(ByValsender AsSystem.Object, ByVale As

    System.EventArgs) HandlesMyBase.Load

    btnSave.Enabled = FalsebtnDelete.Enabled = FalsebtnUpdate.Enabled = FalseTry

    'Establish connectioncon = NewOleDbConnection("Provider=MSDAORA;Data Source=XE;User

    ID=vikrant;Password=shaga")Catchex AsException

    MsgBox(ex.Message)EndTry

  • 8/12/2019 Jawaharlal Nehru Engineering College VB

    20/34

    20

    EndSub

    PrivateSubbtnAdd_Click(ByValsender AsSystem.Object, ByVale AsSystem.EventArgs)HandlesbtnAdd.Click

    btnAdd.Enabled = FalsebtnSave.Enabled = TrueTry

    con.Open()cmd = NewOleDbCommand("Select Max(substr(dno,2,3)) from dept", con)count = cmd.ExecuteScalar()count += 1con.Close()

    Catchex AsExceptioncount += 1 'for adding first record Or to handle Null value exception

    EndTrytxtDeptId.Text = "D"& count

    EndSub

    PrivateSubbtnSave_Click(ByValsender AsSystem.Object, ByVale AsSystem.EventArgs)HandlesbtnSave.Click

    btnSave.Enabled = FalsebtnAdd.Enabled = TrueTry

    con.Open() 'Openning the connectioncmd = NewOleDbCommand("Insert into dept values('"& txtDeptId.Text & "','"&

    txtDeptName.Text & "')", con) 'Execute INSERT Querycmd.ExecuteNonQuery()MsgBox("Data Saved Successfully...")con.Close() 'Close the connection

    txtDeptId.Text = ""txtDeptName.Text = ""

    Catchex AsExceptionMsgBox(ex.Message)

    EndTryEndSub

    PrivateSubbtnSearch_Click(ByValsender AsSystem.Object, ByVale AsSystem.EventArgs)HandlesbtnSearch.Click

    btnDelete.Enabled = TruebtnUpdate.Enabled = True

    btnAdd.Enabled = FalsebtnSave.Enabled = FalsedeptNo = InputBox("Enter DeptNo to Search ")

    Trycon.Open()cmd = NewOleDbCommand("Select * from dept where dno='"& deptNo & "'", con) '

    Execute SELECT Querydr = cmd.ExecuteReader()Ifdr.Read Then

  • 8/12/2019 Jawaharlal Nehru Engineering College VB

    21/34

    21

    txtDeptId.Text = dr(0)txtDeptName.Text = dr(1)

    ElseMsgBox("Sorry no records found..")

    EndIfcon.Close()

    Catchex AsException

    MsgBox(ex.Message)EndTry

    EndSub

    PrivateSubbtnDelete_Click(ByValsender AsSystem.Object, ByVale AsSystem.EventArgs)HandlesbtnDelete.Click

    btnDelete.Enabled = FalsebtnUpdate.Enabled = FalsebtnAdd.Enabled = TruebtnSave.Enabled = TrueTry

    con.Open()cmd = NewOleDbCommand("Delete from dept where dno='"& txtDeptId.Text & "'", con)

    'Execute DELETE Querycmd.ExecuteNonQuery()MsgBox("Record Deleted Succesully...")txtDeptId.Text = ""txtDeptName.Text = ""con.Close()

    Catchex AsExceptionMsgBox(ex.Message)

    EndTry

    EndSub

    PrivateSubbtnUpdate_Click(ByValsender AsSystem.Object, ByVale AsSystem.EventArgs)HandlesbtnUpdate.Click

    btnDelete.Enabled = FalsebtnUpdate.Enabled = FalsebtnAdd.Enabled = TruebtnSave.Enabled = TrueTry

    con.Open()cmd = NewOleDbCommand("Update dept set dname='"& txtDeptName.Text & "' where

    dno='"& txtDeptId.Text & "'", con) 'Execute UPDATE Querycmd.ExecuteNonQuery()MsgBox("Record Updated Succesully...")

    con.Close()Catchex AsException

    MsgBox(ex.Message)EndTry

    EndSubEndClass

  • 8/12/2019 Jawaharlal Nehru Engineering College VB

    22/34

    22

    8. Lab Exercises:

    [Purpose of this exercise is to show records from database to crystal reports]

    Steps to follow:

    1) In FILE menu select NEW PROJECT.

    2) Give the name for Project CrystalReportApplication and click OK. Window with

    Form1.vb gets generated.3) Take combo box from toolbox on Form1.

    4) Fetch Department numbers from database in Combo box.

    5) Add Form2 and add CrystalReportViewer from toolbox on Form2.

    6) Choose the New Crystal report CrystalReport1.rpt.

    7) Attach the data source with CrystalReport1.rpt.

    8) Set the properties of controls as below:

    Sr no Controls Properties Values

    1 Form1 Name

    Text

    frmDepartment

    CrystalReport application

    2 ComboBox1 Name cmbDept

    3 Button1 Name

    Text

    btnShow

    Show4 Form2 Name frmDeptWiseReport

    5 CrystalReport1 Name deptWise

    9) Build the Project and Execute by Start Debugging or by pressing F5.

    Exercise No.8: ( 2 Hours) 1 Practical

    [form1]

    ImportsSystem.DataImportsSystem.Data.OleDb

    PublicClassfrmDepartmentPubliccon AsOleDbConnectionPubliccmd AsOleDbCommandPublicdr AsOleDbDataReaderDimcount AsInteger= 100DimdeptNo AsStringPrivateSubfrmDepartment_Load(ByValsender AsSystem.Object, ByVale As

    System.EventArgs) HandlesMyBase.LoadTry

    'Establish connectioncon = NewOleDbConnection("Provider=MSDAORA;Data Source=XE;User

    ID=vikrant;Password=shaga")Catchex AsException

    MsgBox(ex.Message)

    EndTryTry

    con.Open()cmd = NewOleDbCommand("Select * from dept", con) ' Execute SELECT Querydr = cmd.ExecuteReader()Whiledr.Read

  • 8/12/2019 Jawaharlal Nehru Engineering College VB

    23/34

    23

    cmbDept.Items.Add(dr(0))EndWhilecon.Close()

    Catchex AsException

    MsgBox(ex.Message)EndTry

    EndSub

    PrivateSubbtnShow_Click(ByValsender AsSystem.Object, ByVale AsSystem.EventArgs)HandlesbtnShow.Click

    frmDeptWiseReport.Show ()EndSub

    EndClass

    [form2]

    ImportsCrystalDecisions.CrystalReports.EngineImportsCrystalDecisions.ReportSourceImportsCrystalDecisions.Shared

    PublicClassfrmDeptWiseReport

    Publicmreport AsNewReportDocumentPublicstr AsStringPrivateSubfrmDeptWiseReport_Load(ByValsender AsSystem.Object, ByVale As

    System.EventArgs) HandlesMyBase.Loadstr = "{DEPT.DNO}='"& frmDepartment.cmbDept.SelectedItem & "'"mreport.Load("C:\Documents and Settings\Vicky\My Documents\Visual Studio 2008\VBNET

    Lab\Practical8\Practical8\singleDept.rpt")mreport.RecordSelectionFormula = strCrystalReportViewer1.ReportSource = mreport

    EndSubEndClass

  • 8/12/2019 Jawaharlal Nehru Engineering College VB

    24/34

    24

    9. Lab Exercises:

    [Purpose of this exercise is to design web application that uses validation controls]

    Steps to follow:

    1) In FILE menu select NEW WEBSITE.

    2) Give the name for Project RegistrationForm and click OK. Web form with Default.aspxgets generated.

    3) Take Server Controls from toolbox on WebForm1.

    4) Take Validation Controls from toolbox

    5) Add one more web form .Give name Default2.aspx for showing records of first form.

    6) Set the properties of controls as below:

    Sr no Controls Properties Values

    1 WebForm1 Name Default.aspx

    3 Button1 Name

    Text

    btnSubmit

    Submit

    4 TextBox1 Name txtUserName

    5 TextBox2 Name txtChoosePwd

    6 TextBox3 Name txtConfirmPwd

    7 TextBox4 Name txtEmail

    8 TextBox5 Name txtAge

    DropDownList1 Name Citydropdown

    9 RequiredFiledValidator1 Error Message*

    10 CompareValidator1 ErrorMessage Mismatch Password

    CustomValidator1 ErrorMessage

    ClientValidationFunction

    Please Select city

    CityValidate

    11 RangeValidator1 Error Message

    MinimumValue

    MaximumValue

    Type

    18-40

    18

    40

    Integer

    12 RegularExpressionValidator1 ErrorMessage

    ValidationExpression

    Invalid Email

    \w+([-

    +.']\w+)*@\w+([-

    .]\w+)*\.\w+([-

    .]\w+)*

    7) Browse with right clicking on default.aspx and selecting View in Browser

    Exercise No.9: ( 2 Hours) 1 Practical

    [default.aspx]

    Registration

  • 8/12/2019 Jawaharlal Nehru Engineering College VB

    25/34

    25

    functionCityValidate(ctl, args)

    {args.IsValid=(args.Value != "Select");}

    functionwindow_onload() {CityValidate ();}

    UserName :

    Choose Password :

    Confirm Password :

  • 8/12/2019 Jawaharlal Nehru Engineering College VB

    26/34

    26

    ControlToCompare="txtChoosePwd"ControlToValidate="txtConfirmPwd"ErrorMessage="Password Mismatch">

    Age:

    Email Id:

    City:

    SelectPuneMumbai

  • 8/12/2019 Jawaharlal Nehru Engineering College VB

    27/34

    27

    Inline code( Default.aspx.vb)PartialClass_Default

    InheritsSystem.Web.UI.PageProtectedSubButton1_Click(ByValsender AsObject, ByVale AsSystem.EventArgs) Handles

    Button1.ClickResponse.Write("Submitted successfully...")

    EndSubEndClass

  • 8/12/2019 Jawaharlal Nehru Engineering College VB

    28/34

    28

    10. Lab Exercises:

    [Purpose of this exercise is to design web application and insert, delete, update and search the

    data from database. Also provide proper validations]

    Steps to follow:

    1) In FILE menu select NEW WEBSITE.

    2) Give the name for Project RegistrationForm and click OK. Web form with Default.aspx

    gets generated.3) Take Server Controls from toolbox on WebForm1.

    4) Set the properties of controls as below:

    Sr no Controls Properties Values

    1 WebForm1 Name Default.aspx

    2 WebForm2 Name Default2.aspx

    3 Button1 Name

    Text

    btnSubmit

    Submit

    4 TextBox1 Name txtName

    5 TextBox2 Name txtChoosePwd

    6 TextBox3 Name txtConfirmPwd

    7 TextBox4 Name txtEmail8 TextBox5 Name txtPhno

    5) Create a database and connect to the database.

    6) Browse with right clicking on default.aspx and selecting View in Browser

    Exercise No.9: ( 2 Hours) 1 Practical[default.aspx]

    Student's Online Registration Form

    Candidate Name :

    Choose password :

  • 8/12/2019 Jawaharlal Nehru Engineering College VB

    29/34

  • 8/12/2019 Jawaharlal Nehru Engineering College VB

    30/34

    30

    [default.aspx.vb]

    ImportsSystem.DataImportsSystem.Data.OleDb

    PartialClass_DefaultInheritsSystem.Web.UI.Page

    Dimcon AsOleDbConnectionDimcmd AsOleDbCommandDimdr AsOleDbDataReader

    PublicSubgetConnection()Try

    con = NewOleDbConnection("Provider=MSDAORA;Data source=XE;UserID=vikrant;Password=shaga")

    Catchex AsExceptionResponse.Write("Error =>"& ex.Message)

    EndTryEndSub

    ProtectedSubbtnSearch_Click(ByValsender AsObject, ByVale AsSystem.EventArgs)HandlesbtnSearch.Click

    TrygetConnection()con.Open()cmd = NewOleDbCommand("Select * from registration where username='"&

    txtName.Text & "'", con)dr = cmd.ExecuteReader()

    Ifdr.Read ThentxtChoosePwd.Text = dr(1)txtConfirmPwd.Text = dr(1)txtEmail.Text = dr(2)txtPhno.Text = dr(3).ToString()

    ElseResponse.Write("No Records")

    EndIfcon.Close()

    Catchex AsExceptionResponse.Write("Error =>"& ex.Message)

    EndTryEndSub

    ProtectedSubbtnSubmit_Click1(ByValsender AsObject, ByVale AsSystem.EventArgs)HandlesbtnSubmit.Click

    TrygetConnection()con.Open()

  • 8/12/2019 Jawaharlal Nehru Engineering College VB

    31/34

    31

    cmd = NewOleDbCommand("Insert into registration values ('"& txtName.Text & "','"&txtConfirmPwd.Text & "','"& txtEmail.Text & "',"& Convert.ToInt64(txtPhno.Text) & ")", con)

    cmd.ExecuteNonQuery()Response.Write("Inserted successfully....")

    con.Close()Catchex AsException

    Response.Write("Error =>"& ex.Message)

    EndTryEndSub

    ProtectedSubbtnUpdate_Click(ByValsender AsObject, ByVale AsSystem.EventArgs)HandlesbtnUpdate.Click

    TrygetConnection()con.Open()cmd = NewOleDbCommand("Update registration set username='"& txtName.Text &

    "',pwd='"& txtConfirmPwd.Text & "',email='"& txtEmail.Text & "',phNo="&Convert.ToInt64(txtPhno.Text) & "where username='"& txtName.Text & "'", con)

    cmd.ExecuteNonQuery()Response.Write("Updated successfully....")

    con.Close()Catchex AsException

    Response.Write("Error=>"& ex.Message)EndTry

    EndSub

    ProtectedSubbtnDelete_Click(ByValsender AsObject, ByVale AsSystem.EventArgs) HandlesbtnDelete.Click

    Try

    getConnection()con.Open()cmd = NewOleDbCommand("Delete from registration where username='"& txtName.Text

    & "'", con)cmd.ExecuteNonQuery()Response.Write("Deleted successfully....")con.Close()

    Catchex AsExceptionResponse.Write("Error=>"& ex.Message)

    EndTrytxtName.Text = ""

    txtConfirmPwd.Text = ""txtChoosePwd.Text = ""txtEmail.Text = ""

    txtPhno.Text = ""EndSub

    EndClass

  • 8/12/2019 Jawaharlal Nehru Engineering College VB

    32/34

    32

    4. Quiz on the subject:

    Quiz should be conducted on tips in the laboratory, recent trends and subject knowledge of thesubject. The quiz questions should be formulated such that questions are normally are from the

    scope outside of the books. However twisted questions and self formulated questions by thefaculty can be asked but correctness of it is necessarily to be thoroughly checked before theconduction of the quiz.

    5. Conduction of Viva-Voce Examinations:

    Teacher should oral exams of the students with full preparation. Normally, the objective questionswith guess are to be avoided. To make it meaningful, the questions should be such that depth ofthe students in the subject is tested Oral examinations are to be conducted in co-cordialenvironment amongst the teachers taking the examination. Teachers taking such examinations

    should not have ill thoughts about each other and courtesies should be offered to each other in

    case of difference of opinion, which should be critically suppressed in front of the students.

    6. Submission:

    Document Standard:A] Page Size A4 SizeB] Running text Justified textC] Spacing 1 LineD] Page Layout and Margins (Dimensions in Cms)

    Normal Page Horizantal

    2.0

    2.5

    2.02.5 2.0

    2.0

    0.7

    0.72.0

    2.0

  • 8/12/2019 Jawaharlal Nehru Engineering College VB

    33/34

    33

    Desription Font Size Boldness Italics Underline Capitalize

    College Name Arial 24 ----- ------ Yes ----------

    Document Title Tahoma 22 ----- ------ --------- ----------Document Subject Century Gothic 14 ----- ------ --------- Capital

    Class Bookman old Slyle 12 ----- ------ --------- ----------

    Document No Bookman old Slyle 10 ----- ------ --------- ----------

    Copy write inf Bookman old Slyle 9 ----- ------ --------- ----------

    Forward heading Bookman old Slyle 12 ----- ------ Yes Capital

    Forward matter Bookman old Slyle 12 ----- ------ --------- ----------

    Lab man Contents title Bookman old Slyle 12 ----- ------ Yes Capital

    Index title Bookman old Slyle 12 Yes ------ Yes Capital

    Index contents Bookman old Slyle 12 ----- ------ --------- ----------

    Heading Tahoma 14 Yes Yes Yes ----------Running Matter Comic Sans MS 10 ----- ------ --------- ----------

    7. Evaluation and marking system:

    Basic honesty in the evaluation and marking system is absolutely essential and in the processimpartial nature of the evaluator is required in the examination system to become popular amongstthe students. It is a wrong approach or concept to award the students by way of easy marking toget cheap popularity among the students to which they do not deserve. It is a primaryresponsibility of the teacher that right students who are really putting up lot of hard work withright kind of intelligence are correctly awarded.

    The marking patterns should be justifiable to the students without any ambiguity and teachershould see that students are faced with unjust circumstances.

  • 8/12/2019 Jawaharlal Nehru Engineering College VB

    34/34