18-10-2016, 04:01 PM
This Project explains about Online Mobile store system where database created with SQL Server.
create database Mobile
use Mobile
create table agent (AID numeric primary key,AName varchar(30),Contact varchar(50),PhMb varchar(30))
select * from agent
create table Payment (AID numeric,AName varchar(30),Contact varchar(50),PhMb varchar(30),SID Numeric,Scheme1 Varchar(30),UID varchar(30),Amount varchar(10))
select * from Payment
create table Regscheme (UID varchar(30),SID numeric,Scheme1 Varchar(30),Amount varchar(10))
select * from Regscheme
create table schemes (SID numeric primary key,CBY varchar(30),CDT varchar(30),Scheme1 Varchar(30),Amount varchar(10))
select * from schemes
create table UserInfo (UName varchar(30),UPwd varchar(30),loc varchar(50),Accno numeric,Name1 varchar(30),JoinDT varchar(30),OffCode numeric,PhMB Varchar(30),Addr varchar(100))
select * from UserInfo
VB Source code of this Project:
[cc lang=”vb”]
Imports System.Data.sqlclient
Public Class FrmPayments
Private Cn As SqlConnection
Private Cmd As SqlCommand
Private dr As SqlDataReader
Private Sub FrmPayments_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Cn = New SqlConnection(“server=;uid=sa;pwd=sa;database=Mobile;”)
Cn.Open()
Dim S As String
S = “Select * From Regscheme”
Cmd = New SqlCommand(S, Cn)
dr = Cmd.ExecuteReader
CmbUID.Items.Add(“—————-Select————-“)
While dr.Read
CmbUID.Items.Add(dr!UID)
End While
CmbUID.Text = “—————-Select————-”
dr.Close()
Cmd.Dispose()
Dim S1 As String
S1 = “Select * From Agent”
Cmd = New SqlCommand(S1, Cn)
dr = Cmd.ExecuteReader
CmbAID.Items.Add(“—————-Select————-“)
While dr.Read
CmbAID.Items.Add(dr!AID)
End While
CmbAID.Text = “—————-Select————-”
dr.Close()
Cmd.Dispose()
End Sub
Private Sub CmbAID_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CmbAID.SelectedIndexChanged
If CmbAID.Text <> “—————-Select————-” Then
Dim S As String
S = “Select * From Agent Where AID=” & CmbAID.Text & “”
Cmd = New SqlCommand(S, Cn)
dr = Cmd.ExecuteReader
If dr.Read Then
TxtName.Text = dr!AName
TxtContacts.Text = dr!Contact
TxtPhMb.Text = dr!PhMb
End If
dr.Close()
Cmd.Dispose()
End If
End Sub
Private Sub CmbUID_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CmbUID.SelectedIndexChanged
If CmbUID.Text <> “—————-Select————-” Then
Dim S As String
S = “Select * From Regscheme Where UID='” & CmbUID.Text & “‘”
Cmd = New SqlCommand(S, Cn)
dr = Cmd.ExecuteReader
If dr.Read Then
TxtScheme.Text = dr!Scheme1
TxtSID.Text = dr!SID
End If
dr.Close()
Cmd.Dispose()
End If
End Sub
Private Sub CmdNew_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CmdNew.Click
Clear()
End Sub
Public Sub Clear()
CmbUID.Text = “—————-Select————-”
CmbAID.Text = “—————-Select————-”
TxtName.Text = “”
TxtContacts.Text = “”
TxtPhMb.Text = “”
TxtSID.Text = “”
TxtScheme.Text = “”
TxtAmt.Text = “”
End Sub
Private Sub CmdExit_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CmdExit.Click
Me.Close()
End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Try
Dim Str As String = “”
If CmbUID.Text = “—————-Select————-” Then
Str += “Select The User-ID” & vbLf
End If
If CmbAID.Text = “—————-Select————-” Then
Str += “Select The Agent-ID” & vbLf
End If
If Trim(TxtSID.Text) = “” Then
Str += “Enter The Scheme-ID” & vbLf
End If
If Trim(TxtScheme.Text) = “” Then
Str += “Enter The Scheme” & vbLf
End If
If Trim(TxtName.Text) = “” Then
Str += “Enter The Name” & vbLf
End If
If Trim(TxtContacts.Text) = “” Then
Str += “Enter The Contacts” & vbLf
End If
If Trim(TxtPhMb.Text) = “” Then
Str += “Enter The Contact Number” & vbLf
End If
If Trim(TxtAmt.Text) = “” Then
Str += “Enter The Amount” & vbLf
End If
If Str = “” Then
Dim S As String
S = “Insert Into Payment Values(” & CmbAID.Text & “,'” & TxtName.Text & “‘,'” & TxtContacts.Text & “‘,'” & TxtPhMb.Text & “‘,” & TxtSID.Text & “,'” & TxtScheme.Text & “‘,'” & CmbUID.Text & “‘,” & TxtAmt.Text & “)”
Cmd = New SqlCommand(S, Cn)
Cmd.ExecuteNonQuery()
MsgBox(“Successfully Saved”, MsgBoxStyle.Information, “Mobile Simulation”)
Cmd.Dispose()
Clear()
End If
Catch ex As Exception
MsgBox(ex.Message)
End Try
End Sub
End Class[/cc]
create database Mobile
use Mobile
create table agent (AID numeric primary key,AName varchar(30),Contact varchar(50),PhMb varchar(30))
select * from agent
create table Payment (AID numeric,AName varchar(30),Contact varchar(50),PhMb varchar(30),SID Numeric,Scheme1 Varchar(30),UID varchar(30),Amount varchar(10))
select * from Payment
create table Regscheme (UID varchar(30),SID numeric,Scheme1 Varchar(30),Amount varchar(10))
select * from Regscheme
create table schemes (SID numeric primary key,CBY varchar(30),CDT varchar(30),Scheme1 Varchar(30),Amount varchar(10))
select * from schemes
create table UserInfo (UName varchar(30),UPwd varchar(30),loc varchar(50),Accno numeric,Name1 varchar(30),JoinDT varchar(30),OffCode numeric,PhMB Varchar(30),Addr varchar(100))
select * from UserInfo
VB Source code of this Project:
[cc lang=”vb”]
Imports System.Data.sqlclient
Public Class FrmPayments
Private Cn As SqlConnection
Private Cmd As SqlCommand
Private dr As SqlDataReader
Private Sub FrmPayments_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Cn = New SqlConnection(“server=;uid=sa;pwd=sa;database=Mobile;”)
Cn.Open()
Dim S As String
S = “Select * From Regscheme”
Cmd = New SqlCommand(S, Cn)
dr = Cmd.ExecuteReader
CmbUID.Items.Add(“—————-Select————-“)
While dr.Read
CmbUID.Items.Add(dr!UID)
End While
CmbUID.Text = “—————-Select————-”
dr.Close()
Cmd.Dispose()
Dim S1 As String
S1 = “Select * From Agent”
Cmd = New SqlCommand(S1, Cn)
dr = Cmd.ExecuteReader
CmbAID.Items.Add(“—————-Select————-“)
While dr.Read
CmbAID.Items.Add(dr!AID)
End While
CmbAID.Text = “—————-Select————-”
dr.Close()
Cmd.Dispose()
End Sub
Private Sub CmbAID_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CmbAID.SelectedIndexChanged
If CmbAID.Text <> “—————-Select————-” Then
Dim S As String
S = “Select * From Agent Where AID=” & CmbAID.Text & “”
Cmd = New SqlCommand(S, Cn)
dr = Cmd.ExecuteReader
If dr.Read Then
TxtName.Text = dr!AName
TxtContacts.Text = dr!Contact
TxtPhMb.Text = dr!PhMb
End If
dr.Close()
Cmd.Dispose()
End If
End Sub
Private Sub CmbUID_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CmbUID.SelectedIndexChanged
If CmbUID.Text <> “—————-Select————-” Then
Dim S As String
S = “Select * From Regscheme Where UID='” & CmbUID.Text & “‘”
Cmd = New SqlCommand(S, Cn)
dr = Cmd.ExecuteReader
If dr.Read Then
TxtScheme.Text = dr!Scheme1
TxtSID.Text = dr!SID
End If
dr.Close()
Cmd.Dispose()
End If
End Sub
Private Sub CmdNew_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CmdNew.Click
Clear()
End Sub
Public Sub Clear()
CmbUID.Text = “—————-Select————-”
CmbAID.Text = “—————-Select————-”
TxtName.Text = “”
TxtContacts.Text = “”
TxtPhMb.Text = “”
TxtSID.Text = “”
TxtScheme.Text = “”
TxtAmt.Text = “”
End Sub
Private Sub CmdExit_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CmdExit.Click
Me.Close()
End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Try
Dim Str As String = “”
If CmbUID.Text = “—————-Select————-” Then
Str += “Select The User-ID” & vbLf
End If
If CmbAID.Text = “—————-Select————-” Then
Str += “Select The Agent-ID” & vbLf
End If
If Trim(TxtSID.Text) = “” Then
Str += “Enter The Scheme-ID” & vbLf
End If
If Trim(TxtScheme.Text) = “” Then
Str += “Enter The Scheme” & vbLf
End If
If Trim(TxtName.Text) = “” Then
Str += “Enter The Name” & vbLf
End If
If Trim(TxtContacts.Text) = “” Then
Str += “Enter The Contacts” & vbLf
End If
If Trim(TxtPhMb.Text) = “” Then
Str += “Enter The Contact Number” & vbLf
End If
If Trim(TxtAmt.Text) = “” Then
Str += “Enter The Amount” & vbLf
End If
If Str = “” Then
Dim S As String
S = “Insert Into Payment Values(” & CmbAID.Text & “,'” & TxtName.Text & “‘,'” & TxtContacts.Text & “‘,'” & TxtPhMb.Text & “‘,” & TxtSID.Text & “,'” & TxtScheme.Text & “‘,'” & CmbUID.Text & “‘,” & TxtAmt.Text & “)”
Cmd = New SqlCommand(S, Cn)
Cmd.ExecuteNonQuery()
MsgBox(“Successfully Saved”, MsgBoxStyle.Information, “Mobile Simulation”)
Cmd.Dispose()
Clear()
End If
Catch ex As Exception
MsgBox(ex.Message)
End Try
End Sub
End Class[/cc]