public bool TryUpdateQuery(string newSql) { dt = DBSingleton.TrySelectSql(newSql); if (dt == null) { MessageBox.Show("The select sql query wasn't valid!"); return(false); } mainView.ItemsSource = dt.AsDataView(); return(true); }
private void SetUpPartyBox( ) { DataTable dt; dt = DBSingleton.TrySelectSql("select party_ID,party_name from party"); foreach (DataRowView item in dt.AsDataView()) { if (item.Row.ItemArray.Length > 1) { partyBox.Items.Add(item.Row.ItemArray[0].ToString() + " - " + item.Row.ItemArray[1].ToString()); } } }
private void SetUpForigenKey(string name) { IsForigenKey = true; comboBox.Visibility = Visibility.Visible; value.Visibility = Visibility.Collapsed; int i = 0; int index = -1; DataTable dt; dt = DBSingleton.TrySelectSql(string.Format("select {0}_ID,{0}_name from {0}", name)); if (dt == null) { dt = DBSingleton.TrySelectSql(string.Format("select {0}_ID,{0}_location from {0}", name)); } if (dt == null) { dt = DBSingleton.SelectSql(string.Format("select {0}_ID,{0}_date from {0}", name)); } foreach (DataRowView item in dt.AsDataView()) { i++; if (IsForigenKey) { if (item.Row.ItemArray[0].ToString() == originalValue) { index = i; } } if (item.Row.ItemArray.Length > 1) { comboBox.Items.Add(item.Row.ItemArray[0].ToString() + " - " + item.Row.ItemArray[1].ToString()); } else { comboBox.Items.Add(item.Row.ItemArray[0].ToString()); } } if (IsForigenKey) { comboBox.SelectedIndex = index; } }