/// <summary>
 /// 新增(传入事务处理)
 /// </summary>
 /// <param name="p_BE">要新增的实体</param>
 /// <param name="sqlTrans">事务类</param>
 public void RAdd(BaseEntity p_BE, IDBTransAccess sqlTrans)
 {
     try
     {
         this.CheckCorrect(p_BE);
         ItemBuyFollow entity = (ItemBuyFollow)p_BE;
         string        sql    = "SELECT FormNo FROM Buy_ItemBuyFollow WHERE FormNo=" + SysString.ToDBString(entity.FormNo);
         DataTable     dt     = SysUtils.Fill(sql);
         if (dt.Rows.Count > 0)
         {
             throw new BaseException("跟单单号已存在,请重新生成");
         }
         //sql = "SELECT BuyFormNo FROM Buy_ItemBuyFollow WHERE BuyFormNo="+SysString.ToDBString(entity.BuyFormNo);
         sql = "SELECT DLoadDtsID FROM Buy_ItemBuyFollow WHERE DLoadDtsID=" + SysString.ToDBString(entity.DLoadDtsID);
         dt  = sqlTrans.Fill(sql);
         if (dt.Rows.Count > 0)
         {
             throw new BaseException("该采购合同已跟单,请检查");
         }
         ItemBuyFollowCtl control = new ItemBuyFollowCtl(sqlTrans);
         entity.ID = (int)EntityIDTable.GetID((long)SysEntity.Buy_ItemBuyFollow, sqlTrans);
         control.AddNew(entity);
         FormNoControlRule rulest = new FormNoControlRule();
         rulest.RAddSort((int)FormNoControlEnum.跟单单号, sqlTrans);
     }
     catch (BaseException)
     {
         throw;
     }
     catch (Exception E)
     {
         throw new BaseException(E.Message);
     }
 }
 /// <summary>
 /// 修改
 /// </summary>
 /// <param name="p_BE">要修改的实体</param>
 /// <param name="sqlTrans">事务类</param>
 public void RUpdate(BaseEntity p_BE, IDBTransAccess sqlTrans)
 {
     try
     {
         this.CheckCorrect(p_BE);
         ItemBuyFollow    entity  = (ItemBuyFollow)p_BE;
         ItemBuyFollowCtl control = new ItemBuyFollowCtl(sqlTrans);
         control.Update(entity);
     }
     catch (BaseException)
     {
         throw;
     }
     catch (Exception E)
     {
         throw new BaseException(E.Message);
     }
 }
        /// <summary>
        /// 删除
        /// </summary>
        /// <param name="p_BE">要删除的实体</param>
        /// <param name="sqlTrans">事务类</param>
        public void RDelete(BaseEntity p_BE, IDBTransAccess sqlTrans)
        {
            try
            {
                this.CheckCorrect(p_BE);
                ItemBuyFollow    entity  = (ItemBuyFollow)p_BE;
                ItemBuyFollowCtl control = new ItemBuyFollowCtl(sqlTrans);


                string sql = "DELETE FROM Buy_ItemBuyFollowDts WHERE MainID=" + entity.ID.ToString();
                sqlTrans.ExecuteNonQuery(sql);//删除原单据明细数据

                control.Delete(entity);
            }
            catch (BaseException)
            {
                throw;
            }
            catch (Exception E)
            {
                throw new BaseException(E.Message);
            }
        }