.NET数据库编程求索之路--4.使用ADO.NET实现(三层架构篇-使用Table传递数据)(4)
Posted on 2012-07-25 23:05 SummerRain 阅读(280) 评论(0) 编辑 收藏 举报
4.使用ADO.NET实现(三层架构篇-使用Table传递数据)(4)
作者:夏春涛 xchunta@163.com
转载请注明来源:http://www.cnblogs.com/SummerRain/archive/2012/07/25/2609154.html
4.5 业务逻辑层HomeShop.BLL
OrderBiz.cs
1 using System;
2 using System.Collections.Generic;
3 using System.Linq;
4 using System.Text;
5 //新添命名空间
6 using System.Data;
7 using System.Data.SqlClient;
8 using HomeShop.Model;
9 using HomeShop.DAL;
10
11 namespace HomeShop.BLL
12 {
13 public class OrderBiz
14 {
15 private OrderDAO dao;
16
17 public OrderBiz()
18 {
19 dao = new OrderDAO();
20 }
21
22 public OrderBiz(string connectionString)
23 {
24 dao = new OrderDAO(connectionString);
25 }
26
27 public int Add(Order order)
28 {
29 return dao.Add(order);
30 }
31
32 public int Update(Order order)
33 {
34 return dao.Update(order);
35 }
36
37 public int Delete(int orderID)
38 {
39 return dao.Delete(orderID);
40 }
41
42 public DataTable GetTable()
43 {
44 return dao.GetTable();
45 }
46
47 public DataTable GetTable(string customerName)
48 {
49 string predicate = " [CustomerName] LIKE @CustomerName "; ;
50 SqlParameter param = new SqlParameter("@CustomerName", "%" + customerName + "%");
51 return dao.GetTable(predicate, param);
52 }
53
54 public Order GetSingle(int orderID)
55 {
56 return dao.GetSingle(orderID);
57 }
58
59 }
60 }
2 using System.Collections.Generic;
3 using System.Linq;
4 using System.Text;
5 //新添命名空间
6 using System.Data;
7 using System.Data.SqlClient;
8 using HomeShop.Model;
9 using HomeShop.DAL;
10
11 namespace HomeShop.BLL
12 {
13 public class OrderBiz
14 {
15 private OrderDAO dao;
16
17 public OrderBiz()
18 {
19 dao = new OrderDAO();
20 }
21
22 public OrderBiz(string connectionString)
23 {
24 dao = new OrderDAO(connectionString);
25 }
26
27 public int Add(Order order)
28 {
29 return dao.Add(order);
30 }
31
32 public int Update(Order order)
33 {
34 return dao.Update(order);
35 }
36
37 public int Delete(int orderID)
38 {
39 return dao.Delete(orderID);
40 }
41
42 public DataTable GetTable()
43 {
44 return dao.GetTable();
45 }
46
47 public DataTable GetTable(string customerName)
48 {
49 string predicate = " [CustomerName] LIKE @CustomerName "; ;
50 SqlParameter param = new SqlParameter("@CustomerName", "%" + customerName + "%");
51 return dao.GetTable(predicate, param);
52 }
53
54 public Order GetSingle(int orderID)
55 {
56 return dao.GetSingle(orderID);
57 }
58
59 }
60 }
OrderStateBiz.cs
1 using System;
2 using System.Collections.Generic;
3 using System.Linq;
4 using System.Text;
5 //新添命名空间
6 using System.Data;
7 using System.Data.SqlClient;
8 using HomeShop.DAL;
9
10 namespace HomeShop.BLL
11 {
12 public class OrderStateBiz
13 {
14 private OrderStateDAO dao;
15
16 public OrderStateBiz()
17 {
18 dao = new OrderStateDAO();
19 }
20
21 public OrderStateBiz(string connectionString)
22 {
23 dao = new OrderStateDAO(connectionString);
24 }
25
26 public DataTable GetTable()
27 {
28 return dao.GetTable();
29 }
30 }
31 }
2 using System.Collections.Generic;
3 using System.Linq;
4 using System.Text;
5 //新添命名空间
6 using System.Data;
7 using System.Data.SqlClient;
8 using HomeShop.DAL;
9
10 namespace HomeShop.BLL
11 {
12 public class OrderStateBiz
13 {
14 private OrderStateDAO dao;
15
16 public OrderStateBiz()
17 {
18 dao = new OrderStateDAO();
19 }
20
21 public OrderStateBiz(string connectionString)
22 {
23 dao = new OrderStateDAO(connectionString);
24 }
25
26 public DataTable GetTable()
27 {
28 return dao.GetTable();
29 }
30 }
31 }
数据库文件:/Files/SummerRain/NetDbDevRoad/HomeShopDB.rar
完整源代码:/Files/SummerRain/NetDbDevRoad/4使用ADONET实现三层架构Table.rar