public int BindProfileMeasure(EHS_PROFILE_MEASURE pm)
        {
            int status = 0;

            pnlMetricEdit.Visible   = true;
            spUOMFactor.Visible     = false;
            pnlMetricEdit.Visible   = true;
            btnMetricCancel.Enabled = true;
            DisplayErrorMessage(null);

            if (pm == null)
            {
                ddlMetricID.Enabled             = ddlMetricCost.Enabled = ddlMetricDisposalCode.Enabled = ddlMetricRegStatus.Enabled = ddlMetricUOM.Enabled = ddlMetricCurrency.Enabled = ddlMetricResponsible.Enabled = false;
                ddlMetricCategory.SelectedIndex = ddlMetricID.SelectedIndex = ddlMetricDisposalCode.SelectedIndex = ddlMetricRegStatus.SelectedIndex = ddlMetricUOM.SelectedIndex = ddlMetricCost.SelectedIndex = ddlMetricResponsible.SelectedIndex = 0;
                if (ddlMetricCurrency.Items.FindByValue(LocalProfile().Plant.CURRENCY_CODE) != null)
                {
                    ddlMetricCurrency.SelectedValue = LocalProfile().Plant.CURRENCY_CODE;
                }
                lblMetricName.Text       = lblDisposalDesc.Text = "";
                tbMetricPrompt.Text      = tbUOMFactor.Text = tbWasteCode.Text = "";
                winMetricEdit.Title      = hfAddMetric.Value;
                tbValueDflt.Text         = tbCostDflt.Text = "";
                cbEnableOverride.Checked = false;
                cbMetricRequired.Checked = true;
            }
            else
            {
                winMetricEdit.Title = hfUpdateMetric.Value;
                LocalProfile().CurrentProfileMeasure = pm;
                LocalProfile().CurrentEHSMeasure     = pm.EHS_MEASURE;

                if (pm.EHS_MEASURE != null && ddlMetricCategory.Items.FindByValue(pm.EHS_MEASURE.MEASURE_CATEGORY) != null)
                {
                    ddlMetricCategory.SelectedValue = pm.EHS_MEASURE.MEASURE_CATEGORY;
                    ddlCategoryChanged(ddlMetricCategory, null);
                    ddlMetricID.SelectedValue = WebSiteCommon.PackItemValue(pm.EHS_MEASURE.MEASURE_CATEGORY, pm.EHS_MEASURE.EFM_TYPE, pm.EHS_MEASURE.MEASURE_ID.ToString());
                    lblMetricName.Text        = pm.EHS_MEASURE.MEASURE_CD;

                    if (pm.EHS_MEASURE.MEASURE_CATEGORY != "PROD" && pm.EHS_MEASURE.MEASURE_CATEGORY != "SAFE" && pm.EHS_MEASURE.MEASURE_CATEGORY != "FACT" && ddlMetricCurrency.Items.FindByValue(pm.DEFAULT_CURRENCY_CODE) != null)
                    {
                        ddlMetricCurrency.SelectedValue = pm.DEFAULT_CURRENCY_CODE;
                    }

                    if (pm.EHS_MEASURE.MEASURE_CATEGORY != "PROD" && pm.EHS_MEASURE.MEASURE_CATEGORY != "SAFE" && pm.EHS_MEASURE.MEASURE_CATEGORY != "FACT" && pm.DEFAULT_UOM > 0)
                    {
                        UOM uom = SessionManager.UOMList.FirstOrDefault(l => l.UOM_ID == pm.DEFAULT_UOM);
                        if (uom != null)
                        {
                            if (ddlMetricUOM.Items.FindByValue(WebSiteCommon.PackItemValue(uom.UOM_CATEGORY, uom.EFM_TYPE, uom.UOM_ID.ToString())) != null)
                            {
                                ddlMetricUOM.SelectedValue = WebSiteCommon.PackItemValue(uom.UOM_CATEGORY, uom.EFM_TYPE, uom.UOM_ID.ToString());
                            }
                            else
                            {
                                ddlMetricUOM.SelectedIndex = 0;
                            }

                            if (uom.UOM_CATEGORY == "CUST")
                            {
                                spUOMFactor.Visible = true;
                            }
                        }

                        if (pm.UOM_FACTOR.HasValue)
                        {
                            tbUOMFactor.Text = SQMBasePage.FormatValue((decimal)pm.UOM_FACTOR, 5);
                        }
                    }

                    if (pm.EHS_MEASURE.MEASURE_CATEGORY != "PROD" && pm.EHS_MEASURE.MEASURE_CATEGORY != "SAFE" && pm.EHS_MEASURE.MEASURE_CATEGORY != "FACT")
                    {
                        if (pm.NEG_VALUE_ALLOWED.HasValue && (bool)pm.NEG_VALUE_ALLOWED)
                        {
                            ddlMetricCost.SelectedValue = "CREDIT";
                        }
                        else
                        {
                            ddlMetricCost.SelectedValue = "COST";
                        }
                    }
                }

                tbMetricPrompt.Text = pm.MEASURE_PROMPT;
                ddlMetricRegStatus.SelectedValue    = pm.REG_STATUS;
                ddlMetricDisposalCode.SelectedValue = pm.UN_CODE;
                if (!string.IsNullOrEmpty(pm.UN_CODE))
                {
                    lblDisposalDesc.Text = SessionManager.DisposalCodeList.FirstOrDefault(l => l.UN_CODE == pm.UN_CODE).DESCRIPTION;
                }
                else
                {
                    lblDisposalDesc.Text = "";
                }

                tbWasteCode.Text = pm.WASTE_CODE;

                if (pm.RESPONSIBLE_ID > 0 && ddlMetricResponsible.Items.FindByValue(pm.RESPONSIBLE_ID.ToString()) != null)
                {
                    ddlMetricResponsible.SelectedValue = pm.RESPONSIBLE_ID.ToString();
                }
                else
                {
                    ddlMetricResponsible.SelectedIndex = 0;
                }

                ddlUOMChanged(ddlMetricUOM, null);
                ddlMetricStatus.SelectedValue = pm.STATUS;
                cbMetricRequired.Checked      = (bool)pm.IS_REQUIRED;

                tbValueDflt.Text         = tbCostDflt.Text = "";
                cbEnableOverride.Checked = false;
                // radEffEndDate.ShowPopupOnFocus = true;
                //radEffEndDate.SelectedDate = null;
                if (pm.EHS_PROFILE_MEASURE_EXT != null && pm.EHS_PROFILE_MEASURE_EXT.VALUE_DEFAULT.HasValue)
                {
                    tbValueDflt.Text = SQMBasePage.FormatValue((decimal)pm.EHS_PROFILE_MEASURE_EXT.VALUE_DEFAULT, 2);
                }
                if (pm.EHS_PROFILE_MEASURE_EXT != null && pm.EHS_PROFILE_MEASURE_EXT.COST_DEFAULT.HasValue)
                {
                    tbCostDflt.Text = SQMBasePage.FormatValue((decimal)pm.EHS_PROFILE_MEASURE_EXT.COST_DEFAULT, 2);
                }
                if (pm.EHS_PROFILE_MEASURE_EXT != null && pm.EHS_PROFILE_MEASURE_EXT.OVERRIDE_ALLOWED.HasValue)
                {
                    cbEnableOverride.Checked = (bool)pm.EHS_PROFILE_MEASURE_EXT.OVERRIDE_ALLOWED;
                }
                //if (pm.EHS_PROFILE_MEASURE_EXT != null && pm.EHS_PROFILE_MEASURE_EXT.EFF_END_DT.HasValue)
                //    radEffEndDate.SelectedDate = pm.EHS_PROFILE_MEASURE_EXT.EFF_END_DT;
            }

            UpdateListTitles();
            pnlMetricEdit.Enabled = btnMetricCancel.Enabled = btnMetricSave.Enabled = UserContext.CheckAccess("EHS", "311") >= AccessMode.Plant ? true : false;

            string script = "function f(){OpenMetricEditWindow(); Sys.Application.remove_load(f);}Sys.Application.add_load(f);";

            ScriptManager.RegisterStartupScript(Page, Page.GetType(), "key", script, true);

            return(status);
        }
        private void SetupPage()
        {
            AccessMode accessmode = UserContext.RoleAccess();

            ddlScheduleScope.Items.Clear();

            if (accessmode >= AccessMode.Plant)
            {
                // List<BusinessLocation> locationList = SQMModelMgr.SelectBusinessLocationList(SessionManager.PrimaryCompany().COMPANY_ID, 0, true);
                List <BusinessLocation> locationList = SessionManager.PlantList;
                locationList = UserContext.FilterPlantAccessList(locationList, "EHS", "");
                locationList = UserContext.FilterPlantAccessList(locationList, "SQM", "");

                if (locationList.Select(l => l.Plant.BUS_ORG_ID).Distinct().Count() > 1 && SessionManager.IsUserAgentType("ipad,iphone") == false)
                {
                    ddlScheduleScope.Visible = false;
                    mnuScheduleScope.Visible = true;
                    SQMBasePage.SetLocationList(mnuScheduleScope, locationList, 0, SessionManager.UserContext.Person.FIRST_NAME + " " + SessionManager.UserContext.Person.LAST_NAME, "TOP", true);
                    RadMenuItem mi = new RadMenuItem();
                    mi.Text     = (SessionManager.UserContext.Person.FIRST_NAME + " " + SessionManager.UserContext.Person.LAST_NAME);
                    mi.Value    = "0";
                    mi.ImageUrl = "~/images/defaulticon/16x16/user-alt-2.png";
                    mnuScheduleScope.Items[0].Items.Insert(0, mi);
                }
                else
                {
                    ddlScheduleScope.Visible = true;
                    mnuScheduleScope.Visible = false;
                    SQMBasePage.SetLocationList(ddlScheduleScope, locationList, 0, true);
                    ddlScheduleScope.Items.Insert(0, new RadComboBoxItem((SessionManager.UserContext.Person.FIRST_NAME + " " + SessionManager.UserContext.Person.LAST_NAME), "0"));
                    ddlScheduleScope.Items[0].ImageUrl = "~/images/defaulticon/16x16/user-alt-2.png";
                }
            }
            else
            {
                ddlScheduleScope.Visible = true;
                mnuScheduleScope.Visible = false;
                ddlScheduleScope.Items.Insert(0, new RadComboBoxItem((SessionManager.UserContext.Person.FIRST_NAME + " " + SessionManager.UserContext.Person.LAST_NAME), "0"));
                ddlScheduleScope.Items[0].ImageUrl = "~/images/defaulticon/16x16/user-alt-2.png";
            }

            respForList = new List <decimal>();
            respForList.Add(SessionManager.UserContext.Person.PERSON_ID);
            respForList.AddRange(SessionManager.UserContext.DelegateList);
            SessionManager.UserContext.TaskList.Clear();
            SessionManager.UserContext.TaskList = new List <TaskItem>();

            DateTime fromDate = DateTime.Now.AddMonths(-6);

            if (accessmode >= AccessMode.Limited)
            {
                SessionManager.UserContext.TaskList.AddRange(TaskMgr.ProfileInputStatus(new DateTime(fromDate.Year, fromDate.Month, 1), new DateTime(DateTime.Now.Year, DateTime.Now.Month, DateTime.Now.Day), respForList, SessionManager.UserContext.EscalationAssignments));
                SessionManager.UserContext.TaskList.AddRange(TaskMgr.IncidentTaskStatus(SessionManager.UserContext.HRLocation.Company.COMPANY_ID, respForList, SessionManager.UserContext.EscalationAssignments, true));
                if (accessmode == AccessMode.Admin && SessionManager.UserContext.EscalationAssignments.Count > 0)
                {
                    SessionManager.UserContext.TaskList.AddRange(TaskMgr.ProfileFinalizeStatus(new DateTime(fromDate.Year, fromDate.Month, 1), new DateTime(DateTime.Now.Year, DateTime.Now.Month, DateTime.Now.Day), respForList, SessionManager.UserContext.EscalationAssignments, SessionManager.UserContext.Person));
                }
            }

            ++SessionManager.UserContext.InboxReviews;
        }
        protected void rptLostTime_ItemCommand(object source, RepeaterCommandEventArgs e)
        {
            string cmd = "";

            if (source is Button)
            {
                Button btn = (Button)source;
                cmd = btn.CommandArgument;
            }
            else
            {
                cmd = e.CommandArgument.ToString();
            }

            if (cmd == "AddAnother")
            {
                var  itemList     = new List <INCFORM_LOSTTIME_HIST>();
                bool hasEmptyItem = false;

                foreach (RepeaterItem losttimeitem in rptLostTime.Items)
                {
                    var item = new INCFORM_LOSTTIME_HIST();

                    Label lb = (Label)losttimeitem.FindControl("lbItemSeq");

                    RadDropDownList rddlw = (RadDropDownList)losttimeitem.FindControl("rddlWorkStatus");

                    TextBox       tbr = (TextBox)losttimeitem.FindControl("tbRestrictDesc");
                    RadDatePicker bd  = (RadDatePicker)losttimeitem.FindControl("rdpBeginDate");
                    bd = SQMBasePage.SetRadDateCulture(bd, "");
                    RadDatePicker md = (RadDatePicker)losttimeitem.FindControl("rdpNextMedDate");
                    md = SQMBasePage.SetRadDateCulture(md, "");
                    RadDatePicker ed = (RadDatePicker)losttimeitem.FindControl("rdpExpectedReturnDT");
                    ed = SQMBasePage.SetRadDateCulture(ed, "");

                    rddlw.Items.Add(new DropDownListItem("", ""));
                    List <EHSMetaData> statuses = EHSMetaDataMgr.SelectMetaDataList("WORK_STATUS");
                    foreach (var s in statuses)
                    {
                        rddlw.Items.Add(new DropDownListItem(s.Text, s.Value));
                    }

                    if (!string.IsNullOrEmpty(rddlw.SelectedValue) && (rddlw.SelectedValue != ""))
                    {
                        item.WORK_STATUS = rddlw.SelectedValue;
                    }

                    if (rddlw.SelectedIndex == -1 || string.IsNullOrEmpty(rddlw.SelectedValue))
                    {
                        hasEmptyItem = true;
                    }

                    item.ITEM_DESCRIPTION = tbr.Text;
                    item.BEGIN_DT         = bd.SelectedDate;
                    //item.RETURN_TOWORK_DT = rd.SelectedDate;
                    item.NEXT_MEDAPPT_DT    = md.SelectedDate;
                    item.RETURN_EXPECTED_DT = ed.SelectedDate;

                    itemList.Add(item);
                }

                if (!hasEmptyItem)
                {
                    var emptyItem = new INCFORM_LOSTTIME_HIST();

                    emptyItem.ITEM_DESCRIPTION   = "";
                    emptyItem.WORK_STATUS        = null;
                    emptyItem.BEGIN_DT           = null;
                    emptyItem.RETURN_TOWORK_DT   = null;
                    emptyItem.NEXT_MEDAPPT_DT    = null;
                    emptyItem.RETURN_EXPECTED_DT = null;
                    itemList.Add(emptyItem);
                }
                rptLostTime.DataSource = itemList;
                rptLostTime.DataBind();

                Label lbResultsCtl = (Label)this.Page.FindControl("lbResults");
                if (lbResultsCtl != null)
                {
                    lbResultsCtl.Text = "";
                }

                if (LostTimeUpdateEvent != null)
                {
                    LostTimeUpdateEvent("AddOrDelete");
                }
            }

            else if (cmd == "Delete")
            {
                int delId    = e.Item.ItemIndex;
                int sequence = -1;
                var itemList = new List <INCFORM_LOSTTIME_HIST>();

                foreach (RepeaterItem losttimeitem in rptLostTime.Items)
                {
                    var item = new INCFORM_LOSTTIME_HIST();
                    ++sequence;
                    Label lb = (Label)losttimeitem.FindControl("lbItemSeq");

                    RadDropDownList rddlw = (RadDropDownList)losttimeitem.FindControl("rddlWorkStatus");
                    //rddlw.SelectedIndexChanged += rddlw_SelectedIndexChanged;

                    TextBox       tbr = (TextBox)losttimeitem.FindControl("tbRestrictDesc");
                    RadDatePicker bd  = (RadDatePicker)losttimeitem.FindControl("rdpBeginDate");
                    bd = SQMBasePage.SetRadDateCulture(bd, "");
                    RadDatePicker md = (RadDatePicker)losttimeitem.FindControl("rdpNextMedDate");
                    md = SQMBasePage.SetRadDateCulture(md, "");
                    RadDatePicker ed = (RadDatePicker)losttimeitem.FindControl("rdpExpectedReturnDT");
                    ed = SQMBasePage.SetRadDateCulture(ed, "");

                    rddlw.Items.Add(new DropDownListItem("", ""));
                    List <EHSMetaData> statuses = EHSMetaDataMgr.SelectMetaDataList("WORK_STATUS");
                    foreach (var s in statuses)
                    {
                        rddlw.Items.Add(new DropDownListItem(s.Text, s.Value));
                    }

                    if (!string.IsNullOrEmpty(rddlw.SelectedValue) && (rddlw.SelectedValue != ""))
                    {
                        item.WORK_STATUS = rddlw.SelectedValue;
                    }

                    if (sequence != delId)
                    {
                        item.ITEM_DESCRIPTION = tbr.Text;
                        item.BEGIN_DT         = bd.SelectedDate;
                        //item.RETURN_TOWORK_DT = rd.SelectedDate;
                        item.NEXT_MEDAPPT_DT    = md.SelectedDate;
                        item.RETURN_EXPECTED_DT = ed.SelectedDate;
                        itemList.Add(item);
                    }
                }

                rptLostTime.DataSource = itemList;
                rptLostTime.DataBind();

                decimal incidentId = (IsEditContext) ? IncidentId : NewIncidentId;
                SaveLostTime(incidentId, itemList);

                if (LostTimeUpdateEvent != null)
                {
                    LostTimeUpdateEvent("AddOrDelete");
                }
            }
        }
        public void LoadProfileInputHdr(bool loadPlants, DateTime dateFrom, DateTime dateTo, decimal defaultPlantID, bool hideUndefined, bool showExpanded)
        {
            ToggleVisible(pnlProfileInputHdr);

            if (loadPlants && ddlPlantSelect.Items.Count == 0)
            {
                List <BusinessLocation> locationList = SQMModelMgr.SelectBusinessLocationList(SessionManager.UserContext.HRLocation.Company.COMPANY_ID, 0, true).Where(l => l.Plant.TRACK_EW_DATA == true).ToList();
                locationList = UserContext.FilterPlantAccessList(locationList);

                if (locationList.Count > 1 && showExpanded && locationList.Select(l => l.Plant.BUS_ORG_ID).Distinct().Count() > 1)
                {
                    ddlPlantSelect.Visible = false;
                    tdLocation.Visible     = false;
                    mnuPlantSelect.Visible = true;
                    SQMBasePage.SetLocationList(mnuPlantSelect, locationList, 0, "select a location...", "TOP", false);

                    int           undefinedCount = 0;
                    List <string> profileList    = EHSModel.SelectPlantProfileList(SessionManager.UserContext.HRLocation.Company.COMPANY_ID).Select(l => l.PLANT_ID.ToString()).ToList();
                    RadMenuItem   miTop          = mnuPlantSelect.Items[0];
                    foreach (RadMenuItem miBU in miTop.Items)
                    {
                        foreach (RadMenuItem miLoc in miBU.Items)
                        {
                            if (!profileList.Contains(miLoc.Value))
                            {
                                ++undefinedCount;
                                miLoc.ImageUrl = "~/images/defaulticon/16x16/grid-dot.png";
                                miLoc.CssClass = "rcbItemEmphasis";
                                if (hideUndefined)
                                {
                                    miLoc.Visible = false;
                                }
                            }
                        }
                    }
                    if (mnuPlantSelect.FindItemByValue(defaultPlantID.ToString()) != null)
                    {
                        mnuPlantSelect.FindItemByValue(defaultPlantID.ToString()).Selected = true;
                        LocationSelect_Click(mnuPlantSelect, null);
                    }
                }
                else
                {
                    ddlPlantSelect.Visible = true;
                    mnuPlantSelect.Visible = false;
                    SQMBasePage.SetLocationList(ddlPlantSelect, locationList, 0);
                    if (ddlPlantSelect.Items.Count == 1)
                    {
                        tdLocationSelect.Visible = false;
                        tdLocation.Visible       = true;
                        lblPlantName_out.Text    = ddlPlantSelect.SelectedItem.Text;
                        LocationSelect_Click(ddlPlantSelect, null);
                    }
                    else
                    {
                        List <string> profileList    = EHSModel.SelectPlantProfileList(SessionManager.UserContext.HRLocation.Company.COMPANY_ID).Select(l => l.PLANT_ID.ToString()).ToList();
                        int           undefinedCount = 0;
                        foreach (RadComboBoxItem item in ddlPlantSelect.Items)
                        {
                            if (!item.IsSeparator && !profileList.Contains(item.Value))
                            {
                                ++undefinedCount;
                                //item.ImageUrl = "~/images/defaulticon/16x16/grid-dot.png";
                                item.CssClass = "rcbItemEmphasis";
                                item.ToolTip  = "Metrics not defined";
                                if (hideUndefined)
                                {
                                    item.Visible = false;
                                }
                                else
                                {
                                    item.Enabled = false;
                                }
                            }
                        }
                        if (undefinedCount > 0 && !hideUndefined)
                        {
                            ddlPlantSelect.ToolTip += hfPlantProfileUndefined.Value;
                        }

                        tdLocationSelect.Visible = true;
                        tdLocation.Visible       = false;
                        if (ddlPlantSelect.FindItemByValue(defaultPlantID.ToString()) != null)
                        {
                            ddlPlantSelect.SelectedValue = defaultPlantID.ToString();
                            LocationSelect_Click(ddlPlantSelect, null);
                        }
                        else
                        {
                            LocationSelect_Click(ddlPlantSelect, null);
                        }
                    }
                }
            }

            if (dateFrom > DateTime.MinValue)
            {
                radPeriodSelect.Visible = true;
                // radPeriodSelect.Culture = System.Threading.Thread.CurrentThread.CurrentUICulture;
                radPeriodSelect.MinDate          = dateFrom;
                radPeriodSelect.MaxDate          = dateTo;
                radPeriodSelect.ShowPopupOnFocus = true;
                if (dateFrom == dateTo)
                {
                    radPeriodSelect.SelectedDate = dateFrom;
                    radPeriodSelect.Enabled      = false;
                }
                else
                {
                    radPeriodSelect.SelectedDate = DateTime.Now;
                }

                radPeriodSelect.Culture = System.Threading.Thread.CurrentThread.CurrentUICulture;
                tdPeriod.Visible        = false;
                tdPeriodSelect.Visible  = true;
            }
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            decimal issueID = 0;

            if (!Page.IsPostBack)
            {
                //string appContext;
                if (!string.IsNullOrEmpty(Request.QueryString["c"]))
                {
                    appContext = Request.QueryString["c"];
                }
                else
                {
                    appContext = "RCV";
                }

                if (!string.IsNullOrEmpty(Request.QueryString["i"]))
                {
                    try
                    {
                        issueID = Convert.ToDecimal(EncryptionManager.Decrypt(Request.QueryString["i"]));
                    }
                    catch { }
                }

                SetIssueCtl(new QualityIssueCtl().Initialize(null, appContext));

                if (SessionManager.EffLocation.BusinessOrg == null)
                {
                    SessionManager.EffLocation = SessionManager.UserContext.WorkingLocation;
                }
                if (uclIssueSearch.DDLPlantSelect.Items.Count == 0)
                {
                    List <BusinessLocation> locationList = SQMModelMgr.SelectBusinessLocationList(SessionManager.UserContext.HRLocation.Company.COMPANY_ID, 0, true);
                    SQMBasePage.SetLocationList(uclIssueSearch.DDLPlantSelect, UserContext.FilterPlantAccessList(locationList), -1);
                }

                PERSPECTIVE_VIEW view = ViewModel.LookupView(entities, appContext, appContext, 0);
                if (view != null)
                {
                    ddlChartType.Items.Clear();
                    ddlChartType.Items.Add(new RadComboBoxItem("", ""));
                    foreach (PERSPECTIVE_VIEW_ITEM vi in view.PERSPECTIVE_VIEW_ITEM.Where(l => l.STATUS != "I").OrderBy(l => l.ITEM_SEQ).ToList())
                    {
                        RadComboBoxItem item = new RadComboBoxItem();
                        item.Text     = vi.TITLE;
                        item.Value    = vi.ITEM_SEQ.ToString();
                        item.ImageUrl = ViewModel.GetViewItemImageURL(vi);
                        ddlChartType.Items.Add(item);
                    }
                }

                pnlChartSection.Style.Add("display", "none");
                lblChartType.Visible = ddlChartType.Visible = false;

                uclSearchBar_OnListClick();  // display list options upon page entry
            }

            switch (IssueCtl().Context)
            {
            case "CST":
                uclSearchBar1.PageTitle.Text    = lblQICSTTitle.Text;
                uclSearchBar1.NewButton.ToolTip = "Create a new " + lblQICSTTitle.Text;
                foreach (RadComboBoxItem ci in ddlChartType.Items)
                {
                    if (ci.Value.Contains("RCV"))
                    {
                        ci.Visible = false;
                    }
                }
                break;

            case "RCV":
                uclSearchBar1.PageTitle.Text    = lblQIRCVTitle.Text;
                uclSearchBar1.NewButton.ToolTip = "Create a new " + lblQIRCVTitle.Text;
                foreach (RadComboBoxItem ci in ddlChartType.Items)
                {
                    if (ci.Value.Contains("CST"))
                    {
                        ci.Visible = false;
                    }
                }
                break;

            default:
                uclSearchBar1.PageTitle.Text = lblQIPRQTitle.Text;
                break;
            }

            if (issueID > 0)
            {
                OnIssue_Click(issueID);
            }
        }
Example #6
0
 public string[] DDLPlantSelectNames()
 {
     string[] plantSels = SQMBasePage.GetComboBoxCheckedItems(ddlPlantSelect).Select(i => i.Text).ToArray();
     return(plantSels);
 }
Example #7
0
        private int SaveInputs(decimal targetPrmrID, bool commitChanges)
        {
            int              status = 0;
            LinkButton       lnk;
            HiddenField      hf;
            TextBox          tbValue, tbCost, tbCredit;
            CheckBox         cbDelete;
            decimal          decimalValue;
            DateTime         dateValue;
            decimal          prmrID;
            bool             hasReqdInputs  = true;
            bool             hasSaveWarning = false;
            bool             hasSaveError   = false;
            EHSProfileStatus saveStatus     = EHSProfileStatus.Normal;

            try
            {
                foreach (RepeaterItem item in rptProfilePeriod.Items)
                {
                    lnk    = (LinkButton)item.FindControl("lnkMetricCD");
                    prmrID = Convert.ToDecimal(lnk.CommandArgument);
                    EHS_PROFILE_MEASURE metric = LocalProfile().GetMeasure((decimal)prmrID);

                    if (prmrID == targetPrmrID || commitChanges)
                    {
                        Repeater rpt      = (Repeater)item.FindControl("rptProfileInput");
                        int      numInput = 0;
                        foreach (RepeaterItem inputItem in rpt.Items)
                        {
                            hf = (HiddenField)inputItem.FindControl("hfInputDate");
                            EHS_PROFILE_INPUT input = LocalProfile().InputPeriod.GetPeriodInput(prmrID, Convert.ToDateTime(hf.Value));
                            if (input != null)
                            {
                                RadDatePicker dtpFrom = (RadDatePicker)inputItem.FindControl("radDateFrom");
                                RadDatePicker dtpTo   = (RadDatePicker)inputItem.FindControl("radDateTo");
                                tbValue  = (TextBox)inputItem.FindControl("tbMetricValue");
                                tbCost   = (TextBox)inputItem.FindControl("tbMetricCost");
                                tbCredit = (TextBox)inputItem.FindControl("tbMetricCredit");
                                cbDelete = (CheckBox)inputItem.FindControl("cbDelete");
                                hf       = (HiddenField)inputItem.FindControl("hfStatus");
                                Control tr = new Control();

                                EHSProfileStatus inputStatus = EHSProfileStatus.Normal;
                                switch (metric.EHS_MEASURE.MEASURE_CATEGORY)
                                {
                                case "PROD":
                                case "SAFE":
                                case "FACT":
                                    if (dtpFrom.SelectedDate == null || dtpTo.SelectedDate == null)
                                    {
                                        inputStatus = EHSProfileStatus.Incomplete;
                                    }
                                    else if (string.IsNullOrEmpty(tbValue.Text.Trim()))
                                    {
                                        inputStatus = EHSProfileStatus.NoInputs;
                                    }
                                    break;

                                default:
                                    if (string.IsNullOrEmpty(tbValue.Text.Trim()))
                                    {
                                        if (string.IsNullOrEmpty(tbCost.Text.Trim() + tbCredit.Text.Trim()))
                                        {
                                            inputStatus = EHSProfileStatus.NoInputs;
                                        }
                                        else
                                        {
                                            inputStatus = EHSProfileStatus.Incomplete;
                                        }
                                    }
                                    else if (string.IsNullOrEmpty(tbCost.Text.Trim() + tbCredit.Text.Trim()))
                                    {
                                        inputStatus = EHSProfileStatus.Incomplete;
                                    }
                                    else if (dtpFrom.SelectedDate == null || dtpTo.SelectedDate == null)
                                    {
                                        inputStatus = EHSProfileStatus.Incomplete;
                                    }

                                    if (metric.EHS_PROFILE_MEASURE_EXT != null && (metric.EHS_PROFILE_MEASURE_EXT.VALUE_DEFAULT.HasValue || metric.EHS_PROFILE_MEASURE_EXT.COST_DEFAULT.HasValue))
                                    {
                                        if (inputStatus == EHSProfileStatus.Incomplete && (dtpFrom.SelectedDate == null || dtpTo.SelectedDate == null))
                                        {
                                            inputStatus = EHSProfileStatus.NoInputs;
                                        }
                                    }

                                    break;
                                }

                                if (inputStatus == EHSProfileStatus.NoInputs)
                                {
                                    LocalProfile().InputPeriod.DeletePeriodInput(input);
                                }
                                else if (inputStatus == EHSProfileStatus.Incomplete)
                                {
                                    hasSaveError = true;
                                    saveStatus   = EHSProfileStatus.Incomplete;
                                    dtpFrom.DateInput.Style.Add("BACKGROUND-COLOR", "LIGHTCORAL");
                                    dtpTo.DateInput.Style.Add("BACKGROUND-COLOR", "LIGHTCORAL");
                                    tbValue.Style.Add("BACKGROUND-COLOR", "LIGHTCORAL");
                                    if (tbCost.Enabled)
                                    {
                                        tbCost.Style.Add("BACKGROUND-COLOR", "LIGHTCORAL");
                                    }
                                    if (tbCredit.Enabled)
                                    {
                                        tbCredit.Style.Add("BACKGROUND-COLOR", "LIGHTCORAL");
                                    }
                                }

                                //if ((string.IsNullOrEmpty(tbValue.Text) || dtpFrom.SelectedDate == null || dtpTo.SelectedDate == null) || (string.IsNullOrEmpty(tbCost.Text + tbCredit.Text) && metric.EHS_MEASURE.MEASURE_CATEGORY != "PROD" && metric.EHS_MEASURE.MEASURE_CATEGORY != "SAFE" && metric.EHS_MEASURE.MEASURE_CATEGORY != "FACT"))
                                //{
                                //    LocalProfile().InputPeriod.DeletePeriodInput(input);
                                //}
                                else
                                {
                                    ++numInput;

                                    if (cbDelete.Checked)
                                    {
                                        input.STATUS = "D";
                                    }
                                    else if (input.STATUS == "D")
                                    {
                                        input.STATUS = "A";
                                    }

                                    if (input.EFF_FROM_DT > DateTime.MinValue || input.EFF_FROM_DT != dtpFrom.SelectedDate)
                                    {
                                        input.EFF_FROM_DT = (DateTime)dtpFrom.SelectedDate;
                                    }

                                    if (input.EFF_TO_DT > DateTime.MinValue || input.EFF_TO_DT != dtpTo.SelectedDate)
                                    {
                                        input.EFF_TO_DT = (DateTime)dtpTo.SelectedDate;
                                    }

                                    if (SQMBasePage.ParseToDecimal(tbValue.Text, out decimalValue))
                                    {
                                        if (input.MEASURE_VALUE != decimalValue)
                                        {
                                            input.MEASURE_VALUE = decimalValue;
                                        }
                                    }
                                    if (!string.IsNullOrEmpty(tbCredit.Text))
                                    {
                                        SQMBasePage.ParseToDecimal(tbCredit.Text, out decimalValue);
                                        decimalValue = Math.Abs(decimalValue) * -1;
                                        if (!input.MEASURE_COST.HasValue || input.MEASURE_COST != decimalValue)
                                        {
                                            input.MEASURE_COST = decimalValue;
                                        }
                                    }
                                    else
                                    {
                                        SQMBasePage.ParseToDecimal(tbCost.Text, out decimalValue);
                                        decimalValue = Math.Abs(decimalValue);
                                        if (!input.MEASURE_COST.HasValue || input.MEASURE_COST != decimalValue)
                                        {
                                            input.MEASURE_COST = decimalValue;
                                        }
                                    }

                                    if (commitChanges && metric.EHS_MEASURE.MEASURE_CATEGORY != "PROD" && metric.EHS_MEASURE.MEASURE_CATEGORY != "SAFE" && metric.EHS_MEASURE.MEASURE_CATEGORY != "FACT" && LocalProfile().CurrentStatus != EHSProfileStatus.OutOFRange)
                                    {
                                        if (!EHSModel.IsMeasureValueInRange(metric, (double)input.MEASURE_VALUE, 1.0))
                                        {
                                            hasSaveWarning = true;
                                            saveStatus     = EHSProfileStatus.OutOFRange;
                                            tbValue.Style.Add("BACKGROUND-COLOR", "CORNSILK");
                                        }
                                    }
                                }
                            }
                            if (metric != null && (bool)metric.IS_REQUIRED && numInput == 0)
                            {
                                hasReqdInputs = false;
                            }
                        }
                    }
                }

                if (commitChanges)
                {
                    if (hasSaveError)
                    {
                        MessageDisplay(saveStatus);
                        return(0);
                    }

                    if (hasSaveWarning)
                    {
                        MessageDisplay(saveStatus);
                        return(0);
                    }

                    // deleted inputs after approval
                    if ((!string.IsNullOrEmpty(hfNumDelete.Value) && hfNumDelete.Value != "0") && LocalProfile().InputPeriod.PlantAccounting.APPROVAL_DT.HasValue)
                    {
                        cbFinalApproval.Checked = false;
                    }
                    // changed inputs after approval
                    if ((!string.IsNullOrEmpty(hfNumChanged.Value) && hfNumChanged.Value != "0") && LocalProfile().InputPeriod.PlantAccounting.APPROVAL_DT.HasValue)
                    {
                        cbFinalApproval.Checked = false;
                    }

                    status = LocalProfile().UpdatePeriod(true, "", cbFinalApproval.Checked, SessionManager.UserContext.UserName());

                    if (status >= 0)
                    {
                        // option to finalize metrics
                        SETTINGS sets = SQMSettings.GetSetting("EHS", "INPUTFINALIZE");
                        if (sets != null)
                        {
                            bool     doRollup = false;
                            DateTime lastUpdateDate;
                            LocalProfile().PeriodStatus(new string[0] {
                            }, false, out lastUpdateDate);
                            switch (sets.VALUE.ToUpper())
                            {
                            case "ANY":         // finalize any inputs
                                doRollup = true;
                                break;

                            case "ANY_CURRENCY":           // finalize any inputs and if the exchange rate for the period exists
                                if (LocalProfile().InputPeriod.PeriodExchangeRate(LocalProfile().Plant) != null)
                                {
                                    doRollup = true;
                                }
                                break;

                            case "REQD":        // finalize only when all required inputs have been entered
                                if (LocalProfile().InputPeriod.IsRequiredComplete())
                                {
                                    doRollup = true;
                                }
                                break;

                            case "REQD_CURRENCY":           // finalize only when all required inputs are entered and exchange rate for the period exists
                                if (LocalProfile().InputPeriod.IsRequiredComplete() && LocalProfile().InputPeriod.PeriodExchangeRate(LocalProfile().Plant) != null)
                                {
                                    doRollup = true;
                                }
                                break;

                            default:
                                break;
                            }
                            if (doRollup && LocalProfile().ValidPeriod())
                            {
                                status = LocalProfile().UpdateMetricHistory(LocalProfile().InputPeriod.PeriodDate);  // new roll-up logic
                            }
                        }
                    }

                    if (status >= 0)
                    {
                        ScriptManager.RegisterStartupScript(this, GetType(), "showalert", "alertResult('hfAlertSaveSuccess');", true);
                        hasSaveWarning = false;  // cancel warning to allow re-save
                        MessageDisplay(0);
                        LoadProfileInput(LocalProfile().InputPeriod.PeriodDate, EHSProfileStatus.Normal);
                    }
                    else
                    {
                        ScriptManager.RegisterStartupScript(this, GetType(), "showalert", "alertResult('hfAlertSaveError');", true);
                        MessageDisplay(0);
                        ClearInput();
                    }
                }
            }
            catch (Exception ex)
            {
                //   SQMLogger.LogException(ex);
                status = -1;
            }

            BindSharedCalendars();

            return(status);
        }
        private void SetupPage()
        {
            if (ddlPlantSelect.Items.Count < 1)
            {
                List <XLAT> xlatList = SQMBasePage.SelectXLATList(new string[2] {
                    "STATUS_SELECT", "INCIDENT_SEVERITY"
                }, 1);
                List <BusinessLocation> locationList = SQMModelMgr.SelectBusinessLocationList(SessionManager.UserContext.HRLocation.Company.COMPANY_ID, 0, true);
                SQMBasePage.SetLocationList(ddlPlantSelect, UserContext.FilterPlantAccessList(locationList), 0);
                rcbStatusSelect = SQMBasePage.SetComboBoxItemsFromXLAT(rcbStatusSelect, xlatList.Where(l => l.XLAT_GROUP == "STATUS_SELECT" && new string[3] {
                    "", "A", "C"
                }.Contains(l.XLAT_CODE)).ToList(), "SHORT");
                rcbStatusSelect.SelectedValue = "A";
                rcbSeverity = SQMBasePage.SetComboBoxItemsFromXLAT(rcbSeverity, xlatList.Where(l => l.XLAT_GROUP == "INCIDENT_SEVERITY").OrderBy(l => l.SORT_ORDER).ToList(), "SHORT");
            }
            divIncidentList.Visible = true;
            pnlChartSection.Style.Add("display", "none");
            lblChartType.Visible = ddlChartType.Visible = false;

            //Bind data with severity level dropdown.
            var severityList = EHSIncidentMgr.PopulateSeverityLevel();

            rcbSeverityLevel = SQMBasePage.SetComboBoxItemsFromXLAT(rcbSeverityLevel, severityList, "SHORT");


            SQMBasePage.SetRadDateCulture(dmFromDate, "");
            SQMBasePage.SetRadDateCulture(dmToDate, "");

            dmFromDate.ShowPopupOnFocus = dmToDate.ShowPopupOnFocus = true;
            dmFromDate.SelectedDate     = SessionManager.UserContext.LocalTime.AddMonths(-11);
            dmToDate.SelectedDate       = SessionManager.UserContext.LocalTime;

            lblViewEHSRezTitle.Text  = GetLocalResourceObject("lblViewEHSRezTitleResource1.Text").ToString();
            lblPageInstructions.Text = GetLocalResourceObject("lblPageInstructionsResource1.Text").ToString();
            //lblStatus.Text = "Incident Status:";
            rbNew.Text = GetLocalResourceObject("rbNewResource1.Text").ToString();
            lblIncidentDate.Visible   = true;
            lblInspectionDate.Visible = false;
            phIncident.Visible        = true;

            SETTINGS sets = SQMSettings.GetSetting("EHS", "INCIDENTSEARCHFROM");

            if (sets != null)
            {
                try
                {
                    string[] args = sets.VALUE.Split('-');
                    if (args.Length > 1)
                    {
                        dmFromDate.SelectedDate = new DateTime(Convert.ToInt32(args[0]), Convert.ToInt32(args[1]), Convert.ToInt32(args[2]));
                    }
                    else
                    {
                        dmFromDate.SelectedDate = SessionManager.UserContext.LocalTime.AddMonths(Convert.ToInt32(args[0]) * -1);
                    }
                }
                catch { }
            }

            foreach (INCIDENT_TYPE ip in EHSIncidentMgr.SelectIncidentTypeList(SessionManager.PrimaryCompany().COMPANY_ID, SessionManager.UserContext.Language.NLS_LANGUAGE))
            {
                RadComboBoxItem item = new RadComboBoxItem(ip.TITLE, ip.INCIDENT_TYPE_ID.ToString());
                item.Checked = true;
                rcbIncidentType.Items.Add(item);
            }

            // lookup charts defined for this module & app context
            PERSPECTIVE_VIEW view = ViewModel.LookupView(entities, "HSIR", "HSIR", 0, SessionManager.UserContext.Language.NLS_LANGUAGE);

            if (view != null)
            {
                ddlChartType.Items.Clear();
                ddlChartType.Items.Add(new RadComboBoxItem("", ""));
                foreach (PERSPECTIVE_VIEW_ITEM vi in view.PERSPECTIVE_VIEW_ITEM.Where(l => l.STATUS != "I").OrderBy(l => l.ITEM_SEQ).ToList())
                {
                    RadComboBoxItem item = new RadComboBoxItem();
                    item.Text     = vi.TITLE;
                    item.Value    = vi.ITEM_SEQ.ToString();
                    item.ImageUrl = ViewModel.GetViewItemImageURL(vi);
                    ddlChartType.Items.Add(item);
                }
            }

            if (UserContext.GetMaxScopePrivilege(SysScope.incident) <= SysPriv.action)
            {
                uclExport.Visible = true;
            }
            else
            {
                uclExport.Visible = false;
            }
        }
        protected void ddlChartTypeChange(object sender, EventArgs e)
        {
            divChart.ViewStateMode = System.Web.UI.ViewStateMode.Disabled;
            if (ddlChartType.SelectedValue == "" || HSCalcs().ehsCtl.IncidentHst == null || HSCalcs().ehsCtl.IncidentHst.Count == 0)
            {
                pnlChartSection.Style.Add("display", "none");
                lnkChartClose.Visible = lnkPrint.Visible = false;
            }
            else
            {
                PERSPECTIVE_VIEW view = null;
                divChart.Controls.Clear();

                LOCAL_LANGUAGE lang = SQMModelMgr.LookupLanguage(entities, "", SessionManager.UserContext.Person.PREFERRED_LANG_ID.HasValue ? (int)SessionManager.UserContext.Person.PREFERRED_LANG_ID : 1, false);
                view = ViewModel.LookupView(entities, "HSIR", "HSIR", 0, lang.NLS_LANGUAGE);

                if (view != null)
                {
                    PERSPECTIVE_VIEW_ITEM vi = view.PERSPECTIVE_VIEW_ITEM.Where(i => i.ITEM_SEQ.ToString() == ddlChartType.SelectedValue).FirstOrDefault();
                    if (vi != null)
                    {
                        GaugeDefinition ggCfg = new GaugeDefinition().Initialize().ConfigureControl(vi, null, "", false, !string.IsNullOrEmpty(hfwidth.Value) ? Convert.ToInt32(hfwidth.Value) - 62 : 0, 0);
                        ggCfg.Position = null;
                        HSCalcs().ehsCtl.SetCalcParams(vi.CALCS_METHOD, vi.CALCS_SCOPE, vi.CALCS_STAT, (int)vi.SERIES_ORDER, vi.FILTER, vi.OPTIONS).IncidentSeries((EHSCalcsCtl.SeriesOrder)vi.SERIES_ORDER, SQMBasePage.GetComboBoxCheckedItems(ddlPlantSelect).Select(i => Convert.ToDecimal(i.Value)).ToArray(), new DateTime(1900, 1, 1), SessionManager.UserContext.LocalTime.AddYears(100), HSCalcs().ehsCtl.GetIncidentTopics());
                        uclChart.CreateControl((SQMChartType)vi.CONTROL_TYPE, ggCfg, HSCalcs().ehsCtl.Results, divChart);
                        pnlChartSection.Style.Add("display", "inline");
                        lnkChartClose.Visible = lnkPrint.Visible = true;
                        // return;
                    }
                }
            }
        }
Example #10
0
        public void rptTaskList_OnItemDataBound(object sender, RepeaterItemEventArgs e)
        {
            if (e.Item.ItemType == ListItemType.AlternatingItem || e.Item.ItemType == ListItemType.Item)
            {
                try
                {
                    TaskItem         item = (TaskItem)e.Item.DataItem;
                    Ucl_IncidentList ucl;
                    Ucl_EHSList      ecl;
                    LinkButton       lnk;
                    Label            lbl;
                    Image            img;
                    //TaskStatus status;
                    TaskRecordType taskType = (TaskRecordType)item.RecordType;
                    switch (taskType)
                    {
                    case TaskRecordType.QualityIssue:        // quality issue
                        lnk = (LinkButton)e.Item.FindControl("lnkTask");
                        if (!string.IsNullOrEmpty(item.Task.DESCRIPTION))
                        {
                            lnk.Text = item.Title + "<br>(" + item.Task.DESCRIPTION + ")";
                        }
                        else
                        {
                            lnk.Text = item.Title;
                        }

                        INCIDENT incident = (INCIDENT)item.Detail;
                        QI_OCCUR qiIssue  = (QI_OCCUR)item.Reference;
                        lnk.CommandArgument = item.RecordKey;
                        lbl          = (Label)e.Item.FindControl("lblDueDate");
                        lbl.Text     = SQMBasePage.FormatDate((DateTime)item.Task.DUE_DT, "d", false);
                        img          = (Image)e.Item.FindControl("imgTaskStatus");
                        img.ImageUrl = TaskMgr.TaskStatusImage(item.Taskstatus);
                        img.ToolTip  = item.Taskstatus.ToString();
                        QualityIncidentData issue = new QualityIncidentData();
                        issue.Incident         = incident;
                        issue.QIIssue          = qiIssue;
                        issue.Plant            = item.Plant;
                        issue.PlantResponsible = item.PlantResponsible;
                        issue.Person           = item.Person;
                        issue.Part             = item.Part;
                        List <QualityIncidentData> incidentList = new List <QualityIncidentData>();
                        ucl = (Ucl_IncidentList)e.Item.FindControl("uclIssueList");
                        ucl.LinksDisabled = true;
                        ucl.BindQualityIncidentHeader(issue, true);
                        break;

                    case TaskRecordType.ProblemCase:        // 8D problem case
                        lnk      = (LinkButton)e.Item.FindControl("lnkTask");
                        lnk.Text = item.Title;
                        PROB_CASE probCase = (PROB_CASE)item.Detail;
                        lnk.CommandArgument = item.RecordKey;
                        lbl          = (Label)e.Item.FindControl("lblDueDate");
                        lbl.Text     = SQMBasePage.FormatDate((DateTime)item.Task.DUE_DT, "d", false);
                        img          = (Image)e.Item.FindControl("imgTaskStatus");
                        img.ImageUrl = TaskMgr.TaskStatusImage(item.Taskstatus);
                        img.ToolTip  = item.Taskstatus.ToString();
                        ProblemCase theCase = new ProblemCase();
                        theCase.ProbCase = probCase;
                        theCase.SetAliasID();
                        ucl = (Ucl_IncidentList)e.Item.FindControl("uclIssueList");
                        ucl.LinksDisabled = true;
                        ucl.BindProblemCaseHeader(theCase, item);
                        break;

                    case TaskRecordType.ProfileInput:         // Profile inputs
                    case TaskRecordType.ProfileInputApproval: // approval
                    case TaskRecordType.ProfileInputFinalize: // finalize
                        lnk                 = (LinkButton)e.Item.FindControl("lnkTask");
                        lnk.Text            = item.Title;
                        lnk.CommandArgument = item.RecordKey;
                        lbl                 = (Label)e.Item.FindControl("lblDueDate");
                        lbl.Text            = SQMBasePage.FormatDate((DateTime)item.Task.DUE_DT, "d", false);
                        img                 = (Image)e.Item.FindControl("imgTaskStatus");
                        img.ImageUrl        = TaskMgr.TaskStatusImage(item.Taskstatus);
                        img.ToolTip         = item.Taskstatus.ToString();
                        ecl                 = (Ucl_EHSList)e.Item.FindControl("uclEHSPeriod");
                        ecl.BindProfilePeriodHdr(item);
                        break;

                    case TaskRecordType.HealthSafetyIncident:        // Health & safety incidents
                        lnk                 = (LinkButton)e.Item.FindControl("lnkTask");
                        lnk.Text            = item.Title;
                        lnk.CommandArgument = item.RecordKey;
                        lbl                 = (Label)e.Item.FindControl("lblDueDate");
                        lbl.Text            = SQMBasePage.FormatDate((DateTime)item.Task.DUE_DT, "d", false);
                        img                 = (Image)e.Item.FindControl("imgTaskStatus");
                        img.ImageUrl        = TaskMgr.TaskStatusImage(item.Taskstatus);
                        img.ToolTip         = item.Taskstatus.ToString();
                        INCIDENT EHSIncident = (INCIDENT)item.Detail;
                        ucl = (Ucl_IncidentList)e.Item.FindControl("uclIssueList");
                        ucl.LinksDisabled = true;
                        ucl.BindIncidentListHeader(EHSIncident, item);
                        break;

                    case TaskRecordType.PreventativeAction:       // preventative action
                        lnk                 = (LinkButton)e.Item.FindControl("lnkTask");
                        lnk.Text            = item.Title;
                        lnk.CommandArgument = item.RecordKey;
                        lbl                 = (Label)e.Item.FindControl("lblDueDate");
                        lbl.Text            = SQMBasePage.FormatDate((DateTime)item.Task.DUE_DT, "d", false);
                        img                 = (Image)e.Item.FindControl("imgTaskStatus");
                        img.ImageUrl        = TaskMgr.TaskStatusImage(item.Taskstatus);
                        img.ToolTip         = item.Taskstatus.ToString();
                        INCIDENT EHSAction = (INCIDENT)item.Detail;
                        ucl = (Ucl_IncidentList)e.Item.FindControl("uclIssueList");
                        ucl.LinksDisabled = true;
                        ucl.BindIncidentListHeader(EHSAction, item);
                        break;

                    default:
                        break;
                    }

                    if (item.Taskstatus == TaskStatus.EscalationLevel1 || item.Taskstatus == TaskStatus.EscalationLevel2)
                    {
                        if (UserContext.RoleAccess() < AccessMode.Admin)
                        {
                            lnk         = (LinkButton)e.Item.FindControl("lnkTask");
                            lbl         = (Label)e.Item.FindControl("lblTask");
                            lbl.Text    = lnk.Text;
                            lnk.Visible = false;
                            lbl.Visible = true;
                        }
                    }
                }
                catch (Exception ex)
                {
                }
            }
        }
        protected void BindTarget(PERSPECTIVE_TARGET target)
        {
            int n = -1;

            if (target != null)
            {
                if (!string.IsNullOrEmpty(target.CALCS_SCOPE))
                {
                    foreach (RadComboBoxItem item in ddlTarget.Items)
                    {
                        ++n;
                        string[] args = item.Value.Split('|');
                        if (!item.IsSeparator && args[0] == target.CALCS_SCOPE)
                        {
                            ddlTarget.SelectedIndex = n;
                            break;
                        }
                    }
                }

                tbTargetDescLong.Text = target.DESCR_LONG;
                if (ddlStatType.Items.FindByValue(target.SSTAT) != null)
                {
                    ddlStatType.SelectedValue = target.SSTAT;
                }
                if (target.EFF_YEAR > 0)
                {
                    ddlEffYear.SelectedValue = target.EFF_YEAR.ToString();
                }

                btnYTDMetric.Checked = btnYOYMetric.Checked = btnABSMetric.Checked = false;
                if (target.DATE_SPAN <= 0)
                {
                    btnABSMetric.Checked = true;
                }
                else if (target.DATE_SPAN == 1)
                {
                    btnYTDMetric.Checked = true;
                }
                else
                {
                    btnYOYMetric.Checked = true;
                }

                if (target.TARGET_VALUE.HasValue)
                {
                    tbTargetValue.Text = SQMBasePage.FormatValue((decimal)target.TARGET_VALUE, 4);
                }
                else
                {
                    tbTargetValue.Text = "";
                }

                btnTargetMin.Checked = btnTargetMax.Checked = false;
                if (target.MIN_MAX > 0)
                {
                    btnTargetMax.Checked = true;
                }
                else
                {
                    btnTargetMin.Checked = true;
                }

                ddlTargetStatus.SelectedValue = target.STATUS;
                pnlTargetEdit.Enabled         = true;
                btnTargetSave.Enabled         = btnTargetCancel.Enabled = true;

                udpTarget.Update();
            }
        }
 public void CancelIssue()
 {
     IssueCtl().Clear();
     SQMBasePage.ResetControlValues(divPageBody.Controls);
 }
        protected void DisplayIssue()
        {
            SetupPage();

            if (ddlIncidentType.Items.FindItemByValue(IssueCtl().qualityIssue.IssueOccur.QS_ACTIVITY) != null)
            {
                SQMBasePage.DisplayControlValue(ddlIncidentType, IssueCtl().qualityIssue.IssueOccur.QS_ACTIVITY, PageUseMode.ViewOnly, "");
                SelectActivityType(null, null);
                trQIActivity.Visible = false;

                switch (IssueCtl().qualityIssue.IssueOccur.QS_ACTIVITY)
                {
                case "CST":
                    trPartType.Visible = true;
                    ph8DRef.Visible    = true;      // external problem control system reference number
                    trReceipt.Visible  = false;
                    break;

                case "RCV":
                    trPartType.Visible = false;
                    ph8DRef.Visible    = false;
                    trReceipt.Visible  = true;     // reference receipt or po number
                    break;

                default:
                    trPartType.Visible = false;
                    ph8DRef.Visible    = false;
                    trReceipt.Visible  = false;
                    break;
                }
            }

            tbTotalEstNCQty.ReadOnly = true;

            QI_OCCUR_NC sample = IssueCtl().qualityIssue.IssueOccur.QI_OCCUR_ITEM.First().QI_OCCUR_NC.FirstOrDefault();

            if (sample != null)
            {
                if (IssueCtl().qualityIssue.IssueOccur.QI_OCCUR_ITEM.First().QI_OCCUR_NC.First().NONCONF_ID.HasValue)
                {
                    uclNC.Initialize(IssueCtl().qualityIssue.IssueOccur.QI_OCCUR_ITEM.First().QI_OCCUR_NC.First().PROBLEM_AREA,
                                     (decimal)IssueCtl().qualityIssue.IssueOccur.QI_OCCUR_ITEM.First().QI_OCCUR_NC.First().NONCONF_ID,
                                     (int)IssueCtl().qualityIssue.IssueOccur.QI_OCCUR_ITEM.First().QI_OCCUR_NC.First().PROBLEM_COUNT, IssueCtl().PageMode);
                }
                else
                {
                    uclNC.Initialize("", 0, 0, IssueCtl().PageMode);
                }

                gvMeasureGrid.DataSource = sample.QI_OCCUR_MEASURE;
                gvMeasureGrid.DataBind();
            }

            SetB2BLocation(Convert.ToDecimal(IssueCtl().qualityIssue.DetectedLocation.Plant.PLANT_ID.ToString()));
            if (ddlReportedLocation.Items.FindItemByValue(IssueCtl().qualityIssue.DetectedLocation.Plant.PLANT_ID.ToString()) != null)
            {
                SQMBasePage.DisplayControlValue(ddlReportedLocation, IssueCtl().qualityIssue.DetectedLocation.Plant.PLANT_ID.ToString(), IssueCtl().PageMode, "textStd");
            }
            else
            {
                // add the reported location in case the viewing user doesn't have it assigned to him
                BusinessLocation reportLoc = new BusinessLocation().Initialize(IssueCtl().qualityIssue.DetectedLocation.Plant.PLANT_ID);
                if (reportLoc != null)
                {
                    ddlReportedLocation.Items.Add(SQMBasePage.SetLocationItem(reportLoc, true));
                    SQMBasePage.DisplayControlValue(ddlReportedLocation, IssueCtl().qualityIssue.DetectedLocation.Plant.PLANT_ID.ToString(), IssueCtl().PageMode, "textStd");
                }
            }

            ddlResponsibleLocation.Items.Clear();
            if (IssueCtl().qualityIssue.Partdata.B2BList != null)
            {
                foreach (BusinessLocation loc in IssueCtl().qualityIssue.Partdata.B2BList)
                {
                    ddlResponsibleLocation.Items.Add(SQMBasePage.SetLocationItem(loc, true));
                }
                //  ddlResponsibleLocation.SelectedValue = qualityIssue.Incident.RESP_PLANT_ID.ToString();
                SQMBasePage.DisplayControlValue(ddlResponsibleLocation, IssueCtl().qualityIssue.Incident.RESP_PLANT_ID.ToString(), IssueCtl().PageMode, "textStd");
            }

            if (IssueCtl().qualityIssue.Partdata != null && IssueCtl().qualityIssue.Partdata.Part != null)
            {
                SQMBasePage.DisplayControlValue(uclPartSearch1.PartTextBox, IssueCtl().qualityIssue.Partdata.PartDisplayNum(IssueCtl().qualityIssue.IssueOccur.QS_ACTIVITY), IssueCtl().PageMode, "textStd");
                lblPartDesc.Text = IssueCtl().qualityIssue.Partdata.Part.PART_NAME;
                SQMBasePage.DisplayControlValue(tbRelatedParts, IssueCtl().qualityIssue.IssueOccur.RELATED_PARTS, IssueCtl().PageMode, "textStd");
            }

            ddlDisposition.SelectedIndex = ddlStatus.SelectedIndex = 0;

            if (IssueCtl().qualityIssue.IsNew)
            {
                cbNotify.Checked = true;
                cbNotify.Enabled = false;
                ddlResponseTime.SelectedIndex = 1;
            }
            else
            {
                cbNotify.Checked = false;
                cbNotify.Enabled = true;

                lblIssueDate_out.Text = SQMBasePage.FormatDate(WebSiteCommon.LocalTime((DateTime)IssueCtl().qualityIssue.Incident.CREATE_DT, SessionManager.UserContext.TimeZoneID), "d", false);

                SQMBasePage.DisplayControlValue(radIssueDate, IssueCtl().qualityIssue.Incident.INCIDENT_DT.ToShortDateString(), IssueCtl().PageMode, "textStd");

                SQMBasePage.DisplayControlValue(tbIssueDesc, IssueCtl().qualityIssue.Incident.DESCRIPTION, IssueCtl().PageMode, "textStd");

                lblOriginator_out.Text = IssueCtl().qualityIssue.Incident.CREATE_BY;
                SQMBasePage.DisplayControlValue(ddlIncidentSeverity2, IssueCtl().qualityIssue.IssueOccur.SEVERITY, IssueCtl().PageMode, "textStd");

                SQMBasePage.DisplayControlValue(tbReceipt, IssueCtl().qualityIssue.IssueOccur.QS_ACTIVITY == "RCV" ? IssueCtl().qualityIssue.IssueOccur.REF_OPERATION : "", IssueCtl().PageMode, "textStd");

                if (ddlPartType.Items.FindItemByValue(IssueCtl().qualityIssue.IssueOccur.PART_TYPE) != null)
                {
                    SQMBasePage.DisplayControlValue(ddlPartType, IssueCtl().qualityIssue.IssueOccur.PART_TYPE, IssueCtl().PageMode, "textStd");
                }

                SQMBasePage.DisplayControlValue(tbNCLotNum, IssueCtl().qualityIssue.IssueOccur.QI_OCCUR_ITEM.First().LOT_NUM, IssueCtl().PageMode, "textStd");

                try
                {
                    SQMBasePage.DisplayControlValue(tbNCTotalQty, IssueCtl().qualityIssue.IssueOccur.QI_OCCUR_ITEM.First().TOTAL_QTY.ToString(), IssueCtl().PageMode, "textStd");
                    SQMBasePage.DisplayControlValue(tbNCSampleQty, IssueCtl().qualityIssue.IssueOccur.QI_OCCUR_ITEM.First().INSPECT_QTY.ToString(), IssueCtl().PageMode, "textStd");
                    SQMBasePage.DisplayControlValue(tbNCNonConformQty, IssueCtl().qualityIssue.IssueOccur.QI_OCCUR_ITEM.First().INSPECT_NC_QTY.ToString(), IssueCtl().PageMode, "textStd");
                    SQMBasePage.DisplayControlValue(tbTotalEstNCQty, Math.Round((decimal)IssueCtl().qualityIssue.IssueOccur.QI_OCCUR_ITEM.First().TOTAL_NC_QTY, 1).ToString(), IssueCtl().PageMode, "labelEmphasis");
                    lnkCalculateNC.Visible = IssueCtl().PageMode == PageUseMode.EditEnabled ? true : false;
                    lblCalculateNC.Visible = IssueCtl().PageMode == PageUseMode.EditEnabled ? false : true;
                }
                catch
                {
                    tbNCTotalQty.Text = tbNCSampleQty.Text = tbNCNonConformQty.Text = tbTotalEstNCQty.Text = "";
                }

                SQMBasePage.DisplayControlValue(tbObservations, IssueCtl().qualityIssue.IssueOccur.QI_OCCUR_ITEM.First().QI_OCCUR_NC.First().SAMPLE_COMMENTS, IssueCtl().PageMode, "textStd");

                cb8DRequired.Checked = (bool)(IssueCtl().qualityIssue.IssueOccur.PROBCASE_REQD.HasValue == true ? IssueCtl().qualityIssue.IssueOccur.PROBCASE_REQD : false);
                if (IssueCtl().PageMode != PageUseMode.EditEnabled)
                {
                    cb8DRequired.Enabled = phNotify.Visible = false;
                }

                SQMBasePage.DisplayControlValue(tb8DRef, IssueCtl().qualityIssue.IssueOccur.QS_ACTIVITY == "CST" && !string.IsNullOrEmpty(IssueCtl().qualityIssue.IssueOccur.REF_OPERATION) ? IssueCtl().qualityIssue.IssueOccur.REF_OPERATION : "", IssueCtl().PageMode, "refText");

                SQMBasePage.DisplayControlValue(ddlDisposition, IssueCtl().qualityIssue.IssueOccur.DISPOSITION, IssueCtl().PageMode, "textStd");

                if (IssueCtl().PageMode == PageUseMode.Active)
                {
                    if (ddlStatus.Items.FindItemByValue(IssueCtl().qualityIssue.IssueOccur.STATUS) != null)
                    {
                        ddlStatus.SelectedValue = IssueCtl().qualityIssue.IssueOccur.STATUS;
                    }
                }
                else
                {
                    SQMBasePage.DisplayControlValue(ddlStatus, IssueCtl().qualityIssue.IssueOccur.STATUS, IssueCtl().PageMode, "textStd");
                }

                if (ddlCurrency.Items.FindItemByValue(IssueCtl().qualityIssue.IssueOccur.CURRENCY_CODE) != null)
                {
                    SQMBasePage.DisplayControlValue(ddlCurrency, IssueCtl().qualityIssue.IssueOccur.CURRENCY_CODE, IssueCtl().PageMode, "textStd");
                }

                SQMBasePage.DisplayControlValue(tbActCost, IssueCtl().qualityIssue.IssueOccur.EST_ACT_COST.HasValue ? SQMBasePage.FormatValue((decimal)IssueCtl().qualityIssue.IssueOccur.EST_ACT_COST, 2) : "", IssueCtl().PageMode, "textStd");
                SQMBasePage.DisplayControlValue(tbActCostNote, IssueCtl().qualityIssue.IssueOccur.ACT_COST_COMMENT, IssueCtl().PageMode, "textStd");

                SQMBasePage.DisplayControlValue(tbPotCost, IssueCtl().qualityIssue.IssueOccur.EST_POT_COST.HasValue ? SQMBasePage.FormatValue((decimal)IssueCtl().qualityIssue.IssueOccur.EST_POT_COST, 2) : "", IssueCtl().PageMode, "textStd");
                SQMBasePage.DisplayControlValue(tbPotCostNote, IssueCtl().qualityIssue.IssueOccur.POT_COST_COMMENT, IssueCtl().PageMode, "textStd");

                if (IssueCtl().PageMode == PageUseMode.EditEnabled)
                {
                    uclRadAttach.SetReportOption(false);
                    uclRadAttach.GetUploadedFiles(20, IssueCtl().qualityIssue.Incident.INCIDENT_ID, "1");
                }
                else
                {
                    Ucl_Attach attch = (Ucl_Attach)Page.LoadControl("/Include/Ucl_Attach.ascx");
                    uclRadAttach.Parent.Controls.AddAt(uclRadAttach.Parent.Controls.IndexOf(uclRadAttach), attch);
                    attch.BindDisplayAttachments(20, IssueCtl().qualityIssue.Incident.INCIDENT_ID, "1", 0);
                    uclRadAttach.Visible = false;
                }

                btnDupIncident.Visible = IssueCtl().PageMode == PageUseMode.EditEnabled ? true : false;

                //uclQISearch1.Load(false);
                if (!string.IsNullOrEmpty(IssueCtl().qualityIssue.IssueOccur.RELATED_INCIDENTS))
                {
                    QualityIssue refIssue = new QualityIssue().Load(Convert.ToDecimal(IssueCtl().qualityIssue.IssueOccur.RELATED_INCIDENTS));
                    if (refIssue != null)
                    {
                        tbDupIssue.Text = IssueCtl().qualityIssue.IssueOccur.RELATED_INCIDENTS + " - " + refIssue.Incident.DESCRIPTION;
                    }
                }
                else
                {
                    tbDupIssue.Text = "";
                }

                // determine selectable list of responsible persons based on the trading partner locations
                GetResponsibleList();

                if (ddlResponseTime.Items.FindItemByValue(IssueCtl().qualityIssue.IssueOccur.INIT_ACTION) != null)
                {
                    SQMBasePage.DisplayControlValue(ddlResponseTime, IssueCtl().qualityIssue.IssueOccur.INIT_ACTION, IssueCtl().PageMode, "textStd");
                }

                // update the ddl based per selected persons in the task list
                foreach (TASK_STATUS task in IssueCtl().qualityIssue.TeamTask.TaskList)
                {
                    RadComboBoxItem resp = null;
                    if ((resp = ddlResponsible.FindItemByValue(task.RESPONSIBLE_ID.ToString())) != null)
                    {
                        resp.Checked = true;
                    }
                }
                if (IssueCtl().PageMode != PageUseMode.EditEnabled)
                {
                    SQMBasePage.DisplayControlValue(ddlResponsible, "", IssueCtl().PageMode, "textSTd");
                }

                //  btnPrintLabel.OnClientClick = "Popup('../Quality/QualityIssue_Label.aspx?issue=" + qualityIssue.IssueOccur.INCIDENT_ID.ToString() + "', 'newPage', 600, 450); return false;";
            }

            uclResponse.BindResponseList(IssueCtl().qualityIssue.TeamResponse.ResponseList, IssueCtl().PageMode == PageUseMode.EditEnabled || IssueCtl().PageMode == PageUseMode.EditPartial ? true : false, true);
            lblIssueResponseCount.Text = IssueCtl().qualityIssue.TeamResponse.ResponseList.Count.ToString();
            phResponseAlert.Visible    = IssueCtl().PageMode == PageUseMode.EditEnabled ? true : false;
        }
        protected void btnMetricSave_Click(object sender, EventArgs e)
        {
            bool success;
            bool measureChanged    = false;
            bool reqdError         = false;
            EHS_PROFILE_MEASURE pm = null;

            if (hfOper.Value == "add")
            {
                pm = new EHS_PROFILE_MEASURE();
                pm.EHS_PROFILE_MEASURE_EXT = new EHS_PROFILE_MEASURE_EXT();
            }
            else
            {
                pm = LocalProfile().Profile.EHS_PROFILE_MEASURE.FirstOrDefault(l => l.PRMR_ID == LocalProfile().CurrentProfileMeasure.PRMR_ID);
                if (pm.EHS_PROFILE_MEASURE_EXT == null)
                {
                    pm.EHS_PROFILE_MEASURE_EXT         = new EHS_PROFILE_MEASURE_EXT();
                    pm.EHS_PROFILE_MEASURE_EXT.PRMR_ID = pm.PRMR_ID;
                }
            }

            pm.PLANT_ID = LocalProfile().Profile.PLANT_ID;

            decimal measureID = 0;

            if (!string.IsNullOrEmpty(ddlMetricID.SelectedValue))
            {
                measureID = Convert.ToDecimal(WebSiteCommon.ParseItemValue(ddlMetricID.SelectedValue));
                if (pm.MEASURE_ID != measureID)
                {
                    measureChanged = true;
                }
            }

            pm.MEASURE_ID     = measureID;
            pm.MEASURE_PROMPT = tbMetricPrompt.Text;
            pm.REG_STATUS     = ddlMetricRegStatus.SelectedValue;
            pm.UN_CODE        = ddlMetricDisposalCode.SelectedValue;
            pm.WASTE_CODE     = tbWasteCode.Text;

            pm.DEFAULT_CURRENCY_CODE = ddlMetricCurrency.SelectedValue;
            if (ddlMetricResponsible.SelectedIndex > 0)
            {
                decimal personID = Convert.ToDecimal(ddlMetricResponsible.SelectedValue);
                if (personID != pm.RESPONSIBLE_ID)
                {
                    pm = LocalProfile().UpdateMeasureResponsible(pm, personID);
                }
                pm.RESPONSIBLE_ID = personID;
            }
            else
            {
                pm.RESPONSIBLE_ID = Convert.ToDecimal(null);
            }

            if (ddlMetricCost.SelectedValue == "CREDIT")
            {
                pm.NEG_VALUE_ALLOWED = true;
            }
            else
            {
                pm.NEG_VALUE_ALLOWED = false;
            }

            pm.STATUS = ddlMetricStatus.SelectedValue;

            pm.IS_REQUIRED = cbMetricRequired.Checked;

            decimal uomID = 0;

            if (ddlMetricCategory.SelectedValue == "FACT")
            {
                pm.DEFAULT_UOM = EHSModel.LookupEHSMeasure(new PSsqmEntities(), pm.MEASURE_ID, "").STD_UOM;
            }
            else
            {
                if (SQMBasePage.ParseToDecimal(WebSiteCommon.ParseItemValue(ddlMetricUOM.SelectedValue), out uomID))
                {
                    pm.DEFAULT_UOM = uomID;
                }

                decimal UOMFactor = 0;
                if (decimal.TryParse(tbUOMFactor.Text, out UOMFactor))
                {
                    pm.UOM_FACTOR = UOMFactor;
                }
                else
                {
                    pm.UOM_FACTOR = null;
                }
            }

            if (phMetricExt.Visible)
            {
                decimal decimalValue;
                if (SQMBasePage.ParseToDecimal(tbValueDflt.Text, out decimalValue))
                {
                    pm.EHS_PROFILE_MEASURE_EXT.VALUE_DEFAULT = decimalValue;
                }
                else
                {
                    pm.EHS_PROFILE_MEASURE_EXT.VALUE_DEFAULT = null;
                }

                if (SQMBasePage.ParseToDecimal(tbCostDflt.Text, out decimalValue))
                {
                    pm.EHS_PROFILE_MEASURE_EXT.COST_DEFAULT = decimalValue;
                }
                else
                {
                    pm.EHS_PROFILE_MEASURE_EXT.COST_DEFAULT = null;
                }

                if ((pm.EHS_PROFILE_MEASURE_EXT.VALUE_DEFAULT.HasValue || pm.EHS_PROFILE_MEASURE_EXT.COST_DEFAULT.HasValue))
                {
                    pm.EHS_PROFILE_MEASURE_EXT.OVERRIDE_ALLOWED = cbEnableOverride.Checked;
                }
                else
                {
                    pm.EHS_PROFILE_MEASURE_EXT.OVERRIDE_ALLOWED = false;
                }

                /*
                 * if ((pm.EHS_PROFILE_MEASURE_EXT.VALUE_DEFAULT.HasValue || pm.EHS_PROFILE_MEASURE_EXT.COST_DEFAULT.HasValue) && radEffEndDate.SelectedDate != null)
                 *  pm.EHS_PROFILE_MEASURE_EXT.EFF_END_DT = (DateTime)radEffEndDate.SelectedDate;
                 * else
                 *  pm.EHS_PROFILE_MEASURE_EXT.EFF_END_DT = null;
                 */
            }

            // validate

            switch (ddlMetricCategory.SelectedValue)
            {
            case "ENGY":
            case "EUTL":
                if (string.IsNullOrEmpty(ddlMetricCategory.SelectedValue) || string.IsNullOrEmpty(ddlMetricID.SelectedValue) || string.IsNullOrEmpty(ddlMetricUOM.SelectedValue) || string.IsNullOrEmpty(ddlMetricResponsible.SelectedValue))
                {
                    reqdError = true;
                }
                break;

            case "PROD":
            case "FACT":
                if (string.IsNullOrEmpty(ddlMetricCategory.SelectedValue) || string.IsNullOrEmpty(ddlMetricID.SelectedValue) || string.IsNullOrEmpty(ddlMetricResponsible.SelectedValue))
                {
                    reqdError = true;
                }
                break;

            case "SAFE":
                if (string.IsNullOrEmpty(ddlMetricCategory.SelectedValue) || string.IsNullOrEmpty(ddlMetricID.SelectedValue) || string.IsNullOrEmpty(ddlMetricResponsible.SelectedValue))
                {
                    reqdError = true;
                }
                break;

            default:
                if (string.IsNullOrEmpty(ddlMetricCategory.SelectedValue) || string.IsNullOrEmpty(ddlMetricID.SelectedValue) || string.IsNullOrEmpty(ddlMetricUOM.SelectedValue) || string.IsNullOrEmpty(ddlMetricResponsible.SelectedValue) ||
                    string.IsNullOrEmpty(ddlMetricDisposalCode.SelectedValue) || string.IsNullOrEmpty(ddlMetricRegStatus.SelectedValue))
                {
                    reqdError = true;
                }
                if (tbUOMFactor.Visible && string.IsNullOrEmpty(tbUOMFactor.Text))
                {
                    reqdError = true;
                }
                break;
            }
            if (reqdError)
            {
                BindProfileMeasure(pm);
                DisplayErrorMessage(hfErrRequiredInputs);
                return;
            }

            if (hfOper.Value == "add")  // add measure to list
            {
                pm = LocalProfile().AddMeasure(pm, Convert.ToDecimal(WebSiteCommon.ParseItemValue(ddlMetricID.SelectedValue)));
            }

            EHSProfile.UpdateProfile(LocalProfile());

            if (pm.STATUS == "D")
            {
                EHSProfile.DeleteProfileMeasure(LocalProfile(), pm.MEASURE_ID, true, true);
                measureChanged = true;
            }

            if (measureChanged)
            {
                SetLocalProfile(new EHSProfile().Load(LocalProfile().Plant.PLANT_ID, true, false));
            }

            btnMetricClear_Click(null, null);
            BindProfile(LocalProfile());
        }
Example #15
0
        private void SaveNotifyItem()
        {
            PSsqmEntities ctx          = new PSsqmEntities();
            NOTIFYACTION  notifyAction = null;
            bool          isNew        = false;

            if (string.IsNullOrEmpty(hfNotifyActionID.Value))              // add new item
            {
                notifyAction = new NOTIFYACTION();
                if (hfNotifyActionContext.Value == "plant")                  // plant level
                {
                    notifyAction.PLANT_ID = Convert.ToDecimal(hfNotifyActionBusLoc.Value);
                }
                else
                {                  // plant level
                    notifyAction.BUS_ORG_ID = Convert.ToDecimal(hfNotifyActionBusLoc.Value);
                }
                isNew = true;
            }
            else
            {
                notifyAction = SQMModelMgr.LookupNotifyAction(ctx, Convert.ToDecimal(hfNotifyActionID.Value));
            }

            notifyAction.NOTIFY_SCOPE  = ddlNotifyScope.SelectedValue;
            notifyAction.SCOPE_TASK    = ddlScopeTask.SelectedValue;
            notifyAction.TASK_STATUS   = ddlScopeStatus.SelectedValue;
            notifyAction.NOTIFY_TIMING = Convert.ToInt32(ddlScopeTiming.SelectedValue);
            notifyAction.NOTIFY_DIST   = "";
            foreach (string sv in SQMBasePage.GetComboBoxSelectedValues(ddlNotifyPrivGroup))
            {
                notifyAction.NOTIFY_DIST += (string.IsNullOrEmpty(notifyAction.NOTIFY_DIST) ? "" : ",") + sv;
            }

            if ((notifyAction = SQMModelMgr.UpdateNotifyAction(ctx, notifyAction)) != null)
            {
                if (isNew)
                {
                    if (OnNotifyActionCommand != null)
                    {
                        OnNotifyActionCommand("add");
                    }
                }
                else
                {
                    foreach (GridDataItem item in rgNotifyAction.Items)
                    {
                        LinkButton lnk = (LinkButton)item.FindControl("lnkNotifyItem");
                        if (lnk.CommandArgument == hfNotifyActionID.Value)
                        {
                            lnk.Text = XLATList.Where(x => x.XLAT_GROUP == "NOTIFY_SCOPE" && x.XLAT_CODE == notifyAction.NOTIFY_SCOPE).FirstOrDefault().DESCRIPTION_SHORT;

                            Label lbl = (Label)item.FindControl("lblScopeTask");
                            lbl.Text = XLATList.Where(x => x.XLAT_GROUP == "NOTIFY_SCOPE_TASK" && x.XLAT_CODE == notifyAction.SCOPE_TASK).FirstOrDefault().DESCRIPTION_SHORT;

                            lbl      = (Label)item.FindControl("lblScopeStatus");
                            lbl.Text = XLATList.Where(x => x.XLAT_GROUP == "NOTIFY_TASK_STATUS" && x.XLAT_CODE == notifyAction.TASK_STATUS).FirstOrDefault().DESCRIPTION_SHORT;

                            lbl      = (Label)item.FindControl("lblNotifyTiming");
                            lbl.Text = XLATList.Where(x => x.XLAT_GROUP == "NOTIFY_TIMING" && x.XLAT_CODE == notifyAction.NOTIFY_TIMING.ToString()).FirstOrDefault().DESCRIPTION_SHORT;

                            lbl      = (Label)item.FindControl("lblNotifyDist");
                            lbl.Text = notifyAction.NOTIFY_DIST;
                        }
                    }
                }
            }
        }
        private void SearchIncidents()
        {
            string selectedValue = "";

            // work-around for rad persistence manager being cleared upon re-build ??
            if (ddlPlantSelect.CheckedItems.Count == 0)
            {
                foreach (RadComboBoxItem item in ddlPlantSelect.Items)
                {
                    item.Checked = true;
                }
            }
            if (rcbIncidentType.CheckedItems.Count == 0)
            {
                foreach (RadComboBoxItem item in rcbIncidentType.Items)
                {
                    item.Checked = true;
                }
            }
            if (rcbStatusSelect.SelectedItem == null)
            {
                rcbStatusSelect.SelectedIndex = 0;
            }

            DateTime fromDate = Convert.ToDateTime(dmFromDate.SelectedDate);
            DateTime toDate   = Convert.ToDateTime(dmToDate.SelectedDate);

            if (toDate < fromDate)
            {
                return;
            }

            toDate = new DateTime(toDate.Year, toDate.Month, toDate.Day, 23, 59, 59);

            List <decimal> plantIDS = SQMBasePage.GetComboBoxCheckedItems(ddlPlantSelect).Select(i => Convert.ToDecimal(i.Value)).ToList();

            var           typeList            = new List <decimal>();
            List <string> severityList        = new List <string>();
            List <string> selectSeverityLevel = new List <string>();
            decimal       incidentID;

            if (HSCalcs() == null)
            {
                foreach (RadComboBoxItem item in rcbIncidentType.Items)
                {
                    item.Checked = true;
                }
            }
            typeList = rcbIncidentType.Items.Where(c => c.Checked).Select(c => Convert.ToDecimal(c.Value)).ToList();
            if (typeList.Contains((decimal)EHSIncidentTypeId.InjuryIllness))
            {
                severityList = rcbSeverity.Items.Where(c => c.Checked).Select(c => c.Value).ToList();
            }
            else
            {
                severityList.Clear();
                rcbSeverity.Items.ToList().ForEach(i => i.Checked = false);
            }
            //Get selected values of severity level filter dropdownlist.
            selectedValue       = rcbStatusSelect.SelectedValue;
            selectSeverityLevel = rcbSeverityLevel.Items.Where(c => c.Checked).Select(c => c.Value).ToList();

            string incidentid = RTXT_IncidentID.Text;

            incidentID = Convert.ToDecimal(incidentid == "" ?"0" : incidentid);

            SetHSCalcs(new SQMMetricMgr().CreateNew(SessionManager.PrimaryCompany(), "0", fromDate, toDate, new decimal[0]));
            HSCalcs().ehsCtl = new EHSCalcsCtl().CreateNew(1, DateSpanOption.SelectRange, "0");
            HSCalcs().ObjAny = cbShowImage.Checked;

            HSCalcs().ehsCtl.SelectIncidentList(plantIDS, typeList, severityList, fromDate, toDate, selectedValue, selectSeverityLevel, cbShowImage.Checked, cbCreatedByMe.Checked ? SessionManager.UserContext.Person.PERSON_ID : 0, incidentID);

            if (!UserContext.CheckUserPrivilege(SysPriv.admin, SysScope.incident))
            {
                HSCalcs().ehsCtl.IncidentHst = (from i in HSCalcs().ehsCtl.IncidentHst where i.Incident.ISSUE_TYPE_ID != 10 select i).ToList();
            }

            if (HSCalcs().ehsCtl.IncidentHst != null)
            {
                uclIncidentList.BindIncidentListRepeater(HSCalcs().ehsCtl.IncidentHst.OrderByDescending(x => x.Incident.INCIDENT_DT).ToList(), "EHS", cbShowImage.Checked, false);
            }


            if (HSCalcs().ehsCtl.IncidentHst != null && HSCalcs().ehsCtl.IncidentHst.Count > 0)
            {
                lblChartType.Visible = ddlChartType.Visible = true;
            }

            pnlIncidentDetails.Visible = lnkIncidentDetailsClose.Visible = false;

            if (ddlChartType.SelectedValue != "")
            {
                lnkCloseChart(null, null);
            }
        }
Example #17
0
 public decimal[] DDLPlantSelectIDS()
 {
     string[] plantSels = SQMBasePage.GetComboBoxCheckedItems(ddlPlantSelect).Select(i => i.Value).ToArray();
     return(Array.ConvertAll(plantSels, new Converter <string, decimal>(decimal.Parse)));
 }
        protected void btnConversion_Click(object sender, EventArgs e)
        {
            int             status   = 0;
            INCIDENT_ANSWER answer   = null;
            List <XLAT>     xlatList = SQMBasePage.SelectXLATList(new string[6] {
                "SHIFT", "INJURY_CAUSE", "INJURY_TYPE", "INJURY_PART", "INJURY_TENURE", "IQ_10"
            });

            foreach (EHSIncidentData eda in HSCalcs().ehsCtl.IncidentHst.Where(i => i.Incident.INCFORM_LAST_STEP_COMPLETED < 1 && i.Incident.INCIDENT_ID > 0))
            {
                INCIDENT incident = (from i in entities.INCIDENT where i.INCIDENT_ID == eda.Incident.INCIDENT_ID select i).SingleOrDefault();
                incident.INCIDENT_ANSWER.Load();

                // clear any prior conversion reecords
                string delCmd = " = " + incident.INCIDENT_ID.ToString();
                status = entities.ExecuteStoreCommand("DELETE FROM TASK_STATUS WHERE RECORD_TYPE = 40 AND RECORD_ID" + delCmd);
                status = entities.ExecuteStoreCommand("DELETE FROM INCFORM_LOSTTIME_HIST WHERE INCIDENT_ID" + delCmd);
                status = entities.ExecuteStoreCommand("DELETE FROM INCFORM_CONTAIN WHERE INCIDENT_ID" + delCmd);
                status = entities.ExecuteStoreCommand("DELETE FROM INCFORM_ACTION WHERE INCIDENT_ID" + delCmd);
                status = entities.ExecuteStoreCommand("DELETE FROM INCFORM_ROOT5Y WHERE INCIDENT_ID" + delCmd);
                status = entities.ExecuteStoreCommand("DELETE FROM INCFORM_CAUSATION WHERE INCIDENT_ID" + delCmd);
                status = entities.ExecuteStoreCommand("DELETE FROM INCFORM_APPROVAL WHERE INCIDENT_ID" + delCmd);
                status = entities.ExecuteStoreCommand("DELETE FROM INCFORM_WITNESS WHERE INCIDENT_ID" + delCmd);
                status = entities.ExecuteStoreCommand("DELETE FROM INCFORM_INJURYILLNESS WHERE INCIDENT_ID" + delCmd);

                EHSIncidentTypeId issueType = (EHSIncidentTypeId)incident.ISSUE_TYPE_ID;
                try
                {
                    switch (issueType)
                    {
                    case EHSIncidentTypeId.PropertyDamage:
                    case EHSIncidentTypeId.PowerOutage:
                    case EHSIncidentTypeId.Fire:
                    case EHSIncidentTypeId.Explosion:
                    case EHSIncidentTypeId.ImsAudit:
                    case EHSIncidentTypeId.RegulatoryContact:
                    case EHSIncidentTypeId.FireSystemImpairment:
                    case EHSIncidentTypeId.SpillRelease:
                    case EHSIncidentTypeId.EhsWalk:
                    case EHSIncidentTypeId.NearMiss:
                    case EHSIncidentTypeId.InjuryIllness:
                        incident.INCFORM_LAST_STEP_COMPLETED = 100;                                                  // assume new status
                        answer = incident.INCIDENT_ANSWER.Where(a => a.INCIDENT_QUESTION_ID == 69).FirstOrDefault(); // containment
                        if (answer != null && !string.IsNullOrEmpty(answer.ANSWER_VALUE))
                        {
                            incident.INCFORM_LAST_STEP_COMPLETED = 110;                                      // containment
                            INCFORM_CONTAIN contain = new INCFORM_CONTAIN();
                            contain.INCIDENT_ID        = incident.INCIDENT_ID;
                            contain.ITEM_SEQ           = 1;
                            contain.ITEM_DESCRIPTION   = answer.ANSWER_VALUE;
                            contain.ASSIGNED_PERSON_ID = incident.CREATE_PERSON;
                            contain.START_DATE         = contain.COMPLETION_DATE = incident.CREATE_DT;
                            contain.IsCompleted        = true;
                            contain.LAST_UPD_BY        = SessionManager.UserContext.UserName();
                            contain.LAST_UPD_DT        = DateTime.UtcNow;

                            entities.AddToINCFORM_CONTAIN(contain);
                        }

                        answer = incident.INCIDENT_ANSWER.Where(a => a.INCIDENT_QUESTION_ID == 24).FirstOrDefault();                                  // root cause
                        if (answer != null && !string.IsNullOrEmpty(answer.ANSWER_VALUE))
                        {
                            incident.INCFORM_LAST_STEP_COMPLETED = 120;                                      // root cause
                            INCFORM_ROOT5Y rootc = new INCFORM_ROOT5Y();
                            rootc.INCIDENT_ID      = incident.INCIDENT_ID;
                            rootc.ITEM_SEQ         = 1;
                            rootc.ITEM_DESCRIPTION = answer.ANSWER_VALUE;
                            rootc.LAST_UPD_BY      = SessionManager.UserContext.UserName();
                            rootc.LAST_UPD_DT      = DateTime.UtcNow;

                            entities.AddToINCFORM_ROOT5Y(rootc);
                        }

                        answer = incident.INCIDENT_ANSWER.Where(a => a.INCIDENT_QUESTION_ID == 78).FirstOrDefault();                                  // causation
                        if (answer != null && !string.IsNullOrEmpty(answer.ANSWER_VALUE))
                        {
                            incident.INCFORM_LAST_STEP_COMPLETED = 125;                                      // causation
                            INCFORM_CAUSATION cause = new INCFORM_CAUSATION();
                            cause.INCIDENT_ID   = incident.INCIDENT_ID;
                            cause.CAUSEATION_CD = xlatList.Where(l => l.XLAT_GROUP == "INJURY_CAUSE" && l.DESCRIPTION == answer.ANSWER_VALUE).FirstOrDefault() == null ? "1000" : xlatList.Where(l => l.XLAT_GROUP == "INJURY_CAUSE" && l.DESCRIPTION == answer.ANSWER_VALUE).FirstOrDefault().XLAT_CODE;
                            cause.LAST_UPD_BY   = SessionManager.UserContext.UserName();
                            cause.LAST_UPD_DT   = DateTime.UtcNow;

                            entities.AddToINCFORM_CAUSATION(cause);
                        }

                        answer = incident.INCIDENT_ANSWER.Where(a => a.INCIDENT_QUESTION_ID == 27).FirstOrDefault();                                  // corrective action
                        if (answer != null && !string.IsNullOrEmpty(answer.ANSWER_VALUE))
                        {
                            incident.INCFORM_LAST_STEP_COMPLETED = 130;                                      // corrective action
                            TASK_STATUS action = new TASK_STATUS();
                            action.RECORD_TYPE  = (int)TaskRecordType.HealthSafetyIncident;
                            action.RECORD_ID    = incident.INCIDENT_ID;
                            action.TASK_STEP    = ((int)SysPriv.action).ToString();
                            action.TASK_SEQ     = 0;
                            action.RECORD_SUBID = 0;
                            action.TASK_TYPE    = "T";
                            action.TASK_SEQ     = 0;
                            action.DESCRIPTION  = answer.ANSWER_VALUE;
                            action.DETAIL       = incident.DESCRIPTION;
                            action.STATUS       = "1";
                            action.CREATE_ID    = action.RESPONSIBLE_ID = action.COMPLETE_ID = incident.CREATE_PERSON;                                   // default action values
                            action.CREATE_DT    = action.DUE_DT = action.COMPLETE_DT = incident.CREATE_DT;
                            answer = incident.INCIDENT_ANSWER.Where(a => a.INCIDENT_QUESTION_ID == 79).FirstOrDefault();                                 // responsible
                            if (answer != null && !string.IsNullOrEmpty(answer.ANSWER_VALUE))
                            {
                                action.RESPONSIBLE_ID = action.COMPLETE_ID = decimal.Parse(answer.ANSWER_VALUE);
                            }
                            answer = incident.INCIDENT_ANSWER.Where(a => a.INCIDENT_QUESTION_ID == 65).FirstOrDefault();                                      // action due date
                            if (answer != null && !string.IsNullOrEmpty(answer.ANSWER_VALUE))
                            {
                                action.DUE_DT = DateTime.ParseExact(answer.ANSWER_VALUE, "M/d/yyyy hh:mm:ss tt", null);
                            }
                            answer = incident.INCIDENT_ANSWER.Where(a => a.INCIDENT_QUESTION_ID == 66).FirstOrDefault();                                      // action complete date
                            if (answer != null && !string.IsNullOrEmpty(answer.ANSWER_VALUE))
                            {
                                action.COMPLETE_DT = DateTime.ParseExact(answer.ANSWER_VALUE, "M/d/yyyy hh:mm:ss tt", null);
                            }
                            answer = incident.INCIDENT_ANSWER.Where(a => a.INCIDENT_QUESTION_ID == 70).FirstOrDefault();                                      // verification ?
                            if (answer != null && !string.IsNullOrEmpty(answer.ANSWER_VALUE))
                            {
                                action.COMMENTS = answer.ANSWER_VALUE;
                            }

                            entities.AddToTASK_STATUS(action);
                        }

                        if (incident.CLOSE_DATE_DATA_COMPLETE.HasValue || incident.CLOSE_DATE.HasValue)
                        {
                            incident.INCFORM_LAST_STEP_COMPLETED = 151;                                      // signoff
                            INCFORM_APPROVAL approval = new INCFORM_APPROVAL();
                            approval.INCIDENT_ID        = incident.INCIDENT_ID;
                            approval.ITEM_SEQ           = (int)SysPriv.approve1;
                            approval.APPROVAL_DATE      = incident.CLOSE_DATE.HasValue ? incident.CLOSE_DATE : incident.CLOSE_DATE_DATA_COMPLETE;
                            approval.IsAccepted         = true;
                            approval.APPROVER_PERSON_ID = incident.CLOSE_PERSON.HasValue ? incident.CLOSE_PERSON : incident.CREATE_PERSON;
                            PERSON person = (from p in entities.PERSON where p.PERSON_ID == approval.APPROVER_PERSON_ID select p).FirstOrDefault();
                            approval.APPROVAL_MESSAGE = approval.APPROVER_PERSON = (person.FIRST_NAME + " " + person.LAST_NAME);
                            answer = incident.INCIDENT_ANSWER.Where(a => a.INCIDENT_QUESTION_ID == 67).FirstOrDefault();                                      // completed by
                            if (answer != null && !string.IsNullOrEmpty(answer.ANSWER_VALUE))
                            {
                                approval.APPROVAL_MESSAGE = approval.APPROVER_PERSON = answer.ANSWER_VALUE;
                                string[] names = answer.ANSWER_VALUE.ToLower().Split(' ');
                                if (names.Length > 1)
                                {
                                    string firstName = names[0];
                                    string lastnamne = names[1];
                                    person = (from p in entities.PERSON where p.FIRST_NAME.ToLower() == firstName && p.LAST_NAME.ToLower() == lastnamne select p).FirstOrDefault();
                                }
                            }
                            if (person != null)
                            {
                                approval.APPROVER_PERSON_ID = person.PERSON_ID;
                                approval.APPROVER_TITLE     = person.JOB_TITLE;
                            }

                            entities.AddToINCFORM_APPROVAL(approval);
                        }

                        if (issueType == EHSIncidentTypeId.InjuryIllness)
                        {
                            INCFORM_INJURYILLNESS inRec   = new INCFORM_INJURYILLNESS();
                            INCFORM_WITNESS       witness = new INCFORM_WITNESS();
                            INCFORM_LOSTTIME_HIST hist    = new INCFORM_LOSTTIME_HIST();

                            inRec.INCIDENT_ID = incident.INCIDENT_ID;
                            answer            = incident.INCIDENT_ANSWER.Where(a => a.INCIDENT_QUESTION_ID == 6).FirstOrDefault();                          // shift

                            inRec.SHIFT = GetXLATCode(xlatList, "SHIFT", answer.ANSWER_VALUE);
                            answer      = incident.INCIDENT_ANSWER.Where(a => a.INCIDENT_QUESTION_ID == 7).FirstOrDefault();                                // department
                            if (answer != null && !string.IsNullOrEmpty(answer.ANSWER_VALUE))
                            {
                                inRec.DEPARTMENT = answer.ANSWER_VALUE;
                                DEPARTMENT dept = (from d in entities.DEPARTMENT where d.DEPT_NAME.ToLower() == answer.ANSWER_VALUE.ToLower() select d).SingleOrDefault();
                                if (dept != null)
                                {
                                    inRec.DEPT_ID = dept.DEPT_ID;
                                }
                            }
                            answer = incident.INCIDENT_ANSWER.Where(a => a.INCIDENT_QUESTION_ID == 8).FirstOrDefault();                                     // involved person
                            if (answer != null && !string.IsNullOrEmpty(answer.ANSWER_VALUE))
                            {
                                inRec.INVOLVED_PERSON_NAME = answer.ANSWER_VALUE;
                            }
                            answer = incident.INCIDENT_ANSWER.Where(a => a.INCIDENT_QUESTION_ID == 4).FirstOrDefault();                                     // supervisor inform date
                            if (answer != null && !string.IsNullOrEmpty(answer.ANSWER_VALUE))
                            {
                                inRec.SUPERVISOR_INFORMED_DT = DateTime.ParseExact(answer.ANSWER_VALUE, "M/d/yyyy hh:mm:ss tt", null);
                            }
                            answer = incident.INCIDENT_ANSWER.Where(a => a.INCIDENT_QUESTION_ID == 5).FirstOrDefault();                                     // time of incident
                            if (answer != null && !string.IsNullOrEmpty(answer.ANSWER_VALUE))
                            {
                                inRec.INCIDENT_TIME = TimeSpan.Parse(answer.ANSWER_VALUE);
                            }
                            answer = incident.INCIDENT_ANSWER.Where(a => a.INCIDENT_QUESTION_ID == 9).FirstOrDefault();                                     // witness
                            if (answer != null && !string.IsNullOrEmpty(answer.ANSWER_VALUE) && answer.ANSWER_VALUE.Split(' ').Length > 1)
                            {
                                witness.INCIDENT_ID  = incident.INCIDENT_ID;
                                witness.WITNESS_NO   = 1;
                                witness.WITNESS_NAME = answer.ANSWER_VALUE;
                                witness.LAST_UPD_BY  = SessionManager.UserContext.UserName();
                                witness.LAST_UPD_DT  = DateTime.UtcNow;

                                entities.AddToINCFORM_WITNESS(witness);
                            }
                            answer = incident.INCIDENT_ANSWER.Where(a => a.INCIDENT_QUESTION_ID == 10).FirstOrDefault();                                     // inside/outside
                            if (answer != null && !string.IsNullOrEmpty(answer.ANSWER_VALUE))
                            {
                                inRec.INSIDE_OUTSIDE_BLDNG = GetXLATCode(xlatList, "IQ_10", answer.ANSWER_VALUE);
                            }
                            answer = incident.INCIDENT_ANSWER.Where(a => a.INCIDENT_QUESTION_ID == 11).FirstOrDefault();                                     // weather
                            if (answer != null && !string.IsNullOrEmpty(answer.ANSWER_VALUE))
                            {
                                ;                                                                                        // NO FIELD
                            }
                            answer = incident.INCIDENT_ANSWER.Where(a => a.INCIDENT_QUESTION_ID == 12).FirstOrDefault(); // injury type
                            if (answer != null && !string.IsNullOrEmpty(answer.ANSWER_VALUE))
                            {
                                inRec.INJURY_TYPE = GetXLATCode(xlatList, "INJURY_TYPE", answer.ANSWER_VALUE);
                            }
                            answer = incident.INCIDENT_ANSWER.Where(a => a.INCIDENT_QUESTION_ID == 13).FirstOrDefault();                                     // body part
                            if (answer != null && !string.IsNullOrEmpty(answer.ANSWER_VALUE))
                            {
                                inRec.INJURY_BODY_PART = GetXLATCode(xlatList, "INJURY_PART", answer.ANSWER_VALUE);
                            }
                            answer = incident.INCIDENT_ANSWER.Where(a => a.INCIDENT_QUESTION_ID == 15).FirstOrDefault();                                     // reocurrance
                            if (answer != null && !string.IsNullOrEmpty(answer.ANSWER_VALUE))
                            {
                                inRec.REOCCUR = answer.ANSWER_VALUE.ToLower() == "yes" ? true : false;
                            }
                            answer = incident.INCIDENT_ANSWER.Where(a => a.INCIDENT_QUESTION_ID == 16).FirstOrDefault();                                     // first aid case
                            if (answer != null && !string.IsNullOrEmpty(answer.ANSWER_VALUE))
                            {
                                inRec.FIRST_AID = answer.ANSWER_VALUE.ToLower() == "yes" ? true : false;
                            }
                            answer = incident.INCIDENT_ANSWER.Where(a => a.INCIDENT_QUESTION_ID == 37).FirstOrDefault();                                     // employee
                            if (answer != null && !string.IsNullOrEmpty(answer.ANSWER_VALUE))
                            {
                                inRec.COMPANY_SUPERVISED = answer.ANSWER_VALUE.ToLower() == "yes" ? true : false;
                            }
                            answer = incident.INCIDENT_ANSWER.Where(a => a.INCIDENT_QUESTION_ID == 58).FirstOrDefault();                                     // specific description
                            if (answer != null && !string.IsNullOrEmpty(answer.ANSWER_VALUE))
                            {
                                inRec.DESCRIPTION_LOCAL = answer.ANSWER_VALUE;
                            }
                            answer = incident.INCIDENT_ANSWER.Where(a => a.INCIDENT_QUESTION_ID == 62).FirstOrDefault();                                     // recordable
                            if (answer != null && !string.IsNullOrEmpty(answer.ANSWER_VALUE))
                            {
                                inRec.RECORDABLE = answer.ANSWER_VALUE.ToLower() == "yes" ? true : false;
                            }
                            answer = incident.INCIDENT_ANSWER.Where(a => a.INCIDENT_QUESTION_ID == 63).FirstOrDefault();                                     // lost time case
                            if (answer != null && !string.IsNullOrEmpty(answer.ANSWER_VALUE))
                            {
                                inRec.LOST_TIME = answer.ANSWER_VALUE.ToLower() == "yes" ? true : false;
                                if (inRec.LOST_TIME)
                                {
                                    hist.INCIDENT_ID      = incident.INCIDENT_ID;
                                    hist.WORK_STATUS      = "03";
                                    hist.ITEM_DESCRIPTION = "Lost Time";
                                    hist.BEGIN_DT         = incident.INCIDENT_DT;
                                    answer = incident.INCIDENT_ANSWER.Where(a => a.INCIDENT_QUESTION_ID == 3).FirstOrDefault();                                             // expected return date
                                    if (answer != null && !string.IsNullOrEmpty(answer.ANSWER_VALUE))
                                    {
                                        hist.RETURN_EXPECTED_DT = DateTime.ParseExact(answer.ANSWER_VALUE, "M/d/yyyy hh:mm:ss tt", null);
                                    }
                                    answer = incident.INCIDENT_ANSWER.Where(a => a.INCIDENT_QUESTION_ID == 55).FirstOrDefault();                                             // actual return date
                                    if (answer != null && !string.IsNullOrEmpty(answer.ANSWER_VALUE))
                                    {
                                        hist.RETURN_TOWORK_DT = DateTime.ParseExact(answer.ANSWER_VALUE, "M/d/yyyy hh:mm:ss tt", null);
                                    }
                                    hist.LAST_UPD_BY = SessionManager.UserContext.UserName();
                                    hist.LAST_UPD_DT = DateTime.UtcNow;

                                    entities.AddToINCFORM_LOSTTIME_HIST(hist);
                                }
                            }
                            answer = incident.INCIDENT_ANSWER.Where(a => a.INCIDENT_QUESTION_ID == 74).FirstOrDefault();                                     // occupational event ?
                            if (answer != null && !string.IsNullOrEmpty(answer.ANSWER_VALUE))
                            {
                                inRec.STD_PROCS_FOLLOWED = answer.ANSWER_VALUE.ToLower() == "yes" ? true : false;                                          // map to std procedures ?
                            }

                            entities.AddToINCFORM_INJURYILLNESS(inRec);
                        }

                        status = entities.SaveChanges();

                        break;

                    case EHSIncidentTypeId.PreventativeAction:
                        break;

                    default:
                        break;
                    }
                }
                catch
                {
                    decimal id;
                    id = incident.INCIDENT_ID;
                }
            }
        }
Example #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 + ")";
                //}
            }
        }
        private void SetupPage()
        {
            if (ddlPlantSelect.Items.Count < 1)
            {
                List <BusinessLocation> locationList = SQMModelMgr.SelectBusinessLocationList(SessionManager.UserContext.HRLocation.Company.COMPANY_ID, 0, true);
                SQMBasePage.SetLocationList(ddlPlantSelect, UserContext.FilterPlantAccessList(locationList), 0);

                rcbStatusSelect.SelectedValue = "A";
            }
            divAuditList.Visible = true;

            dmFromDate.ShowPopupOnFocus = dmToDate.ShowPopupOnFocus = true;

            // we want the start date to be the previous week Monday
            // ABW 1/5/16 - use user's default plant local time for search default
            DateTime localTime = SessionManager.UserContext.LocalTime;
            int      dayofweek = (int)localTime.DayOfWeek;
            DateTime fromDate  = localTime.AddDays(-7);

            while ((int)(fromDate.DayOfWeek) > 1)
            {
                fromDate = fromDate.AddDays(-1);
            }
            // we want the end date to be the next week Monday (so we can see audits in progress)
            DateTime toDate = localTime;

            while ((int)(toDate.DayOfWeek) > 1)
            {
                toDate = toDate.AddDays(1);
            }

            dmFromDate.SelectedDate = fromDate;
            dmToDate.SelectedDate   = toDate;

            if (Mode == AuditMode.Audit)
            {
                //lblViewEHSRezTitle.Text = "Environmental Health &amp; Safety Assessment Exceptions";
                //lblPageInstructions.Text = "Review and update EH&amp;S Assessment Exceptions below.";
                //lblStatus.Text = "Assessment Status:";
                lblAuditDate.Visible = true;
                phAudit.Visible      = true;

                SETTINGS sets = SQMSettings.GetSetting("EHS", "AUDITEXCEPTIONSEARCHFROM");
                if (sets != null)
                {
                    try
                    {
                        string[] args = sets.VALUE.Split('-');
                        if (args.Length > 1)
                        {
                            dmFromDate.SelectedDate = new DateTime(Convert.ToInt32(args[0]), Convert.ToInt32(args[1]), Convert.ToInt32(args[2]));
                        }
                        else
                        {
                            dmFromDate.SelectedDate = SessionManager.UserContext.LocalTime.AddMonths(Convert.ToInt32(args[0]) * -1);
                        }
                    }
                    catch { }
                }

                if (rcbAuditType.Items.Count < 1)
                {
                    foreach (AUDIT_TYPE ip in EHSAuditMgr.SelectAuditTypeList(SessionManager.PrimaryCompany().COMPANY_ID, false))
                    {
                        RadComboBoxItem item = new RadComboBoxItem(ip.TITLE, ip.AUDIT_TYPE_ID.ToString());
                        item.Checked = true;
                        rcbAuditType.Items.Add(item);
                    }
                }
            }
        }
Example #21
0
        public void rptProfileInput_OnItemDataBound(object sender, RepeaterItemEventArgs e)
        {
            if (e.Item.ItemType == ListItemType.AlternatingItem || e.Item.ItemType == ListItemType.Item)
            {
                try
                {
                    EHS_PROFILE_INPUT   input  = (EHS_PROFILE_INPUT)e.Item.DataItem;
                    EHS_PROFILE_MEASURE metric = LocalProfile().GetMeasure((decimal)input.PRMR_ID);

                    Label      lbl;
                    LinkButton lnk;
                    //TextBox tb;
                    DropDownList ddl;

                    // bool enabled = input.STATUS == "C" ? false : true;
                    bool enabled = true;
                    sharedCalendar.Visible = true;

                    RadDatePicker dtp1 = (RadDatePicker)e.Item.FindControl("radDateFrom");
                    dtp1.SharedCalendar   = sharedCalendar;
                    dtp1.Enabled          = enabled;
                    dtp1.ShowPopupOnFocus = true;

                    RadDatePicker dtp2 = (RadDatePicker)e.Item.FindControl("radDateTo");
                    dtp2.SharedCalendar   = sharedCalendar;
                    dtp2.Enabled          = enabled;
                    dtp2.ShowPopupOnFocus = true;

                    SETTINGS sets       = SQMSettings.GetSetting("EHS", "INPUTSPAN");
                    int      inputspan  = 0;
                    int      monthSpan1 = Convert.ToInt32(WebSiteCommon.GetXlatValue("invoiceSpan", "MINDATE"));
                    int      monthSpan2 = monthSpan1;
                    if (sets != null && int.TryParse(sets.VALUE, out inputspan))
                    {
                        monthSpan2 = monthSpan1 = inputspan;
                    }
                    dtp1.MinDate = LocalProfile().InputPeriod.PeriodDate.AddMonths(monthSpan1 * -1);
                    dtp2.MinDate = LocalProfile().InputPeriod.PeriodDate.AddMonths(monthSpan2 * -1);

                    if (inputspan > 0)
                    {
                        dtp1.MaxDate = dtp2.MaxDate = LocalProfile().InputPeriod.PeriodDate.AddMonths(inputspan);
                    }
                    else
                    {
                        dtp1.MaxDate = dtp2.MaxDate = LocalProfile().InputPeriod.PeriodDate.AddMonths(Convert.ToInt32(WebSiteCommon.GetXlatValue("invoiceSpan", "MAXDATE")));
                    }

                    dtp1.Culture = System.Threading.Thread.CurrentThread.CurrentUICulture;
                    if (input != null)
                    {
                        if (input.STATUS == "N")
                        {
                            dtp1.Focus();
                        }
                        if (input.EFF_FROM_DT > DateTime.MinValue)
                        {
                            dtp1.SelectedDate = input.EFF_FROM_DT;
                        }
                        else
                        {
                            dtp1.FocusedDate = new DateTime(LocalProfile().InputPeriod.PeriodYear, LocalProfile().InputPeriod.PeriodMonth, 1);
                        }
                    }

                    dtp2.Culture = System.Threading.Thread.CurrentThread.CurrentUICulture;
                    if (input != null && input.EFF_TO_DT > DateTime.MinValue)
                    {
                        dtp2.SelectedDate = input.EFF_TO_DT;
                    }
                    else
                    {
                        dtp2.FocusedDate = new DateTime(LocalProfile().InputPeriod.PeriodYear, LocalProfile().InputPeriod.PeriodMonth, 1);
                    }


                    UOM uom = SessionManager.UOMList.FirstOrDefault(l => l.UOM_ID == input.UOM);
                    if (uom != null)
                    {
                        lbl      = (Label)e.Item.FindControl("lblMetricUOM");
                        lbl.Text = uom.UOM_CD;
                    }

                    lbl      = (Label)e.Item.FindControl("lblMetricCurrency");
                    lbl.Text = metric.DEFAULT_CURRENCY_CODE;

                    if (input != null)
                    {
                        lbl.Text = input.CURRENCY_CODE;
                    }

                    TextBox tbValue = (TextBox)e.Item.FindControl("tbMetricValue");
                    tbValue.Enabled = enabled;
                    if (input != null && (dtp1.SelectedDate != null && dtp2.SelectedDate != null))
                    {
                        //if (input != null && input.MEASURE_VALUE != null)
                        tbValue.Text = SQMBasePage.FormatValue((decimal)input.MEASURE_VALUE, 2);
                    }

                    TextBox tbCost   = (TextBox)e.Item.FindControl("tbMetricCost");
                    TextBox tbCredit = (TextBox)e.Item.FindControl("tbMetricCredit");

                    if ((bool)metric.NEG_VALUE_ALLOWED)
                    {
                        tbCredit.Visible = tbCredit.Enabled = enabled;
                        tbCost.Enabled   = false;
                    }
                    else
                    {
                        tbCredit.Visible = false;
                        tbCost.Enabled   = true;
                    }

                    if (input != null && input.MEASURE_COST.HasValue && input.MEASURE_COST < 0)
                    {
                        tbCredit.Text = SQMBasePage.FormatValue((decimal)input.MEASURE_COST * -1, 2);
                    }

                    if (input != null && input.MEASURE_COST.HasValue && input.MEASURE_COST >= 0)
                    {
                        tbCost.Text = SQMBasePage.FormatValue((decimal)input.MEASURE_COST, 2);
                    }

                    if (metric.EHS_MEASURE.MEASURE_CATEGORY == "PROD" || metric.EHS_MEASURE.MEASURE_CATEGORY == "SAFE" || metric.EHS_MEASURE.MEASURE_CATEGORY == "FACT")
                    {
                        dtp1.SelectedDate = new DateTime(LocalProfile().InputPeriod.PeriodYear, LocalProfile().InputPeriod.PeriodMonth, 1);
                        dtp1.Enabled      = false;
                        dtp2.SelectedDate = new DateTime(LocalProfile().InputPeriod.PeriodYear, LocalProfile().InputPeriod.PeriodMonth, DateTime.DaysInMonth(LocalProfile().InputPeriod.PeriodYear, LocalProfile().InputPeriod.PeriodMonth));
                        dtp2.Enabled      = false;
                        tbCost.Visible    = false;
                        tbCredit.Visible  = false;
                        lbl         = (Label)e.Item.FindControl("lblMetricCurrency");
                        lbl.Visible = false;
                    }

                    if (LocalProfile().GetMeasureExt(metric, DateTime.Now) != null && metric.EHS_PROFILE_MEASURE_EXT.VALUE_DEFAULT.HasValue)
                    {
                        tbValue.CssClass = "defaultText";
                        tbValue.ToolTip  = hfDefaultValue.Value + metric.EHS_PROFILE_MEASURE_EXT.NOTE;
                        tbValue.ReadOnly = metric.EHS_PROFILE_MEASURE_EXT.OVERRIDE_ALLOWED == true ? false : true;
                        if (string.IsNullOrEmpty(tbValue.Text))
                        {
                            tbValue.Text = SQMBasePage.FormatValue((decimal)metric.EHS_PROFILE_MEASURE_EXT.VALUE_DEFAULT, 2);
                        }
                    }
                    if (LocalProfile().GetMeasureExt(metric, DateTime.Now) != null && metric.EHS_PROFILE_MEASURE_EXT.COST_DEFAULT.HasValue)
                    {
                        tbCost.CssClass = "defaultText";
                        tbCost.ToolTip  = hfDefaultValue.Value + metric.EHS_PROFILE_MEASURE_EXT.NOTE;
                        tbCost.ReadOnly = metric.EHS_PROFILE_MEASURE_EXT.OVERRIDE_ALLOWED == true ? false : true;
                        if (string.IsNullOrEmpty(tbCost.Text))
                        {
                            tbCost.Text = SQMBasePage.FormatValue((decimal)metric.EHS_PROFILE_MEASURE_EXT.COST_DEFAULT, 2);
                        }
                    }

                    CheckBox cbDelete = (CheckBox)e.Item.FindControl("cbDelete");
                    //string cbId = "ctl00_ContentPlaceHolder_Body_rptProfilePeriod_ctl06_rptProfileInput_ctl01_cbDelete";
                    cbDelete.Attributes.Add("onClick", "CheckInputDelete('" + cbDelete.ClientID + "');");
                    if (input.STATUS == "A" || input.STATUS == "D")
                    {
                        cbDelete.Enabled = true;
                    }

                    if (input.STATUS == "D")
                    {
                        cbDelete.Checked  = true;
                        cbDelete.ToolTip  = hfDeleteText.Value;
                        hfNumDelete.Value = (Convert.ToInt32(hfNumDelete.Value) + 1).ToString();
                    }
                }
                catch (Exception ex)
                {
                    ;
                }
            }
        }
Example #22
0
        public void PopulateInitialForm(INCFORM_TYPE_CONTROL stepRecord)
        {
            PSsqmEntities entities = new PSsqmEntities();

            ApprovalStep = stepRecord;

            XLATList = SQMBasePage.SelectXLATList(new string[1] {
                "INCIDENT_APPROVALS"
            }, SessionManager.UserContext.Person.PREFERRED_LANG_ID.HasValue ? (int)SessionManager.UserContext.Person.PREFERRED_LANG_ID : 1);
            string incident = "";

            if (IncidentId > 0)
            {
                try
                {
                    LocalIncident = (from i in entities.INCIDENT where i.INCIDENT_ID == IncidentId select i).FirstOrDefault();
                    PLANT plant = SQMModelMgr.LookupPlant(entities, (decimal)LocalIncident.DETECT_PLANT_ID, "");
                    if (plant != null)
                    {
                        IncidentLocationTZ = plant.LOCAL_TIMEZONE;
                    }

                    //Get Issue type.
                    if (LocalIncident != null)
                    {
                        incident = LocalIncident.ISSUE_TYPE;
                    }
                    if (incident == null)
                    {
                        incident = "";
                    }
                    //To Display severity-level section only for Injury/Illness type incidents.
                    if (incident == "Injury/Illness")
                    {
                        if (status == 0)
                        {
                            pnlSeverityDescription.Visible = false;
                            pnlSeverity.Visible            = false;
                        }
                        else if (status == 1) //Display severity level and checkBox on Flash Report SignOff only.
                        {
                            pnlSeverity.Visible            = true;
                            pnlSeverityDescription.Visible = false;
                        }
                        else if (status == 2)//Display severity level with description on Investigation Report Signoff only.
                        {
                            pnlSeverity.Visible            = false;
                            pnlSeverityDescription.Visible = true;
                        }
                    }
                    //Get SEVERITY-LEVEL information from database, check related checkbox and display servity-level description.
                    string res = (from i in entities.INCFORM_APPROVAL where i.INCIDENT_ID == IncidentId select i.SEVERITY_LEVEL).FirstOrDefault();
                    if (res == null)
                    {
                        res = "";
                    }
                    else
                    {
                        chkSeverityLevel00.Enabled = false;

                        chkSeverityLevel01.Enabled = false;

                        chkSeverityLevel02.Enabled = false;

                        chkSeverityLevel03.Enabled = false;

                        chkSeverityLevel04.Enabled = false;
                    }
                    if (res == SysPriv.first_add.ToString())
                    {
                        chkSeverityLevel00.Checked       = true;
                        lblSeverityLevelDescription.Text = chkSeverityLevel00.Text;
                    }
                    else if (res == SysPriv.l1.ToString())
                    {
                        chkSeverityLevel01.Checked       = true;
                        lblSeverityLevelDescription.Text = chkSeverityLevel01.Text;
                    }
                    else if (res == SysPriv.l2.ToString())
                    {
                        chkSeverityLevel02.Checked       = true;
                        lblSeverityLevelDescription.Text = chkSeverityLevel02.Text;
                    }
                    else if (res == SysPriv.l3.ToString())
                    {
                        chkSeverityLevel03.Checked       = true;
                        lblSeverityLevelDescription.Text = chkSeverityLevel03.Text;
                    }
                    else if (res == SysPriv.l4.ToString())
                    {
                        chkSeverityLevel04.Checked       = true;
                        lblSeverityLevelDescription.Text = chkSeverityLevel04.Text;
                    }
                }
                catch (Exception ex) { string s = ex.Message; }
            }

            InitializeForm(entities);
        }
        public void LoadProfileSelectHdr(decimal companyID, decimal busOrgID, bool indicateUndefined, bool showExpanded)
        {
            ToggleVisible(pnlProfileSelectHdr);

            List <BusinessLocation> locationList = SQMModelMgr.SelectBusinessLocationList(companyID, busOrgID, true).Where(l => l.Plant.TRACK_EW_DATA == true).ToList();

            locationList = UserContext.FilterPlantAccessList(locationList);

            if (showExpanded && locationList.Select(l => l.Plant.BUS_ORG_ID).Distinct().Count() > 1)
            {
                ddlBusLocSelect.Visible = false;
                mnuBusLocSelect.Visible = true;
                SQMBasePage.SetLocationList(mnuBusLocSelect, locationList, 0, "select a location ...", "TOP", false);
                if (indicateUndefined)
                {
                    int           undefinedCount = 0;
                    List <string> profileList    = EHSModel.SelectPlantProfileList(companyID).Select(l => l.PLANT_ID.ToString()).ToList();
                    RadMenuItem   miTop          = mnuBusLocSelect.Items[0];
                    foreach (RadMenuItem miBU in miTop.Items)
                    {
                        foreach (RadMenuItem miLoc in miBU.Items)
                        {
                            if (!profileList.Contains(miLoc.Value))
                            {
                                ++undefinedCount;
                                // miLoc.ImageUrl = "~/images/defaulticon/16x16/grid-dot.png";
                                miLoc.CssClass = "rcbItemEmphasis";
                            }
                            else
                            {
                                miLoc.ImageUrl = "~/images/defaulticon/16x16/document.png";
                            }
                        }
                    }
                }
            }
            else
            {
                ddlBusLocSelect.Visible = true;
                mnuBusLocSelect.Visible = false;
                SQMBasePage.SetLocationList(ddlBusLocSelect, locationList, 0);
                if (indicateUndefined)
                {
                    int           undefinedCount = 0;
                    List <string> profileList    = EHSModel.SelectPlantProfileList(companyID).Select(l => l.PLANT_ID.ToString()).ToList();
                    foreach (RadComboBoxItem item in ddlBusLocSelect.Items)
                    {
                        if (!item.IsSeparator)
                        {
                            if (!profileList.Contains(item.Value))
                            {
                                ++undefinedCount;
                                item.ImageUrl = "~/images/defaulticon/16x16/blank.png";
                                item.CssClass = "rcbItemEmphasis";
                                item.ToolTip  = "Metrics not defined";
                            }
                            else
                            {
                                item.ImageUrl = "~/images/defaulticon/16x16/document.png";
                            }
                        }
                    }
                    if (undefinedCount > 0)
                    {
                        ddlBusLocSelect.ToolTip += hfBusLocProfileUndefined.Value;
                    }
                }
                ddlBusLocSelect.Items.Insert(0, new RadComboBoxItem("", ""));
            }
        }
        public int BindMeasure(EHS_MEASURE measure)
        {
            int status = 0;

            pnlMeasureEdit.Visible = true;
            DisplayErrorMessage(null);

            BindSubcategoryList(measure != null ? measure.MEASURE_CATEGORY : "");

            trMeasureEFMType.Visible        = false;
            phProdTableField.Visible        = phSafeTableField.Visible = phOutputUOM.Visible = false;
            ddlMeasureEFMType.SelectedIndex = ddlProdTableField.SelectedIndex = ddlSafeTableField.SelectedIndex = ddlOutputUOM.SelectedIndex = 0;

            if ((measure != null && measure.MEASURE_CATEGORY == "PROD") || ddlMeasureCategory.SelectedValue == "PROD")
            {
                phProdTableField.Visible = true;
            }
            else if ((measure != null && measure.MEASURE_CATEGORY == "SAFE") || ddlMeasureCategory.SelectedValue == "SAFE")
            {
                phSafeTableField.Visible = true;
            }
            else if ((measure != null && measure.MEASURE_CATEGORY == "FACT") || ddlMeasureCategory.SelectedValue == "FACT")
            {
                phOutputUOM.Visible = true;
            }
            else if ((measure != null && measure.MEASURE_CATEGORY == "ENGY") || ddlMeasureCategory.SelectedValue == "ENGY")
            {
                trMeasureEFMType.Visible = true;
            }

            winMeasureEdit.Title = hfAddMeasure.Value;

            if (measure != null)
            {
                winMeasureEdit.Title = hfUpdateMeasure.Value;
                tbMeasureCode.Text   = measure.MEASURE_CD;
                tbMeasureName.Text   = measure.MEASURE_NAME.Trim();
                tbMeasureDesc.Text   = measure.MEASURE_DESC.Trim();
                ddlMeasureSubcategory.SelectedValue = measure.MEASURE_SUBCATEGORY;
                SQMBasePage.SetStatusList(ddlMeasureStatus, measure.STATUS);

                ddlProdTableField.SelectedIndex = ddlSafeTableField.SelectedIndex = ddlOutputUOM.SelectedIndex = 0;

                if (!string.IsNullOrEmpty(measure.PLANT_ACCT_FIELD) && ddlProdTableField.Items.FindByValue(measure.PLANT_ACCT_FIELD) != null)
                {
                    ddlProdTableField.SelectedValue = measure.PLANT_ACCT_FIELD;
                }

                if (!string.IsNullOrEmpty(measure.PLANT_ACCT_FIELD) && ddlSafeTableField.Items.FindByValue(measure.PLANT_ACCT_FIELD) != null)
                {
                    ddlSafeTableField.SelectedValue = measure.PLANT_ACCT_FIELD;
                }

                if (measure.STD_UOM.HasValue && ddlOutputUOM.Items.FindByValue(measure.STD_UOM.ToString()) != null)
                {
                    ddlOutputUOM.SelectedValue = measure.STD_UOM.ToString();
                }

                if (ddlMeasureEFMType.Items.FindByValue(measure.EFM_TYPE) != null)
                {
                    ddlMeasureEFMType.SelectedValue = measure.EFM_TYPE;
                }
            }

            btnMeasureCancel.Enabled = btnMeasureSave.Enabled = true;

            string script = "function f(){OpenMeasureEditWindow(); Sys.Application.remove_load(f);}Sys.Application.add_load(f);";

            ScriptManager.RegisterStartupScript(Page, Page.GetType(), "key", script, true);

            return(status);
        }
Example #25
0
        public int MetricSeries(EHSCalcsCtl.SeriesOrder seriesOrder, decimal[] plantIDS, string targetScope)
        {
            int         status = 0;
            int         item   = 0;
            GaugeSeries series = null;

            this.Results.Initialize();
            PLANT plant = null;

            switch (seriesOrder)
            {
            case EHSCalcsCtl.SeriesOrder.PlantMeasure:
                int numYears   = this.ToDate.Year - this.FromDate.Year + 1;
                int numPeriods = ((this.ToDate.Year - this.FromDate.Year) * 12) + (this.ToDate.Month - this.FromDate.Month) + 1;
                foreach (decimal plantID in plantIDS)
                {
                    try
                    {
                        if (plantID > 0)
                        {
                            plant  = SQMModelMgr.LookupPlant(plantID);
                            series = new GaugeSeries().CreateNew(1, plant.PLANT_NAME, "");
                        }
                        else
                        {
                            series = new GaugeSeries().CreateNew(1, "overall", "");
                        }

                        for (int n = 0; n < numPeriods; n++)
                        {
                            DateTime thePeriod = this.FromDate.AddMonths(n);
                            if (TargetMetric(targetScope, new decimal[1] {
                                plantID
                            }, thePeriod) >= 0 && this.Results.ValidResult)
                            {
                                series.ItemList.Add(new GaugeSeriesItem().CreateNew(1, n + 1, 0, this.Results.Result, SQMBasePage.FormatDate(thePeriod, "yyyy/MM", false)));
                            }
                            else
                            {
                                series.ItemList.Add(new GaugeSeriesItem().CreateNew(1, n + 1, 0, 0, SQMBasePage.FormatDate(thePeriod, "yyyy/MM", false)));
                            }
                        }

                        this.Results.metricSeries.Add(series);
                    }
                    catch
                    {
                    }
                }
                break;

            default:
                series = new GaugeSeries().CreateNew(1, "", "");
                foreach (decimal plantID in plantIDS)
                {
                    plant = SQMModelMgr.LookupPlant(plantID);

                    if (TargetMetric(targetScope, new decimal[1] {
                        plantID
                    }, DateTime.MinValue) >= 0 && this.Results.ValidResult)
                    {
                        series.ItemList.Add(new GaugeSeriesItem().CreateNew(1, item++, 0, this.Results.Result, plant.PLANT_NAME));
                        series.Name = this.Results.Text;
                    }
                }
                this.Results.metricSeries.Add(series);
                break;
            }

            if (this.Results.metricSeries.Count > 0)
            {
                this.Results.ValidResult = true;
            }

            return(status);
        }
        protected void ddlReportList_Select(object sender, EventArgs e)
        {
            phBasicCriteria.Visible      = true;
            radExportDateSelect2.Enabled = true;
            divGHGReport.Visible         = divProfilePeriodScrollRepeater.Visible = divMetricHistory.Visible = divMetricHistory.Visible = phIncidentCriteria.Visible = divMetricsTimespan.Visible = false;

            radExportDateSelect1.MinDate          = new DateTime(2001, 1, 1);
            radExportDateSelect1.MaxDate          = DateTime.Now.AddMonths(1);
            radExportDateSelect1.SelectedDate     = radExportDateSelect2.SelectedDate = DateTime.Now;
            radExportDateSelect1.ShowPopupOnFocus = radExportDateSelect2.ShowPopupOnFocus = true;

            ddlExportPlantSelect.Items.Clear();
            switch (ddlReportList.SelectedValue)
            {
            case "1":
                SQMBasePage.SetLocationList(ddlExportPlantSelect, LocationList().Where(l => l.Plant.TRACK_EW_DATA == true || l.Plant.TRACK_FIN_DATA == true).ToList(), 0);
                break;

            case "2":      // incident export
                SQMBasePage.SetLocationList(ddlExportPlantSelect, LocationList(), 0);
                phIncidentCriteria.Visible = true;
                List <INCIDENT_TYPE> typeList = EHSIncidentMgr.SelectIncidentTypeList(SessionManager.PrimaryCompany().COMPANY_ID);
                ddlExportIncidentType.Items.Clear();
                foreach (INCIDENT_TYPE intype in typeList)
                {
                    RadComboBoxItem item = new RadComboBoxItem(intype.TITLE, intype.INCIDENT_TYPE_ID.ToString());
                    item.Checked = true;
                    ddlExportIncidentType.Items.Add(item);
                }
                break;

            case "3":      // metric status
                SQMBasePage.SetLocationList(ddlExportPlantSelect, LocationList().Where(l => l.Plant.TRACK_EW_DATA == true || l.Plant.TRACK_FIN_DATA == true).ToList(), 0);
                radExportDateSelect2.Enabled = false;
                break;

            case "4":      // dashboard eff date
                phBasicCriteria.Visible      = false;
                divMetricsTimespan.Visible   = true;
                lblTimespanDateError.Visible = false;
                COMPANY company = SQMModelMgr.LookupCompany(SessionManager.UserContext.HRLocation.Company.COMPANY_ID);
                if (company.COMPANY_ACTIVITY != null)
                {
                    try
                    {
                        if (company.COMPANY_ACTIVITY.EFF_EHS_METRIC_FROM_DT.HasValue)
                        {
                            radEffFrom.SelectedDate = (DateTime)company.COMPANY_ACTIVITY.EFF_EHS_METRIC_FROM_DT;
                        }
                        if (company.COMPANY_ACTIVITY.EFF_EHS_METRIC_DT.HasValue)
                        {
                            radEffTo.SelectedDate = (DateTime)company.COMPANY_ACTIVITY.EFF_EHS_METRIC_DT;
                        }
                    }
                    catch
                    {
                        radEffFrom.SelectedDate = DateTime.Now.AddMonths(-1);
                        radEffTo.SelectedDate   = DateTime.Now;
                    }
                }
                break;

            case "11":     // CO2 reports
                SQMBasePage.SetLocationList(ddlExportPlantSelect, LocationList().Where(l => l.Plant.TRACK_EW_DATA == true || l.Plant.TRACK_FIN_DATA == true).ToList(), 0);
                break;

            default:
                phBasicCriteria.Visible = phIncidentCriteria.Visible = false;
                break;
            }
        }
        public void rptLostTime_OnItemDataBound(object sender, RepeaterItemEventArgs e)
        {
            if (e.Item.ItemType == ListItemType.AlternatingItem || e.Item.ItemType == ListItemType.Item)
            {
                //int minRowsToValidate = 1;

                try
                {
                    INCFORM_LOSTTIME_HIST losttime = (INCFORM_LOSTTIME_HIST)e.Item.DataItem;

                    RadDropDownList rddlw = (RadDropDownList)e.Item.FindControl("rddlWorkStatus");
                    //rddlw.SelectedIndexChanged += rddlw_SelectedIndexChanged;

                    TextBox       tbr = (TextBox)e.Item.FindControl("tbRestrictDesc");
                    RadDatePicker bd  = (RadDatePicker)e.Item.FindControl("rdpBeginDate");
                    bd = SQMBasePage.SetRadDateCulture(bd, "");
                    RadDatePicker md = (RadDatePicker)e.Item.FindControl("rdpNextMedDate");
                    md = SQMBasePage.SetRadDateCulture(md, "");
                    RadDatePicker ed = (RadDatePicker)e.Item.FindControl("rdpExpectedReturnDT");
                    ed = SQMBasePage.SetRadDateCulture(ed, "");
                    RadButton itmdel = (RadButton)e.Item.FindControl("btnItemDelete");

                    System.Web.UI.HtmlControls.HtmlTableRow trMd = (System.Web.UI.HtmlControls.HtmlTableRow)e.Item.FindControl("trNextMedDate");
                    System.Web.UI.HtmlControls.HtmlTableRow trEd = (System.Web.UI.HtmlControls.HtmlTableRow)e.Item.FindControl("trExpectedReturnDate");

                    rddlw.Items.Add(new DropDownListItem("", ""));
                    List <EHSMetaData> statuses = EHSMetaDataMgr.SelectMetaDataList("WORK_STATUS");
                    foreach (var s in statuses)
                    {
                        rddlw.Items.Add(new DropDownListItem(s.Text, s.Value));
                    }

                    if (losttime.WORK_STATUS != null)
                    {
                        rddlw.SelectedValue = losttime.WORK_STATUS;
                    }

                    rddlw.SelectedValue = losttime.WORK_STATUS;
                    tbr.Text            = losttime.ITEM_DESCRIPTION;
                    bd.SelectedDate     = losttime.BEGIN_DT;
                    //rd.SelectedDate = losttime.RETURN_TOWORK_DT;
                    md.SelectedDate = losttime.NEXT_MEDAPPT_DT;
                    ed.SelectedDate = losttime.RETURN_EXPECTED_DT;

                    // Set user access:
                    rddlw.Enabled = tbr.Enabled = bd.Enabled = md.Enabled = ed.Enabled = itmdel.Visible = PageMode == PageUseMode.ViewOnly ? false : SessionManager.CheckUserPrivilege(SysPriv.originate, SysScope.incident);

                    switch (rddlw.SelectedValue)
                    {
                    case "":
                        tbr.Visible = true;
                        bd.Visible  = true;
                        //rd.Visible = false;
                        md.Visible = trMd.Visible = false;
                        ed.Visible = trEd.Visible = false;
                        break;

                    case "01":                                  // Return Restricted Duty
                        tbr.Visible = true;
                        bd.Visible  = true;
                        //rd.Visible = false;
                        md.Visible = true;
                        ed.Visible = trEd.Visible = false;
                        //rvfr.Enabled = true;
                        break;

                    case "02":                                  // Return to Work
                        tbr.Visible = true;
                        bd.Visible  = true;
                        //rd.Visible = false;
                        md.Visible = trMd.Visible = false;
                        ed.Visible = trEd.Visible = false;
                        break;

                    case "03":                                  // Additional Lost Time
                        tbr.Visible = true;
                        bd.Visible  = true;
                        //rd.Visible = false;
                        md.Visible = true;
                        ed.Visible = true;
                        //rvfr.Enabled = true;
                        break;
                    }
                }
                catch { }
            }

            // btnAddLostTime.Visible = SessionManager.CheckUserPrivilege(SysPriv.originate, SysScope.incident);

            btnSave.Visible = PageMode == PageUseMode.ViewOnly ? false : EHSIncidentMgr.CanUpdateIncident(null, true, SysPriv.action, WorkStatusIncident.INCFORM_LAST_STEP_COMPLETED);              // can log lost time ?
            if (btnSave.Visible == false)
            {
                btnSave.Visible = PageMode == PageUseMode.ViewOnly ? false : EHSIncidentMgr.CanUpdateIncident(null, true, SysPriv.config, WorkStatusIncident.INCFORM_LAST_STEP_COMPLETED);                  // check if has closed incident priv
            }
            btnAddLostTime.Visible = btnSave.Visible;

            if (hfContext.Value == "embeded")
            {
                btnSave.Visible = false;
            }
        }
        public void rptProfileStatus_OnItemDataBound(object sender, RepeaterItemEventArgs e)
        {
            if (e.Item.ItemType == ListItemType.AlternatingItem || e.Item.ItemType == ListItemType.Item)
            {
                Label lbl;
                try
                {
                    EHSProfile profile = (EHSProfile)e.Item.DataItem;

                    Button btn = (Button)e.Item.FindControl("btnRollup");
                    btn.CommandArgument = profile.Plant.PLANT_ID.ToString();
                    btn = (Button)e.Item.FindControl("btnRollupYTD");
                    btn.CommandArgument = profile.Plant.PLANT_ID.ToString();

                    DateTime   lastUpdateDate;
                    TaskStatus status = profile.PeriodStatus(new string[0] {
                    }, true, out lastUpdateDate);

                    lbl       = (Label)e.Item.FindControl("lblInputs");
                    lbl.Text += profile.InputPeriod.NumComplete + " of " + profile.MeasureList(false).Count + " (Total)";
                    lbl       = (Label)e.Item.FindControl("lblReqdInputs");
                    lbl.Text  = profile.InputPeriod.NumRequiredComplete.ToString() + " of " + profile.InputPeriod.NumRequired.ToString() + " (Required)";
                    LinkButton lnk = (LinkButton)e.Item.FindControl("lnkInputs");
                    lnk.CommandArgument = profile.Plant.PLANT_ID.ToString();

                    lbl = (Label)e.Item.FindControl("lblRollupStatus");
                    lnk = (LinkButton)e.Item.FindControl("lnkHistory");
                    lnk.CommandArgument = profile.Plant.PLANT_ID.ToString();
                    if (profile.InputPeriod.PlantAccounting != null && profile.InputPeriod.PlantAccounting.FINALIZE_DT != null)
                    {
                        lbl.Text    = SQMModelMgr.FormatPersonListItem(SQMModelMgr.LookupPerson((decimal)profile.InputPeriod.PlantAccounting.FINALIZE_ID, ""));
                        lbl.Text   += " ";
                        lbl.Text   += SQMBasePage.FormatDate((DateTime)profile.InputPeriod.PlantAccounting.FINALIZE_DT, "d", false);
                        lnk.Visible = true;
                    }

                    string currencyCode = SQMModelMgr.LookupPlant(profile.Plant.PLANT_ID).CURRENCY_CODE;
                    lbl      = (Label)e.Item.FindControl("lblRateStatus");
                    lbl.Text = currencyCode + ": ";
                    CURRENCY_XREF currentRate = CurrencyConverter.CurrentRate(currencyCode, profile.InputPeriod.PeriodYear, profile.InputPeriod.PeriodMonth);
                    if (currentRate != null && currentRate.EFF_MONTH > 0)
                    {
                        lbl.Text += (System.Environment.NewLine + SQMBasePage.FormatDate(new DateTime(currentRate.EFF_YEAR, currentRate.EFF_MONTH, DateTime.DaysInMonth(currentRate.EFF_YEAR, currentRate.EFF_MONTH)), "d", false));
                    }

                    if (profile.InputPeriod.PlantAccounting != null)
                    {
                        SETTINGS    sets = SQMSettings.GetSetting("EHS", "ACCTFIELDS"); // try to retrieve fields to display for this client
                        Ucl_EHSList ucl  = (Ucl_EHSList)e.Item.FindControl("uclProdList");
                        ucl.BindProdFieldsList(profile, sets == null ? "" : sets.VALUE);

                        if (profile.InputPeriod.PlantAccounting.APPROVER_ID.HasValue && profile.InputPeriod.PlantAccounting.APPROVAL_DT.HasValue)
                        {
                            lbl       = (Label)e.Item.FindControl("lblFinalStatus");
                            lbl.Text  = SQMModelMgr.FormatPersonListItem(SQMModelMgr.LookupPerson((decimal)profile.InputPeriod.PlantAccounting.APPROVER_ID, ""));
                            lbl.Text += " ";
                            lbl.Text += SQMBasePage.FormatDate((DateTime)profile.InputPeriod.PlantAccounting.APPROVAL_DT, "", false);
                        }
                    }
                }
                catch (Exception ex)
                {
                    ;
                }
            }
        }
        public void rptContain_OnItemDataBound(object sender, RepeaterItemEventArgs e)
        {
            if (e.Item.ItemType == ListItemType.AlternatingItem || e.Item.ItemType == ListItemType.Item)
            {
                int minRowsToValidate = 1;

                try
                {
                    INCFORM_CONTAIN contain = (INCFORM_CONTAIN)e.Item.DataItem;

                    TextBox       tbca  = (TextBox)e.Item.FindControl("tbContainAction");
                    RadComboBox   rddlp = (RadComboBox)e.Item.FindControl("rddlContainPerson");
                    Label         lb    = (Label)e.Item.FindControl("lbItemSeq");
                    RadDatePicker sd    = (RadDatePicker)e.Item.FindControl("rdpStartDate");
                    sd = SQMBasePage.SetRadDateCulture(sd, "");
                    //RadDatePicker cd = (RadDatePicker)e.Item.FindControl("rdpCompleteDate");
                    //CheckBox ic = (CheckBox)e.Item.FindControl("cbIsComplete");
                    RadButton itmdel = (RadButton)e.Item.FindControl("btnItemDelete");

                    RequiredFieldValidator rvfca = (RequiredFieldValidator)e.Item.FindControl("rfvContainAction");
                    RequiredFieldValidator rvfcp = (RequiredFieldValidator)e.Item.FindControl("rfvContainPerson");
                    RequiredFieldValidator rvfsd = (RequiredFieldValidator)e.Item.FindControl("rvfStartDate");

                    rvfca.ValidationGroup = ValidationGroup;
                    rvfcp.ValidationGroup = ValidationGroup;
                    rvfsd.ValidationGroup = ValidationGroup;

                    rddlp.Items.Add(new RadComboBoxItem("", ""));

                    var personList = new List <PERSON>();
                    personList = SQMModelMgr.SelectPlantPersonList(SessionManager.UserContext.WorkingLocation.Company.COMPANY_ID, (decimal)LocalIncident.DETECT_PLANT_ID);
                    foreach (PERSON p in personList)
                    {
                        if (!String.IsNullOrEmpty(p.EMAIL))
                        {
                            string displayName = string.Format("{0}, {1} ({2})", p.LAST_NAME, p.FIRST_NAME, p.EMAIL);
                            rddlp.Items.Add(new RadComboBoxItem(displayName, Convert.ToString(p.PERSON_ID)));
                        }
                    }

                    if (contain.ASSIGNED_PERSON_ID != null)
                    {
                        rddlp.SelectedValue = contain.ASSIGNED_PERSON_ID.ToString();
                    }
                    lb.Text         = contain.ITEM_SEQ.ToString();
                    tbca.Text       = contain.ITEM_DESCRIPTION;
                    sd.SelectedDate = contain.START_DATE;
                    //cd.SelectedDate = contain.COMPLETION_DATE;
                    //ic.Checked = contain.IsCompleted;

                    if ((tbca = (TextBox)e.Item.FindControl("tbComments")) != null)
                    {
                        tbca.Text = contain.COMMENTS;
                    }

                    // Set user access:
                    tbca.Enabled = rddlp.Enabled = sd.Enabled = itmdel.Visible = SessionManager.CheckUserPrivilege(SysPriv.action, SysScope.incident);

                    rvfca.Enabled = rvfcp.Enabled = rvfsd.Enabled = SessionManager.CheckUserPrivilege(SysPriv.action, SysScope.incident);

                    if (contain.ITEM_SEQ > minRowsToValidate)
                    {
                        rvfca.Enabled = false;
                        rvfcp.Enabled = false;
                        rvfsd.Enabled = false;
                    }

                    itmdel.Visible = PageMode == PageUseMode.ViewOnly ? false : EHSIncidentMgr.CanUpdateIncident(LocalIncident, IsEditContext, SysPriv.originate, LocalIncident.INCFORM_LAST_STEP_COMPLETED);
                }
                catch { }
            }

            btnSave.Visible = btnAddContain.Visible = PageMode == PageUseMode.ViewOnly ? false : EHSIncidentMgr.CanUpdateIncident(LocalIncident, IsEditContext, SysPriv.originate, LocalIncident.INCFORM_LAST_STEP_COMPLETED);
        }
        private void SetupProfilePanel()
        {
            if (ddlMetricDisposalCode.Items.Count == 0)
            {
                ddlDayDue.Items.AddRange(WebSiteCommon.PopulateDropDownListNums(1, 31));
                ddlWarningDays.Items.AddRange(WebSiteCommon.PopulateDropDownListNums(0, 11));

                ddlMetricDisposalCode.DataSource     = SessionManager.DisposalCodeList;
                ddlMetricDisposalCode.DataValueField = "UN_CODE";
                ddlMetricDisposalCode.DataTextField  = "UN_CODE";
                ddlMetricDisposalCode.DataBind();
                ddlMetricDisposalCode.Items.Insert(0, new ListItem(""));

                ddlMetricRegStatus.Items.AddRange(WebSiteCommon.PopulateDropDownListItems("regulatoryStatus"));
                ddlMetricRegStatus.Items.Insert(0, new ListItem(""));

                SQMBasePage.FillCurrencyDDL(ddlMetricCurrency, "EUR");
                ddlMetricCurrency.Items.Insert(0, "");

                ddlMetricCost.Items.AddRange(WebSiteCommon.PopulateDropDownListItems("costType", "long"));
                ddlMetricCost.Items.Insert(0, "");

                if (UserContext.CheckAccess("EHS", "") >= AccessMode.Admin)
                {
                    ddlMetricStatus.Items.AddRange(WebSiteCommon.PopulateDropDownListItems("statusCodeDelete"));
                }
                else
                {
                    ddlMetricStatus.Items.AddRange(WebSiteCommon.PopulateDropDownListItems("statusCode"));
                }

                ddlMetricCategory.Items.AddRange(WebSiteCommon.PopulateDropDownListItems("measureCategoryEHS", 2, ""));
                ddlMetricCategory.Items.Insert(0, "");

                measureList = EHSModel.SelectEHSMeasureList("", true).OrderBy(l => l.MEASURE_NAME).ToList();
                foreach (EHS_MEASURE measure in measureList)
                {
                    ddlMetricID.Items.Add(new ListItem(measure.MEASURE_NAME.Trim(), WebSiteCommon.PackItemValue(measure.MEASURE_CATEGORY, measure.EFM_TYPE, measure.MEASURE_ID.ToString())));
                    if (measure.MEASURE_CATEGORY == "FACT")
                    {
                        ListItem item = new ListItem(measure.MEASURE_NAME.Trim(), measure.MEASURE_ID.ToString());
                        item.Attributes.Add("title", measure.MEASURE_DESC);
                        ddlNormFact.Items.Add(item);
                    }
                }
                ddlMetricID.Items.Insert(0, "");
                ddlNormFact.Items.Insert(0, "");

                if (ddlNormFact.Items.Count == 1)       // don't display normalize selects if no factors defined
                {
                    phNormFact.Visible = false;
                }

                foreach (UOM uom in SessionManager.UOMList.Where(l => l.OWNER_ID == null).OrderBy(l => l.UOM_NAME).ToList())
                {
                    ddlMetricUOM.Items.Add(new ListItem(uom.UOM_NAME, WebSiteCommon.PackItemValue(uom.UOM_CATEGORY, uom.EFM_TYPE, uom.UOM_ID.ToString())));
                }
                ddlMetricUOM.Items.Insert(0, "");
                ddlMetricUOM.SelectedIndex = 0;
            }
            divEHSProfile.Visible  = true;
            pnlCopyProfile.Visible = false;
            UpdateListTitles();
        }