public void PopulateEmployeeDetailsByRankLevel() { TBikeDAL MyDAL = new TBikeDAL(); DataTable ResultTable = MyDAL.SelectEmployeeDetailsByRankLevel(RankID); dataGrid1.ItemsSource = ResultTable.DefaultView; dataGrid1.AutoGenerateColumns = false; dataGrid1.CanUserAddRows = false; }
private async void dataGrid1_SelectionChanged(object sender, SelectionChangedEventArgs e) { TBikeDAL MyDAL = new TBikeDAL(); DataRowView dataRow = (DataRowView)dataGrid1.SelectedItem; int index = dataGrid1.Items.IndexOf(dataGrid1.CurrentItem); if (index == -1) { index = 0; } //string cellValue = dataRow.Row.ItemArray[index].ToString(); DataTable ResultTable = MyDAL.SelectEmployeeDetailsByRankLevel(RankID); id = Convert.ToString(ResultTable.Rows[index]["EmployeeID"]); self = Convert.ToString(ResultTable.Rows[index]["username"]); int Rank = Convert.ToInt32(ResultTable.Rows[index]["EmployeeRank"]); if (id != null) { if (RankID >= 4 || self == username) { Framework.Visibility = Visibility.Visible; dataGrid1.Visibility = Visibility.Collapsed; EmployeeModify mod = new EmployeeModify(); mod.populateEmployee(id); mod.PopulateDataFromLogin(username); Framework.Content = mod.Content; } } else { var res = await this.ShowMessageAsync("Error", "Please Select Employee"); } }