Prog 9

You might also like

Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 6

ELECTRICITY BILLING

DECLARATION:
Dim cn As ADODB.Connection
Dim rs As ADODB.Recordset
Dim i As Integer
Dim j As Integer
INSERT:
Private Sub Command1_Click()
If (Text1.Text = " ") Or (Text2.Text = " ") Or (Text3.Text = " ") Or (Text4.Text = " ") Or
(Text5.Text = " ") Or (Text6.Text = " ") Or (Text7.Text = " ") Then
MsgBox ("enter the data")
Else
cn.Execute ("insert into eb values('" & Val(Text1.Text) & "','" & (Text2.Text) & "','" &
(Text3.Text) & "','" & Val(Text4.Text) & "','" & Val(Text5.Text) & "','" & Val(Text6.Text) &
"','" & Val(Text7.Text) & "')")
MsgBox ("inserted")
End If
End Sub

DELETE:
Private Sub Command2_Click()
i = InputBox("enter the deleted value")
cn.Execute ("select*from eb where customerid='" & Val(i) & "'")
Text1.Text = rs(0)
Text2.Text = rs(1)
Text3.Text = rs(2)
Text4.Text = rs(3)
Text5.Text = rs(4)
Text6.Text = rs(5)
Text7.Text = rs(6)
cn.Execute ("delete from eb where customerid=('" & Val(i) & "')")
MsgBox ("deleted")
End Sub

MODIFY:
Private Sub Command3_Click()
j = InputBox("enter the cutomerid")
cn.Execute ("select* from eb where customerid=('" & Val(j) & "')")
rs.Find "customerid=" & Str(j)
If (rs.EOF) Then
MsgBox ("record not found")
Else
Text1.Text = rs(0)
Text2.Text = rs(1)
Text3.Text = rs(2)
Text4.Text = rs(3)
Text5.Text = rs(4)
Text6.Text = rs(5)
Text7.Text = rs(6)
End If
Command3.Enabled = False
End Sub

UPDATE:
Private Sub Command4_Click()
cn.Execute ("update eb set customerid='" & Val(Text1.Text) & "' where customerid='" &
Val(Text1.Text) & "'")
cn.Execute ("update eb set customerid='" & Val(Text2.Text) & "' where customerid='" &
Val(Text1.Text) & "'")
cn.Execute ("update eb set customerid='" & Val(Text3.Text) & "' where customerid='" &
Val(Text1.Text) & "'")
cn.Execute ("update eb set customerid='" & Val(Text4.Text) & "' where customerid='" &
Val(Text1.Text) & "'")
cn.Execute ("update eb set customerid='" & Val(Text5.Text) & "' where customerid='" &
Val(Text1.Text) & "'")
cn.Execute ("update eb set customerid='" & Val(Text6.Text) & "' where customerid='" &
Val(Text1.Text) & "'")
cn.Execute ("update eb set customerid='" & Val(Text7.Text) & "' where customerid='" &
Val(Text1.Text) & "'")
MsgBox ("updated")
Command4.Enabled = True
End Sub

REPORT:
Private Sub Command5_Click()
DataReport1.Show
End Sub

EXIT:
Private Sub Command6_Click()
Unload Me
End Sub

FORM LOAD:
Private Sub Form_Load()
Set cn = New ADODB.Connection
Set rs = New ADODB.Recordset
cn.Open ("Provider=MSDAORA.1;Password=tiger;User ID=scott;Persist Security Info=True")
rs.Open ("select*from eb"), cn, adOpenDynamic
End Sub
CALCULATION:
Private Sub Text6_GotFocus()
Text6.Text = Val(Text5.Text) - Val(Text4.Text)
End Sub

Private Sub Text7_GotFocus()


If (Text6.Text) < 500 Then
Text7.Text = Val(Text6.Text) * 2
Else
If (Text6.Text) > -500 Then
Text7.Text = Val(Text6.Text) * 5
Else
If (Text6.Text) > 1000 Then
Text6.Text = Val(Text6.Text) * 10
End If
End If
End If
End Sub
ELECTRICITY BILLING

INSERT

DELETE
REPORT:

You might also like