public void PopulatePurchaseObj() { try { PurchaseObject = DATA.GetPurchaseDetailsByStockID(Convert.ToInt32(Stockid)); } catch (Exception e) { if (e.HResult == -2147467261) { throw new Exception("No Purchase exists for this stock item."); } } }