protected void btnEdit_Click(object sender, EventArgs e) { WcfServiceCustomerHost.Customer customer = client.GetCustomerById(lbCustomer.SelectedValue); lblFname.Text = customer.FirstName; lblLname.Text = customer.LastName; lblEmail.Text = customer.Email; lblTel.Text = customer.Tel.ToString(); btnSaveEdit.Visible = true; lblError.Text = "Editing customer " + customer.FirstName + " " + customer.LastName + ". Write the new info and remember to press SaveEdit"; }
protected void btnSearchCustomer_Click(object sender, EventArgs e) { try { WcfServiceCustomerHost.Customer customer = client.GetCustomerByLastName(tbLastName.Text); lbCustomer.SelectedValue = customer.ID.ToString(); lblError.Text = "Found Customer: " + customer.FirstName + " " + customer.LastName; } catch (Exception a) { lblError.Text = "Could not find any customer. Did you spell the last name correct? Log:" + a.Message; } }
protected void btnSaveEdit_Click(object sender, EventArgs e) { if (tbTel.Text == "") { tbTel.Text = "0"; } ; WcfServiceCustomerHost.Customer customer = new WcfServiceCustomerHost.Customer() { ID = int.Parse(lbCustomer.SelectedValue), FirstName = tbFirstName.Text, LastName = tbLastName.Text, Email = tbEmail.Text, Tel = int.Parse(tbTel.Text) }; client.UpdateCustomer(customer); lblFname.Text = "First Name"; lblLname.Text = "Last Name"; lblEmail.Text = "Email"; lblTel.Text = "Tel"; btnSaveEdit.Visible = false; LoadCustomers(); lblError.Text = "Customer with ID: " + customer.ID + " Updated"; }