//Add New Card into DB protected void btnSubmit_Click(object sender, EventArgs e) { //data fields string name = txtNameOnCard.Text; float cardNumber; int CSV; int expMonth; int expYear; //conditions bool validCardNumber = float.TryParse(txtCardNumber.Text,out cardNumber); bool validCSV = int.TryParse(txtCSV.Text, out CSV); bool validExpMonth = int.TryParse(ddlExpMonth.SelectedValue, out expMonth); bool validExpYear = int.TryParse(ddlExpYear.SelectedValue, out expYear); if (validCardNumber && validExpMonth && validExpYear && validCSV) { cardNumber = float.Parse(txtCardNumber.Text); expMonth = Int32.Parse(ddlExpMonth.SelectedValue); expYear = Int32.Parse(ddlExpYear.SelectedValue); CSV = Int32.Parse(txtCSV.Text); CreditCardWSRef.CreditCardWS pxy = new CreditCardWSRef.CreditCardWS(); pxy.AddCreditCardAccount(name, cardNumber, expMonth, expYear, CSV); } }
public void showAccounts() { CreditCardWSRef.CreditCardWS pxy = new CreditCardWSRef.CreditCardWS(); DataSet ds = pxy.GetAccounts(); gvAccounts.DataSource = ds; gvAccounts.DataBind(); }
protected void lnkbtnViewAllTransactions_Click(object sender, EventArgs e) { //load a gridview of transactions CreditCardWSRef.CreditCardWS pxy = new CreditCardWSRef.CreditCardWS(); DataSet ds = pxy.getAllTransactions(); gvTransactions.DataSource = ds; gvTransactions.DataBind(); }
protected void btnSubmit_Click(object sender, EventArgs e) { //data fields string name = txtNameOnCard.Text; float cardNumber; int CSV; int expMonth; int expYear; double transactionAmt; DateTime dateTime = DateTime.Now; //conditions bool validCardNumber = float.TryParse(txtCardNumber.Text,out cardNumber); bool validCSV = int.TryParse(txtCSV.Text, out CSV); bool validExpMonth = int.TryParse(ddlExpMonth.SelectedValue, out expMonth); bool validExpYear = int.TryParse(ddlExpYear.SelectedValue, out expYear); bool validTransactionAmt = double.TryParse(txtAmount.Text, out transactionAmt); if (validCardNumber && validExpMonth && validExpYear && validCSV && validTransactionAmt) { cardNumber = float.Parse(txtCardNumber.Text); expMonth = Int32.Parse(ddlExpMonth.SelectedValue); expYear = Int32.Parse(ddlExpYear.SelectedValue); CSV = Int32.Parse(txtCSV.Text); // Application.Lock(); //pass amount //return value to determine if it was successful CreditCardWSRef.CreditCardWS pxy = new CreditCardWSRef.CreditCardWS(); int Result = pxy.Transaction(name, cardNumber, expMonth, expYear, CSV, transactionAmt); if (Result < 1) { lblTransactionError.Text = "Your transaction was successful"; } else { lblTransactionError.Text = "Your transaction failed"; } // Application.UnLock(); } }
protected void gvAccounts_RowUpdating(object sender, GridViewUpdateEventArgs e) { int rowIndex = e.RowIndex; //get accountID value from textbox field int accountID = int.Parse(gvAccounts.Rows[rowIndex].Cells[1].Text); CreditCardWSRef.CreditCardWS pxy = new CreditCardWSRef.CreditCardWS(); //string accountNumber = gvAccounts.Rows[rowIndex].Cells[1].Text; // Retrieve a reference to the TextBox in the row for the Name TextBox TBoxName; TBoxName = (TextBox)gvAccounts.Rows[rowIndex].Cells[2].Controls[0]; string name = TBoxName.Text; pxy.updateName(name, accountID); // Retrieve a reference to the TextBox in the row for the CardNumber TextBox TBoxCardNum; TBoxCardNum = (TextBox)gvAccounts.Rows[rowIndex].Cells[3].Controls[0]; float cardnum = float.Parse(TBoxCardNum.Text); pxy.updateCardNumber(cardnum, accountID); // Retrieve a reference to the TextBox in the row for the expMonth TextBox TBoxmonth; TBoxmonth = (TextBox)gvAccounts.Rows[rowIndex].Cells[4].Controls[0]; int expMonth = int.Parse(TBoxmonth.Text); pxy.UpdateExpMonth(expMonth, accountID); // Retrieve a reference to the TextBox in the row for the expYear TextBox TBoxYear; TBoxYear = (TextBox)gvAccounts.Rows[rowIndex].Cells[5].Controls[0]; int expYear = int.Parse(TBoxYear.Text); pxy.UpdateExpYear(expYear, accountID); // Retrieve a reference to the TextBox in the row for the CSV TextBox TBoxCSV; TBoxCSV = (TextBox)gvAccounts.Rows[rowIndex].Cells[6].Controls[0]; int csv = int.Parse(TBoxCSV.Text); pxy.UpdateCSV(csv, accountID); gvAccounts.EditIndex = -1; showAccounts(); }