/// <summary>
 /// Kiểm tra và thêm mới Phuongphapkiemtra
 /// </summary>
 /// <param name="entity">Entity</param>
 /// <returns>Int32: ID của Phuongphapkiemtra Mới Thêm Vào</returns>
 public static Int32 Add(PhuongphapkiemtraEntity entity)
 {
     checkLogic(entity);
     checkDuplicate(entity, false);
     checkFK(entity);
     return PhuongphapkiemtraDAL.Add(entity);
 }
 /// <summary>
 /// Kiểm tra và chỉnh sửa Phuongphapkiemtra
 /// </summary>
 /// <param name="entity">PhuongphapkiemtraEntity</param>
 /// <returns>bool:kết quả thực hiện</returns>
 public static bool Edit(PhuongphapkiemtraEntity entity)
 {
     checkExist(entity.PK_iPhuongphapkiemtraID);
     checkLogic(entity);
     checkDuplicate(entity, true);
     checkFK(entity);
     return PhuongphapkiemtraDAL.Edit(entity);
 }
    protected void btnOK_Click(object sender, EventArgs e)
    {
        PhuongphapkiemtraEntity oPhuongphapkiemtra = new PhuongphapkiemtraEntity();
        oPhuongphapkiemtra.sTenphuongphapkiemtra = txtTenphuongphapkiemtra.Text;
        if (btnOK.CommandName == "Edit")
        {
            int PhuongphapkiemtraID = Convert.ToInt32(btnOK.CommandArgument);
            oPhuongphapkiemtra.PK_iPhuongphapkiemtraID = PhuongphapkiemtraID;
            PhuongphapkiemtraBRL.Edit(oPhuongphapkiemtra);
            btnOK.CausesValidation = true;
            lblThongbao.Text = "Cập nhật thành công";
        }
        else
        {
            int PhuongphapkiemtraID = PhuongphapkiemtraBRL.Add(oPhuongphapkiemtra);
            lblThongbao.Text = "Thêm thành công";
        }

        //Nạp lại dữ liệu
        pnAdd.Visible = false;
        napgrvPhuongphapkiemtra();
    }
 /// <summary>
 /// Kiểm tra trùng lặp bản ghi
 /// </summary>
 /// <param name="entity">PhuongphapkiemtraEntity: PhuongphapkiemtraEntity</param>
 private static void checkDuplicate(PhuongphapkiemtraEntity entity,bool checkPK)
 {
     /*
     Example
     List<PhuongphapkiemtraEntity> list = PhuongphapkiemtraDAL.GetAll();
     if (list.Exists(
         delegate(PhuongphapkiemtraEntity oldEntity)
         {
             bool result =oldEntity.FIELD.Equals(entity.FIELD, StringComparison.OrdinalIgnoreCase);
             if(checkPK)
                 result=result && oldEntity.PK_iPhuongphapkiemtraID != entity.PK_iPhuongphapkiemtraID;
             return result;
         }
     ))
     {
         list.Clear();
         throw new Exception(EX_FIELD_EXISTED);
     }
     */
 }
 /// <summary>
 /// Kiểm tra logic Entity
 /// </summary>
 /// <param name="entity">PhuongphapkiemtraEntity: entity</param>
 private static void checkLogic(PhuongphapkiemtraEntity entity)
 {
 }