Exemplo n.º 1
0
 public int 销售价格_AddNew(销售价格EditModel model)
 {
     using (var context = new BDKRContext())
     {
         var _货品 = context.货品信息S.FirstOrDefault(t => t.编码 == model.货品信息编码);
         if (null == _货品)
             throw new Exception("菜品信息并不存在");
         var _o = context.销售价格表S.Where(t => t.货品信息编码 == model.货品信息编码)
             .OrderByDescending(t => t.创建时间).FirstOrDefault();
         if (null == _o || _o.价格 != model.当前销售价格)
         {
             var _n = new 销售价格表
             {
                 价格 = model.当前销售价格,
                 创建时间 = DateTime.Now,
                 编码 = model.编码,
                 货品信息编码 = model.货品信息编码,
                 附加说明 = model.附加说明
             };
             context.销售价格表S.Add(_n);
         }
         return context.SaveChanges();
     }
 }
Exemplo n.º 2
0
 public int 菜品信息_AddNew(菜品信息EditModel model)
 {
     int _count = 0;
     using (TransactionScope ts = new TransactionScope(TransactionScopeOption.Required))
     {
         using (var context = new BDKRContext())
         {
             var r = new Repository<货品信息>(context);
             var e = r.GetSingle(t => t.编码 == model.编码);
             if (null != e)
                 throw new Exception("菜品信息当前已存在");
             e = new 货品信息
             {
                 单位 = model.单位,
                 名称 = model.菜品名称,
                 备注 = model.附加说明,
                 拼音 = UtilHelper.PinYin(model.菜品名称),
                 是否菜品 = true,
                 编码 = model.编码,
                 规格 = model.规格,
                 货品类别编码 = model.菜品类别
             };
             if (model.当前销售价格 > 0)
             {
                 var cj = new 销售价格表
                 {
                     价格 = model.当前销售价格,
                     创建时间 = DateTime.Now,
                     编码 = 销售价格_GetNewCode(),
                     货品信息编码 = model.编码,
                     附加说明 = ""
                 };
                 var _jg = new Repository<销售价格表>(context);
                 _jg.AddNew(cj);
             }
             _count = r.AddNew(e);
             if (model.Details != null && model.Details.Count > 0)
             {
                 var _bcode = 货品BOM_GetNewCode();
             }
         }
         ts.Complete();
     }
     return _count;
 }