예제 #1
0
        private void DeleteButton_Click(object sender, RoutedEventArgs e)
        {
            if (Client.Id == 0)
            {
                MessageBox.Show("Выберете клиента!");
                return;
            }

            using (var db = new ClientsEntities())
            {
                var credits = db.Account.Where(a => (a.DepositTypeID == 3 || a.DepositTypeID == 4) && a.ClientID == Client.Id && !a.IsClosed).ToList();
                if (credits.Count == 0)
                {
                    var client = db.GetClientById(Client.Id);
                    db.Client.Remove(client);
                    db.SaveChanges();
                    MessageBox.Show("Информация о клиенте успешно удалена!");
                    ClearFields();
                }
                else
                {
                    MessageBox.Show("Клиент не может быть удалён, так как у него не погашен кредит!");
                }
            }
        }
예제 #2
0
 public AccountViewModel(Account account)
 {
     using (var db = new ClientsEntities())
     {
         var client = db.GetClientById(account.ClientID);
         _surname    = client?.Surname;
         _name       = client?.Name;
         _patronimic = client?.Patronimic;
         var depositType = db.GetDepositTypeById(account.DepositTypeID);
         _depositType   = depositType.Name;
         _accountNumber = account.AccountNumber;
         _moneyAmount   = account.MoneyAmount.ToString();
         _startDate     = account.StartDate;
         _endDate       = account.EndDate;
         _daysCount     = account.DaysCount.ToString();
         _percents      = depositType.Percents.ToString();
         _currency      = db.GetCurrencyById(account.CurrencyID);
         _isPercentage  = (account.PercentAccountID == null) ? "Да" : "Нет";
         if (account.PercentAccountID != null)
         {
             var percentAcc = db.GetAccountById(account.PercentAccountID.Value);
             _percentMoney = percentAcc.MoneyAmount.ToString();
         }
         _isClosed = account.IsClosed ? "Закрыт" : "Открыт";
     }
 }
예제 #3
0
        private void UpdateClientInfo()
        {
            using (var db = new ClientsEntities())
            {
                var client = db.GetClientById(Client.Id);

                client.Surname              = Client.Surname;
                client.Name                 = Client.Name;
                client.Patronimic           = Client.Patronimic;
                client.BirthDate            = Client.BirthDate;
                client.PassportSeries       = Client.PassportSeries;
                client.PassportNumber       = Client.PassportNumber;
                client.Authority            = Client.Authority;
                client.DateOfIssue          = Client.IssueDate;
                client.PlaceOfBirth         = Client.PlaceOfBirth;
                client.IdentificationNumber = Client.IdentificationNumber;
                client.Location             = db.GetCityIDByValue(Client.Location);
                client.Address              = Client.Address;
                client.MobileNumber         = Client.MobileNumber;
                client.PhoneNumber          = Client.PhoneNumber?.Replace("_", "");
                client.Email                = Client.Email;
                client.MaritalStatus        = db.GetMaritualStatusIDByValue(Client.MaritualStatus);
                client.Disability           = db.GetDisabilityIDByValue(Client.Disability);
                client.Nationality          = db.GetNationalityIDByValue(Client.Nationality);
                client.Pensioner            = Client.Pensioner;
                client.RegistrationCity     = db.GetCityIDByValue(Client.RegistrationCity);
                client.Gender               = (Client.MaleGender) ? true : false;
                client.MonthlyIncome        = ConvertStringToMoneyValue(Client.MonthlyIncome);

                db.SaveChanges();
            }
        }
예제 #4
0
        private void SelectButton_Click(object sender, RoutedEventArgs e)
        {
            var    selectedClientID = (ClientListDataGrid.SelectedItem as Client).ClientID;
            Client selectedClient;

            using (ClientsEntities db = new ClientsEntities())
            {
                selectedClient = db.GetClientById(selectedClientID);

                if (selectedClient != null)
                {
                    InitializeClient(selectedClient, db);
                }
            }

            this.Close();
        }