예제 #1
0
        protected override bool ValidData()
        {
            if (string.IsNullOrEmpty(AccountCode))
            {
                XtraMessageBox.Show(ResourceHelper.GetResourceValueByName("ResAccountCode"),
                                    ResourceHelper.GetResourceValueByName("ResDetailContent"), MessageBoxButtons.OK, MessageBoxIcon.Error);
                txtAccountCode.Focus();
                return(false);
            }
            var listAccount = _accountsPresenter.GetAccountsActive();

            foreach (var accountModel in listAccount)
            {
                // option Edit
                if (AccountId > 0)
                {
                    if (accountModel.AccountId != AccountId)
                    {
                        if (accountModel.AccountCode == AccountCode)
                        {
                            XtraMessageBox.Show(ResourceHelper.GetResourceValueByName("ResCheckAccountsCode"),
                                                ResourceHelper.GetResourceValueByName("ResDetailContent"),
                                                MessageBoxButtons.OK, MessageBoxIcon.Error);
                            txtAccountCode.Focus();
                            return(false);
                        }
                    }
                }
                // option Add New
                else
                {
                    if (accountModel.AccountCode == AccountCode)
                    {
                        XtraMessageBox.Show(ResourceHelper.GetResourceValueByName("ResCheckAccountsCode"),
                                            ResourceHelper.GetResourceValueByName("ResDetailContent"),
                                            MessageBoxButtons.OK, MessageBoxIcon.Error);
                        txtAccountCode.Focus();
                        return(false);
                    }
                }
            }
            // Kiểm tra khi có tài khoản tiết con thì mã của Cha chứa mã con
            if (!AccountCode.Contains(grdLockUpParentID.Text))
            {
                XtraMessageBox.Show(ResourceHelper.GetResourceValueByName("ResContainCodesParentError"),
                                    ResourceHelper.GetResourceValueByName("ResDetailContent"), MessageBoxButtons.OK, MessageBoxIcon.Error);
                txtAccountCode.Focus();
                return(false);
            }
            if (string.IsNullOrEmpty(AccountName))
            {
                XtraMessageBox.Show(ResourceHelper.GetResourceValueByName("ResAccountName"),
                                    ResourceHelper.GetResourceValueByName("ResDetailContent"), MessageBoxButtons.OK, MessageBoxIcon.Error);
                txtAccountName.Focus();
                return(false);
            }
            if (string.IsNullOrEmpty(grdLockUpCategoryID.Text))
            {
                XtraMessageBox.Show(ResourceHelper.GetResourceValueByName("ResAccountCategory"),
                                    ResourceHelper.GetResourceValueByName("ResDetailContent"), MessageBoxButtons.OK, MessageBoxIcon.Error);
                grdLockUpCategoryID.Focus();
                return(false);
            }
            if (string.IsNullOrEmpty(cboBalance.Text))
            {
                XtraMessageBox.Show(ResourceHelper.GetResourceValueByName("ResBalanceSide"),
                                    ResourceHelper.GetResourceValueByName("ResDetailContent"), MessageBoxButtons.OK, MessageBoxIcon.Error);
                cboBalance.Focus();
                return(false);
            }
            if (AccountCode == grdLockUpParentID.Text)
            {
                XtraMessageBox.Show(ResourceHelper.GetResourceValueByName("ResCodeSameAsParentError"),
                                    ResourceHelper.GetResourceValueByName("ResDetailContent"), MessageBoxButtons.OK, MessageBoxIcon.Error);
                grdLockUpParentID.Focus();
                return(false);
            }

            return(true);
        }