Ejemplo n.º 1
0
 public async Task <IActionResult> Create([Bind("Sum,LessonId")] PaymentBindingModel payment)
 {
     if (ModelState.IsValid)
     {
         payment.ClientId = Program.Client.Id;
         _paymentLogic.CreateOrUpdate(payment);
         return(RedirectToAction(nameof(Index)));
     }
     ViewData["LessonId"] = new SelectList(_lessonLogic.Read(null), "Id", "LessonName", payment.LessonId);
     return(View(payment));
 }
Ejemplo n.º 2
0
        private void buttonSave_Click(object sender, EventArgs e)
        {
            int sum;

            if (string.IsNullOrEmpty(comboBoxRoute.Text))
            {
                MessageBox.Show("Выберите маршрут", "Ошибка",
                                MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }
            if (string.IsNullOrEmpty(comboBoxReserve.Text))
            {
                MessageBox.Show("Выберите заповедник", "Ошибка",
                                MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }
            if (string.IsNullOrEmpty(textBoxSum.Text))
            {
                MessageBox.Show("Введите сумму", "Ошибка",
                                MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }
            else if (!int.TryParse(textBoxSum.Text, out sum))
            {
                MessageBox.Show("Внесённая сумма должна быть целым числом", "Ошибка",
                                MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }
            if (sum <= 0)
            {
                MessageBox.Show("Внесённая сумма должна быть больше нуля", "Ошибка",
                                MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }
            if (sum > Convert.ToDecimal(labelSum.Text))
            {
                MessageBox.Show("Внесённая сумма не должна быть больше суммы к оплате", "Ошибка",
                                MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }
            try
            {
                _paymentLogic.CreateOrUpdate(new PaymentBindingModel
                {
                    Sum       = sum,
                    ReserveId = Convert.ToInt32(comboBoxRoute.SelectedValue),
                    UserId    = Program.User.Id
                });
                DialogResult = DialogResult.OK;
                Close();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex?.InnerException.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
Ejemplo n.º 3
0
 public void CreatePayment(PaymentBindingModel model) => _payment.CreateOrUpdate(model);