This post originated from an RSS feed registered with Web Buzz
by Josh Baltzell.
Original Post: Test post from Visual Blogger 2004
Feed Title: ShortDomainName.com
Feed URL: http://www.contegix.com/Rss.aspx
Feed Description: Weblog of Josh Baltzell. Focusing on the computer industry and .NET programming related news. I like to get involved on the discussions wherever they are.
I just wanted to make a quick test post from Visual Blogger to see how things
work.
1 Private Sub SubmitOrder()
2 3'Create the array
4 Try
5 Dim User As New VIUser
6 Dim intMPowerLoop As Integer
7 Dim arrForm As New ArrayList
8 Dim StringSplit() As String
9 Dim strSQLView As String
10 11'Populate the array with information from the form to prepare to send to MPower
12 For intMPowerLoop = 1 To Request.Form.Count - 2 'To let it ignore the clear and submit buttons at the end of the form
13'Request.Form.GetKey()
14 StringSplit = Split(Request.Form.GetKey(intMPowerLoop).ToString, ":")
15 If StringSplit(1) = "SQLView" Then
16 strSQLView = StringSplit(1)
17 Else
18'arrForm.Add("x")
19 arrForm.Add(Request.Form.Get(intMPowerLoop))
20 StringSplit = Split(Request.Form.GetKey(intMPowerLoop), ":")
21 arrForm.Add(StringSplit(1))
22 End If
23 24 StringSplit = Nothing
25 26 Next
27 28 User.arrVariableForm = arrForm
29 30 Catch ex As Exception
31 Response.Redirect("errormessage.aspx?text=" & ex.Message.ToString)
32 33 End Try
34 35 Try
36'Read information for an item from the database
37 Dim ProductID As Integer = Request.QueryString("ProductID")
38 39'Get the name of the XML File
40 Dim Catalog As New VICatalog
41 Dim Cart As New VICart
42 Dim User As New VIUser
43 44 Dim strPub As String = Catalog.GetFormXML(ProductID)
45 46'Read the XML File in to a Dataset
47 Dim dsXML As New DataSet("New DataSet")
48 49'Read XML from specified location
50 dsXML.ReadXml(ConfigurationSettings.AppSettings("SiteName") & "/XML/Forms/" & strPub & ".xml")
51 52'Set the active Dataset table to the one specifically about the fields in the form
53 Dim dtXML As DataTable
54 dtXML = dsXML.Tables("question")
55 Dim drXML As DataRow
56 Dim dcXML As DataColumn
57 Dim arrVariableData(2, dtXML.Rows.Count - 1) As String
58 Dim intCounter As Integer = 0
59 Dim intQuantity As Integer
60 For Each drXML In dtXML.Rows
61'For intCounter = 0 To dtXML.Rows.Count Step 1
62 For Each dcXML In dtXML.Columns
63'Collect the Needed XML
64 Select Case dcXML.ColumnName
65 Case "name"
66 arrVariableData(0, intCounter) = drXML(dcXML)
67 Case "table_source"
68 arrVariableData(1, intCounter) = drXML(dcXML)
69 End Select
70 71 Next
72 intCounter = intCounter + 1
73 Next
74 75'Read the first variable name and match it to the view name in the array
76 intCounter = 0
77 Dim arrVariability As New ArrayList
78 arrVariability = User.arrVariableForm
79'arrVariability()
80 Dim strTemp As String
81 Dim strVariability As String
82 For Each strVariability In arrVariableData
83 If intCounter < arrVariability.Count Then
84 strTemp = arrVariability(intCounter + 1)
85 86 Dim intLoop As Integer
87 For intLoop = 0 To (arrVariableData.Length / 3) - 1
88 If arrVariableData(0, intLoop) = strTemp Then
89 If strTemp = "Quantity" Then
90 intQuantity = CInt(arrVariability(intCounter))
91 End If
92 arrVariableData(2, intLoop) = arrVariability(intCounter)
93 End If
94 Next
95 96 intCounter = intCounter + 2
97 End If
98 Next
99 100'Add the order to the OrderItems Table
101 Dim intOrderItemID As Integer = Cart.AddItem(User.UID, ProductID, intQuantity)
102 103'Build a SQL string to enter the variable data
104 Dim strFields As String
105 Dim strValues As String
106 Dim intCount As Integer
107 108 For intCount = 0 To (arrVariableData.GetLength(1) - 2)
109 If arrVariableData(0, intCount) <> "Quantity" Then
110 strFields += arrVariableData(1, intCount) & ","
111 strValues += "'" & arrVariableData(2, intCount) & "',"
112 End If
113 Next
114 115 strFields += "OrderItemID"
116 strValues += "'" & intOrderItemID & "'"
117 118'Submit Variability to the database
119 Cart.AddItemVariability(strFields, strValues)
120'Response.Redirect("cart.aspx")
121 Catch ex As Exception
122 Response.Redirect("errormessage.aspx?text=" & ex.Message.ToString)
123 Finally
124 125 End Try
126 Response.Redirect("cart.aspx")
127 End Sub
128
The code pasting along makes it sweet (please do not read this sloppy
code!)