public FrmStock(DateTime startDate, DateTime endDate, bool isPurchase) { try { InitializeComponent(); grdViewStock.AutoGenerateColumns = false; _repository = new StockRepo(); _startDate = startDate; _endDate = endDate; var listStk = _repository.GetAllStocksByDate(startDate, endDate, isPurchase); BindingList <Stock> newlist = new BindingList <Stock>(listStk); grdViewStock.DataSource = newlist; _isPurchase = isPurchase; if (isPurchase == true) { lblTitle.Text = "Stock In"; } else { lblTitle.Text = "Stock Out"; } btnPrint.Visible = true; } catch (Exception ex) { MessageBox.Show(ex.Message); } }