Beispiel #1
0
 /// <summary>
 /// 保存配方表数据(新增、修改)
 /// </summary>
 /// <param name="keyValue">主键</param>
 /// <returns></returns>
 public void SaveBomRecordForm(string keyValue, Mes_BomRecordEntity entity)
 {
     try
     {
         if (!string.IsNullOrEmpty(keyValue))
         {
             entity.Modify(keyValue);
             this.BaseRepository().Update(entity);
         }
         else
         {
             entity.Create();
             this.BaseRepository().Insert(entity);
         }
     }
     catch (Exception ex)
     {
         if (ex is ExceptionEx)
         {
             throw;
         }
         else
         {
             throw ExceptionEx.ThrowServiceException(ex);
         }
     }
 }
Beispiel #2
0
        /// <summary>
        /// 保存实体数据(新增、修改)
        /// </summary>
        /// <param name="keyValue">主键</param>
        /// <returns></returns>
        public void SaveEntity(string keyValue, Mes_BomHeadEntity entity)
        {
            var db = this.BaseRepository().BeginTrans();

            try
            {
                if (!string.IsNullOrEmpty(keyValue))
                {
                    //var mes_BomHeadEntityTmp = GetMes_BomHeadEntity(keyValue);
                    entity.Modify(keyValue);
                    db.Update(entity);
                    //db.Delete<Mes_BomRecordEntity>(t=>t.B_FormulaCode == mes_BomHeadEntityTmp.B_FormulaCode);
                    //foreach (Mes_BomRecordEntity item in mes_BomRecordList)
                    //{
                    //    item.Create();
                    //    item.B_FormulaCode = mes_BomHeadEntityTmp.B_FormulaCode;
                    //    db.Insert(item);
                    //}
                }
                else
                {
                    entity.Create();
                    db.Insert(entity);
                    var bomRecord = new Mes_BomRecordEntity()
                    {
                        B_FormulaCode = entity.B_FormulaCode,

                        B_GoodsCode = entity.B_GoodsCode,
                        B_GoodsName = entity.B_GoodsName
                    };
                    bomRecord.Create();
                    db.Insert(bomRecord);
                    //foreach (Mes_BomRecordEntity item in mes_BomRecordList)
                    //{
                    //    item.Create();
                    //    item.B_FormulaCode = entity.B_FormulaCode;
                    //    db.Insert(item);
                    //}
                }
                db.Commit();
            }
            catch (Exception ex)
            {
                db.Rollback();
                if (ex is ExceptionEx)
                {
                    throw;
                }
                else
                {
                    throw ExceptionEx.ThrowServiceException(ex);
                }
            }
        }