protected void rgIncidentActionList_ItemDataBound(object sender, GridItemEventArgs e)
        {
            if (e.Item is GridDataItem)
            {
                GridDataItem item = (GridDataItem)e.Item;
                HiddenField  hf;
                Label        lbl;

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

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


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

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

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

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

                catch
                {
                }
            }
        }
        public void rptOrgList_OnItemDataBound(object sender, RepeaterItemEventArgs e)
        {
            if (e.Item.ItemType == ListItemType.AlternatingItem || e.Item.ItemType == ListItemType.Item)
            {
                Label       lbl;
                HiddenField hfField;

                try
                {
                    BUSINESS_ORG busOrg = (BUSINESS_ORG)e.Item.DataItem;

                    lbl = (Label)e.Item.FindControl("lblParentBUHdr_out");
                    if (busOrg.PARENT_BUS_ORG_ID == busOrg.BUS_ORG_ID || busOrg.PARENT_BUS_ORG_ID < 1)
                    {
                        lbl.Text = "Top Level";
                    }
                    else
                    {
                        BUSINESS_ORG parentOrg = null;
                        if ((parentOrg = SQMModelMgr.LookupParentBusOrg(null, busOrg)) != null)
                        {
                            lbl.Text = parentOrg.ORG_NAME;
                        }
                    }

                    lbl      = (Label)e.Item.FindControl("lblStatus");
                    hfField  = (HiddenField)e.Item.FindControl("hfStatus");
                    lbl.Text = WebSiteCommon.GetStatusString(hfField.Value);

                    GridView gv = (GridView)e.Item.FindControl("gvPlantList");
                    gv.DataSource = busOrg.PLANT.OrderBy(l => l.PLANT_NAME).ToList();  // order by plant name
                    gv.DataBind();

                    Label divLabel         = (Label)e.Item.FindControl("lblPlantListEmpty");
                    HtmlGenericControl div = (HtmlGenericControl)e.Item.FindControl("divPlantGVScroll");
                    SetGridViewDisplay(gv, divLabel, div, 20, gv.Rows.Count, "scrollArea");

                    if (UserContext.RoleAccess() >= AccessMode.Admin)
                    {
                        if (busOrg.PLANT.Count > 0)
                        {
                            Button btnAddPlant = (Button)gv.HeaderRow.FindControl("btnAddPlant");
                            btnAddPlant.CommandArgument = busOrg.BUS_ORG_ID.ToString();
                            btnAddPlant.Visible         = true;
                        }
                        else
                        {
                            Button btnAddPlant = (Button)e.Item.FindControl("btnAddPlantEmpty");
                            btnAddPlant.CommandArgument = busOrg.BUS_ORG_ID.ToString();
                            btnAddPlant.Visible         = true;
                        }
                    }
                }
                catch
                {
                }
            }
        }
Example #3
0
        private void SetupPage()
        {
            if (langList == null || langList.Count == 0)
            {
                langList = SQMModelMgr.SelectLanguageList(new PSsqmEntities(), true);
                uclPrefsEdit.SetLanguageList(langList);
            }

            BusinessLocation businessLocation = new BusinessLocation(); businessLocation = SessionManager.UserContext.HRLocation;

            List <decimal> 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>();
            AccessMode accessmode;

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

            if ((accessmode = UserContext.RoleAccess()) > 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));
                }
            }

            lblTaskCount0.Text = SessionManager.UserContext.TaskList.Where(l => l.NotifyType == TaskNotification.Owner).Count().ToString();
            uclTaskList0.BindTaskList(SessionManager.UserContext.TaskList.Where(l => l.NotifyType == TaskNotification.Owner).OrderBy(l => l.RecordType).ThenByDescending(l => l.Task.DUE_DT).ToList());

            lblTaskCount1.Text = SessionManager.UserContext.TaskList.Where(l => l.NotifyType == TaskNotification.Delegate).Count().ToString();
            if (lblTaskCount1.Text != "0")
            {
                divTaskList1.Visible = pnlTaskList1.Visible = true;
                uclTaskList1.BindTaskList(SessionManager.UserContext.TaskList.Where(l => l.NotifyType == TaskNotification.Delegate).OrderBy(l => l.RecordType).ThenByDescending(l => l.Task.DUE_DT).ToList());
            }

            lblTaskCount2.Text = SessionManager.UserContext.TaskList.Where(l => l.NotifyType == TaskNotification.Escalation).Count().ToString();
            if (lblTaskCount2.Text != "0")
            {
                divTaskList2.Visible = pnlTaskList2.Visible = true;
                uclTaskList2.BindTaskList(SessionManager.UserContext.TaskList.Where(l => l.NotifyType == TaskNotification.Escalation).OrderBy(l => l.RecordType).ThenByDescending(l => l.Task.DUE_DT).ToList());
            }

            ++SessionManager.UserContext.InboxReviews;
        }
        private void OnLocationSelect(decimal plantID)
        {
            PLANT plant = SQMModelMgr.LookupPlant(plantID);

            if (plant == null)
            {
                DisplayProfileMessage(lblProfileNotExist);
            }
            else
            {
                List <BusinessLocation> locationList = new List <BusinessLocation>();
                locationList.Add(new BusinessLocation().Initialize(plantID));
                List <PERSON> responsibleList = SQMModelMgr.SelectPlantPersonList(locationList, "311", AccessMode.Update);

                SQMBasePage.SetPersonList(ddlMetricResponsible, responsibleList, "");
                SQMBasePage.SetPersonList(ddlFinalApprover, responsibleList.Where(l => l.ROLE < SessionManager.AccessModeRoleXREF(AccessMode.Update)).ToList(), "");

                LoadPlantProfile(plant);

                if (LocalProfile() != null && (LocalProfile().Profile.EHS_PROFILE_MEASURE == null || LocalProfile().Profile.EHS_PROFILE_MEASURE.Count == 0))
                {
                    if (UserContext.RoleAccess() > AccessMode.Plant)
                    {
                        List <EHS_PROFILE> profileList = EHSModel.SelectPlantProfileList(SessionManager.UserContext.HRLocation.Company.COMPANY_ID);
                        SQMBasePage.SetLocationList(ddlCopyProfile, SQMModelMgr.SelectBusinessLocationList(SessionManager.UserContext.HRLocation.Company.COMPANY_ID, 0, true).Where(l => profileList.Select(p => p.PLANT_ID).ToArray().Contains(l.Plant.PLANT_ID)).ToList(), 0);
                        ddlCopyProfile.Items.Insert(0, new Telerik.Web.UI.RadComboBoxItem("", ""));
                        responsibleList = SQMModelMgr.SelectPersonList((decimal)plant.COMPANY_ID, (decimal)plant.BUS_ORG_ID, true, false).Where(p => p.ROLE >= SessionManager.AccessModeRoleXREF(AccessMode.Admin) && p.ROLE < SessionManager.AccessModeRoleXREF(AccessMode.View)).OrderBy(l => l.LAST_NAME).ToList();
                        ddlDefaultResponsible.Items.Clear();
                        foreach (PERSON person in responsibleList)
                        {
                            if (SQMModelMgr.PersonPlantAccess(person, plant.PLANT_ID))
                            {
                                ddlDefaultResponsible.Items.Add(new Telerik.Web.UI.RadComboBoxItem(SQMModelMgr.FormatPersonListItem(person), person.PERSON_ID.ToString()));
                            }
                        }
                        ddlDefaultResponsible.Items.Insert(0, new Telerik.Web.UI.RadComboBoxItem("", ""));
                        pnlCopyProfile.Visible = true;
                    }
                }

                pnlProfileEdit.Style.Add("display", "none");
            }
        }
        protected void SetupPage()
        {
            hdCurrentActiveMenu.Value = SessionManager.CurrentMenuItem;

            lbBusinessCard1_out.Text = SessionManager.UserContext.UserName(); // +": " + SessionManager.UserContext.HRLocation.Company.COMPANY_NAME + ", " + SessionManager.UserContext.HRLocation.Plant.PLANT_NAME;
            lblActiveLocation.Text   = SessionManager.UserContext.HRLocation.Company.COMPANY_NAME + ", " + SessionManager.UserContext.HRLocation.Plant.PLANT_NAME;
            if (SessionManager.StatOfTheDay != null && UserContext.RoleAccess() != AccessMode.Partner)
            {
                lblActiveLocation.Text   = SessionManager.UserContext.HRLocation.Company.COMPANY_NAME + ", " + SessionManager.UserContext.HRLocation.Plant.PLANT_NAME + ": ";
                lblStatOfTheDay_out.Text = SQMBasePage.FormatValue(SessionManager.StatOfTheDay.Value, 0);
                lblStatOfTheDay.Visible  = lblStatOfTheDay_out.Visible = true;
            }
            else
            {
                lblStatOfTheDay_out.Text = "n/a";
            }
            pnlStatOfTheDay.Visible = true;

            tbUserPhone.Text = SessionManager.UserContext.Person.PHONE;
        }
Example #6
0
        protected void DisplayUser()
        {
            PERSON           person = LocalPerson();
            BusinessLocation businessLocation;
            SETTINGS         sets      = SQMSettings.GetSetting("COMPANY", "ESCALATEANYUSER");
            SQM_ACCESS       sysAccess = SQMModelMgr.LookupCredentials(entities, person.SSO_ID, "", false);

            divPageBody.Visible = true;
            ddlPlantSelect.ClearCheckedItems();
            ddlCustPlantSelect.ClearCheckedItems();

            DisplayErrorMessage(null);

            if (person == null || string.IsNullOrEmpty(person.STATUS))                 // new user
            {
                winUserEdit.Title        = hfAddUser.Value;
                businessLocation         = new BusinessLocation();
                businessLocation.Company = SessionManager.EffLocation.Company;
                SetStatusList("ddlUserStatus", "A", true);
                tbUserSSOID.Enabled = true;
                tbUserSSOID.Text    = "";
                tbUserSSOID.Focus();
            }
            else
            {
                winUserEdit.Title   = hfUpdateUser.Value;
                tbUserSSOID.Enabled = false;
                tbUserFirstName.Focus();

                lblPlantAccess.Text = "";
                if (person.PLANT_ID > 0)
                {
                    ddlHRLocation.SelectedValue = person.PLANT_ID.ToString();
                    if (ddlPlantSelect.Items.FindItemByValue(person.PLANT_ID.ToString()) != null)
                    {
                        ddlPlantSelect.Items.FindItemByValue(person.PLANT_ID.ToString()).Checked = true;
                    }
                }

                if (!string.IsNullOrEmpty(person.NEW_LOCATION_CD))
                {
                    RadComboBoxItem plantItem = null;
                    string[]        locs      = person.NEW_LOCATION_CD.Split(',');
                    foreach (string locid in locs)
                    {
                        if ((plantItem = ddlPlantSelect.Items.FindItemByValue(locid)) != null)
                        {
                            ddlPlantSelect.Items.FindItemByValue(locid).Checked = true;
                            if (locs.Length > 2)
                            {
                                lblPlantAccess.Text += lblPlantAccess.Text.Length == 0 ? plantItem.Text : (", " + plantItem.Text);
                            }
                        }
                    }
                }

                if (!string.IsNullOrEmpty(person.OLD_LOCATION_CD))
                {
                    string[] locs = person.OLD_LOCATION_CD.Split(',');
                    foreach (string locid in locs)
                    {
                        if (ddlCustPlantSelect.Items.FindItemByValue(locid) != null)
                        {
                            ddlCustPlantSelect.Items.FindItemByValue(locid).Checked = true;
                        }
                    }
                }
            }

            // AW20131106 - do not want to be able to change a SSO ID once a person has been added
            if (!string.IsNullOrEmpty(person.SSO_ID.Trim()))
            {
                tbUserSSOID.Text = person.SSO_ID;
            }

            tbUserFirstName.Text = person.FIRST_NAME;
            tbUserLastName.Text  = person.LAST_NAME;
            tbUserTitle.Text     = person.JOB_TITLE;
            tbUserPhone.Text     = person.PHONE;
            tbUserEmail.Text     = person.EMAIL;
            SetStatusList("ddlUserStatus", person.STATUS, true);
            if (sysAccess != null && sysAccess.LAST_LOGON_DT.HasValue)
            {
                lblUserLoginDate_out.Text = SQMBasePage.FormatDate(WebSiteCommon.LocalTime((DateTime)sysAccess.LAST_LOGON_DT, WebSiteCommon.GetXlatValue("timeZone", person.PREFERRED_TIMEZONE)), "g", true);
            }
            else
            {
                lblUserLoginDate_out.Text = "";
            }
            lblUserLastUpdate.Text = person.LAST_UPD_BY + "  " + SQMBasePage.FormatDate(WebSiteCommon.LocalTime((DateTime)person.LAST_UPD_DT, SessionManager.UserContext.TimeZoneID), "g", true);

            if (ddlUserLanguage.Items.FindByValue(person.PREFERRED_LANG_ID.ToString()) != null)
            {
                ddlUserLanguage.SelectedValue = person.PREFERRED_LANG_ID.ToString();
            }
            if (ddlUserTimezone.Items.FindByValue(person.PREFERRED_TIMEZONE) != null)
            {
                ddlUserTimezone.SelectedValue = person.PREFERRED_TIMEZONE;
            }

            ddlUserRole.Items.Clear();
            ddlUserRole.Items.AddRange(WebSiteCommon.PopulateRadListItems("userRole"));
            for (int i = ddlUserRole.Items.Count - 1; i >= 0; i--)
            {
                AccessMode roleMode = SessionManager.RoleAccessMode(Convert.ToInt32(ddlUserRole.Items[i].Value));
                if (SessionManager.IsEffLocationPrimary() && roleMode == AccessMode.Partner)
                {
                    ddlUserRole.Items.Remove(i);
                }
                if (!SessionManager.IsEffLocationPrimary() && roleMode != AccessMode.Partner)               // restrict roles of non-primary company users
                {
                    ddlUserRole.Items.Remove(i);
                }
                else if (UserContext.RoleAccess() < AccessMode.SA && roleMode > AccessMode.Admin)      // only QAI admin may see or edit sys admin role
                {
                    ddlUserRole.Items.Remove(i);
                }
            }

            string rolesDesc = "";

            if (ddlUserRole.Items.FindItemByValue(person.ROLE.ToString()) != null)
            {
                ddlUserRole.SelectedValue = person.ROLE.ToString();
            }

            if (sets == null || sets.VALUE.ToUpper() != "Y")      // prompt for user escalation
            {
                cbUserRcvEscalation.Visible = true;
                if (person.RCV_ESCALATION.HasValue)
                {
                    cbUserRcvEscalation.Checked = (bool)person.RCV_ESCALATION;
                }
            }
            else
            {
                cbUserRcvEscalation.Visible = false;        // enable escalation for anyone
                cbUserRcvEscalation.Checked = true;
            }

            if (person.ROLE <= 100 || person.PERSON_ACCESS.Where(a => a.ACCESS_PROD == "SQM").Count() > 0)
            {
                ddlCustPlantSelect.Enabled = true;
            }
            else
            {
                ddlCustPlantSelect.Enabled       = false;
                ddlCustPlantSelect.SelectedIndex = 0;
            }

            List <SysModule> sysmodList = SQMSettings.SystemModuleItems();
            string           prod = "";
            RadComboBoxItem  item = null; RadComboBoxItem itemSep = null;

            ddlModuleAccess.Items.Clear();
            lblModuleAccess.Text = "";
            foreach (SysModule sysmod in sysmodList.Where(l => l.prod != "CQM").ToList())
            {
                if (string.IsNullOrEmpty(sysmod.mod))
                {
                    prod                = sysmod.prod;
                    itemSep             = new RadComboBoxItem(((HiddenField)pnlUserEdit.FindControl("hf" + prod)).Value, prod);
                    itemSep.IsSeparator = true;
                    ddlModuleAccess.Items.Add(itemSep);
                }
                else
                {
                    item = new RadComboBoxItem(sysmod.desc, sysmod.topic);
                    ddlModuleAccess.Items.Add(item);
                    if (GetSelectedUserRole() <= 100)
                    {
                        item.Checked = true;
                    }
                    else if ((sysmod.prod == "SQM" && person.PERSON_ACCESS.Where(a => a.ACCESS_TOPIC == "201").Count() > 0) ||
                             (sysmod.prod == "EHS" && person.PERSON_ACCESS.Where(a => a.ACCESS_TOPIC == "301").Count() > 0))
                    {
                        item.Checked = true;
                    }
                    else if (person.PERSON_ACCESS.Where(a => a.ACCESS_TOPIC == sysmod.topic).Count() > 0)
                    {
                        item.Checked = true;
                    }
                    // exclusions
                    if (!SessionManager.IsEffLocationPrimary())  // restrict module selections if not primary company user
                    {
                        if (sysmod.prod != "SQM")
                        {
                            itemSep.Enabled        = item.Enabled = item.Checked = false;
                            ddlModuleAccess.Height = 120;
                        }
                    }
                    if (item.Checked)
                    {
                        lblModuleAccess.Text += lblModuleAccess.Text.Length == 0 ? item.Text : (", " + item.Text);
                    }
                }
            }

            if (!SessionManager.IsEffLocationPrimary())
            {
                ddlCustPlantSelect.Enabled  = false;
                cbUserRcvEscalation.Visible = cbUserRcvEscalation.Checked = false;
            }

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

            ScriptManager.RegisterStartupScript(Page, Page.GetType(), "key", script, true);
        }
        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;
        }
        private void DisplayCalendar(DateTime selectedDate)
        {
            // don't display task strip if tasklist is empty
            if (SessionManager.UserContext.TaskList.Count == 0)
            {
                divCalendar.Attributes.Remove("class");
                divTasks.Attributes.Remove("class");
                divTasks.Visible = false;
            }

            bool enableItemLinks = false;

            respForList = new List <decimal>();
            respForList.Add(SessionManager.UserContext.Person.PERSON_ID);
            respForList.AddRange(SessionManager.UserContext.DelegateList);
            DateTime toDate = DateTime.Now.AddMonths(Convert.ToInt32(sldScheduleRange.Value));

            string selectedValue = "0";

            if (ddlScheduleScope.SelectedIndex > -1)
            {
                selectedValue = ddlScheduleScope.SelectedValue;
            }
            else if (mnuScheduleScope.SelectedItem != null)
            {
                selectedValue = mnuScheduleScope.SelectedItem.Value;
            }

            List <TaskItem> taskScheduleList = new List <TaskItem>();

            if (selectedValue == "0" || selectedValue == "TOP")
            {
                taskScheduleList.AddRange(SessionManager.UserContext.TaskList.Where(l => l.Task.DUE_DT < DateTime.Now).ToList());
                taskScheduleList.AddRange(TaskMgr.IncidentTaskSchedule(SessionManager.PrimaryCompany().COMPANY_ID, DateTime.Now, toDate, respForList, new decimal[0] {
                }, true));
                taskScheduleList.AddRange(TaskMgr.ProfileInputSchedule(DateTime.Now, toDate, respForList, new decimal[0] {
                }, UserContext.RoleAccess() >= AccessMode.Admin ? true : false));
                enableItemLinks = true;
            }
            else
            {
                List <decimal> plantIDS = new List <decimal>();
                if (selectedValue.All(c => c >= '0' && c <= '9') == false)
                {   // all accessible plants for a selected BU
                    decimal   busOrgID       = Convert.ToDecimal(selectedValue.Substring(2, selectedValue.Length - 2));
                    decimal[] busOrgPlantIDS = SQMModelMgr.SelectPlantList(entities, SessionManager.PrimaryCompany().COMPANY_ID, busOrgID).Select(l => l.PLANT_ID).ToArray();
                    foreach (decimal plantID in busOrgPlantIDS)
                    {
                        if (ddlScheduleScope.Visible && ddlScheduleScope.Items.FindItemByValue(plantID.ToString()) != null)
                        {
                            plantIDS.Add(plantID);
                        }
                        else if (mnuScheduleScope.Visible)
                        {
                            RadMenuItem miTop = mnuScheduleScope.Items[0];
                            foreach (RadMenuItem miBU in miTop.Items)
                            {
                                foreach (RadMenuItem miLoc in miBU.Items)
                                {
                                    if (miLoc.Value == plantID.ToString())
                                    {
                                        plantIDS.Add(plantID);
                                    }
                                }
                            }
                        }
                    }
                }
                else
                {   // specific plant
                    plantIDS.Add(Convert.ToDecimal(selectedValue));
                }
                taskScheduleList.AddRange(SessionManager.UserContext.TaskList.Where(l => l.Task.DUE_DT < DateTime.Now &&
                                                                                    (plantIDS.Contains(l.Plant.PLANT_ID) || (l.PlantResponsible != null && plantIDS.Contains((decimal)l.PlantResponsible.PLANT_ID)))));
                taskScheduleList.AddRange(TaskMgr.IncidentTaskSchedule(SessionManager.PrimaryCompany().COMPANY_ID, DateTime.Now, toDate, new List <decimal>(), plantIDS.ToArray(), true));
                taskScheduleList.AddRange(TaskMgr.ProfileInputSchedule(DateTime.Now, toDate, new List <decimal>(), plantIDS.ToArray(), false));
                if (UserContext.RoleAccess() >= AccessMode.Plant)
                {
                    enableItemLinks = true;
                }
            }

            uclTaskSchedule.BindTaskSchedule(taskScheduleList, selectedDate, enableItemLinks);

            uclTaskStrip.BindTaskStrip(SessionManager.UserContext.TaskList.Where(l => !String.IsNullOrEmpty(l.LongTitle)).OrderBy(l => l.Task.DUE_DT).ToList());
        }
        protected void Page_PreRender(object sender, EventArgs e)
        {
            try
            {
                if (!Page.IsPostBack)
                {
                    SessionManager.CurrentAdminPage = "";
                    string customerLogo = "";
                    customerLogo = System.Configuration.ConfigurationManager.AppSettings["CustomerLogo"];
                    if (string.IsNullOrEmpty(customerLogo) || customerLogo.Contains("Metricsoft"))
                    {
                        imgLogo.ImageUrl = "~/images/company/MetricsoftLogoSmall.png";
                    }
                    else
                    {
                        int pos = customerLogo.IndexOf('.');
                        customerLogo     = customerLogo.Substring(0, pos) + "Small." + customerLogo.Substring(pos + 1, customerLogo.Length - pos - 1);
                        imgLogo.ImageUrl = "~/images/company/" + customerLogo;
                    }

                    string title = System.Configuration.ConfigurationManager.AppSettings["MainTitle"];
                    if (!string.IsNullOrEmpty(title))
                    {
                        lblMainTitle.Text = title;
                    }

                    SetupPage();

                    RadMenu1.Skin                       = "Metro";
                    RadMenu1.ExpandDelay                = 225;
                    RadMenu1.CollapseDelay              = 500;
                    RadMenu1.ExpandAnimation.Duration   = 40;
                    RadMenu1.CollapseAnimation.Duration = 20;
                    RadMenu1.DefaultGroupSettings.Flow  = Telerik.Web.UI.ItemFlow.Horizontal;

                    if (UserContext.RoleAccess() > AccessMode.None)
                    {
                        RadMenuItem HomeMenu = new RadMenuItem("Home");
                        RadMenu1.Items.Add(HomeMenu);
                        if (UserContext.RoleAccess() != AccessMode.Partner)
                        {
                            HomeMenu.Items.Add(new Telerik.Web.UI.RadMenuItem("Dashboard", "/Home/Dashboard.aspx"));
                        }
                        HomeMenu.Items.Add(new Telerik.Web.UI.RadMenuItem("Calendar", "/Home/Calendar.aspx"));
                        // HomeMenu.Items.Add(new Telerik.Web.UI.RadMenuItem(inboxLabel, "/Home/Inbox.aspx"));
                    }

                    if (UserContext.CheckAccess("CQM", "101") >= AccessMode.Admin)
                    {
                        RadMenuItem OrgMenu = new RadMenuItem("Organization");
                        RadMenu1.Items.Add(OrgMenu);
                        OrgMenu.Items.Add(new Telerik.Web.UI.RadMenuItem("Business Structure", "/Admin/Administrate_ViewBusOrg.aspx"));
                        OrgMenu.Items.Add(new Telerik.Web.UI.RadMenuItem("Exchange Rates", "/Admin/Administrate_CurrencyInput.aspx"));
                        //if (UserContext.RoleAccess() == AccessMode.SA)
                        OrgMenu.Items.Add(new Telerik.Web.UI.RadMenuItem("Settings", "/Admin/Administrate_SettingInput.aspx"));
                        OrgMenu.Items.Add(new Telerik.Web.UI.RadMenuItem("Upload Data", "/Admin/Administrate_FileUpload.aspx"));
                    }

                    if (UserContext.CheckAccess("SQM", "") > AccessMode.Limited)
                    {
                        RadMenuItem SQMMenu = new RadMenuItem("Quality");
                        RadMenu1.Items.Add(SQMMenu);
                        if (UserContext.CheckAccess("SQM", "201") > AccessMode.Plant)
                        {
                            SQMMenu.Items.Add(new Telerik.Web.UI.RadMenuItem("Library", "/Quality/Quality_Resources.aspx"));
                        }
                        if (UserContext.CheckAccess("SQM", "201") > AccessMode.Plant)
                        {
                            SQMMenu.Items.Add(new Telerik.Web.UI.RadMenuItem("Parts", "/Admin/Administrate_ViewPart.aspx"));
                        }
                        if (UserContext.CheckAccess("SQM", "211") > AccessMode.Limited)
                        {
                            SQMMenu.Items.Add(new Telerik.Web.UI.RadMenuItem(SQMSettings.GetSetting("QS", "3").XLAT_SHORT, "/Quality/Quality_Issue.aspx?c=RCV"));
                        }
                        if (UserContext.CheckAccess("SQM", "212") > AccessMode.Limited)
                        {
                            SQMMenu.Items.Add(new Telerik.Web.UI.RadMenuItem(SQMSettings.GetSetting("QS", "4").XLAT_SHORT, "/Quality/Quality_Issue.aspx?c=CST"));
                        }
                        if (UserContext.CheckAccess("SQM", "220") > AccessMode.Admin)
                        {
                            SQMMenu.Items.Add(new Telerik.Web.UI.RadMenuItem("Cost Reporting", "/Quality/Quality_CostRecord.aspx"));
                        }
                        if (UserContext.CheckAccess("SQM", "221") > AccessMode.Limited)
                        {
                            SQMMenu.Items.Add(new Telerik.Web.UI.RadMenuItem("Problem Control", "/Problem/Problem_Case.aspx?c=QI"));
                        }
                    }

                    if (UserContext.CheckAccess("EHS", "") > AccessMode.Limited)
                    {
                        RadMenuItem EHSMenu = new RadMenuItem("Environmental, Health & Safety");
                        RadMenu1.Items.Add(EHSMenu);
                        if (UserContext.CheckAccess("EHS", "301") > AccessMode.Plant)
                        {
                            EHSMenu.Items.Add(new Telerik.Web.UI.RadMenuItem("Library", "/EHS/EHS_Resources.aspx"));
                        }
                        if (UserContext.CheckAccess("EHS", "301") >= AccessMode.Plant)
                        {
                            EHSMenu.Items.Add(new Telerik.Web.UI.RadMenuItem("Metric Profiles", "/EHS/EHS_Profile.aspx"));
                        }
                        if (UserContext.CheckAccess("EHS", "311") > AccessMode.Limited)
                        {
                            EHSMenu.Items.Add(new Telerik.Web.UI.RadMenuItem("Data Input", "/EHS/EHS_MetricInput.aspx"));
                        }
                        if (UserContext.CheckAccess("EHS", "311") > AccessMode.Limited)
                        {
                            EHSMenu.Items.Add(new Telerik.Web.UI.RadMenuItem("Plant Analytics", "/EHS/EHS_ENVReport.aspx"));
                        }
                        if (UserContext.CheckAccess("EHS", "312") > AccessMode.Limited)
                        {
                            EHSMenu.Items.Add(new Telerik.Web.UI.RadMenuItem("Incidents", "/EHS/EHS_Incidents.aspx"));
                        }
                        if (UserContext.CheckAccess("EHS", "313") > AccessMode.Limited)
                        {
                            EHSMenu.Items.Add(new Telerik.Web.UI.RadMenuItem("Preventative Actions", "/EHS/EHS_Incidents.aspx?mode=prevent"));
                        }
                        if (UserContext.CheckAccess("EHS", "301") > AccessMode.Plant)
                        {
                            EHSMenu.Items.Add(new Telerik.Web.UI.RadMenuItem("Console", "/EHS/EHS_Console.aspx?c=EHS"));
                        }
                    }

                    /*
                     * if (UserContext.CheckAccess("EHS", "") > AccessMode.Limited)
                     * {
                     *  RadMenuItem ENVMenu = new RadMenuItem("Environmental");
                     *  RadMenu1.Items.Add(ENVMenu);
                     *  if (UserContext.CheckAccess("EHS", "301") > AccessMode.Plant)
                     *      ENVMenu.Items.Add(new Telerik.Web.UI.RadMenuItem("Library", "/EHS/EHS_Resources.aspx"));
                     *  if (UserContext.CheckAccess("EHS", "301") >= AccessMode.Plant)
                     *      ENVMenu.Items.Add(new Telerik.Web.UI.RadMenuItem("Metric Profiles", "/EHS/EHS_Profile.aspx"));
                     *  if (UserContext.CheckAccess("EHS", "311") > AccessMode.Limited)
                     *      ENVMenu.Items.Add(new Telerik.Web.UI.RadMenuItem("Metric Input", "/EHS/EHS_MetricInput.aspx"));
                     *  if (UserContext.CheckAccess("EHS", "311") > AccessMode.Limited)
                     *      ENVMenu.Items.Add(new Telerik.Web.UI.RadMenuItem("Plant Analytics", "/EHS/EHS_ENVReport.aspx"));
                     *  if (UserContext.CheckAccess("EHS", "301") > AccessMode.Plant)
                     *      ENVMenu.Items.Add(new Telerik.Web.UI.RadMenuItem("Console", "/EHS/EHS_Console.aspx?c=EHS"));
                     *
                     *  RadMenuItem EHSMenu = new RadMenuItem("Health & Safety");
                     *  RadMenu1.Items.Add(EHSMenu);
                     *  if (UserContext.CheckAccess("EHS", "312") > AccessMode.Limited)
                     *      EHSMenu.Items.Add(new Telerik.Web.UI.RadMenuItem("Incidents", "/EHS/EHS_Incidents.aspx"));
                     *  if (UserContext.CheckAccess("EHS", "313") > AccessMode.Limited)
                     *                               EHSMenu.Items.Add(new Telerik.Web.UI.RadMenuItem("Preventative Actions", "/EHS/EHS_Incidents.aspx?mode=prevent"));
                     *  if (UserContext.CheckAccess("EHS", "301") > AccessMode.Plant)
                     *      EHSMenu.Items.Add(new Telerik.Web.UI.RadMenuItem("Console", "/EHS/EHS_Console.aspx?c=EHS"));
                     * }
                     */

                    string menuQualityActive = System.Configuration.ConfigurationManager.AppSettings["MenuQualityActive"];
                    if (!string.IsNullOrEmpty(menuQualityActive) && menuQualityActive.ToUpper() == "FALSE")
                    {
                        foreach (RadMenuItem mi in RadMenu1.Items)
                        {
                            if (mi.Text.Contains("Quality"))
                            {
                                mi.Visible = false;
                            }
                        }
                    }

                    string menuEHSActive = System.Configuration.ConfigurationManager.AppSettings["MenuEHSActive"];
                    if (!string.IsNullOrEmpty(menuEHSActive) && menuEHSActive.ToUpper() == "FALSE")
                    {
                        foreach (RadMenuItem mi in RadMenu1.Items)
                        {
                            if (mi.Text.Contains("Environ"))
                            {
                                mi.Visible = false;
                            }
                        }
                    }

                    string menuENVReportActive = System.Configuration.ConfigurationManager.AppSettings["MenuENVReportActive"];
                    if (!string.IsNullOrEmpty(menuENVReportActive) && menuENVReportActive.ToUpper() == "FALSE")
                    {
                        foreach (RadMenuItem mi in RadMenu1.Items)
                        {
                            foreach (RadMenuItem ms in mi.Items)
                            {
                                if (ms.NavigateUrl.EndsWith("EHS_ENVReport.aspx"))
                                {
                                    ms.Visible = false;
                                }
                            }
                        }
                    }

                    string menuEHSIncidentActive = System.Configuration.ConfigurationManager.AppSettings["MenuEHSIncidentActive"];
                    if (!string.IsNullOrEmpty(menuEHSIncidentActive) && menuEHSIncidentActive.ToUpper() == "FALSE")
                    {
                        foreach (RadMenuItem mi in RadMenu1.Items)
                        {
                            foreach (RadMenuItem ms in mi.Items)
                            {
                                if (ms.NavigateUrl.EndsWith("EHS_Incidents.aspx"))
                                {
                                    ms.Visible = false;
                                }
                            }
                        }
                    }

                    string menuPreventativeActive = System.Configuration.ConfigurationManager.AppSettings["MenuPreventativeActive"];
                    if (string.IsNullOrEmpty(menuPreventativeActive) ||
                        (!string.IsNullOrEmpty(menuPreventativeActive) && menuPreventativeActive.ToUpper() == "FALSE"))
                    {
                        foreach (RadMenuItem mi in RadMenu1.Items)
                        {
                            foreach (RadMenuItem ms in mi.Items)
                            {
                                if (ms.NavigateUrl.EndsWith("EHS_Incidents.aspx?mode=prevent"))
                                {
                                    ms.Visible = false;
                                }
                            }
                        }
                    }

                    string menu8DActive = System.Configuration.ConfigurationManager.AppSettings["Menu8DActive"];
                    if (!string.IsNullOrEmpty(menu8DActive) && menu8DActive.ToUpper() == "FALSE")
                    {
                        foreach (RadMenuItem mi in RadMenu1.Items)
                        {
                            foreach (RadMenuItem ms in mi.Items)
                            {
                                if (ms.NavigateUrl.Contains("Problem_Case.aspx?c=QI"))
                                {
                                    ms.Visible = false;
                                }
                            }
                        }
                    }
                }
            }

            catch (Exception ex)
            {
                // SQMLogger.LogException(ex);
            }
        }
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)
                {
                }
            }
        }
Example #11
0
        protected void btnLogin_Click(object sender, EventArgs e)
        {
            string SSOID            = tbUsername.Text;
            string pwd              = tbPassword.Text.Trim();
            bool   calcStatOfTheDay = true;

            ++LoginAttempts;

            lblLoginError_out.Visible = lblSessionError_out.Visible = false;

            string calcStat = System.Configuration.ConfigurationManager.AppSettings["CalcStatOfTheDay"];

            if (!string.IsNullOrEmpty(calcStat) && calcStat.ToLower().Contains("false"))
            {
                calcStatOfTheDay = false;
            }

            LoginStatus status = status = SessionManager.InitializeUser(SSOID, pwd, true, calcStatOfTheDay);

            if (status != LoginStatus.Success)
            {
                if (status == LoginStatus.SessionInUse)
                {
                    lblSessionError_out.Visible = true;
                }
                else
                {
                    int loginAttemptLimit = 5;
                    try
                    {
                        string limitStr = System.Configuration.ConfigurationManager.AppSettings["LoginAttemptLimit"];
                        if (!string.IsNullOrEmpty(limitStr))
                        {
                            int limit;
                            if (int.TryParse(limitStr, out limit) && limit > 0)
                            {
                                loginAttemptLimit = limit;
                            }
                        }
                    }
                    catch { }
                    if (LoginAttempts >= loginAttemptLimit)
                    {
                        tbUsername.Enabled = tbPassword.Enabled = btnLogin.Enabled = false;
                        lblLoginAttemptError_out.Visible = true;
                    }
                    else
                    {
                        lblLoginError_out.Visible = true;
                    }
                }
            }
            else if (SessionManager.UserContext.Credentials.STATUS == "P")             // AW 201310 - force password reset if forgot password
            {
                pnlLogin.Visible             = false;
                pnlLoginPasswordEdit.Visible = true;
                uclPassEdit.BindPwdEdit(true);
            }
            else
            {
                if (status == LoginStatus.SessionInUse)
                {
                    lblSessionError_out.Visible = true;
                }

                SessionManager.LoginURL = Request.Url.PathAndQuery;
                // get browser type and version
                System.Web.HttpBrowserCapabilities browser = Request.Browser;
                SessionManager.Browser   = (object)browser;
                SessionManager.UserAgent = (string)HttpContext.Current.Request.UserAgent.ToLower();

                //CheckInboxItems();
                string redirectPath = (string)ViewState["RedirectPath"];
                if (string.IsNullOrEmpty(redirectPath))
                {
                    if (UserContext.RoleAccess() == AccessMode.Limited)
                    {
                        Response.Redirect("/Home/Dashboard.aspx");
                    }
                    else
                    {
                        Response.Redirect("/Home/Calendar.aspx");
                    }
                }
                else
                {
                    Response.Redirect(redirectPath);
                }
            }
        }
        protected void rgIncidentList_ItemDataBound(object sender, GridItemEventArgs e)
        {
            if (e.Item is GridDataItem)
            {
                GridDataItem item = (GridDataItem)e.Item;
                HiddenField  hf;
                Label        lbl;

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

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

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

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

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

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

                LinkButton lb8d         = (LinkButton)e.Item.FindControl("lb8d");
                LinkButton lbEditReport = (LinkButton)e.Item.FindControl("lbEditReport");

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

                INCIDENT_ANSWER entry = data.Incident.INCIDENT_ANSWER.Where(l => l.INCIDENT_QUESTION_ID == (decimal)EHSQuestionId.Create8D).FirstOrDefault();
                if (entry != null && entry.ANSWER_VALUE == "Yes")
                {
                    if (UserContext.RoleAccess() > AccessMode.View)
                    {
                        lb8d.Visible = true;
                    }
                    else
                    {
                        lb8d.Visible = false;
                    }

                    lbEditReport.Visible = false;

                    var problemCaseId = EHSIncidentMgr.SelectProblemCaseIdByIncidentId(data.Incident.INCIDENT_ID);
                    if (problemCaseId > 0)
                    {
                        hlReport.NavigateUrl = "/EHS/EHS_Alert_PDF.aspx?pcid=" + EncryptionManager.Encrypt(problemCaseId.ToString());

                        LinkButton lbReport = (LinkButton)e.Item.FindControl("lbReport");
                        lbReport.Visible         = true;
                        lbReport.CommandArgument = problemCaseId.ToString();
                        lbReport.Attributes.Add("CaseType", data.Incident.INCIDENT_TYPE);
                    }
                }
                else
                {
                    lb8d.Visible         = false;
                    lbEditReport.Visible = true;

                    hlReport.NavigateUrl = "/EHS/EHS_Alert_PDF.aspx?iid=" + EncryptionManager.Encrypt(data.Incident.INCIDENT_ID.ToString());
                }

                if (data.Incident.ISSUE_TYPE_ID == 10)                 // Prevention Verification
                {
                    lbEditReport.Visible = false;
                    //HtmlImage imgEditReport = (HtmlImage)e.Item.FindControl("imgEditReport");
                    //imgEditReport.Visible = false;
                }

                if (rgIncidentList.MasterTableView.GetColumn("Attach").Visible&& data.AttachList != null)
                {
                    lbl = (Label)e.Item.FindControl("lblAttach");
                    Ucl_Attach attch = (Ucl_Attach)Page.LoadControl("/Include/Ucl_Attach.ascx");
                    lbl.Parent.Controls.AddAt(lbl.Parent.Controls.IndexOf(lbl), attch);
                    attch.BindListAttachment(data.AttachList, "", 1);
                }
            }
        }
        protected void rgCaseList_ItemDataBound(object sender, GridItemEventArgs e)
        {
            if (e.Item is GridHeaderItem)
            {
                GridHeaderItem gh = e.Item as GridHeaderItem;
                if (staticAppContext == "QI")
                {
                    //gh.Cells[4].Text = "";
                    //gh.Cells[4].Visible = false;
                    ;
                }
                else
                {
                    ;
                }
            }

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

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

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

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

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

                    Label lbl = (Label)e.Item.FindControl("lblCaseID");
                    lbl.Text = WebSiteCommon.FormatID(probCase.ProbCase.PROBCASE_ID, 6);
                    LinkButton lnk = (LinkButton)e.Item.FindControl("lbCaseId");
                    if (lnk != null && UserContext.RoleAccess() < AccessMode.Partner)
                    {
                        lnk.Enabled = false;
                    }


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

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