protected void Page_Load(object sender, EventArgs e) { String Paypal = "Paypal"; decimal amountpaypal = (decimal)(Session["amount"]); decimal totalamount = Convert.ToDecimal(amountpaypal); Model.Entities.Request request = (Model.Entities.Request)Session["request"]; SqlConnection conTaxi; string connStr = ConfigurationManager.ConnectionStrings["printDBServer"].ConnectionString; conTaxi = new SqlConnection(connStr); conTaxi.Open(); string strInsert; SqlCommand cmdInsert; strInsert = "Insert Into Payment (PaymentType, PaymentAmount, PaymentDateTime) Values (@PaymentType, @PaymentAmount, @PaymentDateTime);SELECT MAX(PaymentID) from Payment where PaymentAmount=@PaymentAmount"; cmdInsert = new SqlCommand(strInsert, conTaxi); cmdInsert.Parameters.AddWithValue("@PaymentType", Paypal); cmdInsert.Parameters.AddWithValue("@PaymentAmount", totalamount); cmdInsert.Parameters.AddWithValue("@PaymentDateTime", DateTime.Now); var getPaymentID = cmdInsert.ExecuteScalar(); if (getPaymentID != null) { Response.Write("<script>alert('PayPal Successful');</script>"); } else { Response.Write("<script>alert('Upload Failed');</script>"); } PrintingRequestHub.refreshTable(); }
protected void btnSubmit_Click(object sender, EventArgs e) { if (txtCardName.Text == "" || txtCardNumber.Text == "" || txtCCV.Text == "" || txtExpiryYear.Text == "" || txtExpitymonth.Text == "") { Response.Write("<script>alert('Please fill in credit card detail!');</script>"); } else { DateTime currentDate = DateTime.Now; Decimal totalPayment = Convert.ToDecimal(txtpaymentTotal.Text); string type = "Credir Card"; Model.Entities.Payment newpayment = new Model.Entities.Payment(type, totalPayment, currentDate); Model.Entities.Request request = (Model.Entities.Request)Session["request"]; //request.RequestLists[0].RequestItemID[0] request.Payment = newpayment; SqlConnection conTaxi; string connStr = ConfigurationManager.ConnectionStrings["printDBServer"].ConnectionString; conTaxi = new SqlConnection(connStr); conTaxi.Open(); string strInsert; SqlCommand cmdInsert; strInsert = "Insert Into Payment (PaymentType, PaymentAmount, PaymentDateTime) Values (@PaymentType, @PaymentAmount, @PaymentDateTime);SELECT MAX(PaymentID) from Payment where PaymentAmount=@PaymentAmount"; cmdInsert = new SqlCommand(strInsert, conTaxi); Decimal totalamount = Convert.ToDecimal(txtpaymentTotal.Text); cmdInsert.Parameters.AddWithValue("@PaymentType", request.Payment.PaymentType); cmdInsert.Parameters.AddWithValue("@PaymentAmount", request.Payment.PaymentAmount); cmdInsert.Parameters.AddWithValue("@PaymentDateTime", request.Payment.PaymentDateTime); var getPaymentID = cmdInsert.ExecuteScalar(); if (getPaymentID != null) { request.Payment.PaymentID = (string)getPaymentID; insertNewRequest(request); generateQRcode(request); Response.Write("<script>alert('Successful payment');</script>"); } else { Response.Write("<script>alert('Upload Failed');</script>"); } /*Close database connection*/ conTaxi.Close(); Response.Write("<script>alert('Successful payment');</script>"); PrintingRequestHub.refreshTable(); Response.Redirect("~/masterPageTest.aspx"); } }