Ejemplo n.º 1
0
        private void SetJobFields()
        {
            // other fields
            this.lblHeadingJobNumber.Text = curJob.JobId.ToString();

            this.lblStatus.Text = curJob.JobStatus.Name;

            DateTime dateSubmitted = AdminUtils.EmployeeDate(curJob.DateSubmitted, curAdmin);

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

            DateTime dateDue = AdminUtils.EmployeeDate(curJob.DateDue, curAdmin);

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

            if (curJob.JobStatus.IsAClosedStatus())
            {
                DateTime dateCompleted = AdminUtils.EmployeeDate(curJob.DateCompleted, curAdmin);
                this.lblStatus.Text += " at " + dateCompleted.ToString("M/d/yyyy h:mm tt");
            }

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

            this.lblJobType.Text = curJob.JobType.Name;

            this.phInstructions.Controls.Add(
                new LiteralControl(SiteUtils.SurroundTextBlocksWithHtmlTags(curJob.Instructions, "div", null)));
        }
Ejemplo n.º 2
0
        private Panel FileDiv(JobFile file)
        {
            Panel pnlFile = new Panel();

            if (!curJob.IsArchived)
            {
                // just url with qs
                LiteralControl hlFile = new LiteralControl(AdminUtils.LinkToGetFilePage_Image(file, "employees")
                                                           + " " + AdminUtils.LinkToGetFilePage_Text(file, "employees") + " | ");

                LinkButton hlDeleteFile = new LinkButton();
                //hlDeleteFile.OnClientClick = "return confirm('Are you sure you want to delete this file?');";
                hlDeleteFile.Command        += new CommandEventHandler(hlDeleteFile_Command);
                hlDeleteFile.CommandArgument = file.JobFileId.ToString();
                hlDeleteFile.Text            = "Delete";

                pnlFile.Controls.Add(hlFile);
                pnlFile.Controls.Add(hlDeleteFile);
            }

            else // archived - no link
            {
                LiteralControl fileWithImg = new LiteralControl(AdminUtils.FileIcon() + " " + file.Name + " (archived)");

                pnlFile.Controls.Add(fileWithImg);
            }

            return(pnlFile);
        }
        private void GetResponse()
        {
            string strJobId          = this.Request.QueryString["jobId"];
            string strMessageTypeInt = this.Request.QueryString["messageTypeId"];

            if (String.IsNullOrEmpty(strJobId) || String.IsNullOrEmpty(strMessageTypeInt))
            {
                return;
            }

            int intMessageType = Convert.ToInt32(strMessageTypeInt);

            AdminUtils.ClientMessageType messageType = (AdminUtils.ClientMessageType)intMessageType;

            Job job = CacheLayer.JobFromId(Convert.ToInt32(strJobId));

            string subject = AdminUtils.GetClientAlertSubject(messageType, job);
            string message = AdminUtils.GetClientAlertMessage(messageType, job);

            StringBuilder json = new StringBuilder();

            // note - this assumes the returned values from AdminUtils won't have double quotes
            json.Append("[{");
            json.Append("\"subject\": ");
            json.Append("\"" + SiteUtils.EncodeJsString(subject) + "\", ");
            json.Append("\"message\": ");
            json.Append("\"" + SiteUtils.EncodeJsString(message) + "\"");
            json.Append("}]");

            this.Response.Clear();
            Debug.WriteLine(json.ToString());
            this.Response.Write(json.ToString());
            HttpContext.Current.ApplicationInstance.CompleteRequest();
        }
Ejemplo n.º 4
0
 protected DateTime DateForEmployee(DateTime dt)
 {
     if (curAdmin != null)
     {
         return(AdminUtils.EmployeeDate(dt, curAdmin));
     }
     else
     {
         return(DateTime.MinValue);
     }
 }
        protected void Page_Load(object sender, EventArgs e)
        {
            this.Response.Cache.SetCacheability(HttpCacheability.NoCache);
            this.Response.ContentType = "application/json";

            curAdmin = AdminUtils.GetEmployeeFromSessionOrLogOut();
            if (curAdmin == null)
            {
                RespondWithError();
            }
            else
            {
                GetResponse();
            }
        }
Ejemplo n.º 6
0
 protected void Page_PreInit(object sender, EventArgs e)
 {
     curAdmin = AdminUtils.GetEmployeeFromSessionOrLogOut();
 }
Ejemplo n.º 7
0
 private void GetAdmin()
 {
     curAdmin = AdminUtils.GetEmployeeFromSessionOrLogOut();
 }
Ejemplo n.º 8
0
        private void UpdateJob()
        {
            Job newJob = curJob.ShallowCopy(); // copy to new Job in case db update fails
                                               // (we don't want to update the cached job in that case)

            // check fields

            // job type
            int     selectedJobTypeId = Convert.ToInt32(this.ddJobTypes.SelectedValue);
            JobType jobType           = JobType.JobTypeFromId(selectedJobTypeId);

            // new job status
            int       newJobStatusId = Convert.ToInt32(this.ddStatuses.SelectedValue);
            JobStatus newJobStatus   = JobStatus.JobStatusFromId(newJobStatusId);
            bool      statusChanged  = !curJob.JobStatus.Equals(newJobStatus);

            // date due
            DateTime dateDue = Convert.ToDateTime(this.txtDateDue.Text);

            // convert to utc
            dateDue        = AdminUtils.UtcOfEmployeeDate(dateDue, curAdmin);
            newJob.DateDue = dateDue;

            // billing ref
            newJob.BillingReference = txtBillingRef.Text;

            // job type
            newJob.JobType = jobType;

            // job type options
            newJob.ToApplication = this.txtToApplication.Text.Trim();
            newJob.Formatted     = this.chkFormatted.Checked;
            newJob.Proofread     = this.chkProofed.Checked;

            // date completed
            object objDateCompleted = null;

            if (!String.IsNullOrEmpty(this.txtDateCompleted.Text.Trim()))
            {
                DateTime dateCompleted = Convert.ToDateTime(this.txtDateCompleted.Text);
                // to utc
                dateCompleted = AdminUtils.UtcOfEmployeeDate(dateCompleted, curAdmin);

                newJob.DateCompleted = dateCompleted;
                objDateCompleted     = dateCompleted;
            }
            else
            {
                newJob.DateCompleted = DateTime.MinValue;
            }

            // instructions
            newJob.Instructions = this.txtInstructions.Text.Trim();

            // estimate
            newJob.Estimate = Convert.ToDecimal(this.txtEstimate.Text.Replace("$", ""));

            // final charge
            newJob.FinalCharge = Convert.ToDecimal(this.txtFinalCharge.Text.Replace("$", ""));

            // taxes
            newJob.Taxes = Convert.ToDecimal(this.txtTaxes.Text.Replace("$", ""));

            // delivery notes
            newJob.DeliveryNotes = txtNotes.Text.Trim();

            // archive
            newJob.IsArchived = chkArchive.Checked;

            // to do - newJob.PickedUp - no, done in /clients/job.aspx, right ??

            // date for status change
            DateTime nowUtc = DateTime.UtcNow;

            bool ret = ClientData.Current.UpdateJob(newJob.BillingReference, newJob.JobType.JobTypeId, newJob.ToApplication, newJob.Formatted, newJob.Proofread, newJob.DateDue, objDateCompleted, newJob.Instructions, newJob.Estimate, newJob.FinalCharge, newJob.Taxes, newJob.DeliveryNotes, newJob.IsArchived, newJob.JobId);

            if (!ret)
            {
                throw new Exception(SiteUtils.ExceptionMessageForCustomer("Failed to update job in database."));
            }

            // changed status
            if (statusChanged)
            {
                //int jobStatusChangeId = ClientData.Current.InsertJobStatusChange(newJob.JobId, newJobStatusId, nowUtc);
                JobStatusChange change = JobStatusChange.InsertJobStatusChange(newJob, newJobStatus, nowUtc);
                if (change == null)
                {
                    throw new Exception(SiteUtils.ExceptionMessageForCustomer("Job status change is null."));
                }
            }

            // update cached job
            List <Job> jobsInCache = CacheLayer.RecentJobs();
            int        index       = jobsInCache.IndexOf(curJob);

            if (index != -1)
            {
                jobsInCache.Remove(curJob);
                jobsInCache.Insert(index, newJob);
            }

            // replace global ref
            curJob = newJob;

            pnlUpdated.Visible = true;
        }
Ejemplo n.º 9
0
        private void SetControls()
        {
            // link to send message
            this.pnlSendMessage.Controls.Add(new LiteralControl("<a href=\"./ClientMessage.aspx?jobId=" + curJob.JobId.ToString() + "\">Send client a message</a>"));
            this.pnlViewSegments.Controls.Add(new LiteralControl("<a href=\"/employees/Work.aspx?jobId=" + curJob.JobId.ToString() + "\">View work</a>"));

            // files
            if (filesChanged)
            {
                SetFileLists(); // we called this earlier on page_load, so only do it again if
            }
            // added or deleted a file.

            // job no.
            this.lblHeadingJobNumber.Text = curJob.JobId.ToString();

            // client
            this.lblClient.Text = this.Server.HtmlEncode(curJob.Client.FirstName + " " + curJob.Client.LastName);

            // status
            this.ddStatuses.SelectedValue = curJob.JobStatus.JobStatusId.ToString();

            // job type
            this.ddJobTypes.SelectedValue = curJob.JobType.JobTypeId.ToString();

            // job type options
            this.txtToApplication.Text = curJob.ToApplication;
            this.chkFormatted.Checked  = curJob.Formatted;
            this.chkProofed.Checked    = curJob.Proofread;

            // date submitted
            DateTime dateSubmittedInAdminZone = AdminUtils.EmployeeDate(curJob.DateSubmitted, curAdmin);

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

            // billing
            this.txtBillingRef.Text = curJob.BillingReference;

            // date due
            DateTime dateDueInAdminZone = AdminUtils.EmployeeDate(curJob.DateDue, curAdmin);

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

            // original date due
            DateTime originalDateDueInAdminZone = AdminUtils.EmployeeDate(curJob.OriginalDateDue, curAdmin);

            if (originalDateDueInAdminZone != dateDueInAdminZone)
            {
                phOrigDateDue.Controls.Add(new LiteralControl("<br />Original Date Due: " + originalDateDueInAdminZone.ToString("M/d/yyyy h:mm tt")));
            }

            // date completed
            if (curJob.DateCompleted > DateTime.MinValue)
            {
                DateTime dateCompleted = AdminUtils.EmployeeDate(curJob.DateCompleted, curAdmin);
                this.txtDateCompleted.Text = dateCompleted.ToString("M/d/yyyy h:mm tt");
                //this.phCompletedDate.Controls.Add(new LiteralControl(" at " + dateCompleted.ToString("M/d/yyyy h:mm tt")));
            }

            // estimate
            this.txtEstimate.Text = curJob.Estimate.ToString("c");

            // final charge
            this.txtFinalCharge.Text = curJob.FinalCharge.ToString("c");

            // taxes
            this.txtTaxes.Text = curJob.Taxes.ToString("c");

            // instructions
            this.txtInstructions.Text = curJob.Instructions;

            // delivery notes
            this.txtNotes.Text = curJob.DeliveryNotes;

            // archived
            this.chkArchive.Checked = curJob.IsArchived;

            // iOs attrs
            SiteUtils.AddTextBoxAttributes(this, "autocorrect", "off", true);
            SiteUtils.AddTextBoxAttributes(this, "autocapitalize", "off", true);
        }
Ejemplo n.º 10
0
 protected void Page_PreInit(object sender, EventArgs e)
 {
     // get logged on Admin (aka Employee)
     curAdmin = AdminUtils.GetEmployeeFromSessionOrLogOut();
 }