コード例 #1
0
        public void NewForm()
        {
            nameTextBox.Text           = "";
            surnameTextBox.Text        = "";
            typeSubCombo.SelectedIndex = -1;
            dateOfBirthPicker.MaxDate  = new DateTime(DateTime.Today.Year - 18, DateTime.Today.Month, DateTime.Today.Day);
            dateOfBirthPicker.Value    =
                new DateTime(DateTime.Today.Year - 18, DateTime.Today.Month, DateTime.Today.Day - 2);
            if (!_firstIteration)
            {
                return;
            }
            var allSubscriptionTypes = _subscriptionRepo.GetAllSubscriptionTypes();

            if (allSubscriptionTypes.Count == 0)
            {
                MessageBox.Show("Please add an subscription model before adding an subscriber",
                                "Subscription model not exists", MessageBoxButtons.OK, MessageBoxIcon.Error);
                btnSave.Enabled = false;
            }
            foreach (var allSubscriptionType in allSubscriptionTypes)
            {
                typeSubCombo.Items.Add(allSubscriptionType.Category);
            }

            _firstIteration = false;
        }
コード例 #2
0
        private bool SetData()
        {
            if (_firstIteration)
            {
                foreach (var allSubscriptionType in _subscriptionRepo.GetAllSubscriptionTypes())
                {
                    typeSubCombo.Items.Add(allSubscriptionType.Category);
                }

                _firstIteration = false;
            }
            if (_subscriberRepo.GetAllSubscriber().Count == 0)
            {
                MessageBox.Show("No subscriber has been added yet", "Subscriber not exists error", MessageBoxButtons.OK,
                                MessageBoxIcon.Error);
                nameTextBox.Text          = "";
                surnameTextBox.Text       = "";
                dateOfBirthPicker.Value   = DateTime.Now;
                typeSubCombo.Text         = "";
                dateOfRenewalPicker.Value = DateTime.Now;
                btnSave.Enabled           = false;
            }

            if (_subscriberRepo.GetAllSubscriber().Count <= _index || _index < 0)
            {
                return(false);
            }
            nameTextBox.Text          = _subscriberRepo.GetAllSubscriber()[_index].Person.Name;
            surnameTextBox.Text       = _subscriberRepo.GetAllSubscriber()[_index].Person.Surname;
            dateOfBirthPicker.Value   = _subscriberRepo.GetAllSubscriber()[_index].Person.DateOfBirth.Value;
            typeSubCombo.Text         = _subscriberRepo.GetAllSubscriber()[_index].TypeSubscription.Category;
            dateOfRenewalPicker.Value = _subscriberRepo.GetAllSubscriber()[_index].DateOfRenewal;
            return(true);
        }
コード例 #3
0
        private bool SetData()
        {
            if (_subscriptionRepo.GetAllSubscriptionTypes().Count == 0)
            {
                MessageBox.Show("No subscription model has been added yet.", "Subscription model not exists error", MessageBoxButtons.OK,
                                MessageBoxIcon.Error);
                catNameTextBox.Text   = "";
                bookLimitTextBox.Text = "";
                priceTextBox.Text     = "";
                btnDelete.Enabled     = false;
            }

            if (_subscriptionRepo.GetAllSubscriptionTypes().Count <= _index || _index < 0)
            {
                return(false);
            }
            catNameTextBox.Text   = _subscriptionRepo.GetAllSubscriptionTypes()[_index].Category;
            bookLimitTextBox.Text = _subscriptionRepo.GetAllSubscriptionTypes()[_index].BookLimitAtOnce.ToString();
            priceTextBox.Text     = _subscriptionRepo.GetAllSubscriptionTypes()[_index].PricePerMonth.ToString();
            return(true);
        }