/// <summary> /// 保存优惠卡类型 /// </summary> /// <returns></returns> /// <param name="model">优惠卡类型 扩展</param> /// <remarks>2014-01-09 朱成果 创建</remarks> public void SaveCouponCardType(CBSpCouponCardType model) { if (IsExistsTypeName(model.SysNo, model.TypeName)) { throw new Exception("类型名称已经存在,请使用其他名称"); } if (model.SysNo < 1) { #region 新建优惠卡类型 model.CreatedBy = model.LastUpdateBy; model.CreatedDate = model.LastUpdateDate; model.SysNo = Hyt.DataAccess.Promotion.ISpCouponCardTypeDao.Instance.Insert(model); if (model.SysNo > 0 && model.AssociateItem != null) { foreach (var item in model.AssociateItem) { item.CardTypeSysNo = model.SysNo; Hyt.DataAccess.Promotion.ISpCouponCardAssociateDao.Instance.Insert(item); } } #endregion } else { #region 编辑优惠卡类型 var entity = Hyt.DataAccess.Promotion.ISpCouponCardTypeDao.Instance.GetEntity(model.SysNo); if (entity != null) { entity.LastUpdateBy = model.LastUpdateBy; entity.LastUpdateDate = model.LastUpdateDate; entity.StartTime = model.StartTime; entity.EndTime = model.EndTime; entity.Status = model.Status; entity.TypeName = model.TypeName; entity.TypeDescription = model.TypeDescription; Hyt.DataAccess.Promotion.ISpCouponCardTypeDao.Instance.Update(entity); Hyt.DataAccess.Promotion.ISpCouponCardAssociateDao.Instance.DeleteByCardTypeSysNo(entity.SysNo); if (entity.SysNo > 0 && model.AssociateItem != null) { foreach (var item in model.AssociateItem) { item.CardTypeSysNo = entity.SysNo; Hyt.DataAccess.Promotion.ISpCouponCardAssociateDao.Instance.Insert(item); } } } #endregion } }
/// <summary> /// 获取优惠卡类型及其关联优惠券 /// </summary> /// <param name="sysNo">优惠卡类型编号</param> /// <returns>优惠卡类型及其关联优惠券</returns> /// <remarks>2014-01-09 朱成果 创建</remarks> public CBSpCouponCardType GetCouponCardType(int sysNo) { CBSpCouponCardType oo = new CBSpCouponCardType(); var model = Hyt.DataAccess.Promotion.ISpCouponCardTypeDao.Instance.GetEntity(sysNo); if (model.SysNo > 0) { oo.TypeDescription = model.TypeDescription; oo.TypeName = model.TypeName; oo.StartTime = model.StartTime; oo.EndTime = model.EndTime; oo.SysNo = model.SysNo; oo.Status = model.Status; oo.CreatedBy = model.CreatedBy; oo.CreatedDate = model.CreatedDate; oo.AssociateItem = Hyt.DataAccess.Promotion.ISpCouponCardAssociateDao.Instance.GetListByCardTypeSysNo(model.SysNo); } return(oo); }