示例#1
0
        public void OpenDeposit(Client client, int termMonth, Account accCard, float depositSum)
        {
            Account accDeposit = AccountRepository.AddDepositAccount(client);

            DepositRepository.CreateDeposit(client, accDeposit, termMonth);
            AccountRepository.TransferMoney(accCard, accDeposit, depositSum);
        }
示例#2
0
        private void Delete_MenuItem_Click(object sender, RoutedEventArgs e)
        {
            if (InfoLB.SelectedIndex < 0)
            {
                new MyMessageBox("Select any Item first...").ShowDialog();
                return;
            }

            switch (_nameOfData)
            {
            case nameof(Account):
                var account = InfoLB.SelectedItem as Account;
                if (account.IsDeleted == true)
                {
                    new MyMessageBox($"Account with id={account.Id} has already been deleted!").ShowDialog();
                }
                else
                {
                    using (var repo = new AccountRepository())
                        repo.Delete(account);
                    new MyMessageBox($"Account with id={account.Id} deleted!").ShowDialog();
                }
                break;

            case nameof(Client):
                var client = InfoLB.SelectedItem as Client;
                if (client.IsDeleted == true)
                {
                    new MyMessageBox($"Client with id={client.Id} has already been deleted!").ShowDialog();
                }
                else
                {
                    using (var repo = new ClientRepository())
                        repo.Delete(client);
                    new MyMessageBox($"Client with id={client.Id} deleted!").ShowDialog();
                }
                break;

            case nameof(Deposit):
                var deposit = InfoLB.SelectedItem as Deposit;
                if (deposit.IsDeleted == true)
                {
                    new MyMessageBox($"Deposit with id={deposit.Id} has already been deleted!").ShowDialog();
                }
                else
                {
                    using (var repo = new DepositRepository())
                        repo.Delete(deposit);
                    new MyMessageBox($"Deposit with id={deposit.Id} deleted!").ShowDialog();
                }
                break;

            case nameof(Transaction):
                new MyMessageBox("Transactions can't be deleted...").ShowDialog();
                break;

            default:
                return;
            }
        }
示例#3
0
 public static void SetUp()
 {
     _client            = ClientsRepository.CreateNewClient("test");
     _accountRepository = new AccountRepository();
     _accountDeposit    = _accountRepository.AddDepositAccount(_client);
     _depositRepository = new DepositRepository();
 }
示例#4
0
        public HistoryViewModel(WithdrawRepository withRepo, DepositRepository depoRepo)
        {
            _withRepo = withRepo;
            _depoRepo = depoRepo;

            //Runs the LoadData method to fill the list view
            Task.Run(async() => await LoadData());
        }
示例#5
0
        public ActionResult BuyRead([DataSourceRequest] DataSourceRequest request)
        {
            DepositRepository <Er> repo = new DepositRepository <Er>(UnitOfWork);

            repo = new DepositRepository <Er>(UnitOfWork);
            IEnumerable <OrderManagementSystem.Areas.OMS.Models.Er> list = repo.GetBuy();

            return(Json(list.ToDataSourceResult(request)));
        }
示例#6
0
        public MainViewModel(DepositRepository depoRepo, WithdrawRepository withRepo)
        {
            _depositRepo  = depoRepo;
            _withdrawRepo = withRepo;

            _depositRepo.OnObjAdded  += (sender, e) => Task.Run(async() => await LoadData());
            _withdrawRepo.OnObjAdded += (sender, e) => Task.Run(async() => await LoadData());
            //probably not needed
            _depositRepo.OnObjDeleted  += (sender, e) => Task.Run(async() => await LoadData());
            _withdrawRepo.OnObjDeleted += (sender, e) => Task.Run(async() => await LoadData());
            Task.Run(async() => await LoadData());
        }
示例#7
0
        private void Button_Click(object sender, RoutedEventArgs e)
        {
            var item = this.DataContext as Deposit;

            using (var repo = new DepositRepository())
            {
                if (item.Id > 0)
                {
                    repo.Update(item);
                }
                else
                {
                    repo.Add(new Deposit(item.Client.Id, item.DepositType, item.EndTime, item.Amount));
                }
            }

            Window.GetWindow(this).Close();
        }
示例#8
0
        public static void Init()
        {
            using (var clientrepo = new ClientRepository())
            {
                clientrepo.AddRange(
                    new[] {
                    new Client("Client1", DateTime.Now, "client1", "client1"),
                    new Client("Client2", DateTime.Now, "client2", "client2"),
                    new Client("Client3", DateTime.Now, "client3", "client3")
                });
            }

            using (var accountrepo = new AccountRepository())
            {
                accountrepo.AddRange(
                    new[] {
                    new Account(1, 100d),
                    new Account(2, 100d),
                    new Account(3, 100d)
                });
            }

            using (var depositrepo = new DepositRepository())
            {
                depositrepo.AddRange(
                    new[] { new Deposit(1, DepositType.WithCapitalization,
                                        DateTime.Now.AddMonths(1)),
                            new Deposit(2, DepositType.WithCapitalization,
                                        DateTime.Now.AddMonths(5))
                            {
                                CreationTime = DateTime.Now.AddMonths(-2), Amount = 1000
                            },
                            new Deposit(3, DepositType.WithoutCapitalization,
                                        DateTime.Now.AddMonths(15))
                            {
                                CreationTime = DateTime.Now.AddMonths(-8), Amount = 1000
                            } });
            }

            var result = new Transfer(new Transaction(50d, 1, 2)).Execute();

            result = new Withdrawal(new Transaction(25d, 1, 0)).Execute();
            result = new Crediting(new Transaction(25d, 0, 3)).Execute();
        }
示例#9
0
    void ActionResidueActivated(object sender, System.EventArgs e)
    {
        IMoneyRepository       moneyRepository   = new MoneyRepository();
        IDepositRepository     depositRepository = new DepositRepository();
        IBottlesRepository     bottlesRepository = new BottlesRepository();
        ResidueFilterViewModel filter            = new ResidueFilterViewModel();
        var residueJournalViewModel = new ResidueJournalViewModel(
            filter,
            VodovozGtkServicesConfig.EmployeeService,
            VodovozGtkServicesConfig.RepresentationEntityPicker,
            moneyRepository,
            depositRepository,
            bottlesRepository,
            UnitOfWorkFactory.GetDefaultFactory,
            ServicesConfig.CommonServices,
            new DefaultEntityAutocompleteSelectorFactory <Employee, EmployeesJournalViewModel, EmployeeFilterViewModel>(ServicesConfig.CommonServices)
            );

        tdiMain.AddTab(residueJournalViewModel);
    }
示例#10
0
 public void Init()
 {
     ctx = EFContext.CreateContext();
     repo = new DepositRepository(ctx);
 }
        public void Refresh()
        {
            DeliveryPoint = (InfoProvider as IDeliveryPointInfoProvider)?.DeliveryPoint;
            if (DeliveryPoint == null)
            {
                buttonSaveComment.Sensitive = false;
                return;
            }
            buttonSaveComment.Sensitive = true;
            labelAddress.Text           = DeliveryPoint.CompiledAddress;

            foreach (var child in PhonesTable.Children)
            {
                PhonesTable.Remove(child);
                child.Destroy();
            }

            uint rowsCount = Convert.ToUInt32(DeliveryPoint.Phones.Count) + 1;

            PhonesTable.Resize(rowsCount, 2);
            for (uint row = 0; row < rowsCount - 1; row++)
            {
                Label label = new Label();
                label.Selectable = true;
                label.Markup     = $"{DeliveryPoint.Phones[Convert.ToInt32(row)].LongText}";

                HandsetView handsetView = new HandsetView(DeliveryPoint.Phones[Convert.ToInt32(row)].DigitsNumber);

                PhonesTable.Attach(label, 0, 1, row, row + 1);
                PhonesTable.Attach(handsetView, 1, 2, row, row + 1);
            }

            Label labelAddPhone = new Label()
            {
                LabelProp = "Щёлкните чтоб\n добавить телефон-->"
            };

            PhonesTable.Attach(labelAddPhone, 0, 1, rowsCount - 1, rowsCount);

            Image addIcon = new Image();

            addIcon.Pixbuf = Stetic.IconLoader.LoadIcon(this, "gtk-add", IconSize.Menu);
            Button btn = new Button();

            btn.Image    = addIcon;
            btn.Clicked += OnBtnAddPhoneClicked;
            PhonesTable.Attach(btn, 1, 2, rowsCount - 1, rowsCount);
            PhonesTable.ShowAll();

            var bottlesAtDeliveryPoint  = BottlesRepository.GetBottlesAtDeliveryPoint(InfoProvider.UoW, DeliveryPoint);
            var bottlesAvgDeliveryPoint = DeliveryPointRepository.GetAvgBottlesOrdered(InfoProvider.UoW, DeliveryPoint, 5);

            lblBottlesQty.LabelProp = $"{bottlesAtDeliveryPoint} шт. (сред. зак.: {bottlesAvgDeliveryPoint:G3})";
            var bottlesAtCounterparty = BottlesRepository.GetBottlesAtCounterparty(InfoProvider.UoW, DeliveryPoint.Counterparty);

            debtByClientLabel.LabelProp = $"{bottlesAtCounterparty} шт.";
            var depositsAtDeliveryPoint = DepositRepository.GetDepositsAtDeliveryPoint(InfoProvider.UoW, DeliveryPoint, null);

            labelDeposits.LabelProp     = CurrencyWorks.GetShortCurrencyString(depositsAtDeliveryPoint);
            textviewComment.Buffer.Text = DeliveryPoint.Comment;

            var currentOrders = OrderRepository.GetLatestOrdersForDeliveryPoint(InfoProvider.UoW, DeliveryPoint, 5);

            ytreeLastOrders.SetItemsSource <Order>(currentOrders);
            vboxLastOrders.Visible = currentOrders.Any();

            table2.ShowAll();
        }
示例#12
0
        //TODO BookingDocument

        protected override Booking DoPostPutDto(Client currentClient, BookingDTO dto, Booking entity, string path, object param)
        {
            if (entity == null)
            {
                entity = new Booking();
            }
            GetMapper.Map <BookingDTO, Booking>(dto, entity);

            HomeConfig hc = HomeConfigRepository.GetHomeConfigById(entity.HomeId, currentClient.Id);

            if (hc != null)
            {
                if (hc.DefaultHourCheckIn != null)
                {
                    entity.DateArrival = ((DateTime)entity.DateArrival).Date.Add(hc.DefaultHourCheckInToTimeSpan);
                }
                if (hc.DefaultHourCheckOut != null)
                {
                    entity.DateDeparture = ((DateTime)entity.DateDeparture).Date.Add(hc.DefaultHourCheckOutToTimeSpan);
                }
            }
            if (dto.People != null)
            {
                entity.People = PeopleService.PreProcessDTOPostPut(validationDictionnary, dto.HomeId, dto.People, currentClient, path);
            }
            if (dto.AdditionalBookings != null)
            {
                AdditionalBookingRepository.DeleteRange(entity.AdditionalBookings.Where(d => !dto.AdditionalBookings.Any(x => x.Id == d.Id)));
                dto.AdditionalBookings.ForEach(additionalBooking =>
                {
                    if (entity.AdditionalBookings.Count != 0 && additionalBooking.Id != 0 &&
                        entity.AdditionalBookings.Find(p => p.Id == additionalBooking.Id) != null)
                    {
                        return;
                    }
                    AdditionalBooking toAdd = AdditionalBookingService.PreProcessDTOPostPut(validationDictionnary, dto.HomeId, additionalBooking, currentClient, path);

                    if (toAdd != null)
                    {
                        entity.AdditionalBookings.Add(toAdd);
                    }
                });
            }
            if (dto.BookingStepBooking != null)
            {
                entity.BookingStepBooking = BookingStepBookingService.PreProcessDTOPostPut(validationDictionnary, dto.HomeId, dto.BookingStepBooking, currentClient, path);
            }
            if (dto.Deposits != null)
            {
                DepositRepository.DeleteRange(entity.Deposits.Where(d => !dto.Deposits.Any(x => x.Id == d.Id)));
                dto.Deposits.ForEach(deposit =>
                {
                    if (entity.Deposits.Count != 0 && deposit.Id != 0 &&
                        entity.Deposits.Find(p => p.Id == deposit.Id) != null)
                    {
                        return;
                    }
                    Deposit toAdd = DepositService.PreProcessDTOPostPut(validationDictionnary, dto.HomeId, deposit, currentClient, path);

                    if (toAdd != null)
                    {
                        entity.Deposits.Add(toAdd);
                    }
                });
            }
            if (dto.DinnerBookings != null)
            {
                DinnerBookingRepository.DeleteRange(entity.DinnerBookings.Where(d => !dto.DinnerBookings.Any(x => x.Id == d.Id)));
                dto.DinnerBookings.ForEach(dinnerBooking =>
                {
                    if (entity.DinnerBookings.Count != 0 && dinnerBooking.Id != 0 &&
                        entity.DinnerBookings.Find(p => p.Id == dinnerBooking.Id) != null)
                    {
                        return;
                    }
                    DinnerBooking toAdd = DinnerBookingService.PreProcessDTOPostPut(validationDictionnary, dto.HomeId, dinnerBooking, currentClient, path);

                    if (toAdd != null)
                    {
                        entity.DinnerBookings.Add(toAdd);
                    }
                });
            }
            if (dto.ProductBookings != null)
            {
                ProductBookingRepository.DeleteRange(entity.ProductBookings.Where(d => !dto.ProductBookings.Any(x => x.Id == d.Id)));
                dto.ProductBookings.ForEach(productBooking =>
                {
                    if (entity.ProductBookings.Count != 0 && productBooking.Id != 0 &&
                        entity.ProductBookings.Find(p => p.Id == productBooking.Id) != null)
                    {
                        return;
                    }
                    ProductBooking toAdd = ProductBookingService.PreProcessDTOPostPut(validationDictionnary, dto.HomeId, productBooking, currentClient, path);

                    if (toAdd != null)
                    {
                        entity.ProductBookings.Add(toAdd);
                    }
                });
            }
            if (dto.RoomBookings != null)
            {
                RoomBokingRepository.DeleteRange(entity.RoomBookings.Where(d => !dto.RoomBookings.Any(x => x.Id == d.Id)));
                dto.RoomBookings.ForEach(roomBooking =>
                {
                    if (entity.RoomBookings.Count != 0 && roomBooking.Id != 0 &&
                        entity.RoomBookings.Find(p => p.Id == roomBooking.Id) != null)
                    {
                        return;
                    }
                    RoomBooking toAdd = RoomBookingService.PreProcessDTOPostPut(validationDictionnary, dto.HomeId, roomBooking, currentClient, path);

                    if (toAdd != null)
                    {
                        entity.RoomBookings.Add(toAdd);
                    }
                });
            }
            entity.DateCreation = DateTime.UtcNow;
            return(entity);
        }
        protected void RefreshSpinButtons()
        {
            int     bottlesMax           = BottlesRepository.GetBottlesAtDeliveryPoint(UoWGeneric, Entity.FromDeliveryPoint, Entity.TimeStamp);
            decimal depositsBottlesMax   = DepositRepository.GetDepositsAtDeliveryPoint(UoWGeneric, Entity.FromDeliveryPoint, DepositType.Bottles, Entity.TimeStamp);
            decimal depositsEquipmentMax = DepositRepository.GetDepositsAtDeliveryPoint(UoWGeneric, Entity.FromDeliveryPoint, DepositType.Equipment, Entity.TimeStamp);

            if (Entity.OutBottlesOperation != null)
            {
                spinBottles.Value = Entity.OutBottlesOperation.Returned != 0 ? Entity.OutBottlesOperation.Returned : (Entity.OutBottlesOperation.Delivered * -1);
            }
            else
            {
                spinBottles.Value = 0;
            }

            if (Entity.OutBottlesDepositOperation != null)
            {
                spinDepositsBottles.Value = (double)(Entity.OutBottlesDepositOperation.RefundDeposit != 0 ? Entity.OutBottlesDepositOperation.RefundDeposit : (Entity.OutBottlesDepositOperation.ReceivedDeposit * -1));
            }
            else
            {
                spinDepositsBottles.Value = 0;
            }

            if (Entity.OutEquipmentDepositOperation != null)
            {
                spinDepositsEquipment.Value = (double)(Entity.OutEquipmentDepositOperation.RefundDeposit != 0 ? Entity.OutEquipmentDepositOperation.RefundDeposit : (Entity.OutEquipmentDepositOperation.ReceivedDeposit * -1));
            }
            else
            {
                spinDepositsEquipment.Value = 0;
            }

            if (Math.Abs(bottlesMax) < Math.Abs(spinBottles.Value) ||
                Math.Abs(depositsBottlesMax) < Math.Abs((decimal)spinDepositsBottles.Value) ||
                Math.Abs(depositsEquipmentMax) < Math.Abs((decimal)spinDepositsEquipment.Value))
            {
                checkbuttonLock.Active = false;
            }

            spinBottles.Sensitive     = referenceDeliveryPointFrom.Subject != null;
            labelBottlesMax.LabelProp = bottlesMax.ToString();

            spinDepositsBottles.Sensitive     = referenceDeliveryPointFrom.Subject != null;
            labelDepositsBottlesMax.LabelProp = depositsBottlesMax.ToString();

            spinDepositsEquipment.Sensitive     = referenceDeliveryPointFrom.Subject != null;
            labelDepositsEquipmentMax.LabelProp = depositsEquipmentMax.ToString();

            if (checkbuttonLock.Active)
            {
                spinBottles.Adjustment.Upper = bottlesMax > 0 ? bottlesMax : 0;
                spinBottles.Adjustment.Lower = bottlesMax < 0 ? bottlesMax : 0;

                spinDepositsBottles.Adjustment.Upper = (double)(depositsBottlesMax > 0 ? depositsBottlesMax : 0);
                spinDepositsBottles.Adjustment.Lower = (double)(depositsBottlesMax < 0 ? depositsBottlesMax : 0);

                spinDepositsEquipment.Adjustment.Upper = (double)(depositsEquipmentMax > 0 ? depositsEquipmentMax : 0);
                spinDepositsEquipment.Adjustment.Lower = (double)(depositsEquipmentMax < 0 ? depositsEquipmentMax : 0);
            }
            else
            {
                spinBottles.Adjustment.Upper = 1000;
                spinBottles.Adjustment.Lower = -1000;

                spinDepositsBottles.Adjustment.Upper = 100000;
                spinDepositsBottles.Adjustment.Lower = -100000;

                spinDepositsEquipment.Adjustment.Upper = 100000;
                spinDepositsEquipment.Adjustment.Lower = -100000;
            }
        }
示例#14
0
 public DepositViewModel(DepositRepository depoRepo)
 {
     _depoRepo = depoRepo;
 }
示例#15
0
 public EditDeleteViewModel(DepositRepository depoRepo, WithdrawRepository withRepo)
 {
     _depoRepo = depoRepo;
     _withRepo = withRepo;
 }
示例#16
0
 public BankFacade()
 {
     DepositRepository = new DepositRepository();
     AccountRepository = new AccountRepository();
 }
示例#17
0
 public void Init()
 {
     ctx  = EFContext.CreateContext();
     repo = new DepositRepository(ctx);
 }