コード例 #1
0
        }//----------------------

        #endregion

        #region Programmer's Defined Functions
        //this function will validate controls
        public Boolean ValidateControls()
        {
            Boolean isValid = true;

            _errProvider.SetError(this.cboAccountCategory, String.Empty);
            _errProvider.SetError(this.txtAccountCode, String.Empty);
            _errProvider.SetError(this.txtAccountName, String.Empty);
            _errProvider.SetError(this.btnSearchSummaryAccount, String.Empty);

            if (String.IsNullOrEmpty(_chartOfAccountInfo.AccountingCategoryInfo.AccountingCategoryId))
            {
                _errProvider.SetError(this.cboAccountCategory, "You must select a account category information.");
                _errProvider.SetIconAlignment(this.cboAccountCategory, ErrorIconAlignment.MiddleLeft);

                isValid = false;
            }

            if (String.IsNullOrEmpty(_chartOfAccountInfo.AccountCode))
            {
                _errProvider.SetError(this.txtAccountCode, "Account Code is required.");
                _errProvider.SetIconAlignment(this.txtAccountCode, ErrorIconAlignment.MiddleLeft);

                isValid = false;
            }
            else if (_chartOfAccountManager.IsExistsAccountCodeChartOfAccount(_userInfo, _chartOfAccountInfo.AccountSysId, _chartOfAccountInfo.AccountCode,
                                                                              _chartOfAccountInfo.SummaryAccount.AccountSysId))
            {
                _errProvider.SetError(this.txtAccountCode, "Account Code already exist.");
                _errProvider.SetIconAlignment(this.txtAccountCode, ErrorIconAlignment.MiddleLeft);

                isValid = false;
            }

            if (String.IsNullOrEmpty(_chartOfAccountInfo.AccountName))
            {
                _errProvider.SetError(this.txtAccountName, "Account Name is required.");
                _errProvider.SetIconAlignment(this.txtAccountName, ErrorIconAlignment.MiddleLeft);

                isValid = false;
            }

            if (!String.IsNullOrEmpty(_chartOfAccountInfo.SummaryAccount.AccountSysId) &&
                !_chartOfAccountManager.IsValidCategoryBySummaryAccountChartOfAccount(_userInfo, _chartOfAccountInfo.AccountingCategoryInfo.AccountingCategoryId,
                                                                                      _chartOfAccountInfo.SummaryAccount.AccountSysId))
            {
                _errProvider.SetError(this.btnSearchSummaryAccount, "Summary of Account is not valid.");
                _errProvider.SetIconAlignment(this.btnSearchSummaryAccount, ErrorIconAlignment.MiddleLeft);

                isValid = false;
            }

            return(isValid);
        }//--------------------