public void LinkToServiceWindow() { TBikeDAL MyDAL = new TBikeDAL(); DataTable ResultTable = MyDAL.ShowAllServiceDetails(); int index = dataGrid1.Items.IndexOf(dataGrid1.CurrentItem); if (index == -1) { index = 0; } else { string BicycleID = Convert.ToString(ResultTable.Rows[index]["BicycleID"]); string Status = Convert.ToString(ResultTable.Rows[index]["Status"]); if (Status == "M") { Service ret = new Service(); ret.PopulateDataFromLogin(username); ret.PopulateID(BicycleID, Status); ret.ShowDialog(); } else if (Status == "I") { Service ret = new Service(); ret.PopulateDataFromLogin(username); ret.PopulateID(BicycleID, Status); ret.ShowDialog(); } } }