/// <summary> /// Legt ein neues Konto an /// </summary> /// <param name="button"></param> private void Speichern_Click(Button button) { this.validator.clearSB(); this.checkForm(); if (!this.isValid) { MessageBox.Show(this.validator.getErrorMsg().ToString(), IniParser.GetSetting("ERRORMSG", "noTextField"), MessageBoxButton.OK, MessageBoxImage.Hand); this.validator.clearSB(); } else { int accountNumber; if (!Int32.TryParse(tbAccountNumber.Text, out accountNumber)) { return; } var accountName = tbAccountName.Text; var accountDescription = tbAccountDescription.Text; DataModel.Enums.ZeroPeriod period = ((AccountZeroPeriodEnum)cbZeroPeriod.SelectedItem).period; bool isOfficial = (bool)chkbIsOfficial.IsChecked; bool isCapital = (bool)chkbIsCapital.IsChecked; bool isFix = (bool)chkbIsFixAccount.IsChecked; var accountId = Account.Add(accountName, accountNumber, isOfficial, period, isFix, 0.0, accountDescription, isCapital); if (accountId > 0) { MainWindow mainWindow = Application.Current.MainWindow as MainWindow; Type pageType = typeof(pAccountManager); mainWindow.switchPage(IniParser.GetSetting("ACCOUNTING", "accountManagement"), pageType); } else { MessageBoxEnhanced.Error(IniParser.GetSetting("ERRORMSG", "newAccount")); this.validator.clearSB(); } } this.validator.clearSB(); }
/// <summary> /// Speichert die Überarbeitung eines Kontos /// </summary> /// <param name="button"></param> private void Speichern_Click(Button button) { this.validator.clearSB(); this.checkForm(); if (!this.isValid) { MessageBox.Show(this.validator.getErrorMsg().ToString(), IniParser.GetSetting("ERRORMSG", "noTextField"), MessageBoxButton.OK, MessageBoxImage.Hand); this.validator.clearSB(); } else { try { string accountName = tbAccountName.Text; int accountNumber; bool success = Int32.TryParse(tbAccountNumber.Text, out accountNumber); string accountDescription = tbAccountDescription.Text; DataModel.Enums.ZeroPeriod period = ((AccountZeroPeriodEnum)cbZeroPeriod.SelectedItem).period; bool isOfficial = (bool)chkbIsOfficial.IsChecked; bool isCapital = (bool)chkbIsCapital.IsChecked; double latestBalance = this.currentAccount.LatestBalance; bool isFixed = (bool)chkbIsFixAccount.IsChecked; Account.Update(this.currentAccount.AccountID, accountName, accountNumber, period, isOfficial, accountDescription, latestBalance, isCapital, isFixed); MainWindow mainWindow = Application.Current.MainWindow as MainWindow; Type pageType = typeof(pAccountManager); mainWindow.switchPage(IniParser.GetSetting("ACCOUNTING", "accountManagement"), pageType); } catch { MessageBoxEnhanced.Error(IniParser.GetSetting("ERRORMSG", "editAccount")); } } this.validator.clearSB(); }