Example #1
0
        //function for updating records
        void Update()
        {
            //create an instance of the customer book
            APhoneLibrary.clsCustomerCollection CustomerBook = new APhoneLibrary.clsCustomerCollection();
            //validate the data on the web form
            String Error = CustomerBook.ThisCustomer.Valid(txtFirstName.Text, txtHouseNumber.Text, txtDOB.Text, txtPhoneNo.Text, txtPostCode.Text, txtStreetName.Text, txtSurname.Text);

            //if the data is OK then add it to the object
            if (Error == "")
            {
                //find the record to update
                CustomerBook.ThisCustomer.FirstName   = txtFirstName.Text;
                CustomerBook.ThisCustomer.HouseNumber = txtHouseNumber.Text;
                CustomerBook.ThisCustomer.DOB         = Convert.ToDateTime(txtDOB.Text);
                CustomerBook.ThisCustomer.PhoneNo     = txtPhoneNo.Text;
                CustomerBook.ThisCustomer.PostCode    = txtPostCode.Text;
                CustomerBook.ThisCustomer.StreetName  = txtStreetName.Text;
                CustomerBook.ThisCustomer.Surname     = txtSurname.Text;
                //update the record
                CustomerBook.Update();
                //all done so redirect back to the main page
                Response.Redirect("Default.aspx");
            }
            else
            {
                //report an error
                lblError.Text = "There were problems with the data entered " + Error;
            }
        }
Example #2
0
 void DisplayCustomers()
 {
     //create an instance of the customer collection
     APhoneLibrary.clsCustomerCollection Customers = new APhoneLibrary.clsCustomerCollection();
     //set the data source to the list of customers in the collection
     lstCustomers.DataSource = Customers.CustomerList;
     //set the name of the primary key
     lstCustomers.DataValueField = "CustomerID";
     //set the data field to display
     lstCustomers.DataValueField = "Surname";
     //bind the data to the list
     lstCustomers.DataBind();
 }
Example #3
0
 void DisplayCustomerSurname()
 {
     //create an instance of the County Collection
     APhoneLibrary.clsCustomerCollection CustomerSurnameName = new APhoneLibrary.clsCustomerCollection();
     //set the data source to the list of Customer in the collection
     ddlSurname.DataSource = CustomerSurnameName.CustomerList;
     //set the name of the primary key
     ddlSurname.DataValueField = "CustomerID";
     //set the data field to display
     ddlSurname.DataTextField = "Surname";
     //bind the data to the list
     ddlSurname.DataBind();
 }