protected void lnkDeleteTask_OnClick(object sender, EventArgs e)
        {
            // we are only marking the status as deleteded, not physically deleting the task.
            lblErrorMessage.Text = "";
            LinkButton btn = (LinkButton)sender;

            if (btn == null || string.IsNullOrEmpty(btn.CommandArgument))
            {
                return;
            }
            TaskStatusMgr taskMgr = new TaskStatusMgr().CreateNew(0, 0);
            TASK_STATUS   task    = taskMgr.SelectTask(Convert.ToDecimal(btn.CommandArgument));

            taskMgr.UpdateTaskStatus(task, TaskStatus.Delete);
            taskMgr.UpdateTask(task);
            taskMgr.UpdateTaskList(task.RECORD_ID);
            if (OnTaskAdd != null)
            {
                OnTaskAdd("added", task.RECORD_ID, (decimal)task.RECORD_SUBID);
            }
            if (task.RECORD_TYPE == (int)TaskRecordType.Audit)             // update the Question Status when adding tasks for an audit followup.
            {
                EHSAuditQuestion auditQuestion = EHSAuditMgr.SelectAuditQuestion(task.RECORD_ID, (decimal)task.RECORD_SUBID);

                if (auditQuestion != null)
                {
                    auditQuestion.Status = "02";
                    EHSAuditMgr.UpdateAnswer(auditQuestion);
                }
                SessionManager.ReturnRecordID = task.RECORD_ID;
                SessionManager.ReturnObject   = "AddTask";
                SessionManager.ReturnStatus   = true;
            }
        }
        protected void btnTaskAssignUpdate_Click(object sender, EventArgs e)
        {
            Button btn = (Button)sender;

            if (btn == null || string.IsNullOrEmpty(btn.CommandArgument))
            {
                return;
            }

            if (ddlAssignPerson.SelectedItem != null)
            {
                TaskStatusMgr taskMgr = new TaskStatusMgr().CreateNew(0, 0);
                TASK_STATUS   task    = taskMgr.SelectTask(Convert.ToDecimal(btn.CommandArgument));
                task.COMMENTS       = tbAssignComment.Text;
                task.STATUS         = ((int)TaskStatus.New).ToString();
                task.RESPONSIBLE_ID = Convert.ToDecimal(ddlAssignPerson.SelectedValue);
                taskMgr.UpdateTask(task);
                // send email
                EHSNotificationMgr.NotifyTaskAssigment(task, 0);
            }

            if (OnTaskUpdate != null)
            {
                OnTaskUpdate("update");
            }
        }
        protected void btnTaskComplete_Click(object sender, EventArgs e)
        {
            Button btn = (Button)sender;

            if (btn == null || string.IsNullOrEmpty(btn.CommandArgument))
            {
                return;
            }

            TaskStatusMgr taskMgr = new TaskStatusMgr().CreateNew(0, 0);
            TASK_STATUS   task    = taskMgr.SelectTask(Convert.ToDecimal(btn.CommandArgument));

            task.COMMENTS = tbTaskComments.Text;
            task.STATUS   = ((int)TaskStatus.Complete).ToString();
            task          = taskMgr.SetTaskComplete(task, SessionManager.UserContext.Person.PERSON_ID);
            taskMgr.UpdateTask(task);

            if (OnTaskUpdate != null)
            {
                OnTaskUpdate("update");
            }
        }
Пример #4
0
        public static void CreateOrUpdateTask(decimal incidentId, decimal responsiblePersonId, int recordTypeId, DateTime dueDate)
        {
            var entities = new PSsqmEntities();

            INCIDENT incident = SelectIncidentById(entities, incidentId);

            var taskMgr = new TaskStatusMgr();

            taskMgr.Initialize(recordTypeId, incidentId);
            taskMgr.LoadTaskList(recordTypeId, incidentId);
            TASK_STATUS task = taskMgr.FindTask("0", "T", 0);

            if (task == null)
            {
                task        = taskMgr.CreateTask("0", "T", 0, incident.ISSUE_TYPE, dueDate, responsiblePersonId);
                task.STATUS = ((int)TaskMgr.CalculateTaskStatus(task)).ToString();
            }
            else
            {
                task = taskMgr.UpdateTask(task, dueDate, responsiblePersonId, incident.ISSUE_TYPE);
            }

            taskMgr.UpdateTaskList(incidentId);
        }
        protected void btnTaskUpdate_Click(object sender, EventArgs e)
        {
            PSsqmEntities ctx = new PSsqmEntities();

            lblErrorMessage.Text = "";
            Button btn = (Button)sender;

            if (btn == null || string.IsNullOrEmpty(btn.CommandArgument))
            {
                return;
            }

            TaskStatusMgr taskMgr = new TaskStatusMgr().CreateNew(0, 0);
            TASK_STATUS   task    = taskMgr.SelectTask(Convert.ToDecimal(btn.CommandArgument));

            //task.RECORD_TYPE = recordType;
            //task.RECORD_ID = recordID;
            //task.RECORD_SUBID = recordSubID;
            //task.TASK_STEP = taskStep;
            //task.TASK_TYPE = taskType;
            //task.TASK_SEQ = 0;
            task.DUE_DT = rdpTaskDueDT.SelectedDate;
            //task.RESPONSIBLE_ID = Convert.ToDecimal(ddlAssignPerson.SelectedValue.ToString());
            //task.DETAIL = lblTaskDetailValue.Text.ToString(); // this is the original detail, so we don't change it.
            //task.DESCRIPTION = tbTaskDescription.Text.ToString();
            task.COMMENTS = tbTaskComments.Text.ToString();
            //task.STATUS = ((int)TaskStatus.New).ToString();
            //task.CREATE_DT = SessionManager.UserContext.LocalTime != null ? SessionManager.UserContext.LocalTime : DateTime.UtcNow;
            //task.CREATE_ID = SessionManager.UserContext.Person.PERSON_ID;

            taskMgr.UpdateTask(task);
            taskMgr.UpdateTaskList(task.RECORD_ID);
            // send email
            PERSON assignTo = SQMModelMgr.LookupPerson(ctx, (decimal)task.RESPONSIBLE_ID, "", false);

            EHSNotificationMgr.NotifyTaskAssigment(task, assignTo.PLANT_ID);

            // reset the fields for the next add
            ddlAssignPersonAdd.SelectedValue = "";
            tbTaskDescriptionAdd.Text        = "";
            rdpTaskDueDTAdd.SelectedDate     = DateTime.Today;

            if (OnTaskAdd != null)
            {
                OnTaskAdd("added", task.RECORD_ID, (decimal)task.RECORD_SUBID);
            }
            if (task.RECORD_TYPE == (int)TaskRecordType.Audit)             // update the Question Status when adding tasks for an audit followup.
            {
                EHSAuditQuestion auditQuestion = EHSAuditMgr.SelectAuditQuestion(task.RECORD_ID, (decimal)task.RECORD_SUBID);

                if (auditQuestion != null)
                {
                    auditQuestion.Status = "02";
                    EHSAuditMgr.UpdateAnswer(auditQuestion);
                }
                //SessionManager.ReturnRecordID = task.RECORD_ID;
                //SessionManager.ReturnObject = "AddTask";
                //SessionManager.ReturnStatus = true;
            }

            if (Page.Request.Url.ToString().Contains("AssessmentForm"))
            {
                // now update the list and stay on the popup if adding through assessment form
                BindTaskAdd(task.RECORD_TYPE, task.RECORD_ID, (decimal)task.RECORD_SUBID, task.TASK_STEP, task.TASK_TYPE, lblTaskDetailValue.Text.ToString(), assignTo.PLANT_ID, "");
                lblErrorMessage.Text = "";

                string script = "function f(){OpenUpdateTaskWindow(); Sys.Application.remove_load(f);}Sys.Application.add_load(f);";
                ScriptManager.RegisterStartupScript(Page, Page.GetType(), "key", script, true);
            }
            else
            {
                SessionManager.ReturnRecordID = task.RECORD_ID;
                SessionManager.ReturnObject   = "UpdateTask";
                SessionManager.ReturnStatus   = true;

                if (OnTaskUpdate != null)
                {
                    OnTaskUpdate("update");
                }
            }
        }