/// <summary> /// Handles the ItemDeleting event of dtlvCustomer. /// </summary> /// <param name="sender">The sender.</param> /// <param name="e">The DetailsViewDeleteEventArgs.</param> protected void dtlvCustomer_ItemDeleting(object sender, DetailsViewDeleteEventArgs e) { try { using (Bll::ICustomer blCustomer = new Bll::Customer()) { if (Request.QueryString["CustomerId"] != null) { blCustomer.Delete(Request.QueryString["CustomerId"]); } Response.Redirect("~/Customer.aspx"); // Go and show all data. } } catch (SqlException ex) { Response.Write(ex.ToString()); } catch (ObjectDisposedException ex) { Response.Write(ex.ToString()); } catch (Exception ex) { Response.Write(ex.ToString()); } }
/// <summary> /// Handles the ItemInserting event of dtlvCustomer. /// </summary> /// <param name="sender">The sender.</param> /// <param name="e">The DetailsViewInsertEventArgs.</param> protected void dtlvCustomer_ItemInserting(object sender, DetailsViewInsertEventArgs e) { if (this.IsValid) { try { Poco::ICustomer newCustomer = this.GetCustomerObject(); using (Bll::ICustomer blCustomer = new Bll::Customer()) { blCustomer.Create(newCustomer); } Response.Redirect("~/Customer.aspx"); // Go and show all data. } catch (SqlException ex) { Response.Write(ex.ToString()); } catch (ObjectDisposedException ex) { Response.Write(ex.ToString()); } catch (Exception ex) { Response.Write(ex.ToString()); } } }
/// <summary> /// Handles the ItemUpdating event of dtlvCustomer. /// </summary> /// <param name="sender">The sender.</param> /// <param name="e">The DetailsViewUpdateEventArgs.</param> protected void dtlvCustomer_ItemUpdating(object sender, DetailsViewUpdateEventArgs e) { if (this.IsValid) { try { Poco::ICustomer existingCustomer = this.GetCustomerObject(); using (Bll::ICustomer blCustomer = new Bll::Customer()) { blCustomer.Update(existingCustomer); } // Back to read only view. dtlvCustomer.ChangeMode(DetailsViewMode.ReadOnly); IList<Northwind.Poco.ICustomer> customers = this.GetCustomers(); this.BindDetailsView(customers); } catch (SqlException ex) { Response.Write(ex.ToString()); } catch (ObjectDisposedException ex) { Response.Write(ex.ToString()); } catch (Exception ex) { Response.Write(ex.ToString()); } } }