public ListProductViewModel(Action <object, object[]> navigate, object[] parameters) : this() { this.navigate = navigate; if (parameters == null) { newBill = new BillModel(); newBill.ID = BillModel.GenerateID(ListBillModel.GetInstance().List); } else { index = (int)parameters[0]; newBill = (BillModel)ListGeneralBillModel.GetInstance().List[index].Bill; InputDeskNo = newBill.DeskNo; listDetailBill = (ListDetailBillModel)ListGeneralBillModel.GetInstance().List[index].ListDetailBill; } }
//private ObservableCollection<String> timeline; //private ObservableCollection<DateTime> listDate; public ReportManagementViewModel() : base() { listBillModel = ListBillModel.GetInstance(); listBillModel.LoadAllBill(); listRevenueModel = ListRevenueModel.GetInstance(); listExpenditureModel = ListExpenditureModel.GetInstance(); ReportCollection = new LiveCharts.SeriesCollection(); MonthRevenueLabels = new ObservableCollection <String>(); MonthExpenditureLabels = new ObservableCollection <String>(); MonthReportLabels = new ObservableCollection <string>(); revenue_month = new ObservableCollection <int>(); revenue_year = new ObservableCollection <int>(); expenditure_month = new ObservableCollection <int>(); expenditure_year = new ObservableCollection <int>(); overview_month = new ObservableCollection <int>(); overview_year = new ObservableCollection <int>(); // Calculate revenue revenue = new ObservableCollection <double>(); ObservableCollection <String[]> result_revenue = ListBillModel.GetRevenueByDayAndMonth(); for (int i = 0; i < result_revenue.Count; i++) { //Debug.LogOutput(result_revenue[i][0]); String item_timeline = result_revenue[i][0].ToString(); double item_revenue = Double.Parse(result_revenue[i][1].ToString()); MonthRevenueLabels.Add(item_timeline); revenue_month.Add(Int32.Parse(result_revenue[i][2].ToString())); revenue_year.Add(Int32.Parse(result_revenue[i][3].ToString())); revenue.Add(item_revenue); } ReportCollection.Add(new ColumnSeries() { Title = "Tổng thu", Values = new ChartValues <double>(revenue) }); // Calculate expenditure expenditure = new ObservableCollection <double>(); ObservableCollection <String[]> result_expenditure = ListImportationModel.GetExpenditureByDayAndMonth(); for (int i = 0; i < result_expenditure.Count; i++) { Debug.LogOutput(result_expenditure[i][0]); String item_timeline = result_expenditure[i][0].ToString(); double item_expenditure = Double.Parse(result_expenditure[i][1].ToString()); MonthExpenditureLabels.Add(item_timeline); expenditure_month.Add(Int32.Parse(result_expenditure[i][2].ToString())); expenditure_year.Add(Int32.Parse(result_expenditure[i][3].ToString())); expenditure.Add(item_expenditure); } ReportCollection.Add(new ColumnSeries() { Title = "Tổng chi", Values = new ChartValues <double>(expenditure) }); Formatter = value => value.ToString("N"); // Calculate for MonthReportLabels: find min and max timeline ObservableCollection <string[]> overview_temp = new ObservableCollection <string[]>(); overview_temp = AdvancedQuery.GetAllTimeline(); for (int i = 0; i < overview_temp.Count; i++) { MonthReportLabels.Add(overview_temp[i][0]); overview_month.Add(Int32.Parse(overview_temp[i][1])); overview_year.Add(Int32.Parse(overview_temp[i][2])); } // Export Excel ExportExcelCommand = new DelegateCommand(ExportExcel); // Month report combobox MonthReportChangeCommand = new DelegateCommand <string>(MonthReportChange); // Month product combobox NotifyChanged("SelectedMonthProduct"); MonthProductChangeCommand = new DelegateCommand <string>(MonthProductChange); // init product chart ProductSeries = new LiveCharts.SeriesCollection(); // Month product combobox NotifyChanged("SelectedMonthIngredient"); MonthIngredientChangeCommand = new DelegateCommand <string>(MonthIngredientChange); // init ingredient chart IngredientSeries = new LiveCharts.SeriesCollection(); }