/*This function send the account number and amount to be paid to the Sagicor web service for it to update its system*/ protected void PayToSagicor(object sender, EventArgs e) { decimal amount = Convert.ToDecimal(Amount.Text); SqlCommand cmd = con.CreateCommand(); cmd.CommandType = CommandType.Text; cmd.CommandText = "select SagicorAccNum from LinkedSagicorAccounts where CustUserName = '******'"; SqlDataReader rdr = cmd.ExecuteReader(); rdr.Read(); string linkedAccount = rdr["SagicorAccNum"].ToString(); rdr.Close(); cmd.Dispose(); cmd = con.CreateCommand(); cmd.CommandType = CommandType.Text; cmd.CommandText = "select AccountBalance from JCBAccounts where AccountOwner = '" + CustomerID + "'"; rdr = cmd.ExecuteReader(); rdr.Read(); decimal userBalance = Convert.ToDecimal(rdr["AccountBalance"]); if (userBalance >= amount) { if (client.PaySagicor(linkedAccount, amount)) { userBalance = userBalance - amount; rdr.Close(); cmd.Dispose(); cmd = con.CreateCommand(); cmd.CommandType = CommandType.Text; cmd.CommandText = "update JCBAccounts set AccountBalance = '" + userBalance + "' where AccountOwner = '" + CustomerID + "'"; cmd.ExecuteNonQuery(); Response.Redirect("~/LinkFlowSagicor.aspx"); } else { PayStatus.Visible = true; StatusText.Text = "Payment unsuccessful"; } } else { PayStatus.Visible = true; StatusText.Text = "Your Account does not have enough funds"; } }