private void ExecuteSanitizingCommand(object sender, ExecutedRoutedEventArgs e) { BillingDataDataContext db = new BillingDataDataContext(); if (dataGridHelper.currentDataSheet == null) { int key = dataGridHelper.addNewSheet(new List <RuntimeData>(), ""); addingNewPage(key); } SanitizingWindow window; RuntimeData dataToSend = null; if (dataGrid.SelectedItem != null) { dataToSend = (RuntimeData)dataGrid.SelectedItem; } concatinateAllRecordsInOnePage(); Dictionary <string, List <string> > SubClientList = new Dictionary <string, List <string> >(); List <RuntimeData> data = dataGridHelper.getCurrentDataStack; List <string> clients = data.Select(x => x.CustCode).Distinct().ToList(); clients.ForEach(x => { List <string> subClients = data.Where(y => y.CustCode == x).Select(z => z.SubClient).Distinct().ToList(); SubClientList.Add(x, subClients); }); List <string> ConsigneeList = data.Select(x => x.ConsigneeName).Distinct().ToList(); List <string> ConsignerList = data.Select(x => x.ConsignerName).Distinct().ToList(); window = new SanitizingWindow(dataGridHelper.getCurrentDataStack, db, dataGridHelper.currentSheetNumber, dataGrid, dataGridHelper, SubClientList, ConsigneeList, ConsignerList, dataToSend); window.Closed += SanitizingWindow_Closed; window.Show(); }
public MainWindow() { InitializeComponent(); isInitialized = true; // Client listing data import procedure clientToEdit = new List <Client>(); clientViewSource = (CollectionViewSource)FindResource("ClienTable"); clientViewSource.Source = DataSources.ClientCopy; cityViewSource = (CollectionViewSource)FindResource("CityTable"); cityViewSource.Source = DataSources.CityCopy; BillingDataDataContext db = new BillingDataDataContext(); ServiceTable = (CollectionViewSource)FindResource("ServiceTable"); ServiceTable.Source = DataSources.ServicesCopy; #region setupCode PreviewMouseMove += OnPreviewMouseMove; #endregion if (Configs.Default.Background == null || Configs.Default.Background == "") { Configs.Default.Background = "LightSeaGreen"; } this.MainGrid.Background = new SolidColorBrush((Color)ColorConverter.ConvertFromString(Configs.Default.Background)); ResourceDictionary dict = this.Resources; #region DataGrid Code Lines dataGridSource = (CollectionViewSource)FindResource("DataGridDataContext"); dataGridHelper = new DataGridHelper(dataGridSource); buttonList = new Dictionary <Button, int>(); DataGridPageNum.DataContext = dataGridHelper; DataGridNumOfRows.DataContext = dataGridHelper; #endregion #region Command Bindings CommandBinding SanitizingCommandBinding = new CommandBinding(SanitizingCommand, ExecuteSanitizingCommand, CanExecuteSanitizingCommand); this.CommandBindings.Add(SanitizingCommandBinding); SanitizingButton.Command = SanitizingCommand; CommandBinding PowerEntryCommandBinding = new CommandBinding(PowerEntryCommand, PowerEntryCommandExecuted, CanExecuteIsDataGridNotNull); this.CommandBindings.Add(PowerEntryCommandBinding); PowerEntryButton.Command = PowerEntryCommand; CommandBinding DeleteCommandBinding = new CommandBinding(DeleteCommand, DeleteCommandExecuted, DeleteCommand_CanExecute); this.CommandBindings.Add(DeleteCommandBinding); CommandBinding NewSheetCommandBinding = new CommandBinding(NewSheetCommand, NewSheetCommandExecuted, NewSheetCommand_CanExecute); NewSheetCommand.InputGestures.Add(new KeyGesture(Key.N, ModifierKeys.Control)); NewSheetButton.Command = NewSheetMenuItem.Command = NewSheetCommand; this.CommandBindings.Add(NewSheetCommandBinding); #endregion #region loading initial pages List <int> sheets = db.RuntimeDatas.Where(y => y.UserId == SecurityModule.currentUserName).Select(x => x.SheetNo).Distinct().ToList(); foreach (int sheet in sheets) { List <RuntimeData> runtimeData = db.RuntimeDatas.Where(x => x.UserId == SecurityModule.currentUserName && x.SheetNo == sheet).OrderBy(z => z.ConsignmentNo).ToList();; dataGridHelper.addNewSheet(runtimeData, "sheet " + sheet.ToString()); addingNewPage(sheet); } #endregion #region LoadConfigs Configs.Default.PropertyChanged += Default_PropertyChanged; #endregion LoadWorker = new BackgroundWorker(); LoadWorker.DoWork += LoadWorker_DoWork; LoadWorker.ProgressChanged += LoadWorker_ProgressChanged; LoadWorker.RunWorkerCompleted += LoadWorker_RunWorkerCompleted; DeleteSheetWorker = new BackgroundWorker(); DeleteSheetWorker.DoWork += DeleteWorker_DoWork; DeleteSheetWorker.RunWorkerCompleted += DeleteWorker_RunWorkerCompleted; costingRules = new List <CostingRule>(); setUiFromPermissions(); }