Vous êtes sur la page 1sur 9

customer

Option Explicit
Dim con As New ADODB.Connection
Dim rs As New Recordset
Private Sub Form_Load()
'Frame1.Move (Screen.Width - Frame1.Width) / 2, (Screen.Height - Frame1.Height)
/ 2
Combo1.AddItem "Saving"
Combo1.AddItem "Current"

If con.State = 1 Then
con.Close
End If
con.Open "Provider=MSDAORA.1;Password=tiger;User ID=scott;Persist Security I
nfo=True"
End Sub
Private Sub Label3_Click()
End Sub
Private Sub Frame1_DragDrop(Index As Integer, Source As Control, X As Single, Y
As Single)
End Sub
Private Sub okk_Click(Index As Integer)
If Text1 = "" Then
MsgBox "Please Enter Name ", vbExclamation ', Title
Text1.SetFocus
Exit Sub
End If

If Text2 = "" Then
MsgBox "Please enter Father Name ", vbExclamation ', Title
Text2.SetFocus
Exit Sub
End If

If Text3 = "" Then
MsgBox "Please enter Address name", vbExclamation ', Title
Text3.SetFocus
Exit Sub
End If

If Text5 = "" Then
MsgBox "Please Enter Contact id", vbExclamation '', Title
Text5.SetFocus
Exit Sub
End If
If Text6 = "" Then
MsgBox "Please Enter Cnic", vbExclamation ', Title
Text6.SetFocus
Exit Sub
End If

If Text7 = "" Then
MsgBox "Please enter account no", vbExclamation ', Title
Text7.SetFocus
Exit Sub
End If
If Combo1.ListIndex = -1 Then
MsgBox "Please enter account type", vbExclamation ', Title
Combo1.SetFocus
Exit Sub
End If
If Text9 = "" Then
MsgBox "Please enter Balance", vbExclamation ', Title
Text9.SetFocus
Exit Sub
End If

'''''''''''''''
Dim var2 As Integer
If rs.State = 1 Then '
rs.Close
End If
rs.Open "select * from Customer", con, adOpenDynamic, adLockOptimistic
If rs.RecordCount = 0 Then
var2 = 1
Else
While rs.EOF = False
If rs!customer_id > var2 Then
var2 = rs!customer_id
End If
rs.MoveNext
Wend
var2 = var2 + 1
End If
If rs.State = 1 Then
rs.Close
End If
'''''''''''''''''''''
rs.Open "select * From account where account_id='" & Text7.Text & "'", con, adO
penDynamic, adLockOptimistic
If rs.BOF = True And rs.EOF = True Then
If rs.State = 1 Then
rs.Close
End If
rs.Open "insert into account values('" & Text7.Text & "'," & Text9.Text & ",'" &
Combo1.Text & "')", con, adOpenDynamic, adLockOptimistic
Else
MsgBox "This Account_id already exists"
End If
'''''''''''''''''

If rs.State = 1 Then
rs.Close
End If
rs.Open "insert into customer values('" & Text1.Text & "','" & Text2.Text & "','
" & Text6.Text & "','" & Text5.Text & "','" & Text3.Text & "',sysdate, " & var2
& ",'" & Text7.Text & "')", con, adOpenDynamic, adLockOptimistic
Text1.Text = ""
Text2.Text = ""
Text3.Text = ""
Text4.Text = ""
Text5.Text = ""
Text6.Text = ""
Text7.Text = ""
Text8.Text = ""
Text9.Text = ""
Text10.Text = ""
Text1.SetFocus
End Sub
Private Sub quit_Click(Index As Integer)
Unload Me
End Sub
Private Sub Text1_KeyPress(keyascii As Integer)
If keyascii = 8 Then Exit Sub
Select Case keyascii
Case vbKey0 To vbKey9
keyascii = 0
End Select
End Sub
Private Sub Text2_KeyPress(keyascii As Integer)
If keyascii = 8 Then Exit Sub
Select Case keyascii
Case vbKey0 To vbKey9
keyascii = 0
End Select
End Sub
Private Sub Text7_KeyPress(keyascii As Integer)
If keyascii = 8 Then Exit Sub
If (keyascii < 48 Or keyascii > 57) Then
MsgBox "Please enter only digits."
keyascii = 0
End If
Text7.SetFocus
End Sub
Private Sub text5_KeyPress(keyascii As Integer)
If keyascii = 8 Then Exit Sub
If (keyascii < 48 Or keyascii > 57) Then
MsgBox "Please enter only digits."
keyascii = 0
End If
Text5.SetFocus
End Sub
Private Sub text6_KeyPress(keyascii As Integer)
If keyascii = 8 Then Exit Sub
If (keyascii < 48 Or keyascii > 57) Then
MsgBox "Please enter only digits."
keyascii = 0
End If
Text6.SetFocus
End Sub
Private Sub text9_KeyPress(keyascii As Integer)
If keyascii = 8 Then Exit Sub
If (keyascii < 48 Or keyascii > 57) Then
MsgBox "Please enter only digits."
keyascii = 0
End If
Text9.SetFocus
End Sub
////////////////////////////////////////////////////////////////////////////////
/////////////////////////////////
login
Dim con As New ADODB.Connection
Dim rsLogin As New ADODB.Recordset
Private Sub Command1_Click()
' Validation for user name
If Text1.Text = "" Then
MsgBox "Please enter UserName."
Text1.SetFocus
Exit Sub
End If
'Validation for Password
If Text2.Text = "" Then
MsgBox "Please enter password."
Text2.SetFocus
Exit Sub
End If
If rsLogin.State = 1 Then
rsLogin.Close
End If
rsLogin.Open "SELECT * FROM operator WHERE Username='" & Text1.Text & "' ", con,
adOpenKeyset, adLockOptimistic
If rsLogin.BOF = True And rsLogin.EOF = True Then
MsgBox "Invalid User"

'Clear all the controls and set default values.

Text1.Text = ""
Text2.Text = ""
Text1.SetFocus
Exit Sub
ElseIf Text1.Text = rsLogin("Username") And Text2.Text = rsLogin("Password") The
n
' Enabled all menu controls.
Main.mnlogout.Enabled = True
Main.mnlogin.Enabled = False
Main.mnadministrator.Enabled = True
Main.mntransaction.Enabled = True
Main.mnloan.Enabled = True
Main.mnhelp.Enabled = True
Main.mnbranch.Enabled = True
Main.mnaddoperator.Enabled = True
Main.Show
Unload Me
Else
'Clear all the controls and set default values.

Text1.Text = ""
Text2.Text = ""
Text1.SetFocus
Text2.SetFocus
MsgBox "Either User Name or Password is Incorrect."
Exit Sub
End If
Set rsLogin = Nothing
End Sub
Private Sub Command2_Click()
Dim a As String
a = MsgBox("Are you sure to exit", vbYesNo, "Confirm")
If a = vbYes Then
Unload Me
End If
End Sub
Private Sub Form_Load()
Frame1.Move (Screen.Width - Frame1.Width) / 2, (Screen.Height - Frame1.Height) /
2
If con.State = 1 Then
con.Close
End If
con.Open "Provider=MSDAORA.1;Password=tiger;User ID=scott;Persist Security Info=
True"
End Sub
////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////
operator
Dim con As New ADODB.Connection
Dim rs As New ADODB.Recordset
Private Sub Command1_Click()
'Validation for New user name.
If (Len(Trim(Text1.Text)) = 0) Then
MsgBox "First enter the User Name", vbInformation, "Username"
Text1.SetFocus
Exit Sub
End If
'Validation for the password.
If (Len(Trim(Text2.Text)) = 0) Then
MsgBox "First enter the Password", vbInformation, "Password"
Text2.SetFocus
Exit Sub
End If
'Validation to confirm the password.
If (Len(Trim(Text3.Text)) = 0) Then
MsgBox "Please Confirm the Password", vbInformation, "Password"
Text3.SetFocus
Exit Sub
End If
rs.Open "SELECT * FROM operator WHERE Username='" & Text1.Text & "'", con, adOpe
nDynamic, adLockOptimistic
If rs.BOF = True And rs.EOF = True Then

If Trim(Text2.Text) = Trim(Text3.Text) Then

' To Insert new user details.

If rs.State = 1 Then
rs.Close
End If
rs.Open "INSERT INTO operator VALUES('" & Text1.Text & "','" & Text2.Text & "'
)", con, adOpenDynamic, adLockOptimistic

MsgBox "The new user is saved."

' Clear all the controls and set the default values.

Text1.Text = ""
Text2.Text = ""
Text3.Text = ""
Text1.SetFocus
Else
MsgBox "Re-type password again!"

' Clear all the controls and set the default values.
Text2.Text = ""
Text3.Text = ""
Text2.SetFocus
End If
Else
MsgBox "This user already exists"

' Clear all the controls and set the default values.

Text1.Text = ""
Text2.Text = ""
Text3.Text = ""
Text1.SetFocus
End If
Set rs = Nothing

End Sub
Private Sub Command2_Click()
Dim a As String
a = MsgBox("Are you sure to exit", vbYesNo, "Confirm")
If a = vbYes Then
Unload Me
End If
End Sub
Private Sub Form_Load()
Frame1.Move (Screen.Width - Frame1.Width) / 2, (Screen.Height - Frame1.Height) /
2
If con.State = 1 Then
con.Close
End If
con.Open "Provider=MSDAORA.1;Password=tiger;User ID=scott;Persist Security Info=
True"
End Sub
////////////////////////////////////////////////////////////////////////////////
all cus
Option Explicit
Dim con As New ADODB.Connection
Dim rs As New ADODB.Recordset
Private Sub addnew_Click(Index As Integer)
Load customeer
customeer.Show
End Sub
Private Sub Command1_Click()
rs.MovePrevious
If rs.BOF = True Then
rs.MoveFirst
Else
Text1.Text = rs!Name
Text2.Text = rs!fname
Text3.Text = rs!cnic
Text4.Text = rs!address
Text5.Text = rs!phone
Text6.Text = rs!customer_id
Text7.Text = rs!dob
Text8.Text = rs!account_id
Text9.Text = rs!account_type
Text10.Text = rs!amount
End If
End Sub
Private Sub Command2_Click()
rs.MoveFirst
Text1.Text = rs!Name
Text2.Text = rs!fname
Text3.Text = rs!cnic
Text4.Text = rs!address
Text5.Text = rs!phone
Text6.Text = rs!customer_id
Text7.Text = rs!dob
Text8.Text = rs!account_id
Text9.Text = rs!account_type
Text10.Text = rs!amount
End Sub
Private Sub Command3_Click()
rs.MoveNext
If rs.EOF = True Then
rs.MoveLast
Else
Text1.Text = rs!Name
Text2.Text = rs!fname
Text3.Text = rs!cnic
Text4.Text = rs!address
Text5.Text = rs!phone
Text6.Text = rs!customer_id
Text7.Text = rs!dob
Text8.Text = rs!account_id
Text9.Text = rs!account_type
Text10.Text = rs!amount
End If
End Sub
Private Sub Command4_Click()
rs.MoveNext
If rs.EOF = True Then
rs.MoveLast
Text1.Text = rs!Name
Text2.Text = rs!fname
Text3.Text = rs!cnic
Text4.Text = rs!address
Text5.Text = rs!phone
Text6.Text = rs!customer_id
Text7.Text = rs!dob
Text8.Text = rs!account_id
Text9.Text = rs!account_type
Text10.Text = rs!amount
End If
End Sub
Private Sub delete_Click(Index As Integer)
If rs.State = 1 Then
rs.Close
End If
Dim str As String
str = "Delete from customer where account_id = '" & Text8.Text & "'"
MsgBox str
rs.Open str, con, adOpenDynamic, adLockOptimistic
MsgBox "Department deleted from database"
If rs.State = 1 Then
rs.Close
End If
Dim str2 As String
str2 = "Delete from account where account_id = '" & Text8.Text & "'"
rs.Open str, con, adOpenDynamic, adLockOptimistic
End Sub
Private Sub eit_Click(Index As Integer)
Unload Me
End Sub
Private Sub Form_Load()
Frame5.Move (Screen.Width - Frame5.Width) / 2, (Screen.Height - Frame5.Height) /
2
If con.State = 1 Then
con.Close
End If
con.Open "Provider=MSDAORA.1;Password=tiger;User ID=scott;Persist Security Info=
True"
If rs.State = 1 Then
rs.Close
End If
rs.Open "select * from customer,account where customer.account_id=account.accoun
t_id", con, adOpenDynamic, adLockOptimistic
Text1.Text = rs!Name
Text2.Text = rs!fname
Text3.Text = rs!cnic
Text4.Text = rs!address
Text5.Text = rs!phone
Text6.Text = rs!customer_id
Text7.Text = rs!dob
Text8.Text = rs!account_id
Text9.Text = rs!account_type
Text10.Text = rs!amount
End Sub

Vous aimerez peut-être aussi