⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 purchase.aspx

📁 online book store working project
💻 ASPX
📖 第 1 页 / 共 2 页
字号:
<%@ Page Language="VB" MasterPageFile="~/user.master" Title="Book Store" %>
<%@ Import Namespace="System.data.SqlClient" %>
<%@ Import Namespace="System.data" %>
<script runat="server">
    Dim sqlconn As New SqlConnection
    Dim cmd As New SqlCommand
    Dim cmd1 As New SqlCommand
    Dim cmd2 As New SqlCommand
    Dim sql As New SqlDataAdapter
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs)
        pro_quantity.Text = Session("items")
        total_price.Text = Session("totalprice")
        
        
        sqlconn = New SqlConnection("Data Source=.; database =BookStore;Integrated Security=True")
        sqlconn.Open()
        Dim strg As String
        Dim autogen As Long
        strg = "(select FirstName, LastName, CustomerAdd,CustomerPh,CustomerId from tbCustomer_Detail where CustomerId = '" & Session("username") & "')"
        cmd = New SqlCommand(strg, sqlconn)
        Dim dr As SqlDataReader
        dr = cmd.ExecuteReader
        If dr.HasRows Then
            While dr.Read()
                clintfull_name.Text = dr("FirstName") + dr("LastName")
                probilling_address.Text = dr("CustomerAdd")
                billing_phno.Text = dr("CustomerPh")
                clint_idtxt.Text = dr("CustomerId")
                
             
            End While
        End If
        dr.Close()
        
        
        
        sqlconn = New SqlConnection("Data Source=.; database =BookStore;Integrated Security=True")
        sqlconn.Open()
        Dim strg2 As String
        strg2 = "select max(OrderId) from tbOrder"
        cmd2 = New SqlCommand(strg2, sqlconn)
        autogen = cmd2.ExecuteScalar
        autogen = autogen + 1
        trans_number.Text = autogen
        
       
        
        Dim tdate As DateTime
        tdate = System.DateTime.Today
        billing_date.Text = tdate
        
        Dim billtime As String
        billtime = System.DateTime.Now.TimeOfDay.ToString
        bill_time.Text = billtime
    End Sub
    
    Function CheckCC(ByVal CCNo)
        
        Dim i, w, x, y
        y = 0 'Ensure the proper format of the input
        CCNo = Replace(Replace(Replace(CStr(CCNo), "-", ""), " ", ""), ".", "") 'Process digits from right to left, drop last digit if total length is even
        w = 2 * (Len(CCNo) Mod 2)
        For i = Len(CCNo) - 1 To 1 Step -1
            x = Mid(CCNo, i, 1)
            If IsNumeric(x) Then
                Select Case (i Mod 2) + w
                    Case 0, 3 'Even Digit - Odd where total length is odd (eg. Visa vs. Amx)
                        y = y + CInt(x)
                    Case 1, 2 'Odd Digit - Even where total length is odd (eg. Visa vs. Amx)
                        x = CInt(x) * 2
                        If x > 9 Then 'Break the digits (eg. 19 becomes 1 + 9)
                            y = y + (x \ 10) + (x - 10)
                        Else : y = y + x
                        End If
                End Select
            End If
        Next 'Return the 10's complement of the total    
        y = 10 - (y Mod 10)
        If y > 9 Then y = 0
        CheckCC = (CStr(y) = Right(CCNo, 1))
    End Function
    
    
    Protected Sub billing_country_SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs)
        If billing_country.AutoPostBack = True Then
            
            If sender.Items(sender.SelectedIndex).Text = "India" Then
                billing_state.Items.Clear()
                billing_state.Items.Add("Delhi")
                billing_state.Items.Add("Andhra Pradesh")
                billing_state.Items.Add("Haryana ")
                billing_state.Items.Add("Jharkhand ")
                billing_state.Items.Add("West Bengal")
                billing_state.Items.Add("Andhra Pradesh")
                billing_state.Items.Add("Jammu and Kashmir")
                billing_state.Items.Add("Gujarat")
                billing_state.Items.Add("Chandigarh")
                billing_state.Items.Add("Uttar Pradesh")
                billing_state.Items.Add("Maharashtra")
                billing_state.Items.Add("Punjab")
                billing_state.Items.Add("Goa")
                Exit Sub
            End If
       
            If sender.Items(sender.SelectedIndex).Text = "Australia" Then
                billing_state.Items.Clear()
                billing_state.Items.Add("Australian Capital Territory")
                billing_state.Items.Add("Queensland")
                billing_state.Items.Add("New South Wales")
                billing_state.Items.Add("South Australia")
                billing_state.Items.Add("Tasmania")
                billing_state.Items.Add("Victoria")
                billing_state.Items.Add("Western Australia")
                Exit Sub
            End If
            If sender.Items(sender.SelectedIndex).Text = "Canada" Then
                billing_state.Items.Clear()
                billing_state.Items.Add("British Columbia")
                billing_state.Items.Add("Quebec")
                billing_state.Items.Add("Ontario")
                Exit Sub
            End If
            If sender.Items(sender.SelectedIndex).Text = "Japan" Then
                billing_state.Items.Clear()
                billing_state.Items.Add("Ludhiana")
                billing_state.Items.Add("Jalandhar")
                Exit Sub
            End If
            If sender.Items(sender.SelectedIndex).Text = "Malaysia" Then
                billing_state.Items.Clear()
                billing_state.Items.Add("Johore")
                billing_state.Items.Add("Kedah")
                billing_state.Items.Add("Kelantan ")
                billing_state.Items.Add("Kuala Lumpur ")
                billing_state.Items.Add("Lubuan")
                billing_state.Items.Add("Malacca")
                billing_state.Items.Add("Negri Sembilan")
                billing_state.Items.Add("Pahang")
                billing_state.Items.Add("Penang")
                billing_state.Items.Add("Perak")
                billing_state.Items.Add("Perlis")
                billing_state.Items.Add("Sabah")
                billing_state.Items.Add("Sarawak")
                billing_state.Items.Add("Selangor")
                billing_state.Items.Add("Trengganu")
                Exit Sub
            End If
            If sender.Items(sender.SelectedIndex).Text = "UK" Then
                billing_state.Items.Clear()
                billing_state.Items.Add("ALASKA")
                billing_state.Items.Add("HAWAII")
                billing_state.Items.Add("IDAHO")
                billing_state.Items.Add("INDIANA")
                billing_state.Items.Add("IOWA")
                billing_state.Items.Add("LOUISIANA")
                billing_state.Items.Add("MAINE")
                billing_state.Items.Add("MARYLAND")
                billing_state.Items.Add("NEW MEXICO")
                billing_state.Items.Add("NEW YORK")
                billing_state.Items.Add("NORTH DAKOTA")
                billing_state.Items.Add("OREGON")
                billing_state.Items.Add("TEXAS")
               
                Exit Sub
            End If
                 
        End If
    End Sub

    Protected Sub submit_Click(ByVal sender As Object, ByVal e As System.EventArgs)
        sqlconn = New SqlConnection("Data Source=.; database =BookStore;Integrated Security=True")
        
        sqlconn.Open()
        Dim chkclintemail As IDbCommand
        Dim chk As Integer
        
        Dim strSQL2 As String
        'Dim strUserCount As Integer
        Dim strCount1 As Integer
	
        strSQL2 = "SELECT COUNT(*) FROM [tbCustomer_Detail] WHERE CustomerId like '" & Trim(clint_idtxt.Text.ToString) & "' and CustomerEmail like '" & Trim(email_add.Text.ToString) & "'"
       
        chkclintemail = New SqlCommand(strSQL2, sqlconn)
        strCount1 = chkclintemail.ExecuteScalar()
        
        chk = CheckCC(Val(card_number.Text))
        
        
        If billing_city.Text = "" Then
            MsgBox("Please fill your city for transportation", MsgBoxStyle.Information, "Enter City NAme")
        ElseIf billing_post.Text = "" Then
            MsgBox("Enter Postal Code", MsgBoxStyle.Information, "Enter Postal Code")
        ElseIf billing_country.SelectedIndex = "0" Then
            MsgBox("Select Your Country For Transportation", MsgBoxStyle.Information, "Select Country")
       
        ElseIf select_creditcard.SelectedIndex = "0" Then
            MsgBox("Please Fill Your Credit Card Type For Transaction", MsgBoxStyle.Information, "Select Type")
        ElseIf Val(card_number.Text) = 0 Then
            MsgBox("Please Enter Your Valid Card Number", MsgBoxStyle.Information, "Enter Card Number")
        ElseIf card_month.SelectedIndex = "0" Then
            MsgBox("Select Month", MsgBoxStyle.Information, "Select Month")
        ElseIf delivery.SelectedIndex = "0" Then
            MsgBox("Please select delivery option for delivery", MsgBoxStyle.Information, "Delivery By")
        ElseIf card_year.SelectedIndex = "0" Then
            MsgBox("Select Year", MsgBoxStyle.Information, "Select Year")
                  
        ElseIf bank_name.Text = "" Then
            MsgBox("Please Enter Related Bank Name", MsgBoxStyle.Information, "Enter bank Name")
        ElseIf email_add.Text = "" Then
            MsgBox("Please Enter Registered Email Address", MsgBoxStyle.Information, "Enter EMail Address")
        ElseIf click_sign.Checked = False Then
            MsgBox("Check The Sign Box", MsgBoxStyle.Information, "Check It")
           
        ElseIf strCount1 = 0 Then
            MsgBox("EMail Address Not exists. Please Enter Registered EMail Address", MsgBoxStyle.Critical, "EMail Address Not Exixts")
 
        ElseIf card_year.SelectedItem.Text < System.DateTime.Now.Year Then
           
            MsgBox("Your Card Has Expired Please Renew", MsgBoxStyle.Critical, "Expired")
            Response.Redirect("clintlogin.aspx")
            
        ElseIf card_year.SelectedItem.Text = System.DateTime.Now.Year And card_month.SelectedIndex < System.DateTime.Now.Month Then
            MsgBox("Your Card Has Expired Please Renew", MsgBoxStyle.Critical, "Expired")
            Response.Redirect("clintlogin.aspx")
     
        ElseIf chk = 0 Then
                
            MsgBox("Your Credit Card Number Is Not Valid", MsgBoxStyle.Critical, "Enter Correct Card Number")
            
            Exit Sub
            '  MsgBox("xx=" + xx.ToString + " chk= " + chk.ToString)
            
        Else
            Dim ds As New DataSet
      
            Dim demp As DataTable
            Dim dr As DataRow
        
            Dim sql As New SqlDataAdapter
            sql.SelectCommand = New SqlCommand
            sql.SelectCommand.Connection = sqlconn
            sql.SelectCommand.CommandText = "select * from tbOrder"
            sql.Fill(ds, "tbOrder")
            demp = ds.Tables("tbOrder")
            dr = ds.Tables("tbOrder").NewRow
         
            dr.Item(0) = pro_quantity.Text
            dr.Item(1) = total_price.Text
            dr.Item(2) = clintfull_name.Text
            dr.Item(3) = probilling_address.Text
            dr.Item(4) = billing_country.Text
            dr.Item(5) = billing_state.Text
            dr.Item(6) = billing_city.Text
            dr.Item(7) = billing_post.Text
            dr.Item(8) = billing_phno.Text
            dr.Item(9) = billing_date.Text
            dr.Item(10) = bill_time.Text
            dr.Item(11) = clint_idtxt.Text
          
            ds.Tables("tbOrder").Rows.Add(dr)
            sql.InsertCommand = New SqlCommand
            sql.InsertCommand.Connection = sqlconn
            sql.InsertCommand.CommandText = "insert into tbOrder(ProductQa,ProductPrice,CustomerName,CustomerAdd,Country,State,City,Pincode,CustomerPh,OrderDate,OrderTime,CustomerId) values('" & pro_quantity.Text & " ','" & total_price.Text & "','" & clintfull_name.Text & "','" & probilling_address.Text & "','" & billing_country.Text & "','" & billing_state.Text & "','" & billing_city.Text & "','" & billing_post.Text & "','" & billing_phno.Text & "', '" & billing_date.Text & "' ,'" & bill_time.Text & "', '" & clint_idtxt.Text & "')"
        
            sql.Update(dr.Table)
            MsgBox("Your transaction is successfully completed", MsgBoxStyle.Information, "Transaction Completed")
            MsgBox("Please collect your bill receipt", MsgBoxStyle.Information, "Collect Your Bill")
            MsgBox("Your Delivery proccesed within 24 hours,and reach to you within 3-20 days", MsgBoxStyle.Information, "Thank You")
            Dim cmd3 As New SqlCommand("Update tbaddcart set Status = 'Purchased' where CustomerId='" & clint_idtxt.Text & "' ", sqlconn)
            cmd3.ExecuteNonQuery()
            
            'Session("Rpt_clintid") = clint_idtxt.Text
           
           
            Response.Redirect("Purchase_Rpt.aspx")
            'Else
            '    MsgBox("wrong card no")
           
            email_add.Text = ""
          
            trans_number.Text = ""
            total_price.Text = ""
            'clintfull_name.Text = ""
            'probilling_address.Text = ""

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -