public void LinkToBookingWindow() { TBikeDAL MyDAL = new TBikeDAL(); DataTable ResultTable = MyDAL.ShowAllBookingTable(); int index = dataGrid1.Items.IndexOf(dataGrid1.CurrentItem); if (index == -1) { index = 0; } else { string Customer = Convert.ToString(ResultTable.Rows[index]["Customer"]); string Status = Convert.ToString(ResultTable.Rows[index]["BookingStatus"]); if (Customer != null) { if (Status == "A") { rental rent = new rental(); rent.PopulateDataFromLogin(username); rent.PopulateID(Customer, Status); rent.ShowDialog(); } else if (Status == "R") { Return ret = new Return(); ret.PopulateDataFromLogin(username); ret.PopulateID(Customer, Status); ret.ShowDialog(); } else if (Status == "N") { Return ret = new Return(); ret.PopulateDataFromLogin(username); ret.PopulateID(Customer, Status); ret.ShowDialog(); } } } }