protected async override void OnAppearing() { base.OnAppearing(); var hoaDonStore = new SQLiteHoaDonStore(DependencyService.Get <ISQLite>()); var pageService = new PageService(); ViewModel = new ThongKeDoanhThuViewModel(hoaDonStore, pageService); ViewModel.LoadDataCommad.Execute(null); chartView.Chart = new LineChart { ValueLabelOrientation = Orientation.Horizontal, Entries = await ViewModel.LoadChartAsync(), LabelTextSize = 30 }; chartRadar.Chart = new RadarChart { Entries = await ViewModel.LoadChartAsync(), }; }
ThongKeDoanhThuViewModel ThongKeDoanhThu() { var data = SelectRows("EXEC sp_DonHang_ThongKeDoanhThuTheoThang"); string thoiGian = ""; string soLuong = ""; string thanhTien = ""; foreach (DataRow dr in data.Rows) { thoiGian += DateTime.Parse(dr["ThoiGian"].ToString()).ToString("MM/yyyy") + ","; soLuong += dr["SoLuongSanPham"].ToString() + ","; thanhTien += dr["ThanhTien"].ToString() + ","; } var item = new ThongKeDoanhThuViewModel() { SoLuong = soLuong.Substring(0, soLuong.Length - 1), ThoiGian = thoiGian.Substring(0, thoiGian.Length - 1), ThanhTien = thanhTien.Substring(0, thanhTien.Length - 1) }; return(item); }