Exemple #1
0
        public static Job JobFromId(int jobId)
        {
            Job     job   = null;
            DataRow drJob = ClientData.Current.JobFromIdDataRow(jobId);

            if (drJob != null)
            {
                job = new Job();
                job.SetFieldsFromDataRow(drJob);
            }

            return(job);
        }
Exemple #2
0
        public static IList <Job> OpenAndRecentJobs(DateTime asOfDate)
        {
            Debug.WriteLine("Job.OpenAndRecentJobs()");

            DataTable  dtOpenRecentJobs = ClientData.Current.RecentJobsDataTable(asOfDate);
            List <Job> jobs             = new List <Job>();

            foreach (DataRow drJob in dtOpenRecentJobs.Rows)
            {
                Job job = new Job();
                job.SetFieldsFromDataRow(drJob);
                jobs.Add(job);
            }

            return(jobs);
        }
Exemple #3
0
        public static IList <Job> JobsFromSearch(Client client, List <string> searchTerms, bool isAdmin, string sortExpression = "")
        {
            Debug.WriteLine("Job.JobsFromSearch()");

            if (searchTerms.Count == 0)
            {
                return(null);
            }

            DataTable  dtJobsFromSearch = ClientData.Current.JobsFromSearchTermDataTable(client.ClientId, searchTerms, isAdmin);
            List <Job> jobs             = new List <Job>();

            foreach (DataRow drJob in dtJobsFromSearch.Rows)
            {
                Job job = new Job();
                job.SetFieldsFromDataRow(drJob);

                // need to do parent objs here
                job.Client  = client;
                job.JobType = JobType.JobTypeFromId(job.JobTypeId);
                jobs.Add(job);
            }

            // remove dupes (caused by join query)
            jobs = jobs.Distinct().ToList();

            if (!String.IsNullOrEmpty(sortExpression))
            {
                ObjectSortField osf;
                if (sortExpression.ToUpper().EndsWith(" DESC"))
                {
                    osf = new ObjectSortField(sortExpression.Substring(0, sortExpression.Length - 5), ObjectSortField.SortOrders.Descending);
                }
                else
                {
                    osf = new ObjectSortField(sortExpression, ObjectSortField.SortOrders.Ascending);
                }
                jobs.Sort(new ObjectComparer <Job>(new ObjectSortField[] { osf }));
            }

            return(jobs);
        }
Exemple #4
0
        public static IList <Job> JobsForInvoice(Invoice invoice)
        {
            Debug.WriteLine("Job.JobsForInvoice()");

            DataTable  dtJobsForInvoice = ClientData.Current.JobsFromInvoiceIdDataTable(invoice.InvoiceId);
            List <Job> jobs             = new List <Job>();

            foreach (DataRow drJob in dtJobsForInvoice.Rows)
            {
                Job job = new Job();
                job.SetFieldsFromDataRow(drJob);

                job.Invoice = invoice;
                job.Client  = invoice.Client;
                job.JobType = JobType.JobTypeFromId(job.JobTypeId);

                jobs.Add(job);
            }

            return(jobs);
        }
Exemple #5
0
        public static IList <Job> UninvoicedJobsForClient(Client client)
        {
            Debug.WriteLine("Job.UninvoicedJobsForClient()");

            DataTable  dtJobsForInvoice = ClientData.Current.UninvoicedJobsForClientDataTable(client.ClientId);
            List <Job> jobs             = new List <Job>();

            foreach (DataRow drJob in dtJobsForInvoice.Rows)
            {
                Job job = new Job();
                job.SetFieldsFromDataRow(drJob);

                job.Client  = client;
                job.JobType = JobType.JobTypeFromId(job.JobTypeId);

                // only add if job is finished
                if (job.JobStatus.IsAClosedStatus())
                {
                    jobs.Add(job);
                }
            }

            return(jobs);
        }