Beispiel #1
0
        public ImportationManagementViewModel() : base()
        {
            listGeneralImportationModel = ListGeneralImportationModel.GetInstance();
            listExpenditureModel        = ListExpenditureModel.GetInstance();
            listExpenditureModel.List.Clear();
            listExpenditureModel.LoadAllExpenditure();


            ////test
            //ListImportation.Add(new ImportationModel("1", DateTime.Now, 125000));
            //ListImportation.Add(new ImportationModel("2", DateTime.Now, 5000));
            //ListImportation.Add(new ImportationModel("3", DateTime.Now, 75000));
            //ListImportation.Add(new ImportationModel("4", DateTime.Now, 25000));
            //ListImportation.Add(new ImportationModel("4", DateTime.Now, 25000));
            //ListImportation.Add(new ImportationModel("4", DateTime.Now, 25000));
            //ListImportation.Add(new ImportationModel("4", DateTime.Now, 25000));
            //ListImportation.Add(new ImportationModel("4", DateTime.Now, 25000));
            //ListImportation.Add(new ImportationModel("4", DateTime.Now, 25000));
            //ListImportation.Add(new ImportationModel("4", DateTime.Now, 25000));

            //listGeneralImportationModel.Add(new GeneralImportationModel(new ImportationModel("1", DateTime.Now, 125000), new ListDetailImportationModel()));
            //listGeneralImportationModel.Add(new GeneralImportationModel(new ImportationModel("2", DateTime.Now, 12000), new ListDetailImportationModel()));
            //listGeneralImportationModel.Add(new GeneralImportationModel(new ImportationModel("3", DateTime.Now, 25000), new ListDetailImportationModel()));
            //listGeneralImportationModel.Add(new GeneralImportationModel(new ImportationModel("4", DateTime.Now, 15000), new ListDetailImportationModel()));
            //listGeneralImportationModel.Add(new GeneralImportationModel(new ImportationModel("5", DateTime.Now, 5000), new ListDetailImportationModel()));
            //listGeneralImportationModel.Add(new GeneralImportationModel(new ImportationModel("6", DateTime.Now, 15000), new ListDetailImportationModel()));
            //listGeneralImportationModel.Add(new GeneralImportationModel(new ImportationModel("7", DateTime.Now, 25000), new ListDetailImportationModel()));


            CreateImportationCommand = new DelegateCommand(CreateImportation);
            DetailCommand            = new DelegateCommand(ShowDetail);
            CheckoutCommand          = new DelegateCommand(ShowCheckoutDialog);
        }
Beispiel #2
0
        public AddImportationViewModel() : base()
        {
            listExpenditureModel             = ListExpenditureModel.GetInstance();
            listDetailImportation            = new ListDetailImportationModel();
            IngridientSelectionChangeCommand = new DelegateCommand <IngridientModel>(IngridientChange);
            CreateImportationCommand         = new DelegateCommand(CreateImportation);
            ClearImportationCommand          = new DelegateCommand(ClearImportation);

            newImportation    = new ImportationModel();
            newImportation.ID = ImportationModel.GenerateID(ListImportationModel.GetInstance().List);

            SelectedIndex = 0;
            SelectedIndex = -1;
            NotifyChanged("SelectedIndex");
        }
        //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();
        }