//function for adding new records
    void Add()
    {
        //create an instance of the customer book
        CarClasses.clsCustomerCollection CustomerBook = new CarClasses.clsCustomerCollection();
        //validate the data on the web form
        String Error = CustomerBook.ThisCustomer.Valid(txtbxFirstName.Text, txtbxLastName.Text, txtbxEmail.Text, txtbxTeleNo.Text, txtbxAddress1.Text, txtbxAddress2.Text, txtbxPostcode.Text, txtbxPassword.Text);

        //if the data is Ok then add it to the object
        if (Error == "")
        {
            //get the data entered by the user
            CustomerBook.ThisCustomer.CustomerFirstName = txtbxFirstName.Text;
            CustomerBook.ThisCustomer.CustomerLastName  = txtbxLastName.Text;
            CustomerBook.ThisCustomer.Email             = txtbxEmail.Text;
            CustomerBook.ThisCustomer.TelephoneNo       = txtbxTeleNo.Text;
            CustomerBook.ThisCustomer.Address1          = txtbxAddress1.Text;
            CustomerBook.ThisCustomer.Address2          = txtbxAddress2.Text;
            CustomerBook.ThisCustomer.PostCode          = txtbxPostcode.Text;
            CustomerBook.ThisCustomer.CustomerPassword  = txtbxPassword.Text;
            //add the record
            CustomerBook.Add();
            //all done so redirect to the main page
            Response.Redirect("MemberHome.aspx");
        }
        else
        {
            //report an error
            lblError.Text = "There were problems with the data entered " + Error;
        }
    }
 void DisplayCustomers()
 {
     //create an instance of the customer collection
     CarClasses.clsCustomerCollection Customers = new CarClasses.clsCustomerCollection();
     //set the data source to the list of customers in the collection
     lstCustomers.DataSource = Customers.CustomerList;
     //set the data feild to display
     lstCustomers.DataValueField = "CustomerID";
     //SET THE DATA fiedl to display
     lstCustomers.DataTextField = "CustomerName";
     //bind the data to the list
     lstCustomers.DataBind();
 }
示例#3
0
 void DisplayCustomers()
 {
     //create an instance of the customer collection
     CarClasses.clsCustomerCollection Customers = new CarClasses.clsCustomerCollection();
     //set the data source to the list of customers in the collection
     lstbxCustomers.DataSource = Customers.CustomerList;
     //set the name of the primary key
     lstbxCustomers.DataValueField = "CustomerID";
     //set the data field to display
     lstbxCustomers.DataTextField = "CustomerLastName";
     //bind the data to the list
     lstbxCustomers.DataBind();
 }