Ejemplo n.º 1
0
        private void DO11()
        {
            var waitDialog = new WaitingDialog("טוען נתונים", "נא להמתין .....", GetStockData, true, this, tokenSource);
            var r          = waitDialog.ShowDialog();

            if (r != true)
            {
                return;
            }
            GBMaterials.Header      = LM.Count.ToString();
            DGMaterials.ItemsSource = LM;
        }
Ejemplo n.º 2
0
        private void GetStockData(WaitingDialog dialog)
        {
            try
            {
                List <Transaction> LT = null;
                using (var db = new Model1())
                {
                    LM = db.Materials.Where(tt => tt.Status == "פעיל").ToList();
                    LT = db.Transactions.Where(tt => tt.Status == "פעיל").ToList();
                }
                LM = LM.OrderByDescending(x => x.Date1).ThenBy(x => x.Name1).ToList();

                LM.ForEach(tt => tt.TotalQTY =
                               LT.Where(x => x.MatId == tt.MatId && x.Direction == "IN").Sum(y => y.TrnQTY) -
                               LT.Where(x => x.MatId == tt.MatId && x.Direction == "OUT").Sum(y => y.TrnQTY)
                           );

                if (dialog != null)
                {
                    Dispatcher.Invoke(() =>
                    {
                        dialog.DialogResult = true;
                        dialog.Close();
                    }, DispatcherPriority.ApplicationIdle);
                }
            }
            catch (OperationCanceledException)
            {
                if (dialog != null)
                {
                    Dispatcher.Invoke(dialog.Close, DispatcherPriority.ApplicationIdle);
                }
            }
            catch (Exception ex)
            {
                if (dialog != null)
                {
                    Dispatcher.Invoke(() =>
                    {
                        dialog.ToErrorDialog("Exception", ex.ToString());
                    }, DispatcherPriority.ApplicationIdle);
                }
            }
            Thread.Sleep(4000);
        }