0% found this document useful (0 votes)
14 views

Public Class FRM

This document contains the code for a Windows form application that allows users to view, add, update, and delete records in a point system table in a SQL database. The form initializes database connections and clears fields on load and button clicks. It retrieves and displays records from the point table, allows adding new records, updating and deleting existing records based on a point code field.

Uploaded by

anand_gsoft3603
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
14 views

Public Class FRM

This document contains the code for a Windows form application that allows users to view, add, update, and delete records in a point system table in a SQL database. The form initializes database connections and clears fields on load and button clicks. It retrieves and displays records from the point table, allows adding new records, updating and deleting existing records based on a point code field.

Uploaded by

anand_gsoft3603
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 2

Public Class Frm_Point

Dim cn As New ADODB.Connection


Dim rs As New ADODB.Recordset
Private Sub Frm_Point_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
cn = New ADODB.Connection
cn.Open("Provider=SQLOLEDB;Data Source=.;Integrated Security=SSPI;Initial Catalog=collegesocial")
Call clear()
End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Call clear()
End Sub
Public Sub clear()
ps_code.Text = ""
ps_name.Text = ""
points_allot.Text = ""
lv1.Items.Clear()
rs = New ADODB.Recordset
rs.Open("Select * from pointtable", cn, 1, 2)
If rs.EOF = True Then
Else
Dim i As Integer
i=0
While Not rs.EOF
lv1.Items.Add(rs.Fields(0).Value)
lv1.Items(i).SubItems.Add(rs.Fields(1).Value)
lv1.Items(i).SubItems.Add(rs.Fields(2).Value)
i=i+1
rs.MoveNext()
End While
End If
rs.Close()
End Sub
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
rs = New ADODB.Recordset
rs.Open("Select * from pointtable", cn, 1, 2)
rs.AddNew()
rs.Fields(0).Value = ps_code.Text
rs.Fields(1).Value = ps_name.Text
rs.Fields(2).Value = points_allot.Text
rs.Update()
rs.Close()
MsgBox("New Point System Added", MsgBoxStyle.Information)
Call clear()
End Sub
Private Sub lv1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles lv1.Click
ps_code.Text = lv1.SelectedItems(0).Text
ps_name.Text = lv1.SelectedItems(0).SubItems(1).Text
points_allot.Text = lv1.SelectedItems(0).SubItems(2).Text
End Sub
Private Sub lv1_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles
lv1.SelectedIndexChanged

End Sub
Private Sub Button4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button4.Click
rs = New ADODB.Recordset
rs.Open("Select * from pointtable where ps_code = " & ps_code.Text & "", cn, 1, 2)
If rs.EOF = True Then Exit Sub
rs.Fields(0).Value = ps_code.Text
rs.Fields(1).Value = ps_name.Text
rs.Fields(2).Value = points_allot.Text
rs.Update()
rs.Close()
MsgBox("Existing Point System Updated", MsgBoxStyle.Information)
Call clear()
End Sub
Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click
rs = New ADODB.Recordset
rs.Open("Delete from pointtable where ps_code = " & ps_code.Text & "", cn, 1, 2)
MsgBox("Existing Point System Deleted", MsgBoxStyle.Information)
Call clear()
End Sub
Private Sub Button5_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button5.Click
rs = New ADODB.Recordset
rs.Open("Select * from pointtable where ps_code = " & ps_code.Text & "", cn, 1, 2)
If rs.EOF = True Then Exit Sub
ps_code.Text = rs.Fields(0).Value
ps_name.Text = rs.Fields(1).Value
points_allot.Text = rs.Fields(2).Value
rs.Close()
End Sub
Private Sub Button6_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button6.Click
Me.Close()
End Sub
End Class

You might also like