void OpenHandler() { Debtors.Clear(); string filePath = null; OpenFileDialog openFileDialog = new OpenFileDialog(); openFileDialog.Filter = "txt files (*.txt)|*.txt|All files (*.*)|*.*"; if (openFileDialog.ShowDialog() == true) { filePath = openFileDialog.FileName; using (StreamReader reader = new StreamReader(filePath)) { string inputFromFile; while ((inputFromFile = reader.ReadLine()) != null) { string[] words = inputFromFile.Split(","); Debtor openDebtor = new Debtor(words[0], 0); for (int i = 1; i < words.Length - 1; i += 2) { Debt openDebt = new Debt(words[i], double.Parse(words[i + 1])); openDebtor.DebtsList.Add(openDebt); } Debtors.Add(openDebtor); } } } }
public MainWindowViewModel(Debtors debtBook, INavigationService n) { _debtBook = debtBook; _debtBook.addDebtor(new Debtor("Alicja")); _debtBook.addDebtor(new Debtor("Garrett")); _nav = n; }
public void NewDebtor() { DateTime dateTime = new DateTime(2025, 10, 12); Debtors debtor = new Debtors("1111-2222-3333", "Petur Petrov", 200, dateTime, 2, 123123); Assert.AreEqual(Math.Round(3.46512, 2), debtor.installment); }
public ListOfDebtorsForm(Form form, Root root) { InitializeComponent(); _form = form; _root = root; _debtors = new Debtors(); }
//Load a specified Debtor's information private void metroButton2_Click(object sender, EventArgs e) { Exception IBANorNameNotFound = new Exception("The Debtors was not found.\nCheck the IBAN/Name and try again"); string exceptionText = ""; try { if (Access.GetDebtors(id).Where(x => (x.name.Trim() == IBANTextBox.Text || x.IBAN.Trim() == IBANTextBox.Text)).Count() != 0) { changed = Access.GetDebtors(id).Where(x => (x.name.Trim() == IBANTextBox.Text || x.IBAN.Trim() == IBANTextBox.Text)).First(); debtTextBox.Text = changed.debt.ToString(); EndDateTime.Value = changed.endDate; interestTextBox.Text = changed.interest.ToString(); debtTextBox.Enabled = true; EndDateTime.Enabled = true; interestTextBox.Enabled = true; metroButton1.Enabled = true; metroButton3.Enabled = true; } else { exceptionText = IBANorNameNotFound.Message; throw IBANorNameNotFound; } } catch (Exception) { MetroMessageBox.Show(this, exceptionText, "Error", MessageBoxButtons.OK); } }
public MainViewModel() { debtors = new ObservableCollection <IDebtor>(); Debtors.Add(new Debtor("Britta Nielsen")); Debtors.Add(new Debtor("Tobias Lund")); Debtors[0].PayOrBorrow(-012397345); Debtors[1].PayOrBorrow(6969); }
public void AddDebtorWithFixedDebt(Person person, double debt) { if (!IsPersonInDebtors(person)) { Debtor debtor = new Debtor(person, Debtor.FactorType.WithoutFactor, debt); Debtors.Add(debtor); RecountDebtorsData(); } }
public void AddUsualDebtor(Person person) { if (!IsPersonInDebtors(person)) { Debtor debtor = new Debtor(person, Debtor.FactorType.Standart, person.DebtFactor); Debtors.Add(debtor); RecountDebtorsData(); } }
public void AddDebtorWithFactor(Person person, double debtFactor) { if (!IsPersonInDebtors(person)) { Debtor debtor = new Debtor(person, Debtor.FactorType.SpecialForProduct, debtFactor); Debtors.Add(debtor); RecountDebtorsData(); } }
public void RemoveDebtor(Person person) { Debtor debtor = GetDebtor(person); if (debtor != null) { Debtors.Remove(debtor); RecountDebtorsData(); } }
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) { Debtors.Clear(); filename = ""; } }
public ShellViewModel() { Debtors.Add(new Debtor { Name = "Mickey Mouse", Amount = -100 }); Debtors.Add(new Debtor { Name = "Donald Duck", Amount = 1321 }); Debtors.Add(new Debtor { Name = "Tom Cruise", Amount = 300 }); }
private void AnalyzeCandidate ( [NotNull] ReaderInfo reader ) { DebtorInfo debtor = _debtorManager.GetDebtor(reader); if (!ReferenceEquals(debtor, null)) { Debtors.Add(debtor); } }
public void InvolveEveryone() { Recalculate(); var alreadyPresentDebtors = Debtors.Where(t => t.UserId != null).Select(t => t.UserId).ToArray(); var missingDebtors = AllUsers.Where(t => alreadyPresentDebtors.All(d => d != t.Id)).ToArray(); var missingTransactions = missingDebtors.Select(t => new TransactionData() { UserId = t.Id, Name = t.Name, Amount = AmountDifference / missingDebtors.Count() }); Debtors.AddRange(missingTransactions); DebtorsChanged(); }
public string Info() { var userId = GetUserId(); var groupId = Convert.ToInt32(Context.Parameters["GroupId"]); var paymentId = Context.Parameters["Id"]; string uID = userId.ToString(); string gID = Convert.ToString(Context.Parameters["GroupId"]); string date = DateTime.Today.ToString(); string description = Data.Description; string currency = Data.Currency; string text = EmailService.Text(Payers.ToList(), Debtors.ToList(), uID, gID, date, description, currency); return(text); }
public void EditRow(TransactionRowData row, string context) { if (context == "payers") { var item = Payers.Find(n => n == row); item.Name = ""; item.IsUserboxVisible = false; } else if (context == "debtors") { var item = Debtors.Find(n => n == row); item.Name = ""; item.IsUserboxVisible = false; } }
public void FilterDebtorsNames(string filter) { IEnumerable <TransactionData> debtorsDatas = AllDebtors; if (!string.IsNullOrWhiteSpace(filter)) { debtorsDatas = debtorsDatas.Where(t => t.Name.Contains(filter)); } FilteredNames = debtorsDatas.Select(t => t.Name) //select only names .Concat(Debtors.Select(t => t.Name)) //merge Names of allready added debtors with names of all debtors .GroupBy(t => t).Where(g => g.Count() == 1).Select(g => g.Key).ToList(); //select only unique entries MoveCurrentUserToTop(FilteredNames); }
/// <summary> /// Saves the payment. /// </summary> public void Save() { try { var userId = GetUserId(); PaymentService.SavePayment(userId, Data, Payers, Debtors); string text = Info(); EmailService.SendEmail(Debtors.Concat(Payers).ToList(), text); } catch (Exception ex) { ErrorMessage = ex.Message; return; } GoBack(); }
private void AddDebtorCommandExecute() { if (!String.IsNullOrEmpty(newDebtorName)) { var newDebtor = new Debtor(); // Set properties and add to list newDebtor.Name = newDebtorName; newDebtor.PayOrBorrow(newDebtorDebt); Debtors.Add(newDebtor); _modelDebtor = newDebtor; //Reset textbox binded properties newDebtorName = ""; newDebtorDebt = 0; } else { MessageBox.Show($"Cannot add debtor with no name"); } }
public void AddSelectedUser(string name, TransactionRowData row, string context) { if (context == "payers") { var user = AllPayers.FirstOrDefault(n => n.Name == name); if (user != null) { var item = Payers.First(n => n.RowId == row.RowId); item.Name = user.Name; item.UserId = user.UserId; item.ImageUrl = user.ImageUrl; item.Id = user.Id; item.IsUserboxVisible = true; } if (AllPayers.Count > Payers.Count) { AddRow(Payers); } } else if (context == "debtors") { var user = AllDebtors.FirstOrDefault(n => n.Name == name); if (user != null) { var item = Debtors.First(n => n.RowId == row.RowId); item.Name = user.Name; item.UserId = user.UserId; item.ImageUrl = user.ImageUrl; item.Id = user.Id; item.IsUserboxVisible = true; } if (AllDebtors.Count > Debtors.Count) { AddRow(Debtors); } } }
/// <summary> /// Recalculates the remaining amount. /// </summary> public void Recalculate() { AmountDifference = (Payers.Where(p => p.Amount != null).Sum(p => p.Amount) ?? 0) - (Debtors.Where(p => p.Amount != null).Sum(p => p.Amount) ?? 0); }
public void DeleteDebtor(TransactionData debtor) { Debtors.Remove(debtor); EnsureInsertRowPresent(Debtors); Recalculate(); }
public List <Loan> GetLoans(string userID) { List <Loan> loans = null; try { using (var context = new DebtyDBContext()) { var loanss = (from loan in context.Loans join creditor in context.Persons on loan.Creditor.Id equals creditor.Id where loan.Creditor.Id == userID select new { loanID = loan.LoanID, loanName = loan.LoanName, loanDesc = loan.LoanDesc, loanDate = loan.LoanDate, deadline = loan.Deadline, loanAmount = loan.LoanAmount, Creditor = new Creditor { PersonID = loan.Creditor.Id, FirstName = creditor.FirstName, LastName = creditor.LastName }, }).ToList(); var debtors = (from dl in context.DebtorLoans join debtor in context.Persons on dl.DebtorID equals debtor.Id select new { loanID = dl.LoanID, debtor = new Debtor { FirstName = debtor.FirstName, LastName = debtor.LastName } } into D group D by D.loanID into Debtors select new { loanID = Debtors.Key, Debtors = Debtors.ToList() }).ToList(); loans = (from loan in loanss join debtor in debtors on loan.loanID equals debtor.loanID select new Loan { LoanID = loan.loanID, LoanName = loan.loanName, LoanDesc = loan.loanDesc, LoanDate = loan.loanDate, Deadline = loan.deadline, LoanAmount = loan.loanAmount, Creditor = loan.Creditor, Debtors = debtor.Debtors.Select(x => x.debtor).ToList() }).ToList(); return(loans); } } catch (Exception ex) { return(loans.DefaultIfEmpty().ToList()); } }
public AddDebtorViewModel(Debtors debtBook, INavigationService n) { _debtBook = debtBook; _nav = n; }
public ViewDebtorViewModel(Debtors debtBook, String debtorName, INavigationService n) { _debtBook = debtBook; _selectedDebtor = _debtBook.getDebtor(debtorName); _nav = n; }
private void LoadReaders() { Stopwatch stopwatch = new Stopwatch(); stopwatch.Start(); WriteLine("Начало загрузки читателей"); IEnumerable <MarcRecord> records = BatchRecordReader.WholeDatabase ( Connection, Connection.Database, 1000 ); BatchRecordReader batch = records as BatchRecordReader; if (!ReferenceEquals(batch, null)) { batch.BatchRead += Batch_BatchRead; } records.ProcessData(ParseAndAddReader); Readers.CompleteAdding(); WriteDelimiter(); WriteLine("Распределение читателей"); string[] keys = ReadersByStatus.Keys; foreach (string key in keys) { WriteLine ( "Статус {0}: {1} читателей", key, ReadersByStatus[key].Length ); } WriteDelimiter(); DateTime today = DateTime.Today; _debtorManager = new DebtorManager(Connection) { FromDate = today.AddYears(-1), ToDate = today.AddMonths(-1) }; _debtorManager.SetupDates(); ReadersByStatus["0"].ProcessData(AnalyzeCandidate); Debtors.CompleteAdding(); WriteLine ( "Кандидатов в должники: {0}", Debtors.Count ); WriteLine("Окончание загрузки читателей"); stopwatch.Stop(); WriteLine ( "Загрузка заняла: {0}", stopwatch.Elapsed.ToAutoString() ); WriteLine("Загружено: {0}", Readers.Count); WriteDelimiter(); }