public void DataBind(LiveStreamModel model)
 {
     ViewModel = model;
     //DataContext = (LiveStreamModel)model;
     LsTodayControl.DataBind(model);
     LsCurrentMonthControl.DataBind(model);
 }
 public LiveStreamControl()
 {
     ViewModel = (LiveStreamModel)this.DataContext;
     InitializeComponent();
     LsCurrentMonthControl.DataContext = ViewModel;
     LsTodayControl.DataContext = ViewModel;
 }
 public void DataBind(LiveStreamModel model)
 {
     ViewModel = (LiveStreamModel)model;
     this.DataContext = (LiveStreamModel)model;
     if (ViewModel.CycleMoneyDiagram != null)
     {
         LoadDiagram(ref chart);
     }
 }
 public void DataBind(LiveStreamModel model)
 {
     ViewModel = (LiveStreamModel)model;
     this.DataContext = (LiveStreamModel)model;
     if (ViewModel.CurrentMonthDiagram != null && ViewModel.LastMonthDiagram != null)
     {
         LoadDiagram(ref chart);
     }
     UpdateColors();
 }
Exemplo n.º 5
0
 public MainModel()
 {
     InfoModel       = new InfoModel();
     LiveStreamModel = new LiveStreamModel();
 }
Exemplo n.º 6
0
        public static LiveStreamModel GetLiveStream(DateTime startDate, DateTime endDate, MainModel MainModel)
        {
            //var MainModel = new MainModel();

            //MainModel.Sales = Accessors.GetSales(startDate, endDate);

            var model = new LiveStreamModel();

            var tmSpan = MainAccessor.GetTimeSpan();

            //TODO поставить текущую дату
            var stTodayDate = new DateTime(4016, 02, 01);
            var endTodayDate = new DateTime(4016, 02, 01).AddHours(23).AddMinutes(59).AddSeconds(59); //DateTime.Today.AddYears(tmSpan);

            MainModel.StartDate = new DateTime(stTodayDate.Year, stTodayDate.Month, 01);
            MainModel.EndDate = new DateTime(stTodayDate.Month != 12 ? stTodayDate.Year : stTodayDate.Year + 1, stTodayDate.Month != 12 ? stTodayDate.Month + 1 : 01, 01);
            
            // Сегодня
            var sales = Accessors.GetSales(stTodayDate, endTodayDate, true);
            model.SalesToday = sales.Select(i => i.Sales.Sum(j => j.SalesWithoutNDS)).Sum();
            model.GrossProfitToday = model.SalesToday - sales.Select(i => i.Sales.Sum(j => j.CostPrise)).Sum();
            model.ProfitabilityToday = model.SalesToday != 0
                    ? (model.GrossProfitToday / model.SalesToday) * 100
                    : 0;

            MainModel.RegGroups = MainAccessor.GetAllGroups();// группы
            MainModel.ADDSTranz = Accessors.GetAddsTranz(stTodayDate, endTodayDate, MainModel.RegGroups ?? new List<RefGroupsEnt>(), new List<string> { "00002" });
            model.PaymentCustomersToday = MainModel.ADDSTranz.Sum(_ => _.Money);

            MainModel.StartTranz = MainAccessor.GetAllTrans(stTodayDate, null); // Вытащим сразу все транзакции, отдельным запросом
            MainModel.EndTranz = MainAccessor.GetAllTrans(stTodayDate, endTodayDate);

            //MainModel.StartTranzOriginal = MainAccessor.GetAllTransOriginal(MainModel.StartDate, null);
            //MainModel.EndTranzOriginal = MainAccessor.GetAllTransOriginal(MainModel.StartDate, MainModel.EndDate);

            MainModel.BusinessResults = Accessors.GetBusinessResults(MainModel);

            model.DebtOfCustomers = MainModel.BusinessResults.DebtsOfCustomersAndOverpaymentsEnd;
            model.GoodsBalance = MainModel.BusinessResults.GoodsEnd;
            model.PayblesToSupplier = MainModel.BusinessResults.PayablesToSuppliersShortTermDebtsEnd;

            model.CycleMoneyDiagram = new Dictionary<string, decimal>();
            model.CycleMoneyDiagram.Add("Деньги в кассе", MainModel.BusinessResults.CashInCashBoxEnd);
            model.CycleMoneyDiagram.Add("Деньги на счетах", MainModel.BusinessResults.MoneyInTheBankAccountsEnd);
            model.MoneyTotal = MainModel.BusinessResults.CashInCashBoxEnd + MainModel.BusinessResults.MoneyInTheBankAccountsEnd;

            model.CoveringCurrentDebtMoney = (MainModel.BusinessResults.CashInCashBoxEnd + MainModel.BusinessResults.MoneyInTheBankAccountsEnd
               + MainModel.BusinessResults.DepositsEnd) / (MainModel.BusinessResults.CurrentDebtEnd != 0 ? MainModel.BusinessResults.CurrentDebtEnd : 1) * 100;

            model.CoveringCurrentDebtMoneyAndCustomerDebt = (MainModel.BusinessResults.CashInCashBoxEnd + MainModel.BusinessResults.MoneyInTheBankAccountsEnd
                + MainModel.BusinessResults.DepositsEnd + MainModel.BusinessResults.DebtsOfCustomersAndOverpaymentsEnd)
                / (MainModel.BusinessResults.CurrentDebtEnd != 0 ? MainModel.BusinessResults.CurrentDebtEnd : 1) * 100;

            model.CoveringCurrentDebtOfCurrentAssets = MainModel.BusinessResults.CirculatingAssetsEnd
                / (MainModel.BusinessResults.CurrentDebtEnd != 0 ? MainModel.BusinessResults.CurrentDebtEnd : 1) * 100;

            // Текущий месяц            
            sales = Accessors.GetSales(MainModel.StartDate, MainModel.EndDate, true);
            model.SalesMonth = sales.Select(i => i.Sales.Sum(j => j.SalesWithoutNDS)).Sum();
            model.GrossProfitMonth = model.SalesMonth - sales.Select(i => i.Sales.Sum(j => j.CostPrise)).Sum();
            model.ProfitabilityMonth = model.SalesMonth != 0
                    ? (model.GrossProfitMonth / model.SalesMonth) * 100
                    : 0;

            MainModel.ADDSTranz = Accessors.GetAddsTranz(MainModel.StartDate, MainModel.EndDate, MainModel.RegGroups ?? new List<RefGroupsEnt>(), new List<string> { "00002" });
            model.PaymentCustomersMonth = MainModel.ADDSTranz.Sum(_ => _.Money);
            model.LastMonthDiagram = new Dictionary<string, decimal>();
            model.LastMonthDiagram.Add("Продажи", model.SalesMonth);
            model.LastMonthDiagram.Add("Валовая прибыль", model.GrossProfitMonth);
            model.LastMonthDiagram.Add("Оплата покупателя", model.PaymentCustomersMonth);

            // Прошлый месяц
            sales = Accessors.GetSales(MainModel.StartDate.Month != 1 ?
                                        new DateTime(MainModel.StartDate.Year, MainModel.StartDate.Month - 1, 01) :
                                        new DateTime(MainModel.StartDate.Year - 1, 12, 01)
                                        , MainModel.StartDate, true);
            model.SalesPastMonth = sales.Select(i => i.Sales.Sum(j => j.SalesWithoutNDS)).Sum();
            model.GrossProfitPastMonth = model.SalesPastMonth - sales.Select(i => i.Sales.Sum(j => j.SalesWithoutNDS - j.CostPrise)).Sum();

            MainModel.ADDSTranz = Accessors.GetAddsTranz(MainModel.StartDate.Month != 1 ?
                                                            new DateTime(MainModel.StartDate.Year, MainModel.StartDate.Month - 1, 01) :
                                                            new DateTime(MainModel.StartDate.Year - 1, 12, 01)
                                                            , MainModel.StartDate, MainModel.RegGroups ?? new List<RefGroupsEnt>(), new List<string> { "00002" });
            model.PaymentCustomersPastMonth = MainModel.ADDSTranz.Sum(_ => _.Money);

            model.CurrentMonthDiagram = new Dictionary<string, decimal>();
            model.CurrentMonthDiagram.Add("Продажи", model.SalesPastMonth);
            model.CurrentMonthDiagram.Add("Валовая прибыль", model.GrossProfitPastMonth);
            model.CurrentMonthDiagram.Add("Оплата покупателя", model.PaymentCustomersPastMonth);

            model.AverageGrossProfit = model.GrossProfitPastMonth - model.GrossProfitMonth;
            model.AverageSales = model.SalesPastMonth - model.SalesMonth;
            model.AveragePayment = model.PaymentCustomersPastMonth - model.PaymentCustomersMonth;

            model.CountDaysToEndOfMonth = DateTime.DaysInMonth(DateTime.Today.Year, DateTime.Today.Month) - DateTime.Today.Day + 1;

            MainModel.StartDate = startDate;
            MainModel.EndDate = endDate;

            return model;
        }
Exemplo n.º 7
0
 public MainModel()
 {
     InfoModel = new InfoModel();
     LiveStreamModel = new LiveStreamModel();
 }