zoukankan      html  css  js  c++  java
  • .NET数据库编程求索之路4.使用ADO.NET实现(三层架构篇使用Table传递数据)(2)

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

    作者:夏春涛 xchunta@163.com

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

    4.3 实体层HomeShop.Model

    Order.cs

     1 using System;
     2 using System.Collections.Generic;
     3 using System.Linq;
     4 using System.Text;
     5 
     6 namespace HomeShop.Model
     7 {
     8     public class Order
     9     {
    10         //构造函数,初始化成员变量
    11         public Order()
    12         {
    13             this.OrderID = 0;
    14             this.OrderTime = DateTime.Now;
    15             this.OrderStateCode = "1";
    16             this.OrderItems = new List<OrderItem>();
    17             this.CustomerAddress = "";
    18             this.CustomerName = "";
    19             this.CustomerPhoneNo = "";
    20         }
    21 
    22         public int OrderID { setget; }
    23         public DateTime OrderTime { setget; }
    24         public string OrderStateCode{ setget; }
    25         public string CustomerName{ setget; }
    26         public string CustomerPhoneNo { setget; }
    27         public string CustomerAddress { setget; }
    28         
    29         //计算字段
    30         public decimal OrderTotal {
    31             get
    32             {
    33                 decimal total = 0m;
    34                 if (this.OrderItems != null)
    35                 {
    36                     foreach (OrderItem orderItem in this.OrderItems)
    37                     {
    38                         total += (decimal)orderItem.Subtotal;
    39                     }
    40                 }
    41                 return total;
    42             }
    43         }
    44 
    45         //关联属性
    46         public List<OrderItem> OrderItems { setget; }
    47     }
    48 }

    OrderItem.cs

     1 using System;
     2 using System.Collections.Generic;
     3 using System.Linq;
     4 using System.Text;
     5 
     6 namespace HomeShop.Model
     7 {
     8     public class OrderItem
     9     {
    10         //构造函数,初始化成员变量
    11         public OrderItem()
    12         {
    13             OrderItemID = 0;
    14             OrderID = 0;
    15             Product = "";
    16             UnitPrice = 0m;
    17             Quantity = 0;
    18         }
    19 
    20         public int OrderItemID { setget; }
    21         public int OrderID { setget; }
    22         public string Product { setget; }
    23         public decimal UnitPrice { setget; }
    24         public int Quantity { setget; }
    25 
    26         //计算字段
    27         public decimal Subtotal
    28         {
    29             get
    30             {
    31                 return (decimal)UnitPrice * Quantity;
    32 
    33             }
    34         }
    35     }
    36 }

    OrderState.cs

     1 using System;
     2 using System.Collections.Generic;
     3 using System.Linq;
     4 using System.Text;
     5 
     6 namespace HomeShop.Model
     7 {
     8     public class OrderState
     9     {
    10         public string Code { setget; }
    11         public string Name { setget; }
    12     }
    13 }

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

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

  • 相关阅读:
    训练赛(28)—— 计蒜客 45724 Jumping Frog
    训练赛(28)—— 计蒜客 45725 Fujiyama Thursday
    centos上libreoffice+unoconv安装步骤,实现word转pdf
    PhantomJS linux系统下安装步骤及使用方法(网页截屏功能)
    knockout应用开发指南(完整版)
    git 创建版本库
    保留json字符串中文的函数,代替json_encode
    微信公众平台开发接口PHP SDK完整版(转载)
    find_in_set()
    NuSOAP与PHPRPC比较(转)
  • 原文地址:https://www.cnblogs.com/SummerRain/p/2609132.html
Copyright © 2011-2022 走看看