コード例 #1
0
 private static IEnumerable <Ticket> GetTickets(IWorkspace workspace)
 {
     try
     {
         if (CurrentWorkPeriod.StartDate == CurrentWorkPeriod.EndDate)
         {
             return(Dao.Query <Ticket>(x => x.LastPaymentDate >= CurrentWorkPeriod.StartDate,
                                       x => x.Payments, x => x.TaxServices,
                                       x => x.Discounts, x => x.TicketItems,
                                       x => x.TicketItems.Select(y => y.Properties)));
         }
         return
             (Dao.Query <Ticket>(x =>
                                 x.LastPaymentDate >= CurrentWorkPeriod.StartDate && x.LastPaymentDate < CurrentWorkPeriod.EndDate,
                                 x => x.Payments, x => x.TaxServices, x => x.Discounts, x => x.TicketItems.Select(y => y.Properties)));
     }
     catch (SqlException)
     {
         if (CurrentWorkPeriod.StartDate == CurrentWorkPeriod.EndDate)
         {
             return(workspace.All <Ticket>(x => x.LastPaymentDate >= CurrentWorkPeriod.StartDate));
         }
         return
             (workspace.All <Ticket>(x =>
                                     x.LastPaymentDate >= CurrentWorkPeriod.StartDate && x.LastPaymentDate < CurrentWorkPeriod.EndDate));
     }
 }
コード例 #2
0
        private IEnumerable <Department> GetAllDepartments()
        {
            IList <Department> result = new List <Department>(_workspace.All <Department>().OrderBy(x => x.Name));

            result.Insert(0, Department.All);
            return(result);
        }
コード例 #3
0
ファイル: TerminalViewModel.cs プロジェクト: yurseli/sambapos
 protected override void Initialize(IWorkspace workspace)
 {
     _workspace       = workspace;
     Printers         = workspace.All <Printer>();
     PrinterTemplates = workspace.All <PrinterTemplate>();
     PrintJobs        = new ObservableCollection <PrintJob>(Model.PrintJobs);
     Departments      = new ObservableCollection <Department>(workspace.All <Department>());
 }
コード例 #4
0
        public int GetAssignedUserbycurrentuser()
        {
            int userId           = GetCurrentUser().Id;
            IList <AssignJob> AJ = _workspace.All <AssignJob>(x => x.AssignedTo == userId && x.Status == true).ToList();

            if (AJ.Count != 0)
            {
                return(AJ[0].AssignedTo);
            }
            else
            {
                return(0);
            }
        }
コード例 #5
0
ファイル: InventoryService.cs プロジェクト: hpbaotho/sambapos
        private static void CreatePeriodicConsumptionItems(PeriodicConsumption pc, IWorkspace workspace)
        {
            var previousPc = GetPreviousPeriodicConsumption(workspace);
            var transactionItems = GetTransactionItems();
            foreach (var inventoryItem in workspace.All<InventoryItem>())
            {
                var iItem = inventoryItem;
                var pci = new PeriodicConsumptionItem { InventoryItem = inventoryItem };
                pci.UnitMultiplier = pci.InventoryItem.TransactionUnitMultiplier > 0 ? pci.InventoryItem.TransactionUnitMultiplier : 1;
                pc.PeriodicConsumptionItems.Add(pci);
                var previousCost = 0m;
                if (previousPc != null)
                {
                    var previousPci = previousPc.PeriodicConsumptionItems.SingleOrDefault(x => x.InventoryItem.Id == iItem.Id);
                    if (previousPci != null) pci.InStock =
                        previousPci.PhysicalInventory != null
                        ? previousPci.PhysicalInventory.GetValueOrDefault(0)
                        : previousPci.GetInventoryPrediction();
                    if (previousPci != null)
                        previousCost = previousPci.Cost * pci.InStock;
                }
                var tim = transactionItems.Where(x => x.InventoryItem.Id == iItem.Id);
                pci.Purchase = tim.Sum(x => x.Quantity * x.Multiplier) / pci.UnitMultiplier;
                var totalPrice = tim.Sum(x => x.Price * x.Quantity);
                if (pci.InStock > 0 || pci.Purchase > 0)
                {
                    pci.Cost = pci.InStock > 0
                                   ? decimal.Round((totalPrice + previousCost)/(pci.InStock + pci.Purchase), 2)
                                   : decimal.Round(totalPrice/pci.Purchase, 2);
                }

            }
        }
コード例 #6
0
        private static IEnumerable <Entity> ImportPlainText(string[] values, IWorkspace workspace)
        {
            IList <Entity> result = new List <Entity>();

            if (values.Length > 0)
            {
                var        entityTypes       = workspace.All <EntityType>().ToList();
                EntityType currentEntityType = null;

                foreach (var value in values)
                {
                    if (value.StartsWith("#"))
                    {
                        currentEntityType = CreateEntityType(value, entityTypes);
                    }
                    else if (currentEntityType != null)
                    {
                        var entity = CreateEntity(workspace, value, currentEntityType);
                        if (entity != null)
                        {
                            result.Add(entity);
                        }
                    }
                }
            }
            return(result);
        }
コード例 #7
0
        private void OnSelectActions(string obj)
        {
            IList <IOrderable> selectedValues = new List <IOrderable>(Model.Actions);
            var selectedIds           = selectedValues.Select(x => ((ActionContainer)x).AppActionId);
            IList <IOrderable> values = new List <IOrderable>(_workspace.All <AppAction>(x => !selectedIds.Contains(x.Id)).Select(x => new ActionContainer(x)));

            var choosenValues = InteractionService.UserIntraction.ChooseValuesFrom(values, selectedValues, Resources.ActionList,
                                                                                   Resources.SelectActions, Resources.Action, Resources.Actions);

            foreach (var action in Model.Actions.ToList())
            {
                var laction = action;
                if (choosenValues.FirstOrDefault(x => ((ActionContainer)x).AppActionId == laction.AppActionId) == null)
                {
                    if (action.Id > 0)
                    {
                        _workspace.Delete(action);
                    }
                }
            }

            Model.Actions.Clear();
            choosenValues.Cast <ActionContainer>().ToList().ForEach(x => Model.Actions.Add(x));
            _actions = new ObservableCollection <ActionContainerViewModel>(Model.Actions.Select(x => new ActionContainerViewModel(x, this)));

            RaisePropertyChanged("Actions");
        }
コード例 #8
0
ファイル: EntityCreator.cs プロジェクト: GHLabs/SambaPOS-3
        private static IEnumerable<Entity> ImportPlainText(string[] values, IWorkspace workspace)
        {
            IList<Entity> result = new List<Entity>();
            if (values.Length > 0)
            {
                var entityTypes = workspace.All<EntityType>().ToList();
                EntityType currentEntityType = null;

                foreach (var value in values)
                {
                    if (value.StartsWith("#"))
                    {
                        currentEntityType = CreateEntityType(value, entityTypes);
                    }
                    else if (currentEntityType != null)
                    {
                        var entity = CreateEntity(workspace, value, currentEntityType);
                        if (entity != null)
                        {
                            result.Add(entity);
                        }
                    }
                }
            }
            return result;
        }
コード例 #9
0
ファイル: MainDataContext.cs プロジェクト: yurseli/sambapos
            public void ResetTableData(Ticket ticket)
            {
                var tables = _workspace.All <Table>(x => x.TicketId == ticket.Id);

                foreach (var table in tables)
                {
                    table.TicketId       = 0;
                    table.IsTicketLocked = false;
                }
            }
コード例 #10
0
        private void OnAddTaxServiceTemplate(string obj)
        {
            var selectedValues =
                InteractionService.UserIntraction.ChooseValuesFrom(_workspace.All <TaxServiceTemplate>().ToList <IOrderable>(),
                                                                   Model.TaxServiceTemplates.ToList <IOrderable>(), Resources.TaxServiceTemplates, string.Format(Resources.ChooseTaxServicesForDepartmentHint_f, Model.Name),
                                                                   Resources.TaxServiceTemplate, Resources.TaxServiceTemplates);

            foreach (TaxServiceTemplate selectedValue in selectedValues)
            {
                if (!Model.TaxServiceTemplates.Contains(selectedValue))
                {
                    Model.TaxServiceTemplates.Add(selectedValue);
                }
            }

            _taxServiceTemplates = new ObservableCollection <TaxServiceTemplateViewModel>(GetTaxServiceTemplates(Model));

            RaisePropertyChanged("TaxServiceTemplates");
        }
コード例 #11
0
        private void DeleteEntity <T>(IWorkspace workspace, params string[] commandName) where T : class, IEntityClass
        {
            var name = GetName(commandName, 0);
            var acs  = workspace.All <T>(x => x.Name == name).ToList();

            if (acs.Any())
            {
                foreach (var ac in acs)
                {
                    workspace.Delete(ac);
                    workspace.CommitChanges();
                }
            }

            var name2 = GetName(commandName, 1);

            acs = workspace.All <T>(x => x.Name == name2).ToList();
            if (acs.Any())
            {
                foreach (var ac in acs)
                {
                    workspace.Delete(ac);
                    workspace.CommitChanges();
                }
            }

            var name3 = GetName(commandName, 2);

            acs = workspace.All <T>(x => x.Name == name3).ToList();
            if (acs.Any())
            {
                foreach (var ac in acs)
                {
                    workspace.Delete(ac);
                    workspace.CommitChanges();
                }
            }
        }
コード例 #12
0
        private ObservableCollection <PriceViewModel> CreateItems()
        {
            var tags = Dao.Select <MenuItemPriceDefinition, string>(x => x.PriceTag, x => x.Id > 0).Distinct().ToArray();

            var result = new ObservableCollection <PriceViewModel>(
                _workspace.All <MenuItem>(x => x.Portions.Select(y => y.Prices))
                .SelectMany(y => y.Portions, (mi, pt) => new PriceViewModel(pt, mi.Name, tags)));

            foreach (var tag in tags)
            {
                var portions = result.Where(x => !x.Model.Prices.Select(y => y.PriceTag).Contains(tag)).ToList();
                portions.ForEach(x => x.AddPrice(tag));
            }

            return(result);
        }
コード例 #13
0
        private void OnAddPropertyGroup(string obj)
        {
            var selectedValues =
                InteractionService.UserIntraction.ChooseValuesFrom(_workspace.All <MenuItemPropertyGroup>().ToList <IOrderable>(),
                                                                   Model.PropertyGroups.ToList <IOrderable>(), Resources.PropertyGroups, string.Format(Resources.SelectPropertyGroupsHint_f, Model.Name),
                                                                   Resources.PropertyGroup, Resources.PropertyGroups);

            foreach (MenuItemPropertyGroup selectedValue in selectedValues)
            {
                if (!Model.PropertyGroups.Contains(selectedValue))
                {
                    Model.PropertyGroups.Add(selectedValue);
                }
            }

            _propertyGroups = new ObservableCollection <MenuItemPropertyGroupViewModel>(GetProperties(Model));

            RaisePropertyChanged("PropertyGroups");
        }
コード例 #14
0
        public IEnumerable <Account> BatchCreateAccounts(string[] values, IWorkspace workspace)
        {
            IList <Account> result = new List <Account>();

            if (values.Length > 0)
            {
                var         templates       = workspace.All <AccountType>().ToList();
                AccountType currentTemplate = null;

                foreach (var item in values)
                {
                    if (item.StartsWith("#"))
                    {
                        var templateName = item.Trim('#', ' ');
                        currentTemplate = templates.SingleOrDefault(x => x.Name.ToLower() == templateName.ToLower());
                        if (currentTemplate == null)
                        {
                            using (var w = WorkspaceFactory.Create())
                            {
                                currentTemplate = new AccountType {
                                    Name = templateName
                                };
                                w.Add(currentTemplate);
                                w.CommitChanges();
                            }
                        }
                    }
                    else if (currentTemplate != null)
                    {
                        var accountName = item.ToLower().Trim();
                        if (workspace.Single <Account>(x => x.Name.ToLower() == accountName) == null)
                        {
                            var account = new Account {
                                Name = item, AccountTypeId = currentTemplate.Id
                            };
                            result.Add(account);
                        }
                    }
                }
            }
            return(result);
        }
コード例 #15
0
ファイル: TerminalViewModel.cs プロジェクト: yurseli/sambapos
        private void OnAddPrintJob(string obj)
        {
            IList <IOrderable> values = new List <IOrderable>(_workspace.All <PrintJob>()
                                                              .Where(x => PrintJobs.SingleOrDefault(y => y.Id == x.Id) == null));

            IList <IOrderable> selectedValues = new List <IOrderable>(PrintJobs.Select(x => x));

            var choosenValues =
                InteractionService.UserIntraction.ChooseValuesFrom(values, selectedValues, Resources.PrintJobList,
                                                                   string.Format(Resources.SelectPrintJobsForTerminalHint_f, Model.Name), Resources.PrintJob, Resources.PrintJobs);

            PrintJobs.Clear();
            Model.PrintJobs.Clear();

            foreach (PrintJob choosenValue in choosenValues)
            {
                Model.PrintJobs.Add(choosenValue);
                PrintJobs.Add(choosenValue);
            }
        }
コード例 #16
0
        private void OnSelectTables(string obj)
        {
            IList <IOrderable> values = new List <IOrderable>(_workspace.All <Table>()
                                                              .Where(x => ScreenItems.SingleOrDefault(y => y.Model.Id == x.Id) == null));

            IList <IOrderable> selectedValues = new List <IOrderable>(ScreenItems.Select(x => x.Model));

            IList <IOrderable> choosenValues =
                InteractionService.UserIntraction.ChooseValuesFrom(values, selectedValues, Resources.TableList,
                                                                   string.Format(Resources.SelectTableDialogHint_f, Model.Name), Resources.Table, Resources.Tables);

            ScreenItems.Clear();
            Model.Tables.Clear();

            foreach (Table choosenValue in choosenValues)
            {
                Model.AddScreenItem(choosenValue);
                ScreenItems.Add(new TableScreenItemViewModel(choosenValue, Model));
            }
        }
コード例 #17
0
ファイル: InventoryService.cs プロジェクト: yurseli/sambapos
        private static void CreatePeriodicConsumptionItems(PeriodicConsumption pc, IWorkspace workspace)
        {
            var previousPc       = GetPreviousPeriodicConsumption(workspace);
            var transactionItems = GetTransactionItems();

            foreach (var inventoryItem in workspace.All <InventoryItem>())
            {
                var iItem = inventoryItem;
                var pci   = new PeriodicConsumptionItem {
                    InventoryItem = inventoryItem
                };
                pci.UnitMultiplier = pci.InventoryItem.TransactionUnitMultiplier > 0 ? pci.InventoryItem.TransactionUnitMultiplier : 1;
                pc.PeriodicConsumptionItems.Add(pci);
                var previousCost = 0m;
                if (previousPc != null)
                {
                    var previousPci = previousPc.PeriodicConsumptionItems.SingleOrDefault(x => x.InventoryItem.Id == iItem.Id);
                    if (previousPci != null)
                    {
                        pci.InStock =
                            previousPci.PhysicalInventory != null
                        ? previousPci.PhysicalInventory.GetValueOrDefault(0)
                        : previousPci.GetInventoryPrediction();
                    }
                    if (previousPci != null)
                    {
                        previousCost = previousPci.Cost * pci.InStock;
                    }
                }
                var tim = transactionItems.Where(x => x.InventoryItem.Id == iItem.Id);
                pci.Purchase = tim.Sum(x => x.Quantity * x.Multiplier) / pci.UnitMultiplier;
                var totalPrice = tim.Sum(x => x.Price * x.Quantity);
                if (pci.InStock > 0 || pci.Purchase > 0)
                {
                    pci.Cost = pci.InStock > 0
                                   ? decimal.Round((totalPrice + previousCost) / (pci.InStock + pci.Purchase), 2)
                                   : decimal.Round(totalPrice / pci.Purchase, 2);
                }
            }
        }
コード例 #18
0
ファイル: RepositoryBase.cs プロジェクト: Spanky81/SambaPOS-3
 public IEnumerable <TModel> GetAll()
 {
     return(_workspace.All <TModel>());
 }
コード例 #19
0
 protected virtual IEnumerable <TModel> SelectItems()
 {
     return(_workspace.All <TModel>());
 }
コード例 #20
0
 protected override void Initialize(IWorkspace workspace)
 {
     Roles = workspace.All <UserRole>();
 }
コード例 #21
0
 private IEnumerable <MenuItem> GetMenuItemsByGroupCode(string groupCode)
 {
     return(_workspace.All <MenuItem>(x => x.GroupCode == groupCode));
 }
コード例 #22
0
ファイル: ReportContext.cs プロジェクト: hpbaotho/sambapos
 private static IEnumerable<Ticket> GetTickets(IWorkspace workspace)
 {
     try
     {
         if (CurrentWorkPeriod.StartDate == CurrentWorkPeriod.EndDate)
             return Dao.Query<Ticket>(x => x.LastPaymentDate >= CurrentWorkPeriod.StartDate,
                                      x => x.Payments, x => x.TaxServices,
                                      x => x.Discounts, x => x.TicketItems,
                                      x => x.TicketItems.Select(y => y.Properties));
         return
             Dao.Query<Ticket>(x =>
                 x.LastPaymentDate >= CurrentWorkPeriod.StartDate && x.LastPaymentDate < CurrentWorkPeriod.EndDate,
                 x => x.Payments, x => x.TaxServices, x => x.Discounts, x => x.TicketItems.Select(y => y.Properties));
     }
     catch (SqlException)
     {
         if (CurrentWorkPeriod.StartDate == CurrentWorkPeriod.EndDate)
             return workspace.All<Ticket>(x => x.LastPaymentDate >= CurrentWorkPeriod.StartDate);
         return
             workspace.All<Ticket>(x =>
                 x.LastPaymentDate >= CurrentWorkPeriod.StartDate && x.LastPaymentDate < CurrentWorkPeriod.EndDate);
     }
 }