private void BtnNewSpending_Click(object sender, RoutedEventArgs e) { OperationWindow newSpendingWindow = new OperationWindow(); newSpendingWindow.Show(); newSpendingWindow.Closing += NewSpendingWindow_Closing; }
private void OperationWindow_Closing(object sender, System.ComponentModel.CancelEventArgs e) { // to avoid RAM memory leaks OperationWindow operationWindow = sender as OperationWindow; if (operationWindow != null) { operationWindow.Closing -= OperationWindow_Closing; } InitializeTransactions(); }
private void BtnEditOperation_Click(object sender, RoutedEventArgs e) { OperationDto clickedOperation = GetClickedOperation(sender); OperationWindow operationWindow = new OperationWindow(); operationWindow.Id = clickedOperation.Id; // Populate text boxes and date operationWindow.datePicker.SelectedDate = clickedOperation.Date; operationWindow.tbAmmount.Text = clickedOperation.Ammount.ToString(); operationWindow.tbDescription.Text = clickedOperation.Description; // Populate accounts combo box foreach (ComboItem item in operationWindow.cbAccount.Items) { if (item.Id == clickedOperation.IdAccount) { operationWindow.cbAccount.SelectedItem = item; } } // Populate categories combo box foreach (ComboItem item in operationWindow.cbCategory.Items) { if (item.Id == clickedOperation.IdOperationType) { operationWindow.cbCategory.SelectedItem = item; } } operationWindow.Show(); //OperationDto editedOperation = new OperationDto() //{ // Id = clickedOperation.Id, // //Date = , // Ammount = (decimal.Parse(operationWindow.tbAmmount.Text)), // IdOperationType = ((ComboItem)operationWindow.cbCategory.SelectedItem).Id, // Description = operationWindow.tbDescription.Text //}; //_operationRepo.Update(editedOperation); operationWindow.Closing += OperationWindow_Closing; }