Create Student Registration Number Entry Form in VB.NET with Source Code Part 34
Hello Everyone ....
Create a new window Form that named is Student Registration Number Entry Form in VB.NET with Source Code Part 34
Create a new window Form that named is Student Registration Number Entry Form in VB.NET with Source Code Part 34
Step-1 First watch my video for Designing Window Form
Step-2 SQL Server Database Query for Creating Tables:
 Open your SQL Server database and copy & paste following sql query code .
       
 create table Tbl_Regno 
(
Adno int,
regno int,
name nvarchar(50),
course nvarchar(50),
class nvarchar(50)
)
select * from Tbl_Regno
select * from Tbl_Feespayment
create table Tbl_Feespayment
(
course nvarchar(50),
year int,
regno int,
name nvarchar(50),
donation   nvarchar(50),
tuition  nvarchar(50),
fees_amt  nvarchar(50),
con_amt  nvarchar(50),
tot_fee  nvarchar(50),
paid  nvarchar(50),
balance   nvarchar(50),
pay_type    nvarchar(50)
)
       
 
Step-3 After that write Following VB.NET Code:
   Follow step-1 for creating Form design and after that crate table using step-2 then write below displayed source code.
       
             Imports System.Data.SqlClient
Imports System.Data
Public Class RegNum
    Private Sub RegNum_Load(sender As Object, e As EventArgs) Handles MyBase.Load
‘Form load event code bind course combobox     
  connection_open()
        qry = "select C_Name from Tbl_crs"
        cmd = New SqlCommand(qry, cnn)
        dr = cmd.ExecuteReader
        Do While dr.Read = True
            cmbcourse.Items.Add(dr(0).ToString)
        Loop
        connection_close()
    End Sub
    Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
‘OK Button code      
 Panel1.Visible = False
        GridView.Visible = False
        view1()
    End Sub
    Sub view1()
‘Procedure used to show value in Gridview control
        Panel1.Visible = True
        Grid.Visible = True
        connection_close()
        connection_open()
        qry = "select Adno,Name from Tbl_std1 where Course='" & cmbcourse.Text & "' and Class=" & cmbclass.Text & " and Status='false'"
        Dim dd As New DataSet
        adp = New SqlDataAdapter(qry, cnn)
        adp.Fill(dd, "Tbl_std1")
        Grid.DataSource = dd
        Grid.DataMember = dd.Tables(0).ToString
        connection_close()
    End Sub
    Sub view2()
‘Procedure used to show value in another Gridview control
        Panel3.Visible = True
        GridView.Visible = True
        connection_open()
        qry = "select * from Tbl_Regno where course='" & cmbcourse.Text & "'and class=" & cmbclass.Text & ""
        adp = New SqlDataAdapter(qry, cnn)
        Dim ds1 As New DataSet
        adp.Fill(ds1, "Tbl_Regno")
        GridView.DataSource = ds1
        GridView.DataMember = ds1.Tables(0).ToString
        connection_close()
    End Sub
    Private Sub Btnadd_Click(sender As Object, e As EventArgs) Handles btnadd.Click
‘Add button code      
 Dim i As Integer
        connection_open()
        Dim qry2 As String
        qry2 = "select donation,tuition,special,total from Tbl_Fees where course='" & cmbcourse.Text & "' and year=" & cmbclass.Text & ""
        cmd = New SqlCommand(qry2, cnn)
        Dim dr1 As SqlDataReader
        dr1 = cmd.ExecuteReader
        Dim don = 0, tun = 0, spl = 0, tot = 0
        If dr1.Read = True Then
            don = dr1(0).ToString
            tun = dr1(1).ToString
            spl = dr1(2).ToString
            tot = dr1(3).ToString
        End If
        dr1.Close()
        cmd = New SqlCommand("select * from Tbl_Regno where Adno=" & txtadno.Text & "", cnn)
        dr = cmd.ExecuteReader
        If dr.Read = False Then
            dr.Close()
            qry1 = "insert into Tbl_Regno (Adno,regno,name,course,class) values (" & txtadno.Text & "," & txtnum.Text & ", '" & txtname.Text & "', '" & cmbcourse.Text & "'," & cmbclass.Text & ")"
            cmd1 = New SqlCommand(qry1, cnn)
            cmd1.ExecuteNonQuery()
            MsgBox(" Record insereted Successfully", MsgBoxStyle.MsgBoxRight, "Office Automation")
            Dim qry3 As String
            qry3 = "Insert into Tbl_Feespayment(course,year,regno,name,donation,tuition,fees_amt,con_amt,tot_fee,paid,balance,pay_type) values('" &
            cmbcourse.Text & "'," & cmbclass.Text & "," & txtnum.Text & ",'" & txtname.Text & "'," & don & "," & tun & "," & spl & ",0," & tot & ",0, " & tot & ",'Unpaid')"
            cmd1 = New SqlCommand(qry3, cnn)
            i = cmd1.ExecuteNonQuery()
            If i = 1 Then
                MessageBox.Show("Executed")
            Else
                MessageBox.Show("error")
            End If
            Dim ds1 As New DataSet
            qry = "select * from Tbl_Regno where course='" & cmbcourse.Text & "' and class=" & cmbclass.Text & ""
            adp = New SqlDataAdapter(qry, cnn)
            adp.Fill(ds1, "Tbl_Regno")
            Panel3.Visible = True
            GridView.Visible = True
            GridView.DataSource = ds1
            GridView.DataMember = ds1.Tables(0).ToString
            cmbcourse.Focus()
            connection_close()
        Else
            MsgBox("Record already exists", MsgBoxStyle.Information, "Office Automation")
            cmbcourse.Focus()
            connection_close()
        End If
        connection_close()
    End Sub
    Private Sub Grid_DoubleClick(sender As Object, e As EventArgs) Handles Grid.DoubleClick
        Dim a
        a = Grid.CurrentRow.Index
        txtadno.Text = Grid.Item(0, a).Value.ToString
        txtname.Text = Grid.Item(1, a).Value.ToString
    End Sub
    Private Sub GridView_DoubleClick(sender As Object, e As EventArgs) Handles GridView.DoubleClick
        Dim a
        a = GridView.CurrentRow.Index
        txtnum.Text = GridView.Item(0, a).Value.ToString
        txtname.Text = GridView.Item(1, a).Value.ToString
    End Sub
    Private Sub Btnview_Click(sender As Object, e As EventArgs) Handles btnview.Click
        Panel1.Visible = False
        Grid.Visible = False
        view2()
    End Sub
    Private Sub Txtnum_KeyPress(sender As Object, e As KeyPressEventArgs) Handles txtnum.KeyPress
        If Char.IsLetter(e.KeyChar) Or Char.IsPunctuation(e.KeyChar) Then
            e.Handled = True
        Else
            If Len(txtnum.Text) < 25 Or Char.IsControl(e.KeyChar) Then
                e.Handled = False
            Else
                e.Handled = True
            End If
        End If
    End Sub
    Private Sub Btnreset_Click(sender As Object, e As EventArgs) Handles btnreset.Click
        txtnum.Clear()
        txtname.Clear()
        txtadno.Clear()
    End Sub
End Class
       
 
 
 
 
 
No comments:
Post a Comment