Skip to content

Commit

Permalink
auto create sheet for current month
Browse files Browse the repository at this point in the history
  • Loading branch information
nylssoft committed May 14, 2017
1 parent ae49da7 commit 49d783a
Show file tree
Hide file tree
Showing 6 changed files with 52 additions and 4 deletions.
2 changes: 1 addition & 1 deletion Bank.sln
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 15
VisualStudioVersion = 15.0.26403.3
VisualStudioVersion = 15.0.26430.6
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Bank", "Bank\Bank.csproj", "{8FEF79C8-A9E6-432F-96C9-C9C4B199F34B}"
EndProject
Expand Down
33 changes: 33 additions & 0 deletions Bank/MainWindow.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ You should have received a copy of the GNU General Public License
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Input;
using System.Windows.Threading;

namespace Bank
{
Expand Down Expand Up @@ -219,6 +220,11 @@ private void ComboBoxAccounts_SelectionChanged(object sender, SelectionChangedEv
Properties.Settings.Default.LastUsedAccount = comboBox.SelectedIndex;
}
ShowAccount(null);
if (CurrentBalance != null)
{
Application.Current.Dispatcher.BeginInvoke(DispatcherPriority.Background,
new Action(() => { CreateBalance(); }));
}
}
catch (Exception ex)
{
Expand Down Expand Up @@ -342,6 +348,33 @@ private void ShowAccount(Balance current)
ShowBalance(CurrentBalance);
}

private void CreateBalance()
{
try
{
if (comboBox.SelectedItem is Account account && CurrentBalance != null)
{
DateTime now = DateTime.Now;
if (CurrentBalance.Year == now.Year && CurrentBalance.Month == now.Month - 1 ||
CurrentBalance.Year == now.Year + 1 && CurrentBalance.Month == 12 && now.Month == 1)
{
if (MessageBox.Show(
this,
string.Format(Properties.Resources.QUESTION_CREATE_SHEET_0, $"{now:y}"),
Title, MessageBoxButton.YesNo) == MessageBoxResult.Yes)
{
var balance = database.GetBalance(account, now.Month, now.Year, true /* create */);
ShowAccount(balance);
}
}
}
}
catch (Exception ex)
{
HandleError(ex);
}
}

private void ShowBalance(Balance balance)
{
bookings.Clear();
Expand Down
6 changes: 3 additions & 3 deletions Bank/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@
[assembly: AssemblyCulture("")]
[assembly: ComVisible(false)]
[assembly: ThemeInfo(ResourceDictionaryLocation.None, ResourceDictionaryLocation.SourceAssembly)]
[assembly: AssemblyVersion("1.0.1.1")]
[assembly: AssemblyFileVersion("1.0.1.1")]
[assembly: AssemblyInformationalVersion("1.0.1")]
[assembly: AssemblyVersion("1.0.2.2")]
[assembly: AssemblyFileVersion("1.0.2.2")]
[assembly: AssemblyInformationalVersion("1.0.2")]
[assembly: NeutralResourcesLanguage("")]
[assembly: Guid("508F852D-294F-4FDE-8B4E-3B146E326FBD")]
9 changes: 9 additions & 0 deletions Bank/Properties/Resources.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions Bank/Properties/Resources.de.resx
Original file line number Diff line number Diff line change
Expand Up @@ -243,6 +243,9 @@
<data name="MONTH_BALANCE_0" xml:space="preserve">
<value>Monatsbilanz: {0}</value>
</data>
<data name="QUESTION_CREATE_SHEET_0" xml:space="preserve">
<value>Wollen Sie den Kontoauszug für {0} anlegen?</value>
</data>
<data name="QUESTION_DELETE_ACCOUNT_0" xml:space="preserve">
<value>Wollen Sie das Konto '{0}' löschen?</value>
</data>
Expand Down
3 changes: 3 additions & 0 deletions Bank/Properties/Resources.resx
Original file line number Diff line number Diff line change
Expand Up @@ -243,6 +243,9 @@
<data name="MONTH_BALANCE_0" xml:space="preserve">
<value>Monthly balance: {0}</value>
</data>
<data name="QUESTION_CREATE_SHEET_0" xml:space="preserve">
<value>Do you want to create the sheet for {0}?</value>
</data>
<data name="QUESTION_DELETE_ACCOUNT_0" xml:space="preserve">
<value>Do you want to delete the account '{0}'?</value>
</data>
Expand Down

0 comments on commit 49d783a

Please sign in to comment.