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(); }
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; }
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(); }
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(); }
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(); }
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(); }
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(); }
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(); }
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; }
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"); } }
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; } }
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; }
protected override List<ContragentViewModel> GetContragents(Context context) { return context.Guards.ToList().Select(x => new GuardViewModel(x)).Cast<ContragentViewModel>().ToList(); }
private List<MobileTransactionViewModel> GetMobileTransactions(Context context) { return context.MobileTransactions.ToList().Select(x => new MobileTransactionViewModel(x)).ToList(); }
protected override List<ContragentViewModel> GetContragents(Context context) { return context.Salesmen.ToList().Select(x => new SalesmanViewModel(x)).Cast<ContragentViewModel>().ToList(); }
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(); }
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(); }
private List<MobileOperatorViewModel> GetMobileOperators(Context context) { return context.MobileOperators.ToList().Select(x => new MobileOperatorViewModel(x)).ToList(); }
protected abstract List<ProductViewModel> GetProducts(Context context);
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(); }
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); }
protected abstract List<ContragentViewModel> GetContragents(Context context);
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(); }