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    }
posted @ 2007-07-29 22:30  Slashout  阅读(551)  评论(0编辑  收藏  举报