示例#1
0
        // рассчитать социальное положение
        private void CalculationGroupButton_Click(object sender, System.Windows.RoutedEventArgs e)
        {
            if (txtChildren.Text == "" || txtRevenueYear.Text == "")
            {
                MessageBoxWPF.Show("Не все поля заполнены!", "Сообщение.", MessageBoxButton.OK,
                                   MessageBoxImage.Information);
                return;
            }
            string group    = ""; // группа платёжеспособности
            int    maxSumma = 0;  // макс. сумма кредита по группе плат-ти

            string sex         = cmbSex.SelectedValue.ToString();
            string married     = cmbMarried.SelectedValue.ToString();
            int    children    = Convert.ToInt32(txtChildren.Text);
            int    age         = Convert.ToInt32(txtAge.Text);
            int    revenueYear = Convert.ToInt32(txtRevenueYear.Text);

            List <GroupCharacter> listGroup = repository.AlgorirmForGroup(revenueYear, sex, age, children, married).ToList();

            if (listGroup.Count() != 0)
            {
                foreach (var item in listGroup)
                {
                    group    = group + item.GroupCreditWorthinessObj.Name;
                    maxSumma = item.GroupCreditWorthinessObj.MaxSumma > maxSumma ? item.GroupCreditWorthinessObj.MaxSumma : maxSumma;
                }
            }

            txtGroup.Text    = group;
            txtMaxSumma.Text = maxSumma.ToString();
        }
示例#2
0
        // рассчитать экономические параметры
        private void CalculationButton_Click(object sender, System.Windows.RoutedEventArgs e)
        {
            if (txtRevenueYear.Text == "" || txtMonth.Text == "" || txtStavka.Text == "")
            {
                MessageBoxWPF.Show("Не все поля заполнены!", "Сообщение.", MessageBoxButton.OK,
                                   MessageBoxImage.Information);
                return;
            }
            int pay = 0;              // платёжеспособность
            int maxSummaEconomic = 0; // макс сумма кредита по эконом показателям

            int revenueYear = Convert.ToInt32(txtRevenueYear.Text);
            int month       = Convert.ToInt32(txtMonth.Text);
            int stavka      = Convert.ToInt32(txtStavka.Text);

            if (month > 36 || month == 0)
            {
                MessageBoxWPF.Show("Не верный срок кредита, макс. кол-во месяцев 36!", "Сообщение.", MessageBoxButton.OK, MessageBoxImage.Information);
                return;
            }

            int revenueMonth = revenueYear / 12; // среднемесячный доход

            int[] arrayEconomic = repository.AlgoritmEconomicValue(revenueMonth, month, stavka);
            pay = arrayEconomic[0];
            maxSummaEconomic = arrayEconomic[1];

            txtPay.Text = pay.ToString();
            txtMaxSummaEconomic.Text = maxSummaEconomic.ToString();
        }
示例#3
0
        private void UpdateModel(GroupCreditWorthinesViewModel model)
        {
            if (model == null)
            {
                return;
            }
            AddGroupCreditWorthinesView view = new AddGroupCreditWorthinesView(false, model.GetModel, repository)
            {
                ShowInTaskbar = false
            };

            view.ShowDialog();
            if (view.DialogResult != true)
            {
                return;
            }

            bool flag = repository.UpdateGroupCreditWorthiness(model.GetModel);

            if (!flag)
            {
                MessageBoxWPF.Show(StringProject.ErrorUpdRecort, StringProject.ErrorCaption, MessageBoxButton.OK, MessageBoxImage.Error);
                return;
            }
            model.RefreshModel();
        }
示例#4
0
        private void UpdateModel(UserViewModel model)
        {
            if (model == null)
            {
                MessageBoxWPF.Show("Выберите заёмщика!", "Сообщение.", MessageBoxButton.OK, MessageBoxImage.Information);
                return;
            }
            AddUserView view = new AddUserView(model.GetModel, repository)
            {
                ShowInTaskbar = false
            };

            view.ShowDialog();
            if (view.DialogResult != true)
            {
                return;
            }

            bool flag = repository.UpdateUser(model.GetModel);

            if (!flag)
            {
                MessageBoxWPF.Show(StringProject.ErrorUpdRecort, StringProject.ErrorCaption, MessageBoxButton.OK, MessageBoxImage.Error);
                return;
            }
            model.RefreshModel();
        }
示例#5
0
 private void PrintModel(CreditViewModel model)
 {
     if (model == null)
     {
         MessageBoxWPF.Show("Выберите кредит!", "Сообщение.", MessageBoxButton.OK, MessageBoxImage.Information);
         return;
     }
     PrintReport.PrintCredit(model, repository);
 }
        private void DeleteModel(GroupCharacterViewModel model)
        {
            if (model == null) return;
            if (MessageBoxWPF.Show("Вы действительно хотите удалить параметр ?", StringProject.MessageCaption, MessageBoxButton.YesNo, MessageBoxImage.Question) == MessageBoxResult.No)
                return;

            bool flag = repository.DeleteGroupCharacter(model.GetModel);
            if (!flag)
            {
                MessageBoxWPF.Show(StringProject.ErrorDelRecort, StringProject.ErrorCaption, MessageBoxButton.OK, MessageBoxImage.Error);
                return;
            }
            AllModel.Remove(model);
        }
示例#7
0
        private void TxtSummaPay_OnTextChanged(object sender, KeyEventArgs e)
        {
            int summaPay = Convert.ToInt32(txtSummaPay.Text);

            if ((model.SummaMonth - summaPay) < 0)
            {
                txtSummaPay.Text  = "";
                txtSummalost.Text = "";
                MessageBoxWPF.Show("Сумма внесённого платежа превышает ежемесячную сумму платежа!", "Сообщение.",
                                   MessageBoxButton.OK, MessageBoxImage.Information);
                return;
            }
            txtSummalost.Text = (model.SummaMonth - summaPay).ToString();
        }
示例#8
0
        // рассчитать ежемесячный платёж
        private void CalculationPayButton_Click(object sender, System.Windows.RoutedEventArgs e)
        {
            int summaSocial   = Convert.ToInt32(txtMaxSumma.Text);
            int summaEconomic = Convert.ToInt32(txtMaxSummaEconomic.Text);

            txtResulSocial.Text    = "";
            txtResultEconomic.Text = "";

            if (txtSummaCredit.Text == "" || txtMonthCredit.Text == "" || txtStavka.Text == "")
            {
                MessageBoxWPF.Show("Не все поля заполнены!", "Сообщение.", MessageBoxButton.OK,
                                   MessageBoxImage.Information);
                return;
            }

            int pay = 0;     // ежемесячный платёж

            int summa  = Convert.ToInt32(txtSummaCredit.Text);
            int month  = Convert.ToInt32(txtMonthCredit.Text);
            int stavka = Convert.ToInt32(txtStavka.Text);

            if (month > 36 || month == 0)
            {
                MessageBoxWPF.Show("Не верный срок кредита, макс. кол-во месяцев 36!", "Сообщение.", MessageBoxButton.OK,
                                   MessageBoxImage.Information);
                return;
            }

            if (stavka > 100 || month == 0)
            {
                MessageBoxWPF.Show("Не верная процентная ставка!", "Сообщение.", MessageBoxButton.OK,
                                   MessageBoxImage.Information);
                return;
            }

            pay = repository.AlgoritmMonthPay(summa, stavka, month);

            txtSummaMonth.Text = pay.ToString();

            if (summa > summaSocial)
            {
                txtResulSocial.Text = "Не соответствует социальным параметрам";
            }
            if (summa > summaEconomic)
            {
                txtResultEconomic.Text = "Не соответствует экономическим параметрам";
            }
        }
示例#9
0
        private void UpdateModel(CreditViewModel model)
        {
            if (model == null)
            {
                MessageBoxWPF.Show("Выберите кредит!", "Сообщение.", MessageBoxButton.OK, MessageBoxImage.Information);
                return;
            }
            Payment modelPay = repository.SearchPayment(model.Id);

            if (modelPay == null)
            {
                MessageBoxWPF.Show("Кредит уже выплачен!", "Сообщение.", MessageBoxButton.OK, MessageBoxImage.Information);
                return;
            }
            AddPaymentView view = new AddPaymentView(modelPay, repository)
            {
                ShowInTaskbar = false
            };

            view.ShowDialog();
            if (view.DialogResult != true)
            {
                return;
            }

            bool flag = repository.UpdatePayment(modelPay);

            if (!flag)
            {
                MessageBoxWPF.Show(StringProject.ErrorUpdRecort, StringProject.ErrorCaption, MessageBoxButton.OK, MessageBoxImage.Error);
                return;
            }

            List <Payment> list = repository.GetPaymentsByIdCredit(model.Id).ToList();

            if (list.All(x => x.Repay != false))
            {
                ConditionCredit modelConditionCredit = new ConditionCredit
                {
                    Data        = DateTime.Now,
                    IdCredit    = model.Id,
                    IdCondition = 2 // выплачен
                };
                //Сохранение состояния кредита в БД
                repository.AddConditionCredit(modelConditionCredit);
            }
            model.RefreshModel();
        }
        private void AddModel()
        {
            GroupCharacter model = new GroupCharacter();
            AddGroupCharacterView view = new AddGroupCharacterView(true, model, repository) { ShowInTaskbar = false };
            view.ShowDialog();

            if (view.DialogResult != true) return;

            model.Id = repository.AddGroupCharacter(model);
            if (model.Id == 0)
            {
                MessageBoxWPF.Show(StringProject.ErrorAddRecort, StringProject.ErrorCaption, MessageBoxButton.OK, MessageBoxImage.Error);
                return;
            }
            AllModel.Add(new GroupCharacterViewModel(model));
        }
示例#11
0
        public static void CatchExeption(Exception ex)
        {
            if (ex is ReflectionTypeLoadException)
            {
                string message = "Unable to load dll:";

                if (((ReflectionTypeLoadException)ex).LoaderExceptions != null)
                {
                    message += string.Join(Environment.NewLine, ((ReflectionTypeLoadException)ex).LoaderExceptions.Select(exception => exception.Message));
                }

                MessageBoxWPF.ShowError(Application.Current.MainWindow, MessageBoxButton.OK, message);
            }
            else
            {
                MessageBoxWPF.ShowError(Application.Current.MainWindow, MessageBoxButton.OK, "An unhandled exception just occurred: " + ex.Message);
            }
        }
示例#12
0
        public void ShowPaymentModel(CreditViewModel model)
        {
            if (model == null)
            {
                MessageBoxWPF.Show("Выберите кредит!", "Сообщение.", MessageBoxButton.OK, MessageBoxImage.Information);
                return;
            }
            List <Payment>   list = repository.GetPaymentsByIdCredit(model.Id).ToList();
            ShowPaymentsView view = new ShowPaymentsView(list)
            {
                ShowInTaskbar = false
            };

            view.ShowDialog();
            if (view.DialogResult != true)
            {
                return;
            }
        }
示例#13
0
        public void ShowUserCreditModel(UserViewModel model)
        {
            if (model == null)
            {
                MessageBoxWPF.Show("Выберите заёмщика!", "Сообщение.", MessageBoxButton.OK, MessageBoxImage.Information);
                return;
            }
            List <Credit>       list = repository.GetCreditsByIdUser(model.Id).ToList();
            ShowUsersCreditView view = new ShowUsersCreditView(list)
            {
                ShowInTaskbar = false
            };

            view.ShowDialog();
            if (view.DialogResult != true)
            {
                return;
            }
        }
示例#14
0
        // Сохранить
        private void SaveButton_Click(object sender, System.Windows.RoutedEventArgs e)
        {
            if (!String.IsNullOrEmpty(txtSummaPay.Text))
            {
                if ((model.SummaMonth - Convert.ToInt32(txtSummaPay.Text)) < 0)
                {
                    MessageBoxWPF.Show("Сумма внесённого платежа превышает ежемесячную сумму платежа!", "Сообщение.",
                                       MessageBoxButton.OK, MessageBoxImage.Information);
                    return;
                }

                model.SummaMonth = model.SummaMonth - Convert.ToInt32(txtSummaPay.Text);
                if (model.SummaMonth == 0)
                {
                    model.Repay = true;
                }
                this.DialogResult = true;
                this.Close();
            }
        }
示例#15
0
        private void DeleteModel(GroupCreditWorthinesViewModel model)
        {
            if (model == null)
            {
                return;
            }
            if (MessageBoxWPF.Show("Вы действительно хотите удалить группу <" + model.Name + "> ?", StringProject.MessageCaption, MessageBoxButton.YesNo, MessageBoxImage.Question) == MessageBoxResult.No)
            {
                return;
            }

            bool flag = repository.DeleteGroupCreditWorthiness(model.GetModel);

            if (!flag)
            {
                MessageBoxWPF.Show(StringProject.ErrorDelRecort, StringProject.ErrorCaption, MessageBoxButton.OK, MessageBoxImage.Error);
                return;
            }
            AllModel.Remove(model);
        }
示例#16
0
        private void DeleteModel(UserViewModel model)
        {
            if (model == null)
            {
                MessageBoxWPF.Show("Выберите заёмщика!", "Сообщение.", MessageBoxButton.OK, MessageBoxImage.Information);
                return;
            }
            if (MessageBoxWPF.Show("Вы действительно хотите удалить пользователя <" + model.Fio + "> ?", StringProject.MessageCaption, MessageBoxButton.YesNo, MessageBoxImage.Question) == MessageBoxResult.No)
            {
                return;
            }

            bool flag = repository.DeleteUser(model.GetModel);

            if (!flag)
            {
                MessageBoxWPF.Show(StringProject.ErrorDelRecort, StringProject.ErrorCaption, MessageBoxButton.OK, MessageBoxImage.Error);
                return;
            }
            AllModel.Remove(model);
        }
示例#17
0
        private void AddModel(CreditViewModel model)
        {
            Credit           modelCredit = new Credit();
            User             modelUser   = new User();
            List <Payment>   listPayment = new List <Payment>();
            CreateCreditView view;

            if (model == null)
            {
                view = new CreateCreditView(true, repository, modelUser, modelCredit)
                {
                    ShowInTaskbar = false
                };
            }
            else
            {
                modelUser = repository.FirstUser(model.IdUser);
                view      = new CreateCreditView(false, repository, modelUser, modelCredit)
                {
                    ShowInTaskbar = false
                };
            }

            view.ShowDialog();

            if (view.DialogResult != true)
            {
                return;
            }

            if (model == null)
            {
                //Сохранение пользователя в БД
                modelUser.Id = repository.AddUser(modelUser);
                if (modelUser.Id == 0)
                {
                    MessageBoxWPF.Show(StringProject.ErrorAddRecort, StringProject.ErrorCaption, MessageBoxButton.OK,
                                       MessageBoxImage.Error);
                    return;
                }
            }

            modelCredit.IdUser  = modelUser.Id;
            modelCredit.UserObj = repository.FirstUser(modelUser.Id);
            //Сохранение кредита в БД
            modelCredit.Id = repository.AddCredit(modelCredit);

            if (modelCredit.Id == 0)
            {
                MessageBoxWPF.Show(StringProject.ErrorAddRecort, StringProject.ErrorCaption, MessageBoxButton.OK, MessageBoxImage.Error);
                return;
            }

            listPayment = repository.CalculationPayment(modelCredit.SummaFull, modelCredit.SummaMonth,
                                                        modelCredit.Stavka, modelCredit.TermMonth, modelCredit.DataStart).ToList();

            foreach (Payment item in listPayment)
            {
                item.IdCredit = modelCredit.Id;
                //Сохранение графика платежей в БД
                repository.AddPayment(item);
            }

            ConditionCredit modelConditionCredit = new ConditionCredit
            {
                Data        = DateTime.Now,
                IdCredit    = modelCredit.Id,
                IdCondition = 1 // оформлен
            };

            //Сохранение состояния кредита в БД
            repository.AddConditionCredit(modelConditionCredit);

            AllModel.Add(new CreditViewModel(modelCredit, repository));
        }