private void SaveSuCaiInfo() { Model.WxSuCaiInfoModel model = new WxSuCaiInfoModel(); BLL.WxBLL wbll = new BLL.WxBLL(); Model.CurrentMerModel cm = BLL.MerchantBLL.CurrentModel(); #region 事务开启 TransactionOptions transactionOption = new TransactionOptions(); transactionOption.IsolationLevel = System.Transactions.IsolationLevel.ReadCommitted; using (TransactionScope transactionScope = new TransactionScope(TransactionScopeOption.Required, transactionOption)) { #endregion model.WxSuCaiInfoId = ReDecimal("WxSuCaiInfoId", 0); if (model.WxSuCaiInfoId == 0) { //新增 } else { model = wbll.GetSuCaiInfoModel(model.WxSuCaiInfoId); } model.WxSuCaiTitle = ReStr("WxSuCaiTitle"); model.InputCode = ReStr("InputCode", Common.PinYin.GetCodstring(model.WxSuCaiTitle)); model.WxSuCaiContent = ReStrDeCode("WxSuCaiContent"); model.Memo = ReStr("Memo", ""); model.WxSuCaiTypeId = ReInt("WxSuCaiTypeId"); model.WxSuCaiClassId = ReInt("WxSuCaiClassId"); model.CreateUser = cm.CurrentUserId; model.Invalid = ReBool("Invalid", false); model.FmImgId = ReStr("FmImgId", ""); model.MerId = ReDecimal("MerId", cm.CurrentMerId); wbll.SaveSuCaiInfo(model); switch (model.WxSuCaiClassId) { case 2: //如果是图文 wbll.RemoveSuCaiDetail(" WxSuCaiInfoId='" + model.WxSuCaiInfoId + "' "); DataTable dtDetail = ReTable("detail"); if (dtDetail.Rows.Count == 0) { throw new Exception("图文回复需要至少一条明细!"); } foreach (DataRow drDetail in dtDetail.Rows) { Model.WxSuCaiDetailModel DetailModel = new WxSuCaiDetailModel(); DetailModel.ImgId = drDetail["ImgId"].ToString(); DetailModel.OrderNo = int.Parse(drDetail["OrderNo"].ToString()); DetailModel.OtherPara = drDetail["OtherPara"].ToString(); DetailModel.ReKey = drDetail["ReKey"].ToString(); DetailModel.Url = HttpUtility.UrlDecode(drDetail["Url"].ToString()); DetailModel.WxSuCaiInfoId = model.WxSuCaiInfoId; DetailModel.WxSuCaiDetailMemo = drDetail["WxSuCaiDetailMemo"].ToString(); try { DetailModel.WxSuCaiDetailClassId = int.Parse(drDetail["WxSuCaiDetailClassId"].ToString()); } catch { continue; } try { DetailModel.WxSuCaiDetailContent = drDetail["WxSuCaiDetailContent"].ToString(); } catch { DetailModel.WxSuCaiDetailContent = ""; } DetailModel.WxSuCaiDetailId = 0; //必须的,就靠它新增 DetailModel.WxSuCaiDetailTitle = drDetail["WxSuCaiDetailTitle"].ToString(); wbll.SaveSuCaiDetail(DetailModel); } break; default: //其他 break; } #region 事务关闭 transactionScope.Complete(); } #endregion ReDict2.Add("WxSuCaiInfoId", model.WxSuCaiInfoId.ToString()); ReTrue(); }