-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathPaymentSuccessfull.aspx.vb
168 lines (121 loc) · 5.97 KB
/
PaymentSuccessfull.aspx.vb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
Imports System
Imports System.Data
Imports System.Configuration
Imports System.Data.SqlClient
Imports System.Web
Imports System.Web.UI
Imports System.Web.Security
Imports System.Web.UI.WebControls
Imports System.Web.UI.HtmlControls
Imports System.Web.UI.WebControls.WebParts
Imports System.Drawing
Imports System.IO
Imports System.Text
Imports System.Security.Cryptography
Imports System.Net.Mail
Imports System.Net
Partial Class PaymentSuccessfull
Inherits System.Web.UI.Page
Public cn As New SqlConnection
Public cmd As New SqlCommand
Public da As SqlDataAdapter
Public dr As SqlDataReader
Public ds As DataSet = New DataSet
Public ConString As String = System.Configuration.ConfigurationManager.ConnectionStrings("dbconn").ConnectionString
Protected Sub Page_Load(sender As Object, e As EventArgs) Handles Me.Load
Dim tablenum As String = Request.QueryString("tablenum").ToString()
Dim currtablestatus As String = Request.QueryString("currenttablestatus").ToString()
Dim paymentstatus As String = Request.QueryString("paymentstatus").ToString()
If tablenum = Session("ordertablenum") And currtablestatus = Session("ordertablestatus") And paymentstatus = "PAID" Then
Try
cmd.Parameters.Clear()
Dim xSQL As New System.Text.StringBuilder
xSQL.AppendLine("UPDATE SHOPLIFYORDERTOTAL")
xSQL.AppendLine("SET")
xSQL.AppendLine("PAYMENT = @PAYMENT, PAYMENTTYPE = @PAYMENTTYPE, PAYMENTMADEUSING = @PAYMENTMADEUSING")
xSQL.AppendLine("WHERE ORDERFINALNUM = @ORDERFINALNUM")
Using cn As New SqlConnection(ConString)
cn.Open()
Dim cmd As New SqlCommand(xSQL.ToString, cn)
cmd.Parameters.AddWithValue("@PAYMENT", "PAID")
cmd.Parameters.AddWithValue("@PAYMENTTYPE", "ONLINE")
cmd.Parameters.AddWithValue("@PAYMENTMADEUSING", "PayPal")
cmd.Parameters.AddWithValue("@ORDERFINALNUM", Session("orderfinalnum"))
cmd.ExecuteNonQuery()
cn.Close()
End Using
Catch ex As Exception
MyMsgBox("2nd Try" + ex.GetBaseException().ToString())
End Try
Try
cmd.Parameters.Clear()
MyCn()
cn.Open()
cmd.Connection = cn
cmd.CommandText = "SELECT PAYMENT FROM SHOPLIFYORDERTOTAL WHERE TABLENUM = @TABLENUM AND CURRENTTABLESTATUS = @CURRENTTABLESTATUS"
cmd.Parameters.AddWithValue("@TABLENUM", Session("ordertablenum"))
cmd.Parameters.AddWithValue("@CURRENTTABLESTATUS", "OCCUPIED")
Dim lrd As SqlDataReader = cmd.ExecuteReader()
Dim tablestatus As String = "PAID"
Dim tablepaymentstatus As String
Dim paymentvalue(10) As String
If lrd.HasRows = True Then
Dim i As Integer = 0
While lrd.Read()
paymentvalue(i) = lrd.Item("PAYMENT")
i = i + 1
End While
For x As Integer = 1 To paymentvalue.Length - 1
If paymentvalue(x) = "NOT PAID" Then
tablepaymentstatus = "CANCEL"
Exit For
ElseIf paymentvalue(x) = "PAID" Then
tablepaymentstatus = "UPDATE"
End If
Next
'If tablepaymentstatus = "UPDATE" Then
Try
cmd.Parameters.Clear()
Dim xSQL As New System.Text.StringBuilder
xSQL.AppendLine("UPDATE SHOPLIFYRESTAURANTTABLE")
xSQL.AppendLine("SET")
xSQL.AppendLine("CURRENTPAYMENTSTATUS = @CURRENTPAYMENTSTATUS")
xSQL.AppendLine("WHERE TABLENUM = @TABLENUM")
Using cn As New SqlConnection(ConString)
cn.Open()
Dim cmd As New SqlCommand(xSQL.ToString, cn)
cmd.Parameters.AddWithValue("@CURRENTPAYMENTSTATUS", "PAID")
cmd.Parameters.AddWithValue("@TABLENUM", Session("ordertablenum"))
cmd.ExecuteNonQuery()
cn.Close()
End Using
Catch ex As Exception
MyMsgBox("3rd Try" + ex.GetBaseException().ToString())
End Try
' End If
End If
Catch ex As Exception
MyMsgBox("rrr Try" + ex.GetBaseException().ToString())
End Try
Session("paypalstatus") = "SUCCESS"
Else
Session("paypalstatus") = "FAIL"
End If
End Sub
Public Sub MyCn()
If cn.State = Data.ConnectionState.Open Then cn.Close()
cn.ConnectionString = System.Configuration.ConfigurationManager.ConnectionStrings("dbconn").ConnectionString
End Sub
Protected Sub MyMsgBox(ByVal tcMessage As String)
Dim lcScript As String
tcMessage = Replace(tcMessage, vbCrLf, "\n")
tcMessage = Replace(tcMessage, """", "")
lcScript = "<script language=""javascript"">" &
"alert(""" & tcMessage & """);" & vbCrLf &
"</script>"
Page.ClientScript.RegisterStartupScript(GetType(String), "PopUp", lcScript)
End Sub
Private Sub Timer1_Tick(sender As Object, e As EventArgs) Handles Timer1.Tick
Response.Redirect("~/OrderStatusCustomer.aspx?tablenum=" + Request.QueryString("tablenum").ToString() + "¤ttablestatus=" + Request.QueryString("currenttablestatus").ToString())
End Sub
End Class