Dot Net Framework
A) Write a VB.NET program to design following screen, accept the details from the user. Clicking on Submit button Net Salary should be calculated and displayed into the Textbox. Display the Messagebox informing the Name and Net Salary of employee.
Answer :
Public Class Form1
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
Label10.Text =
(Int(TextBox2.Text) + Int(TextBox3.Text) + Int(TextBox4.Text) +
Int(TextBox5.Text) + Int(TextBox6.Text) + Int(TextBox7.Text) +
Int(TextBox8.Text))
Label12.Text =
Int(TextBox6.Text) + Int(TextBox7.Text) + Int(TextBox8.Text)
Label14.Text = Label10.Text -
Label12.Text
MessageBox.Show("Employee Name : "
& TextBox1.Text & Environment.NewLine & "Total Salary is : " & Label14.Text)
End Sub
Private Sub TextBox2_Leave(sender As Object, e As EventArgs) Handles TextBox2.Leave
TextBox3.Text =
(TextBox2.Text * 31) / 100
TextBox4.Text =
(TextBox2.Text * 9) / 100
End Sub
End Class
Output :
B)
Write a VB.NET program to accept the details Supplier (SupId, SupName, Phone
No,
Address) store it into the database and display it.
Answer :
Imports System.Data.OleDb
Public Class Form1
Dim con As New OleDbConnection("Provider=Microsoft.ACE.OLEDB.12.0;Data
Source=C:\Users\Saurabh\Desktop\New folder\Supplier.accdb")
Dim adpt As New OleDbDataAdapter("Select
* from Supplier", con)
Dim cmd As New OleDbCommand
Dim ds As New DataSet
Public Function display()
adpt.Fill(ds, "Supplier")
DataGridView1.DataSource = ds
DataGridView1.DataMember = "Supplier"
Return ds
End Function
Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
display()
End Sub
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
cmd.Connection = con
cmd.CommandType = CommandType.Text
cmd.CommandText = "insert into Supplier values(" & TextBox1.Text & ",'" & TextBox2.Text & "'," & TextBox3.Text & ",'" & TextBox4.Text & "')"
con.Open()
If cmd.ExecuteNonQuery() Then
MessageBox.Show("Inserted Successfully...!")
End If
con.Close()
ds.Clear()
display()
End Sub
End Class
Output :
No comments:
Post a Comment