- basicsample.zip
- BasicSample
- BasicSample.Core
- BasicSample.Data
- BasicSample.resharper
- BasicSample.resharper.user
- BasicSample.sln
- BasicSample.Tests
- BasicSample.Web
- Solution Items
- enterprisesample.zip
- EnterpriseSample
- EnterpriseSample.Core
- EnterpriseSample.Data
- EnterpriseSample.Presenters
- EnterpriseSample.resharper
- EnterpriseSample.resharper.user
- EnterpriseSample.sln
- EnterpriseSample.Tests
- EnterpriseSample.Web
- ProjectBase.Data
- ProjectBase.Utils
- Solution Items
- nhibernatebestpractices_src.zip
- NHibernateSample
- NHibernateSample.Core
- NHibernateSample.Data
- NHibernateSample.sln
- NHibernateSample.Tests
- NHibernateSample.Web
- Solution Items
- Iesi.Collections.dll
- log4net.dll
- NHibernate.dll
- NHibernate.Generics.dll
- nunit.framework.dll
|
using System;
using EnterpriseSample.Core.Domain;
using EnterpriseSample.Presenters;
using EnterpriseSample.Presenters.ViewInterfaces;
using EnterpriseSample.Web;
using ProjectBase.Utils;
public partial class Views_EditCustomerView : BaseUserControl, IEditCustomerView
{
public EventHandler UpdateCompleted;
public EventHandler UpdateCancelled;
public void AttachPresenter(EditCustomerPresenter presenter) {
this.presenter = presenter;
}
public Customer Customer {
set {
Check.Require(value != null, "Customer may not be null");
ShowCustomerDetails(value);
}
}
private void ShowCustomerDetails(Customer customer) {
// Instead of using a hidden input, you could also use ViewState...but it's often best
// to disable ViewState for your entire website
hidCustomerID.Value = customer.ID;
lblCustomerID.Text = customer.ID;
txtCompanyName.Text = customer.CompanyName;
txtContactName.Text = customer.ContactName;
}
/// <summary>
/// Required by <see cref="IEditCustomerView" /> so that the presenter
/// can have the view set the values of the customer.
/// </summary>
public void UpdateValuesOn(Customer customer) {
// Changes to the customer object will be automatically committed at the end of the HTTP request
customer.CompanyName = txtCompanyName.Text;
customer.ContactName = txtContactName.Text;
}
protected void btnUpdate_OnClick(object sender, EventArgs e) {
presenter.Update(hidCustomerID.Value);
// The view itself shouldn't be handling any redirects, so simply raise an event letting
// whomever know that the action has completed
if (UpdateCompleted != null) {
UpdateCompleted(this, EventArgs.Empty);
}
}
protected void btnCancel_OnClick(object sender, EventArgs e) {
if (UpdateCancelled != null) {
UpdateCancelled(this, EventArgs.Empty);
}
}
private EditCustomerPresenter presenter;
}
|
By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.
If a file you wish to view isn't highlighted, and is a text file (not binary), please
let us know and we'll add colourisation support for it.
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.