Example #1
0
 /**
  * method btnDoCreate_Click
  * inserts a new Customer with
  * the supplied parameters.
  * Little to no validation is being done.
  * NOTE: a new Customer always get a new Contact
  * timestamped with NOW
  * and a note saying "Created"
  */
 protected void btnDoCreate_Click(object sender, EventArgs e)
 {
     Customer cu = new Customer();
     int res = cu.insertCustomer(txtCreateFirstName.Text, txtCreateLastName.Text, txtCreatePhoneNumber.Text, txtCreateEmail.Text);
     if (res == 0)
     {
         //error
         lblError.Text = cu.errorMessage;
         lblError.Visible = true;
     }
     else
     {
         CustomerCollection cc = new CustomerCollection();
         if (!cc.getAllCustomers())
         {
             //error
             lblError.Text = cc.errorMessage;
             lblError.Visible = true;
         }
         else
         {
             //clear fields after success
             txtCreateFirstName.Text = "";
             txtCreateLastName.Text = "";
             txtCreatePhoneNumber.Text = "";
             txtCreateEmail.Text = "";
             txtSearchFirstName.Text = "";
             txtSearchLastName.Text = "";
             txtSearchPhoneNumber.Text = "";
             txtSearchEmail.Text = "";
             refreshCustomerList(cc);
         }
     }
 }
Example #2
0
 /**
  * method Page_Load
  * get all Customers and
  * fill the repeater
  */
 protected void Page_Load(object sender, EventArgs e)
 {
     CustomerCollection cc = new CustomerCollection();
     if (!cc.getAllCustomers())
     {
         //error
         lblError.Text = cc.errorMessage;
         lblError.Visible = true;
     }
     else
     {
         refreshCustomerList(cc);
     }
 }