Пример #1
0
        public static JobStatusChange InsertJobStatusChange(Job job, JobStatus jobStatus, DateTime dateOfChange)
        {
            JobStatusChange change = null;

            int changeId = ClientData.Current.InsertJobStatusChange(job.JobId, jobStatus.JobStatusId, dateOfChange);

            if (changeId == 0)
            {
                throw new Exception(SiteUtils.ExceptionMessageForCustomer("Failed to add job status change to database."));
            }

            change = new JobStatusChange();
            change.JobStatusChangeId = changeId;
            change.Job         = job;
            change.JobId       = job.JobId;
            change.JobStatus   = jobStatus;
            change.JobStatusId = jobStatus.JobStatusId;
            change.Date        = dateOfChange;

            if (job.JobStatusChanges == null)
            {
                job.JobStatusChanges = new List <JobStatusChange>();
            }

            job.JobStatusChanges.Add(change);

            return(change);
        }
Пример #2
0
        public static List <JobStatusChange> JobStatusChangesForJob(Job job)
        {
            DataTable dtStatusChangesForJob = ClientData.Current.JobStatusChangesForJobDataTable(job.JobId);
            List <JobStatusChange> changes  = new List <JobStatusChange>();

            foreach (DataRow drChange in dtStatusChangesForJob.Rows)
            {
                JobStatusChange change = new JobStatusChange();
                change.SetFieldsFromDataRow(drChange);

                change.Job       = job;
                change.JobStatus = JobStatus.JobStatusFromId(change.JobStatusId);

                //if (job.JobStatusChanges == null)
                //    job.JobStatusChanges = new List<JobStatusChange>();

                //job.JobStatusChanges.Add(change);

                changes.Add(change);
            }

            return(changes);
        }
Пример #3
0
        private void SetFieldsFromDataRow(DataRow drJob)
        {
            object temp;

            this.JobId            = (int)drJob["JobId"];
            this.ClientId         = (int)drJob["ClientId"];
            this.BillingReference = drJob["BillingReference"].ToString();
            //this.JobStatusId = (int)drJob["JobStatusId"];
            this.JobTypeId       = (int)drJob["JobTypeId"];
            this.ToApplication   = drJob["ToApplication"].ToString();
            this.Formatted       = (bool)drJob["Formatted"];
            this.Proofread       = (bool)drJob["Proofread"];
            this.DateDue         = Convert.ToDateTime(drJob["DateDue"]);
            this.OriginalDateDue = Convert.ToDateTime(drJob["OriginalDateDue"]);
            this.DateSubmitted   = Convert.ToDateTime(drJob["DateSubmitted"]);
            if ((temp = drJob["DateCompleted"]) != DBNull.Value)
            {
                this.DateCompleted = Convert.ToDateTime(temp);
            }
            else
            {
                this.DateCompleted = DateTime.MinValue;
            }
            this.Instructions  = drJob["Instructions"].ToString();
            this.Estimate      = (decimal)drJob["Estimate"];
            this.FinalCharge   = (decimal)drJob["FinalCharge"];
            this.Taxes         = (decimal)drJob["Taxes"];
            this.PickedUp      = (bool)drJob["PickedUp"];
            this.DeliveryNotes = drJob["DeliveryNotes"].ToString();
            this.IsArchived    = (bool)drJob["IsArchived"];
            if ((temp = drJob["InvoiceId"]) != DBNull.Value)
            {
                this.InvoiceId = (int)temp;
            }
            else
            {
                this.InvoiceId = 0;
            }

            // get jobtype - no circular calls
            this.JobType = JobType.JobTypeFromId(this.JobTypeId);

            // don't need parent objects (Client, Invoice) at this point
            // that would cause circular calls
            // set those later, depending on what is calling

            // get child objects
            // that are relevant only in the context of a Job.
            this.JobStatusChanges = JobStatusChange.JobStatusChangesForJob(this);
            this.JobSegments      = JobSegment.JobSegmentsForJob(this);

            //JobFile.JobFilesForJob(this);
            List <JobFile> files = JobFile.JobFilesForJob(this);

            foreach (JobFile file in files)
            {
                if (file.IsReturnedFile)
                {
                    if (this.ReturnedFiles == null)
                    {
                        this.ReturnedFiles = new List <JobFile>();
                    }
                    this.ReturnedFiles.Add(file);
                }
                else if (file.IsSubmittedFile)
                {
                    if (this.SubmittedFiles == null)
                    {
                        this.SubmittedFiles = new List <JobFile>();
                    }
                    this.SubmittedFiles.Add(file);
                }
                else // working
                {
                    if (this.WorkingFiles == null)
                    {
                        this.WorkingFiles = new List <JobFile>();
                    }
                    this.WorkingFiles.Add(file);
                }
            }
        }