Exemplo n.º 1
0
        public double GetActuals(TreeNode <Account> node, TreeNode <Job> job_treenode)
        {
            if (job_treenode == null)
            {
                return(0);
            }
            JobAccount jacc = mAccountant.JobAccountMgr.FindByJobAccount(job_treenode.DataSource, node.DataSource);

            if (jacc != null)
            {
                return(jacc.CurrentBalance);
            }

            double sum = 0;


            if (job_treenode.Children.Count > 0)
            {
                foreach (TreeNode <Job> job_childnode in job_treenode.Children)
                {
                    sum += GetActuals(node, job_childnode);
                }
            }
            else
            {
                foreach (TreeNode <Account> child_node in node.Children)
                {
                    sum += GetActuals(child_node, job_treenode);
                }
            }


            return(sum);
        }
        protected override OpResult _Store(JobAccount _obj)
        {
            if (_obj == null)
            {
                return(OpResult.NotifyStoreAction(OpResult.ResultStatus.ObjectIsNull, _obj, "JobAccount object cannot be created as it is null"));
            }

            if (Exists(_obj))
            {
                ExecuteNonQuery(GetQuery_UpdateQuery(_obj));
                return(OpResult.NotifyStoreAction(OpResult.ResultStatus.Updated, _obj));
            }

            ExecuteNonQuery(GetQuery_InsertQuery(_obj));
            if (_obj.JobAccountID == null)
            {
                _obj.JobAccountID = DbMgr.GetLastInsertID();
            }
            _obj.FromDb = true;

            return(OpResult.NotifyStoreAction(OpResult.ResultStatus.Created, _obj));
        }
 /// <summary>
 /// Verify that the Database object matches the provided values
 /// </summary>
 /// <param name="jobAccount">The job account.</param>
 /// <param name="jobAccountName">Name of the job account.</param>
 /// <param name="databaseId">The database identifier.</param>
 private static void VerifyJobAccountInformation(JobAccount jobAccount, string jobAccountName, string databaseId)
 {
     Assert.Equal(jobAccountName, jobAccount.Name);
     Assert.Equal(databaseId, jobAccount.Properties.DatabaseId);
 }
 private DbUpdateStatement GetQuery_UpdateQuery(JobAccount _obj)
 {
     return(DbMgr.CreateUpdateClause("JobAccounts", GetFields(_obj), "JobAccountID", _obj.JobAccountID));
 }
        private DbInsertStatement GetQuery_InsertQuery(JobAccount _obj)
        {
            Dictionary <string, DbFieldEntry> fields = GetFields(_obj);

            return(DbMgr.CreateInsertClause("JobAccounts", fields));
        }