/// <summary> /// Load the form using table 'Territories' PrimaryKey /// </summary> public void LoadForm(string TerritoryID) { string error = null; TerritoriesDataContext = dataConnection.GetDataContext(TerritoryID, out error); DataContext = TerritoriesDataContext; }
/// <summary> /// Alternative contructor. Creates the Form and also load it's data using table '' Primary key. /// </summary> public FormWPFTerritories(WPFConfig config, string TerritoryID, Frame mainFrame) { this.config = config; this.FrameMainWindow = mainFrame; dataConnection = new WPFTerritoriesDB(config); string error = null; TerritoriesDataContext = dataConnection.GetDataContext(TerritoryID, out error); DataContext = TerritoriesDataContext; InitializeComponent(); }
public void LoadGrid(Func <ModelNotifiedForTerritories, bool> filter = null) { this.DataGridTerritories.ItemsSource = null; //Saving current language WPFMessageAndLabelForList currentLanguage = new WPFMessageAndLabelForList(); if (this.TerritoriesDataContext != null) { currentLanguage = this.TerritoriesDataContext.WPFMessageAndLabelForList; } string error = null; this.TerritoriesDataContext = dataConnection.GetDataContext(out error); if (!string.IsNullOrEmpty(error)) { MessageBox.Show(error); return; } //Setting language messages this.TerritoriesDataContext.WPFMessageAndLabelForList = currentLanguage; this.DataContext = TerritoriesDataContext; List <ModelNotifiedForTerritories> filteredList; if (filter == null) { filteredList = TerritoriesDataContext.modelNotifiedForTerritoriesMain; } else { filteredList = TerritoriesDataContext.modelNotifiedForTerritoriesMain.Where(filter).ToList(); } //Bind data SetGridData(filteredList); //Load detail forms/lists in master/detail if (TerritoriesDataContext.modelNotifiedForTerritoriesMain.Count != 0) { this.LoadDetail(TerritoriesDataContext.modelNotifiedForTerritoriesMain[0]); } }