示例#1
0
 /// <summary>
 /// Kiểm tra và chỉnh sửa Rate
 /// </summary>
 /// <param name="entity">RateEntity</param>
 /// <returns>bool:kết quả thực hiện</returns>
 public static bool Edit(RateEntity entity)
 {
     checkExist(entity);
     checkLogic(entity);
     checkFK(entity);
     return RateDAL.Edit(entity);
 }
 protected void btnBinhchon_Click(object sender, EventArgs e)
 {
     //try
     //{
         int sodiem = Convert.ToInt32(rdlstBinhchon.SelectedValue);
         bool result;
         if (RateBRL.Exist(this.m_newsID))
         {
             result=RateBRL.Edit(sodiem, this.m_newsID);
         }
         else
         {
             RateEntity oRate=new RateEntity();
             oRate.iRate=sodiem;
             oRate.iCount=1;
             oRate.iNewsID=this.m_newsID;
             result=RateBRL.Add(oRate)>0;
         }
         if (result) lblThongbao.Text = Resources.language.camonbinhchon;
         this.napThongke();
     //}
     //catch(Exception ex)
     //{
     //    lblThongbao.Text = ex.Message;
     //}
 }
示例#3
0
 /// <summary>
 /// Kiểm tra và thêm mới Rate
 /// </summary>
 /// <param name="entity">Entity</param>
 /// <returns>Int32: ID của Rate Mới Thêm Vào</returns>
 public static Int32 Add(RateEntity entity)
 {
     checkLogic(entity);
     checkFK(entity);
     return RateDAL.Add(entity);
 }
示例#4
0
 /// <summary>
 /// Kiểm tra logic Entity
 /// </summary>
 /// <param name="entity">RateEntity: entity</param>
 private static void checkLogic(RateEntity entity)
 {
     if (entity.iNewsID < 0)
         throw new Exception(EX_INEWSID_INVALID);
     if (entity.iRate < 0)
         throw new Exception(EX_IRATE_INVALID);
     if (entity.iCount < 0)
         throw new Exception(EX_ICOUNT_INVALID);
 }
示例#5
0
 /// <summary>
 /// Kiểm tra tồn tại khóa ngoại
 /// </summary>
 /// <param name="entity">RateEntity:entity</param>
 private static void checkFK(RateEntity entity)
 {
     NewsEntity oNews = NewsDAL.GetOne(entity.iNewsID);
     if (oNews==null)
     {
         throw new Exception("Không tìm thấy tin tức");
     }
 }
示例#6
0
 private static void checkExist(RateEntity entity)
 {
     RateEntity oRate=RateDAL.GetOne(entity.iRateID);
     if(oRate==null)
         throw new Exception(EX_NOT_EXIST);
 }
示例#7
0
 /// <summary>
 /// Kiểm tra và xoá Rate
 /// </summary>
 /// <param name="entity">RateEntity</param>
 /// <returns>bool:kết quả thực hiện</returns>
 public static bool Remove(RateEntity entity)
 {
     checkExist(entity);
     checkFK(entity);
     return RateDAL.Remove(entity.iRateID);
 }