void AddRecord_Loaded(object sender, RoutedEventArgs e) { if (hasLoaded) { return; } if (App.APPDB == null) { APPDB = new YingDB("Data Source = isostore:/yingDB.sdf"); } else { APPDB = App.APPDB; } if (App.homeinfo == null) { homeInfo = APPDB.Home_info.FirstOrDefault(); } else { homeInfo = App.homeinfo; } MainTypeList = (from s in APPDB.Main_type where s.Delete == 0 select s ).ToList(); listPickerMainType.ItemsSource = MainTypeList; TextBoxMoneyInt.Focus(); hasLoaded = true; }
void InithomeCompleted(object sender, RunWorkerCompletedEventArgs e) { initResult result = (initResult)e.Result; homeInfo = result.HomeInfo; App.homeinfo = result.HomeInfo; _RecentData = result.RecentData; _pieData = result.pieData; _LineData = result.LineData; PanelHomeInfo.DataContext = homeInfo; pieChart.DataContext = this; LineChart.DataContext = this; ListBoxRecent.ItemsSource = _RecentData; setHistoryData(datePicker.Value.Value); progressBar1.Visibility = Visibility.Collapsed; DBLOCK = false; }
partial void DeleteHome_info(Home_info instance);
partial void UpdateHome_info(Home_info instance);
partial void InsertHome_info(Home_info instance);
void AddRecord_Loaded(object sender, RoutedEventArgs e) { if (hasLoaded) { return; } if (App.APPDB == null) APPDB = new YingDB("Data Source = isostore:/yingDB.sdf"); else APPDB = App.APPDB; if (App.homeinfo == null) homeInfo = APPDB.Home_info.FirstOrDefault(); else homeInfo = App.homeinfo; MainTypeList = (from s in APPDB.Main_type where s.Delete==0 select s ).ToList(); listPickerMainType.ItemsSource = MainTypeList; TextBoxMoneyInt.Focus(); hasLoaded = true; }
/** * 返回_pieData,_lineData,_RecentData,homeinfo */ private void initHomePage(object sender, DoWorkEventArgs e) { YingDB DB = App.APPDB; Home_info HomeInfo = DB.Home_info.FirstOrDefault(); DateTime today = DateTime.Today; initResult result = new initResult(); //获取首页信息 if (HomeInfo.Date.Year == today.Year) { if (HomeInfo.Date.Month != today.Month) { HomeInfo.Mouthsum = 0; HomeInfo.Daysum = 0; } else { if (HomeInfo.Date != today) { HomeInfo.Daysum = 0; } } } else { HomeInfo.Weeksum = 0; HomeInfo.Daysum = 0; } HomeInfo.Date = today; if ((today - HomeInfo.Weekstart).Days > 7) { HomeInfo.Weeksum = 0; HomeInfo.Weekstart = today.AddDays(-(int)today.DayOfWeek); } result.HomeInfo = HomeInfo; //最近数据 ObservableCollection <HData> recentData = new ObservableCollection <HData>( ( from p in APPDB.Outgoing join g in APPDB.Sub_type on p.Sub_id equals g.Id orderby p.Id descending select new HData { Name = g.Name, value = p.Money } ).Take(7) ); result.RecentData = recentData; //7天饼图数据 DateTime start = DateTime.Today.AddDays(-7); ObservableCollection <PData> PieData = new ObservableCollection <PData>( (from p in APPDB.Outgoing where p.Time > start group p by p.Main_id into g join m in APPDB.Main_type on g.Key equals m.Id select new PData { title = m.Name, value = g.Sum(p => p.Money) / 100 } ) ); result.pieData = PieData; //30天线图数据 start = DateTime.Today.AddDays(-30); ObservableCollection <LData> LineData = new ObservableCollection <LData>( (from p in APPDB.Outgoing where p.Time > start group p by p.Time into g select new LData { // time = g.Key.ToShortDateString(), time = "", value = g.Sum(p => p.Money) / 100 } ) ); if (LineData.Count != 0) { LineData[0].time = start.ToShortDateString(); LineData.LastOrDefault().time = DateTime.Today.ToShortDateString(); } result.LineData = LineData; e.Result = result; }