public void AddMethodOK() { //create the instance of the class we want to create clsPaymentCollection AllPayments = new clsPaymentCollection(); //create some test data to assign to the property clsPayment TestItem = new clsPayment(); //var to store the primary key Int32 PrimaryKey = 0; //set the properties of the test object TestItem.PaymentId = 1; TestItem.PayeeName = "Jack Daniel"; TestItem.Amount = 8888.88m; TestItem.CardNumber = "555555555555555"; TestItem.Method = "MasterCard"; TestItem.DatePurchased = DateTime.Now.Date; TestItem.Email = "*****@*****.**"; //set ThisPayment to the test data AllPayments.ThisPayment = TestItem; //add the record PrimaryKey = AllPayments.Add(); //set the primary key to the test data TestItem.PaymentId = PrimaryKey; //assign the data to the property AllPayments.ThisPayment = TestItem; //test to see that the two values are the same Assert.AreEqual(AllPayments.ThisPayment, TestItem); }
void Add() { //create an instance of the Payment Collenction clsPaymentCollection AllPayments = new clsPaymentCollection(); //validate the data on the web form string Error = AllPayments.ThisPayment.Valid(txtName.Text, Convert.ToString(DDListMethod.SelectedItem), txtOrderTotal.Text, txtCardNumber.Text, txtDatePurchased.Text, txtEmail.Text); //if the data is OK then add it to the object if (Error == "") { //get the data entered by the user AllPayments.ThisPayment.PayeeName = txtName.Text; AllPayments.ThisPayment.CardNumber = txtCardNumber.Text; AllPayments.ThisPayment.Method = Convert.ToString(DDListMethod.SelectedItem); AllPayments.ThisPayment.Amount = Convert.ToDecimal(txtOrderTotal.Text); AllPayments.ThisPayment.DatePurchased = Convert.ToDateTime(txtDatePurchased.Text); AllPayments.ThisPayment.Email = Convert.ToString(txtEmail.Text); //add the record AllPayments.Add(); } else { //report an error lblError.Text = "There were problems with the data entered : " + Error; } }
public void DeleteMethodOK() { //create the instance of the class we want to create clsPaymentCollection AllPayments = new clsPaymentCollection(); //create some test data to assign to the property clsPayment TestItem = new clsPayment(); //var to store the primary key Int32 PrimaryKey = 0; //set the properties of the test object TestItem.PaymentId = 7; TestItem.PayeeName = "Samsung OLED TV"; TestItem.Amount = 3999.99m; TestItem.CardNumber = "111111111111111"; TestItem.Method = "Debit"; TestItem.DatePurchased = DateTime.Now.Date; TestItem.Email = "*****@*****.**"; //set ThisPayment to the test data AllPayments.ThisPayment = TestItem; //add the record PrimaryKey = AllPayments.Add(); //set the primary key to the test data TestItem.PaymentId = PrimaryKey; //find the record AllPayments.ThisPayment.Find(PrimaryKey); //delete the record AllPayments.Delete(); //now find the record Boolean Found = AllPayments.ThisPayment.Find(PrimaryKey); //test to see that the two values are the same Assert.IsFalse(Found); }
void Add() { //create an instance of the Inventory Collenction clsPaymentCollection AllPayments = new clsPaymentCollection(); //validate the data on the web form string Error = AllPayments.ThisPayment.Valid(txtPayeeName.Text, Convert.ToString(comboBoxMethod.SelectedItem), txtAmount.Text, txtCardNumber.Text, txtDatePurchased.Text, txtEmail.Text); //if the data is OK then add it to the object if (Error == "") { //get the data entered by the user AllPayments.ThisPayment.PayeeName = txtPayeeName.Text; AllPayments.ThisPayment.Amount = Convert.ToDecimal(txtAmount.Text); AllPayments.ThisPayment.Method = Convert.ToString(comboBoxMethod.Text); AllPayments.ThisPayment.DatePurchased = Convert.ToDateTime(txtDatePurchased.Text); AllPayments.ThisPayment.Email = txtEmail.Text; AllPayments.ThisPayment.CardNumber = Convert.ToString(txtCardNumber.Text); //add the record AllPayments.Add(); //all done so redirect back to the main page PaymentManageForm PM = new PaymentManageForm(); this.Hide(); PM.ShowDialog(); this.Close(); } else { //report an error lblError.Text = "Following Errors : " + Error; } }
public void UpdateMethodOK() { //create the instance of the class we want to create clsPaymentCollection AllPayments = new clsPaymentCollection(); //create some test data to assign to the property clsPayment TestItem = new clsPayment(); //var to store the primary key Int32 PrimaryKey = 0; //set the properties of the test object TestItem.PaymentId = 1; TestItem.PayeeName = "Samsung OLED TV"; TestItem.Amount = 3999.99m; TestItem.CardNumber = "111111111111111"; TestItem.Method = "Debit"; TestItem.DatePurchased = DateTime.Now.Date; TestItem.Email = "*****@*****.**"; //set ThisPayment to the test data AllPayments.ThisPayment = TestItem; //add the record PrimaryKey = AllPayments.Add(); //set the primary key to the test data TestItem.PaymentId = PrimaryKey; //modify the test data TestItem.PaymentId = 1; TestItem.PayeeName = "George Milkin"; TestItem.Amount = 5555.55m; TestItem.CardNumber = "4444444444444444"; TestItem.Method = "MasterCard"; TestItem.DatePurchased = DateTime.Now.Date; TestItem.Email = "*****@*****.**"; //assign the new data to the property AllPayments.ThisPayment = TestItem; //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, TestItem); }