Exemplo n.º 1
0
        /// <summary>
        /// This method validates the account information
        /// </summary>
        /// <param name="acct"></param>
        /// <param name="invalidAccts"></param>
        /// <returns></returns>
        private bool ValidateAccountInfo(KPMGAccount acct, List<KPMGAccount> invalidAccts)
        {
            bool IsValid = true;
            string reason = string.Empty;
            KPMGAccount invalidAcct = new KPMGAccount();

            if (!ValidateAccount(acct.Account))
            {
                reason = Constants.VAL_MSG_NO_ACCOUNT;
                IsValid = false;
                invalidAcct.Account = null;
            }
            else { invalidAcct.Account = acct.Account; }

            if (!ValidateAccount(acct.Description))
            {
                reason = reason + Constants.VAL_MSG_NO_DESC;
                IsValid = false;
                invalidAcct.Description = null;
            }
            else { invalidAcct.Description = acct.Description; }

            if (!ValidateAmount(acct.Amount))
            {
                reason = reason + Constants.VAL_MSG_NO_AMOUNT;
                IsValid = false;
                invalidAcct.Amount = null;
            }
            else { invalidAcct.Amount = acct.Amount; }

            if (!MvcApplication.lstCurrencyCodes.Exists(x => x.code == acct.CurrencyCode))
            {
                reason = reason + Constants.VAL_MSG_NO_AMOUNT;
                IsValid = false;
                invalidAcct.CurrencyCode = null;
            }
            else { invalidAcct.CurrencyCode = acct.CurrencyCode; }

            if (!IsValid)
            {
                invalidAcct.Reason = reason;
                invalidAccts.Add(invalidAcct);
            }

            return IsValid;
        }
Exemplo n.º 2
0
        /// <summary>
        /// This method validates the excel data and separates valid and invalid accounts
        /// </summary>
        public void ValidateData()
        {
            KPMGAccount acct;
            for (int i = 0; i < _localObjAccountBO.FileData.Tables[0].Rows.Count; i++)
            {
                acct = new KPMGAccount();
                decimal amt;

                acct.Account = _localObjAccountBO.FileData.Tables[0].Rows[i][0].ToString();

                acct.Description = _localObjAccountBO.FileData.Tables[0].Rows[i][1].ToString();
                acct.CurrencyCode = _localObjAccountBO.FileData.Tables[0].Rows[i][2].ToString();
                if (decimal.TryParse(_localObjAccountBO.FileData.Tables[0].Rows[i][3].ToString(), out amt))
                {
                    acct.Amount = amt;
                }

                if (ValidateAccountInfo(acct, lstInvalidAcct))
                { lstValidAcct.Add(acct); }
            }
        }