コード例 #1
0
        private void SaveAccountCommand_E(object obj)
        {
            try
            {
                var account = db.ChurchAccountDetails.Where(i => i.AccountName == NewChurchAccount.AccountName && i.AccountNumber == NewChurchAccount.AccountNumber && i.BankBranch == NewChurchAccount.BankBranch).FirstOrDefault();

                bool IsAccountValid = ValidateAccount(NewChurchAccount);
                if (account == null && IsAccountValid)
                {
                    NewChurchAccount.ChurchId = FocusedChurch.ChurchId;
                    focusedChurch.AccountDetails.Add(NewChurchAccount);
                    db.ChurchAccountDetails.Add(NewChurchAccount);
                    db.SaveChanges();
                    NewChurchAccount = new ChurchAccountDetail();
                    refreshCs_E(null);
                    SetFocusedChurch();
                    FocusedChurch.AccountDetails = focusedChurch.AccountDetails;
                    // show messagebox to alert success;
                    MessageBox.Show("Account Detail Added Successfully", "Success !! ", MessageBoxButton.OK, MessageBoxImage.Information);
                    return;
                }
                else if (account != null)
                {
                    Error = this["Duplicate"];
                }
                if (!IsAccountValid)
                {
                    return;
                }
            }
            catch
            {  // show Message Box  to alert failure
                MessageBox.Show("Failed to add Account detail", "Failure !! ", MessageBoxButton.OK, MessageBoxImage.Error);
            }
        }
コード例 #2
0
        private bool ValidateAccount(ChurchAccountDetail newChurchAccount)
        {
            if (string.IsNullOrWhiteSpace(newChurchAccount.AccountName) || string.IsNullOrEmpty(newChurchAccount.AccountNumber) || string.IsNullOrEmpty(newChurchAccount.BankName) || string.IsNullOrEmpty(newChurchAccount.BankBranch)
                )
            {
                Error = this["ProvideValues"];
                return(false);
            }

            Error = null;
            return(true);
        }
コード例 #3
0
        public ChurchPageViewModel()
        {
            try
            {
                NewChurch = new Church();

                NewChurchAccount  = new ChurchAccountDetail();
                BrowseCommand     = new RelayCommand(Browse_E, Browse_C);
                SaveChurchCommand = new RelayCommand(SaveChurch_E, SaveChurch_C);

                SaveAccountCommand     = new RelayCommand(SaveAccountCommand_E, SaveAccountCommand_C);
                DeleteChurchCommand    = new RelayCommand(DeleteChurch_E, General_C);
                GeneralCommand         = new RelayCommand(null, General_C);
                DeleteAccDetailCommand = new RelayCommand(DeleteAccDetail_E, General_C);
                ClearBoxes             = new RelayCommand(Clear_E);
                AllChurches            = new ObservableCollection <Church>(db.Churches);
                currentContext         = SynchronizationContext.Current;
                SearchChurchCommand    = new RelayCommand(_ =>
                {
                    SearchChurch();
                });
            }
            catch { }
        }
コード例 #4
0
 private void Clear_E(object parameter)
 {
     NewChurchAccount = new ChurchAccountDetail();
     NewChurch        = new Church();
 }