private async void Window_Loaded(object sender, RoutedEventArgs e) { Flags.MultiViewer = this; EventControl.BankDataLoaded += UpdatedDataLoaded; EventControl.CustDataLoaded += UpdatedDataLoaded; EventControl.DetDataLoaded += UpdatedDataLoaded; EventControl.ViewerDataHasBeenChanged += EventControl_ViewerDataHasBeenChanged; if (MultiBankcollection == null || MultiBankcollection.Count == 0) { MultiBankcollection = BankCollection.LoadBank(3); } BankGrid.ItemsSource = MultiBankcollection; if (MultiCustcollection == null || MultiCustcollection.Count == 0) { MultiCustcollection = CustCollection.LoadCust(MultiCustcollection); } if (MultiDetcollection == null || MultiDetcollection.Count == 0) { MultiDetcollection = DetCollection.LoadDet(MultiDetcollection); } this.BankGrid.ItemsSource = MultiBankcollection; this.CustomerGrid.ItemsSource = MultiCustcollection; this.DetailsGrid.ItemsSource = MultiDetcollection; }
void ReloadData(DataGrid DGrid) { try { Mouse.OverrideCursor = Cursors.Wait; // Make sure we are back on UI thread int current = 0; current = DGrid.SelectedIndex == -1 ? 0 : DGrid.SelectedIndex; this.BankGrid.ItemsSource = null; this.CustomerGrid.ItemsSource = null; this.DetailsGrid.ItemsSource = null; BankCollection.LoadBank(3); this.BankGrid.ItemsSource = MultiBankcollection; MultiCustcollection = CustCollection.LoadCust(MultiCustcollection); this.CustomerGrid.ItemsSource = MultiCustcollection; MultiDetcollection = DetCollection.LoadDet(MultiDetcollection); this.DetailsGrid.ItemsSource = MultiDetcollection; DGrid.SelectedIndex = current; Console.WriteLine($"End of ReloadGrid() : Thread = { Thread . CurrentThread . ManagedThreadId}"); } catch (Exception ex) { Console.WriteLine($"ERROR: ReloadGrid() {ex . Message}, : {ex . Data}"); } }
private async void ReLoadAllDataBases( ) { this.BankGrid.ItemsSource = null; this.CustomerGrid.ItemsSource = null; this.DetailsGrid.ItemsSource = null; this.BankGrid.Items.Clear( ); this.CustomerGrid.Items.Clear( ); this.DetailsGrid.Items.Clear( ); BankCollection.LoadBank(3); MultiBankcollection = BankCollection.LoadBank(3); MultiCustcollection = CustCollection.LoadCust(MultiCustcollection); MultiDetcollection = DetCollection.LoadDet(MultiDetcollection); int b = bindex; int c = cindex; int d = dindex; this.BankGrid.ItemsSource = MultiBankcollection; this.CustomerGrid.ItemsSource = MultiCustcollection; this.DetailsGrid.ItemsSource = MultiDetcollection; bindex = b; cindex = c; dindex = d; this.BankGrid.Refresh( ); this.CustomerGrid.Refresh( ); this.DetailsGrid.Refresh( ); }
public static bool SelectViewer(int ViewerType, CustCollection tmp) { bool result = false; switch (ViewerType) { case 1: SqlViewerCustcollection = tmp; result = true; break; case 2: EditDbCustcollection = tmp; result = true; break; case 3: MultiCustcollection = tmp; result = true; break; case 4: CustViewerDbcollection = tmp; result = true; break; //case 5: // CustViewerDbcollection = tmp; // result = true; // break; //case 6: // DetViewerDbcollection = tmp; // result = true; // break; //case 7: // SqlViewerCustcollection = tmp; // result = true; // break; //case 8: // SqlViewerDetcollection = tmp; // result = true; // break; case 9: // = tmp; result = true; break; } return(result); }
public static CustCollection LoadCust(CustCollection cc, int ViewerType = 1) { // Called to Load/reload the One & Only Bankcollection data source if (dtCust.Rows.Count > 0) { dtCust.Clear( ); } if (cc != null) { Custinternalcollection = cc; } else { Custinternalcollection = new CustCollection( ); } if (Custinternalcollection.Count > 0) { Custinternalcollection.ClearItems( ); } CustCollection c = new CustCollection(); c.LoadCustDataSql( ); if (dtCust.Rows.Count > 0) { Custinternalcollection = LoadCustomerTest( ); } // We now have the ONE AND ONLY pointer the the Bank data in variable Bankcollection Flags.CustCollection = Custinternalcollection; SqlViewerCustcollection = Custinternalcollection; if (Flags.IsMultiMode == false) { // Finally fill and return The global Dataset SelectViewer(ViewerType, Custinternalcollection); return(Custinternalcollection); } else { // return the "working copy" pointer, it has filled the relevant collection to match the viewer return(Custinternalcollection); } }
//**************************************************************************************************************************************************************// // Entry point for all data load/Reload //**************************************************************************************************************************************************************// public static async Task <bool> LoadCustomerTaskInSortOrderAsync(bool isOriginator, int mode = -1) { try { if (dtCust.Rows.Count > 0) { dtCust.Clear( ); } if (Custcollection.Items.Count > 0) { Custcollection.ClearItems( ); } Custcollection = new CustCollection( ); Console.WriteLine($"Calling Task.Run in custcollection ...."); await Task.Run(async( ) => { Console.WriteLine($"Calling LoadCustDataSql in Task.Run in Bankcollection ...."); try { await LoadCustDataSql( ); Console.WriteLine($"Returned from LoadCustDataSql in Task.Run in Custcollection ...."); } catch (Exception ex) { Console.WriteLine($"ERROR in LoadCustData Task{ex.Message}, {ex.Data}...."); } Application.Current.Dispatcher.Invoke( async( ) => { Console.WriteLine($"Calling LoadCustomerCollection in Task.Run in Custcollection ...."); try { await LoadCustomerCollection( ); Console.WriteLine($"Returned from LoadCustmerCollection Task.Run in Custcollection ...."); } catch (Exception ex) { Console.WriteLine($"ERROR in LoadCustomerCollection Task {ex . Message}, {ex . Data}...."); } }); }); Console.WriteLine($"**** END **** OF ASYNC CALL METHOD {dtCust . Rows . Count} records in DataTable, {Custcollection . Count} in Custcollection ...."); Console.WriteLine($"**** END **** SENDING CALLBACK MESSAGE TO SQLDBVIEWER WINDOW TO LOAD THEIR DATAGRID !!!"); if (CustDataLoaded != null) { CustDataLoaded.Invoke(Custcollection, new LoadedEventArgs { CallerDb = "CUSTOMER", DataSource = Custcollection }); } } catch (Exception ex) { Console.WriteLine($"ERROR in LoadCustomerTaskInSortOrderAsync() : {ex . Message}, : {ex . Data}"); return(false); } return(true); }
public CustCollection( ) : base( ) { //set the static pointer to this class Custcollection = this; }