예제 #1
0
        public void UpdateMethodOK()
        {
            //create an instance of the class we want to create
            clsContactUsCollection AContact = new clsContactUsCollection("Fbloggs");
            //create an instance of test data
            clsContactUs TestItem = new clsContactUs();
            //var to store primary key
            Int32 PK = 0;

            //set the properties
            TestItem.Email   = "[email protected]";
            TestItem.Name    = "Ayub Osman2";
            TestItem.Message = " I Loved the meal. Thanks !2 ";
            //set ThisCustomer to validate test data
            AContact.ThisContact = TestItem;
            //add the record
            PK = AContact.Add();
            //set primary key of test data
            TestItem.ContactId = PK;
            //modify the record
            TestItem.Email   = "[email protected]";
            TestItem.Name    = "Ayub Osman1";
            TestItem.Message = " I Loved the meal. Thanks !1 ";
            //set the record based on the new record
            AContact.ThisContact = TestItem;
            //update the record
            AContact.Update();
            //find the record
            AContact.ThisContact.Find(PK);
            //test to see that it exists
            Assert.AreEqual(AContact.ThisContact, TestItem);
        }
예제 #2
0
    void Update()
    {
        //create an instance of the booking list
        clsContactUsCollection Contacts = new clsContactUsCollection();
        //validate the data on the web form
        //string foreName, string surname, string dateOfBirth, string gender, string contactNumber, string eMail, string flatNo, string houseNo, string postCode
        String Error = Contacts.ThisContact.Valid(txtEmail.Text, txtName.Text, txtMessage.Text);

        //if the data is OK then add it to the object
        if (Error == "")
        {
            //find the record to update
            Contacts.ThisContact.Find(ContactId);
            //get the data entered by the user
            Contacts.ThisContact.Email   = Convert.ToString(txtEmail.Text);
            Contacts.ThisContact.Name    = Convert.ToString(txtName.Text);
            Contacts.ThisContact.Message = Convert.ToString(txtMessage.Text);
            //CList.ThisCustomer.UserName = User.Identity.Name;
            //update the record
            Contacts.Update();
            //all done so redirect back to the main page
            //  Response.Redirect("AdminHomepage.aspx");
            lblError.Text = "update";
        }
        else
        {
            //report an error
            lblError.Text = "There were problems with the data entered " + Error;
        }
    }