Пример #1
0
        private bool DueDateIsValid()
        {
            DateTime clientNow = ClientUtils.DateForClient(curClient, DateTime.UtcNow);

            dateDue = new DateTime();

            try
            {
                dateDue = Convert.ToDateTime(this.txtDateDue.Text + " " + this.ddHalfHours.SelectedValue);
            }
            catch
            {
                return(false);
            }

            return(dateDue > clientNow && dateDue < clientNow.AddYears(1));
        }
Пример #2
0
 protected DateTime DateForClient(DateTime dt)
 {
     return(ClientUtils.DateForClient(curClient, dt));
 }
Пример #3
0
        private string SegmentsTable()
        {
            StringBuilder sbSegments = new StringBuilder();

            sbSegments.Append("<table class=\"clientSegmentsTable\">");
            sbSegments.Append("<tr>");
            sbSegments.Append("<th>Staff</th>");
            sbSegments.Append("<th>Date</th>");
            sbSegments.Append("<th class=\"right\">Hours</th>");
            sbSegments.Append("</tr>");

            // copy segments to new list of segments in ***Client's time***
            List <JobSegment> clientSegments = new List <JobSegment>();

            foreach (JobSegment segment in curJob.JobSegments)
            {
                JobSegment clientSegment = segment.ShallowCopy();
                clientSegment.StartDate = ClientUtils.DateForClient(curClient, segment.StartDate);
                clientSegment.EndDate   = ClientUtils.DateForClient(curClient, segment.EndDate);
                clientSegments.Add(clientSegment);
                //Debug.WriteLine("for me (real segment): " + TimeZoneInfo.ConvertTimeFromUtc(segment.StartDate, TimeZoneInfo.Local).ToString());
                //Debug.WriteLine("for client (copy): " + clientSegment.StartDate.ToString());
            }

            // group segments by date
            var segmentGroups = clientSegments
                                .GroupBy(cs => new { cs.Employee, cs.StartDate.Date })                                                               // grouping on ee and startdate
                                .Select(gs => new { Employee = gs.Key.Employee, Date = gs.Key.Date, TotalMinutes = gs.Sum(cs => cs.MinutesWorked) }) // getting sum of minutes
                                .ToList();

            decimal totalHoursForCompare = 0m;

            foreach (var segmentGroup in segmentGroups)
            {
                sbSegments.Append("<tr>");

                string eeName = segmentGroup.Employee.FirstName.Substring(0, 1) + ". "
                                + segmentGroup.Employee.LastName;
                sbSegments.Append("<td>" + eeName + "</td>");

                // already did this:
                //DateTime startDate = ClientUtils.DateForClient(curClient, segmentGroup.Date);

                // to do - not this way. aggregate hours by day
                string strDate = segmentGroup.Date.ToString("M/d/yyyy");
                sbSegments.Append("<td>" + strDate + "</td>");

                int     minutes = segmentGroup.TotalMinutes;
                decimal hours   = decimal.Round((decimal)minutes / 60m, 1);

                // keep running total of displayed
                totalHoursForCompare += hours;

                sbSegments.Append("<td class=\"right\">" + hours.ToString("#,##0.0") + "</td>");
                sbSegments.Append("</tr>");
            }

            sbSegments.Append("</table>");

            int     totalMinutes         = curJob.JobSegments.Sum(s => s.MinutesWorked);
            decimal totalHoursForSegment = decimal.Round((decimal)totalMinutes / 60m, 1);

            sbSegments.Append("<div class=\"marginTop20px\">Total hours: " + totalHoursForSegment.ToString("#,##0.0") + "</div>");

            // note if they don't add up
            if (totalHoursForCompare != totalHoursForSegment)
            {
                sbSegments.Append("<div><span class=\"asterisk\">*</span> Total hours may not exactly equal the sum of the hours shown in the history table, due to rounding. Our time records are kept in minutes, and converted to hours in this display for your convenience.</div>");
            }

            return(sbSegments.ToString());
        }
Пример #4
0
        private void SetControls()
        {
            // nothing if bad job
            if (curJob == null)
            {
                this.pnlBadJob.Visible = true;
                return;
            }

            // page title
            this.Title = Settings.Default.CompanyName + " - Job No. " + curJob.JobId.ToString();

            // link to contact
            this.hlContact.NavigateUrl = Settings.Default.ContactUrl + "?jobId=" + curJob.JobId.ToString();

            // delivery notes
            if (!curJob.JobStatus.IsAClosedStatus())
            {
                this.pnlDeliveryNotesContainer.Visible = false;
            }
            else
            {
                this.pnlDeliveryNotesContainer.Visible = true;
                if (!String.IsNullOrEmpty(curJob.DeliveryNotes))
                {
                    phDeliveryNotes.Controls.Add(new LiteralControl(SiteUtils.SurroundTextBlocksWithHtmlTags(curJob.DeliveryNotes, "div", null)));
                }
                else
                {
                    phDeliveryNotes.Controls.Add(new LiteralControl("<div>[No notes.]</div>"));
                }
            }

            // fees
            if (curJob.JobStatus.IsAClosedStatus())
            {
                phFees.Controls.Add(new LiteralControl("<div>Fees: " + curJob.FinalCharge.ToString("c") + "</div>"));
                if (curJob.Taxes > 0)
                {
                    phFees.Controls.Add(new LiteralControl("<div>Taxes: " + curJob.Taxes.ToString("c") + "</div>"));
                    phFees.Controls.Add(new LiteralControl("<div>Total: " + (curJob.FinalCharge + curJob.Taxes).ToString("c") + "</div>"));
                }

                pnlFees.Visible = true;
            }

            // returned files
            if (curJob.ReturnedFiles != null && curJob.ReturnedFiles.Count > 0)
            {
                foreach (JobFile returnedFile in curJob.ReturnedFiles)
                {
                    phReturnedFiles.Controls.Add(FileDiv(returnedFile));
                }

                pnlReturnFiles.Visible = true;
            }

            // submitted files
            if (curJob.SubmittedFiles != null && curJob.SubmittedFiles.Count > 0)
            {
                foreach (JobFile submittedFile in curJob.SubmittedFiles)
                {
                    phSubmittedFiles.Controls.Add(FileDiv(submittedFile));
                }
            }

            else // no submitted files
            {
                phSubmittedFiles.Controls.Add(new LiteralControl("<div>[No files submitted.]</div>"));
            }

            // segments
            if (curJob.JobSegments != null && curJob.JobSegments.Count > 0)
            {
                this.phJobSegments.Controls.Add(new LiteralControl(SegmentsTable()));
                pnlJobSegments.Visible = true;
            }

            // other fields
            this.lblHeadingJobNumber.Text = curJob.JobId.ToString();

            // status
            this.lblStatus.Text = curJob.JobStatus.Name;
            string jobStatusCss = "jobStatus" + curJob.JobStatus.Name.NoSpaces();

            //this.pnlStatusLeft.CssClass = jobStatusCss;
            this.tdStatus.Attributes.Add("class", jobStatusCss);

            //this.lblStatusHeading.Text = curJob.JobStatus.Name;
            //this.pnlStatus.CssClass = jobStatusCss;

            // date submitted
            DateTime dateSubmitted = ClientUtils.DateForClient(curClient, curJob.DateSubmitted);

            this.lblDateSubmitted.Text = dateSubmitted.ToString("M/d/yyyy h:mm tt");

            // date due
            DateTime dateDue = ClientUtils.DateForClient(curClient, curJob.DateDue);

            this.lblDateDue.Text = dateDue.ToString("M/d/yyyy h:mm tt");

            // date completed
            if (curJob.JobStatus.IsAClosedStatus())
            {
                DateTime dateCompleted = ClientUtils.DateForClient(curClient, curJob.DateCompleted);
                this.lblStatus.Text += " at " + dateCompleted.ToString("M/d/yyyy h:mm tt");
            }

            // billing ref
            this.lblBillingRef.Text = this.Server.HtmlEncode(curJob.BillingReference);

            // job type
            this.lblJobType.Text = curJob.JobType.Name;

            // options
            string options = "N/A";

            if (curJob.JobType.Equals(JobType.Conversion) || curJob.JobType.Equals(JobType.Editing))
            {
                options = curJob.ToApplication;
                if (!String.IsNullOrEmpty(options))
                {
                    options += "/";
                }
                options += (curJob.Formatted ? "Formatted/" : "Unformatted/");
                options += (curJob.Proofread ? "Proofed" : "Not proofed");
            }
            this.lblOptions.Text = options;

            // instructions
            this.phInstructions.Controls.Add(
                new LiteralControl(SiteUtils.SurroundTextBlocksWithHtmlTags(curJob.Instructions, "div", null)));
        }