1
using
System;
2 using System.Data;
3 using System.Configuration;
4 using System.Collections;
5 using System.Web;
6 using System.Web.Security;
7 using System.Web.UI;
8 using System.Web.UI.WebControls;
9 using System.Web.UI.WebControls.WebParts;
10 using System.Web.UI.HtmlControls;
11 using BlueBeanDemo.Data;
12 using BlueBeanDemo.Entities;
13
14 public partial class Purchase_PurchaseCreate : System.Web.UI.Page
15 {
16 protected void Page_Load(object sender, EventArgs e)
17 {
18
19
20 }
21
22 private void InsertRecord()
23
24 {
25//深度保存,可以同时保存父对象和子集
26/**////*
27//DeepSave helper method can help you to save an object and its children in
28//one call.
29//*/
30//using Northwind.DataAccessLayer;
31//Order order = Order.CreateOrder("ALFKI", 1, DateTime.Now, DateTime.Now,
32//DateTime.Now, 1, 0.1m, "ship name", "ship address" , "paris", "idf", "75000",
33//"france");
34//order.OrderDetailCollection.Add(order.OrderID, 1, 15.6m, 10, 0.02f);
35//order.OrderDetailCollection.Add(order.OrderID, 2, 122.6m, 43, 0.03f);
36//DataRepository.OrderProvider.DeepSave(order);
37//Console.WriteLine("new order saved: orderId is: " + order.OrderID.ToString());
38
39 Order order = new Order();
40
41 order.OrderID = 9;
42 order.OrderTime = DateTime.Now;
43 order.ShipTime = DateTime.Now;
44 order.CustomerID = 4;
45 order.ShipPathID = 1;
46 for (int i = 0; i < 4; i++)
47 {
48 OrderItem orderitem = new OrderItem();
49 orderitem.OrderID = 9;
50 orderitem.ProductID = 1;
51 orderitem.Price = 2;
52 orderitem.OrderItemType = 1;
53 orderitem.ProductUnitID = 1;
54 orderitem.Amount = 50;
55
56
57 order.OrderItemCollection.Add(orderitem);
58 }
59
60
61 DataRepository.OrderProvider.DeepSave(order);
62
63
64 }
65 protected void TextBox2_TextChanged(object sender, EventArgs e)
66 {
67
68 }
69 protected void Button1_Click(object sender, EventArgs e)
70 {
71 this.InsertRecord();
72 }
73}
74
2 using System.Data;
3 using System.Configuration;
4 using System.Collections;
5 using System.Web;
6 using System.Web.Security;
7 using System.Web.UI;
8 using System.Web.UI.WebControls;
9 using System.Web.UI.WebControls.WebParts;
10 using System.Web.UI.HtmlControls;
11 using BlueBeanDemo.Data;
12 using BlueBeanDemo.Entities;
13
14 public partial class Purchase_PurchaseCreate : System.Web.UI.Page
15 {
16 protected void Page_Load(object sender, EventArgs e)
17 {
18
19
20 }
21
22 private void InsertRecord()
23
24 {
25//深度保存,可以同时保存父对象和子集
26/**////*
27//DeepSave helper method can help you to save an object and its children in
28//one call.
29//*/
30//using Northwind.DataAccessLayer;
31//Order order = Order.CreateOrder("ALFKI", 1, DateTime.Now, DateTime.Now,
32//DateTime.Now, 1, 0.1m, "ship name", "ship address" , "paris", "idf", "75000",
33//"france");
34//order.OrderDetailCollection.Add(order.OrderID, 1, 15.6m, 10, 0.02f);
35//order.OrderDetailCollection.Add(order.OrderID, 2, 122.6m, 43, 0.03f);
36//DataRepository.OrderProvider.DeepSave(order);
37//Console.WriteLine("new order saved: orderId is: " + order.OrderID.ToString());
38
39 Order order = new Order();
40
41 order.OrderID = 9;
42 order.OrderTime = DateTime.Now;
43 order.ShipTime = DateTime.Now;
44 order.CustomerID = 4;
45 order.ShipPathID = 1;
46 for (int i = 0; i < 4; i++)
47 {
48 OrderItem orderitem = new OrderItem();
49 orderitem.OrderID = 9;
50 orderitem.ProductID = 1;
51 orderitem.Price = 2;
52 orderitem.OrderItemType = 1;
53 orderitem.ProductUnitID = 1;
54 orderitem.Amount = 50;
55
56
57 order.OrderItemCollection.Add(orderitem);
58 }
59
60
61 DataRepository.OrderProvider.DeepSave(order);
62
63
64 }
65 protected void TextBox2_TextChanged(object sender, EventArgs e)
66 {
67
68 }
69 protected void Button1_Click(object sender, EventArgs e)
70 {
71 this.InsertRecord();
72 }
73}
74