예제 #1
0
        private Grid MakeGrid(ArrayOfPacked x)
        {
            TextBlock val = new TextBlock()
            {
                Text = (x.income ? "+ " : "- ") + x.val.Text + "$",
                HorizontalAlignment = HorizontalAlignment.Left,
                VerticalAlignment   = VerticalAlignment.Center,
                Margin = new Thickness(10, 0, 0, 0)
            };
            TextBlock cat = new TextBlock()
            {
                Text = x.cat.Text,
                HorizontalAlignment = HorizontalAlignment.Center,
                VerticalAlignment   = VerticalAlignment.Center
            };
            TextBlock dat = new TextBlock()
            {
                Text = x.dat.Text,
                HorizontalAlignment = HorizontalAlignment.Right,
                VerticalAlignment   = VerticalAlignment.Center,
                Margin = new Thickness(0, 0, 10, 0)
            };
            BrushConverter bc   = new BrushConverter();
            string         c    = x.income ? "#0fd628" : "#ff3445";
            Grid           make = new Grid
            {
                Background = (Brush)bc.ConvertFrom(c),
            };

            make.Children.Add(val);
            make.Children.Add(cat);
            make.Children.Add(dat);
            return(make);
        }
예제 #2
0
        void BuildLastTransactions(SQLiteConnection x, string db)
        {
            SQLiteCommand comm   = new SQLiteCommand("SELECT COUNT (*) FROM (SELECT * FROM " + db + " LIMIT 5)", x);
            long          length = (long)comm.ExecuteScalar();

            comm = new SQLiteCommand("SELECT * FROM " + db + "ORDER BY DATETIME([DATE]) DESC LIMIT 5", x);
            SQLiteDataReader read = comm.ExecuteReader();

            ArrayOfPacked[] ArrayOfPacked = new ArrayOfPacked[length];
            int             k             = 0;

            while (read.Read())
            {
                ArrayOfPacked[k] = new ArrayOfPacked(((double)read["VALUE"]).ToString(), (string)read["TYPE"], ((string)read["DATE"]).Remove(10, 9), (string)read["CATEGORY"]);
                LatestTransactions.Children.Add(MakeGrid(ArrayOfPacked[k]));
                k++;
            }
        }