Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Imports System.Data.Odbc
- Imports System.Random
- Imports System.Data.SqlClient
- Public Class OrderForm
- Inherits System.Web.UI.Page
- Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
- medID.Text = Request.QueryString("mediaID")
- MEDCATPR.Text = Request.QueryString("MEDCATPR")
- medNM.Text = Request.QueryString("medNM")
- mediaLink.Attributes.Add("src", Request.QueryString("mediaLink"))
- End Sub
- Protected Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button1.Click
- placeOrder()
- End Sub
- Protected Sub radioYes_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles radioYes.CheckedChanged
- Dim random As New Random()
- Dim contNum As Integer = random.Next(1000000)
- txtContNum.Text = contNum.ToString
- txtContNum.Enabled = False
- lblFName.Visible = True
- txtFName.Visible = True
- lblLName.Visible = True
- txtLName.Visible = True
- 'lblTitle.Visible = True
- 'listTitle.Visible = True
- lblAddress.Visible = True
- txtAddress.Visible = True
- lblCity.Visible = True
- txtCity.Visible = True
- lblState.Visible = True
- txtState.Visible = True
- lblZip.Visible = True
- txtZip.Visible = True
- lblPhone.Visible = True
- txtPhone.Visible = True
- lblEmail.Visible = True
- txtEmail.Visible = True
- End Sub
- Protected Sub radioNo_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles radioNo.CheckedChanged
- txtContNum.Enabled = True
- lblFName.Visible = False
- txtFName.Visible = False
- lblLName.Visible = False
- txtLName.Visible = False
- lblTitle.Visible = False
- listTitle.Visible = False
- lblAddress.Visible = False
- txtAddress.Visible = False
- lblCity.Visible = False
- txtCity.Visible = False
- lblState.Visible = False
- txtState.Visible = False
- lblZip.Visible = False
- txtZip.Visible = False
- lblPhone.Visible = False
- txtPhone.Visible = False
- lblEmail.Visible = False
- txtEmail.Visible = False
- End Sub
- Public Function getMediaValue(ByVal value As String) As String
- Dim parameter As String = Nothing
- MsgBox("returning " + value)
- Select Case value
- Case "medID"
- parameter = medID.Text
- Case "MEDCATPR"
- MsgBox("stupid") ' = MEDCATPR.Text
- Case "medNM"
- parameter = medNM.Text
- Case "mediaText"
- parameter = mediaText.Text
- Case Else
- parameter = "didn't work"
- End Select
- MsgBox(parameter)
- Return parameter
- End Function
- '
- 'This should go in the order class, but I can't get it to work
- '
- Public Sub placeOrder()
- Try
- 'Dim conn = "Driver={MySQL ODBC 5.1 Driver};Server='173.15.24.2';Database=mydb; User=root;Password=password;Option=3;"
- Dim conn As String = "Driver={MySQL ODBC 5.1 Driver};Server=173.15.24.2;Database=wsc; User=root;Password=Viku1988!;Option=3;"
- Dim dbConn2 As New OdbcConnection(conn)
- dbConn2.Open()
- 'Dim sql As String = "INSERT INTO order (medID, ordID, contNum, empID, ordTO, medQuan, mediaText) VALUES('medID','ordID','contNum','empID','ordTO','medQuan', 'mediaText')"
- 'Dim sql As String = "INSERT INTO wsc.order (medID, ordID, contNum, medQuan, mediaText) VALUES('a','1','2','2', 'abc')"
- 'put order data values in correct format
- Dim random As New Random()
- Dim orderID As Integer = random.Next(1000000)
- Dim price As Integer = CInt(MEDCATPR.Text)
- Dim quantity As Decimal = CDec(medQuan.SelectedValue)
- Dim contNum As Integer = CInt(txtContNum.Text)
- Dim ordTotal As Decimal = price * quantity
- 'put customer data values in correct format
- 'Dim Zip As Integer = CInt(txtZip.Text)
- 'Dim title As String = listTitle.SelectedValue
- 'Dim Phone As Integer = CInt(txtPhone.Text)
- Dim passWord As String = "default"
- 'Dim title As String = "default"
- MsgBox(mediaText.Text)
- Dim sql As String = "INSERT INTO wsc.order (medID, contNum, medQuan, mediaText, ordTotal) VALUES('" + medID.Text + "','" + contNum.ToString + "','" + quantity.ToString + "', '" + mediaText.Text + "', '" + ordTotal.ToString + "')"
- Dim sql2 As String = "INSERT INTO wsc.customer (contNum, Fname, Lname, ADD, CITY, ST, ZIP, phNUM, PASS, EMAIL) VALUES('" + contNum.ToString + "','" + txtFName.Text + "','" + txtLName.Text + "', '" + txtAddress.Text + "', '" + txtCity.Text + "', '" + txtState.Text + "', '" + txtZip.Text + "', '" + txtPhone.Text + "','" + passWord + "', '" + txtEmail.Text + "')"
- Dim command As New OdbcCommand
- command.Connection = dbConn2
- command.CommandText = sql2
- command.ExecuteNonQuery()
- Dim command2 As New OdbcCommand
- command2.Connection = dbConn2
- command2.CommandText = sql
- command.ExecuteNonQuery()
- dbConn2.Close()
- 'command.Parameters.AddWithValue("medID", medID.Text)
- 'command.Parameters.AddWithValue("ordID", orderID)
- 'command.Parameters.AddWithValue("contNum", contNum)
- 'command.Parameters.AddWithValue("empID", empID)
- 'command.Parameters.AddWithValue("ordTO", total)
- 'command.Parameters.AddWithValue("medQuan", quantity)
- 'command.Parameters.AddWithValue("mediaText", mediaText.Text)
- 'command.Parameters.Add("@medID", OdbcType.NVarChar, 25).Value = getMediaValue("medID")
- 'Dim orderID As Integer = CInt(getMediaValue("ordID"))
- 'command.Parameters.Add("@ordID", OdbcType.Int, 8).Value = orderID
- ''not sure about these
- 'command.Parameters.Add("@contNum", OdbcType.Int, 10).Value = 123456
- 'command.Parameters.Add("@empID", OdbcType.Int, 8).Value = 11111111
- 'Dim price As Decimal = CDec(getMediaValue(MEDCATPR.Text))
- 'Dim quantity As Decimal = CDec(getMediaValue(medQuan.SelectedValue))
- 'Dim total As Decimal = price * quantity
- 'command.Parameters.Add("@ordTO", OdbcType.Decimal, 3, 2).Value = total
- 'command.Parameters.Add("@medQuan", OdbcType.Int, 11).Value = quantity
- 'Dim reader As OdbcDataReader = command.ExecuteReader
- MsgBox("Your order was placed successfully")
- Catch ex As Exception
- 'MsgBox("Your order was not able to placed at this time")
- MsgBox(ex.Message)
- End Try
- End Sub
- End Class
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement