Você está na página 1de 9

' conn.

ConnectionString =
("Server=192.9.202.166;uid=sa;pwd=pwd;database=power_view")
conn.ConnectionString =
("Server=192.9.202.72;uid=sa;pwd=pwd;database=power_view")
Dim uid, brkname, scrptname, qty, buyrate, broakrage, exchange, type,
expdate, optiontype, stkprice As String
Try
uid = guserid
brkname = broakernamecombo.Text
scrptname = Scriptcombo.Text
qty = Qtytb.Text
buyrate = buyratetb.Text
broakrage = brokragecombo.Text
exchange = comboexchange.Text
If RadioButton1.Checked = True Then
type = RadioButton1.Text
End If
If RadioButton2.Checked = True Then
type = RadioButton2.Text
End If
If RadioButton3.Checked = True Then
type = RadioButton3.Text
End If
expdate = expirydatecombo.Text
optiontype = optiontypecombo.Text
stkprice = strikepricecombo.Text
If stkprice = "Data Not Found" Then
stkprice = 0
End If

conn.Open()
cmd.CommandText = "insert into Dp values ('" & uid & "','" & brkname &
"','" & scrptname & "'," & qty & "," & buyrate & "," & broakrage & ",'" & exchange
& "','" & type & "','" & expdate & "','" & optiontype & "'," & stkprice & ")"
cmd.CommandType = CommandType.Text
cmd.Connection = conn
cmd.ExecuteNonQuery()
MessageBox.Show("data save successfully")
Me.Close()
Catch ex As Exception
MsgBox(ex.Message)
cmd.Connection.Close()

End Try

End Sub
Private Sub Closebutt_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Closebutt.Click
Me.Close()
End Sub

Private Sub CreateWatchlist_Load(ByVal sender As System.Object, ByVal e As


System.EventArgs) Handles MyBase.Load
Dim conn As New SqlConnection
Dim myCommand As New SqlCommand
Dim myAdapter As New SqlDataAdapter
Dim dt As New DataTable
Dim myarray As String
i = 0
'conn.ConnectionString = "server=192.9.202.166;user
id=sa;password=pwd;database=tickerplantdatabase"
conn.ConnectionString = "server=192.9.202.72;user
id=sa;password=pwd;database=tickerplantdatabase"
myCommand.Connection = conn
myCommand.CommandText = "select Scripcode from
tickerplantdatabase..Bsecurrentprices"
Try
conn.Open()
myCommand.ExecuteNonQuery()
myAdapter.SelectCommand = myCommand
myAdapter.Fill(dt)
'myAdapter.Fill(myarray)
Scriptcombo.DataSource = dt
Scriptcombo.DisplayMember = "Scripcode"
i = 1
Catch myerror As SqlException
MessageBox.Show("Error Connecting to Database: " & myerror.Message)
Finally
conn.Close()
End Try
RadioButton1.Checked = True
End Sub

Private Sub comboexchange_SelectedIndexChanged_1(ByVal sender As


System.Object, ByVal e As System.EventArgs) Handles
comboexchange.SelectedIndexChanged

If comboexchange.Text = "BSE" Then


RadioButton1.Focus()
expirydatecombo.Enabled = False
optiontypecombo.Enabled = False
strikepricecombo.Enabled = False
RadioButton2.Enabled = False
RadioButton3.Enabled = False
'expirydatecombo.Text = ""
'optiontypecombo.Text = ""
'strikepricecombo.Text = ""

Else
comboexchange.Text = "NSE"
RadioButton1.Focus()

expirydatecombo.Enabled = False
optiontypecombo.Enabled = False
strikepricecombo.Enabled = False
RadioButton1.Enabled = True
RadioButton2.Enabled = True
RadioButton3.Enabled = True

End If
End Sub

Private Sub RadioButton2_CheckedChanged(ByVal sender As System.Object, ByVal e


As System.EventArgs) Handles RadioButton2.CheckedChanged
QtyMessage.Text = ""
BuyrateMessage.Text = ""
BroakrageMessage.Text = ""
'expdatemessage.Text = ""
'optmessage.Text = ""
'strikepmessage.Text = ""

If RadioButton2.Checked = True Then

optiontypecombo.Enabled = False
strikepricecombo.Enabled = False
expirydatecombo.Enabled = True
optiontypecombo.Text = ""
strikepricecombo.Text = ""
Qtytb.Text = ""
buyratetb.Text = ""
End If

Dim conn As New SqlConnection


Dim myCommand As New SqlCommand
Dim myCommand1 As New SqlCommand
Dim myAdapter As New SqlDataAdapter
Dim myAdapter1 As New SqlDataAdapter
Dim dt As New DataTable
Dim ds As New DataSet
' conn.ConnectionString = "server=192.9.202.166;user
id=sa;password=db2admin;database=tickerplantdatabase"
conn.ConnectionString = "server=192.9.202.72;user
id=sa;password=db2admin;database=tickerplantdatabase"
conn.Open()
myCommand.Connection = conn
myCommand1.Connection = conn
myCommand.CommandText = "select distinct(scripcode)as scripcode from
tickerplantdatabase..fonsecurrentprices where sid like 'f%m%' order by scripcode
asc"
myCommand1.CommandText = "select distinct(substring(sid,1,7)) as
expirydate from tickerplantdatabase..fonsecurrentprices where sid like 'f%m%' "
myCommand.ExecuteNonQuery()
myCommand1.ExecuteNonQuery()
myAdapter.SelectCommand = myCommand
myAdapter1.SelectCommand = myCommand1
myAdapter.Fill(dt)
myAdapter1.Fill(ds)
Scriptcombo.DataSource = dt
expirydatecombo.DataSource = ds.Tables(0)
Scriptcombo.DisplayMember = "scripcode"
expirydatecombo.DisplayMember = "expirydate"
End Sub

Private Sub RadioButton3_CheckedChanged(ByVal sender As System.Object, ByVal e


As System.EventArgs) Handles RadioButton3.CheckedChanged
expirydatecombo.Enabled = True
optiontypecombo.Enabled = True
strikepricecombo.Enabled = True
optiontypecombo.Text = ":CA:"

QtyMessage.Text = ""
BuyrateMessage.Text = ""
BroakrageMessage.Text = ""
expdatemessage.Text = ""
optmessage.Text = ""
strikepmessage.Text = ""
Qtytb.Text = ""
buyratetb.Text = ""

If RadioButton3.Checked = True Then


Dim conn As New SqlConnection
Dim myCommand As New SqlCommand
Dim mycommand1 As New SqlCommand
Dim mycommand2 As New SqlCommand
Dim myAdapter As New SqlDataAdapter
Dim myadapter1 As New SqlDataAdapter
Dim myadapter2 As New SqlDataAdapter
Dim dt As New DataTable
Dim ds As New DataSet
Dim ds1 As New DataSet

Dim scrpcomb As String


Dim type As String
'Dim expdate As String

' conn.ConnectionString = "server=192.9.202.166;user


id=sa;password=db2admin;database=tickerplantdatabase"
conn.ConnectionString = "server=192.9.202.72;user
id=sa;password=db2admin;database=tickerplantdatabase"
conn.Open()
myCommand.Connection = conn
mycommand1.Connection = conn
mycommand2.Connection = conn
myCommand.CommandText = "select distinct(scripcode) from
tickerplantdatabase..fonsecurrentprices where sid like '%O%:%' order by scripcode
asc"
mycommand1.CommandText = "select distinct(substring(sid,1,7)) as
expirydate from tickerplantdatabase..fonsecurrentprices where sid like '%o%:%'
order by expirydate asc"
scrpcomb = Scriptcombo.Text
type = optiontypecombo.Text
' expdate = expirydatecombo.Text
mycommand2.CommandText = "select substring(sid,12,18) as strikeprice
from tickerplantdatabase..fonsecurrentprices where scripcode like '%" & scrpcomb &
"%' and sid like '%O%:%' and sid like '%" & type & "%' "
myCommand.ExecuteNonQuery()
mycommand1.ExecuteNonQuery()
mycommand2.ExecuteNonQuery()
myAdapter.SelectCommand = myCommand
myadapter1.SelectCommand = mycommand1
myadapter2.SelectCommand = mycommand2
myAdapter.Fill(dt)
myadapter1.Fill(ds)
myadapter2.Fill(ds1)
Scriptcombo.DataSource = dt
expirydatecombo.DataSource = ds.Tables(0)
strikepricecombo.DataSource = ds1.Tables(0)
Scriptcombo.DisplayMember = "scripcode"
expirydatecombo.DisplayMember = "expirydate"
strikepricecombo.DisplayMember = "strikeprice"
conn.Close()

End If

End Sub

Private Sub RadioButton1_CheckedChanged(ByVal sender As System.Object, ByVal e


As System.EventArgs) Handles RadioButton1.CheckedChanged

If RadioButton1.Checked = True Then


expirydatecombo.Enabled = False
optiontypecombo.Enabled = False
strikepricecombo.Enabled = False
expirydatecombo.Text = ""
optiontypecombo.Text = ""
strikepricecombo.Text = ""
Qtytb.Text = ""
buyratetb.Text = ""
End If

QtyMessage.Text = ""
BuyrateMessage.Text = ""
BroakrageMessage.Text = ""
'expdatemessage.Text = ""
'optmessage.Text = ""
'strikepmessage.Text = ""

Dim conn As New SqlConnection


Dim myCommand As New SqlCommand
Dim myAdapter As New SqlDataAdapter
Dim dt As New DataTable
myCommand.Connection = conn
' conn.ConnectionString = "server=192.9.202.166;user
id=sa;password=db2admin;database=tickerplantdatabase"
conn.ConnectionString = "server=192.9.202.72;user
id=sa;password=db2admin;database=tickerplantdatabase"

If comboexchange.Text = "BSE" Then


myCommand.CommandText = "select Scripcode from Bsecurrentprices"
Else
If comboexchange.Text = "NSE" Then
myCommand.CommandText = "select Scripcode from Nsecurrentprices"
End If
End If
Try
conn.Open()
myCommand.ExecuteNonQuery()
myAdapter.SelectCommand = myCommand
myAdapter.Fill(dt)
Scriptcombo.DataSource = dt
Scriptcombo.DisplayMember = "Scripcode"
Catch myerror As SqlException
MessageBox.Show("Error Connecting to Database: " & myerror.Message)
Finally
conn.Close()
End Try

End Sub

Private Sub comboexchange_Leave(ByVal sender As System.Object, ByVal e As


System.EventArgs) Handles comboexchange.Leave
Dim conn As New SqlConnection
Dim myCommand As New SqlCommand
Dim myAdapter As New SqlDataAdapter
Dim dt As New DataTable
myCommand.Connection = conn
' conn.ConnectionString = "server=192.9.202.166;user
id=sa;password=db2admin;database=tickerplantdatabase"
conn.ConnectionString = "server=192.9.202.72;user
id=sa;password=db2admin;database=tickerplantdatabase"
If comboexchange.Text = "BSE" Then
myCommand.CommandText = "select Scripcode from Bsecurrentprices"
Else
If comboexchange.Text = "NSE" Then
myCommand.CommandText = "select Scripcode from Nsecurrentprices"
End If
End If
Try
conn.Open()
myCommand.ExecuteNonQuery()
myAdapter.SelectCommand = myCommand
myAdapter.Fill(dt)
Scriptcombo.DataSource = dt
Scriptcombo.DisplayMember = "Scripcode"

Catch myerror As SqlException


MessageBox.Show("Error Connecting to Database: " & myerror.Message)
Finally
conn.Close()
End Try
End Sub

Private Sub optiontypecombo_SelectedIndexChanged(ByVal sender As


System.Object, ByVal e As System.EventArgs) Handles
optiontypecombo.SelectedIndexChanged
If i = 1 Then
Dim conn As New SqlConnection
Dim myCommand As New SqlCommand
Dim myAdapter As New SqlDataAdapter
Dim dt As New DataTable
Dim scrpcomb As String
Dim type As String
Dim expdate As String

' conn.ConnectionString = "server=192.9.202.166;user


id=sa;password=db2admin;database=tickerplantdatabase"
conn.ConnectionString = "server=192.9.202.72;user
id=sa;password=db2admin;database=tickerplantdatabase"
myCommand.Connection = conn
scrpcomb = Scriptcombo.Text
type = optiontypecombo.Text
expdate = expirydatecombo.Text
If RadioButton3.Checked = True Then
myCommand.CommandText = "select substring(sid,12,18) as
strikeprice from tickerplantdatabase..fonsecurrentprices where scripcode like '%"
& scrpcomb & "%' and sid like '%O%:%' and sid like '%" & type & "%' and sid like
'%" & expdate & "%'"
Try
conn.Open()
myCommand.ExecuteNonQuery()
myAdapter.SelectCommand = myCommand
myAdapter.Fill(dt)
strikepricecombo.DataSource = dt
strikepricecombo.DisplayMember = "strikeprice"
i = 1
Catch myerror As SqlException
MessageBox.Show("Error Connecting to Database: " &
myerror.Message)
Finally
conn.Close()
End Try

End If
End If
strikepricecombo.Focus()
If strikepricecombo.Text.Length = 0 Then
strikepricecombo.Text = "Data Not Found"
End If
End Sub

Private Sub Scriptcombo_SelectedIndexChanged(ByVal sender As System.Object,


ByVal e As System.EventArgs) Handles Scriptcombo.SelectedIndexChanged
Dim conn As New SqlConnection
Dim myCommand As New SqlCommand
Dim myAdapter As New SqlDataAdapter
Dim dt As New DataTable
Dim scrpcomb As String
Dim type As String
Dim expdate As String

' conn.ConnectionString = "server=192.9.202.166;user


id=sa;password=db2admin;database=tickerplantdatabase"
conn.ConnectionString = "server=192.9.202.72;user
id=sa;password=db2admin;database=tickerplantdatabase"
myCommand.Connection = conn
scrpcomb = Scriptcombo.Text
type = optiontypecombo.Text
expdate = expirydatecombo.Text
If RadioButton3.Checked = True Then
myCommand.CommandText = "select substring(sid,12,18) as strikeprice
from tickerplantdatabase..fonsecurrentprices where scripcode like '%" & scrpcomb &
"%' and sid like '%O%:%' and sid like '%" & type & "%' and sid like '%" & expdate
& "%'"
Try
conn.Open()
myCommand.ExecuteNonQuery()
myAdapter.SelectCommand = myCommand
myAdapter.Fill(dt)
strikepricecombo.DataSource = dt
strikepricecombo.DisplayMember = "strikeprice"

Catch myerror As SqlException


MessageBox.Show("Error Connecting to Database: " &
myerror.Message)
Finally
conn.Close()
End Try
End If
If strikepricecombo.Text.Length = 0 Then
strikepricecombo.Text = "Data Not Found"
End If
End Sub

Private Sub expirydatecombo_SelectedIndexChanged(ByVal sender As


System.Object, ByVal e As System.EventArgs) Handles
expirydatecombo.SelectedIndexChanged
Dim conn As New SqlConnection
Dim myCommand As New SqlCommand
Dim myAdapter As New SqlDataAdapter
Dim dt As New DataTable
Dim scrpcomb As String
Dim type As String
Dim expdate As String

' conn.ConnectionString = "server=192.9.202.166;user


id=sa;password=db2admin;database=tickerplantdatabase"
conn.ConnectionString = "server=192.9.202.72;user
id=sa;password=db2admin;database=tickerplantdatabase"
myCommand.Connection = conn
scrpcomb = Scriptcombo.Text
type = optiontypecombo.Text
expdate = expirydatecombo.Text
If RadioButton3.Checked = True Then
myCommand.CommandText = "select substring(sid,12,18) as strikeprice
from tickerplantdatabase..fonsecurrentprices where scripcode like '%" & scrpcomb &
"%' and sid like '%O%:%' and sid like '%" & type & "%' and sid like '%" & expdate
& "%'"
Try
conn.Open()
myCommand.ExecuteNonQuery()
myAdapter.SelectCommand = myCommand
myAdapter.Fill(dt)
strikepricecombo.DataSource = dt
strikepricecombo.DisplayMember = "strikeprice"

Catch myerror As SqlException


MessageBox.Show("Error Connecting to Database: " &
myerror.Message)
Finally
conn.Close()
End Try
End If
If strikepricecombo.Text.Length = 0 Then
strikepricecombo.Text = "Data Not Found"
End If
End Sub

End Class

Você também pode gostar