void chart1_MouseDown(object s, MouseEventArgs e)
        {
            var htr = chart1.HitTest(e.X, e.Y);

            if (htr.ChartElementType == ChartElementType.DataPoint)
            {
                using (var db = A0DbContext.Create())
                {
                    var st  = DateTime.FromOADate(htr.Series.Points[htr.PointIndex].XValue);
                    var txn = db.TxCoreV2.Where(r => r.TxDate == st).ToList();
                    if (txn == null)
                    {
                        MessageBox.Show(this, "Not good: \r\n\tNo txs for this date found.");
                    }
                    else
                    {
                        //db.Laps.Load();
                        var dlg = new TxnDetailsVw
                        {
                            ChartRef   = chart1,
                            PointIndex = htr.PointIndex,
                            HTR        = htr,
                            Txns       = txn
                        };
                        dlg.Show(); // MessageBox.Show(this, "DataPoint.Dialog popup is not ready\r\n\nSelected Element is: " + result.ChartElementType.ToString());
                    }
                }
            }
            //else if (result.ChartElementType != ChartElementType.Nothing)
            //{
            //	MessageBox.Show(this, "Selected Element is: " + result.ChartElementType.ToString());
            //}
        }
        async Task reload()
        {
            _db         = A0DbContext.Create();
            tbComp.Text = VerHelper.CurVerStr(A0DbContext.SolutionCfg);

            try
            {
                await _db.TxMoneySrcs.LoadAsync();

                await _db.BalAmtHists.LoadAsync();

                await _db.TxCoreV2.LoadAsync(); //full history is here: await _db.Vw_TxCore.LoadAsync(); - is it worth it/useful

                var groupByMnySrc = _db.TxCoreV2.Local.GroupBy(c => new { c.TxMoneySrcId }).Select(g => new { g.Key.TxMoneySrcId, Count = g.Count(), LastTx = g.Max(r => r.TxDate) }).ToList();

                //var usedMnySrcList = _db.TxCoreV2.Local.Select(r => r.TxMoneySrcId).Distinct().ToList();        //lbMnySrc_Flas.ItemsSource = _db.TxMoneySrcs.Local.Where(r => usedMnySrcList.Contains(r.Id)).OrderBy(r => r.Fla);
                lbMnySrc_Flas.ItemsSource = _db.TxMoneySrcs.Local.
                                            Join(groupByMnySrc, s => s.Id, c => c.TxMoneySrcId, (s, c) => new { s, c }).
                                            Select(r => new Tms(r.s.Id, r.s.Fla, r.s.Name,
                                                                r.s.IniBalance,
                                                                r.c.LastTx,
                                                                $"{r.s.Notes}\r\nCount: \t {r.c.Count}\r\nLast: \t {r.c.LastTx:yyy-MM-dd}"
                                                                ));

                lbMnySrc_Flas.Focus();
            }
            catch (Exception ex) { ex.Log(); }
        }
        private void Window_Loaded(object sender, RoutedEventArgs e)
        {
            A0DbContext db = A0DbContext.Create();

            //var lq = _db.Machines.Include(m => m.Feeds).ToList();
            //var blog1 = _db.Machines.Where(m => m.Id == " V AIO1").Include(m => m.Feeds).FirstOrDefault();			// Load one blogs and its related posts     - http://msdn.microsoft.com/en-ca/data/jj574232.aspx

            //_db.Machines.Where(m => m.Id == "v aio1").Load();//ok: ignore case SQL style.	+	((CollectionViewSource)(this.FindResource("machineViewSource"))).Source = _db.Machines.Local; //!!! ==> only case-sensitive matches


            db.Feeds.Where(r => /*string.Compare(r.HostMachineId, Environment.MachineName, true) == 0 &&*/ r.IsActive && !r.IsDeleted).Load(); ((CollectionViewSource)(this.FindResource("feedViewSource"))).Source = db.Feeds.Local;
        }
Example #4
0
        async void onLoaded(object s, RoutedEventArgs e)
        {
            _db = A0DbContext.Create();
            await Task.Yield();                   // displays window now - not after db loads.

            await _db.Vw_TxCore.LoadAsync();      // TxCoreV2 would show the MoneySrc.Name in Binding

            await _db.Vw_Exp_Hist_vs_Last.LoadAsync();

            dgTxVs.ItemsSource = _db.Vw_Exp_Hist_vs_Last.Local.OrderBy(r => r.Name).ThenBy(r => r.TaxLiq__);
            dgTxVs.Focus();
            Bpr.BeepShort();
        }
        async void onBalanceToDb(object s, RoutedEventArgs e)
        {
            try
            {
                bBalance.Visibility = Visibility.Collapsed;
                await Task.Delay(9);

                using (var db = A0DbContext.Create())
                {
                    var tmsdb = db.TxMoneySrcs.FirstOrDefault(r => r.Id == _tmsId);
                    if (tmsdb != null)
                    {
                        tmsdb.IniBalance += _balDelta;
                        var rowsSaved = DbSaveMsgBox.CheckAskSave(db);
                        tBalance.Text = $"{rowsSaved} row saved.";
                        await reload();

                        chartuc.RmvSeries(_tmsFla);
                        addSeries(tmsdb.Id, tmsdb.Fla, tmsdb.IniBalance);
                    }
                }
            }
            finally { /*bBalance.Visibility = Visibility.Visible;*/ }
        }