Ejemplo n.º 1
0
        public static List<CashTransactionViewModel> GetSalaryTransactions(int employeeID, DateTime fromDate,
            DateTime throughDate, Context context)
        {
            var result = GetSalaryTransactions(fromDate, throughDate, context);

            return result.Where(x => x.Contragent != null && x.Contragent.ID == employeeID).ToList();
        }
Ejemplo n.º 2
0
        public MainViewModel()
        {
            _context = new Context();

            UpdateCashInHand();

            SoldProductsViewModel = new SoldProductsViewModel(this);
            OnStockProductsViewModel = new OnStockProductsViewModel(this);
            ToRepairProductsViewModel = new ToRepairProductsViewModel(this);
            ToPawnProductsViewModel = new ToPawnProductsViewModel(this);

            SalesmenViewModel = new SalesmenViewModel(this);
            ClientsViewModel = new ClientsViewModel(this);
            RepairersViewModel = new RepairersViewModel(this);
            GuardsViewModel = new GuardsViewModel(this);

            CashTransactionsViewModel = new CashTransactionsViewModel(this);

            MobileOperatorsViewModel = new MobileOperatorsViewModel(this);
            MobileTransactionsViewModel = new MobileTransactionsViewModel(this);

            ReportsViewModel = new ReportsViewModel(_context);

            IsUserAdmin = OperatorManager.Instance.IsUserAdmin;
        }
Ejemplo n.º 3
0
        public static List<SoldTransactionViewModel> GetSoldTransactions(int salesmanID, DateTime fromDate,
            DateTime throughDate,
            Context context)
        {
            var result = GetSoldTransactions(fromDate, throughDate, context);

            return result.Where(x => x.SoldProduct.SalesmanWithProfit.ID == salesmanID).ToList();
        }
Ejemplo n.º 4
0
 public static List<MobileTransactionViewModel> GetMobileTransactions(DateTime fromDate,
     DateTime throughDate, Context context)
 {
     return
         context.MobileTransactions.Where(
             x => x.Transaction.Date >= fromDate && x.Transaction.Date <= throughDate).OrderBy(x => x.MobileOperatorID).ThenBy(x => x.Transaction.Date)
             .ToList()
             .Select(x => new MobileTransactionViewModel(x))
             .ToList();
 }
Ejemplo n.º 5
0
 public static List<CashTransactionViewModel> GetSalaryTransactions(DateTime fromDate, DateTime throughDate,
     Context context)
 {
     return
         context.Transactions.Where(
             x => x.Date >= fromDate && x.Date <= throughDate && x.TypeID == (int)TranType.Salary).OrderBy(x => x.ContragentID).ThenBy(x => x.Date)
             .ToList()
             .Select(x => new CashTransactionViewModel(x))
             .ToList();
 }
Ejemplo n.º 6
0
 public static List<SoldTransactionViewModel> GetSoldTransactions(DateTime fromDate, DateTime throughDate,
     Context context)
 {
     return
         context.Transactions.Where(
             x => x.Date >= fromDate && x.Date <= throughDate && x.TypeID == (int)TranType.Sold && x.ProductID != null).OrderBy(x => x.Product.Model.Category.Name).ThenBy(x => x.Date)
             .ToList()
             .Select(x => new SoldTransactionViewModel(x))
             .ToList();
 }
Ejemplo n.º 7
0
 public static List<CashTransactionViewModel> GetCashTransactions(DateTime fromDate,
     DateTime throughDate, Context context)
 {
     return
         context.Transactions.Where(
             x =>
                 x.Date >= fromDate && x.Date <= throughDate &&
                 (x.TypeID == (int) TranType.CashIn || x.TypeID == (int) TranType.CashOut))
             .OrderBy(x => x.Date)
             .ToList()
             .Select(x => new CashTransactionViewModel(x))
             .ToList();
 }
Ejemplo n.º 8
0
        public ReportsViewModel(Context context)
        {
            _context = context;

            SalesmanReportCommand = new DelegateCommand(SalesmanReport, () => ThroughDate >= FromDate && SelectedSalesman != null);
            GeneralReportCommand = new DelegateCommand(GeneralReport, () => ThroughDate >= FromDate);

            FromDate = DateTime.Today.AddDays(-14);
            ThroughDate = DateTime.Today.AddDays(1);

            Salesmen = context.Salesmen.ToList().Select(x => new SalesmanViewModel(x)).ToList();
            SelectedSalesman = Salesmen.FirstOrDefault();
        }
Ejemplo n.º 9
0
        protected ContragentsViewModel(Context context)
        {
            _context = context;

            Contragents = new ObservableCollection<ContragentViewModel>(GetContragents(context));
            ContragentsView = CollectionViewSource.GetDefaultView(Contragents);

            AddContragentCommand = new DelegateCommand(AddContragent);

            DeleteContragentCommand = new DelegateCommand(DeleteContragent, () => SelectedContragent != null);

            EditContragentCommand = new DelegateCommand(EditContragent, () => SelectedContragent != null);
        }
        private List<TransactionViewModel> GetTransactions(List<int> ids, Context context)
        {
            List<TransactionViewModel> result = new List<TransactionViewModel>();

            foreach (var id in ids)
            {
                var product = context.Products.FirstOrDefault(x => x.ID == id);
                if (product == null) continue;
                if (product.Transactions == null) continue;
                result.AddRange(product.Transactions.OrderBy(t => t.Date).ToList().Select(t => new TransactionViewModel(t)).ToList());
            }

            return result;
        }
Ejemplo n.º 11
0
        private static void Main(string[] args)
        {
            //get the currently logged in user
            WindowsIdentity user = WindowsIdentity.GetCurrent();
            WindowsPrincipal principal = new WindowsPrincipal(user);
            Console.WriteLine(principal.IsInRole(WindowsBuiltInRole.Administrator));
            Console.ReadLine();

            Context context = new Context();

            using (context)
            {
                ExcelExport excel = new ExcelExport();

                excel.GeneralReport("E:\\report.xlsx", DateTime.MinValue, DateTime.MaxValue, context);

                Console.WriteLine("DONE");
            }
        }
Ejemplo n.º 12
0
        private OperatorManager()
        {
            using (var context = new Context())
            {
                WindowsIdentity user = WindowsIdentity.GetCurrent();
                WindowsPrincipal principal = new WindowsPrincipal(user);
                IsUserAdmin = principal.IsInRole(WindowsBuiltInRole.Administrator);

                var name = Environment.UserName.ToLower();

                var salesman = context.Salesmen.FirstOrDefault(x => x.Login.ToLower() == name);
                if (salesman == null)
                {
                    if (IsUserAdmin) CurrentUserID = 0;
                    else throw new Exception("Current user does not exist");
                }
                else CurrentUserID = salesman.ID;
            }
        }
Ejemplo n.º 13
0
        public EditProductDialogViewModel(Context context, List<int> selectedProductIDs, ProductsViewModel productsViewModel)
        {
            _context = context;
            _productsViewModel = productsViewModel;
            _selectedProductIDs = selectedProductIDs;

            var firstSelectedProduct = _context.Products.FirstOrDefault(x => x.ID == selectedProductIDs.FirstOrDefault());

            EditProductCommand = new DelegateCommand(EditProduct, Validate);

            Categories = _context.Categories.Include(x => x.Models).ToList();

            SelectedCategory = Categories.FirstOrDefault(x => x.ID == firstSelectedProduct.Model.CategoryID);
            if (SelectedCategory != null)
                Models = SelectedCategory.Models.Select(x => x.Name).ToList();

            ModelName = firstSelectedProduct.Model.Name;
            SerialNumber = firstSelectedProduct.SerialNumber;
            Notes = firstSelectedProduct.Notes;
            SellingPrice = firstSelectedProduct.SellingPrice;
            DateSellTo = firstSelectedProduct.DateSellTo;
        }
Ejemplo n.º 14
0
 protected override List<ContragentViewModel> GetContragents(Context context)
 {
     return context.Guards.ToList().Select(x => new GuardViewModel(x)).Cast<ContragentViewModel>().ToList();
 }
Ejemplo n.º 15
0
 private List<MobileTransactionViewModel> GetMobileTransactions(Context context)
 {
     return context.MobileTransactions.ToList().Select(x => new MobileTransactionViewModel(x)).ToList();
 }
Ejemplo n.º 16
0
 protected override List<ContragentViewModel> GetContragents(Context context)
 {
     return context.Salesmen.ToList().Select(x => new SalesmanViewModel(x)).Cast<ContragentViewModel>().ToList();
 }
Ejemplo n.º 17
0
        protected override List<ProductViewModel> GetProducts(Context context)
        {
            var notSoldProducts =
                context.Products.Where(x => x.Transactions.Any()).ToList()
                    .Where(x => x.Transactions.OrderBy(y => y.Date).Last().TypeID != (int)TranType.Sold);

            return
                notSoldProducts.Select(x => new ToPawnProductViewModel(x))
                    .Where(y => y.Origin == TranType.ToPawn)
                    .Cast<ProductViewModel>()
                    .ToList();
        }
Ejemplo n.º 18
0
        protected override List<ProductViewModel> GetProducts(Context context)
        {
            var notSoldProducts =
                context.Products.Where(x => x.Transactions.Any()).ToList()
                    .Where(x => x.Transactions.OrderBy(y => y.Date).Last().TypeID != (int) TranType.Sold);

            return
                notSoldProducts.GroupBy(x => new ModelSerialNumberStatusPriceBoughtGroup(x))
                    .Select(x => new OnStockProductViewModel(x))
                      .Where(y => y.Origin == TranType.Bought)
                    .Cast<ProductViewModel>()
                    .ToList();

            //return
            //    notSoldProducts.Select(x => new OnStockProductViewModel(x))
            //        .Where(y => y.Origin == TranType.Bought)
            //        .Cast<ProductViewModel>()
            //        .ToList();
        }
Ejemplo n.º 19
0
 private List<MobileOperatorViewModel> GetMobileOperators(Context context)
 {
     return
         context.MobileOperators.ToList().Select(x => new MobileOperatorViewModel(x)).ToList();
 }
Ejemplo n.º 20
0
 protected abstract List<ProductViewModel> GetProducts(Context context);
Ejemplo n.º 21
0
 private List<CashTransactionViewModel> GetCashTransactions(Context context)
 {
     return
         context.Transactions.Where(
             x => x.TypeID == (int)TranType.CashIn || x.TypeID == (int)TranType.CashOut || x.TypeID == (int)TranType.Coffee || x.TypeID == (int)TranType.Salary).ToList()
             .Select(x => new CashTransactionViewModel(x)).ToList();
 }
Ejemplo n.º 22
0
 protected override List<ContragentViewModel> GetContragents(Context context)
 {
     return context.Repairers.ToList().Select(x => new RepairerViewModel(x)).Cast<ContragentViewModel>().ToList();
 }
 public ShowAllTransactionsDialogViewModel(Context context, List<int> ids, ProductsViewModel productsViewModel)
 {
     var transactions = new ObservableCollection<TransactionViewModel>(GetTransactions(ids, context));
     TransactionsView = CollectionViewSource.GetDefaultView(transactions);
 }
Ejemplo n.º 24
0
 protected abstract List<ContragentViewModel> GetContragents(Context context);
Ejemplo n.º 25
0
 public static List<CashTransactionViewModel> GetCashTransactions(int salesmanID, DateTime fromDate,
     DateTime throughDate, Context context)
 {
     return GetCashTransactions(fromDate, throughDate, context).Where(x => x.Salesman.ID == salesmanID).ToList();
 }