예제 #1
0
        /// <summary>
        /// Inserts JobFile and relates it to Job. Returns the JobFile or null.
        /// </summary>
        /// <param name="job"></param>
        /// <param name="filename"></param>
        /// <param name="path"></param>
        /// <param name="isReturnedFile"></param>
        /// <param name="isSubmittedFile"></param>
        /// <returns></returns>
        public static JobFile InsertJobFile(Job job, string filename, string path, bool isReturnedFile, bool isSubmittedFile)
        {
            JobFile jobFile = null;

            int jobFileId = ClientData.Current.InsertJobFile(job.JobId, filename, path, isReturnedFile, isSubmittedFile);

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

            jobFile                 = new JobFile();
            jobFile.JobFileId       = jobFileId;
            jobFile.Job             = job;
            jobFile.JobId           = job.JobId;
            jobFile.Name            = filename;
            jobFile.Path            = path;
            jobFile.IsReturnedFile  = isReturnedFile;
            jobFile.IsSubmittedFile = isSubmittedFile;

            if (jobFile.IsReturnedFile)
            {
                if (job.ReturnedFiles == null)
                {
                    job.ReturnedFiles = new List <JobFile>();
                }

                job.ReturnedFiles.Add(jobFile);
            }
            else if (jobFile.IsSubmittedFile)
            {
                if (job.SubmittedFiles == null)
                {
                    job.SubmittedFiles = new List <JobFile>();
                }

                job.SubmittedFiles.Add(jobFile);
            }
            else
            {
                if (job.WorkingFiles == null)
                {
                    job.WorkingFiles = new List <JobFile>();
                }

                job.WorkingFiles.Add(jobFile);
            }

            return(jobFile);
        }
예제 #2
0
        // methods
        public static JobFile JobFileFromId(int jobFileId)
        {
            Debug.WriteLine("JobFile.JobFileFromId()");

            DataRow drJobFile = ClientData.Current.JobFileFromIdDataRow(jobFileId);

            if (drJobFile != null)
            {
                JobFile jobFile = new JobFile();
                jobFile.SetFieldsFromDataRow(drJobFile);

                // get job
                jobFile.Job = Job.JobFromId(jobFile.JobId);

                return(jobFile);
            }

            return(null);
        }
예제 #3
0
        public static List <JobFile> JobFilesForJob(Job job)
        {
            Debug.WriteLine("JobFile.JobFilesForJob(Job " + job.JobId.ToString() + ")");

            DataTable      dtJobFilesForJob = ClientData.Current.JobFilesForJobDataTable(job.JobId);
            List <JobFile> jobFiles         = new List <JobFile>();

            foreach (DataRow drJobFile in dtJobFilesForJob.Rows)
            {
                JobFile jobFile = new JobFile();
                jobFile.SetFieldsFromDataRow(drJobFile);

                jobFile.Job = job;

                //if (jobFile.IsReturnedFile)
                //{
                //    if (job.ReturnedFiles == null)
                //        job.ReturnedFiles = new List<JobFile>();
                //    job.ReturnedFiles.Add(jobFile);
                //}
                //else if (jobFile.IsSubmittedFile)
                //{
                //    if (job.SubmittedFiles == null)
                //        job.SubmittedFiles = new List<JobFile>();
                //    job.SubmittedFiles.Add(jobFile);
                //}
                //else
                //{
                //    if (job.WorkingFiles == null)
                //        job.WorkingFiles = new List<JobFile>();
                //    job.WorkingFiles.Add(jobFile);
                //}

                jobFiles.Add(jobFile);
            }

            return(jobFiles);
        }
예제 #4
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);
                }
            }
        }