Ejemplo n.º 1
0
        void Save()
        {
            if (!ValidData())
            {
                string msg = null;
                foreach (var viol in RulesViolations)
                {
                    msg += viol.ErrorMessage;
                }
                RulesViolations.Clear();
                Helper.ShowMessage(msg);
                return;
            }

            try
            {
                WriteModelValues(_currnetModel);
                if (_modelState == ModelState.New)
                {
                    _currnetModel.LoanStatus = LoansStatuses.Single(x => x.Id == 1);
                    _repository.Add(_currnetModel);
                }
                _unitOfWork.Save();
                SetState(ModelState.Saved);
            }
            catch (Exception ex)
            {
                string msg = Helper.ProcessExceptionMessages(ex);
                Helper.ShowMessage(msg);
            }
        }
Ejemplo n.º 2
0
        private void Save()
        {
            if (!ValidData())
            {
                string msg = null;
                foreach (RuleViolation viol in RulesViolations)
                {
                    msg += viol.ErrorMessage;
                }
                RulesViolations.Clear();
                Helper.ShowMessage(msg);
                return;
            }

            try
            {
                WriteModelValues(_currnetModel);
                if (_modelState == ModelState.New)
                {
                    _repository.Add(_currnetModel);
                }
                _unitOfWork.Save();
                SetState(ModelState.Saved);
            }
            catch (Exception)
            {
                throw;
            }
        }
Ejemplo n.º 3
0
        bool ValidData()
        {
            bool valid = true;

            if (Member == null)
            {
                RulesViolations.Add(new RuleViolation(Properties.Resources.LoansView_MemberMissing));
                return(false);
            }
            if (LoanType == null)
            {
                RulesViolations.Add(new RuleViolation(Properties.Resources.LoansView_LoanTypeMissing));
                return(false);
            }
            if (LoanYear == null)
            {
                RulesViolations.Add(new RuleViolation(Properties.Resources.LoansView_LoanYearMissing));
                return(false);
            }
            if (PaymentSequence == null)
            {
                RulesViolations.Add(new RuleViolation(Properties.Resources.LoansView_PaySeqMissing));
                return(false);
            }
            if (Balance < 0)
            {
                RulesViolations.Add(new RuleViolation(Properties.Resources.LoansView_InsufBalance));
                return(false);
            }
            if (Amount == 0)
            {
                RulesViolations.Add(new RuleViolation(Properties.Resources.LoansView_ZeroloanAmount));
                return(false);
            }
            if (_modelState == ModelState.New)
            {
                var currYearLoans = _repository.Query(
                    lo => lo.PeriodSetting.Id == LoanYear.Id
                    &&
                    lo.PaymentSequence.Id == PaymentSequence.Id
                    );
                bool exist = currYearLoans.Any(
                    lo => lo.FamilyMember.Code == Member.Code
                    &&
                    lo.LoanType.Code == LoanType.Code
                    );
                if (exist)
                {
                    RulesViolations.Add(new RuleViolation(Properties.Resources.LoansView_ExistMemberLoan));
                    return(false);
                }
            }
            if (string.IsNullOrEmpty(Description))
            {
                RulesViolations.Add(new RuleViolation(Properties.Resources.LoansView_DescriptionMissing));
                return(false);
            }
            return(valid);
        }
Ejemplo n.º 4
0
        private bool ValidData()
        {
            if (string.IsNullOrEmpty(StartDate) || !Helper.ValidDate(StartDate))
            {
                RulesViolations.Add(new RuleViolation(Properties.Resources.PeriodView_InvalidStartDate));
                return(false);
            }
            if (string.IsNullOrEmpty(EndDate) || !Helper.ValidDate(EndDate))
            {
                RulesViolations.Add(new RuleViolation(Properties.Resources.PeriodView_InvalidEndDate));
                return(false);
            }
            int i = String.CompareOrdinal(StartDate, EndDate);

            if (i >= 0)
            {
                RulesViolations.Add(new RuleViolation(Properties.Resources.PeriodView_InconsistentStartEndDate));
                return(false);
            }
            string startYearPart = StartDate.Substring(0, 4);
            string endYearPart   = EndDate.Substring(0, 4);

            if (startYearPart != endYearPart)
            {
                RulesViolations.Add(new RuleViolation(Properties.Resources.PeriodView_YearPartNotMatch));
                return(false);
            }
            if (_modelState == ModelState.New && _repository.GetAll().Any(x => x.StartDate == StartDate))
            {
                RulesViolations.Add(new RuleViolation(Properties.Resources.PeriodView_AlreadyRegistredYear));
                return(false);
            }
            if (SelectedStatus == null)
            {
                RulesViolations.Add(new RuleViolation(Properties.Resources.PeriodView_PeriodStutsMissing));
                return(false);
            }
            if (CurrentPeriod != null && _currnetModel.Id != CurrentPeriod.Id &&
                SelectedStatus.Id == 2)
            {
                RulesViolations.Add(new RuleViolation(Properties.Resources.PeriodView_InvalidPeriodStatus));
                return(false);
            }
            if (YearSequences.Count == 0)
            {
                RulesViolations.Add(new RuleViolation(Properties.Resources.PeriodView_YearSeqMissing));
                return(false);
            }


            return(true);
        }
Ejemplo n.º 5
0
        bool ValidData()
        {
            bool valid = true;

            if (Code < 10)
            {
                RulesViolations.Add(new RuleViolation(Properties.Resources.LoanTypesView_InvalidCode));
                return(false);
            }
            if (string.IsNullOrEmpty(Description))
            {
                RulesViolations.Add(new RuleViolation(Properties.Resources.LoanTypesView_MissingDescription));
                return(false);
            }


            return(valid);
        }