Line 1: Imports System.Security.Cryptography
Line 2: Imports System.Data.OleDb
Line 3: Imports System.Net.Mail
Line 4:
Line 5: Public Class OnlineSales
Line 6: Public Structure Client
Line 7: Public ClientID As String 'proivsion for future use for non-members.
Line 8: Public Title As String
Line 9: Public Initials As String
Line 10: Public Surname As String
Line 11: Public Name As String '= title + initials + surname
Line 12: Public Knownas As String
Line 13: Public Address1 As String
Line 14: Public Address2 As String
Line 15: Public Address3 As String
Line 16: Public PostTown As String
Line 17: Public County As String
Line 18: Public PostCode As String
Line 19: Public Country As String
Line 20: Public CountryCode As String
Line 21: Public CountryNumber As String
Line 22: Public PostZone As String
Line 23: Public FormattedAddress As String
Line 24: Public emailAddress As String
Line 25: Public eName As String
Line 26: Public FirstName As String
Line 27: Public ST1 As String 'for members only
Line 28: End Structure
Line 29:
Line 30: Public Structure MemberDet 'to be replace by Client
Line 31: Public Title As String
Line 32: Public Initials As String
Line 33: Public Surname As String
Line 34: Public Name As String '= title + initials + surname
Line 35: Public Knownas As String
Line 36: Public Address1 As String
Line 37: Public Address2 As String
Line 38: Public Address3 As String
Line 39: Public PostTown As String
Line 40: Public County As String
Line 41: Public PostCode As String
Line 42: Public Country As String
Line 43: Public CountryCode As String
Line 44: Public CountryNumber As String
Line 45: Public PostZone As String
Line 46: Public FormattedAddress As String
Line 47: Public emailAddress As String
Line 48: Public eName As String
Line 49: Public FirstName As String
Line 50: Public Area As Integer
Line 51: Public DateJoined As Date
Line 52: Public ST1 As String
Line 53: Public ST2 As String
Line 54: End Structure
Line 55:
Line 56: Public Structure Orders
Line 57: Public SaleType As String 'used to identify who processes the sale as well as cost group
Line 58: Public ItemID As String 'reference code for item being sold - set at capture
Line 59: Public Quantity As Integer 'number of items being ordered - set at capture
Line 60: Public Description As String 'description of item - set at capture
Line 61: Public Price As Double 'price of item excluding postage incl VAT- set at capture
Line 62: Public Cost As Double 'order cost = qty * price - set at capture incl VAT
Line 63: Public VATrate As Double 'VAT rate % - set at capture
Line 64: Public VAT As Double 'VAT chargeable = Price /(1+ rate)
Line 65: End Structure
Line 66:
Line 67: Public Structure OrderHeader
Line 68: Public ohID As Integer
Line 69: Public OrderNo As Integer
Line 70: Public TransType As String
Line 71: Public MemberNo As Integer 'member number or trader id
Line 72: Public ClientID As Integer 'Guid of non-member sale not fully implemented as member only sales
Line 73: Public Name As String 'client Name
Line 74: Public email As String 'client email address
Line 75: Public Other As String 'additional information applying to the order, eg delivery details.
Line 76: Public Postage As Integer 'postage costs in pence
Line 77: Public PostVAT As Double 'VAT rate for VAT inlcuded in postage as decimal eg 0.2 for 20%
Line 78: Public AmtToPay As Integer 'total amount to pay incl postage
Line 79: Public AmtPaid As Integer 'actual amount paid
Line 80: Public PayType As String 'how the payment was made, eg online, paypal
Line 81: Public ohOsID As Integer 'Order Status via link
Line 82: Public PayAdjust As Integer 'adjustment if manual payment not equal to order value
Line 83: Public PayNotes As String 'notes regarding manual payment details.
Line 84: Public Address1 As String
Line 85: Public Address2 As String
Line 86: Public Address3 As String
Line 87: Public Town As String
Line 88: Public County As String
Line 89: Public PostCode As String
Line 90: Public Country As String
Line 91: Public DateSubmitted As Date
Line 92:
Line 93: End Structure
Line 94:
Line 95: Public Structure OrderCart
Line 96: Public ID As Integer 'autonumber
Line 97: Public UserID As String 'GUID to identify user
Line 98: Public MemberNo As Integer 'Membership number if member, default 0
Line 99: Public OrderSiid As Integer 'Order Number
Line 100: Public Title As String 'title of shop item
Line 101: Public Quantity As String 'quantity ordered
Line 102: Public UnitPrice As Integer 'Price per unit
Line 103: Public Notes As String 'special instructions, eg colour
Line 104: Public DateAdded As String 'date item added to cart.
Line 105: End Structure
Line 106:
Line 107: Public Structure OrderDetails 'needs to contain sufficient detail to stand alone for not shop sales
Line 108: Public SaleItem As Integer 'link to shop item
Line 109: Public Title As String 'Short description of item
Line 110: Public SaleType As String 'SaleType of item
Line 111: Public odscID As Integer 'link to SalesCategories
Line 112: Public Person As String 'Additional information on sale eg Name to be added.
Line 113: Public Notes As String 'Details Of Variant, eg colour
Line 114: Public Quantity As Integer 'quantity being ordered.
Line 115: Public UnitPrice As Integer 'price per unit in pence incl VAT
Line 116: Public AmtToPay As Integer 'actual cost of item to client.
Line 117: Public Discount As Double 'discount rate % as decimal eg 0.1 for 10%
Line 118: Public VATrate As Double 'VAT rate % as decimal eg 0.2 for 20%
Line 119: Public VAT As Integer 'vat included in cost - calculated in checkout
Line 120: End Structure
Line 121:
Line 122: Public Structure PP
Line 123: Public Title As String
Line 124: Public Description As String
Line 125: Public Zone As String
Line 126: Public ShareGroup As String
Line 127: Public Combine As Boolean
Line 128: Public Qty1 As Integer
Line 129: Public Qty2 As Integer
Line 130: Public Qty3 As Integer
Line 131: Public Price1 As Integer
Line 132: Public Price2 As Integer
Line 133: Public Price3 As Integer
Line 134: End Structure
Line 135:
Line 136: Public Structure SalesCategory
Line 137: Public scid As Integer
Line 138: Public Name As String
Line 139: Public Deleted As Boolean
Line 140: Public Description As String
Line 141: Public Email As String
Line 142: Public ImageURL As String
Line 143: Public LongDescription As String
Line 144: Public Shop As Boolean
Line 145: Public Intro As String
Line 146: Public Sort As String
Line 147: End Structure
Line 148:
Line 149: Public Structure SalesItem
Line 150: Public siID As Integer 'unique reference = 0 if item empty
Line 151: Public SaleType As String
Line 152: Public siscID As Integer 'link to Sales Categories - will replace SaleType
Line 153: Public Title As String 'short description of sales itemR As String
Line 154: Public Description As String 'html formatted
Line 155: Public DescriptionRaw As String 'plain text
Line 156: Public CompanyAbbreviation As String
Line 157: Public Company As String
Line 158: Public Publisher As String
Line 159: Public Price As Integer 'standard price per unit in pence
Line 160: Public MemberPrice As Integer 'member price per unit in pence - default is null in database, 0 in structure
Line 161: Public isMemberPrice As Boolean 'used to check if MemberPrice is used, not a database field
Line 162: Public VATrate As Double 'VAT rate % as decimal eg 0.2 for 20%
Line 163: Public Discount As Double 'discount % as decimal
Line 164: Public ImagePath As String 'url for image
Line 165: Public StockLevel As Integer
Line 166: Public UseStockLevel As Boolean 'default is False
Line 167: Public AllowPreOrder As Boolean 'default is True
Line 168: Public Deleted As Boolean
Line 169: Public Notes As String 'allow for variants
Line 170: Public Person As String 'allow for personalisation - not part of SalesItem database
Line 171: Public PersonPrice As Integer 'personalisation cost in pence
Line 172: Public sipgID As Integer 'postage group
Line 173: Public MemberOnly As Boolean 'restrict sales to members
Line 174: Public ShowNonMembers As Boolean 'show member only items to non members - default = true
Line 175: Public OnSaleDate As DateTime 'inclusive
Line 176: Public OffSaleDate As DateTime 'inclusive
Line 177: Public Sku As String 'Stock Reference
Line 178: Public DateAdded As DateTime 'default is Now()
Line 179: Public Featured As Boolean 'default is false
Line 180: Public sivcID As Integer 'VAT ID
Line 181: Public Download As Boolean 'item is only available by download - default is false.
Line 182: Public DownloadURL As String 'URL to download item from.
Line 183: End Structure
Line 184:
Line 185: Public Structure TicketCounts
Line 186: Public TicketCount As Integer
Line 187: Public TicketCountMember As Integer
Line 188: Public TicketCountNonMember As Integer
Line 189: Public VenueCount As Integer
Line 190: End Structure
Line 191:
Line 192: Public Structure TicketVenues
Line 193: Public VenueCode As String
Line 194: Public VenueDesc As String
Line 195:
Line 196: End Structure
Line 197:
Line 198: Public Structure TicketDetail
Line 199: Public TicketNumber As String
Line 200: Public TicketTitle As String
Line 201: Public TicketFirstName As String
Line 202: Public TicketSurname As String
Line 203: Public Ticketemail As String
Line 204: Public TicketBarcodeSource As String
Line 205: Public TicketPrice As Double
Line 206: Public TicketemailText As String
Line 207: Public TicketST1 As String
Line 208: End Structure
Line 209:
Line 210: Public Structure TraderDetail
Line 211: Public TraderCode As String
Line 212: Public TraderName As String
Line 213: Public TraderContact As String
Line 214: Public TraderEmail As String
Line 215: End Structure
Line 216:
Line 217: Dim defaultEmail As String = ConfigurationManager.AppSettings("memberEmail")
Line 218: Dim gogfromDefault As String = "confirm13@gaugeoguild.com"
Line 219: Dim gogfromDisplay As String = "Gauge O Guild"
Line 220: Public gogAddress As String = "The Gauge O Guild Ltd, 6 Kings Buildings, Hill Street, Lydney GL15 5HE"
Line 221: Dim gogNewLine As String = "<br />"
Line 222:
Line 223: Public Sub SetOrderID(ByVal retOrderID As String, ByRef WPSaleType As String, ByRef SalesOrderID As Object, ByRef SubYear As Integer, ByRef gogOrderID As Integer)
Line 224: Dim i As Integer = 0
Line 225: 'SalesOrderID input type not defined for compatibility between old and new order systems.
Line 226:
Line 227: WPSaleType = ""
Line 228: If IsNumeric(retOrderID) Then
Line 229: WPSaleType = "Memb"
Line 230: SubYear = CInt(Left(retOrderID, 4))
Line 231: gogOrderID = CInt(Right(retOrderID, Len(retOrderID) - 4))
Line 232: SalesOrderID = 0
Line 233: Else
Line 234: i = 1
Line 235: Do Until IsNumeric(Mid(retOrderID, i, 1)) Or i >= retOrderID.Length
Line 236: WPSaleType = WPSaleType + Mid(retOrderID, i, 1)
Line 237: i = i + 1
Line 238: Loop
Line 239: If IsNumeric(Right(retOrderID, Len(retOrderID) - i + 1)) Then
Line 240: SalesOrderID = Right(retOrderID, Len(retOrderID) - i + 1)
Line 241: Else
Line 242: SalesOrderID = 0
Line 243: End If
Line 244: End If
Line 245: End Sub
Line 246:
Line 247: Public Sub SendTicket(ByVal Orderid As Integer, ByVal OrderDetails As String, toEmail As String, ByVal SenderCopy As String, ByVal testmode As Integer, ByRef sMsg As String)
Line 248: Dim TDES As New TripleDES
Line 249: Dim Ticket(50) As OnlineSales.TicketDetail
Line 250: Dim Venues(10) As OnlineSales.TicketVenues
Line 251: Dim TicketCounts As New OnlineSales.TicketCounts
Line 252: Dim BcsEncrypted As String = ""
Line 253: Dim BarcodeSource As String = ""
Line 254: Dim emailText As String = ""
Line 255: Dim MembNum As Integer = 0
Line 256: Dim memStream As New System.IO.MemoryStream
Line 257: Dim Barcode As New LinkedResource(memStream, "image/png")
Line 258: Dim htmlView As System.Net.Mail.AlternateView = System.Net.Mail.AlternateView.CreateAlternateViewFromString("temp", Nothing, "text/html")
Line 259: Dim i As Integer = 0
Line 260:
Line 261: Dim sMsg1 As String = ""
Line 262: Dim mmfrom As New MailAddress("confirm13@gaugeoguild.com", "Gauge O Guild")
Line 263: Dim mmto As New MailAddress("confirm13@gaugeoguild.com")
Line 264: Dim mm As New MailMessage
Line 265: Dim ohID As Integer = 0
Line 266: Dim rs As OleDbDataReader
Line 267:
Line 268: Dim ShopFormat As Boolean = True
Line 269: Dim smtp As New SmtpClient
Line 270: Dim sBody As String = ""
Line 271: Dim memName As String = ""
Line 272: Dim memNumber As Integer = 0
Line 273: Dim memVenues As String = ""
Line 274: Dim memComp As String = ""
Line 275:
Line 276: Using con As New OleDbConnection 'check is this order is in the Shop
Line 277: con.ConnectionString = ConfigurationManager.ConnectionStrings("onlinesalesConnectionString").ConnectionString
Line 278: con.Open()
Line 279: Dim cmdOrders As OleDbCommand = New OleDbCommand("SELECT * FROM OrderHeader WHERE ohOrderNo = " & Orderid, con)
Line 280: rs = cmdOrders.ExecuteReader()
Line 281: If rs.HasRows Then
Line 282: rs.Read()
Line 283: ' MembNum = CInt(rs.Item("ohMemberNo"))
Line 284: ' Price = CInt(rs.Item("ohAmtToPay")) / 100
Line 285: ' ' Postage = CInt(rs.Item("ohPostage"))
Line 286: ' MembEmail = rs.Item("ohEmail")
Line 287: ' toEmail = rs.Item("ohEmail")
Line 288: ohID = rs.Item("ohID")
Line 289: ' If Not IsDBNull(rs.Item("ohOther")) Then Extras = rs.Item("ohOther")
Line 290: ' 'Price = rs.Item("ohAmtToPay") 'assume to be amount paid in absence of other checks
Line 291: Else
Line 292: ShopFormat = False
Line 293: End If
Line 294: End Using
Line 295:
Line 296: If ShopFormat Then
Line 297: Call LoadTickets(ohID, OrderDetails, Ticket, Venues, TicketCounts)
Line 298: Else
Line 299: Call ReadTicketList(OrderDetails, Orderid, Ticket, Venues, TicketCounts)
Line 300: End If
Line 301:
Line 302: If TicketCounts.VenueCount > 0 Then
Line 303: memVenues = Venues(0).VenueDesc
Line 304: For i = 1 To TicketCounts.VenueCount - 1 Step 1
Line 305: memVenues = memVenues & "<br />" & Venues(i).VenueDesc
Line 306: Next
Line 307: End If
Line 308:
Line 309: If TicketCounts.TicketCount > 0 Then
Line 310: If Ticket(0).TicketNumber = "" Then
Line 311: MembNum = 0
Line 312: Else
Line 313: MembNum = Ticket(0).TicketNumber
Line 314: End If
Line 315:
Line 316: OrderDetails = "Tickets will be sent to the same email address for the following:" & gogNewLine
Line 317: For i = 0 To TicketCounts.TicketCount - 1
Line 318: memName = Ticket(i).TicketTitle & " " & Ticket(i).TicketFirstName & " " & Ticket(i).TicketSurname
Line 319: If memName <> memComp Then 'avoid duplicate lines for same person.
Line 320: If IsNumeric(Ticket(i).TicketNumber) Then
Line 321: If CDbl(Ticket(i).TicketNumber) > 99999 Then
Line 322: OrderDetails += memName & gogNewLine
Line 323: Else
Line 324: OrderDetails += Ticket(i).TicketNumber.ToString & " " & memName & gogNewLine
Line 325: End If
Line 326: Else
Line 327: OrderDetails += memName & gogNewLine
Line 328: End If
Line 329: memComp = memName
Line 330: End If
Line 331: Next
Line 332: End If
Line 333:
Line 334:
Line 335: sMsg = "<p>Order Details" & gogNewLine & OrderDetails & "</p>" 'gogNewLine & gogNewLine
Line 336:
Line 337: 'sMsg = sMsg & gogNewLine & "<p>email: " & Ticket(0).Ticketemail & "</p>" 'gogNewLine
Line 338:
Line 339: mm.Body = "Payment has been received for order no " & Orderid & " from member " & MembNum & " for the following order:" & gogNewLine & sMsg
Line 340: If testmode > 0 Then
Line 341: mm.Body += "http://proof.gauge0guild.com/onlinesales/markdespatched.aspx?OrderId=" & Orderid & gogNewLine & "End of message"
Line 342: Else
Line 343: mm.Body += "http://www.gauge0guild.com/onlinesales/markdespatched.aspx?OrderId=" & Orderid & gogNewLine & "End of message"
Line 344: End If
Line 345: mm.Dispose()
Line 346:
Line 347: memComp = ""
Line 348: For i = 0 To TicketCounts.TicketCount - 1 Step 1
Line 349:
Line 350: BarcodeSource = Ticket(i).TicketBarcodeSource.ToString
Line 351:
Line 352: BcsEncrypted = System.Net.WebUtility.UrlEncode(TDES.Encrypt("orderid=" & ohID & "&bcs=" & BarcodeSource & "&eof=end"))
Line 353: emailText = Replace(Ticket(i).TicketemailText, "**barcodesource**", "?ident=" & BcsEncrypted)
Line 354: memName = Ticket(i).TicketTitle.ToString & " " & Ticket(i).TicketFirstName.ToString & " " & Ticket(i).TicketSurname.ToString
Line 355: If memName <> memComp Then 'check for multiple tickets for same person.
Line 356: mmto = New MailAddress(toEmail.ToString) 'send purchasers ticket, use email address from order table
Line 357: mm = New MailMessage(mmfrom, mmto)
Line 358: If SenderCopy.Length > 0 Then mm.Bcc.Add(SenderCopy)
Line 359: mm.IsBodyHtml = True
Line 360: mm.Subject = "Gauge O Guild Online Sales"
Line 361: If Ticket(i).TicketNumber = "" Then
Line 362: memNumber = 0
Line 363: Else
Line 364: memNumber = CInt(Ticket(i).TicketNumber)
Line 365: End If
Line 366: If i = 0 Then
Line 367: htmlView = System.Net.Mail.AlternateView.CreateAlternateViewFromString(eticket(memVenues, memNumber, memName, CInt(Orderid), BarcodeSource, emailText).ToString & sMsg.ToString & VATreceipt(Orderid, testmode) & gogNewLine & gogAddress & gogNewLine, Nothing, "text/html")
Line 368:
Line 369: Else
Line 370: htmlView = System.Net.Mail.AlternateView.CreateAlternateViewFromString(eticket(memVenues, memNumber, memName, CInt(Orderid), BarcodeSource, emailText).ToString & sMsg.ToString, Nothing, "text/html")
Line 371: End If
Line 372:
Line 373: Barcode = New LinkedResource(getBarcode("*" & BarcodeSource & "*"), "image/png")
Line 374:
Line 375: Barcode.ContentId = "barcodeticket"
Line 376: Barcode.ContentType.MediaType = "image/" + System.Drawing.Imaging.ImageFormat.Png.ToString
Line 377: Barcode.ContentStream.Position = 0
Line 378:
Line 379: htmlView.LinkedResources.Add(Barcode)
Line 380:
Line 381: mm.AlternateViews.Add(htmlView)
Line 382:
Line 383: Try
Line 384: smtp.Send(mm)
Line 385: Catch ex As Exception
Line 386: sMsg = "send email failed error = " & Err().ToString
Line 387: SendErrorMsg("OnlineSales SendTicket", sMsg)
Line 388: 'Response.Write("Send sales message error to customer" & Err.ToString & "<br>")
Line 389: End Try
Line 390: mm.Dispose()
Line 391: memComp = memName
Line 392: 'Else
Line 393: End If
Line 394: Next
Line 395:
Line 396: End Sub
Line 397:
Line 398: Function eticket(ByVal venue As String, ByVal membnumber As Integer, ByVal membname As String, ByVal orderid As Integer, ByVal BarCodeSource As String, ByVal emailText As String) As String
Line 399: Dim sBody As String
Line 400: sBody = "<p>Thank you for your order no " & orderid & ". Keep this email as your record of purchase." & gogNewLine
Line 401:
Line 402:
Line 403: ' sBody = sBody & "Joining instructions and a Zoom link will be sent to you a week before the event." & gogNewLine
Line 404: 'If membnumber > 0 Then
Line 405: ' sBody = sBody & "The stewards may also ask you for your membership card and make a check against Guild Records." & gogNewLine & gogNewLine
Line 406: 'Else
Line 407: ' sBody = sBody & "The stewards may also make a check against Guild Records." & gogNewLine & gogNewLine
Line 408: 'End If
Line 409: If emailText Is Nothing Then
Line 410: sBody = sBody & "Please print this email and use it as your advance ticket." & gogNewLine
Line 411: 'sBody = sBody & "Joining instructions and a Zoom link will be sent to you a week before the event." & gogNewLine
Line 412: Else
Line 413: sBody += emailText & gogNewLine
Line 414: End If
Line 415:
Line 416: sBody = sBody & "</p>"
Line 417: sBody = sBody & "<table style='border: 4px solid #000080; height: 400px; width: 500px'>"
Line 418: sBody = sBody & "<tr><td align='center' style='font-family: "Bodoni MT Black"; font-size: x-large; color: #0000FF'>Gauge O Guild E-TICKET</td></tr>"
Line 419: If MaxLineLength(venue) > 20 Then
Line 420: sBody = sBody & "<tr><td style='border-bottom: thin solid #000080; font-family: " & """Times New Roman"", " & "Times, serif; font-size: x-large; font-weight: bolder; text-align: center; border-left-color: #000080; border-right-color: #000080; border-top-color: #000080;'>"
Line 421: Else
Line 422: sBody = sBody & "<tr><td style='border-bottom: thin solid #000080; font-family: " & """Times New Roman"", " & "Times, serif; font-size: xx-large; font-weight: bolder; text-align: center; border-left-color: #000080; border-right-color: #000080; border-top-color: #000080;'>"
Line 423: End If
Line 424: sBody = sBody & venue & "</td></tr>"
Line 425: sBody = sBody & "<tr><td style='font-family: " & """Times New Roman"", " & "Times, serif; font-size: xx-large; font-weight: bolder; text-align: center;'>"
Line 426: If membnumber > 0 And membnumber < 99999 Then
Line 427: sBody += "GOG " & membnumber & "</td></tr>"
Line 428: Else
Line 429: sBody += "ORD " & orderid & "</td></tr>"
Line 430: End If
Line 431: sBody = sBody & "<tr><td style=' font-family: " & """Times New Roman"", " & "Times, serif; font-size: xx-large; font-weight: bolder; text-align: center;'>"
Line 432: sBody = sBody & membname + "</td></tr>"
Line 433: sBody += "<tr><td style=""text-align:center""><img src= 'cid:barcodeticket'></td></tr>"
Line 434: sBody += "<tr><td style=""text-align:center"">" & "*" & BarCodeSource & "*" & "</td></tr>"
Line 435: sBody = sBody + "</table>"
Line 436: sBody = sBody + "<p> </p>"
Line 437: ' Response.Write("eticket sBody=:</br>" & sBody)
Line 438: eticket = sBody
Line 439: End Function
Line 440:
Line 441: Public Sub LoadTickets(ByVal ohID As Integer, ByRef OrderDetails As String, ByRef Ticket As TicketDetail(), ByRef TicketVenue() As TicketVenues, ByRef TicketCounts As TicketCounts)
Line 442: Dim odscID As Integer = getscID("Tickets")
Line 443: Dim rsDet As OleDbDataReader
Line 444: Dim VenueFound As Boolean = False
Line 445:
Line 446: Using con As New OleDbConnection 'using shop format
Line 447: con.ConnectionString = ConfigurationManager.ConnectionStrings("onlinesalesConnectionString").ConnectionString
Line 448: con.Open()
Line 449: Dim cmdOrderDet As OleDbCommand = New OleDbCommand("SELECT * FROM OrdDetails WHERE odOhID = " & ohID & " ORDER BY odSaleType, odPerson, odTitle ", con)
Line 450: rsDet = cmdOrderDet.ExecuteReader()
Line 451: TicketCounts.TicketCountMember = 0
Line 452: TicketCounts.TicketCountNonMember = 0
Line 453: TicketCounts.VenueCount = 0
Line 454: TicketCounts.TicketCount = 0
Line 455:
Line 456: If rsDet.HasRows Then
Line 457: OrderDetails = "Tickets will be sent to the same email address for the following:" & gogNewLine
Line 458: Do While rsDet.Read
Line 459: 'generate emails for the processing of the order. (purchaser will receive a VAT receipt with details)
Line 460: VenueFound = False
Line 461: If rsDet.Item("odscID") = odscID Or rsDet.Item("odSaleType") = "Etkt" Or rsDet.Item("odSaleType") = "Vtkt" Then
Line 462: For i = 0 To TicketCounts.VenueCount - 1 Step 1
Line 463: If TicketVenue(i).VenueDesc = rsDet.Item("odTitle") Then
Line 464: i = TicketCounts.VenueCount
Line 465: VenueFound = True
Line 466: End If
Line 467: Next
Line 468: If Not VenueFound Then
Line 469: ' Venues(TicketCounts.VenueCount).VenueCode =
Line 470: TicketVenue(TicketCounts.VenueCount).VenueDesc = rsDet.Item("odTitle")
Line 471: TicketCounts.VenueCount += 1
Line 472: End If
Line 473:
Line 474: With Ticket(TicketCounts.TicketCount)
Line 475: .TicketNumber = rsDet.Item("odNotes")
Line 476: .TicketTitle = ""
Line 477: .TicketFirstName = ""
Line 478: .TicketSurname = rsDet.Item("odPerson")
Line 479: .Ticketemail = ""
Line 480: .TicketBarcodeSource = rsDet.Item("odNotes")
Line 481: .TicketemailText = getTicketDef(rsDet.Item("odsiID")).TicketemailText 'needs to read tickets record.
Line 482: OrderDetails += rsDet.Item("odTitle") & " for "
Line 483: If .TicketNumber.Length > 1 Then
Line 484: OrderDetails += .TicketNumber.ToString & " " & .TicketTitle & " " & .TicketFirstName & " " & .TicketSurname & gogNewLine
Line 485: Else
Line 486: OrderDetails += .TicketTitle & " " & .TicketFirstName & " " & .TicketSurname & gogNewLine
Line 487: End If
Line 488:
Line 489: If IsNumeric(.TicketNumber) Then
Line 490: TicketCounts.TicketCountMember += 1
Line 491: Else
Line 492: TicketCounts.TicketCountNonMember += 1
Line 493: End If
Line 494: TicketCounts.TicketCount += 1
Line 495: End With
Line 496: If TicketCounts.TicketCount >= 50 Then 'too many tickets per order
Line 497: Stop
Line 498: End If
Line 499:
Line 500: End If
Line 501: Loop
Line 502: End If
Line 503:
Line 504:
Line 505:
Line 506: End Using
Line 507:
Line 508: End Sub
Line 509:
Line 510: Public Sub ReadTicketList(ByVal TicketList As String, ByVal OrderNo As Integer, ByRef Ticket As TicketDetail(), ByRef TicketVenue() As TicketVenues, ByRef TicketCounts As TicketCounts)
Line 511:
Line 512: Dim TicketStart As Integer = InStr(1, TicketList, "{")
Line 513: Dim TicketEnd As Integer = 0
Line 514: Dim EndMember As String = ""
Line 515: Dim memchar As String = ""
Line 516: Dim i As Integer = 1
Line 517: Dim tempint As Integer = 0
Line 518: Dim memliststart As Integer = 0
Line 519: Dim memlistend As Integer = 0
Line 520: Dim memVenues As String = ""
Line 521:
Line 522: TicketCounts.TicketCountMember = 0
Line 523: TicketCounts.TicketCountNonMember = 0
Line 524: TicketCounts.VenueCount = 0
Line 525:
Line 526: If TicketStart > 0 Then 'this routine only works on format with {}
Line 527: TicketStart += 1
Line 528: TicketEnd = Len(TicketList)
Line 529:
Line 530: memliststart = InStr(1, TicketList, "(")
Line 531: ' 'response.write("Venues memliststart=:" & memliststart & ": orderdetails=:" & orderdetails & ":</br>")
Line 532: If memliststart > 0 Then
Line 533: memliststart = memliststart + 1
Line 534: memlistend = TicketList.Length
Line 535:
Line 536: If memlistend > 0 Then 'Event code found
Line 537: Do Until memliststart >= memlistend Or memliststart <= 0
Line 538: EndMember = InStr(memliststart, TicketList, ")")
Line 539: ' If Len(memVenues) = 0 Then
Line 540: TicketVenue(TicketCounts.VenueCount).VenueCode = Mid(TicketList, memliststart, EndMember - memliststart)
Line 541: ' Else
Line 542: ' memVenues = memVenues & "<br />" & Mid(TicketList, memliststart, EndMember - memliststart)
Line 543: ' End If
Line 544: memliststart = EndMember + 1
Line 545: memliststart = InStr(memliststart, TicketList, "[")
Line 546: If memliststart > 0 Then memliststart = memliststart + 1
Line 547: 'response.write("Venues memliststart loop=:" & memliststart & "</br>")
Line 548: EndMember = InStr(memliststart, TicketList, "]")
Line 549: TicketVenue(TicketCounts.VenueCount).VenueDesc = Mid(TicketList, memliststart, EndMember - memliststart)
Line 550: TicketCounts.VenueCount += 1
Line 551: memliststart = EndMember + 1
Line 552: memliststart = InStr(memliststart, TicketList, "(")
Line 553: Loop
Line 554: 'response.write("memVenues=:" & memVenues & "</br>")
Line 555: End If
Line 556: End If
Line 557:
Line 558:
Line 559: EndMember = InStr(TicketStart, TicketList, "}")
Line 560: TicketList = Mid(TicketList, TicketStart, TicketEnd - TicketStart - 1)
Line 561:
Line 562: i = 1
Line 563: TicketCounts.TicketCount = 0
Line 564: Do While i <= TicketList.Length
Line 565: With Ticket(TicketCounts.TicketCount)
Line 566: .TicketNumber = ""
Line 567: .TicketTitle = ""
Line 568: .TicketFirstName = ""
Line 569: .TicketSurname = ""
Line 570: .Ticketemail = ""
Line 571: .TicketBarcodeSource = ""
Line 572:
Line 573: Do While i <= TicketList.Length And Mid(TicketList, i, 1) <> ";" And Mid(TicketList, i, 1) <> ":"
Line 574: .TicketNumber += Mid(TicketList, i, 1)
Line 575: i += 1
Line 576: Loop
Line 577: If .TicketNumber.Length > 1 Then
Line 578: .TicketBarcodeSource = .TicketNumber.ToString
Line 579: TicketCounts.TicketCountMember += 1
Line 580: Else
Line 581: .TicketNumber = ""
Line 582: memchar = OrderNo.ToString
Line 583: Do While memchar.Length < 6
Line 584: memchar = "0" + memchar
Line 585: Loop
Line 586: .TicketBarcodeSource = "5" & memchar
Line 587: memchar = TicketCounts.TicketCount.ToString
Line 588: Do While memchar.Length < 2
Line 589: memchar = "0" + memchar
Line 590: Loop
Line 591: .TicketBarcodeSource += memchar
Line 592: TicketCounts.TicketCountNonMember += 1
Line 593: End If
Line 594: i += 1
Line 595: Do While i <= TicketList.Length And Mid(TicketList, i, 1) <> ";" And Mid(TicketList, i, 1) <> ":"
Line 596: .TicketTitle += Mid(TicketList, i, 1)
Line 597: i += 1
Line 598: Loop
Line 599: i += 1
Line 600: Do While i <= TicketList.Length And Mid(TicketList, i, 1) <> ";" And Mid(TicketList, i, 1) <> ":"
Line 601: .TicketFirstName += Mid(TicketList, i, 1)
Line 602: i += 1
Line 603: Loop
Line 604: i += 1
Line 605: Do While i <= TicketList.Length And Mid(TicketList, i, 1) <> ";" And Mid(TicketList, i, 1) <> ":"
Line 606: .TicketSurname += Mid(TicketList, i, 1)
Line 607: i += 1
Line 608: Loop
Line 609: i += 1
Line 610: Do While i <= TicketList.Length And Mid(TicketList, i, 1) <> ";" And Mid(TicketList, i, 1) <> ":"
Line 611: .Ticketemail += Mid(TicketList, i, 1)
Line 612: i += 1
Line 613: Loop
Line 614: End With
Line 615: TicketCounts.TicketCount += 1
Line 616: If TicketCounts.TicketCount >= 50 Then 'too many tickets per order
Line 617: Stop
Line 618: End If
Line 619: i += 1
Line 620: Loop
Line 621:
Line 622: End If
Line 623: End Sub
Line 624:
Line 625: Public Function getBarcode(ByVal id As String) As System.IO.MemoryStream
Line 626: Dim draw As New Zen.Barcode.Code128BarcodeDraw(Zen.Barcode.Code128Checksum.Instance)
Line 627:
Line 628: Dim barcodeimage As Drawing.Image = draw.Draw(id, 70, 1)
Line 629:
Line 630: 'Dim arr As Byte()
Line 631:
Line 632: Dim memStream As New System.IO.MemoryStream
Line 633: barcodeimage.Save(memStream, Drawing.Imaging.ImageFormat.Png)
Line 634: memStream.Position = 0
Line 635: ' arr = memStream.ToArray()
Line 636:
Line 637: Return memStream
Line 638:
Line 639: End Function
Line 640:
Line 641:
Line 642: Public Sub Shop(SalesOrderID As Integer, ByRef retEmail As String, retPayType As String, ByVal SenderCopy As String, ByVal testmode As Integer, ByRef sMsg As String, ByVal Resend As Boolean)
Line 643: Dim mfrom As gogmail.gogMailAddress
Line 644: mfrom.gogAddress = gogfromDefault '"confirm13@gaugeoguild.com"
Line 645: mfrom.gogDisplayName = gogfromDisplay '"Gauge O Guild"
Line 646: Dim mto As gogmail.gogMailAddress
Line 647: mto.gogAddress = defaultEmail '"confirm13@gaugeoguild.com"
Line 648: Dim mCC(5) As gogmail.gogMailAddress
Line 649: Dim mSubject As String = ""
Line 650: Dim mBody As String = ""
Line 651: Dim sendresult As String = ""
Line 652:
Line 653: ' Dim AmtPaid As Integer = 0
Line 654: Dim Client As OnlineSales.MemberDet
Line 655: ' Dim eName As String = ""
Line 656: ' Dim dvOrderDet As DataView
Line 657: ' Dim Extras As String = ""
Line 658: Dim gogmail As New gogmail
Line 659: Dim iMemberNr As Integer = 0
Line 660: Dim itemCount As Integer = 0
Line 661: Dim link As String = ""
Line 662: Dim member As New OnlineSales.MemberDet
Line 663: Dim memberfound As Boolean
Line 664: ' Dim MembNum As Integer = 0
Line 665: ' Dim ohID As Integer = 0
Line 666: Dim OrderComplete As Boolean = True 'will be set false by any items not downloadable
Line 667: Dim OrderHeader As OnlineSales.OrderHeader
Line 668: ' Dim Postage As Integer = 0
Line 669: ' Dim Price As Integer = 0
Line 670: Dim retamount As Double = 0
Line 671: 'Dim retemail As String = ""
Line 672: ' Dim rs As OleDbDataReader
Line 673: Dim rsDet As OleDbDataReader
Line 674: Dim SaleType As Integer = 0
Line 675: Dim sBody As New StringBuilder
Line 676: ' Dim sMsg As String = ""
Line 677: Dim sMsgOrd As String = ""
Line 678: Dim sQty As String = ""
Line 679: Dim str As String = ""
Line 680:
Line 681: If testmode > 0 Then
Line 682: If testmode = 110 Then
Line 683: link = "localHost:49300/onlinesales/fulfilment.aspx?Orderid="
Line 684: Else
Line 685: link = "https://proof.gaugeoguild.com/onlinesales/fulfilment.aspx?Orderid="
Line 686: End If
Line 687: Else
Line 688: link = "https://www.gaugeoguild.com/onlinesales/fulfilment.aspx?Orderid="
Line 689: End If
Line 690:
Line 691: ' If Actionee = "" Then Actionee = Author
Line 692: ' mto.gogAddress = Actionee
Line 693: mCC(0).gogAddress = SenderCopy
Line 694: mCC(0).gogType = "Bcc"
Line 695: mSubject = "Gauge O Guild Online Shop"
Line 696:
Line 697: OrderHeader = getOrderHeader(SalesOrderID)
Line 698: retEmail = OrderHeader.email
Line 699: Client = getClient(OrderHeader.ohID, 0)
Line 700: ' OnlineSales.GetMemberDetails(MembNum, member, memberfound)
Line 701: If OrderHeader.MemberNo > 0 Then
Line 702: ' eName = member.Name
Line 703: sMsg = Client.Name & " (" & OrderHeader.MemberNo.ToString & ")" & gogNewLine
Line 704: sMsg += Client.FormattedAddress & gogNewLine 'address is full country specific postal address
Line 705: Else
Line 706: ' With dvSales.Item(0)
Line 707: ' eName = .Item("client")
Line 708: sMsg = Client.Name & gogNewLine
Line 709: sMsg += Client.FormattedAddress & gogNewLine
Line 710: ' End With
Line 711: End If
Line 712:
Line 713: sMsg += "email: " & OrderHeader.email & gogNewLine
Line 714:
Line 715: Using con As New OleDbConnection
Line 716: con.ConnectionString = ConfigurationManager.ConnectionStrings("onlinesalesConnectionString").ConnectionString
Line 717: con.Open()
Line 718: Dim cmdOrderDet As OleDbCommand = New OleDbCommand("SELECT * FROM OrdDetails WHERE odOhID = " & OrderHeader.ohID & " ORDER BY odscID, odTitle ", con)
Line 719: rsDet = cmdOrderDet.ExecuteReader()
Line 720: If rsDet.HasRows Then
Line 721: Do While rsDet.Read
Line 722: 'generate emails for the processing of the order.
Line 723: With rsDet
Line 724: If IsDBNull(.Item("odscID")) Then
Line 725: SaleType = 0
Line 726: ElseIf .Item("odscID") = SaleType Then
Line 727: If CInt(.Item("odQuantity")) > 0 Then
Line 728: sQty = "Quantity: " & .Item("odQuantity").ToString & " "
Line 729: Else
Line 730: sQty = ""
Line 731: End If
Line 732: sMsgOrd += ProcessOrder(rsDet, .Item("odQuantity"), OrderComplete, Resend)
Line 733:
Line 734: Else
Line 735: If SaleType <> 0 Then 'send previous SaleType for order processing
Line 736: mto.gogAddress = ShopActionee(SaleType, testmode)
Line 737: If OrderHeader.Other <> "" Then sMsgOrd += OrderHeader.Other & gogNewLine & gogNewLine
Line 738: If memberfound Then
Line 739: mBody = "Payment has been received For order no " & SalesOrderID & " from member " & OrderHeader.MemberNo & " For the following item(s) : " & gogNewLine & sMsgOrd & sMsg
Line 740: Else
Line 741: mBody = "Payment has been received for order no " & SalesOrderID & " for the following item(s):" & gogNewLine & sMsgOrd & sMsg
Line 742: End If
Line 743:
Line 744: str = "<a href='" & link & SalesOrderID & "&ohID=" & OrderHeader.ohID & "&odscID=" & SaleType & "&complete=all'>Mark Order Complete</a>" & gogNewLine
Line 745: str += "<a href='" & link & SalesOrderID & "&ohID=" & OrderHeader.ohID & "&odscID=" & SaleType & "&complete=part'>Mark Despatched Items</a>" & gogNewLine & "End of message"
Line 746: mBody += str
Line 747:
Line 748: sendresult = gogmail.ggMail(mfrom, mto, mSubject, mBody, mCC)
Line 749: If sendresult <> "Email sent" Then SendErrorMsg("Online Sales vb Send Error", "Send sales message (else) error to officers " & sendresult & gogNewLine)
Line 750: 'If sendresult <> "Email sent" Then Response.Write("Send sales message (else) error to officers " & sendresult & gogNewLine)
Line 751: End If
Line 752:
Line 753: SaleType = .Item("odscID")
Line 754: mto.gogAddress = ShopActionee(SaleType, testmode)
Line 755: If CInt(.Item("odQuantity")) > 0 Then
Line 756: sQty = "Quantity: " & .Item("odQuantity").ToString & " "
Line 757: Else
Line 758: sQty = ""
Line 759: End If
Line 760: sMsgOrd = ProcessOrder(rsDet, .Item("odQuantity"), OrderComplete, Resend)
Line 761:
Line 762: End If
Line 763: End With
Line 764: Loop
Line 765: Else
Line 766: SendErrorMsg("Online Sales vb Send Error", "Case Else shop order Details record not found record not found<br>")
Line 767: 'Response.Write("Case Else shop order Details record not found record not found<br>")
Line 768: End If
Line 769: End Using
Line 770:
Line 771: 'Send the last or only SaleType
Line 772:
Line 773: If OrderHeader.Postage > 0 Then sMsgOrd += " Postage: £" & FormatNumber(OrderHeader.Postage / 100, 2) & gogNewLine & gogNewLine
Line 774: If OrderHeader.PayAdjust > 0 Then sMsgOrd += " Donation: £" & FormatNumber(OrderHeader.PayAdjust / 100, 2) & gogNewLine & gogNewLine
Line 775: If OrderHeader.PayAdjust < 0 Then sMsgOrd += " Adjustment: £" & FormatNumber(OrderHeader.PayAdjust / 100, 2) & gogNewLine & gogNewLine
Line 776: sMsgOrd += " Amount Paid: £" & FormatNumber(OrderHeader.AmtToPay / 100, 2) & gogNewLine & gogNewLine
Line 777: If OrderHeader.Other <> "" Then sMsgOrd += OrderHeader.Other & gogNewLine & gogNewLine
Line 778:
Line 779: If memberfound Then
Line 780: mBody = "Payment has been received for order no " & SalesOrderID & " from member " & OrderHeader.MemberNo & " for the following item(s):" & gogNewLine & sMsgOrd & sMsg
Line 781: Else
Line 782: mBody = "Payment has been received for order no " & SalesOrderID & " for the following item(s):" & gogNewLine & sMsgOrd & sMsg
Line 783: End If
Line 784:
Line 785:
Line 786: str = "<a href='" & link & SalesOrderID & "&ohID=" & OrderHeader.ohID & "&odscID=" & SaleType & "&complete=all'>Mark Order Complete</a>" & gogNewLine
Line 787: str += "<a href='" & link & SalesOrderID & "&ohID=" & OrderHeader.ohID & "&odscID=" & SaleType & "&complete=part'>Mark Despatched Items</a>" & gogNewLine & "End of message"
Line 788: mBody += str
Line 789:
Line 790: If Not Resend Then
Line 791: sendresult = gogmail.ggMail(mfrom, mto, mSubject, mBody, mCC)
Line 792: If sendresult <> "Email sent" Then SendErrorMsg("Online Sales vb Send Error", "Send sales message (else) error to officers " & sendresult & gogNewLine)
Line 793: ' If sendresult <> "Email sent" Then Response.Write("Send sales message (else) error to officers " & sendresult & gogNewLine)
Line 794: End If
Line 795:
Line 796: 'Send message to customer
Line 797: sBody.Append("Thank you for your order no ").Append(SalesOrderID).Append(". Please keep this email as your record of purchase.").Append(gogNewLine)
Line 798: sBody.Append(" If you have ordered goods they will be despatched to the address below as soon as our volunteers are able to do so.")
Line 799: sBody.Append(" Otherwise this email can be used as evidence of purchase and may be checked against Guild records.").Append(gogNewLine).Append(gogNewLine)
Line 800:
Line 801: If Not Resend Then
Line 802: Using con As New OleDbConnection 'update order header status
Line 803: con.ConnectionString = ConfigurationManager.ConnectionStrings("onlinesalesConnectionString").ConnectionString
Line 804: con.Open()
Line 805: 'set paid (=3)
Line 806: Dim cmdUpdate As OleDbCommand = New OleDbCommand("UPDATE OrderHeader SET ohosID = @ohosID, ohAmtPaid = " & OrderHeader.AmtToPay.ToString & ", ohPayType = '" & retPayType & "', ohDateSubmitted = @DateSubmitted WHERE (ohID = " & OrderHeader.ohID.ToString & ")", con)
Line 807: If OrderComplete Then
Line 808: cmdUpdate.Parameters.AddWithValue("@ohosID", getosID("Complete")) 'all items are downloadable
Line 809: Else
Line 810: cmdUpdate.Parameters.AddWithValue("@ohosID", getosID("Paid"))
Line 811: End If
Line 812: cmdUpdate.Parameters.Add("@DateSubmitted", OleDbType.Date)
Line 813: cmdUpdate.Parameters("@DateSubmitted").Value = Now
Line 814: cmdUpdate.ExecuteNonQuery()
Line 815: End Using
Line 816: StockLevels(SalesOrderID) 'update StockLevels
Line 817: ' gogOrderidLabel.Text = SalesOrderID.ToString
Line 818: ' '' PriceLabel.Text = FormatNumber(OrderHeader.AmtToPay / 100, 2)
Line 819: ' emailLabel.Text = retemail.ToString
Line 820: ' MultiView1.ActiveViewIndex = 2
Line 821: End If
Line 822:
Line 823:
Line 824: If Not retEmail = "" Then
Line 825:
Line 826: mto.gogAddress = retEmail.ToString
Line 827: mto.gogDisplayName = Client.eName
Line 828: mSubject = "Gauge O Guild Online Shop"
Line 829:
Line 830: mBody = sBody.Append(VATreceipt(SalesOrderID, testmode)).Append(sMsg).Append(gogNewLine & gogAddress & gogNewLine & OrderHeader.Other & gogNewLine).ToString
Line 831: If Resend Then
Line 832: sendresult = gogmail.ggMail(mfrom, mto, mSubject, mBody, mCC)
Line 833: Else
Line 834: sendresult = gogmail.ggMail(mfrom, mto, mSubject, mBody)
Line 835: End If
Line 836:
Line 837: If sendresult <> "Email sent" Then SendErrorMsg("Online Sales vb Send Error", "Send sales message (else) error to customer " & sendresult & gogNewLine)
Line 838: ' If sendresult <> "Email sent" Then Response.Write("Send sales message (else) error to customer " & sendresult & gogNewLine)
Line 839: End If
Line 840: ' Session("SalesBasket") = ""
Line 841: 'Session.Remove("SalesBasket")
Line 842: End Sub
Line 843:
Line 844: Public Sub StandBookings(SalesOrderID As Integer, ByRef retEmail As String, retPayType As String, ByVal SenderCopy As String, ByVal testmode As Integer, ByRef sMsg As String, ByVal Resend As Boolean)
Line 845: Dim gogmail As New gogmail
Line 846: Dim mfrom As gogmail.gogMailAddress
Line 847: mfrom.gogAddress = gogfromDefault '"confirm13@gaugeoguild.com"
Line 848: mfrom.gogDisplayName = gogfromDisplay '"Gauge 'O' Guild"
Line 849: Dim mto As gogmail.gogMailAddress
Line 850: mto.gogAddress = defaultEmail ' "confirm13@gaugeoguild.com"
Line 851: Dim mCC(5) As gogmail.gogMailAddress
Line 852: Dim mSubject As String = ""
Line 853: Dim mBody As String = ""
Line 854: Dim sendresult As String = ""
Line 855:
Line 856: Dim Address As String = ""
Line 857: Dim BkgEvent As String = ""
Line 858: Dim BkgYear As String = ""
Line 859: Dim strDiscount As String = ""
Line 860: Dim i As Integer = 0
Line 861: Dim odId As Integer = 0
Line 862: Dim ohID As Integer = 0
Line 863: Dim onlinesales As New OnlineSales
Line 864: Dim OrderDet(3) As OnlineSales.Orders
Line 865: Dim PayType As String = ""
Line 866: Dim Price As Double = 0
Line 867: Dim rs As OleDbDataReader
Line 868: Dim SalesCat As New OnlineSales.SalesCategory
Line 869: Dim sBody As New StringBuilder
Line 870: 'Dim sMsg As String = ""
Line 871: Dim sReceipt As String = ""
Line 872: Dim ShopFormat As Boolean = True
Line 873: Dim StandBkgCosts As New StandBkgCosts
Line 874: Dim StandBkgSummary As String = ""
Line 875: Dim Start As Integer = 0
Line 876: Dim Tname As String = ""
Line 877: Dim Trader As String = ""
Line 878: Dim TraderDet As OnlineSales.TraderDetail
Line 879: Dim TraderID As Integer = 0
Line 880: ' Dim dvSales As DataView
Line 881:
Line 882: Dim Author As String = defaultEmail
Line 883: Dim StandBkgEvents As String = gogmail.FindEmail("Events", "Events Trade Manager")
Line 884: Dim Treasurer As String = gogmail.FindEmail("Board", "Treasurer") '"mgp-treasurer@gauge0guild.com"
Line 885: If testmode <> 0 Then
Line 886: Author = defaultEmail
Line 887: StandBkgEvents = defaultEmail
Line 888: Treasurer = defaultEmail
Line 889: End If
Line 890:
Line 891: ' mmto = New MailAddress(Actionee.ToString)
Line 892: mto.gogAddress = SetActionee("Stands", testmode)
Line 893: 'mm = New MailMessage(mfrom, mto)
Line 894:
Line 895: ' mm.To.Add(Treasurer) '"mgp-treasurer@gauge0guild.com"
Line 896: ' mm.Bcc.Add(Author)
Line 897: mCC(0).gogAddress = SenderCopy 'StandBkgEvents
Line 898: mCC(0).gogType = "CC"
Line 899: mCC(1).gogAddress = Treasurer
Line 900: mCC(1).gogType = "CC"
Line 901: mCC(2).gogAddress = StandBkgEvents
Line 902: mCC(2).gogType = "CC"
Line 903: mCC(3).gogAddress = Author
Line 904: mCC(3).gogType = "Bcc"
Line 905: ' mm.IsBodyHtml = False
Line 906: mSubject = "Gauge O Guild Online Trade Stand Payments"
Line 907:
Line 908: Dim All3Events As String = ""
Line 909: Dim Standdetails As String = ""
Line 910: Dim StandEmail As String = ""
Line 911: Dim Payment As Double = 0
Line 912: Dim ActualPayment As Double = 0
Line 913: Dim Deposit As Double = 0
Line 914: Dim Discount As Double = 0
Line 915: Dim EvPrice As Double = 0
Line 916:
Line 917: Using con As New OleDbConnection 'check is this order is in the Shop
Line 918: con.ConnectionString = ConfigurationManager.ConnectionStrings("onlinesalesConnectionString").ConnectionString
Line 919: con.Open()
Line 920: Dim cmdOrders As OleDbCommand = New OleDbCommand("SELECT * FROM OrderHeader WHERE ohOrderNo = " & SalesOrderID, con)
Line 921: rs = cmdOrders.ExecuteReader()
Line 922: If rs.HasRows Then
Line 923: rs.Read()
Line 924: ohID = rs.Item("ohID")
Line 925: ' MembEmail = rs.Item("ohEmail").ToString
Line 926: StandEmail = rs.Item("ohEmail").ToString
Line 927: Payment = CDbl(rs.Item("ohAmtToPay")) / 100
Line 928: ActualPayment = Payment 'keep actual price paid
Line 929:
Line 930: If Not IsDBNull(rs.Item("ohAddress1")) Then
Line 931: Address = rs.Item("ohAddress1")
Line 932: Else
Line 933: Address = " "
Line 934: End If
Line 935: 'Standdetails = rs.Item("description").ToString ' this will need to come from details record.
Line 936: ' StandEmail = MembEmail 'dvSales.Item(0).Item("email").ToString
Line 937:
Line 938: TraderDet = onlinesales.getTraderDetail(rs.Item("ohMemberNo"))
Line 939: Trader = TraderDet.TraderCode
Line 940: Tname = TraderDet.TraderName
Line 941: Else
Line 942: ShopFormat = False
Line 943: End If
Line 944: End Using
Line 945:
Line 946: ' SqlDataSourceExtras.UpdateParameters("BkgDate").DefaultValue = Now()
Line 947:
Line 948: ' SqlDataSourceExtras.UpdateParameters("DepPaid").DefaultValue = Price
Line 949:
Line 950:
Line 951: Using con As New OleDbConnection 'get order details
Line 952: con.ConnectionString = ConfigurationManager.ConnectionStrings("onlinesalesConnectionString").ConnectionString
Line 953: con.Open()
Line 954: Dim cmdOrders As OleDbCommand = New OleDbCommand("SELECT * FROM OrdDetails WHERE odohID = " & ohID, con)
Line 955: rs = cmdOrders.ExecuteReader()
Line 956: If rs.HasRows Then
Line 957: rs.Read()
Line 958: 'Trader - see above
Line 959: odId = rs.Item("odID")
Line 960: BkgEvent = rs.Item("odTitle")
Line 961: BkgYear = rs.Item("odPerson")
Line 962: Discount = rs.Item("odDiscount")
Line 963: PayType = rs.Item("odNotes") 'Deposit or final payment
Line 964: Else
Line 965: sMsg = "Order number " & SalesOrderID & " is not a Stand Booking. "
Line 966: Exit Sub
Line 967: End If
Line 968: rs.Close()
Line 969: End Using
Line 970:
Line 971:
Line 972: SalesCat = onlinesales.getSalesCategory(onlinesales.getscID("Stands"))
Line 973: If BkgEvent = SalesCat.Description Then
Line 974: 'Discounted stand sales
Line 975: Call StandBkgCosts.SetCosts(Trader, ActualPayment, Discount, PayType, "AllThree", BkgYear, sBody, OrderDet)
Line 976: Else
Line 977: Call StandBkgCosts.SetCosts(Trader, ActualPayment, Discount, PayType, BkgEvent, BkgYear, sBody, OrderDet)
Line 978: End If
Line 979:
Line 980: StandBkgSummary = StandBkgCosts.StdBkgSummary(Trader, BkgYear)
Line 981: sMsg = "Order Details" & "<br />" & "Trader: " & Tname & "<br />"
Line 982: sMsg += "Event: " & BkgEvent & " Year: " & BkgYear
Line 983: sMsg += "<br />" & "email: " & StandEmail.ToString & "<br />"
Line 984: sMsg += "<br />" & StandBkgSummary & "<br/>"
Line 985:
Line 986: mBody = "Payment of £" & Format(ActualPayment, "F2") & " has been received for order no " & SalesOrderID & " from Trader " & Tname & " for the following order:" & "<br />" & sMsg
Line 987: mBody += Right(Standdetails, Standdetails.Length - Start)
Line 988:
Line 989: ' gogOrderidLabel.Text = SalesOrderId
Line 990: ' PriceLabel.Text = Format(ActualPayment, "F2")
Line 991: ' emailLabel.Text = StandEmail
Line 992: ' MultiView1.ActiveViewIndex = 2
Line 993:
Line 994: If Not Resend Then
Line 995: Using con As New OleDbConnection 'check is this order is in the Shop
Line 996: con.ConnectionString = ConfigurationManager.ConnectionStrings("onlinesalesConnectionString").ConnectionString
Line 997: con.Open()
Line 998: Dim cmdUpdate As OleDbCommand = New OleDbCommand("UPDATE OrderHeader SET ohDateSubmitted = @DateSubmitted, ohDateProcessed = @DateProcessed, ohosID = " & onlinesales.getosID("Complete") & ", ohAmtPaid = " & CInt(CDbl(Payment) * 100) & ", ohPayType = '" & retPayType & "' WHERE ohOrderNo = " & SalesOrderID, con)
Line 999: cmdUpdate.Parameters.Add("@DateSubmitted", OleDbType.Date)
Line 1000: cmdUpdate.Parameters("@DateSubmitted").Value = Now
Line 1001: cmdUpdate.Parameters.Add("@DateProcessed", OleDbType.Date)
Line 1002: cmdUpdate.Parameters("@DateProcessed").Value = Now
Line 1003: cmdUpdate.ExecuteNonQuery()
Line 1004: MarkShopDownLoad(odId)
Line 1005: End Using
Line 1006:
Line 1007: 'send sales message to officers
Line 1008: sendresult = gogmail.ggMail(mfrom, mto, mSubject, mBody, mCC)
Line 1009: If sendresult <> "Email sent" Then SendErrorMsg("Online Sales StandDetails Send Error", "Send sales message (else) error to officers " & sendresult & gogNewLine)
Line 1010: End If
Line 1011:
Line 1012:
Line 1013: 'Send confirmation to Trader
Line 1014: If Not StandEmail = "" Then
Line 1015: If LCase(PayType) = "deposit" Then
Line 1016: sBody.Append(sMsg).Append(gogNewLine & onlinesales.gogAddress & gogNewLine)
Line 1017: Else
Line 1018: sBody.Append(onlinesales.VATreceipt(SalesOrderID, testmode)).Append(sMsg).Append(gogNewLine & onlinesales.gogAddress & gogNewLine)
Line 1019: End If
Line 1020:
Line 1021: 'If LocalHost then
Line 1022: If testmode > 0 Then
Line 1023: mto.gogAddress = defaultEmail
Line 1024: Else
Line 1025: mto.gogAddress = StandEmail
Line 1026: mto.gogDisplayName = ""
Line 1027: End If
Line 1028: sendresult = gogmail.ggMail(mfrom, mto, "Gauge O Guild Online Stand Booking", sBody.ToString)
Line 1029: If sendresult <> "Email sent" Then SendErrorMsg("OnlineSales Standbooking Error", "Send sales message (else) error to customer " & sendresult & "<br>")
Line 1030: End If
Line 1031:
Line 1032: End Sub
Line 1033:
Line 1034:
Line 1035:
Line 1036: Public Sub MarkDownLoad(ohID As Integer, odscID As Integer)
Line 1037:
Line 1038: Using con As New OleDbConnection
Line 1039: con.ConnectionString = ConfigurationManager.ConnectionStrings("onlinesalesConnectionString").ConnectionString
Line 1040: con.Open()
Line 1041: Dim cmdOrdDet As OleDbCommand = New OleDbCommand("UPDATE OrdDetails SET odosID=@odosID WHERE odOhID=@odOhID AND odscID=@odSaleType", con)
Line 1042: cmdOrdDet.Parameters.Add("@odosID", OleDbType.Integer)
Line 1043: cmdOrdDet.Parameters.Add("@odOhId", OleDbType.Integer)
Line 1044: cmdOrdDet.Parameters.Add("@odscID", OleDbType.Integer)
Line 1045:
Line 1046: cmdOrdDet.Parameters("@odosID").Value = getosID("Down Load") 'items are all downloads
Line 1047: cmdOrdDet.Parameters("@odohID").Value = ohID
Line 1048: cmdOrdDet.Parameters("@odscID").Value = odscID
Line 1049: cmdOrdDet.ExecuteNonQuery()
Line 1050: cmdOrdDet.Dispose()
Line 1051:
Line 1052: End Using
Line 1053: End Sub
Line 1054:
Line 1055: Public Sub GetClientDetails(ByVal membnum As Integer, ByRef Member As Client, ByRef MemberFound As Boolean)
Line 1056:
Line 1057: Dim WPAddress As String = ""
Line 1058: Dim WPCountryCode As String = ""
Line 1059: Dim WPCountryNumber As String = "826" '= United Kingdom
Line 1060: Dim addrFormat As String = ""
Line 1061: Dim connString As ConnectionStringSettings = ConfigurationManager.ConnectionStrings("gognewConnectionString")
Line 1062: Dim dsMembers As SqlDataSource = New SqlDataSource
Line 1063: Dim dsCountries As SqlDataSource = New SqlDataSource
Line 1064: Dim PostZone As String = ""
Line 1065: dsMembers.ConnectionString = connString.ConnectionString
Line 1066: dsMembers.ProviderName = "System.Data.OleDb"
Line 1067: dsMembers.SelectCommand = "SELECT * FROM gogmemMaster WHERE [NUMBER] = " & membnum 'set Select command
Line 1068:
Line 1069: Dim dvMember As DataView = CType(dsMembers.Select(System.Web.UI.DataSourceSelectArguments.Empty), DataView)
Line 1070: If dvMember.Count > 0 Then
Line 1071: With dvMember.Item(0)
Line 1072: Member.ST1 = .Item("ST1").ToString
Line 1073: Member.Title = .Item("Title").ToString
Line 1074: Member.Initials = .Item("Initials").ToString
Line 1075: Member.Surname = .Item("Surname").ToString
Line 1076: Member.FirstName = .Item("FirstName").ToString
Line 1077: Member.Name = Member.Title & " " & Member.Initials & " " & Member.Surname
Line 1078: If Member.FirstName = "" Then
Line 1079: Member.eName = Member.Initials & " " & Member.Surname
Line 1080: Else
Line 1081: Member.eName = Member.FirstName & " " & Member.Surname
Line 1082: End If
Line 1083: Member.Address1 = .Item("Addr1").ToString
Line 1084: Member.Address2 = .Item("Addr2").ToString
Line 1085: Member.Address3 = .Item("Addr3").ToString
Line 1086:
Line 1087: WPAddress = Member.Address1 & gogNewLine & Member.Address2 & gogNewLine & Member.Address3 & gogNewLine
Line 1088:
Line 1089: If IsDBNull(.Item("Country")) Then 'Or .Item("Country").ToString = "" Then
Line 1090: addrFormat = "A"
Line 1091: Member.Country = ""
Line 1092: Else
Line 1093: Member.Country = .Item("Country").ToString
Line 1094: If Len(Trim(.Item("Country").ToString)) = 0 Then
Line 1095: addrFormat = "A"
Line 1096: WPCountryCode = "GB" 'default to United Kingdom
Line 1097: WPCountryNumber = "826"
Line 1098: Else
Line 1099: 'Call CountryCode(Member.Country, WPCountryCode, WPCountryNumber, PostZone, addrFormat)
Line 1100: End If
Line 1101: End If
Line 1102: Call CountryCode(Member.Country, WPCountryCode, WPCountryNumber, PostZone, addrFormat)
Line 1103:
Line 1104: Dim strCounty As String = ""
Line 1105: If Not IsDBNull(.Item("County")) Then strCounty = .Item("County").ToString
Line 1106: Member.County = strCounty
Line 1107: 'response.write(addrformat)
Line 1108: Select Case UCase(addrFormat)
Line 1109: Case "A" 'UK address format
Line 1110: WPAddress = WPAddress & UCase(Trim(.Item("POST_TOWN").ToString)) & strCounty & gogNewLine & Trim(UCase(.Item("POSTCODE").ToString))
Line 1111: WPCountryCode = "GB" 'default to United Kingdom
Line 1112: Case "B" 'US address format
Line 1113: WPAddress = WPAddress & Trim(UCase(.Item("POST_TOWN").ToString)) & " " _
Line 1114: & Trim(UCase(strCounty.ToString)) _
Line 1115: & " " & Trim(UCase(.Item("POSTCODE").ToString)) _
Line 1116: & gogNewLine & Trim(UCase(.Item("Country").ToString))
Line 1117: Case "E"
Line 1118: WPAddress = WPAddress & Trim(UCase(.Item("POSTCODE").ToString)) & " " _
Line 1119: & Trim(UCase(.Item("POST_TOWN").ToString)) & " " & Trim(UCase(strCounty.ToString)) _
Line 1120: & gogNewLine & Trim(UCase(.Item("Country").ToString))
Line 1121: Case Else
Line 1122: WPAddress = WPAddress & Trim(UCase(.Item("POST_TOWN").ToString)) _
Line 1123: & " " & Trim(UCase(strCounty.ToString)) _
Line 1124: & " " & Trim(UCase(.Item("POSTCODE").ToString)) _
Line 1125: & gogNewLine & Trim(UCase(.Item("Country").ToString))
Line 1126: End Select
Line 1127:
Line 1128: Member.FormattedAddress = WPAddress & gogNewLine
Line 1129: Member.PostTown = .Item("Post_Town").ToString
Line 1130: Member.PostCode = .Item("PostCode").ToString
Line 1131: Member.Country = .Item("Country").ToString
Line 1132: Member.CountryCode = WPCountryCode
Line 1133: Member.CountryNumber = WPCountryNumber
Line 1134: Member.PostZone = PostZone
Line 1135:
Line 1136: If IsDBNull(.Item("e_mail")) Then
Line 1137: Member.emailAddress = ""
Line 1138: Else
Line 1139: Member.emailAddress = .Item("e_mail").ToString
Line 1140: End If
Line 1141:
Line 1142: End With
Line 1143: MemberFound = True
Line 1144: Else
Line 1145: MemberFound = False
Line 1146: End If
Line 1147:
Line 1148: End Sub
Line 1149:
Line 1150: Public Sub GetMemberDetails(ByVal membnum As Integer, ByRef Member As MemberDet, ByRef MemberFound As Boolean)
Line 1151:
Line 1152: Dim WPAddress As String = ""
Line 1153: Dim WPCountryCode As String = ""
Line 1154: Dim WPCountryNumber As String = "826" '= United Kingdom
Line 1155: Dim addrFormat As String = ""
Line 1156: Dim connString As ConnectionStringSettings = ConfigurationManager.ConnectionStrings("gognewConnectionString")
Line 1157: Dim dsMembers As SqlDataSource = New SqlDataSource
Line 1158: Dim dsCountries As SqlDataSource = New SqlDataSource
Line 1159: Dim PostZone As String = ""
Line 1160: dsMembers.ConnectionString = connString.ConnectionString
Line 1161: dsMembers.ProviderName = "System.Data.OleDb"
Line 1162: dsMembers.SelectCommand = "SELECT * FROM gogmemMaster WHERE [NUMBER] = " & membnum 'set Select command
Line 1163:
Line 1164: Dim dvMember As DataView = CType(dsMembers.Select(System.Web.UI.DataSourceSelectArguments.Empty), DataView)
Line 1165: If dvMember.Count > 0 Then
Line 1166: With dvMember.Item(0)
Line 1167: Member.Title = .Item("Title").ToString
Line 1168: Member.Initials = .Item("Initials").ToString
Line 1169: Member.Surname = .Item("Surname").ToString
Line 1170: Member.FirstName = .Item("FirstName").ToString
Line 1171: Member.Name = Member.Title & " " & Member.Initials & " " & Member.Surname
Line 1172: If Member.FirstName = "" Then
Line 1173: Member.eName = Member.Initials & " " & Member.Surname
Line 1174: Else
Line 1175: Member.eName = Member.FirstName & " " & Member.Surname
Line 1176: End If
Line 1177: Member.Address1 = .Item("Addr1").ToString
Line 1178: Member.Address2 = .Item("Addr2").ToString
Line 1179: Member.Address3 = .Item("Addr3").ToString
Line 1180:
Line 1181: WPAddress = Member.Address1 & gogNewLine & Member.Address2 & gogNewLine & Member.Address3 & gogNewLine
Line 1182:
Line 1183: If IsDBNull(.Item("Country")) Then 'Or .Item("Country").ToString = "" Then
Line 1184: addrFormat = "A"
Line 1185: Member.Country = ""
Line 1186: Else
Line 1187: Member.Country = .Item("Country").ToString
Line 1188: If Len(Trim(.Item("Country").ToString)) = 0 Then
Line 1189: addrFormat = "A"
Line 1190: WPCountryCode = "GB" 'default to United Kingdom
Line 1191: WPCountryNumber = "826"
Line 1192: Else
Line 1193: Call CountryCode(Member.Country, WPCountryCode, WPCountryNumber, PostZone, addrFormat)
Line 1194: End If
Line 1195: End If
Line 1196:
Line 1197: Dim strCounty As String = ""
Line 1198: If Not IsDBNull(.Item("County")) Then strCounty = .Item("County").ToString
Line 1199: Member.County = strCounty
Line 1200: 'response.write(addrformat)
Line 1201: Select Case UCase(addrFormat)
Line 1202: Case "A" 'UK address format
Line 1203: WPAddress = WPAddress & UCase(Trim(.Item("POST_TOWN").ToString)) & strCounty & gogNewLine & Trim(UCase(.Item("POSTCODE").ToString))
Line 1204: WPCountryCode = "GB" 'default to United Kingdom
Line 1205: Case "B" 'US address format
Line 1206: WPAddress = WPAddress & Trim(UCase(.Item("POST_TOWN").ToString)) & " " _
Line 1207: & Trim(UCase(strCounty.ToString)) _
Line 1208: & " " & Trim(UCase(.Item("POSTCODE").ToString)) _
Line 1209: & gogNewLine & Trim(UCase(.Item("Country").ToString))
Line 1210: Case "E"
Line 1211: WPAddress = WPAddress & Trim(UCase(.Item("POSTCODE").ToString)) & " " _
Line 1212: & Trim(UCase(.Item("POST_TOWN").ToString)) & " " & Trim(UCase(strCounty.ToString)) _
Line 1213: & gogNewLine & Trim(UCase(.Item("Country").ToString))
Line 1214: Case Else
Line 1215: WPAddress = WPAddress & Trim(UCase(.Item("POST_TOWN").ToString)) _
Line 1216: & " " & Trim(UCase(strCounty.ToString)) _
Line 1217: & " " & Trim(UCase(.Item("POSTCODE").ToString)) _
Line 1218: & gogNewLine & Trim(UCase(.Item("Country").ToString))
Line 1219: End Select
Line 1220:
Line 1221: Member.FormattedAddress = WPAddress & gogNewLine
Line 1222: Member.PostTown = .Item("Post_Town").ToString
Line 1223: Member.PostCode = .Item("PostCode").ToString
Line 1224: Member.Country = .Item("Country").ToString
Line 1225: Member.CountryCode = WPCountryCode
Line 1226: Member.CountryNumber = WPCountryNumber
Line 1227: Member.PostZone = PostZone
Line 1228:
Line 1229: If IsDBNull(.Item("e_mail")) Then
Line 1230: Member.emailAddress = ""
Line 1231: Else
Line 1232: Member.emailAddress = .Item("e_mail").ToString
Line 1233: End If
Line 1234: Member.Area = .Item("Area")
Line 1235: If IsDBNull(.Item("Date_Joined")) Then
Line 1236: ' Member.DateJoined = ""
Line 1237: Else
Line 1238: Member.DateJoined = .Item("Date_Joined")
Line 1239: End If
Line 1240: Member.ST1 = .Item("ST1").ToString
Line 1241: Member.ST2 = .Item("ST2").ToString
Line 1242: End With
Line 1243: MemberFound = True
Line 1244: Else
Line 1245: MemberFound = False
Line 1246: End If
Line 1247:
Line 1248: End Sub
Line 1249:
Line 1250: Public Function getTraderDetail(ByVal Traderid As Integer) As OnlineSales.TraderDetail
Line 1251: Dim rs As OleDbDataReader
Line 1252: Using con As New OleDbConnection
Line 1253: con.ConnectionString = ConfigurationManager.ConnectionStrings("digestConnectionString").ConnectionString
Line 1254: con.Open()
Line 1255: Dim cmdOrders As OleDbCommand = New OleDbCommand("Select * FROM Traders WHERE id= " & Traderid, con)
Line 1256: rs = cmdOrders.ExecuteReader()
Line 1257: If rs.HasRows Then
Line 1258: rs.Read()
Line 1259: With getTraderDetail
Line 1260: If Not IsDBNull(rs.Item("Code")) Then .TraderCode = rs.Item("Code")
Line 1261: If Not IsDBNull(rs.Item("FullName")) Then .TraderName = rs.Item("FullName")
Line 1262: If Not IsDBNull(rs.Item("Contact")) Then .TraderContact = rs.Item("Contact")
Line 1263: If Not IsDBNull(rs.Item("email")) Then .TraderEmail = rs.Item("email")
Line 1264: End With
Line 1265: Else
Line 1266: getTraderDetail.TraderCode = "zzzzzz"
Line 1267: End If
Line 1268: End Using
Line 1269:
Line 1270: End Function
Line 1271:
Line 1272: Public Function getTraderfromCode(ByVal TraderCode As String) As OnlineSales.TraderDetail
Line 1273: Dim rs As OleDbDataReader
Line 1274: Using con As New OleDbConnection
Line 1275: con.ConnectionString = ConfigurationManager.ConnectionStrings("digestConnectionString").ConnectionString
Line 1276: con.Open()
Line 1277: Dim cmdOrders As OleDbCommand = New OleDbCommand("Select * FROM Traders WHERE Code = '" & TraderCode & "'", con)
Line 1278: rs = cmdOrders.ExecuteReader()
Line 1279: If rs.HasRows Then
Line 1280: rs.Read()
Line 1281: With getTraderfromCode
Line 1282: If Not IsDBNull(rs.Item("Code")) Then .TraderCode = rs.Item("Code")
Line 1283: If Not IsDBNull(rs.Item("FullName")) Then .TraderName = rs.Item("FullName")
Line 1284: If Not IsDBNull(rs.Item("Contact")) Then .TraderContact = rs.Item("Contact")
Line 1285: If Not IsDBNull(rs.Item("email")) Then .TraderEmail = rs.Item("email")
Line 1286: End With
Line 1287: Else
Line 1288: getTraderfromCode.TraderCode = "zzzzzz"
Line 1289: End If
Line 1290: End Using
Line 1291:
Line 1292: End Function
Line 1293:
Line 1294: Public Sub CountryCode(ByVal Country As String, ByRef CountryCode As String, ByRef CountryNumber As String, ByRef PostZone As String, ByRef AddressFormat As String)
Line 1295: Dim addrFormat As String = ""
Line 1296: Dim WPCountryCode As String = ""
Line 1297: Dim WPCountryNumber As String = "826" '= United Kingdom
Line 1298: Dim connString As ConnectionStringSettings = ConfigurationManager.ConnectionStrings("gognewConnectionString")
Line 1299: Dim dsCountries As SqlDataSource = New SqlDataSource
Line 1300: dsCountries.ConnectionString = connString.ConnectionString
Line 1301: dsCountries.ProviderName = "System.Data.OleDb"
Line 1302: dsCountries.SelectCommand = "SELECT * FROM tblCountries WHERE Country = '" & UCase(Trim(Country)) & "'"
Line 1303:
Line 1304: Dim dvCountry As DataView = CType(dsCountries.Select(System.Web.UI.DataSourceSelectArguments.Empty), DataView) 'execute select command
Line 1305:
Line 1306: 'If Err() > 0 Then Response.Write("read objRsCountries execute error = " & Err())
Line 1307: If dvCountry.Count <= 0 Then
Line 1308: AddressFormat = "ZZZZZZ"
Line 1309: CountryCode = "GB" 'default to United Kingdom
Line 1310: CountryNumber = "826"
Line 1311: PostZone = "UK"
Line 1312: Else
Line 1313: If IsDBNull(dvCountry.Item(0).Item("AddrFormat")) Then
Line 1314: AddressFormat = "ZZZZZZ"
Line 1315: CountryCode = dvCountry.Item(0).Item("A2")
Line 1316: CountryNumber = dvCountry.Item(0).Item("Number")
Line 1317: Else
Line 1318: AddressFormat = dvCountry.Item(0).Item("AddrFormat")
Line 1319: CountryCode = dvCountry.Item(0).Item("A2")
Line 1320: CountryNumber = dvCountry.Item(0).Item("Number")
Line 1321: End If
Line 1322: If IsDBNull(dvCountry.Item(0).Item("PostZone")) Then
Line 1323: PostZone = "WZ2"
Line 1324: Else
Line 1325: PostZone = dvCountry.Item(0).Item("PostZone")
Line 1326: End If
Line 1327: End If
Line 1328:
Line 1329: End Sub
Line 1330:
Line 1331: Public Function CheckPayments() As Integer
Line 1332: 'FirstData Connect makes two resposes to a payment request
Line 1333: 'One response is an asynchronous call to callbackConnectComplete
Line 1334: 'If this fails then FirstData should sed an error message.
Line 1335: 'The other response is a re-direct to callbackConnect.
Line 1336: 'There is no check that this re-direct has worked.
Line 1337: 'Each of these responses causes a result to be recorded in OrderPay/ConnectCheck
Line 1338: 'This routine checks to ensure that there is a response from callbackConnect to a successful payment.
Line 1339:
Line 1340: Dim mmfrom As New MailAddress("membermail@gaugeoguild.com", "Gauge O Guild Member Mail")
Line 1341: Dim mmto As New MailAddress(defaultEmail)
Line 1342: Dim mm As New MailMessage
Line 1343: Dim smtp As New SmtpClient
Line 1344:
Line 1345: mm = New MailMessage(mmfrom, mmto)
Line 1346: mm.Subject = "Connect Callback Complete"
Line 1347: mm.IsBodyHtml = True
Line 1348: mm.Body = "Payment call back failures:" & "<br />" & "<br />"
Line 1349:
Line 1350: Dim SqlDataSourcePayCheck As New SqlDataSource
Line 1351:
Line 1352: SqlDataSourcePayCheck.ConnectionString = ConfigurationManager.ConnectionStrings("orderpayconnectionstring").ConnectionString
Line 1353: SqlDataSourcePayCheck.ProviderName = ConfigurationManager.ConnectionStrings("orderpayconnectionstring").ProviderName
Line 1354: SqlDataSourcePayCheck.SelectCommand = "SELECT * FROM connectcheck WHERE reported = FALSE ORDER BY oid"
Line 1355: Dim dvcheck As DataView = CType(SqlDataSourcePayCheck.Select(DataSourceSelectArguments.Empty), DataView)
Line 1356: Dim i As Integer = 0
Line 1357: Dim reportcount As Integer = 0
Line 1358: If dvcheck.Count > 0 Then
Line 1359: For i = 0 To dvcheck.Count - 1 Step 1
Line 1360: With dvcheck.Item(i)
Line 1361: If IsDBNull(.Item("cbcomplete")) AndAlso IsDBNull(.Item("cbconnect")) Then
Line 1362: ' If Left(.Item("cbcomplete"), 1) = "Y" Then
Line 1363: 'If IsDBNull(.Item("cbconnect")) Then
Line 1364: mm.Body += "ID = " & .Item("ID") & " oid = " & .Item("oid") & " "
Line 1365: mm.Body += "transaction date = " & .Item("transdate") & " PayType = " & .Item("PayType") & "<br />" & "<br />"
Line 1366: reportcount += 1
Line 1367:
Line 1368: 'End If
Line 1369: 'End If
Line 1370: End If
Line 1371: SqlDataSourcePayCheck.UpdateCommand = "UPDATE ConnectCheck SET reported = True WHERE (ID = " & .Item("ID").ToString & ")"
Line 1372: SqlDataSourcePayCheck.Update()
Line 1373: End With
Line 1374: Next
Line 1375: End If
Line 1376: If reportcount > 0 Then
Line 1377: Try
Line 1378: smtp.Send(mm)
Line 1379: Catch
Line 1380: 'Response.Write("Send to membermail error " & Err.ToString & "<br />")
Line 1381: End Try
Line 1382:
Line 1383: End If
Line 1384: mm.Dispose()
Line 1385: Return reportcount
Line 1386: End Function
Line 1387:
Line 1388: Public Sub callbacklog(logtext As String, ByRef PageResponse As HttpResponse)
Line 1389: Dim file As System.IO.StreamWriter
Line 1390: Dim logFolder As String = HttpRuntime.AppDomainAppPath & "App_Data/CallbackLogs/"
Line 1391: Dim logPath As String = logFolder & "CallBackLogs" & Year(Now) & Month(Now) & ".txt"
Line 1392: Dim i As Integer = 0
Line 1393: Dim NumOfRetries As Integer = 3
Line 1394: Dim DelayOnRetry As Integer = 1000
Line 1395:
Line 1396: For i = 0 To NumOfRetries Step 1
Line 1397: Try
Line 1398: If Not System.IO.File.Exists(logPath) Then
Line 1399: file = System.IO.File.CreateText(logPath)
Line 1400: file.Close()
Line 1401: End If
Line 1402:
Line 1403: If System.IO.File.Exists(logPath) Then
Line 1404: file = My.Computer.FileSystem.OpenTextFileWriter(logPath, True)
Line 1405: file.WriteLine(Now() & ":" & logtext)
Line 1406: file.Close()
Line 1407: End If
Line 1408: i = NumOfRetries + 1
Line 1409:
Line 1410: Catch ex As Exception
Line 1411: If i < NumOfRetries Then
Line 1412: System.Threading.Thread.Sleep(DelayOnRetry)
Line 1413: Else
Line 1414: Dim gmbody As String = "Callback log error - logpath = " & logPath
Line 1415: gmbody += vbNewLine & logtext
Line 1416: gmbody += vbNewLine & ex.Message
Line 1417: Dim gmail As New gogmail
Line 1418: Dim gmfrom As New gogmail.gogMailAddress
Line 1419: Dim gmto As New gogmail.gogMailAddress
Line 1420: gmfrom.gogAddress = "confirm13@gaugeoguild.com"
Line 1421: gmto.gogAddress = defaultEmail
Line 1422: gmail.ggMail(gmfrom, gmto, "GOG callback log Error", gmbody)
Line 1423: End If
Line 1424: Finally
Line 1425: If file IsNot Nothing Then file.Dispose()
Line 1426: End Try
Line 1427: Next
Line 1428: End Sub
Line 1429:
Line 1430: Public Function VATreceipt(ByVal OrderNo As Integer, ByVal Testmode As Integer) As String
Line 1431: Dim AmtPaid As Double = 0
Line 1432: Dim OnlineSales As New OnlineSales
Line 1433: Dim connString As ConnectionStringSettings = ConfigurationManager.ConnectionStrings("onlinesalesConnectionString")
Line 1434: Dim dsOrderDetails As New SqlDataSource
Line 1435: Dim dsOrders As New SqlDataSource
Line 1436: Dim i As Integer = 0
Line 1437: Dim odOhID As Integer = 0
Line 1438: Dim PayAdjust As Integer = 0
Line 1439: Dim PandP As Double = 0
Line 1440: Dim rs As OleDbDataReader
Line 1441: Dim rsOrdDet As OleDbDataReader
Line 1442: ' Dim rsOrders As OleDbDataReader
Line 1443: Dim s As New System.Text.StringBuilder
Line 1444: Dim TDES As New TripleDES
Line 1445: Dim UKpurchase As Boolean = False
Line 1446: Dim VAT As Double = 0
Line 1447:
Line 1448: Try
Line 1449: Using con As New OleDbConnection 'check is this order is in the Shop
Line 1450: con.ConnectionString = ConfigurationManager.ConnectionStrings("onlinesalesConnectionString").ConnectionString
Line 1451: con.Open()
Line 1452: Dim cmdOrders As OleDbCommand = New OleDbCommand("SELECT * FROM OrderHeader WHERE ohOrderNo = " & OrderNo, con)
Line 1453: rs = cmdOrders.ExecuteReader()
Line 1454: If rs.HasRows Then
Line 1455: rs.Read()
Line 1456: If Not IsDBNull(rs.Item("ohAmtPaid")) Then AmtPaid = rs.Item("ohAmtPaid")
Line 1457: If Not IsDBNull(rs.Item("ohPostage")) Then PandP = rs.Item("ohPostage")
Line 1458: If Not IsDBNull(rs.Item("ohPostVAT")) Then VAT = rs.Item("ohPostVAT")
Line 1459: If Not IsDBNull(rs.Item("ohPayAdjust")) Then PayAdjust = rs.Item("ohPayAdjust")
Line 1460: If rs.Item("ohCountry") = "" Then
Line 1461: UKpurchase = True 'Assume UK if no Country
Line 1462: ElseIf LCase(rs.Item("ohCountry")) = "united kingdom" Then
Line 1463: UKpurchase = True
Line 1464: Else
Line 1465: UKpurchase = False
Line 1466: End If
Line 1467: odOhID = rs.Item("ohID")
Line 1468: rs.Close()
Line 1469:
Line 1470: 'Dim cmdOrdDetails As OleDbCommand = New OleDbCommand("SELECT * FROM OrderItem WHERE odohid = " & odOhID & " ORDER BY [siTitle]", con)
Line 1471: Dim cmdOrdDetails As OleDbCommand = New OleDbCommand("SELECT * FROM OrdDetails WHERE odOhID = " & odOhID & " AND (odQuantity > 0 OR odAmtToPay > 0) ORDER BY [odOhID]", con)
Line 1472: rsOrdDet = cmdOrdDetails.ExecuteReader()
Line 1473:
Line 1474: If Testmode > 0 Then
Line 1475: s.Append("Test document only " & gogNewLine)
Line 1476: ElseIf UKpurchase Then
Line 1477: s.Append("Receipt " & gogNewLine)
Line 1478: Else
Line 1479: s.Append("Receipt " & gogNewLine)
Line 1480: End If
Line 1481: If rsOrdDet.HasRows Then
Line 1482: s.Append("<table>")
Line 1483: s.Append("<tr>")
Line 1484: s.Append("<th>Qty</td>")
Line 1485: s.Append("<th>Description</td>")
Line 1486: s.Append("<th>Price</td>")
Line 1487: s.Append("<th>Total £</td>")
Line 1488: s.Append("</tr>")
Line 1489: 'For i = 0 To dvOrderDet.Count - 1 Step 1
Line 1490: Do While rsOrdDet.Read
Line 1491: With rsOrdDet
Line 1492: s.Append("<tr>")
Line 1493: s.Append("<td>" & .Item("odQuantity") & "</td>")
Line 1494: ' SalesItem = OnlineSales.getSalesItem(.Item("odSiID"))
Line 1495: ' s.Append("<td>" & SalesItem.Title & "</td>")
Line 1496: s.Append("<td>" & .Item("odTitle"))
Line 1497: If Not IsDBNull(.Item("odPerson")) Then If .Item("odPerson").ToString.Length > 0 Then s.Append(" for " & .Item("odPerson").ToString)
Line 1498: If Not IsDBNull(.Item("odNotes")) Then s.Append(" " & .Item("odNotes").ToString)
Line 1499: s.Append("</td>")
Line 1500: s.Append("<td>" & FormatNumber(.Item("odUnitPrice") / 100, 2) & "</td>")
Line 1501: s.Append("<td>" & FormatNumber(.Item("odAmtToPay") / 100, 2) & "</td>")
Line 1502: s.Append("</tr>")
Line 1503: VAT += CDbl(.Item("odVAT"))
Line 1504: ' AmtPaid += CDbl(.Item("odAmtToPay"))
Line 1505:
Line 1506: Dim SaleItem As OnlineSales.SalesItem = OnlineSales.getSalesItem(.Item("odsiID"))
Line 1507: If SaleItem.Download Then
Line 1508: Dim DownLoadLinkEncrypted As String = ConfigurationManager.AppSettings("baseurl") & "/OnlineSales/SalesDownload.aspx?ident=" & System.Net.WebUtility.UrlEncode(TDES.Encrypt("odohid=" & .Item("odohID") & "&url=" & SaleItem.DownloadURL & "&date=" & Now().ToShortDateString & "&eof=End"))
Line 1509: s.Append("<tr><td colspan='4'>" & "<a href=" & DownLoadLinkEncrypted & ">Click here To download " & .Item("odTitle").ToString & "</a></td></tr>")
Line 1510: End If
Line 1511: End With
Line 1512: Loop
Line 1513: s.Append("<tr>")
Line 1514: s.Append("<td></td>")
Line 1515: s.Append("<td>Post and Packing</td>")
Line 1516: s.Append("<td></td>")
Line 1517: s.Append("<td>" & FormatNumber(PandP / 100, 2) & "</td>")
Line 1518: s.Append("</tr>")
Line 1519:
Line 1520: If PayAdjust <> 0 Then
Line 1521: s.Append("<tr>")
Line 1522: s.Append("<td></td>")
Line 1523: If PayAdjust > 0 Then
Line 1524: s.Append("<td>Donation</td>")
Line 1525: Else
Line 1526: s.Append("<td>Adjustment</td>")
Line 1527: End If
Line 1528: s.Append("<td></td>")
Line 1529: s.Append("<td>" & FormatNumber(PayAdjust / 100, 2) & "</td>")
Line 1530: s.Append("</tr>")
Line 1531: End If
Line 1532:
Line 1533: s.Append("<tr>")
Line 1534: s.Append("<td></td>")
Line 1535: s.Append("<td>Amount Paid</td>")
Line 1536: s.Append("<td></td>")
Line 1537: s.Append("<td>" & FormatNumber(AmtPaid / 100, 2) & "</td>")
Line 1538: s.Append("</tr>")
Line 1539:
Line 1540: ' If UKpurchase Then
Line 1541: ' s.Append("<tr>")
Line 1542: ' s.Append("<td></td>")
Line 1543: ' s.Append("<td>includes VAT </td>")
Line 1544: ' s.Append("<td></td>")
Line 1545: ' s.Append("<td>£" & FormatNumber(VAT / 100, 2) & "</td>")
Line 1546: ' s.Append("</tr>")
Line 1547: ' End If
Line 1548: s.Append("</table>").Append(gogNewLine & gogNewLine)
Line 1549: s.Append(FormatDateTime(Now(), DateFormat.LongDate)).Append(gogNewLine)
Line 1550: ' s.Append("VAT registration number 411 6633 80").Append(gogNewLine)
Line 1551:
Line 1552: End If
Line 1553: rsOrdDet.Close()
Line 1554:
Line 1555: Else
Line 1556: rs.Close()
Line 1557: 'for transactions not put through shop, eg before shop was added
Line 1558: dsOrders.ConnectionString = connString.ConnectionString
Line 1559: dsOrders.ProviderName = "System.Data.OleDb"
Line 1560: dsOrders.SelectCommand = "SELECT * FROM [Orders] WHERE ([OrderNo] = ?) "
Line 1561: dsOrders.SelectParameters.Add("OrderNo", OrderNo)
Line 1562: 'Dim cmdOrd As OleDbCommand = New OleDbCommand("SELECT [orderno], PandP, PandPVAT, countrycode FROM [orders] ORDER BY [orderno] DESC", con)
Line 1563: Dim dvOrders As DataView = CType(dsOrders.Select(DataSourceSelectArguments.Empty), DataView)
Line 1564: If dvOrders.Count > 0 Then
Line 1565: 'rsOrders = cmdOrd.ExecuteReader
Line 1566: 'If rsOrders.HasRows Then
Line 1567: 'rsOrders.Read()
Line 1568:
Line 1569: With dvOrders.Item(0)
Line 1570: 'With rsOrders
Line 1571: If Not IsDBNull(.Item("PandP")) Then PandP = .Item("PandP")
Line 1572: If Not IsDBNull(.Item("PandPVAT")) Then VAT = .Item("PandPVAT")
Line 1573: If .Item("countrycode") = "" Then
Line 1574: UKpurchase = True 'Assume UK if no Country
Line 1575: ElseIf .Item("countrycode") = "GB" Then
Line 1576: UKpurchase = True
Line 1577: Else
Line 1578: UKpurchase = False
Line 1579: End If
Line 1580: End With
Line 1581: End If
Line 1582:
Line 1583: dsOrderDetails.ConnectionString = connString.ConnectionString
Line 1584: dsOrderDetails.ProviderName = "System.Data.OleDb"
Line 1585: dsOrderDetails.SelectCommand = "SELECT * FROM [OrderDetails] WHERE ([OrderNo] = ?) ORDER BY [Description]"
Line 1586: dsOrderDetails.SelectParameters.Add("OrderNo", OrderNo)
Line 1587:
Line 1588: Dim dvOrderDet As DataView = CType(dsOrderDetails.Select(DataSourceSelectArguments.Empty), DataView)
Line 1589:
Line 1590: If Testmode > 0 Then
Line 1591: s.Append("Test document only " & gogNewLine)
Line 1592: ElseIf UKpurchase Then
Line 1593: s.Append("Receipt " & gogNewLine)
Line 1594: Else
Line 1595: s.Append("Receipt " & gogNewLine)
Line 1596: End If
Line 1597: If dvOrderDet.Count > 0 Then
Line 1598: s.Append("<table>")
Line 1599: s.Append("<tr>")
Line 1600: s.Append("<th>Qty</td>")
Line 1601: s.Append("<th>Description</td>")
Line 1602: s.Append("<th>Price</td>")
Line 1603: s.Append("<th>Total £</td>")
Line 1604: s.Append("</tr>")
Line 1605: For i = 0 To dvOrderDet.Count - 1 Step 1
Line 1606: With dvOrderDet.Item(i)
Line 1607: s.Append("<tr>")
Line 1608: s.Append("<td>" & .Item("Qty") & "</td>")
Line 1609: s.Append("<td>" & .Item("Description") & "</td>")
Line 1610: s.Append("<td>" & FormatNumber(.Item("Price"), 2) & "</td>")
Line 1611: s.Append("<td>" & FormatNumber(.Item("Total"), 2) & "</td>")
Line 1612: s.Append("</tr>")
Line 1613: VAT += CDbl(.Item("VAT"))
Line 1614: AmtPaid += CDbl(.Item("Total"))
Line 1615: End With
Line 1616: Next
Line 1617: s.Append("<tr>")
Line 1618: s.Append("<td></td>")
Line 1619: s.Append("<td>Post and Packing</td>")
Line 1620: s.Append("<td></td>")
Line 1621: s.Append("<td>" & FormatNumber(PandP, 2) & "</td>")
Line 1622: s.Append("</tr>")
Line 1623:
Line 1624: s.Append("<tr>")
Line 1625: s.Append("<td></td>")
Line 1626: s.Append("<td>Amount Paid</td>")
Line 1627: s.Append("<td></td>")
Line 1628: s.Append("<td>" & FormatNumber(AmtPaid, 2) & "</td>")
Line 1629: s.Append("</tr>")
Line 1630:
Line 1631: ' If UKpurchase Then
Line 1632: ' s.Append("<tr>")
Line 1633: ' s.Append("<td></td>")
Line 1634: ' s.Append("<td>includes VAT </td>")
Line 1635: ' s.Append("<td></td>")
Line 1636: ' s.Append("<td>£" & FormatNumber(VAT, 2) & "</td>")
Line 1637: ' s.Append("</tr>")
Line 1638: ' End If
Line 1639: s.Append("</table>").Append(gogNewLine & gogNewLine)
Line 1640: s.Append(FormatDateTime(Now(), DateFormat.LongDate)).Append(gogNewLine)
Line 1641: ' s.Append("VAT registration number 411 6633 80").Append(gogNewLine)
Line 1642:
Line 1643: End If
Line 1644: End If
Line 1645: End Using
Line 1646: VATreceipt = s.ToString
Line 1647: Catch
Line 1648: VATreceipt = ""
Line 1649: End Try
Line 1650: End Function
Line 1651:
Line 1652: Public Function getOrderNo(ByVal ohID As Integer) As Integer
Line 1653: Dim rs As OleDbDataReader
Line 1654:
Line 1655: Using con As New OleDbConnection
Line 1656: con.ConnectionString = ConfigurationManager.ConnectionStrings("onlinesalesConnectionString").ConnectionString
Line 1657: con.Open()
Line 1658:
Line 1659: Dim cmd As OleDbCommand = New OleDbCommand("Select ohOrderNo FROM OrderHeader WHERE ohID = " & ohID, con)
Line 1660: rs = cmd.ExecuteReader()
Line 1661: If rs.HasRows Then
Line 1662: rs.Read()
Line 1663: getOrderNo = rs.Item("ohOrderNo")
Line 1664: Else
Line 1665: getOrderNo = 0
Line 1666: End If
Line 1667: End Using
Line 1668: End Function
Line 1669:
Line 1670: Public Function getOrderHeader(ByVal ohOrderNo As Integer) As OrderHeader
Line 1671: Dim rs As OleDbDataReader
Line 1672:
Line 1673: Using con As New OleDbConnection
Line 1674: con.ConnectionString = ConfigurationManager.ConnectionStrings("onlinesalesConnectionString").ConnectionString
Line 1675: con.Open()
Line 1676: Dim cmdOrders As OleDbCommand = New OleDbCommand("Select * FROM OrderHeader WHERE ohOrderNo= " & ohOrderNo, con)
Line 1677: rs = cmdOrders.ExecuteReader()
Line 1678: If rs.HasRows Then
Line 1679: rs.Read()
Line 1680: With getOrderHeader
Line 1681: .ohID = rs.Item("ohID")
Line 1682: If Not IsDBNull(rs.Item("ohOrderNo")) Then .OrderNo = rs.Item("ohOrderNo")
Line 1683: If Not IsDBNull(rs.Item("ohTransType")) Then .TransType = rs.Item("ohTransType")
Line 1684: If Not IsDBNull(rs.Item("ohMemberNo")) Then .MemberNo = rs.Item("ohMemberNo")
Line 1685: If Not IsDBNull(rs.Item("ohClientID")) Then .ClientID = rs.Item("ohClientID")
Line 1686: If Not IsDBNull(rs.Item("ohName")) Then .Name = rs.Item("ohName")
Line 1687: If Not IsDBNull(rs.Item("ohEmail")) Then .email = rs.Item("ohEmail")
Line 1688: If Not IsDBNull(rs.Item("ohOther")) Then .Other = rs.Item("ohOther")
Line 1689: If Not IsDBNull(rs.Item("ohPostage")) Then .Postage = rs.Item("ohPostage")
Line 1690: If Not IsDBNull(rs.Item("ohPostVAT")) Then .PostVAT = rs.Item("ohPostVAT")
Line 1691: If Not IsDBNull(rs.Item("ohAmtToPay")) Then .AmtToPay = rs.Item("ohAmtToPay")
Line 1692: If Not IsDBNull(rs.Item("ohAmtPaid")) Then .AmtPaid = rs.Item("ohAmtPaid")
Line 1693: If Not IsDBNull(rs.Item("ohPayType")) Then .PayType = rs.Item("ohPayType")
Line 1694: If Not IsDBNull(rs.Item("ohOsID")) Then .ohOsID = rs.Item("ohOsID")
Line 1695: If Not IsDBNull(rs.Item("ohPayAdjust")) Then .PayAdjust = rs.Item("ohPayAdjust")
Line 1696: If Not IsDBNull(rs.Item("ohPayNotes")) Then .PayNotes = rs.Item("ohPayNotes")
Line 1697: If Not IsDBNull(rs.Item("ohAddress1")) Then .Address1 = rs.Item("ohAddress1")
Line 1698: If Not IsDBNull(rs.Item("ohAddress2")) Then .Address2 = rs.Item("ohAddress2")
Line 1699: If Not IsDBNull(rs.Item("ohAddress3")) Then .Address3 = rs.Item("ohAddress3")
Line 1700: If Not IsDBNull(rs.Item("ohTown")) Then .Town = rs.Item("ohTown")
Line 1701: If Not IsDBNull(rs.Item("ohCounty")) Then .County = rs.Item("ohCounty")
Line 1702: If Not IsDBNull(rs.Item("ohPostCode")) Then .PostCode = rs.Item("ohPostCode")
Line 1703: If Not IsDBNull(rs.Item("ohCountry")) Then .Country = rs.Item("ohCountry")
Line 1704: If IsDBNull(rs.Item("ohDateSubmitted")) Then
Line 1705: '.DateSubmitted = ""
Line 1706: Else
Line 1707: .DateSubmitted = rs.Item("ohDateSubmitted")
Line 1708: End If
Line 1709: End With
Line 1710: Else
Line 1711: getOrderHeader.ohID = 0
Line 1712: End If
Line 1713: End Using
Line 1714:
Line 1715: End Function
Line 1716:
Line 1717: Public Function GetOrderCart(UserID As String, MemberNo As Integer) As OrderCart()
Line 1718: Dim i As Integer = 0
Line 1719: Dim OrdCart(20) As OrderCart
Line 1720: Dim rs As OleDbDataReader
Line 1721:
Line 1722: Using con As New OleDbConnection
Line 1723: con.ConnectionString = ConfigurationManager.ConnectionStrings("onlinesalesConnectionString").ConnectionString
Line 1724: con.Open()
Line 1725: Dim cmd As OleDbCommand = New OleDbCommand("Select * FROM OrdersCart WHERE UserID = '" & UserID & "'", con)
Line 1726: If MemberNo > 0 Then cmd.CommandText = "Select * FROM OrdersCart WHERE MemberNo = " & MemberNo
Line 1727:
Line 1728: 'Dim cmd As OleDbCommand = New OleDbCommand("Select ID, Userid, MemberNo, OrderSiid, Title, Quantity, UnitPrice, Notes, DateAdded FROM OrdersCart WHERE UserID = '" & UserID & "'", con)
Line 1729: rs = cmd.ExecuteReader()
Line 1730: Do While rs.Read()
Line 1731: With OrdCart(i)
Line 1732: .ID = rs.Item("ID")
Line 1733: If Not IsDBNull(rs.Item("UserID")) Then .UserID = rs.Item("UserID")
Line 1734: .MemberNo = rs.Item("MemberNo")
Line 1735: .OrderSiid = rs.Item("OrderSiid")
Line 1736: .Title = rs.Item("Title")
Line 1737: .Quantity = rs.Item("Quantity")
Line 1738: .UnitPrice = rs.Item("UnitPrice")
Line 1739: .Notes = rs.Item("Notes")
Line 1740: .DateAdded = rs.Item("DateAdded")
Line 1741: i += 1
Line 1742: End With
Line 1743: Loop
Line 1744: End Using
Line 1745: Return OrdCart
Line 1746: End Function
Line 1747:
Line 1748: Public Function GetBasket(Ordercart() As OnlineSales.OrderCart) As OnlineSales.OrderDetails()
Line 1749: Dim Basket(20) As OnlineSales.OrderDetails
Line 1750: Dim SC As SalesCategory
Line 1751: Dim SI As SalesItem
Line 1752: Dim i As Integer = 0
Line 1753: For Each ord As OrderCart In Ordercart
Line 1754: With Basket(i)
Line 1755: .SaleItem = ord.OrderSiid
Line 1756: SI = getSalesItem(ord.OrderSiid) 'this is a workaround, there should be a more direct way. Needs dataflow review
Line 1757: 'SC = getSalesCategory(SI.siscID)
Line 1758: .SaleType = SI.SaleType
Line 1759: .odscID = SI.siscID
Line 1760: .Title = ord.Title
Line 1761: .Notes = ord.Notes
Line 1762: .Quantity = ord.Quantity
Line 1763: .UnitPrice = ord.UnitPrice
Line 1764: .AmtToPay = ord.UnitPrice * ord.Quantity
Line 1765: End With
Line 1766: i += 1
Line 1767: Next
Line 1768: Return Basket
Line 1769: End Function
Line 1770:
Line 1771: Public Sub DeleteOrderCCart(UserID As String, MemberNo As Integer)
Line 1772: Using con As New OleDbConnection
Line 1773: con.ConnectionString = ConfigurationManager.ConnectionStrings("onlinesalesConnectionString").ConnectionString
Line 1774: con.Open()
Line 1775: Dim cmd As OleDbCommand = New OleDbCommand("DELETE * FROM OrdersCart WHERE MemberNo = " & MemberNo, con)
Line 1776: If UserID > 0 Then cmd.CommandText = "DELETE * FROM OrdersCart WHERE UserID = " & UserID
Line 1777: cmd.ExecuteNonQuery()
Line 1778:
Line 1779: End Using
Line 1780: HttpContext.Current.Response.Cookies("gogGuid").Expires = DateAdd(DateInterval.Day, -1, Now)
Line 1781:
Line 1782: End Sub
Line 1783:
Line 1784: Public Sub UpdateOrderCart(UserID As String, MemberNo As Integer, OrderCart() As OrderCart)
Line 1785: Dim i As Integer = 0
Line 1786:
Line 1787:
Line 1788: Using con As New OleDbConnection
Line 1789: con.ConnectionString = ConfigurationManager.ConnectionStrings("onlinesalesConnectionString").ConnectionString
Line 1790: con.Open()
Line 1791: Dim cmd As OleDbCommand = New OleDbCommand("UPDATE OrdersCart SET Quantity = @quantity WHERE ID = @id", con)
Line 1792: cmd.Parameters.Add("@quantity", OleDbType.Integer)
Line 1793: cmd.Parameters.Add("@id", OleDbType.Integer)
Line 1794:
Line 1795: ' Dim cmd As OleDbCommand = New OleDbCommand("DELETE * FROM OrdersCart WHERE UserID = " & UserID, con)
Line 1796: ' cmd.ExecuteNonQuery()
Line 1797: '
Line 1798: ' cmd.CommandText = "INSERT INTO OrderCart (UserID, MemberNo, OrderSiid, Title, Quantity, UnitPrice, Notes, DateAdded) "
Line 1799: ' cmd.CommandText += " VALUES (@UserID, @MemberNo, @OrderSiid, @Title, @Quantity, @UnitPrice, @Notes, @DateAdded )"
Line 1800: ' cmd.Parameters.Add("@UserID", OleDbType.VarChar)
Line 1801: '' cmd.Parameters.Add("@MemberNo", OleDbType.Integer)
Line 1802: ' ' ' cmd.Parameters.Add("@OrderSiid", OleDbType.Integer)
Line 1803: ' cmd.Parameters.Add("@Title", OleDbType.VarChar)
Line 1804: ' cmd.Parameters.Add("@Quantity", OleDbType.Integer)
Line 1805: ' cmd.Parameters.Add("@UnitPrice", OleDbType.Integer)
Line 1806: ' cmd.Parameters.Add("@Notes", OleDbType.VarChar)
Line 1807: ' cmd.Parameters.Add("@DateAdded", OleDbType.Date)
Line 1808:
Line 1809: For Each ord As OrderCart In OrderCart
Line 1810: ' If ord.Quantity <> OrderCart(i).quantity Then
Line 1811: If ord.Quantity IsNot Nothing Then
Line 1812: cmd.Parameters("@quantity").Value = ord.Quantity
Line 1813: cmd.Parameters("@id").Value = ord.ID
Line 1814: cmd.ExecuteNonQuery()
Line 1815: End If
Line 1816: i += 1
Line 1817: Next
Line 1818:
Line 1819:
Line 1820: ' For Each ord As OrderDetails In OrderDet
Line 1821: ' With ord
Line 1822: ' If .Quantity > 0 Then
Line 1823: ' cmd.Parameters("@UserID").Value = UserID
Line 1824: ' cmd.Parameters("@MemberNo").Value = MemberNo
Line 1825: ' cmd.Parameters("@OrderSiid").Value = .SaleItem
Line 1826: ' cmd.Parameters("@Title").Value = .Title
Line 1827: 'cmd.Parameters("@Quantity").Value = .Quantity
Line 1828: ' cmd.Parameters("@UnitPrice").Value = .UnitPrice
Line 1829: ' cmd.Parameters("@Notes").Value = .Notes
Line 1830: ' cmd.Parameters("@DateAdded").Value = Now()
Line 1831: ' End If
Line 1832: 'End With
Line 1833: ' Next
Line 1834: End Using
Line 1835: End Sub
Line 1836:
Line 1837: Public Function getSalesCategory(ByVal scID As Integer) As SalesCategory
Line 1838: Dim rs As OleDbDataReader
Line 1839:
Line 1840: Using con As New OleDbConnection
Line 1841: con.ConnectionString = ConfigurationManager.ConnectionStrings("onlinesalesConnectionString").ConnectionString
Line 1842: con.Open()
Line 1843:
Line 1844: Dim cmd As OleDbCommand = New OleDbCommand("Select * FROM SalesCategories WHERE scID = " & scID, con)
Line 1845: rs = cmd.ExecuteReader()
Line 1846: If rs.HasRows Then
Line 1847: rs.Read()
Line 1848: With getSalesCategory
Line 1849: .scid = rs.Item("scID")
Line 1850: If Not IsDBNull(rs.Item("scName")) Then .Name = rs.Item("scName")
Line 1851: .Deleted = rs.Item("scDeleted")
Line 1852: If Not IsDBNull(rs.Item("scDescription")) Then .Description = rs.Item("scDescription")
Line 1853: If Not IsDBNull(rs.Item("scEmail")) Then .Email = rs.Item("scEmail")
Line 1854: If Not IsDBNull(rs.Item("scImage")) Then .ImageURL = rs.Item("scImage")
Line 1855: If Not IsDBNull(rs.Item("scLongDescription")) Then .LongDescription = rs.Item("scLongDescription")
Line 1856: .Shop = rs.Item("scShop")
Line 1857: If Not IsDBNull(rs.Item("scIntro")) Then .Intro = rs.Item("scIntro")
Line 1858: If Not IsDBNull(rs.Item("scSort")) Then .Sort = rs.Item("scSort")
Line 1859: End With
Line 1860: Else
Line 1861: getSalesCategory.scid = 0
Line 1862: End If
Line 1863: End Using
Line 1864: End Function
Line 1865:
Line 1866: Public Function getSalesItem(ByVal SiID As Integer) As SalesItem
Line 1867: Dim rs As OleDbDataReader
Line 1868:
Line 1869: Using con As New OleDbConnection
Line 1870: con.ConnectionString = ConfigurationManager.ConnectionStrings("onlinesalesConnectionString").ConnectionString
Line 1871: con.Open()
Line 1872: ' Dim cmdOrders As OleDbCommand = New OleDbCommand("Select SalesItems.[siID], SalesItems.[siScID], SalesItems.[siTitle], SalesItems.[siDescription], SalesItems.[siPrice], SalesItems.[siVAT], SalesItems.[siDiscount], SalesItems.[siImagePath], SalesItems.[siStockLevel], SalesItems.[siDeleted], SalesItems.[siNotes], SalesItems.[siPerson], SalesItems.[siPersonPrice], SalesItems.[siPGroup], SalesItems.[siMemberOnly], SalesCategories.scName, VATCategories.vcRate FROM (SalesItems Left JOIN SalesCategories On SalesItems.siScID = SalesCategories.scID) LEFT JOIN VATCategories On SalesItems.siVAT = VATCategories.vcID WHERE SiID = " & SiID, con)
Line 1873: Dim cmdOrders As OleDbCommand = New OleDbCommand("Select *, SalesCategories.scName, VATCategories.vcRate FROM (SalesItems Left JOIN SalesCategories On SalesItems.siScID = SalesCategories.scID) LEFT JOIN VATCategories On SalesItems.sivcID = VATCategories.vcID WHERE SiID = " & SiID, con)
Line 1874: rs = cmdOrders.ExecuteReader()
Line 1875: If rs.HasRows Then
Line 1876: rs.Read()
Line 1877: With getSalesItem
Line 1878: .siID = rs.Item("siID")
Line 1879: If Not IsDBNull(rs.Item("scName")) Then .SaleType = rs.Item("scName")
Line 1880: If Not IsDBNull(rs.Item("siscID")) Then .siscID = rs.Item("siscID")
Line 1881: If Not IsDBNull(rs.Item("siTitle")) Then .Title = rs.Item("siTitle")
Line 1882: If Not IsDBNull(rs.Item("siDescription")) Then .Description = rs.Item("siDescription")
Line 1883: If Not IsDBNull(rs.Item("siDescriptionRaw")) Then .DescriptionRaw = rs.Item("siDescriptionRaw")
Line 1884: If Not IsDBNull(rs.Item("siCompanyAbbreviation")) Then .CompanyAbbreviation = rs.Item("siCompanyAbbreviation")
Line 1885: If Not IsDBNull(rs.Item("siCompany")) Then .Company = rs.Item("siCompany")
Line 1886: If Not IsDBNull(rs.Item("siPublisher")) Then .Publisher = rs.Item("siPublisher")
Line 1887: If Not IsDBNull(rs.Item("siPrice")) Then .Price = rs.Item("siPrice")
Line 1888: If Not IsDBNull(rs.Item("siMemberPrice")) Then
Line 1889: .MemberPrice = rs.Item("siMemberPrice")
Line 1890: .isMemberPrice = True
Line 1891: Else
Line 1892: .isMemberPrice = False
Line 1893: End If
Line 1894: If Not IsDBNull(rs.Item("vcRate")) Then .VATrate = rs.Item("vcRate")
Line 1895: If Not IsDBNull(rs.Item("siDiscount")) Then .Discount = rs.Item("siDiscount")
Line 1896: If Not IsDBNull(rs.Item("siImagePath")) Then .ImagePath = rs.Item("siImagePath")
Line 1897: If Not IsDBNull(rs.Item("siStockLevel")) Then .StockLevel = rs.Item("siStockLevel")
Line 1898: .UseStockLevel = rs.Item("siUseStockLevel")
Line 1899: .AllowPreOrder = rs.Item("siAllowPreOrder")
Line 1900: If Not IsDBNull(rs.Item("siDeleted")) Then .Deleted = rs.Item("siDeleted")
Line 1901: If Not IsDBNull(rs.Item("siNotes")) Then .Notes = rs.Item("siNotes")
Line 1902: ' If Not IsDBNull(rs.Item("siPerson")) Then .Person = rs.Item("siPerson")
Line 1903: If Not IsDBNull(rs.Item("siPersonPrice")) Then .PersonPrice = rs.Item("siPersonPrice")
Line 1904: If Not IsDBNull(rs.Item("sipgID")) Then .sipgID = rs.Item("sipgID")
Line 1905: .MemberOnly = rs.Item("siMemberOnly")
Line 1906: .ShowNonMembers = rs.Item("siShowNonMembers")
Line 1907: If Not IsDBNull(rs.Item("siOnSaleDate")) Then .OnSaleDate = rs.Item("siOnSaleDate")
Line 1908: If Not IsDBNull(rs.Item("siOffSaleDate")) Then .OffSaleDate = rs.Item("siOffSaleDate")
Line 1909: If Not IsDBNull(rs.Item("siscID")) Then .siscID = rs.Item("sisciD")
Line 1910: If Not IsDBNull(rs.Item("sivcID")) Then .sivcID = rs.Item("sivciD")
Line 1911: If Not IsDBNull(rs.Item("siSku")) Then .Sku = rs.Item("siSku")
Line 1912: If Not IsDBNull(rs.Item("siDateAdded")) Then .DateAdded = rs.Item("siDateAdded")
Line 1913: If Not IsDBNull(rs.Item("siFeatured")) Then .Featured = rs.Item("siFeatured")
Line 1914: If Not IsDBNull(rs.Item("siDownload")) Then .Download = rs.Item("siDownload")
Line 1915: If Not IsDBNull(rs.Item("siDownloadURL")) Then .DownloadURL = rs.Item("siDownloadURL")
Line 1916: End With
Line 1917: Else
Line 1918: getSalesItem.siID = 0
Line 1919: End If
Line 1920: End Using
Line 1921:
Line 1922: End Function
Line 1923:
Line 1924: Public Function getClient(ByVal ohID As Integer, ByVal ohOrderNo As Integer) As MemberDet
Line 1925: Dim Address As String = ""
Line 1926: Dim AddrFormat As String = ""
Line 1927: Dim CountryICode As String = ""
Line 1928: Dim CountryNumber As Integer = 0
Line 1929: Dim PostZone As String = ""
Line 1930: Dim rs As OleDbDataReader
Line 1931:
Line 1932: Using con As New OleDbConnection
Line 1933: con.ConnectionString = ConfigurationManager.ConnectionStrings("onlinesalesConnectionString").ConnectionString
Line 1934: con.Open()
Line 1935: Dim cmdClient As OleDbCommand = New OleDbCommand("Select * FROM OrderHeader WHERE ohID = " & ohID, con)
Line 1936: rs = cmdClient.ExecuteReader()
Line 1937: If rs.HasRows Then
Line 1938: rs.Read()
Line 1939: With getClient
Line 1940: If Not IsDBNull(rs.Item("ohName")) Then .Name = rs.Item("ohName").ToString
Line 1941: .Title = ""
Line 1942: .Initials = ""
Line 1943: .Surname = ""
Line 1944: .FirstName = ""
Line 1945: If Not IsDBNull(rs.Item("ohName")) Then .eName = rs.Item("ohName").ToString
Line 1946: If Not IsDBNull(rs.Item("ohAddress1")) Then .Address1 = rs.Item("ohAddress1").ToString
Line 1947: If Not IsDBNull(rs.Item("ohAddress2")) Then .Address2 = rs.Item("ohAddress2").ToString
Line 1948: If Not IsDBNull(rs.Item("ohAddress3")) Then .Address3 = rs.Item("ohAddress3").ToString
Line 1949: If Not IsDBNull(rs.Item("ohTown")) Then .PostTown = rs.Item("ohTown").ToString
Line 1950: If Not IsDBNull(rs.Item("ohPostCode")) Then .PostCode = rs.Item("ohPostCode").ToString
Line 1951: If Not IsDBNull(rs.Item("ohCountry")) Then .Country = rs.Item("ohCountry").ToString
Line 1952:
Line 1953: Address = .Address1 & gogNewLine & .Address2 & gogNewLine & .Address3 & gogNewLine
Line 1954:
Line 1955: If IsDBNull(rs.Item("ohCountry")) Then
Line 1956: AddrFormat = "A"
Line 1957: .Country = ""
Line 1958: Else
Line 1959: .Country = rs.Item("ohCountry").ToString
Line 1960: If Len(Trim(rs.Item("ohCountry").ToString)) = 0 Then
Line 1961: AddrFormat = "A"
Line 1962: CountryICode = "GB" 'default to United Kingdom
Line 1963: CountryNumber = "826"
Line 1964: Else
Line 1965: Call CountryCode(.Country, CountryICode, CountryNumber, PostZone, AddrFormat)
Line 1966: End If
Line 1967: End If
Line 1968:
Line 1969: Dim strCounty As String = ""
Line 1970: If Not IsDBNull(rs.Item("ohCounty")) Then strCounty = rs.Item("ohCounty").ToString
Line 1971: .County = strCounty
Line 1972: 'response.write(addrformat)
Line 1973: Select Case UCase(AddrFormat)
Line 1974: Case "A" 'UK address format
Line 1975: Address += UCase(Trim(.PostTown)) & gogNewLine & Trim(UCase(.PostCode))
Line 1976: CountryICode = "GB" 'default to United Kingdom
Line 1977: Case "B" 'US address format
Line 1978: Address += Trim(UCase(.PostTown)) & " " _
Line 1979: & Trim(UCase(strCounty.ToString)) _
Line 1980: & " " & Trim(UCase(.PostCode)) _
Line 1981: & gogNewLine & Trim(UCase(.Country))
Line 1982: Case "E"
Line 1983: Address += Trim(UCase(.PostCode)) & " " _
Line 1984: & Trim(UCase(.PostTown)) & " " & Trim(UCase(strCounty.ToString)) _
Line 1985: & gogNewLine & Trim(UCase(.Country))
Line 1986: Case Else
Line 1987: Address = Address & Trim(UCase(.PostTown)) _
Line 1988: & " " & Trim(UCase(strCounty.ToString)) _
Line 1989: & " " & Trim(UCase(.PostCode)) _
Line 1990: & gogNewLine & Trim(UCase(.Country))
Line 1991: End Select
Line 1992: .FormattedAddress = Address & gogNewLine
Line 1993:
Line 1994: .CountryCode = CountryICode
Line 1995: .CountryNumber = CountryNumber
Line 1996: .PostZone = PostZone
Line 1997:
Line 1998: If Not IsDBNull(rs.Item("ohEmail")) Then .emailAddress = rs.Item("ohEmail").ToString
Line 1999:
Line 2000: End With
Line 2001: Else
Line 2002: getClient.Title = "No Name"
Line 2003: End If
Line 2004: End Using
Line 2005:
Line 2006: End Function
Line 2007:
Line 2008: Public Function getClientClient(ByVal ohID As Integer) As Client
Line 2009: Dim Address As String = ""
Line 2010: Dim AddrFormat As String = ""
Line 2011: Dim CountryICode As String = ""
Line 2012: Dim CountryNumber As Integer = 0
Line 2013: Dim PostZone As String = ""
Line 2014: Dim rs As OleDbDataReader
Line 2015:
Line 2016: Using con As New OleDbConnection
Line 2017: con.ConnectionString = ConfigurationManager.ConnectionStrings("onlinesalesConnectionString").ConnectionString
Line 2018: con.Open()
Line 2019: Dim cmdClient As OleDbCommand = New OleDbCommand("Select * FROM OrderHeader WHERE ohID = " & ohID, con)
Line 2020: rs = cmdClient.ExecuteReader()
Line 2021: If rs.HasRows Then
Line 2022: rs.Read()
Line 2023: With getClientClient
Line 2024: If Not IsDBNull(rs.Item("ohName")) Then .Name = rs.Item("ohName").ToString
Line 2025: .Title = ""
Line 2026: .Initials = ""
Line 2027: .Surname = ""
Line 2028: .FirstName = ""
Line 2029: If Not IsDBNull(rs.Item("ohName")) Then .eName = rs.Item("ohName").ToString
Line 2030: If Not IsDBNull(rs.Item("ohAddress1")) Then .Address1 = rs.Item("ohAddress1").ToString
Line 2031: If Not IsDBNull(rs.Item("ohAddress2")) Then .Address2 = rs.Item("ohAddress2").ToString
Line 2032: If Not IsDBNull(rs.Item("ohAddress3")) Then .Address3 = rs.Item("ohAddress3").ToString
Line 2033: If Not IsDBNull(rs.Item("ohTown")) Then .PostTown = rs.Item("ohTown").ToString
Line 2034: If Not IsDBNull(rs.Item("ohPostCode")) Then .PostCode = rs.Item("ohPostCode").ToString
Line 2035: If Not IsDBNull(rs.Item("ohCountry")) Then .Country = rs.Item("ohCountry").ToString
Line 2036:
Line 2037: Address = .Address1 & gogNewLine & .Address2 & gogNewLine & .Address3 & gogNewLine
Line 2038:
Line 2039: If IsDBNull(rs.Item("ohCountry")) Then
Line 2040: AddrFormat = "A"
Line 2041: .Country = ""
Line 2042: Else
Line 2043: .Country = rs.Item("ohCountry").ToString
Line 2044: If Len(Trim(rs.Item("ohCountry").ToString)) = 0 Then
Line 2045: AddrFormat = "A"
Line 2046: CountryICode = "GB" 'default to United Kingdom
Line 2047: CountryNumber = "826"
Line 2048: Else
Line 2049: Call CountryCode(.Country, CountryICode, CountryNumber, PostZone, AddrFormat)
Line 2050: End If
Line 2051: End If
Line 2052:
Line 2053: Dim strCounty As String = ""
Line 2054: If Not IsDBNull(rs.Item("ohCounty")) Then strCounty = rs.Item("ohCounty").ToString
Line 2055: .County = strCounty
Line 2056: 'response.write(addrformat)
Line 2057: Select Case UCase(AddrFormat)
Line 2058: Case "A" 'UK address format
Line 2059: Address += UCase(Trim(.PostTown)) & gogNewLine & Trim(UCase(.PostCode))
Line 2060: CountryICode = "GB" 'default to United Kingdom
Line 2061: Case "B" 'US address format
Line 2062: Address += Trim(UCase(.PostTown)) & " " _
Line 2063: & Trim(UCase(strCounty.ToString)) _
Line 2064: & " " & Trim(UCase(.PostCode)) _
Line 2065: & gogNewLine & Trim(UCase(.Country))
Line 2066: Case "E"
Line 2067: Address += Trim(UCase(.PostCode)) & " " _
Line 2068: & Trim(UCase(.PostTown)) & " " & Trim(UCase(strCounty.ToString)) _
Line 2069: & gogNewLine & Trim(UCase(.Country))
Line 2070: Case Else
Line 2071: Address = Address & Trim(UCase(.PostTown)) _
Line 2072: & " " & Trim(UCase(strCounty.ToString)) _
Line 2073: & " " & Trim(UCase(.PostCode)) _
Line 2074: & gogNewLine & Trim(UCase(.Country))
Line 2075: End Select
Line 2076: .FormattedAddress = Address & gogNewLine
Line 2077:
Line 2078: .CountryCode = CountryICode
Line 2079: .CountryNumber = CountryNumber
Line 2080: .PostZone = PostZone
Line 2081:
Line 2082: If Not IsDBNull(rs.Item("ohEmail")) Then .emailAddress = rs.Item("ohEmail").ToString
Line 2083:
Line 2084: End With
Line 2085: Else
Line 2086: getClientClient.Title = "No Name"
Line 2087: End If
Line 2088: End Using
Line 2089:
Line 2090: End Function
Line 2091:
Line 2092: Public Function getTicketDef(ByVal idRef As Integer) As TicketDetail
Line 2093: Dim rs As OleDbDataReader
Line 2094:
Line 2095: Using con As New OleDbConnection
Line 2096: con.ConnectionString = ConfigurationManager.ConnectionStrings("onlinesalesConnectionString").ConnectionString
Line 2097: con.Open()
Line 2098: Dim cmdClient As OleDbCommand = New OleDbCommand("Select * FROM Tickets WHERE idREf = " & idRef, con)
Line 2099: rs = cmdClient.ExecuteReader()
Line 2100: If rs.HasRows Then
Line 2101: rs.Read()
Line 2102: With getTicketDef
Line 2103: If Not IsDBNull(rs.Item("description")) Then .TicketTitle = rs.Item("description").ToString
Line 2104: If Not IsDBNull(rs.Item("emailText")) Then .TicketemailText = rs.Item("emailText").ToString
Line 2105:
Line 2106: End With
Line 2107: Else
Line 2108: getTicketDef.TicketTitle = "No Name"
Line 2109: End If
Line 2110: End Using
Line 2111: End Function
Line 2112:
Line 2113: Public Function getPP(ByVal pgID As Integer, ByVal pdZone As String) As PP
Line 2114: Dim rs As OleDbDataReader
Line 2115:
Line 2116: Using con As New OleDbConnection
Line 2117: con.ConnectionString = ConfigurationManager.ConnectionStrings("onlinesalesConnectionString").ConnectionString
Line 2118: con.Open()
Line 2119:
Line 2120: Dim cmdPP As OleDbCommand = New OleDbCommand("Select PostageDetails.*, PostageGroup.* FROM PostageDetails LEFT JOIN PostageGroup ON PostageDetails.pdpgID = PostageGroup.pgID WHERE pdpgID = " & pgID & " And pdZone = '" & pdZone & "'", con)
Line 2121: rs = cmdPP.ExecuteReader()
Line 2122: If rs.HasRows Then
Line 2123: rs.Read()
Line 2124: With getPP
Line 2125: If Not IsDBNull(rs.Item("pgTitle")) Then .Title = rs.Item("pgTitle")
Line 2126: If Not IsDBNull(rs.Item("pgDescription")) Then .Description = rs.Item("pgDescription")
Line 2127: If Not IsDBNull(rs.Item("pgShareGroup")) Then .ShareGroup = rs.Item("pgShareGroup")
Line 2128: If Not IsDBNull(rs.Item("pdZone")) Then .Zone = rs.Item("pdZone")
Line 2129: If Not IsDBNull(rs.Item("pdCombine")) Then .Combine = rs.Item("pdCombine")
Line 2130: If Not IsDBNull(rs.Item("pdQty1")) Then .Qty1 = rs.Item("pdQty1")
Line 2131: If Not IsDBNull(rs.Item("pdQty2")) Then .Qty2 = rs.Item("pdQty2")
Line 2132: If Not IsDBNull(rs.Item("pdQty3")) Then .Qty3 = rs.Item("pdQty3")
Line 2133: If Not IsDBNull(rs.Item("pdPrice1")) Then .Price1 = rs.Item("pdPrice1")
Line 2134: If Not IsDBNull(rs.Item("pdPrice2")) Then .Price2 = rs.Item("pdPrice2")
Line 2135: If Not IsDBNull(rs.Item("pdPrice3")) Then .Price3 = rs.Item("pdPrice3")
Line 2136:
Line 2137: End With
Line 2138: Else
Line 2139: getPP.Qty1 = -1
Line 2140: getPP.Price1 = 0
Line 2141:
Line 2142: End If
Line 2143: End Using
Line 2144: End Function
Line 2145:
Line 2146: Public Function getStatus(ByVal osID As Integer) As String
Line 2147: Dim rs As OleDbDataReader
Line 2148:
Line 2149: Using con As New OleDbConnection
Line 2150: con.ConnectionString = ConfigurationManager.ConnectionStrings("onlinesalesConnectionString").ConnectionString
Line 2151: con.Open()
Line 2152:
Line 2153: Dim cmdOrderStatus As OleDbCommand = New OleDbCommand("Select * FROM OrderStatus WHERE osID = " & osID, con)
Line 2154: rs = cmdOrderStatus.ExecuteReader()
Line 2155: If rs.HasRows Then
Line 2156: rs.Read()
Line 2157: If Not IsDBNull(rs.Item("osStatus")) Then getStatus = rs.Item("osStatus")
Line 2158: Else
Line 2159: getStatus = ""
Line 2160: End If
Line 2161: End Using
Line 2162: End Function
Line 2163:
Line 2164: Public Function getscID(ByVal SaleType As String) As Integer
Line 2165: Dim rs As OleDbDataReader
Line 2166:
Line 2167: Using con As New OleDbConnection
Line 2168: con.ConnectionString = ConfigurationManager.ConnectionStrings("onlinesalesConnectionString").ConnectionString
Line 2169: con.Open()
Line 2170:
Line 2171: Dim cmdOrderStatus As OleDbCommand = New OleDbCommand("Select * FROM SalesCategories WHERE scName = '" & SaleType & "'", con)
Line 2172: rs = cmdOrderStatus.ExecuteReader()
Line 2173: If rs.HasRows Then
Line 2174: rs.Read()
Line 2175: getscID = rs.Item("scID")
Line 2176: Else
Line 2177: getscID = 0
Line 2178: End If
Line 2179: End Using
Line 2180: End Function
Line 2181:
Line 2182: Public Function getosID(ByVal OrderStatus As String) As Integer
Line 2183: Dim rs As OleDbDataReader
Line 2184:
Line 2185: Using con As New OleDbConnection
Line 2186: con.ConnectionString = ConfigurationManager.ConnectionStrings("onlinesalesConnectionString").ConnectionString
Line 2187: con.Open()
Line 2188:
Line 2189: Dim cmdOrderStatus As OleDbCommand = New OleDbCommand("Select * FROM OrderStatus WHERE osStatus = '" & OrderStatus & "'", con)
Line 2190: rs = cmdOrderStatus.ExecuteReader()
Line 2191: If rs.HasRows Then
Line 2192: rs.Read()
Line 2193: getosID = rs.Item("osID")
Line 2194: Else
Line 2195: getosID = 0
Line 2196: End If
Line 2197: End Using
Line 2198: End Function
Line 2199:
Line 2200: Public Function countTickets(ByVal EventRef As String) As Integer
Line 2201: Dim rs As OleDbDataReader
Line 2202: countTickets = 0
Line 2203: Using con As New OleDbConnection
Line 2204: con.ConnectionString = ConfigurationManager.ConnectionStrings("onlinesalesConnectionString").ConnectionString
Line 2205: con.Open()
Line 2206: Dim cmdClient As OleDbCommand = New OleDbCommand("Select COUNT(*) As TicketCount FROM OrdDetails LEFT Join OrderHeader On OrdDetails.odOhID = OrderHeader.ohID WHERE ohTransType = 'Tickets' AND odsiID = " & EventRef, con)
Line 2207: rs = cmdClient.ExecuteReader()
Line 2208: If rs.HasRows Then
Line 2209: rs.Read()
Line 2210: countTickets = rs.Item("TicketCount")
Line 2211: End If
Line 2212: End Using
Line 2213:
Line 2214: End Function
Line 2215:
Line 2216: Public Function ProcessOrder(ByRef rsDet As OleDbDataReader, ByRef sQty As Integer, ByRef OrderComplete As Boolean, Resend As Boolean) As String
Line 2217: Dim smsgOrd As String = ""
Line 2218: Dim TDES As New TripleDES
Line 2219: With rsDet
Line 2220: Dim SaleItem As OnlineSales.SalesItem = getSalesItem(.Item("odsiID"))
Line 2221: If SaleItem.Download Then
Line 2222: Dim DownLoadURL As String = SaleItem.DownloadURL
Line 2223: Dim DownLoadLinkEncrypted As String = ConfigurationManager.AppSettings("baseurl") & "/Onlinesales/SalesDownload?ident=" & System.Net.WebUtility.UrlEncode(TDES.Encrypt("odohid=" & .Item("odohID") & "&url=" & SaleItem.DownloadURL & "&date=" & Now().ToShortDateString & "&eof=End"))
Line 2224: If IsDBNull(.Item("odTitle")) Then
Line 2225: smsgOrd += sQty & " " & "(no details available)"
Line 2226: Else
Line 2227: smsgOrd += sQty & " " & .Item("odTitle").ToString & " download" & gogNewLine
Line 2228: smsgOrd += "The item will be downloaded by the client. No action is required." & gogNewLine
Line 2229: smsgOrd += gogNewLine
Line 2230:
Line 2231: End If
Line 2232: smsgOrd += " £" & FormatNumber((.Item("odAmtToPay")) / 100, 2) & gogNewLine
Line 2233: If ShopItemDetails(.Item("odsiID")).Length > 0 Then smsgOrd += gogNewLine & ShopItemDetails(.Item("odsiID"))
Line 2234: smsgOrd += gogNewLine
Line 2235: If Not Resend Then MarkShopDownLoad(.Item("odid"))
Line 2236: Else
Line 2237: OrderComplete = False
Line 2238: If IsDBNull(.Item("odTitle")) Then
Line 2239: smsgOrd += sQty & " " & "(no details available)"
Line 2240: Else
Line 2241: smsgOrd += sQty & " " & .Item("odTitle").ToString
Line 2242: If Not IsDBNull(.Item("odPerson")) Then If .Item("odPerson").ToString.Length > 0 Then smsgOrd += " For " & .Item("odPerson").ToString
Line 2243: If Not IsDBNull(.Item("odNotes")) Then smsgOrd += " " & .Item("odNotes").ToString
Line 2244: End If
Line 2245: smsgOrd += " £" & FormatNumber((.Item("odAmtToPay")) / 100, 2) & gogNewLine
Line 2246: If ShopItemDetails(.Item("odsiID")).Length > 0 Then smsgOrd += gogNewLine & ShopItemDetails(.Item("odsiID"))
Line 2247: smsgOrd += gogNewLine
Line 2248: End If
Line 2249: End With
Line 2250: ProcessOrder = smsgOrd
Line 2251: End Function
Line 2252:
Line 2253: Protected Function ShopItemDetails(siID As Integer) As String
Line 2254: Dim SalesItem As New OnlineSales.SalesItem
Line 2255: ShopItemDetails = ""
Line 2256: SalesItem = getSalesItem(siID)
Line 2257: Select Case SalesItem.SaleType
Line 2258: Case Is = "Dwgs"
Line 2259: ShopItemDetails += "GOG Ref: " & SalesItem.Sku & gogNewLine
Line 2260: ShopItemDetails += SalesItem.Description & gogNewLine
Line 2261: ' ShopItemDetails += "Company: " & SalesItem.Company & gogNewLine
Line 2262: ' ShopItemDetails += "Publisher; " & SalesItem.Publisher & gogNewLine
Line 2263: End Select
Line 2264: End Function
Line 2265:
Line 2266: Public Function ShopActionee(SaleType As Integer, TestMode As Integer) As String
Line 2267: Dim rs As OleDbDataReader
Line 2268:
Line 2269: Using con As New OleDbConnection
Line 2270: con.ConnectionString = ConfigurationManager.ConnectionStrings("onlinesalesConnectionString").ConnectionString
Line 2271: con.Open()
Line 2272: Dim cmd As OleDbCommand = New OleDbCommand("SELECT * FROM SalesCategories WHERE scID = " & SaleType, con)
Line 2273: ShopActionee = defaultEmail
Line 2274: rs = cmd.ExecuteReader()
Line 2275: If rs.HasRows Then
Line 2276: rs.Read()
Line 2277: If Not IsDBNull(rs.Item("scemail")) Then ShopActionee = rs.Item("scemail")
Line 2278: End If
Line 2279:
Line 2280: If TestMode <> 0 Then ShopActionee = defaultEmail
Line 2281:
Line 2282: End Using
Line 2283: End Function
Line 2284:
Line 2285: Public Function SetActionee(SaleType As String, testmode As Integer) As String
Line 2286: Dim gogmail As New gogmail
Line 2287: Select Case SaleType
Line 2288: Case "Donation"
Line 2289: SetActionee = gogmail.FindEmail("Board", "Treasurer")
Line 2290: Case "Memb"
Line 2291: SetActionee = "" 'Membership applications/renewals processed below.
Line 2292: Case "Video"
Line 2293: SetActionee = gogmail.FindEmail("Membership", "Video Hire") '"chris_simpson99@btinternet.com" 'request("email") '"nigel_nelson@mail.com" 'Video Hire Manager
Line 2294: Case "Slide"
Line 2295: SetActionee = gogmail.FindEmail("Membership", "Video Hire") '"chris_simpson99@btinternet.com"
Line 2296: Case "Drawing"
Line 2297: SetActionee = gogmail.FindEmail("Membership", "Drawings Scheme Administrator") '"john@johnhobden.net"
Line 2298: Case "Tickets"
Line 2299: SetActionee = gogmail.FindEmail("Membership", "Advance Tickets") '"aj6339@blueyonder.co.uk" 'Advanced Tickets Manager
Line 2300: Case "Stands"
Line 2301: SetActionee = gogmail.FindEmail("Events", "Stand Bookings") 'ArtyType of acounting
Line 2302: Case "Pubs"
Line 2303: SetActionee = gogmail.FindEmail("Publications", "Sales")
Line 2304: Case Else
Line 2305: SetActionee = defaultEmail
Line 2306: End Select
Line 2307: If testmode <> 0 Then 'overwrite actionee if test run
Line 2308: Select Case SaleType
Line 2309: Case "Tickets"
Line 2310: SetActionee = defaultEmail
Line 2311: Case Else
Line 2312: SetActionee = defaultEmail 'retemail not always set in OrderPay
Line 2313: End Select
Line 2314: End If
Line 2315: End Function
Line 2316:
Line 2317: Public Sub MarkShopDownLoad(odID As Integer)
Line 2318: Using con As New OleDbConnection
Line 2319: con.ConnectionString = ConfigurationManager.ConnectionStrings("onlinesalesConnectionString").ConnectionString
Line 2320: con.Open()
Line 2321: Dim cmdOrdDet As OleDbCommand = New OleDbCommand("UPDATE OrdDetails SET odosID=@odosID WHERE odID=@odID ", con)
Line 2322: cmdOrdDet.Parameters.Add("@odosID", OleDbType.Integer)
Line 2323: cmdOrdDet.Parameters.Add("@odId", OleDbType.Integer)
Line 2324:
Line 2325: cmdOrdDet.Parameters("@odosID").Value = getosID("Down Load") 'items are all downloads
Line 2326: cmdOrdDet.Parameters("@odID").Value = odID
Line 2327:
Line 2328: cmdOrdDet.ExecuteNonQuery()
Line 2329: cmdOrdDet.Dispose()
Line 2330: End Using
Line 2331: End Sub
Line 2332:
Line 2333: Private Sub StockLevels(SalesOrderID As Integer)
Line 2334: Dim rsOrdDet As OleDbDataReader
Line 2335: Dim SalesItem As New OnlineSales.SalesItem
Line 2336: Dim StockLevel As Integer = 0
Line 2337:
Line 2338: Using con As New OleDbConnection 'check is this order is in the Shop
Line 2339: con.ConnectionString = ConfigurationManager.ConnectionStrings("onlinesalesConnectionString").ConnectionString
Line 2340: con.Open()
Line 2341: Dim cmdSalesItem As OleDbCommand = New OleDbCommand("UPDATE SalesItems SET siStocklevel = @StockLevel WHERE siID=@siID", con)
Line 2342: cmdSalesItem.Parameters.Add("@StockLevel", OleDbType.Integer)
Line 2343: cmdSalesItem.Parameters.Add("@siID", OleDbType.Integer)
Line 2344: Dim cmdOrdDetails As OleDbCommand = New OleDbCommand("SELECT * FROM OrdDetails LEFT JOIN OrderHeader ON OrdDetails.odOhID = OrderHeader.ohID WHERE ohOrderNo = " & SalesOrderID & " AND (odQuantity > 0 OR odAmtToPay > 0) ORDER BY [odOhID]", con)
Line 2345: rsOrdDet = cmdOrdDetails.ExecuteReader()
Line 2346: Do While rsOrdDet.Read()
Line 2347: Try
Line 2348: SalesItem = getSalesItem(rsOrdDet.Item("odSiID"))
Line 2349: If SalesItem.UseStockLevel Then
Line 2350: StockLevel = SalesItem.StockLevel - rsOrdDet.Item("odQuantity")
Line 2351:
Line 2352: cmdSalesItem.Parameters("@StockLevel").Value = StockLevel
Line 2353: cmdSalesItem.Parameters("@SiID").Value = rsOrdDet.Item("odSiID")
Line 2354: cmdSalesItem.ExecuteNonQuery()
Line 2355: End If
Line 2356: Catch
Line 2357: SendErrorMsg("Online Sales vb Send Error", "Update StockLevel Error - SalesOrderid=" & SalesOrderID & "odsiId=" & rsOrdDet.Item("odSiID") & "<br />")
Line 2358: ' Response.Write("Update StockLevel Error - SalesOrderid=" & SalesOrderID & "odsiId=" & rsOrdDet.Item("odSiID") & "<br />")
Line 2359: End Try
Line 2360: Loop
Line 2361: End Using
Line 2362: End Sub
Line 2363:
Line 2364: Private Function MaxLineLength(str As String) As Integer
Line 2365: Dim i As Integer = 0
Line 2366: Dim j As Integer = 0
Line 2367: Dim Max As Integer = 0
Line 2368: For i = 0 To str.Length - 1 Step 1
Line 2369: If Mid(str(i), 1) = vbNewLine Then
Line 2370: If i - j > Max Then Max = i - j
Line 2371: j = i
Line 2372: End If
Line 2373: Next
Line 2374: If i - j > Max Then Max = i - j 'allow for no new line or no new line on last line
Line 2375: MaxLineLength = Max
Line 2376: End Function
Line 2377:
Line 2378: Public Function PaymentFailure(gogOrderid As Integer, SalesOrderID As Integer, WPSaleType As String) As String
Line 2379: Dim gogmail As New gogmail
Line 2380: Dim mfrom As gogmail.gogMailAddress
Line 2381: mfrom.gogAddress = gogfromDefault '"confirm13@gaugeoguild.com"
Line 2382: mfrom.gogDisplayName = gogfromDisplay '"Gauge O Guild"
Line 2383: Dim mto As gogmail.gogMailAddress
Line 2384: mto.gogAddress = defaultEmail '"confirm13@gaugeoguild.com"
Line 2385: Dim mCC(5) As gogmail.gogMailAddress
Line 2386: Dim mSubject As String = ""
Line 2387: Dim mBody As String = ""
Line 2388: Dim sendresult As String = ""
Line 2389:
Line 2390: Dim bNewMember As Boolean = False
Line 2391: Dim iMemberNr As Integer = 0
Line 2392: Dim MemDetails As String = ""
Line 2393: Dim MembEmail As String = ""
Line 2394: Dim ohID As Integer = 0
Line 2395: Dim OrderDetails As String = ""
Line 2396: Dim payerror As String = ""
Line 2397: Dim retemail As String = ""
Line 2398: Dim retMessage As String = ""
Line 2399: Dim rs As OleDbDataReader
Line 2400: Dim sBody As String = ""
Line 2401: Dim sMsg As String = ""
Line 2402:
Line 2403: 'Dim dvSales As DataView
Line 2404: PaymentFailure = "Your application has been cancelled." 'default setting to return
Line 2405: payerror = retMessage
Line 2406: Select Case WPSaleType
Line 2407: Case = "Memb"
Line 2408: iMemberNr = gogOrderid
Line 2409: 'response.write("subyear=:" & subyear & ":<br>")
Line 2410: If iMemberNr > 999999 Then ' = New member
Line 2411: bNewMember = True
Line 2412: Else
Line 2413: bNewMember = False
Line 2414: End If '
Line 2415:
Line 2416: If bNewMember Then
Line 2417: sMsg = "Gauge O Guild applicant with reference number " & iMemberNr & " has applied to join online but your payment has been cancelled."
Line 2418: PaymentFailure = "Your application has been cancelled, " & payerror
Line 2419: Else
Line 2420: sMsg = "Gauge O Guild member " & iMemberNr & " has applied to renew online but your payment has been cancelled."
Line 2421:
Line 2422: ' LabelSalesError.Text = "Your order has been cancelled, " & payerror
Line 2423:
Line 2424: PaymentFailure = "Your membership renwal has been cancelled, " & payerror
Line 2425: If bNewMember Then
Line 2426:
Line 2427: sBody = "Thank you for applying to join the Gauge O Guild. Your application reference is:" & gogNewLine & gogNewLine _
Line 2428: & iMemberNr & gogNewLine & gogNewLine
Line 2429: sBody = sBody & "However, your payment has been cancelled."
Line 2430:
Line 2431: Else
Line 2432:
Line 2433: sBody = "Thank you for your application to renew your Gauge O membership:" & gogNewLine & gogNewLine _
Line 2434: & iMemberNr & gogNewLine & gogNewLine
Line 2435: sBody = sBody & "However, your payment has been cancelled."
Line 2436:
Line 2437: End If
Line 2438: End If
Line 2439: If retemail.Length > 0 Then
Line 2440: ' mmto = New MailAddress(retemail.ToString)
Line 2441: mto.gogAddress = retemail.ToString
Line 2442: ' mm = New MailMessage(mmfrom, mmto)
Line 2443: 'mm.Subject = "Your Gauge 'O' Guild application/renewal"
Line 2444: mSubject = "Your Gauge O Guild application/renewal"
Line 2445: ' mm.IsBodyHtml = False
Line 2446: ' mm.Body = sBody
Line 2447: mBody = sBody
Line 2448:
Line 2449: ' Try
Line 2450: ' smtp.Send(mm)
Line 2451: ' Catch ex As Exception
Line 2452: ' Response.Write("Send message error to applicant" & Err.ToString & "<br>")
Line 2453: ' End Try
Line 2454: sendresult = gogmail.ggMail(mfrom, mto, mSubject, mBody)
Line 2455: If sendresult <> "Email sent" Then SendErrorMsg("OnlineSales PaymentFailure Error", "Send message error to applicant " & sendresult & gogNewLine)
Line 2456: End If
Line 2457:
Line 2458: Case = "Shop"
Line 2459: ' Response.Write("start payfail 1 - " & Session("retorderid") & "<br />")
Line 2460: If IsNumeric(SalesOrderID) Then
Line 2461: PaymentFailure = ShopFailure(SalesOrderID)
Line 2462: Else
Line 2463: SendErrorMsg("OnlineSales PaymentFailure Error", "Shop SalesOrder id not numeric - transaction failure")
Line 2464: 'MultiView1.SetActiveView(SystemError)
Line 2465: End If
Line 2466:
Line 2467: Case = "Tickets"
Line 2468: ' mto.gogAddress = Actionee.ToString
Line 2469: ' mCC(0).gogAddress = Author
Line 2470: ' mCC(0).gogType = "BCc"
Line 2471: ' mSubject = "Gauge O Guild Online Sales"
Line 2472:
Line 2473: If IsNumeric(SalesOrderID) Then
Line 2474: Using con As New OleDbConnection 'check is this order is in the Shop
Line 2475: con.ConnectionString = ConfigurationManager.ConnectionStrings("onlinesalesConnectionString").ConnectionString
Line 2476: con.Open()
Line 2477: Dim cmdOrders As OleDbCommand = New OleDbCommand("SELECT * FROM OrderHeader WHERE ohOrderNo = " & SalesOrderID, con)
Line 2478: rs = cmdOrders.ExecuteReader()
Line 2479: If rs.HasRows Then
Line 2480: PaymentFailure = ShopFailure(SalesOrderID) 'tickets using new order structure
Line 2481: Else
Line 2482: 'OrderFailure(SalesOrderID)
Line 2483: End If
Line 2484: End Using
Line 2485: Else
Line 2486: SendErrorMsg("OnlineSales PayFailure Error", "Shop Order id Not numeric - record update failure")
Line 2487: 'MultiView1.SetActiveView(SystemError)
Line 2488: End If
Line 2489:
Line 2490: Case Else
Line 2491: If IsNumeric(SalesOrderID) Then
Line 2492: PaymentFailure = ShopFailure(SalesOrderID)
Line 2493: Else
Line 2494: SendErrorMsg("OnlineSales PaymentFailure Error", "SalesOrder id Not numeric - transaction failure")
Line 2495: 'MultiView1.SetActiveView(SystemError)
Line 2496: End If
Line 2497: End Select
Line 2498:
Line 2499: End Function
Line 2500:
Line 2501: Public Function ShopFailure(SalesOrderID As Integer) As String
Line 2502: Dim gogmail As New gogmail
Line 2503: Dim mfrom As gogmail.gogMailAddress
Line 2504: mfrom.gogAddress = gogfromDefault '"confirm13@gaugeoguild.com"
Line 2505: mfrom.gogDisplayName = gogfromDisplay '"Gauge O Guild"
Line 2506: Dim mto As gogmail.gogMailAddress
Line 2507: mto.gogAddress = defaultEmail '"confirm13@gaugeoguild.com"
Line 2508: Dim mCC(5) As gogmail.gogMailAddress
Line 2509: Dim mSubject As String = ""
Line 2510: Dim mBody As String = ""
Line 2511: Dim sendresult As String = ""
Line 2512:
Line 2513: Dim bNewMember As Boolean = False
Line 2514: Dim iMemberNr As Integer = 0
Line 2515: Dim MemDetails As String = ""
Line 2516: Dim MembEmail As String = ""
Line 2517: Dim ohID As Integer = 0
Line 2518: Dim OrderDetails As String = ""
Line 2519: Dim payerror As String = ""
Line 2520: Dim retemail As String = ""
Line 2521: Dim retMessage As String = ""
Line 2522: Dim rs As OleDbDataReader
Line 2523: Dim sBody As String = ""
Line 2524: Dim sMsg As String = ""
Line 2525: ' Response.Write("start shopfail 1 - " & Session("retorderid") & "<br />")
Line 2526: ' mto.gogAddress = Actionee.ToString
Line 2527: ' mCC(0).gogAddress = Author
Line 2528: ' mCC(0).gogType = "BCc"
Line 2529: mSubject = "Gauge O Guild Online Sales"
Line 2530:
Line 2531: Using con As New OleDbConnection 'check is this order is in the Shop
Line 2532: con.ConnectionString = ConfigurationManager.ConnectionStrings("onlinesalesConnectionString").ConnectionString
Line 2533: con.Open()
Line 2534: Dim cmdOrders As OleDbCommand = New OleDbCommand("SELECT * FROM OrderHeader WHERE ohOrderNo = " & SalesOrderID, con)
Line 2535: rs = cmdOrders.ExecuteReader()
Line 2536: If rs.HasRows Then
Line 2537: rs.Read()
Line 2538: MembEmail = rs.Item("ohemail").ToString
Line 2539: OrderDetails = rs.Item("ohOrderNo").ToString
Line 2540: ohID = rs.Item("ohID")
Line 2541: Else
Line 2542: SendErrorMsg("OnlineSales ShopFailure Error", "ShopFailure shop order record Not found record Not found SalesOrderID= " & SalesOrderID & "<br>")
Line 2543: End If
Line 2544:
Line 2545: sMsg = "<p>Order Details" & gogNewLine & OrderDetails & "</p><p>" 'gogNewLine & gogNewLine
Line 2546: sMsg += MemDetails
Line 2547: sMsg = sMsg & gogNewLine & "email: " & MembEmail.ToString & "</p>" 'gogNewLine
Line 2548:
Line 2549: 'mm.Body = "Order no " & SalesOrderid & " cancelled, no payment received for:" & gogNewLine & sMsg & gogNewLine & gogNewLine & "End of message"
Line 2550: mBody = "Order no " & SalesOrderID & " cancelled, no payment received for:" & gogNewLine & sMsg & gogNewLine & gogNewLine & "End of message"
Line 2551:
Line 2552: sBody = "Thank you for trying to place the order no " & SalesOrderID & " detailed below, but this cannot be processed as your payment has been cancelled." & gogNewLine
Line 2553:
Line 2554: rs.Close()
Line 2555: cmdOrders.CommandText = "UPDATE OrderHeader SET ohOsID = 5 WHERE (ohID = " & ohID.ToString & ")"
Line 2556: cmdOrders.ExecuteNonQuery()
Line 2557:
Line 2558: If MembEmail <> "" Then
Line 2559: mto.gogAddress = MembEmail
Line 2560: sendresult = gogmail.ggMail(mfrom, mto, mSubject, mBody, mCC)
Line 2561: If sendresult <> "Email sent" Then SendErrorMsg("OnlineSales ShopFailure Error", "Shop sales message error to purchaser" & sendresult & gogNewLine)
Line 2562: Else
Line 2563: SendErrorMsg("OnlineSales ShopFailure Error", "Shop sales message error MembEmail is not set - SalesOrderID=" & SalesOrderID & gogNewLine)
Line 2564: End If
Line 2565: End Using
Line 2566: ShopFailure = "Your order has been cancelled, " & payerror
Line 2567: ' Response.Write("end shopfail 1 - " & Session("retorderid") & "<br />")
Line 2568:
Line 2569: End Function
Line 2570:
Line 2571: Protected Sub SendErrorMsg(mSubject As String, mBody As String)
Line 2572:
Line 2573: Dim defaultEmail As String = ConfigurationManager.AppSettings("memberEmail")
Line 2574: Dim gogmail As New gogmail
Line 2575: Dim mmfrom As gogmail.gogMailAddress
Line 2576: Dim mmto As gogmail.gogMailAddress
Line 2577: mmfrom.gogAddress = "confirm13@gauge0guild.com"
Line 2578: mmto.gogAddress = defaultEmail '"membermail@gaugeoguild.com"
Line 2579: Dim result As String = gogmail.ggMail(mmfrom, mmto, mSubject, mBody)
Line 2580: End Sub
Line 2581:
Line 2582: End Class
Line 2583:
|