private void SaveDebitor(int ClientId)
        {
            if (SelectedDebitor.DebitorId == 0)
            {
                int DebitorNumber = CostAccounts.GetNextDebitorNumber();
                SelectedDebitor.RefClientId = CompanyViewModel.Client.ClientId;
                SelectedDebitor.CostAccount.RefTaxTypeId             = CompanyViewModel.SelectedTaxTypeId;
                SelectedDebitor.CostAccount.AccountNumber            = DebitorNumber;
                SelectedDebitor.CostAccount.RefCostAccountCategoryId =
                    CostAccountCategories.GetDebitorId();
                SelectedDebitor.CostAccount.Description = CompanyViewModel.Client.Name;
                SelectedDebitor.CostAccount.IsVisible   = true;
                SelectedDebitor.RefCostAccountId        =
                    CostAccounts.Insert(SelectedDebitor.CostAccount);
                Debitors.Insert(SelectedDebitor);
            }
            else
            {
                Clients.Update(CompanyViewModel.Client);
                if (CompanyViewModel.SelectedClientType == ClientType.Business)
                {
                    Companies.Update(CompanyViewModel.Client.Company);
                }

                CostAccounts.Update(SelectedDebitor.CostAccount);
                Debitors.Update(SelectedDebitor);
            }
        }
        private void DeleteDebitor()
        {
            if (SelectedDebitor.DebitorId != 0)
            {
                Debitors.Delete(SelectedDebitor.DebitorId);
            }

            FilteredDebitors.Remove(SelectedDebitor);
        }
        private void NewFileCommand_Execute()
        {
            MessageBoxResult res = MessageBox.Show(
                "Any unsaved data will be lost. Are you sure you want to initiate a new file?", "Warning",
                MessageBoxButton.YesNo, MessageBoxImage.Question, MessageBoxResult.No);

            if (res == MessageBoxResult.Yes)
            {
                Debitors.Clear();
                filename = "";
            }
        }
        public MainWindowViewModel()
        {
            debitors = new ObservableCollection <Debitor>
            {
                new Debitor("Lena", "2000", "06/03-2020"),
                new Debitor("Mikkel", "-5000", "15/10-2018")
            };

            var clonedlist = Debitors.Select(objEntity => (Debitor)objEntity.Clone()).ToList();

            clonedCollection = new ObservableCollection <Debitor>(clonedlist);
        }
        private bool ValidateDelete()
        {
            if (SelectedCreditor == null && SelectedDebitor == null)
            {
                return(false);
            }

            if (SelectedCreditor != null)
            {
                return(!Creditors.IsCreditorInUse(SelectedCreditor.CreditorId));
            }

            if (SelectedDebitor != null)
            {
                return(!Debitors.IsDebitorInUse(SelectedDebitor.DebitorId));
            }

            return(false);
        }
示例#6
0
        public void ShowEditDebtorCommand()
        {
            Debitors copydebitor = new Debitors(DebitorsCreditors[CurrentIndex]);

            ((App)Application.Current).Debitor = DebitorsCreditors[CurrentIndex];

            _iDialogService.ShowDialog("EditShowDetailView", null, r =>
            {
                if (r.Result == ButtonResult.OK)
                {
                    DebitorsCreditors[CurrentIndex] = ((App)Application.Current).Debitor;
                    DebitorsCreditors[CurrentIndex].UpdateBalance();
                }
                else
                {
                    DebitorsCreditors[CurrentIndex] = copydebitor;
                    DebitorsCreditors[CurrentIndex].UpdateBalance();
                }
            });
        }
示例#7
0
 public virtual void OnDialogOpened(IDialogParameters parameters)
 {
     CurrentDebitor = new Debitors("Test");
 }
 private void RefreshData()
 {
     FilteredCreditors = CreditorList = Creditors.GetAll().ToSvenTechCollection();
     FilteredDebitors  = DebitorList = Debitors.GetAll().ToSvenTechCollection();
 }