예제 #1
0
        public void BindProfilePeriodHdr(TaskItem taskItem)
        {
            pnlEHSItemHdr.Visible = true;

            if (taskItem.Plant != null)
            {
                lblProfilePlant_out.Text = taskItem.Plant.PLANT_NAME;
            }

            lblResponsible_out.Text = (string)taskItem.Detail.ToString();

            if (taskItem.RecordID == 0)
            {
                trEHSIncident.Visible    = false;
                trEHSInputPeriod.Visible = trEHSInput.Visible = true;
                lblInputPeriod_out.Text  = SQMBasePage.FormatDate(taskItem.TaskDate, "MMMM yyyy", false);
                lblInput_out.Text        = taskItem.Description;
            }
            else
            {
                trEHSInput.Visible      = trEHSInputPeriod.Visible = false;
                trEHSIncident.Visible   = true;
                lblIncidentID_out.Text  = WebSiteCommon.FormatID(taskItem.RecordID, 6);
                lblDescription_out.Text = taskItem.Description;
            }
        }
        protected void rgAuditScheduleList_ItemDataBound(object sender, GridItemEventArgs e)
        {
            if (e.Item is GridDataItem)
            {
                GridDataItem item = (GridDataItem)e.Item;
                HiddenField  hf;
                Label        lbl;

                EHSAuditSchedulerData data = (EHSAuditSchedulerData)e.Item.DataItem;

                lbl      = (Label)e.Item.FindControl("lblAuditScheduleId");
                lbl.Text = WebSiteCommon.FormatID(data.AuditScheduler.AUDIT_SCHEDULER_ID, 6);

                lbl = (Label)e.Item.FindControl("lblAuditScheduleStatus");

                if (data.AuditScheduler.INACTIVE)
                {
                    lbl.Text = "Inactive";
                }
                else
                {
                    lbl.Text = "Active";
                }

                lbl = (Label)e.Item.FindControl("lblDayOfWeek");
                DayOfWeek day = (DayOfWeek)data.AuditScheduler.DAY_OF_WEEK;
                lbl.Text = day.ToString();

                LinkButton lnk = (LinkButton)e.Item.FindControl("lbAuditScheduleId");
                lnk.CommandArgument = data.AuditScheduler.AUDIT_SCHEDULER_ID.ToString();
            }
        }
        protected void rgIncidentActionList_ItemDataBound(object sender, GridItemEventArgs e)
        {
            if (e.Item is GridDataItem)
            {
                GridDataItem item = (GridDataItem)e.Item;
                HiddenField  hf;
                Label        lbl;

                EHSIncidentData data = (EHSIncidentData)e.Item.DataItem;

                try
                {
                    lbl      = (Label)e.Item.FindControl("lblIncidentId");
                    lbl.Text = WebSiteCommon.FormatID(data.Incident.INCIDENT_ID, 6);


                    if (data.Incident.DESCRIPTION.Length > 200)
                    {
                        lbl      = (Label)e.Item.FindControl("lblDescription");
                        lbl.Text = data.Incident.DESCRIPTION.Substring(0, 200) + "...";
                    }

                    lbl = (Label)e.Item.FindControl("lblDueDT");
                    INCIDENT_ANSWER entry = data.Incident.INCIDENT_ANSWER.Where(l => l.INCIDENT_QUESTION_ID == 65).FirstOrDefault();  // due date
                    if (entry != null && !string.IsNullOrEmpty(entry.ANSWER_VALUE))
                    {
                        lbl.Text = SQMBasePage.FormatDate(Convert.ToDateTime(entry.ANSWER_VALUE), "d", false);
                        entry    = data.Incident.INCIDENT_ANSWER.Where(l => l.INCIDENT_QUESTION_ID == 64).FirstOrDefault(); // responsible person
                        if (entry != null && !string.IsNullOrEmpty(entry.ANSWER_VALUE))
                        {
                            lbl      = (Label)e.Item.FindControl("lblResponsible");
                            lbl.Text = entry.ANSWER_VALUE;
                        }
                    }

                    RadGrid gv = (RadGrid)e.Item.FindControl("rgIncidentActions");
                    List <INCIDENT_ANSWER> incidentActionList = new List <INCIDENT_ANSWER>();
                    incidentActionList.AddRange(data.Incident.INCIDENT_ANSWER.Where(l => l.INCIDENT_QUESTION_ID == 24 || l.INCIDENT_QUESTION_ID == 27).ToList());
                    if (incidentActionList.Count > 0)
                    {
                        baseRowIndex  = e.Item.RowIndex;
                        gv.DataSource = incidentActionList;
                        gv.DataBind();
                        gv.Visible = true;
                    }

                    LinkButton lb8d = (LinkButton)e.Item.FindControl("lb8d");
                    if (lb8d != null && UserContext.RoleAccess() <= AccessMode.Partner)
                    {
                        lb8d.Visible = false;
                    }
                }

                catch
                {
                }
            }
        }
        protected void RefreshPageContext()
        {
            string typeString = "";

            if (UserContext.GetMaxScopePrivilege(SysScope.audit) < SysPriv.view && CurrentStep == 0)
            {
                pnlAddEdit.Visible = true;
                if (!IsEditContext)
                {
                    // Add
                    btnSaveReturn.Enabled  = true;
                    btnSaveReturn.Visible  = true;
                    rddlAuditType.Visible  = (rddlAuditType.Items.Count == 1) ? false : true;
                    lblAddOrEditAudit.Text = "<strong>Add a New Audit Schedule:</strong>";

                    btnDelete.Visible = false;
                }
                else
                {
                    // Edit
                    typeString = " Audit Schedule";
                    btnSaveReturn.CommandArgument = "0";
                    SelectedTypeId        = 0;
                    btnSaveReturn.Enabled = true;
                    btnSaveReturn.Visible = true;

                    lblAddOrEditAudit.Text = "<strong>Editing " + WebSiteCommon.FormatID(EditAuditScheduleId, 6) + typeString + "</strong><br/>";

                    btnDelete.Visible = true;
                    LoadInformation();
                }

                UpdateButtonText();

                // Only admin and higher can delete audits
                if (UserContext.CheckUserPrivilege(SysPriv.admin, SysScope.system))
                {
                    btnDelete.Visible = false;
                }
            }
            else
            {
                // View only
                typeString            = " Audit Schedule";
                SelectedTypeId        = 0;
                btnSaveReturn.Enabled = false;
                btnSaveReturn.Visible = false;

                lblAddOrEditAudit.Text = "<strong>" + WebSiteCommon.FormatID(EditAuditScheduleId, 6) + typeString + " Closed</strong><br/>";

                rddlAuditType.Visible = false;
                btnDelete.Visible     = false;
                LoadInformation();
                var displaySteps = new int[] { CurrentStep };
                pnlAddEdit.Visible = false;
            }
        }
        public void BindAuditListHeader(AUDIT audit, TaskItem taskItem)
        {
            pnlIncidentTaskHdr.Visible = true;
            lblCaseDescription.Visible = lblIncidentDescription.Visible = lblActionDescription.Visible = false;

            lblIncidentDescription.Visible = true;

            if (taskItem.Plant != null)
            {
                lblCasePlant_out.Text = taskItem.Plant.PLANT_NAME;
            }
            lblResponsible_out.Text = SQMModelMgr.FormatPersonListItem(taskItem.Person);
            lblCase2ID_out.Text     = WebSiteCommon.FormatID(audit.AUDIT_ID, 6);
            lblCase2Desc_out.Text   = taskItem.Task.DESCRIPTION;
        }
        public void BindQualityIncidentHeader(QualityIncidentData qualityIncident, bool showAll)
        {
            pnlQualityIncidentHdr.Visible = true;

            lblDetectedLocation_out.Text = qualityIncident.Plant.PLANT_NAME;
            lblIssueID_out.Text          = WebSiteCommon.FormatID(qualityIncident.Incident.INCIDENT_ID, 6);
            lblIssueDesc_out.Text        = qualityIncident.Incident.DESCRIPTION;
            if (qualityIncident.Part != null)
            {
                lblIssuePartNum_out.Text = qualityIncident.Part.PART_NUM;
            }
            lblIssueResponsible_out.Text = SQMModelMgr.FormatPersonListItem(qualityIncident.Person);
            if (qualityIncident.PlantResponsible != null)
            {
                lblIssueResponsible_out.Text += " (" + qualityIncident.PlantResponsible.PLANT_NAME + ")";
            }
        }
예제 #7
0
        public void gvAuditList_OnRowDataBound(object sender, System.Web.UI.WebControls.GridViewRowEventArgs e)
        {
            if ((!e.Row.RowType.ToString().Trim().Equals(System.Web.UI.WebControls.ListItemType.Header.ToString())) & (!e.Row.RowType.ToString().Trim().Equals(System.Web.UI.WebControls.ListItemType.Footer.ToString())))
            {
                try
                {
                    HiddenField hf  = (HiddenField)e.Row.Cells[0].FindControl("hfAuditDate");
                    Label       lbl = (Label)e.Row.Cells[0].FindControl("lblAuditDate");
                    lbl.Text = SQMBasePage.FormatDate(Convert.ToDateTime(hf.Value), "d", false);

                    hf       = (HiddenField)e.Row.Cells[0].FindControl("hfAuditID");
                    lbl      = (Label)e.Row.Cells[0].FindControl("lblAuditID");
                    lbl.Text = WebSiteCommon.FormatID(Convert.ToInt32(hf.Value), 6);
                }
                catch
                {
                }
            }
        }
예제 #8
0
        public static int NotifyIncidentTaskAssigment(INCIDENT incident, TASK_STATUS theTask, string scopeAction)
        {
            int    status = 0;
            PLANT  plant  = SQMModelMgr.LookupPlant((decimal)incident.DETECT_PLANT_ID);
            PERSON person = SQMModelMgr.LookupPerson((decimal)theTask.RESPONSIBLE_ID, "");

            if (person != null && !string.IsNullOrEmpty(person.EMAIL))
            {
                List <XLAT> XLATList = SQMBasePage.SelectXLATList(new string[3] {
                    "NOTIFY_SCOPE", "NOTIFY_SCOPE_TASK", "NOTIFY_TASK_STATUS"
                });
                string appUrl = SQMSettings.SelectSettingByCode(new PSsqmEntities(), "MAIL", "TASK", "MailURL").VALUE;
                if (string.IsNullOrEmpty(appUrl))
                {
                    appUrl = "the website";
                }

                string emailTo      = person.EMAIL;
                string actionText   = XLATList.Where(x => x.XLAT_GROUP == "NOTIFY_SCOPE_TASK" && x.XLAT_CODE == scopeAction).FirstOrDefault().DESCRIPTION;
                string emailSubject = "Health/Safety Incident " + actionText + ": " + incident.ISSUE_TYPE + " (" + plant.PLANT_NAME + ")";
                string emailBody    = "You have been assigned to one or more tasks regarding the following Incident: <br/>" +
                                      "<br/>" +
                                      "Incident ID: " + WebSiteCommon.FormatID(incident.INCIDENT_ID, 6) + "<br/>" +
                                      plant.PLANT_NAME + "<br/>" +
                                      incident.ISSUE_TYPE + "<br/>" +
                                      "<br/>" +
                                      incident.DESCRIPTION + "<br/>" +
                                      "<br/>" +
                                      theTask.DESCRIPTION + "<br/>" +
                                      "<br/>" +
                                      "Due : " + theTask.DUE_DT.ToString() + "<br/>" +
                                      "<br/>" +
                                      "Please log in to " + (appUrl + incidentPath) + " to view this incident.";

                Thread thread = new Thread(() => WebSiteCommon.SendEmail(emailTo, emailSubject, emailBody, "", "web", null));
                thread.IsBackground = true;
                thread.Start();
            }

            return(status);
        }
 public void rptCRList_OnItemDataBound(object sender, RepeaterItemEventArgs e)
 {
     if (e.Item.ItemType == ListItemType.AlternatingItem || e.Item.ItemType == ListItemType.Item)
     {
         try
         {
             IncidentCostReport rpt = (IncidentCostReport)e.Item.DataItem;
             LinkButton         lnk = (LinkButton)e.Item.FindControl("lnkViewCRID");
             lnk.Text = WebSiteCommon.FormatID(Convert.ToDecimal(lnk.CommandArgument), 6);
             Label lbl = (Label)e.Item.FindControl("lblCRCreateDT");
             lbl.Text = SQMBasePage.FormatDate(Convert.ToDateTime(lbl.Text), "d", false);
             lbl      = (Label)e.Item.FindControl("lblCRType");
             lbl.Text = WebSiteCommon.GetXlatValue("issueResponsible", lbl.Text);
             Ucl_IncidentList uclIncidents = (Ucl_IncidentList)e.Item.FindControl("uclIncidents");
             uclIncidents.BindQualityIssueList(rpt.IncidentList, false);
         }
         catch
         {
         }
     }
 }
예제 #10
0
        protected void rgReceiptList_ItemDataBound(object sender, GridItemEventArgs e)
        {
            if (e.Item is GridDataItem)
            {
                GridDataItem item = (GridDataItem)e.Item;
                Label        lbl;
                if (e.Item is GridDataItem)
                {
                    ReceiptData data = (ReceiptData)e.Item.DataItem;

                    LinkButton lnk = (LinkButton)e.Item.FindControl("lbIssueID");
                    if (data.IssueList != null && data.IssueList[0] != null)
                    {
                        lnk.Text            = WebSiteCommon.FormatID(data.IssueList[0].INCIDENT_ID, 6);
                        lnk.CommandArgument = lnk.Text;
                    }
                    else
                    {
                        lnk.Visible = false;
                    }
                }
            }
        }
        public void gvIssueList_OnRowDataBound(object sender, System.Web.UI.WebControls.GridViewRowEventArgs e)
        {
            if ((!e.Row.RowType.ToString().Trim().Equals(System.Web.UI.WebControls.ListItemType.Header.ToString())) & (!e.Row.RowType.ToString().Trim().Equals(System.Web.UI.WebControls.ListItemType.Footer.ToString())))
            {
                try
                {
                    Label       lbl;
                    HiddenField hf = (HiddenField)e.Row.Cells[0].FindControl("hfIssueID");

                    LinkButton lnk = (LinkButton)e.Row.Cells[0].FindControl("lnkViewIssue_out");
                    lnk.Text = WebSiteCommon.FormatID(Convert.ToInt32(hf.Value), 6);

                    lbl = (Label)e.Row.Cells[0].FindControl("lblDisposition_Out");
                    string tempDisposition = lbl.Text;
                    lbl.Text = WebSiteCommon.GetXlatValue("NCDisposition", lbl.Text);

                    lnk      = (LinkButton)e.Row.Cells[0].FindControl("lnkIssueDate_Out");
                    lnk.Text = WebSiteCommon.LocalTime(Convert.ToDateTime(lnk.Text), SessionManager.UserContext.TimeZoneID).ToShortDateString();

                    lnk      = (LinkButton)e.Row.Cells[0].FindControl("lnkIssueTask_out");
                    lnk.Text = WebSiteCommon.GetXlatValueLong("taskType", lnk.Text);

                    TASK_STATUS task = new TASK_STATUS();
                    hf           = (HiddenField)e.Row.Cells[0].FindControl("hfTaskStatus");
                    task.TASK_ID = Convert.ToDecimal(hf.Value);
                    hf           = (HiddenField)e.Row.Cells[0].FindControl("hfTaskDueDate");
                    task.DUE_DT  = WebSiteCommon.LocalTime(Convert.ToDateTime(hf.Value), SessionManager.UserContext.TimeZoneID);
                    Image      img    = (Image)e.Row.Cells[0].FindControl("imgTaskStatus");
                    TaskStatus status = TaskMgr.CalculateTaskStatus(task);
                    img.ImageUrl = TaskMgr.TaskStatusImage(status);
                    img.ToolTip  = status.ToString();
                }
                catch
                {
                }
            }
        }
예제 #12
0
        protected void RefreshPageContext()
        {
            string typeString = " " + Resources.LocalizedText.Video;

            bool createVideoAccess = SessionManager.CheckUserPrivilege(SysPriv.admin, SysScope.audit);

            btnDelete.Visible = createVideoAccess;

            if (EditVideoId > 0)
            {
                if (UserContext.GetMaxScopePrivilege(SysScope.media) < SysPriv.view && CurrentStep == 0)
                {
                    // Edit
                    btnSaveReturn.CommandArgument = "0";
                    SelectedTypeId        = 0;
                    btnSaveReturn.Enabled = true;
                    btnSaveReturn.Visible = true;

                    lblAddOrEditVideo.Text = "<strong>" + Resources.LocalizedText.Editing + " " + WebSiteCommon.FormatID(EditVideoId, 6) + typeString + "</strong><br/>";
                    LoadVideoInformation();
                    UpdateButtonText();
                }
                else
                {
                    // View only
                    SelectedTypeId        = 0;
                    btnSaveReturn.Enabled = false;
                    btnSaveReturn.Visible = false;

                    lblAddOrEditVideo.Text = "<strong>" + WebSiteCommon.FormatID(EditVideoId, 6) + typeString + "</strong><br/>";

                    LoadVideoInformation();
                    var displaySteps = new int[] { CurrentStep };
                }
            }
        }
        public void BindIncidentListHeader(INCIDENT incident, TaskItem taskItem)
        {
            pnlIncidentTaskHdr.Visible = true;
            lblCaseDescription.Visible = lblIncidentDescription.Visible = lblActionDescription.Visible = false;

            if (incident.ISSUE_TYPE_ID == 13)              //  preventative action
            {
                lblActionDescription.Visible = true;
            }
            else
            {
                lblIncidentDescription.Visible = true;
            }


            if (taskItem.Plant != null)
            {
                lblCasePlant_out.Text = taskItem.Plant.PLANT_NAME;
            }
            lblResponsible_out.Text = SQMModelMgr.FormatPersonListItem(taskItem.Person);
            lblCase2ID_out.Text     = WebSiteCommon.FormatID(incident.INCIDENT_ID, 6);
            // lblCase2Desc_out.Text = incident.ISSUE_TYPE;
            lblCase2Desc_out.Text = taskItem.Task.DESCRIPTION;
        }
        protected void rgIncidentList_ItemDataBound(object sender, GridItemEventArgs e)
        {
            if (e.Item is GridDataItem)
            {
                GridDataItem item = (GridDataItem)e.Item;
                HiddenField  hf;
                Label        lbl;

                EHSIncidentData data = (EHSIncidentData)e.Item.DataItem;

                lbl      = (Label)e.Item.FindControl("lblIncidentId");
                lbl.Text = WebSiteCommon.FormatID(data.Incident.INCIDENT_ID, 6);

                if (data.Incident.DESCRIPTION.Length > 120)
                {
                    lbl      = (Label)e.Item.FindControl("lblDescription");
                    lbl.Text = data.Incident.DESCRIPTION.Substring(0, 117) + "...";
                }

                lbl      = (Label)e.Item.FindControl("lblDescription");
                lbl.Text = HttpUtility.HtmlEncode(lbl.Text);

                if (data.Person != null)
                {
                    lbl      = (Label)e.Item.FindControl("lblReportedBy");
                    lbl.Text = SQMModelMgr.FormatPersonListItem(data.Person);
                }

                lbl = (Label)e.Item.FindControl("lblIncStatus");
                if (data.Status == "C")
                {
                    lbl.Text = WebSiteCommon.GetXlatValue("incidentStatus", "C") + " " + SQMBasePage.FormatDate((DateTime)data.Incident.CLOSE_DATE, "d", false) + "<br/>(" + data.DaysToClose.ToString() + ")";
                }
                else if (data.Status == "C8")
                {
                    lbl.Text = WebSiteCommon.GetXlatValue("incidentStatus", "C8") + " " + SQMBasePage.FormatDate((DateTime)data.Incident.CLOSE_DATE_8D, "d", false) + "<br/>(" + data.DaysToClose.ToString() + ")";
                }
                else if (data.Status == "N")
                {
                    lbl.Text = "<strong>" + WebSiteCommon.GetXlatValue("incidentStatus", "N") + "</strong>";
                }
                else
                {
                    lbl.Text = WebSiteCommon.GetXlatValue("incidentStatus", "A") + "<br/>(" + data.DaysOpen + ")";
                }

                LinkButton lb8d         = (LinkButton)e.Item.FindControl("lb8d");
                LinkButton lbEditReport = (LinkButton)e.Item.FindControl("lbEditReport");
                lb8d.Visible = lbEditReport.Visible = false;                  // mt - for AAM

                HyperLink hlReport = (HyperLink)e.Item.FindControl("hlReport");
                hlReport.Visible = true;

                /*
                 * INCIDENT_ANSWER entry = data.Incident.INCIDENT_ANSWER.Where(l => l.INCIDENT_QUESTION_ID == (decimal)EHSQuestionId.Create8D).FirstOrDefault();
                 * if (entry != null && entry.ANSWER_VALUE == "Yes")
                 * {
                 *      if (UserContext.RoleAccess() > AccessMode.View)
                 *              lb8d.Visible = true;
                 *      else
                 *              lb8d.Visible = false;
                 *
                 *      lbEditReport.Visible = false;
                 *
                 *      var problemCaseId = EHSIncidentMgr.SelectProblemCaseIdByIncidentId(data.Incident.INCIDENT_ID);
                 *      if (problemCaseId > 0)
                 *      {
                 *
                 *              hlReport.NavigateUrl = "/EHS/EHS_Alert_PDF.aspx?pcid=" + EncryptionManager.Encrypt(problemCaseId.ToString());
                 *
                 *              LinkButton lbReport = (LinkButton)e.Item.FindControl("lbReport");
                 *              lbReport.Visible = true;
                 *              lbReport.CommandArgument = problemCaseId.ToString();
                 *              lbReport.Attributes.Add("CaseType", data.Incident.INCIDENT_TYPE);
                 *      }
                 * }
                 * else
                 * {
                 *      lb8d.Visible = false;
                 *      lbEditReport.Visible = true;
                 *
                 *      hlReport.NavigateUrl = "/EHS/EHS_Alert_PDF.aspx?iid=" + EncryptionManager.Encrypt(data.Incident.INCIDENT_ID.ToString());
                 * }
                 */

                if (data.Incident.ISSUE_TYPE_ID == 10)                 // Prevention Verification
                {
                    lbEditReport.Visible = false;
                }

                if (rgIncidentList.MasterTableView.GetColumn("Attach").Visible&& data.AttachList != null)
                {
                    lbl = (Label)e.Item.FindControl("lblAttach");
                    Ucl_Attach attch = (Ucl_Attach)Page.LoadControl("/Include/Ucl_Attach.ascx");
                    lbl.Parent.Controls.AddAt(lbl.Parent.Controls.IndexOf(lbl), attch);
                    attch.BindListAttachment(data.AttachList, "", 1);
                }
            }
        }
        public void BindIncident(decimal incidentID)
        {
            staticIncidentID = incidentID;
            try
            {
                COST_REPORT_ITEM    item   = costReport.CostReport.COST_REPORT_ITEM.Where(l => l.INCIDENT_ID == incidentID).FirstOrDefault();
                QualityIncidentData qiData = costReport.IncidentList.Where(l => l.Incident.INCIDENT_ID == item.INCIDENT_ID).FirstOrDefault();

                lblCRIncidentIDHdr.Text = WebSiteCommon.FormatID(qiData.Incident.INCIDENT_ID, 6);

                tbCRItemQtyActual.Text = item.NCM_ACT_QTY.ToString();
                tbCRItemQtyActual.Focus();
                tbCRItemQtyAvoid.Text   = item.NCM_POT_QTY.ToString();
                tbCRUnitCostActual.Text = item.UNIT_COST.ToString();
                tbCRUnitCostAvoid.Text  = item.UNIT_COST.ToString();
                tbCRItemCostActual.Text = item.NCM_ACT_COST.ToString();
                tbCRItemCostAvoid.Text  = item.NCM_POT_COST.ToString();
                tbCRItemNote.Text       = item.NCM_COMMENTS;

                List <PLANT_LINE> lineList = SQMModelMgr.SelectPlantLineList(this.entities, (decimal)qiData.Incident.DETECT_PLANT_ID);
                ddlCRPlantLineActual.DataSource     = lineList;
                ddlCRPlantLineActual.DataValueField = "PLANT_LINE_ID";
                ddlCRPlantLineActual.DataTextField  = "PLANT_LINE_NAME";
                ddlCRPlantLineActual.DataBind();
                ddlCRPlantLineActual.Items.Insert(0, new ListItem("", "0"));
                ddlCRPlantLineAvoid.DataSource     = lineList;
                ddlCRPlantLineAvoid.DataValueField = "PLANT_LINE_ID";
                ddlCRPlantLineAvoid.DataTextField  = "PLANT_LINE_NAME";
                ddlCRPlantLineAvoid.DataBind();
                ddlCRPlantLineAvoid.Items.Insert(0, new ListItem("", "0"));

                if (ddlCRPlantLineActual.Items.FindByValue(item.DWN_ACT_LINE_ID.ToString()) != null)
                {
                    ddlCRPlantLineActual.SelectedValue = item.DWN_ACT_LINE_ID.ToString();
                }
                tbCRDowntimeRateActual.Text = item.DWN_ACT_RATE.ToString();
                tbCRDowntimeRateAvoid.Text  = item.DWN_POT_RATE.ToString();
                tbCRDowntimeActual.Text     = item.DWN_ACT.ToString();
                if (ddlCRPlantLineAvoid.Items.FindByValue(item.DWN_POT_LINE_ID.ToString()) != null)
                {
                    ddlCRPlantLineAvoid.SelectedValue = item.DWN_POT_LINE_ID.ToString();
                }
                tbCRDowntimeAvoid.Text      = item.DWN_POT.ToString();
                tbCRDowntimeCostActual.Text = item.DWN_ACT_COST.ToString();
                tbCRDowntimeCostAvoid.Text  = item.DWN_POT_COST.ToString();
                tbCRDowntimeNote.Text       = item.DWN_COMMENTS;

                List <DEPARTMENT> deptList = SQMModelMgr.SelectDepartmentList(this.entities, (decimal)qiData.Incident.DETECT_COMPANY_ID, 0, (decimal)qiData.Incident.DETECT_PLANT_ID);
                ddlCRLaborDeptActual.DataSource     = deptList;
                ddlCRLaborDeptActual.DataValueField = "DEPT_ID";
                ddlCRLaborDeptActual.DataTextField  = "DEPT_NAME";
                ddlCRLaborDeptActual.DataBind();
                ddlCRLaborDeptActual.Items.Insert(0, new ListItem("", "0"));
                ddlCRLaborDeptAvoid.DataSource     = deptList;
                ddlCRLaborDeptAvoid.DataValueField = "DEPT_ID";
                ddlCRLaborDeptAvoid.DataTextField  = "DEPT_NAME";
                ddlCRLaborDeptAvoid.DataBind();
                ddlCRLaborDeptAvoid.Items.Insert(0, new ListItem("", "0"));

                List <LABOR_TYPE> laborList = SQMModelMgr.SelectLaborTypeList(this.entities, (decimal)qiData.Incident.DETECT_COMPANY_ID, 0, (decimal)qiData.Incident.DETECT_PLANT_ID);
                ddlCRLaborTypeActual.DataSource     = laborList;
                ddlCRLaborTypeActual.DataValueField = "LABOR_TYP_ID";
                ddlCRLaborTypeActual.DataTextField  = "LABOR_NAME";
                ddlCRLaborTypeActual.DataBind();
                ddlCRLaborTypeActual.Items.Insert(0, new ListItem("", "0"));
                ddlCRLaborTypeAvoid.DataSource     = laborList;
                ddlCRLaborTypeAvoid.DataValueField = "LABOR_TYP_ID";
                ddlCRLaborTypeAvoid.DataTextField  = "LABOR_NAME";
                ddlCRLaborTypeAvoid.DataBind();
                ddlCRLaborTypeAvoid.Items.Insert(0, new ListItem("", "0"));

                if (ddlCRLaborDeptActual.Items.FindByValue(item.LABOR_ACT_DEPT_ID.ToString()) != null)
                {
                    ddlCRLaborDeptActual.SelectedValue = item.LABOR_ACT_DEPT_ID.ToString();
                }
                if (ddlCRLaborTypeActual.Items.FindByValue(item.LABOR_ACT_TYPE_ID.ToString()) != null)
                {
                    ddlCRLaborTypeActual.SelectedValue = item.LABOR_ACT_TYPE_ID.ToString();
                }
                tbCRLaborRateActual.Text = item.LABOR_ACT_RATE.ToString();
                tbCRLaborRateAvoid.Text  = item.LABOR_POT_RATE.ToString();
                tbCRLaborActual.Text     = item.LABOR_ACT.ToString();
                if (ddlCRLaborDeptAvoid.Items.FindByValue(item.LABOR_POT_DEPT_ID.ToString()) != null)
                {
                    ddlCRLaborDeptAvoid.SelectedValue = item.LABOR_POT_DEPT_ID.ToString();
                }
                if (ddlCRLaborTypeAvoid.Items.FindByValue(item.LABOR_POT_TYPE_ID.ToString()) != null)
                {
                    ddlCRLaborTypeAvoid.SelectedValue = item.LABOR_POT_TYPE_ID.ToString();
                }
                tbCRLaborAvoid.Text      = item.LABOR_POT.ToString();
                tbCRLaborCostActual.Text = item.LABOR_ACT_COST.ToString();
                tbCRLaborCostAvoid.Text  = item.LABOR_POT_COST.ToString();
                tbCRLaborNote.Text       = item.LABOR_COMMENTS;

                tbCRShipDescActual.Text = item.SHIP_ACT_TYPE.ToString();
                tbCRShipDescAvoid.Text  = item.SHIP_POT_TYPE.ToString();
                tbCRShipCostActual.Text = item.SHIP_ACT_COST.ToString();
                tbCRShipCostAvoid.Text  = item.SHIP_POT_COST.ToString();
                tbCRShipNote.Text       = item.SHIP_COMMENTS;

                tbCRIncidentCostActual.Text    = FormatValue((decimal)item.TOTAL_ACT_COST, 2);
                tbCRIncidentCostAvoid.Text     = FormatValue((decimal)item.TOTAL_POT_COST, 2);
                tbCRIncidentCostActual.Enabled = tbCRIncidentCostAvoid.Enabled = false;
                btnCRCalculate.Enabled         = true;
                tbCRTotalNote.Text             = item.TOTAL_COMMENTS;

                // copy relevant incident data to the cost report when creating new
                if (costReport.IsNew || item.EntityState == System.Data.EntityState.Added || item.EntityState == System.Data.EntityState.Detached)
                {
                    QI_OCCUR_ITEM insp = qiData.QIIssue.QI_OCCUR_ITEM.FirstOrDefault();
                    tbCRItemQtyActual.Text  = FormatValue((decimal)insp.TOTAL_NC_QTY, 2);
                    tbCRUnitCostActual.Text = tbCRUnitCostAvoid.Text = "1.0";   // td
                    tbCRItemCostActual.Text = FormatValue((decimal)insp.TOTAL_NC_QTY, 2);
                    if (qiData.Incident.DETECT_PLANT_LINE_ID.HasValue && ddlCRPlantLineActual.Items.FindByValue(qiData.Incident.DETECT_PLANT_LINE_ID.ToString()) != null)
                    {
                        PLANT_LINE line = lineList.Where(l => l.PLANT_LINE_ID == qiData.Incident.DETECT_PLANT_LINE_ID).FirstOrDefault();
                        ddlCRPlantLineActual.SelectedValue = qiData.Incident.DETECT_PLANT_LINE_ID.ToString();
                        tbCRDowntimeRateActual.Text        = FormatValue((decimal)line.DOWNTIME_RATE, 2);
                    }
                }
            }
            catch
            {
            }
        }
예제 #16
0
        AlertData PopulateByIncidentId(decimal iid)
        {
            AlertData d        = new AlertData();
            var       entities = new PSsqmEntities();

            d.incident = EHSIncidentMgr.SelectIncidentById(entities, iid);

            if (d.incident != null)
            {
                try
                {
                    string plantName = EHSIncidentMgr.SelectPlantNameById((decimal)d.incident.DETECT_PLANT_ID);
                    d.incidentLocation = plantName;
                    d.incidentNumber   = WebSiteCommon.FormatID(iid, 6);

                    string  incidentType   = EHSIncidentMgr.SelectIncidentTypeByIncidentId(iid);
                    decimal incidentTypeId = EHSIncidentMgr.SelectIncidentTypeIdByIncidentId(iid);
                    decimal companyId      = d.incident.DETECT_COMPANY_ID;
                    var     questions      = EHSIncidentMgr.SelectIncidentQuestionList(incidentTypeId, companyId, 0);
                    questions.AddRange(EHSIncidentMgr.SelectIncidentQuestionList(incidentTypeId, companyId, 1));

                    d.answerList = EHSIncidentMgr.GetIncidentAnswerList(d.incident.INCIDENT_ID);
                    INCIDENT_ANSWER answer = null;

                    // Date/Time

                    d.incidentDate = d.incident.INCIDENT_DT.ToShortDateString();
                    if ((answer = d.answerList.Where(a => a.INCIDENT_QUESTION_ID == (decimal)EHSQuestionId.TimeOfDay).SingleOrDefault()) != null)
                    {
                        if (!string.IsNullOrEmpty(answer.ANSWER_VALUE))
                        {
                            d.incidentTime = Convert.ToDateTime(answer.ANSWER_VALUE).ToShortTimeString();
                        }
                    }

                    if ((answer = d.answerList.Where(a => a.INCIDENT_QUESTION_ID == (decimal)EHSQuestionId.Shift).SingleOrDefault()) != null)
                    {
                        if (!string.IsNullOrEmpty(SQMBasePage.GetXLAT(reportXLAT, "SHIFT", answer.ANSWER_VALUE).DESCRIPTION))
                        {
                            answer.ANSWER_VALUE = SQMBasePage.GetXLAT(reportXLAT, "SHIFT", answer.ANSWER_VALUE).DESCRIPTION;
                        }
                    }

                    if ((answer = d.answerList.Where(a => a.INCIDENT_QUESTION_ID == (decimal)EHSQuestionId.Department).SingleOrDefault()) != null)
                    {
                        d.incidentDept = answer.ANSWER_VALUE;
                        decimal deptID = 0;
                        if (decimal.TryParse(answer.ANSWER_VALUE, out deptID))
                        {
                            DEPARTMENT dept = SQMModelMgr.LookupDepartment(entities, deptID);
                            if (dept != null)
                            {
                                d.incidentDept = dept.DEPT_NAME;
                            }
                        }
                    }

                    // Incident Type

                    d.incidentType = incidentType;

                    // Description

                    d.incidentDescription = d.incident.DESCRIPTION;

                    d.detectPerson = SQMModelMgr.LookupPerson(entities, (decimal)d.incident.CREATE_PERSON, "", false);
                    if (d.detectPerson != null)
                    {
                        d.supervisorPerson = SQMModelMgr.LookupPersonByEmpID(entities, d.detectPerson.SUPV_EMP_ID);
                    }

                    if (d.incident.ISSUE_TYPE_ID == (decimal)EHSIncidentTypeId.InjuryIllness)
                    {
                        if (d.incident.INCFORM_INJURYILLNESS.INVOLVED_PERSON_ID.HasValue)
                        {
                            d.involvedPerson = SQMModelMgr.LookupPerson(entities, (decimal)d.incident.INCFORM_INJURYILLNESS.INVOLVED_PERSON_ID, "", false);
                            if (d.involvedPerson != null)
                            {
                                if (d.incident.INCFORM_INJURYILLNESS.SUPERVISOR_PERSON_ID.HasValue)                                             // supervisor was known
                                {
                                    d.supervisorPerson = SQMModelMgr.LookupPerson(entities, (decimal)d.incident.INCFORM_INJURYILLNESS.SUPERVISOR_PERSON_ID, "", false);
                                }
                                else
                                {
                                    // get current supervisor
                                    d.supervisorPerson = SQMModelMgr.LookupPersonByEmpID(entities, d.involvedPerson.SUPV_EMP_ID);
                                }
                            }
                        }
                        else
                        {
                            d.involvedPerson            = new PERSON();
                            d.involvedPerson.FIRST_NAME = d.incident.INCFORM_INJURYILLNESS.INVOLVED_PERSON_NAME;
                        }

                        if (d.incident.INCFORM_INJURYILLNESS.DEPT_ID.HasValue)
                        {
                            DEPARTMENT dept = SQMModelMgr.LookupDepartment(entities, (decimal)d.incident.INCFORM_INJURYILLNESS.DEPT_ID);
                            if (dept != null)
                            {
                                d.incidentDept = dept.DEPT_NAME;
                            }
                        }
                        else
                        {
                            d.incidentDept = d.incident.INCFORM_INJURYILLNESS.DEPARTMENT;
                        }
                    }

                    // Containment
                    foreach (INCFORM_CONTAIN cc in EHSIncidentMgr.GetContainmentList(iid, null, false))
                    {
                        if (cc.ASSIGNED_PERSON_ID.HasValue)
                        {
                            cc.ASSIGNED_PERSON = SQMModelMgr.FormatPersonListItem(SQMModelMgr.LookupPerson((decimal)cc.ASSIGNED_PERSON_ID, ""));
                        }
                        d.containList.Add(cc);
                    }

                    // Root Cause(s)
                    d.root5YList = EHSIncidentMgr.GetRootCauseList(iid).Where(l => !string.IsNullOrEmpty(l.ITEM_DESCRIPTION)).ToList();
                    if (d.root5YList != null && d.root5YList.Count > 0)
                    {
                        d.incident.INCFORM_CAUSATION.Load();
                        if (d.incident.INCFORM_CAUSATION != null && d.incident.INCFORM_CAUSATION.Count > 0)
                        {
                            d.causation = d.incident.INCFORM_CAUSATION.ElementAt(0);
                        }
                    }

                    // Corrective Actions
                    foreach (TASK_STATUS ac in EHSIncidentMgr.GetCorrectiveActionList(iid, null, false))
                    {
                        if (ac.RESPONSIBLE_ID.HasValue)
                        {
                            ac.COMMENTS = SQMModelMgr.FormatPersonListItem(SQMModelMgr.LookupPerson((decimal)ac.RESPONSIBLE_ID, ""));
                        }
                        d.actionList.Add(ac);
                    }

                    var files = (from a in entities.ATTACHMENT
                                 where
                                 (a.RECORD_ID == iid && a.RECORD_TYPE == 40 && a.DISPLAY_TYPE > 0) &&
                                 (a.FILE_NAME.ToLower().Contains(".jpg") || a.FILE_NAME.ToLower().Contains(".jpeg") ||
                                  a.FILE_NAME.ToLower().Contains(".gif") || a.FILE_NAME.ToLower().Contains(".png") ||
                                  a.FILE_NAME.ToLower().Contains(".bmp"))
                                 orderby a.RECORD_TYPE, a.FILE_NAME
                                 select new
                    {
                        Data = (from f in entities.ATTACHMENT_FILE where f.ATTACHMENT_ID == a.ATTACHMENT_ID select f.ATTACHMENT_DATA).FirstOrDefault(),
                        Description = (string.IsNullOrEmpty(a.FILE_DESC)) ? "" : a.FILE_DESC,
                    }).ToList();


                    d.approvalList = EHSIncidentMgr.GetApprovalList(entities, (decimal)d.incident.ISSUE_TYPE_ID, 10.0m, iid, null, 0);

                    if (files.Count > 0)
                    {
                        d.photoData     = new List <byte[]>();
                        d.photoCaptions = new List <string>();

                        foreach (var f in files)
                        {
                            d.photoData.Add(f.Data);
                            d.photoCaptions.Add(f.Description);
                        }
                    }
                }
                catch
                {
                }
            }

            return(d);
        }
예제 #17
0
        private void uclCaseEdit_OnSaveClick(string cmdArg)
        {
            bool bNotify;

            CaseCtl().problemCase.UpdateStatus = CaseUpdateStatus.Success;
            switch (cmdArg)
            {
            case "0":
                CaseCtl().problemCase = uclCaseEdit.UpdateCase0(CaseCtl().problemCase);
                if (CaseCtl().problemCase.UpdateStatus == CaseUpdateStatus.Success)
                {
                    CaseCtl().Update();
                    uclCaseEdit.BindCase0();
                }
                break;

            case "1":
                CaseCtl().problemCase = uclCaseEdit.UpdateCase1(CaseCtl().problemCase, out bNotify);
                if (CaseCtl().problemCase.UpdateStatus == CaseUpdateStatus.Success)
                {
                    CaseCtl().Update();
                    uclCaseEdit.BindCase1(bNotify);
                    if (CaseCtl().problemCase.UpdateStatus == CaseUpdateStatus.Success && bNotify)
                    {
                        try
                        {
                            string appUrl = SQMSettings.SelectSettingByCode(entities, "MAIL", "TASK", "MailURL").VALUE;
                            PERSON person = null;
                            PLANT  plant  = SQMModelMgr.LookupPlant((decimal)CaseCtl().problemCase.IncidentList[0].DETECT_PLANT_ID);
                            int    emailStatus;
                            bool   bUpdateTasks = false;
                            foreach (TASK_STATUS task in CaseCtl().problemCase.TeamTask.TaskList.Where(t => t.TASK_TYPE == "C" && t.TASK_SEQ == 0).ToList())
                            {
                                if (task.RESPONSIBLE_ID.HasValue && (person = SQMModelMgr.LookupPerson((decimal)task.RESPONSIBLE_ID, "")) != null && !task.NOTIFY_DT.HasValue)
                                {
                                    task.NOTIFY_DT = DateTime.UtcNow;
                                    List <TaskItem> taskList = new List <TaskItem>();
                                    TaskItem        taskItem = new TaskItem();
                                    taskItem.RecordID    = CaseCtl().problemCase.ProbCase.PROBCASE_ID;
                                    taskItem.RecordKey   = CaseCtl().problemCase.ProbCase.PROBCASE_ID.ToString();
                                    taskItem.RecordType  = 21;
                                    taskItem.NotifyType  = TaskNotification.Owner;
                                    taskItem.Taskstatus  = TaskMgr.CalculateTaskStatus(task);
                                    taskItem.Detail      = SQMModelMgr.FormatPersonListItem(person);
                                    taskItem.Description = WebSiteCommon.FormatID(CaseCtl().problemCase.ProbCase.PROBCASE_ID, 6) + " / " + WebSiteCommon.GetXlatValue("caseStep", task.TASK_STEP);
                                    taskItem.Plant       = plant;
                                    taskItem.Task        = task;
                                    //  taskItem.Task = task;
                                    taskList.Add(taskItem);
                                    Thread thread = new Thread(() => TaskMgr.MailTaskList(taskList, person.EMAIL, "web"));
                                    thread.IsBackground = true;
                                    thread.Start();
                                    bUpdateTasks = true;
                                    //  if ((emailStatus = TaskMgr.MailTaskList(taskList, person.EMAIL, "web")) > 0)
                                    //      bUpdateTasks = true;
                                }
                            }
                            if (bUpdateTasks)
                            {
                                CaseCtl().Update();     // save task notify dates
                            }
                        }
                        catch (Exception ex)
                        {
                            //  SQMLogger.LogException(ex);
                        }
                    }
                }
                break;

            case "2":
                CaseCtl().problemCase = uclCaseEdit.UpdateCase2(CaseCtl().problemCase);
                if (CaseCtl().problemCase.UpdateStatus == CaseUpdateStatus.Success)
                {
                    CaseCtl().Update();
                    uclCaseEdit.BindCase2();
                }
                break;

            case "3":
                CaseCtl().problemCase = uclCaseEdit.UpdateCase3(CaseCtl().problemCase);
                if (CaseCtl().problemCase.UpdateStatus == CaseUpdateStatus.Success)
                {
                    CaseCtl().Update();
                    uclCaseEdit.BindCase3();
                }
                break;

            case "4":
                CaseCtl().problemCase = uclCaseEdit.UpdateCase4(CaseCtl().problemCase);
                if (CaseCtl().problemCase.UpdateStatus == CaseUpdateStatus.Success)
                {
                    CaseCtl().Update();
                    uclCaseEdit.BindCase4();
                }
                break;

            case "5":
                CaseCtl().problemCase = uclCaseEdit.UpdateCase5(CaseCtl().problemCase);
                if (CaseCtl().problemCase.UpdateStatus == CaseUpdateStatus.Success)
                {
                    CaseCtl().Update();
                    uclCaseEdit.BindCase5();
                }
                break;

            case "6":
                CaseCtl().problemCase = uclCaseEdit.UpdateCase6(CaseCtl().problemCase);
                if (CaseCtl().problemCase.UpdateStatus == CaseUpdateStatus.Success)
                {
                    CaseCtl().Update();
                    uclCaseEdit.BindCase6();
                }
                break;

            case "7":
                CaseCtl().problemCase = uclCaseEdit.UpdateCase7(CaseCtl().problemCase, true);
                if (CaseCtl().problemCase.UpdateStatus == CaseUpdateStatus.Success)
                {
                    CaseCtl().Update();
                    uclCaseEdit.BindCase7();
                }
                break;

            case "8":
                CaseCtl().problemCase = uclCaseEdit.UpdateCase8(CaseCtl().problemCase, out bNotify);
                CaseCtl().Update();
                uclCaseEdit.BindCase8(bNotify);
                if (bNotify && CaseCtl().problemCase != null)
                {
                    List <decimal?> teamList = new List <decimal?>();
                    teamList = CaseCtl().problemCase.TeamTask.TaskList.Where(l => l.TASK_TYPE == "C" && l.RESPONSIBLE_ID > 0).Select(l => l.RESPONSIBLE_ID).Distinct().ToList();
                    PERSON person = null;
                    // string emailStatus;
                    foreach (decimal?personID in teamList)
                    {
                        if ((person = SQMModelMgr.LookupPerson((decimal)personID, "")) != null)
                        {
                            Thread thread = new Thread(() => WebSiteCommon.SendEmail(person.EMAIL, CaseCtl().problemCase.ProbCase.PROB_CLOSE.MESSAGE_TITLE, CaseCtl().problemCase.ProbCase.PROB_CLOSE.MESSAGE, ""));
                            thread.IsBackground = true;
                            thread.Start();
                        }
                    }
                }
                break;

            default:
                break;
            }

            if (CaseCtl().problemCase.UpdateStatus == CaseUpdateStatus.Success)
            {
                ScriptManager.RegisterStartupScript(this, GetType(), "showalert", "alertResult('hfAlertSaveSuccess');", true);
                SetupPage();
            }
            else
            {
                ErrorAlert(CaseCtl().problemCase.UpdateStatus);
            }
        }
예제 #18
0
        public static int NotifyIncidentStatus(INCIDENT incident, string scopeAction)
        {
            int    status = 0;
            string notifyScope;

            if ((EHSIncidentTypeId)incident.ISSUE_TYPE_ID == EHSIncidentTypeId.InjuryIllness)
            {
                notifyScope = "IN-" + incident.ISSUE_TYPE_ID.ToString();
            }
            else
            {
                notifyScope = "IN-" + ((int)EHSIncidentTypeId.Any).ToString();
            }

            PLANT         plant            = SQMModelMgr.LookupPlant((decimal)incident.DETECT_PLANT_ID);
            List <PERSON> notifyPersonList = InvolvedPersonList(incident);

            notifyPersonList.AddRange(GetNotifyPersonList(plant, notifyScope, scopeAction));

            if (notifyPersonList.Count > 0)
            {
                List <XLAT> XLATList = SQMBasePage.SelectXLATList(new string[3] {
                    "NOTIFY_SCOPE", "NOTIFY_SCOPE_TASK", "NOTIFY_TASK_STATUS"
                });
                string appUrl = SQMSettings.SelectSettingByCode(new PSsqmEntities(), "MAIL", "TASK", "MailURL").VALUE;
                if (string.IsNullOrEmpty(appUrl))
                {
                    appUrl = "the website";
                }

                string actionText   = XLATList.Where(x => x.XLAT_GROUP == "NOTIFY_SCOPE_TASK" && x.XLAT_CODE == scopeAction).FirstOrDefault().DESCRIPTION;
                string emailSubject = "Health/Safety Incident " + actionText + ": " + incident.ISSUE_TYPE + " (" + plant.PLANT_NAME + ")";
                string emailBody    = "A new Health/Safety incident has been " + actionText + " :<br/>" +
                                      "<br/>" +
                                      "Incident ID: " + WebSiteCommon.FormatID(incident.INCIDENT_ID, 6) + "<br/>" +
                                      plant.PLANT_NAME + "<br/>" +
                                      incident.ISSUE_TYPE + "<br/>" +
                                      "<br/>" +
                                      incident.DESCRIPTION + "<br/>" +
                                      "<br/>" +
                                      "On : " + DateTime.Now.ToString() +
                                      "<br/>" +
                                      "By : " + incident.LAST_UPD_BY +
                                      "<br/>" +
                                      "Please log in to " + (appUrl + incidentPath) + " to view this incident.";

                string emailTo = "";
                foreach (PERSON person in notifyPersonList.Where(l => !string.IsNullOrEmpty(l.EMAIL)).ToList())
                {
                    emailTo += string.IsNullOrEmpty(emailTo) ? person.EMAIL : ("," + person.EMAIL);
                }

                Thread thread = new Thread(() => WebSiteCommon.SendEmail(emailTo, emailSubject, emailBody, "", "web", null));
                thread.IsBackground = true;
                thread.Start();
            }

            //WebSiteCommon.SendEmail(emailTo, emailSubject, emailBody, "", "web", null);

            return(status);
        }
예제 #19
0
        protected void rgVideoList_ItemDataBound(object sender, GridItemEventArgs e)
        {
            if (e.Item is GridDataItem)
            {
                GridDataItem item = (GridDataItem)e.Item;
                HiddenField  hf;
                Label        lbl;

                MediaVideoData data = (MediaVideoData)e.Item.DataItem;

                LinkButton lnk = (LinkButton)e.Item.FindControl("lbVideoId");
                lnk.Text            = WebSiteCommon.FormatID(data.Video.VIDEO_ID, 6);
                lnk.CommandArgument = data.Video.VIDEO_ID.ToString();
                //if (SessionManager.UserContext.Person.PERSON_ID == data.Person.PERSON_ID)
                //	lnk.CommandArgument = data.Video.VIDEO_ID.ToString() + "~" + data.Status;
                //else if (!data.Status.Equals("C"))
                //	lnk.CommandArgument = data.Audit.AUDIT_ID.ToString() + "~D";
                //else
                //	lnk.CommandArgument = data.Audit.AUDIT_ID.ToString() + "~C";

                RadButton rlnk = (RadButton)e.Item.FindControl("lbnDelete");
                if (data.Video.SOURCE_TYPE == (int)TaskRecordType.Audit || data.Video.SOURCE_TYPE == (int)TaskRecordType.HealthSafetyIncident)
                {
                    rlnk.Visible = false;
                }
                else
                {
                    rlnk.Visible = true;
                }

                if (data.Video.TITLE.Length > 120)
                {
                    lbl      = (Label)e.Item.FindControl("lblVideoTitle");
                    lbl.Text = data.Video.TITLE.Substring(0, 117) + "...";
                }

                if (data.Person != null)
                {
                    lbl      = (Label)e.Item.FindControl("lblVideoBy");
                    lbl.Text = SQMModelMgr.FormatPersonListItem(data.Person);
                }

                lbl = (Label)e.Item.FindControl("lblVideoStatus");                 // what to do with this?
                try
                {
                    lbl.Text = SQMBasePage.GetXLAT(listXLAT, "MEDIA_VIDEO_STATUS", data.Video.VIDEO_STATUS).DESCRIPTION;
                }
                catch { }

                //if (data.Video.VIDEO_STATUS == "C")
                //{
                //	DateTime clsDate = (DateTime)data.Audit.CLOSE_DATE_DATA_COMPLETE;
                //	lbl.Text = WebSiteCommon.GetXlatValue("auditStatus", "C") + " " + SQMBasePage.FormatDate(clsDate, "d", false);
                //}
                //else
                //{
                //	if (data.DaysToClose == 0)
                //	{
                //		DateTime tmp = ((DateTime)data.Audit.AUDIT_DT).AddDays(data.AuditType.DAYS_TO_COMPLETE);
                //		lbl.Text = WebSiteCommon.GetXlatValue("auditStatus", "X") + "<br/>(" + SQMBasePage.FormatDate(tmp, "d", false) + ")";
                //	}
                //	else if (data.Audit.PERCENT_COMPLETE > 0)
                //		lbl.Text = WebSiteCommon.GetXlatValue("auditStatus", "I") + "<br/>(" + data.DaysToClose + ")";
                //	else
                //		lbl.Text = WebSiteCommon.GetXlatValue("auditStatus", "A") + "<br/>(" + data.DaysToClose + ")";
                //}
            }
        }
예제 #20
0
        protected void rgTaskList_ItemDataBound(object sender, GridItemEventArgs e)
        {
            if (e.Item is GridDataItem)
            {
                GridDataItem item = (GridDataItem)e.Item;
                HiddenField  hf;
                Label        lbl;

                try
                {
                    TASK_STATUS task = (TASK_STATUS)e.Item.DataItem;

                    LinkButton lnk = (LinkButton)e.Item.FindControl("lbTaskId");
                    lnk.Text = WebSiteCommon.FormatID(task.TASK_ID, 6);
                    if (task.DESCRIPTION != null)
                    {
                        if (task.DESCRIPTION.Length > 120)
                        {
                            lbl      = (Label)e.Item.FindControl("lblDescription");
                            lbl.Text = task.DESCRIPTION.Substring(0, 117) + "...";
                        }
                    }
                    lbl = (Label)e.Item.FindControl("lblTaskType");

                    lbl.Text = TaskXLATList.Where(l => l.XLAT_GROUP == "RECORD_TYPE" && l.XLAT_CODE == task.RECORD_TYPE.ToString()).FirstOrDefault().DESCRIPTION;
                    if (task.TASK_STEP == "350" || task.TASK_STEP == "400")
                    {
                        if (task.RECORD_TYPE == (int)TaskRecordType.Audit && task.RECORD_SUBID > 0)
                        {
                            lbl.Text += ("&nbsp;Exception");
                        }
                        lbl.Text += (" - " + TaskXLATList.Where(l => l.XLAT_GROUP == "NOTIFY_SCOPE_TASK" && l.XLAT_CODE == task.TASK_STEP).FirstOrDefault().DESCRIPTION);
                    }

                    lbl = (Label)e.Item.FindControl("lblCreateDT");
                    if (task.CREATE_DT.HasValue)
                    {
                        lbl.Text = Convert.ToDateTime(task.CREATE_DT).ToShortDateString();
                    }
                    lbl = (Label)e.Item.FindControl("lblDueDT");
                    if (task.DUE_DT.HasValue)
                    {
                        lbl.Text = Convert.ToDateTime(task.DUE_DT).ToShortDateString();
                    }

                    lbl      = (Label)e.Item.FindControl("lblStatus");
                    lbl.Text = TaskXLATList.Where(l => l.XLAT_GROUP == "TASK_STATUS" && l.XLAT_CODE == ((int)TaskMgr.CalculateTaskStatus(task)).ToString()).FirstOrDefault().DESCRIPTION_SHORT;

                    lbl = (Label)e.Item.FindControl("lblResponsiblePerson");
                    PERSON responsiblePerson = new PERSON();
                    try
                    {
                        PSsqmEntities entities = new PSsqmEntities();
                        responsiblePerson = SQMModelMgr.LookupPerson((decimal)task.RESPONSIBLE_ID, "");
                    }
                    catch { }

                    if (responsiblePerson != null)
                    {
                        lbl.Text = SQMModelMgr.FormatPersonListItem(responsiblePerson, false, "LF");
                    }
                }
                catch
                {
                }
            }
        }
예제 #21
0
        protected void rgAuditList_ItemDataBound(object sender, GridItemEventArgs e)
        {
            if (e.Item is GridDataItem)
            {
                GridDataItem item = (GridDataItem)e.Item;
                HiddenField  hf;
                Label        lbl;

                EHSAuditData data = (EHSAuditData)e.Item.DataItem;

                LinkButton lnk = (LinkButton)e.Item.FindControl("lbAuditId");
                lnk.Text = WebSiteCommon.FormatID(data.Audit.AUDIT_ID, 6);

                /*
                 * if (data.Audit.DESCRIPTION.Length > 120)
                 * {
                 *      lbl = (Label)e.Item.FindControl("lblDescription");
                 *      lbl.Text = data.Audit.DESCRIPTION.Substring(0, 117) + "...";
                 * }
                 */
                //lbl = (Label)e.Item.FindControl("lblDescription");
                //lbl.Text = HttpUtility.HtmlEncode(lbl.Text);

                if (data.Person != null)
                {
                    lbl      = (Label)e.Item.FindControl("lblAuditBy");
                    lbl.Text = SQMModelMgr.FormatPersonListItem(data.Person);
                }

                lbl = (Label)e.Item.FindControl("lblAuditStatus");

                List <XLAT> TaskXLATList = SQMBasePage.SelectXLATList(new string[1] {
                    "AUDIT_STATUS"
                });

                if (data.Audit.CURRENT_STATUS == "C")
                {
                    // TODO: This throws a null reference error when the database field is NULL (which is valid)
                    DateTime clsDate = (DateTime)data.Audit.CLOSE_DATE_DATA_COMPLETE;
                    lbl.Text = TaskXLATList.Where(l => l.XLAT_GROUP == "AUDIT_STATUS" && l.XLAT_CODE == "C").FirstOrDefault().DESCRIPTION + " " + SQMBasePage.FormatDate(clsDate, "d", false);

                    // TODO: Possible fix
                    //DateTime? clsDate = data.Audit.CLOSE_DATE;
                    //if (data.Audit.CLOSE_DATE_DATA_COMPLETE.HasValue)
                    //{
                    //	clsDate = data.Audit.CLOSE_DATE_DATA_COMPLETE;
                    //}

                    //if (clsDate.HasValue)
                    //{
                    //	lbl.Text = TaskXLATList.Where(l => l.XLAT_GROUP == "AUDIT_STATUS" && l.XLAT_CODE == "C").FirstOrDefault().DESCRIPTION + " " + SQMBasePage.FormatDate(clsDate.Value, "d", false);
                    //}
                }
                else
                {
                    if (data.DaysToClose == 0)
                    {
                        DateTime tmp = ((DateTime)data.Audit.AUDIT_DT).AddDays(data.AuditType.DAYS_TO_COMPLETE);
                        lbl.Text = TaskXLATList.Where(l => l.XLAT_GROUP == "AUDIT_STATUS" && l.XLAT_CODE == "X").FirstOrDefault().DESCRIPTION + "<br/>(" + SQMBasePage.FormatDate(tmp, "d", false) + ")";
                    }
                    else if (data.Audit.PERCENT_COMPLETE > 0)
                    {
                        lbl.Text = TaskXLATList.Where(l => l.XLAT_GROUP == "AUDIT_STATUS" && l.XLAT_CODE == "I").FirstOrDefault().DESCRIPTION + "<br/>(" + data.DaysToClose + ")";
                    }
                    else
                    {
                        lbl.Text = TaskXLATList.Where(l => l.XLAT_GROUP == "AUDIT_STATUS" && l.XLAT_CODE == "A").FirstOrDefault().DESCRIPTION + "<br/>(" + data.DaysToClose + ")";
                    }
                }

                lnk = (LinkButton)e.Item.FindControl("lbAuditId");
                LinkButton  lnkReAudit    = (LinkButton)e.Item.FindControl("lbReAudit");
                Label       lblAuditingId = (Label)e.Item.FindControl("lblAuditingId");
                HiddenField hdnId         = (HiddenField)e.Item.FindControl("hdnAuditingId");

                if (allowReAudits.ToUpper().Equals("Y"))
                {
                    if (SessionManager.CheckUserPrivilege(SysPriv.admin, SysScope.audit))
                    {
                        if (hdnId.Value.ToString().Trim().Equals("0") || hdnId.Value.ToString().Trim().Equals(""))
                        {
                            lblAuditingId.Visible = false;
                        }
                        else
                        {
                            lnkReAudit.Visible = false;
                            lblAuditingId.Text = Resources.LocalizedText.ReAuditing + " " + hdnId.Value.ToString();
                        }
                    }
                    else
                    {
                        lnkReAudit.Visible    = false;
                        lblAuditingId.Visible = false;
                    }
                }
                else
                {
                    lnkReAudit.Visible    = false;
                    lblAuditingId.Visible = false;
                }

                if (SessionManager.UserContext.Person.PERSON_ID == data.Person.PERSON_ID)
                {
                    lnk.CommandArgument = data.Audit.AUDIT_ID.ToString() + "~" + data.Status;
                    lnkReAudit.Visible  = false;
                    //lblAuditingId.Visible = false;
                }
                else if (!data.Status.Equals("C"))
                {
                    lnk.CommandArgument = data.Audit.AUDIT_ID.ToString() + "~D";
                }
                else
                {
                    lnk.CommandArgument = data.Audit.AUDIT_ID.ToString() + "~C";
                }
            }
        }
        protected void rgCaseList_ItemDataBound(object sender, GridItemEventArgs e)
        {
            if (e.Item is GridHeaderItem)
            {
                GridHeaderItem gh = e.Item as GridHeaderItem;
                if (staticAppContext == "QI")
                {
                    //gh.Cells[4].Text = "";
                    //gh.Cells[4].Visible = false;
                    ;
                }
                else
                {
                    ;
                }
            }

            if (e.Item is GridDataItem)
            {
                try
                {
                    GridDataItem item = (GridDataItem)e.Item;
                    HiddenField  hf   = (HiddenField)item["Reports"].FindControl("hfProblemCaseType");

                    LinkButton lbReportQi  = (LinkButton)item["Reports"].FindControl("lbReport");
                    HyperLink  hlReportEhs = (HyperLink)item["Reports"].FindControl("hlReport");

                    lbReportQi.Attributes.Add("CaseType", hf.Value);

                    //lbReportQi.Visible = (hf.Value != "EHS");
                    lbReportQi.Visible  = true;
                    hlReportEhs.Visible = (hf.Value == "EHS");

                    ProblemCase probCase = (ProblemCase)e.Item.DataItem;

                    Label lbl = (Label)e.Item.FindControl("lblCaseID");
                    lbl.Text = WebSiteCommon.FormatID(probCase.ProbCase.PROBCASE_ID, 6);
                    LinkButton lnk = (LinkButton)e.Item.FindControl("lbCaseId");

                    lbl = (Label)e.Item.FindControl("lblIncidentID");
                    if (probCase.IncidentList != null && probCase.IncidentList.Count > 0)
                    {
                        lbl.Text = WebSiteCommon.FormatID(probCase.IncidentList[0].INCIDENT_ID, 6);
                    }

                    lbl = (Label)e.Item.FindControl("lblStatus");
                    if (probCase.ProbCase.CLOSE_DT.HasValue)
                    {
                        lbl.Text = WebSiteCommon.GetXlatValue("recordStatus", "C") + ": " + SQMBasePage.FormatDate((DateTime)probCase.ProbCase.CLOSE_DT, "d", false);
                    }
                    else
                    {
                        lbl.Text = WebSiteCommon.GetXlatValue("caseStep", (Math.Max((decimal)probCase.ProbCase.PROGRESS, 1) - 1).ToString());
                        hf       = (HiddenField)e.Item.FindControl("hfStatus");
                        if (hf.Value == "I")
                        {
                            Image img = (Image)e.Item.FindControl("imgStatus");
                            img.ImageUrl = "/images/defaulticon/16x16/no.png";
                            img.Visible  = true;
                        }
                    }
                }
                catch
                {
                }
            }
        }
예제 #23
0
        protected void rgAuditList_ItemDataBound(object sender, GridItemEventArgs e)
        {
            if (e.Item is GridDataItem)
            {
                GridDataItem item = (GridDataItem)e.Item;
                HiddenField  hf;
                Label        lbl;

                EHSAuditData data = (EHSAuditData)e.Item.DataItem;

                lbl      = (Label)e.Item.FindControl("lblAuditId");
                lbl.Text = WebSiteCommon.FormatID(data.Audit.AUDIT_ID, 6);

                if (data.Audit.DESCRIPTION.Length > 120)
                {
                    lbl      = (Label)e.Item.FindControl("lblDescription");
                    lbl.Text = data.Audit.DESCRIPTION.Substring(0, 117) + "...";
                }

                //lbl = (Label)e.Item.FindControl("lblDescription");
                //lbl.Text = HttpUtility.HtmlEncode(lbl.Text);

                if (data.Person != null)
                {
                    lbl      = (Label)e.Item.FindControl("lblAuditBy");
                    lbl.Text = SQMModelMgr.FormatPersonListItem(data.Person);
                }

                lbl = (Label)e.Item.FindControl("lblAuditStatus");

                if (data.Audit.CURRENT_STATUS == "C")
                {
                    DateTime clsDate = (DateTime)data.Audit.CLOSE_DATE_DATA_COMPLETE;
                    lbl.Text = WebSiteCommon.GetXlatValue("auditStatus", "C") + " " + SQMBasePage.FormatDate(clsDate, "d", false);
                }
                else
                {
                    if (data.DaysToClose == 0)
                    {
                        DateTime tmp = ((DateTime)data.Audit.AUDIT_DT).AddDays(data.AuditType.DAYS_TO_COMPLETE);
                        lbl.Text = WebSiteCommon.GetXlatValue("auditStatus", "X") + "<br/>(" + SQMBasePage.FormatDate(tmp, "d", false) + ")";
                    }
                    else if (data.Audit.PERCENT_COMPLETE > 0)
                    {
                        lbl.Text = WebSiteCommon.GetXlatValue("auditStatus", "I") + "<br/>(" + data.DaysToClose + ")";
                    }
                    else
                    {
                        lbl.Text = WebSiteCommon.GetXlatValue("auditStatus", "A") + "<br/>(" + data.DaysToClose + ")";
                    }
                }

                LinkButton lnk = (LinkButton)e.Item.FindControl("lbAuditId");

                if (SessionManager.UserContext.Person.PERSON_ID == data.Person.PERSON_ID)
                {
                    lnk.CommandArgument = data.Audit.AUDIT_ID.ToString() + "~" + data.Status;
                }
                else if (!data.Status.Equals("C"))
                {
                    lnk.CommandArgument = data.Audit.AUDIT_ID.ToString() + "~D";
                }
                else
                {
                    lnk.CommandArgument = data.Audit.AUDIT_ID.ToString() + "~C";
                }
            }
        }
        protected void rgPreventativeList_ItemDataBound(object sender, GridItemEventArgs e)
        {
            if (e.Item is GridDataItem)
            {
                HiddenField hf;
                Label       lbl;
                string      val = "";

                EHSIncidentData data = (EHSIncidentData)e.Item.DataItem;

                lbl      = (Label)e.Item.FindControl("lblIncidentId");
                lbl.Text = WebSiteCommon.FormatID(data.Incident.INCIDENT_ID, 6);

                lbl      = (Label)e.Item.FindControl("lblDescription");
                lbl.Text = StringHtmlExtensions.TruncateHtml(data.Incident.DESCRIPTION, 100, "...");
                lbl.Text = lbl.Text.Replace("<a href", "<a target=\"blank\" href");

                if (data.Person != null)
                {
                    lbl      = (Label)e.Item.FindControl("lblReportedBy");
                    lbl.Text = SQMModelMgr.FormatPersonListItem(data.Person);
                }

                lbl      = (Label)e.Item.FindControl("lblCategory");
                lbl.Text = EHSIncidentMgr.SelectIncidentAnswer(data.Incident, (decimal)EHSQuestionId.InspectionCategory) + "<br/>" +
                           EHSIncidentMgr.SelectIncidentAnswer(data.Incident, (decimal)EHSQuestionId.RecommendationType);

                lbl = (Label)e.Item.FindControl("lblIncStatus");
                try
                {
                    if (data.Status == "U")
                    {
                        lbl.Text = "Audited " + SQMBasePage.FormatDate((DateTime)data.Incident.CLOSE_DATE_DATA_COMPLETE, "d", false) + "<br/>(" + data.DaysToClose.ToString() + ")";
                    }
                    else if (data.Status == "F")
                    {
                        lbl.Text = "Awaiting Funding " + SQMBasePage.FormatDate((DateTime)data.Incident.CLOSE_DATE_DATA_COMPLETE, "d", false) + "<br/>(" + data.DaysToClose.ToString() + ")";
                    }
                    else if (data.Status == "C")
                    {
                        lbl.Text = "Closed  " + SQMBasePage.FormatDate((DateTime)data.Incident.CLOSE_DATE, "d", false) + "<br/><strong>Not Audited</strong>";
                    }
                    else
                    {
                        lbl.Text = WebSiteCommon.GetXlatValue("incidentStatus", data.Status) + "<br/>(" + data.DaysOpen + ")";
                    }
                }
                catch
                {
                    ;
                }

                LinkButton lbEditReport = (LinkButton)e.Item.FindControl("lbEditReport");
                lbEditReport.Visible = true;

                try
                {
                    lbl      = (Label)e.Item.FindControl("lblIncidentDT");
                    lbl.Text = SQMBasePage.FormatDate(data.Incident.INCIDENT_DT, "d", false);
                    if ((val = data.EntryList.Where(l => l.INCIDENT_QUESTION_ID == 80).Select(l => l.ANSWER_VALUE).FirstOrDefault()) != null && !string.IsNullOrEmpty(val))
                    {
                        val = val.Substring(0, val.IndexOf(' '));
                        DateTime parseDate;
                        if (DateTime.TryParse(val, CultureInfo.GetCultureInfo("en-US"), DateTimeStyles.AssumeLocal, out parseDate))
                        {
                            lbl.Text = parseDate.ToShortDateString();
                        }
                    }
                }
                catch {}
                try {
                    if ((val = data.EntryList.Where(l => l.INCIDENT_QUESTION_ID == 92).Select(l => l.ANSWER_VALUE).FirstOrDefault()) != null && !string.IsNullOrEmpty(val))
                    {
                        val = val.Substring(0, val.IndexOf(' '));
                        DateTime parseDate;
                        if (DateTime.TryParse(val, CultureInfo.GetCultureInfo("en-US"), DateTimeStyles.AssumeLocal, out parseDate))
                        {
                            lbl      = (Label)e.Item.FindControl("lblDueDT");
                            lbl.Text = parseDate.ToShortDateString();
                        }
                    }
                }
                catch  {; }

                if (data.RespPerson != null)
                {
                    lbl      = (Label)e.Item.FindControl("lblAssignedTo");
                    lbl.Text = SQMModelMgr.FormatPersonListItem(data.RespPerson);
                }

                if (rgPreventativeList.MasterTableView.GetColumn("Attach").Visible&&  data.AttachList != null)
                {
                    lbl = (Label)e.Item.FindControl("lblAttach");
                    Ucl_Attach attch = (Ucl_Attach)Page.LoadControl("/Include/Ucl_Attach.ascx");
                    lbl.Parent.Controls.AddAt(lbl.Parent.Controls.IndexOf(lbl), attch);
                    attch.BindListAttachment(data.AttachList, "1", 1);
                }
            }
        }