Visual updates to Northwind demo, some refactoring
This commit is contained in:
@@ -64,7 +64,7 @@ namespace Spring.Northwind.Dao.NHibernate
|
||||
}
|
||||
|
||||
[Transaction(ReadOnly = false)]
|
||||
public void SaveOrUpdate(Customer customer)
|
||||
public void Update(Customer customer)
|
||||
{
|
||||
Session.SaveOrUpdate(customer);
|
||||
}
|
||||
|
||||
@@ -26,34 +26,41 @@ using Spring.Data.NHibernate.Generic;
|
||||
using Spring.Data.NHibernate.Support;
|
||||
|
||||
using Spring.Northwind.Domain;
|
||||
using Spring.Stereotype;
|
||||
using Spring.Transaction.Interceptor;
|
||||
|
||||
#endregion
|
||||
|
||||
namespace Spring.Northwind.Dao.NHibernate
|
||||
{
|
||||
[Repository]
|
||||
public class HibernateOrderDao : HibernateDao, IOrderDao
|
||||
{
|
||||
[Transaction(ReadOnly = true)]
|
||||
public Order Get(int orderId)
|
||||
{
|
||||
return Session.Get<Order>(orderId);
|
||||
|
||||
}
|
||||
|
||||
[Transaction(ReadOnly = true)]
|
||||
public IList<Order> GetAll()
|
||||
{
|
||||
return GetAll<Order>();
|
||||
}
|
||||
|
||||
[Transaction]
|
||||
public int Save(Order order)
|
||||
{
|
||||
return (int) Session.Save(order);
|
||||
}
|
||||
|
||||
public void SaveOrUpdate(Order order)
|
||||
[Transaction]
|
||||
public void Update(Order order)
|
||||
{
|
||||
Session.SaveOrUpdate(order);
|
||||
}
|
||||
|
||||
[Transaction]
|
||||
public void Delete(Order order)
|
||||
{
|
||||
Session.Delete(order);
|
||||
|
||||
@@ -25,34 +25,41 @@ using System.Collections.Generic;
|
||||
using Spring.Data.NHibernate.Support;
|
||||
|
||||
using Spring.Northwind.Domain;
|
||||
using Spring.Stereotype;
|
||||
using Spring.Transaction.Interceptor;
|
||||
|
||||
#endregion
|
||||
|
||||
namespace Spring.Northwind.Dao.NHibernate
|
||||
{
|
||||
[Repository]
|
||||
public class HibernateProductDao : HibernateDao, IProductDao
|
||||
{
|
||||
[Transaction(ReadOnly = true)]
|
||||
public Product Get(int productId)
|
||||
{
|
||||
return Session.Get<Product>(productId);
|
||||
|
||||
}
|
||||
|
||||
[Transaction(ReadOnly = true)]
|
||||
public IList<Product> GetAll()
|
||||
{
|
||||
return GetAll<Product>();
|
||||
}
|
||||
|
||||
[Transaction]
|
||||
public int Save(Product product)
|
||||
{
|
||||
return (int) Session.Save(product);
|
||||
}
|
||||
|
||||
public void SaveOrUpdate(Product product)
|
||||
[Transaction]
|
||||
public void Update(Product product)
|
||||
{
|
||||
Session.SaveOrUpdate(product);
|
||||
}
|
||||
|
||||
[Transaction]
|
||||
public void Delete(Product product)
|
||||
{
|
||||
Session.Delete(product);
|
||||
|
||||
@@ -36,6 +36,10 @@
|
||||
<SpecificVersion>False</SpecificVersion>
|
||||
<HintPath>..\..\..\..\..\bin\net\2.0\debug\Common.Logging.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="FluentNHibernate, Version=0.1.0.535, Culture=neutral, PublicKeyToken=8aa435e3cb308880, processorArchitecture=MSIL">
|
||||
<SpecificVersion>False</SpecificVersion>
|
||||
<HintPath>..\..\lib\net\2.0\FluentNHibernate.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="Iesi.Collections, Version=1.0.0.3, Culture=neutral, PublicKeyToken=aa95f207798dfdb4, processorArchitecture=MSIL">
|
||||
<SpecificVersion>False</SpecificVersion>
|
||||
<HintPath>..\..\..\..\..\lib\NHibernate21\net\2.0\Iesi.Collections.dll</HintPath>
|
||||
@@ -61,6 +65,7 @@
|
||||
<HintPath>..\..\..\..\..\bin\net\2.0\debug\Spring.Data.NHibernate21.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="System" />
|
||||
<Reference Include="System.Core, Version=3.5.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089, processorArchitecture=MSIL" />
|
||||
<Reference Include="System.Data" />
|
||||
<Reference Include="System.Xml" />
|
||||
</ItemGroup>
|
||||
|
||||
@@ -28,6 +28,9 @@ using Spring.Northwind.Domain;
|
||||
|
||||
namespace Spring.Northwind.Dao
|
||||
{
|
||||
/// <summary>
|
||||
/// Customer related DAO operations interface.
|
||||
/// </summary>
|
||||
public interface ICustomerDao : IDao<Customer, string>, ISupportsDeleteDao<Customer>, ISupportsSave<Customer, string>
|
||||
{
|
||||
}
|
||||
|
||||
@@ -2,6 +2,11 @@ using System.Collections.Generic;
|
||||
|
||||
namespace Spring.Northwind.Dao
|
||||
{
|
||||
/// <summary>
|
||||
/// Generic DAO interface with minimum retrieval methods.
|
||||
/// </summary>
|
||||
/// <typeparam name="TEntity">Entity to operate with.</typeparam>
|
||||
/// <typeparam name="TId">Entity id type.</typeparam>
|
||||
public interface IDao<TEntity, TId>
|
||||
{
|
||||
/// <summary>
|
||||
|
||||
@@ -28,10 +28,10 @@ using Spring.Northwind.Domain;
|
||||
|
||||
namespace Spring.Northwind.Dao
|
||||
{
|
||||
public interface IOrderDao : IDao<Order, int>, ISupportsDeleteDao<Order>
|
||||
/// <summary>
|
||||
/// Order related DAO operations interface.
|
||||
/// </summary>
|
||||
public interface IOrderDao : IDao<Order, int>, ISupportsDeleteDao<Order>, ISupportsSave<Order, int>
|
||||
{
|
||||
int Save(Order order);
|
||||
|
||||
void SaveOrUpdate(Order order);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -28,6 +28,9 @@ using Spring.Northwind.Domain;
|
||||
|
||||
namespace Spring.Northwind.Dao
|
||||
{
|
||||
/// <summary>
|
||||
/// Product related DAO operations interface.
|
||||
/// </summary>
|
||||
public interface IProductDao : IDao<Product, int>, ISupportsDeleteDao<Product>, ISupportsSave<Product, int>
|
||||
{
|
||||
|
||||
|
||||
@@ -1,7 +1,15 @@
|
||||
namespace Spring.Northwind.Dao
|
||||
{
|
||||
/// <summary>
|
||||
/// Role interface for DAOs that support deletion of entities.
|
||||
/// </summary>
|
||||
/// <typeparam name="TEntity">Entity type.</typeparam>
|
||||
public interface ISupportsDeleteDao<TEntity>
|
||||
{
|
||||
/// <summary>
|
||||
/// Deletes the entity.
|
||||
/// </summary>
|
||||
/// <param name="entity">Entity to delete.</param>
|
||||
void Delete(TEntity entity);
|
||||
}
|
||||
}
|
||||
@@ -1,5 +1,10 @@
|
||||
namespace Spring.Northwind.Dao
|
||||
{
|
||||
/// <summary>
|
||||
/// Role interface for DAOs that support saves and updates to entities.
|
||||
/// </summary>
|
||||
/// <typeparam name="TEntity">Entity type.</typeparam>
|
||||
/// <typeparam name="TId">Entity id type.</typeparam>
|
||||
public interface ISupportsSave<TEntity, TId>
|
||||
{
|
||||
/// <summary>
|
||||
@@ -13,6 +18,6 @@ namespace Spring.Northwind.Dao
|
||||
/// Saves or updates the entity. Behavior depends on the current state of entity's ID.
|
||||
/// </summary>
|
||||
/// <param name="entity">Entity to save or update.</param>
|
||||
void SaveOrUpdate(TEntity entity);
|
||||
void Update(TEntity entity);
|
||||
}
|
||||
}
|
||||
@@ -96,7 +96,7 @@ namespace Spring.Northwind.Service
|
||||
order.ShippedDate = DateTime.Now;
|
||||
|
||||
//Update shipment date
|
||||
OrderDao.SaveOrUpdate(order);
|
||||
OrderDao.Update(order);
|
||||
|
||||
//Other operations...Decrease product quantity... etc
|
||||
}
|
||||
|
||||
Binary file not shown.
Binary file not shown.
@@ -0,0 +1,6 @@
|
||||
<asp:DataGrid runat="server" CssClass="datagrid">
|
||||
<HeaderStyle CssClass="datagrid-header" />
|
||||
<ItemStyle CssClass="datagrid-item" />
|
||||
<AlternatingItemStyle CssClass="datagrid-alt-item" />
|
||||
<FooterStyle CssClass="datagrid-header" />
|
||||
</asp:DataGrid>
|
||||
@@ -1,129 +1,166 @@
|
||||
body {
|
||||
margin: 0px;
|
||||
padding: 0px;
|
||||
background-color: #dfeac1;
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
.logo {
|
||||
position:relative;
|
||||
top:-8px;
|
||||
left:22px;
|
||||
float:left;
|
||||
}
|
||||
|
||||
#ad {
|
||||
float:right;
|
||||
position:relative;
|
||||
right: 22px;
|
||||
top:-8px;
|
||||
}
|
||||
|
||||
|
||||
|
||||
.navigation {
|
||||
position:relative;
|
||||
left: 25px;
|
||||
font-family: Verdana, Arial, Helvetica, sans;
|
||||
font-size: 12px;
|
||||
color: #000000;
|
||||
text-decoration: none;
|
||||
width:150px;
|
||||
}
|
||||
.navigation a, .navigation a:active, .navigation a:visited {
|
||||
font-family: Verdana, Arial, Helvetica, sans;
|
||||
font-size: 12px;
|
||||
color: #7E7E7E;
|
||||
text-decoration: none;
|
||||
}
|
||||
.navigation a:hover {
|
||||
font-family: Verdana, Arial, Helvetica, sans;
|
||||
font-size: 12px;
|
||||
color: #000000;
|
||||
text-decoration: none;
|
||||
}
|
||||
|
||||
|
||||
h4.navbar {
|
||||
position:relative;
|
||||
left: 0px;
|
||||
font-family: Verdana, Arial, Helvetica, sans;
|
||||
font-size: 12px;
|
||||
color: #5F5F5F;
|
||||
text-decoration: none;
|
||||
margin-bottom: 2px;
|
||||
}
|
||||
h1 {
|
||||
font-family: Verdana, Arial, Helvetica, sans;
|
||||
font-size: 14px;
|
||||
font-weight: normal;
|
||||
color: #90A720;
|
||||
}
|
||||
a, a:active, a:visited {
|
||||
font-family: Verdana, Arial, Helvetica, sans;
|
||||
font-size: 12px;
|
||||
color: #606060;
|
||||
text-decoration: underline;
|
||||
}
|
||||
a:hover {
|
||||
font-family: Verdana, Arial, Helvetica, sans;
|
||||
font-size: 12px;
|
||||
color: #000000;
|
||||
}
|
||||
b {
|
||||
font-family: Verdana, Arial, Helvetica, sans;
|
||||
font-size: 12px;
|
||||
font-weight: bold;
|
||||
color: #606060;
|
||||
}
|
||||
i {
|
||||
font-family: Verdana, Arial, Helvetica, sans;
|
||||
font-size: 12px;
|
||||
color: #606060;
|
||||
}
|
||||
|
||||
table {
|
||||
font-family: Verdana, Arial, Helvetica, sans;
|
||||
font-size: 12px;
|
||||
color: #606060;
|
||||
}
|
||||
.news {
|
||||
border: 1px solid;
|
||||
border-color: #C9C9C9;
|
||||
padding: 12px;
|
||||
font-family: Verdana, Arial, Helvetica, sans;
|
||||
font-size: 12px;
|
||||
color: #606060;
|
||||
background-color: #F5F5F5;
|
||||
margin-top: 20px;
|
||||
margin-bottom: 20px;
|
||||
}
|
||||
.news b {
|
||||
font-family: Verdana, Arial, Helvetica, sans;
|
||||
font-size: 11px;
|
||||
font-weight: normal;
|
||||
color: #90A720;
|
||||
}
|
||||
.news u {
|
||||
font-family: Verdana, Arial, Helvetica, sans;
|
||||
font-size: 12px;
|
||||
font-weight: bold;
|
||||
color: #606060;
|
||||
text-decoration: none;
|
||||
}
|
||||
li {
|
||||
margin-bottom: 12px;
|
||||
}
|
||||
|
||||
li.newslist {
|
||||
margin-bottom: 2px;
|
||||
}
|
||||
|
||||
ul.newslist {
|
||||
margin-left: 10px;
|
||||
margin-top: 10px;
|
||||
}
|
||||
ul {
|
||||
margin-left: 25px;
|
||||
margin-top: 10px;
|
||||
body {
|
||||
margin: 0px;
|
||||
padding: 0px;
|
||||
background-color: #dfeac1;
|
||||
text-align: center;
|
||||
text-decoration: none;
|
||||
}
|
||||
|
||||
.logo {
|
||||
position:relative;
|
||||
top:-8px;
|
||||
left:22px;
|
||||
float:left;
|
||||
}
|
||||
|
||||
.headerText
|
||||
{
|
||||
color: White;
|
||||
left: 350px;
|
||||
top: 50px;
|
||||
font-family: Verdana;
|
||||
font-size: 150%;
|
||||
font-weight: bold;
|
||||
position: absolute;
|
||||
}
|
||||
|
||||
fieldset {
|
||||
border: 1px solid #CCA383;
|
||||
width: 60%;
|
||||
background: LightGoldenrodYellow;
|
||||
padding: 3px;
|
||||
padding-bottom: 10px;
|
||||
}
|
||||
|
||||
fieldset legend {
|
||||
background: PaleGoldenrod;
|
||||
padding: 6px;
|
||||
font-weight: bold;
|
||||
}
|
||||
|
||||
.formLabelCell
|
||||
{
|
||||
text-align: left;
|
||||
padding-left: 10px;
|
||||
padding-right: 30px;
|
||||
font-weight: bold;
|
||||
}
|
||||
|
||||
.formValueCell
|
||||
{
|
||||
text-align: left;
|
||||
}
|
||||
|
||||
.actionPanel
|
||||
{
|
||||
margin: 30px;
|
||||
border: 1px solid #CCA383;
|
||||
width: 50%;
|
||||
background: LightGoldenrodYellow;
|
||||
text-align: center;
|
||||
padding: 5px;
|
||||
}
|
||||
|
||||
#headerCell
|
||||
{
|
||||
background: url(../img/header-spring.png);
|
||||
height: 150px;
|
||||
width: 719px;
|
||||
}
|
||||
|
||||
#contentCell
|
||||
{
|
||||
background-image: url(../img/bg-spring.png);
|
||||
text-align: left;
|
||||
vertical-align: top;
|
||||
}
|
||||
|
||||
#footerCell
|
||||
{
|
||||
background-image: url(../img/footern.gif);
|
||||
text-align: center;
|
||||
height: 29px;
|
||||
}
|
||||
|
||||
.datagrid
|
||||
{
|
||||
border: solid 1px Tan;
|
||||
margin-left: 10px;
|
||||
}
|
||||
|
||||
.datagrid-header
|
||||
{
|
||||
font-weight: bold;
|
||||
background-color: Tan;
|
||||
}
|
||||
|
||||
.datagid-item
|
||||
{
|
||||
background-color: LightGoldenrodYellow;
|
||||
}
|
||||
|
||||
.datagrid-alt-item
|
||||
{
|
||||
background-color: PaleGoldenrod;
|
||||
}
|
||||
|
||||
.datagrid-footer
|
||||
{
|
||||
font-weight: bold;
|
||||
background-color: Tan;
|
||||
}
|
||||
|
||||
h1 {
|
||||
font-family: Verdana, Arial, Helvetica, sans;
|
||||
font-size: 14px;
|
||||
font-weight: normal;
|
||||
color: #90A720;
|
||||
}
|
||||
a, a:active, a:visited {
|
||||
font-family: Verdana, Arial, Helvetica, sans;
|
||||
font-size: 12px;
|
||||
color: #606060;
|
||||
text-decoration: underline;
|
||||
}
|
||||
a:hover {
|
||||
font-family: Verdana, Arial, Helvetica, sans;
|
||||
font-size: 12px;
|
||||
color: #000000;
|
||||
}
|
||||
b {
|
||||
font-family: Verdana, Arial, Helvetica, sans;
|
||||
font-size: 12px;
|
||||
font-weight: bold;
|
||||
color: #606060;
|
||||
}
|
||||
i {
|
||||
font-family: Verdana, Arial, Helvetica, sans;
|
||||
font-size: 12px;
|
||||
color: #606060;
|
||||
}
|
||||
|
||||
table {
|
||||
font-family: Verdana, Arial, Helvetica, sans;
|
||||
font-size: 12px;
|
||||
color: #606060;
|
||||
}
|
||||
.news {
|
||||
border: 1px solid;
|
||||
border-color: #C9C9C9;
|
||||
padding: 12px;
|
||||
font-family: Verdana, Arial, Helvetica, sans;
|
||||
font-size: 12px;
|
||||
color: #606060;
|
||||
background-color: #F5F5F5;
|
||||
margin-top: 20px;
|
||||
margin-bottom: 20px;
|
||||
}
|
||||
|
||||
li {
|
||||
margin-bottom: 12px;
|
||||
}
|
||||
|
||||
ul {
|
||||
margin-left: 25px;
|
||||
margin-top: 10px;
|
||||
}
|
||||
@@ -2,22 +2,36 @@
|
||||
Inherits="CustomerEditor" %>
|
||||
|
||||
<asp:Content ID="content" ContentPlaceHolderID="content" runat="server">
|
||||
<spring:DataBindingPanel runat="server">
|
||||
<table>
|
||||
<tr>
|
||||
<td>
|
||||
ID:</td>
|
||||
<td>
|
||||
<asp:TextBox runat="server" BindingTarget="CurrentCustomer.Id" BindingDirection="TargetToSource"
|
||||
ReadOnly="true" /></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
Contact:</td>
|
||||
<td>
|
||||
<asp:TextBox runat="server" BindingTarget="CurrentCustomer.ContactName" /></td>
|
||||
</tr>
|
||||
</table>
|
||||
</spring:DataBindingPanel>
|
||||
<asp:Button runat="server" ID="btnSave" Text="Save" />
|
||||
<h1>
|
||||
Update customer information</h1>
|
||||
<div align="center">
|
||||
<spring:DataBindingPanel runat="server">
|
||||
<fieldset>
|
||||
<legend>Customer details</legend>
|
||||
<table>
|
||||
<tr>
|
||||
<td class="formLabelCell">
|
||||
ID:</td>
|
||||
<td class="formValueCell">
|
||||
<asp:TextBox runat="server" BindingTarget="CurrentCustomer.Id" BindingDirection="TargetToSource"
|
||||
ReadOnly="true" /></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="formLabelCell">
|
||||
Contact:</td>
|
||||
<td class="formValueCell">
|
||||
<asp:TextBox runat="server" BindingTarget="CurrentCustomer.ContactName" /></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td colspan="2" style="text-align: right; padding-top: 10px">
|
||||
<asp:Button runat="server" ID="btnSave" Text="Save" /></td>
|
||||
</tr>
|
||||
</table>
|
||||
</fieldset>
|
||||
</spring:DataBindingPanel>
|
||||
<div class="actionPanel">
|
||||
<a href="customerlist.aspx">« Back to customer list</a> | <a href="CustomerView.aspx">
|
||||
Cancel edit »</a>
|
||||
</div>
|
||||
</div>
|
||||
</asp:Content>
|
||||
|
||||
@@ -1,69 +1,63 @@
|
||||
using System;
|
||||
using System.Web;
|
||||
using Spring.Northwind.Dao;
|
||||
using Spring.Northwind.Domain;
|
||||
using Spring.Web.UI;
|
||||
|
||||
public partial class CustomerEditor : Page
|
||||
{
|
||||
private ICustomerEditController customerEditController;
|
||||
private ICustomerDao customerDao;
|
||||
private ICustomerEditController customerEditController;
|
||||
private ICustomerDao customerDao;
|
||||
|
||||
public ICustomerDao CustomerDao
|
||||
{
|
||||
set { this.customerDao = value; }
|
||||
}
|
||||
|
||||
public ICustomerEditController CustomerEditController
|
||||
{
|
||||
set { this.customerEditController = value; }
|
||||
}
|
||||
|
||||
public Customer CurrentCustomer
|
||||
{
|
||||
get
|
||||
public ICustomerDao CustomerDao
|
||||
{
|
||||
//return (Customer) Session[typeof(CustomerEditor).FullName + ".Customer"];
|
||||
return customerEditController.CurrentCustomer;
|
||||
set { customerDao = value; }
|
||||
}
|
||||
}
|
||||
|
||||
// public static void Edit( Customer customer )
|
||||
// {
|
||||
// HttpContext.Current.Session[typeof(CustomerEditor).FullName + ".Customer"] = customer;
|
||||
// }
|
||||
public ICustomerEditController CustomerEditController
|
||||
{
|
||||
set { customerEditController = value; }
|
||||
}
|
||||
|
||||
public CustomerEditor()
|
||||
{
|
||||
this.InitializeControls+=new EventHandler(Page_InitializeControls);
|
||||
this.DataBound+=new EventHandler(Page_DataBound);
|
||||
this.DataUnbound+=new EventHandler(Page_DataUnbound);
|
||||
}
|
||||
public Customer CurrentCustomer
|
||||
{
|
||||
get
|
||||
{
|
||||
return customerEditController.CurrentCustomer;
|
||||
}
|
||||
}
|
||||
|
||||
override protected void InitializeDataBindings()
|
||||
{
|
||||
base.InitializeDataBindings();
|
||||
public CustomerEditor()
|
||||
{
|
||||
InitializeControls += Page_InitializeControls;
|
||||
DataBound += Page_DataBound;
|
||||
DataUnbound += Page_DataUnbound;
|
||||
}
|
||||
|
||||
// do the "one time" setup for databinding
|
||||
}
|
||||
override protected void InitializeDataBindings()
|
||||
{
|
||||
base.InitializeDataBindings();
|
||||
|
||||
private void Page_DataBound(object sender, EventArgs e)
|
||||
{
|
||||
// perform custom tasks for binding data from model to the form
|
||||
}
|
||||
// do the "one time" setup for databinding
|
||||
}
|
||||
|
||||
private void Page_DataUnbound(object sender, EventArgs e)
|
||||
{
|
||||
// perform custom tasks for unbinding data from form to the model
|
||||
}
|
||||
private void Page_DataBound(object sender, EventArgs e)
|
||||
{
|
||||
// perform custom tasks for binding data from model to the form
|
||||
}
|
||||
|
||||
private void Page_InitializeControls(object sender, EventArgs e)
|
||||
{
|
||||
btnSave.Click += new EventHandler(BtnSave_Click);
|
||||
}
|
||||
private void Page_DataUnbound(object sender, EventArgs e)
|
||||
{
|
||||
// perform custom tasks for unbinding data from form to the model
|
||||
}
|
||||
|
||||
private void BtnSave_Click(object sender, EventArgs e)
|
||||
{
|
||||
customerDao.SaveOrUpdate(CurrentCustomer);
|
||||
}
|
||||
private void Page_InitializeControls(object sender, EventArgs e)
|
||||
{
|
||||
btnSave.Click += BtnSave_Click;
|
||||
}
|
||||
|
||||
private void BtnSave_Click(object sender, EventArgs e)
|
||||
{
|
||||
customerDao.Update(CurrentCustomer);
|
||||
Response.Redirect("~/CustomerView.aspx");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,6 +3,8 @@
|
||||
|
||||
<asp:Content ID="content" ContentPlaceHolderID="content" runat="server">
|
||||
|
||||
<h1>Customers in database</h1>
|
||||
|
||||
<asp:DataGrid id="customerList" runat="server"
|
||||
AllowPaging="true"
|
||||
AllowSorting="false"
|
||||
|
||||
@@ -2,13 +2,25 @@
|
||||
CodeFile="CustomerOrders.aspx.cs" Inherits="CustomerOrders" %>
|
||||
|
||||
<asp:Content ID="content" ContentPlaceHolderID="content" runat="server">
|
||||
|
||||
<h1>Orders for customer <strong><asp:Literal ID="customerName" runat="server" /></strong></h1>
|
||||
|
||||
<div align="center">
|
||||
<asp:DataGrid ID="customerOrders" runat="server" AllowPaging="false" AllowSorting="false"
|
||||
BorderColor="black" BorderWidth="1" CellPadding="3" AutoGenerateColumns="false"
|
||||
ShowFooter="true">
|
||||
<HeaderStyle CssClass="" />
|
||||
<ItemStyle CssClass="" />
|
||||
<AlternatingItemStyle CssClass="" />
|
||||
<Columns>
|
||||
<asp:BoundColumn HeaderText="OrderID" DataField="ID" />
|
||||
<asp:BoundColumn HeaderText="OrderDate" DataFormatString="{0:d}" DataField="OrderDate" />
|
||||
<asp:BoundColumn HeaderText="ShippedDate" DataFormatString="{0:d}" DataField="ShippedDate" />
|
||||
</Columns>
|
||||
</asp:DataGrid>
|
||||
|
||||
<div class="actionPanel">
|
||||
<a href="CustomerList.aspx">« Back to customer listing</a>
|
||||
</div>
|
||||
</div>
|
||||
</asp:Content>
|
||||
|
||||
@@ -3,66 +3,64 @@ using System.Collections;
|
||||
using System.Web.UI.WebControls;
|
||||
using Spring.Northwind.Domain;
|
||||
|
||||
public partial class CustomerOrders:Spring.Web.UI.Page
|
||||
public partial class CustomerOrders : Spring.Web.UI.Page
|
||||
{
|
||||
private ICustomerEditController customerEditController;
|
||||
private ICustomerEditController customerEditController;
|
||||
|
||||
public ICustomerEditController CustomerEditController
|
||||
{
|
||||
set { this.customerEditController = value; }
|
||||
}
|
||||
|
||||
public Customer SelectedCustomer
|
||||
{
|
||||
get
|
||||
public ICustomerEditController CustomerEditController
|
||||
{
|
||||
return this.customerEditController.CurrentCustomer;
|
||||
set { customerEditController = value; }
|
||||
}
|
||||
}
|
||||
|
||||
public CustomerOrders()
|
||||
{
|
||||
this.InitializeControls+=new EventHandler(Page_InitializeControls);
|
||||
this.DataBound+=new EventHandler(Page_DataBound);
|
||||
this.DataUnbound+=new EventHandler(Page_DataUnbound);
|
||||
}
|
||||
|
||||
override protected void InitializeDataBindings()
|
||||
{
|
||||
base.InitializeDataBindings();
|
||||
|
||||
// do the "one time" setup for databinding
|
||||
}
|
||||
|
||||
private void Page_DataBound(object sender, EventArgs e)
|
||||
{
|
||||
// perform custom tasks for binding data from model to the form
|
||||
}
|
||||
|
||||
private void Page_DataUnbound(object sender, EventArgs e)
|
||||
{
|
||||
// perform custom tasks for unbinding data from form to the model
|
||||
}
|
||||
|
||||
private void Page_InitializeControls(object sender, EventArgs e)
|
||||
{
|
||||
// create/initialize controls here
|
||||
customerOrders.DataSource = SelectedCustomer.Orders;
|
||||
if (!IsPostBack)
|
||||
public Customer SelectedCustomer
|
||||
{
|
||||
customerOrders.DataBind();
|
||||
get { return customerEditController.CurrentCustomer; }
|
||||
}
|
||||
else
|
||||
{
|
||||
customerOrders.ItemCreated+=new DataGridItemEventHandler( this.CustomerList_ItemCreated );
|
||||
}
|
||||
}
|
||||
|
||||
private void CustomerList_ItemCreated(object sender, DataGridItemEventArgs e)
|
||||
{
|
||||
if(e.Item.DataSetIndex > -1)
|
||||
public CustomerOrders()
|
||||
{
|
||||
e.Item.DataItem = ((IList)customerOrders.DataSource)[e.Item.DataSetIndex];
|
||||
InitializeControls += Page_InitializeControls;
|
||||
DataBound += Page_DataBound;
|
||||
DataUnbound += Page_DataUnbound;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
protected override void InitializeDataBindings()
|
||||
{
|
||||
base.InitializeDataBindings();
|
||||
|
||||
// do the "one time" setup for databinding
|
||||
}
|
||||
|
||||
private void Page_DataBound(object sender, EventArgs e)
|
||||
{
|
||||
// perform custom tasks for binding data from model to the form
|
||||
}
|
||||
|
||||
private void Page_DataUnbound(object sender, EventArgs e)
|
||||
{
|
||||
// perform custom tasks for unbinding data from form to the model
|
||||
}
|
||||
|
||||
private void Page_InitializeControls(object sender, EventArgs e)
|
||||
{
|
||||
// create/initialize controls here
|
||||
customerOrders.DataSource = SelectedCustomer.Orders;
|
||||
customerName.Text = SelectedCustomer.CompanyName;
|
||||
if (!IsPostBack)
|
||||
{
|
||||
customerOrders.DataBind();
|
||||
}
|
||||
else
|
||||
{
|
||||
customerOrders.ItemCreated += CustomerList_ItemCreated;
|
||||
}
|
||||
}
|
||||
|
||||
private void CustomerList_ItemCreated(object sender, DataGridItemEventArgs e)
|
||||
{
|
||||
if (e.Item.DataSetIndex > -1)
|
||||
{
|
||||
e.Item.DataItem = ((IList) customerOrders.DataSource)[e.Item.DataSetIndex];
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,25 +1,32 @@
|
||||
<%@ Page Language="C#" MasterPageFile="~/Shared/MasterPage.master" CodeFile="CustomerEditor.aspx.cs"
|
||||
Inherits="CustomerEditor" %>
|
||||
<%@ Page Language="C#" MasterPageFile="~/Shared/MasterPage.master" CodeFile="CustomerView.aspx.cs"
|
||||
Inherits="CustomerView" %>
|
||||
|
||||
<asp:Content ID="content" ContentPlaceHolderID="content" runat="server">
|
||||
<spring:DataBindingPanel runat="server" ID="panel">
|
||||
<fieldset title="Customer details">
|
||||
<table>
|
||||
<tr>
|
||||
<td>
|
||||
ID:</td>
|
||||
<td>
|
||||
<asp:Label runat="server" BindingTarget="CurrentCustomer.Id" BindingDirection="TargetToSource"
|
||||
ReadOnly="true" /></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
Contact:</td>
|
||||
<td>
|
||||
<asp:Label runat="server" BindingTarget="CurrentCustomer.ContactName" /></td>
|
||||
</tr>
|
||||
</table>
|
||||
</fieldset>
|
||||
</spring:DataBindingPanel>
|
||||
<asp:Button runat="server" ID="btnSave" Text="Edit" />
|
||||
<div align="center">
|
||||
<spring:DataBindingPanel runat="server" ID="panel">
|
||||
<fieldset>
|
||||
<legend>Customer details</legend>
|
||||
<table>
|
||||
<tr>
|
||||
<td class="formLabelCell">
|
||||
ID:</td>
|
||||
<td class="formValueCell">
|
||||
<%= CurrentCustomer.Id %>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="formLabelCell">
|
||||
Contact:</td>
|
||||
<td class="formValueCell">
|
||||
<%= CurrentCustomer.ContactName %>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
</fieldset>
|
||||
</spring:DataBindingPanel>
|
||||
<div class="actionPanel">
|
||||
<a href="customerlist.aspx">« Back to customer list</a> | <a href="CustomerEditor.aspx">
|
||||
Edit Customer »</a>
|
||||
</div>
|
||||
</div>
|
||||
</asp:Content>
|
||||
|
||||
@@ -55,11 +55,7 @@ public partial class CustomerView : Page
|
||||
|
||||
private void Page_InitializeControls(object sender, EventArgs e)
|
||||
{
|
||||
btnSave.Click += new EventHandler(BtnSave_Click);
|
||||
|
||||
}
|
||||
|
||||
private void BtnSave_Click(object sender, EventArgs e)
|
||||
{
|
||||
customerDao.SaveOrUpdate(CurrentCustomer);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,2 +1,13 @@
|
||||
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" %>
|
||||
<%Response.Redirect("CustomerList.aspx");%>
|
||||
<%@ Page Language="C#" MasterPageFile="~/Shared/MasterPage.master" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" %>
|
||||
|
||||
<asp:Content ID="content" ContentPlaceHolderID="content" runat="server">
|
||||
|
||||
<h1>Welcome to Spring.NET Northwind sample application!</h1>
|
||||
|
||||
<p>
|
||||
This sample demostrates Spring.NET NHibernate integration and concepts. All data access is done using NHibernate and
|
||||
all transactions are automatically handled by Spring.NET.
|
||||
</p>
|
||||
|
||||
<a href="CustomerList.aspx">Proceed to customer listing »</a>
|
||||
</asp:Content>
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 2.8 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 540 B |
@@ -7,52 +7,38 @@
|
||||
</head>
|
||||
<body>
|
||||
<form id="form1" runat="server">
|
||||
<div>
|
||||
<table border="0" cellpadding="0" cellspacing="0">
|
||||
<tbody>
|
||||
<tr>
|
||||
<td background="img/header-spring.png" height="150" width="719">
|
||||
<div class="logo">
|
||||
<a href="~/Default.aspx" runat="server">
|
||||
<img src="img/logo.png" border="0" height="84" width="271"></a></div>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td style="background-image: url(img/bg-spring.png);" align="left" valign="top">
|
||||
<table border="0" cellpadding="0" cellspacing="0" width="700">
|
||||
<tbody>
|
||||
<tr>
|
||||
<td colspan="2">
|
||||
<br>
|
||||
<br>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td style="height: 4721px" valign="top" width="210">
|
||||
<!-- Navigation: Start -->
|
||||
</td>
|
||||
<td style="height: 4721px" valign="top">
|
||||
<!-- Inhalt: Start -->
|
||||
<asp:ContentPlaceHolder ID="content" runat="server">
|
||||
</asp:ContentPlaceHolder>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td colspan="2">
|
||||
<br>
|
||||
<br>
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td style="background-image: url(img/footern.gif);" align="center" height="29">
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
<a name="top" />
|
||||
<div align="center">
|
||||
<div style="position: relative; top: 0px; width: 719px;">
|
||||
<table border="0" cellpadding="0" cellspacing="0">
|
||||
<tbody>
|
||||
<tr>
|
||||
<td id="headerCell">
|
||||
<div class="logo">
|
||||
<a href="~/Default.aspx" runat="server">
|
||||
<img src="img/logo.png" border="0" height="84" width="271"></a>
|
||||
</div>
|
||||
<div class="headerText">
|
||||
Goes Northwind <br /> with NHibernate
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td id="contentCell">
|
||||
<div style="margin: 20px;">
|
||||
|
||||
<asp:ContentPlaceHolder ID="content" runat="server">
|
||||
</asp:ContentPlaceHolder>
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td id="footerCell">
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
</body>
|
||||
|
||||
@@ -65,8 +65,10 @@
|
||||
<compilation debug="true">
|
||||
<assemblies>
|
||||
<add assembly="System.Data.OracleClient, Version=2.0.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089"/>
|
||||
<add assembly="System.Transactions, Version=2.0.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089"/></assemblies></compilation>
|
||||
<pages>
|
||||
<add assembly="System.Transactions, Version=2.0.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089"/>
|
||||
<add assembly="System.Core, Version=3.5.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089"/>
|
||||
<add assembly="System.Security, Version=2.0.0.0, Culture=neutral, PublicKeyToken=B03F5F7F11D50A3A"/></assemblies></compilation>
|
||||
<pages theme="Spring">
|
||||
<controls>
|
||||
<add tagPrefix="spring" namespace="Spring.Web.UI.Controls" assembly="Spring.Web"/>
|
||||
</controls>
|
||||
|
||||
@@ -34,6 +34,11 @@
|
||||
<property name="CustomerDao" ref="CustomerDao" />
|
||||
</object>
|
||||
|
||||
<object type="CustomerView.aspx">
|
||||
<property name="CustomerDao" ref="CustomerDao" />
|
||||
<property name="CustomerEditController" ref="CustomerEditController" />
|
||||
</object>
|
||||
|
||||
<object type="CustomerOrders.aspx" parent="CustomerEditPage" />
|
||||
|
||||
</objects>
|
||||
|
||||
@@ -20,8 +20,6 @@
|
||||
|
||||
#region Imports
|
||||
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Data;
|
||||
using NHibernate;
|
||||
using NUnit.Framework;
|
||||
@@ -99,7 +97,7 @@ namespace Spring.Northwind.IntegrationTests
|
||||
|
||||
c.CompanyName = "SpringSource";
|
||||
|
||||
customerDao.SaveOrUpdate(c);
|
||||
customerDao.Update(c);
|
||||
|
||||
c = customerDao.Get("MPOLL");
|
||||
Assert.AreEqual(c.Id, "MPOLL");
|
||||
@@ -149,7 +147,7 @@ namespace Spring.Northwind.IntegrationTests
|
||||
Assert.AreEqual(831, orderDao.GetAll().Count);
|
||||
|
||||
order.ShipCity = "Sao Paulo";
|
||||
orderDao.SaveOrUpdate(order);
|
||||
orderDao.Update(order);
|
||||
|
||||
order = orderDao.Get(orderId);
|
||||
Assert.AreEqual("PICCO", order.Customer.Id);
|
||||
|
||||
Reference in New Issue
Block a user