/// <summary> /// 新增发货计划 /// </summary> /// <param name="data"></param> /// <param name="listGoods"></param> /// <param name="nOpStaffId"></param> /// <param name="strOpStaffName"></param> /// <param name="strErrText"></param> /// <returns></returns> public long InsertDeliverPlan(DeliverPlan data, List <DeliverPlanGoods> listGoods, long nOpStaffId, string strOpStaffName, out string strErrText) { long nPlanId = 0; try { using (TransactionScope transScope = new TransactionScope(TransactionScopeOption.Required, new TimeSpan(2, 0, 0))) { using (PlanDAO dao = new PlanDAO()) { //新增计划数据 nPlanId = dao.InsertDeliverPlan(data, nOpStaffId, strOpStaffName, out strErrText); if (nPlanId <= 0) { return(0); } //新增货物数据 foreach (DeliverPlanGoods goods in listGoods) { goods.PlanId = nPlanId; if (!dao.InsertDeliverPlanGoods(goods, nOpStaffId, strOpStaffName, out strErrText)) { return(0); } } } transScope.Complete(); } return(nPlanId); } catch (Exception e) { strErrText = e.Message; return(0); } }