Exemplo n.º 1
0
        public bool IsValid(hihDataContext context)
        {
            var isvalid = true;

            if (ItemID <= 0)
            {
                isvalid = false;
            }
            if (isvalid)
            {
                if (AccountID <= 0)
                {
                    isvalid = false;
                }
                else
                {
                    isvalid = context.FinanceAccount.Where(p => p.ID == AccountID).Count() == 1;
                }
            }
            if (isvalid)
            {
                if (TranType <= 0)
                {
                    isvalid = false;
                }
                else
                {
                    isvalid = context.FinTransactionType.Where(p => p.ID == TranType).Count() == 1;
                }
            }

            return(isvalid);
        }
Exemplo n.º 2
0
        public override bool IsValid(hihDataContext context)
        {
            if (!base.IsValid(context))
            {
                return(false);
            }

            return(true);
        }
Exemplo n.º 3
0
        public override bool IsDeleteAllowed(hihDataContext context)
        {
            if (!base.IsDeleteAllowed(context))
            {
                return(false);
            }

            return(true);
        }
Exemplo n.º 4
0
        public override bool IsDeleteAllowed(hihDataContext context)
        {
            if (!base.IsDeleteAllowed(context))
            {
                return(false);
            }

            var refcnt = 0;

            // Document items
            refcnt = context.FinanceDocumentItem.Where(p => p.OrderID == this.ID).Count();
            if (refcnt > 0)
            {
                return(false);
            }

            return(true);
        }
Exemplo n.º 5
0
        public override bool IsDeleteAllowed(hihDataContext context)
        {
            if (!base.IsDeleteAllowed(context))
            {
                return(false);
            }

            // Account
            var refcnt = 0;

            // Documents
            refcnt = context.FinanceAccountExtraAS.Where(p => p.CategoryID == this.ID).Count();
            if (refcnt > 0)
            {
                return(false);
            }

            return(true);
        }
Exemplo n.º 6
0
        public override bool IsValid(hihDataContext context)
        {
            var bValid = base.IsValid(context);

            if (!bValid)
            {
                return(false);
            }

            if (bValid && HomeID <= 0)
            {
                return(false);
            }

            if (bValid && CategoryID <= 0)
            {
                return(false);
            }

            if (bValid && String.IsNullOrEmpty(Name))
            {
                bValid = false;
            }

            if (bValid && String.IsNullOrEmpty(Content))
            {
                bValid = false;
            }

            if (bValid && context != null)
            {
                bValid = context.HomeDefines.Where(p => p.ID == HomeID).Count() == 1;
                if (bValid)
                {
                    bValid = context.LearnCategories
                             .Where(p => p.ID == CategoryID && (p.HomeID == null || p.HomeID == HomeID))
                             .Count() == 1;
                }
            }
            return(bValid);
        }
Exemplo n.º 7
0
        public override bool IsValid(hihDataContext context)
        {
            var bValid = base.IsValid(context);

            if (!bValid)
            {
                return(false);
            }

            if (String.IsNullOrEmpty(Name))
            {
                bValid = false;
            }

            //if (bValid && !HomeID.HasValue)
            //    bValid = false;

            if (bValid && ParentID.HasValue)
            {
                if (!HomeID.HasValue)
                {
                    bValid = false;
                }
            }

            if (bValid && context != null && (HomeID.HasValue || ParentID.HasValue))
            {
                if (HomeID.HasValue)
                {
                    bValid = context.HomeDefines.Where(p => p.ID == HomeID.Value).Count() == 1;
                }
                if (bValid && ParentID.HasValue)
                {
                    bValid = context.LearnCategories
                             .Where(p => p.ID == ParentID.Value && (p.HomeID == null || p.HomeID == HomeID.Value))
                             .Count() == 1;
                }
            }

            return(bValid);
        }
Exemplo n.º 8
0
        public override bool IsValid(hihDataContext context)
        {
            if (!base.IsValid(context))
            {
                return(false);
            }

            // Check Validility
            var ts = ValidTo - ValidFrom;

            if (ts.TotalSeconds < 0)
            {
                return(false);
            }

            // SRule must exist
            if (SRule.Count <= 0)
            {
                return(false);
            }

            // Percentage checks
            var total = 0;

            foreach (var rule in SRule)
            {
                if (!rule.IsValid())
                {
                    return(false);
                }

                total += rule.Precent;
            }
            if (total != 100)
            {
                return(false);
            }

            return(true);
        }
Exemplo n.º 9
0
        public override bool IsValid(hihDataContext context)
        {
            if (!base.IsValid(context))
            {
                return(false);
            }

            if (String.IsNullOrEmpty(Host))
            {
                return(false);
            }
            if (String.IsNullOrEmpty(Name))
            {
                return(false);
            }
            if (String.IsNullOrEmpty(BaseCurrency))
            {
                return(false);
            }
            if (HomeMembers.Count <= 0)
            {
                return(false);
            }
            var self = HomeMembers.First(p => p.Relation == HomeMemberRelationType.Self);

            if (self == null)
            {
                return(false);
            }
            else
            {
                if (self.User != this.Host)
                {
                    return(false);
                }
            }

            return(true);
        }
Exemplo n.º 10
0
        public override bool IsValid(hihDataContext context)
        {
            if (!base.IsValid(context))
            {
                return(false);
            }

            if (Items.Count == 0)
            {
                return(false);
            }

            foreach (var item in Items)
            {
                if (!item.IsValid(context))
                {
                    return(false);
                }
            }

            return(true);
        }
Exemplo n.º 11
0
 public override bool IsValid(hihDataContext context)
 {
     return(base.IsValid(context));
 }
Exemplo n.º 12
0
        public override bool IsValid(hihDataContext context)
        {
            var isValid = base.IsValid(context);

            if (!isValid)
            {
                return(false);
            }

            // Perform own check logic
            // Home ID
            if (HomeID <= 0)
            {
                isValid = false;
            }
            // Currency
            if (isValid)
            {
                if (String.IsNullOrEmpty(TranCurr))
                {
                    isValid = false;
                }
            }
            // Description
            if (isValid)
            {
                if (String.IsNullOrEmpty(Description))
                {
                    isValid = false;
                }
            }
            // Date Range
            if (isValid)
            {
                if (TargetDate < StartDate)
                {
                    isValid = false;
                }
            }
            // Plan type and its value
            if (isValid)
            {
                switch (PlanType)
                {
                case FinancePlanTypeEnum.Account:
                    if (AccountID.HasValue)
                    {
                        var acntexist = context.FinanceAccount.Where(p => p.ID == AccountID.Value && p.HomeID == HomeID).Count();
                        if (acntexist < 1)
                        {
                            isValid = false;
                        }
                    }
                    else
                    {
                        isValid = false;
                    }
                    break;

                case FinancePlanTypeEnum.AccountCategory:
                    if (AccountCategoryID.HasValue)
                    {
                        var ctgexist = context.FinAccountCategories.Where(p => p.ID == AccountCategoryID.Value).Count();
                        if (ctgexist < 1)
                        {
                            isValid = false;
                        }
                    }
                    else
                    {
                        isValid = false;
                    }
                    break;

                case FinancePlanTypeEnum.ControlCenter:
                    if (ControlCenterID.HasValue)
                    {
                        var ccexist = context.FinanceControlCenter.Where(p => p.ID == ControlCenterID.Value).Count();
                        if (ccexist < 1)
                        {
                            isValid = false;
                        }
                    }
                    else
                    {
                        isValid = false;
                    }
                    break;

                case FinancePlanTypeEnum.TranType:
                    if (TranTypeID.HasValue)
                    {
                        var ttexist = context.FinTransactionType.Where(p => p.ID == TranTypeID.Value).Count();
                        if (ttexist < 1)
                        {
                            isValid = false;
                        }
                    }
                    else
                    {
                        isValid = false;
                    }
                    break;

                default:
                    isValid = false;
                    break;
                }
            }

            return(isValid);
        }
Exemplo n.º 13
0
        public override bool IsDeleteAllowed(hihDataContext context)
        {
            if (!base.IsDeleteAllowed(context))
            {
                return(false);
            }

            // Check whether there still data exists
            // Account category
            var refcnt = 0;

            refcnt = context.FinAccountCategories.Where(p => p.HomeID == this.ID).Count();
            if (refcnt > 0)
            {
                return(false);
            }
            // Asset category
            refcnt = context.FinAssetCategories.Where(p => p.HomeID == this.ID).Count();
            if (refcnt > 0)
            {
                return(false);
            }
            // Document type
            refcnt = context.FinDocumentTypes.Where(p => p.HomeID == this.ID).Count();
            if (refcnt > 0)
            {
                return(false);
            }
            // Transaction type
            refcnt = context.FinTransactionType.Where(p => p.HomeID == this.ID).Count();
            if (refcnt > 0)
            {
                return(false);
            }
            // Accounts
            refcnt = context.FinanceAccount.Where(p => p.HomeID == this.ID).Count();
            if (refcnt > 0)
            {
                return(false);
            }
            // Control centers
            refcnt = context.FinanceControlCenter.Where(p => p.HomeID == this.ID).Count();
            if (refcnt > 0)
            {
                return(false);
            }
            // Orders
            refcnt = context.FinanceOrder.Where(p => p.HomeID == this.ID).Count();
            if (refcnt > 0)
            {
                return(false);
            }
            // Documents
            refcnt = context.FinanceDocument.Where(p => p.HomeID == this.ID).Count();
            if (refcnt > 0)
            {
                return(false);
            }

            return(true);
        }
Exemplo n.º 14
0
 public override bool IsDeleteAllowed(hihDataContext context)
 {
     return(base.IsDeleteAllowed(context));
 }