.NET数据库编程求索之路--5.使用ADO.NET实现(三层架构篇-使用List传递数据)(2)

5.使用ADO.NET实现(三层架构篇-使用List传递数据)(2)

 

作者:夏春涛 xchunta@163.com

转载请注明来源: http://www.cnblogs.com/SummerRain/archive/2012/07/26/2610945.html

 

5.3 业务逻辑层HomeShop.BLL

OrderBiz.cs

 1 using System;
 2 using System.Collections.Generic;
 3 using System.Linq;
 4 using System.Text;
 5 //新添命名空间
 6 using HomeShop.Model;
 7 using HomeShop.DAL;
 8 
 9 namespace HomeShop.BLL
10 {
11     public class OrderBiz
12     {
13         private OrderDAO dao;
14 
15         public OrderBiz()
16         {
17             dao = new OrderDAO();
18         }
19 
20         public OrderBiz(string connectionString)
21         {
22             dao = new OrderDAO(connectionString);
23         }
24 
25         public int Add(Order order)
26         {
27             return dao.Add(order);
28         }
29 
30         public int Update(Order order)
31         {
32             return dao.Update(order);
33         }
34 
35         public int Delete(int orderID)
36         {            
37             Order order = this.GetSingle(orderID);
38             return dao.Delete(order);
39         }
40 
41         public List<Order> GetList()
42         {
43             return dao.GetList(null,null);
44         }
45 
46         public List<Order> GetList(string customerName)
47         {
48             return GetList().FindAll(
49                 delegate(Order order)
50                 {
51                     return (order.CustomerName.IndexOf(customerName) >= 0);
52                 });
53         }
54 
55         public Order GetSingle(int orderID)
56         {
57             return GetList().Find(
58                 delegate(Order order)
59                 {
60                     return (order.OrderID == orderID);
61                 }
62                 );
63         }
64 
65     }
66 }

 

OrderStateBiz.cs

 1 using System;
 2 using System.Collections.Generic;
 3 using System.Linq;
 4 using System.Text;
 5 //新添命名空间
 6 using HomeShop.Model;
 7 using HomeShop.DAL;
 8 
 9 namespace HomeShop.BLL
10 {
11     public class OrderStateBiz
12     {
13         private OrderStateDAO dao;
14 
15         public OrderStateBiz()
16         {
17             dao = new OrderStateDAO();
18         }
19 
20         public OrderStateBiz(string connectionString)
21         {
22             dao = new OrderStateDAO(connectionString);
23         }
24 
25         public List<OrderState> GetList()
26         {
27             return dao.GetList(nullnull);
28         }
29     }
30 }

 

 

数据库文件:/Files/SummerRain/NetDbDevRoad/HomeShopDB.rar

完整源代码:/Files/SummerRain/NetDbDevRoad/5使用ADONET实现三层架构List.rar

 

 

上一篇:网络安全公司Optiv欲进行IPO,计划融资1亿美元


下一篇:Linux学习之路