CodeSmith Nettier调用Transaction事务Sample
1 public static class ProductManager
2 {
3 public static void In(DateTime date, string batchCode, int from, int to, int reasonId, int operatorId, int auditor,int releaseCode,
4 IList<WareHouseRequestItem> items)
5 {
6 TransactionManager trans = DataRepository.Provider.CreateTransaction(); ;
7
8 WareHouseMovementRequest movReq = new WareHouseMovementRequest();
9 movReq.BatchCode = batchCode;
10 movReq.From = from;
11 movReq.To = to;
12 //movReq.ReasonId = reasonId;
13 movReq.Operator = operatorId;
14 movReq.Auditor = auditor;
15 movReq.ReleaseCode = releaseCode;
16 movReq.Items = new WareHouseRequestItemCollection();
17
18 foreach (WareHouseRequestItem item in items)
19 {
20 WareHouseRequestItem reqItem = new WareHouseRequestItem();
21 reqItem.ProductId = item.ProductId;
22 reqItem.ReasonId = item.ReasonId;
23 reqItem.WareHouseID = item.WareHouseID;
24 reqItem.Amount = item.Amount;
25 reqItem.UnitPrice = item.UnitPrice;
26 reqItem.UnitId = item.UnitId;
27 reqItem.SumPrice = item.SumPrice;
28 reqItem.Status = item.Status;
29
30 movReq.Items.Add(reqItem);
31 }
32
33 //TransactionManager trans = DataRepository.Provider.CreateTransaction();
34 BlueBeans.WareHouses.WareHouseService.Request(trans, movReq);
35 BlueBeans.WareHouses.WareHouseService.RequestAudit(trans,movReq);
36 trans.Commit();
37 //Insert(trans);
38 //Warehouse.Request(trans, );入库出库申请
39 //Warehouse.RequestAudit 出入库审核
40 //trans.Commit();
41 }
42 }
2 {
3 public static void In(DateTime date, string batchCode, int from, int to, int reasonId, int operatorId, int auditor,int releaseCode,
4 IList<WareHouseRequestItem> items)
5 {
6 TransactionManager trans = DataRepository.Provider.CreateTransaction(); ;
7
8 WareHouseMovementRequest movReq = new WareHouseMovementRequest();
9 movReq.BatchCode = batchCode;
10 movReq.From = from;
11 movReq.To = to;
12 //movReq.ReasonId = reasonId;
13 movReq.Operator = operatorId;
14 movReq.Auditor = auditor;
15 movReq.ReleaseCode = releaseCode;
16 movReq.Items = new WareHouseRequestItemCollection();
17
18 foreach (WareHouseRequestItem item in items)
19 {
20 WareHouseRequestItem reqItem = new WareHouseRequestItem();
21 reqItem.ProductId = item.ProductId;
22 reqItem.ReasonId = item.ReasonId;
23 reqItem.WareHouseID = item.WareHouseID;
24 reqItem.Amount = item.Amount;
25 reqItem.UnitPrice = item.UnitPrice;
26 reqItem.UnitId = item.UnitId;
27 reqItem.SumPrice = item.SumPrice;
28 reqItem.Status = item.Status;
29
30 movReq.Items.Add(reqItem);
31 }
32
33 //TransactionManager trans = DataRepository.Provider.CreateTransaction();
34 BlueBeans.WareHouses.WareHouseService.Request(trans, movReq);
35 BlueBeans.WareHouses.WareHouseService.RequestAudit(trans,movReq);
36 trans.Commit();
37 //Insert(trans);
38 //Warehouse.Request(trans, );入库出库申请
39 //Warehouse.RequestAudit 出入库审核
40 //trans.Commit();
41 }
42 }
本文来自博客园,作者:Slashout,转载请注明原文链接:https://www.cnblogs.com/SlashOut/archive/2007/07/29/835766.html