void Update()
        {
            //Create an instance of the payment book
            clsSTPaymentCollection PaymentBook = new clsSTPaymentCollection();
            //Validate the data on the web form
            string Error = PaymentBook.ThisPayment.Valid(TextBoxCardNumber.Text, TextBoxAccountNumber.Text, TextBoxSortCode.Text, TextBoxExpiryDate.Text, TextBoxValidFrom.Text, TextBoxCardHolderName.Text, TextBoxCVC.Text);

            //If the data is ok then add it to the object
            if (Error == "")
            {
                //Find the payment id record to update
                PaymentBook.ThisPayment.Find(PaymentID);
                //Get the data entered by the user
                PaymentBook.ThisPayment.CardNumber     = TextBoxCardNumber.Text;
                PaymentBook.ThisPayment.AccountNumber  = TextBoxAccountNumber.Text;
                PaymentBook.ThisPayment.SortCode       = TextBoxSortCode.Text;
                PaymentBook.ThisPayment.ExpiryDate     = TextBoxExpiryDate.Text;
                PaymentBook.ThisPayment.ValidFrom      = TextBoxValidFrom.Text;
                PaymentBook.ThisPayment.CardHolderName = TextBoxCardHolderName.Text;
                PaymentBook.ThisPayment.CVC            = TextBoxCVC.Text;
                //Update the payment record
                PaymentBook.Update();
                //All done so redirect to the home payment page
                Response.Redirect("Payment.aspx");
            }
            else
            {
                //Report an error
                LableError.Text = "There was a problem with the payment method you tried updating" + Error;
            }
        }
Esempio n. 2
0
        public void UpdatePaymentMethodOK()
        {
            //Create an instance of the class we want to create
            clsSTPaymentCollection AllPayments = new clsSTPaymentCollection();
            //Create an item of test data
            clsSTPayment PaymentTestItem = new clsSTPayment();
            //Var to store the primary key
            Int32 PrimaryKey = 0;

            //Set its properties
            PaymentTestItem.CardNumber     = "1234567891234567";
            PaymentTestItem.AccountNumber  = "12345678";
            PaymentTestItem.SortCode       = "123456";
            PaymentTestItem.ExpiryDate     = "12/22";
            PaymentTestItem.ValidFrom      = "12/19";
            PaymentTestItem.CardHolderName = "ABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLM";
            PaymentTestItem.CVC            = "123";
            //Set this ThisPayment to the test data
            AllPayments.ThisPayment = PaymentTestItem;
            //Add the payment record
            PrimaryKey = AllPayments.Add();
            //Set the primary key of the test data
            PaymentTestItem.PaymentID = PrimaryKey;
            //Modify the test data
            PaymentTestItem.CardNumber     = "1234567891234568";
            PaymentTestItem.AccountNumber  = "12345679";
            PaymentTestItem.SortCode       = "123457";
            PaymentTestItem.ExpiryDate     = "12/23";
            PaymentTestItem.ValidFrom      = "12/20";
            PaymentTestItem.CardHolderName = "I HATE PROJECT MANAGEMENT";
            PaymentTestItem.CVC            = "124";
            //Set the record based on the new test data
            AllPayments.ThisPayment = PaymentTestItem;
            //Update the record
            AllPayments.Update();
            //Find the record
            AllPayments.ThisPayment.Find(PrimaryKey);
            //test to see that the two values are the same
            Assert.AreEqual(AllPayments.ThisPayment, PaymentTestItem);
        }