public void PopulateInitialForm()
        {
            PSsqmEntities entities = new PSsqmEntities();
            decimal       typeId   = (IsEditContext) ? EditIncidentTypeId : SelectedTypeId;

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


                    if (PageMode == PageUseMode.ViewOnly)
                    {
                        divTitle.Visible  = true;
                        lblFormTitle.Text = Resources.LocalizedText.RootCause;
                    }

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

            InitializeForm();
        }
        protected void lnkPlantView_Click(object sender, EventArgs e)
        {
            PLANT plant = (PLANT)SessionManager.EffLocation.Plant;

            TextBox tbPlantName    = (TextBox)hfBase.FindControl("tbPlantName"); tbPlantName.Text = plant.PLANT_NAME;
            TextBox tbPlantDesc    = (TextBox)hfBase.FindControl("tbPlantDesc"); tbPlantDesc.Text = plant.DISP_PLANT_NAME;
            TextBox tbPlantLocCode = (TextBox)hfBase.FindControl("tbPlantLocCode"); tbPlantLocCode.Text = plant.DUNS_CODE;

            cbTrackFinData.Checked = (bool)plant.TRACK_FIN_DATA;
            cbTrackEWData.Checked  = (bool)plant.TRACK_EW_DATA;
            Label lblLastUpdate = (Label)hfBase.FindControl("lblPlantLastUpdate"); lblLastUpdate.Text = plant.LAST_UPD_BY;

            lblPlantLastUpdateDate.Text = SQMBasePage.FormatDate(WebSiteCommon.LocalTime((DateTime)plant.LAST_UPD_DT, SessionManager.UserContext.TimeZoneID), "d", false);
            // Label lblLastUpdateDate = (Label)hfBase.FindControl("lblPlantLastUpdateDate"); lblLastUpdateDate.Text = WebSiteCommon.LocalTime((DateTime)plant.LAST_UPD_DT, SessionManager.UserContext.TimeZoneID).ToString();

            LoadPlantSelects(plant);

            if (plant.ADDRESS != null)
            {
                ADDRESS address = plant.ADDRESS.FirstOrDefault();
                if (address != null)
                {
                    tbAddress1.Text = address.STREET1;
                    tbAddress2.Text = address.STREET2;
                    tbCity.Text     = address.CITY;
                    tbState.Text    = address.STATE_PROV;
                    tbPostal.Text   = address.POSTAL_CODE;
                }
            }

            LocalOrg().EditObject = plant;
        }
Exemplo n.º 3
0
        static void UpdatePastDueAuditStatus()
        {
            string status = "";
            // get a list of all audits that do not have a close date
            List <AUDIT> openAudits = EHSAuditMgr.SelectOpenAudits(0, null);

            foreach (AUDIT audit in openAudits)
            {
                AUDIT_TYPE type      = EHSAuditMgr.SelectAuditTypeById(entities, audit.AUDIT_TYPE_ID);
                PLANT      plant     = SQMModelMgr.LookupPlant((decimal)audit.DETECT_PLANT_ID);
                DateTime   closeDT   = Convert.ToDateTime(audit.AUDIT_DT.AddDays(type.DAYS_TO_COMPLETE + 1));              // add one to the date and it will default to the next day at 00:00:00, which means midnight
                DateTime   localTime = WebSiteCommon.LocalTime(DateTime.UtcNow, plant.LOCAL_TIMEZONE);
                if (closeDT.CompareTo(localTime) < 0)
                {
                    // close the audit
                    // valid status codes... A = active, C = complete, I = incomplete/in-process, E = Expired. We are closing audits that are past due, so Expired.
                    try
                    {
                        status = audit.CURRENT_STATUS;
                        if (status != "C")
                        {
                            status = "E";
                        }
                    }
                    catch
                    {
                        status = "E";
                    }
                    EHSAuditMgr.CloseAudit(audit.AUDIT_ID, status, closeDT.AddDays(-1));                     // now take the one day back off so that the close date sets correctly
                    // now mark the Task as expired too!
                    EHSAuditMgr.CreateOrUpdateTask(audit.AUDIT_ID, (decimal)audit.AUDIT_PERSON, 50, closeDT.AddDays(-1), status, 0);
                }
            }
        }
        void InitializeForm()
        {
            lblStatusMsg.Visible = false;
            pnlContain.Visible   = true;

            LocalIncident = EHSIncidentMgr.SelectIncidentById(new PSsqmEntities(), IncidentId);
            if (LocalIncident == null)
            {
                return;
            }

            PLANT plant = SQMModelMgr.LookupPlant(entities, (decimal)LocalIncident.DETECT_PLANT_ID, "");

            if (plant != null)
            {
                IncidentLocationTZ = plant.LOCAL_TIMEZONE;
            }

            pnlContain.Visible = true;
            if (PageMode == PageUseMode.ViewOnly)
            {
                divTitle.Visible  = true;
                lblFormTitle.Text = Resources.LocalizedText.InitialAction;
            }

            rptContain.DataSource = EHSIncidentMgr.GetContainmentList(IncidentId, WebSiteCommon.LocalTime(DateTime.UtcNow, IncidentLocationTZ), PageMode == PageUseMode.ViewOnly ? false : true);
            rptContain.DataBind();

            pnlContain.Enabled = PageMode == PageUseMode.ViewOnly ? false : EHSIncidentMgr.CanUpdateIncident(LocalIncident, IsEditContext, SysPriv.originate, LocalIncident.INCFORM_LAST_STEP_COMPLETED);
        }
        protected void SaveLine()
        {
            PLANT plant = (PLANT)SessionManager.EffLocation.Plant;
            bool  success;

            if (uclAdminEdit.IsNew)
            {
                PLANT_LINE lineNew = new PLANT_LINE();
                lineNew = uclAdminEdit.ReadPlantLine(lineNew);
                SQMModelMgr.CreatePlantLine(entities, plant, lineNew, SessionManager.UserContext.UserName());
                // plant.PLANT_LINE.Load();
            }
            else
            {
                PLANT_LINE line = (PLANT_LINE)LocalOrg().EditObject;
                line = SQMModelMgr.LookupPlantLine(entities, line.PLANT_ID, line.PLANT_LINE_ID, "", false);
                line = uclAdminEdit.ReadPlantLine(line);
                PLANT_LINE lineExisting = SQMModelMgr.UpdatePlantLine(entities, line, SessionManager.UserContext.UserName());
                //PLANT_LINE lineExisting = SQMModelMgr.FindPlantLine(entities, plant, line.PLANT_LINE_ID, "", false);
                lineExisting.PLANT_LINE_NAME = line.PLANT_LINE_NAME;
                lineExisting.DOWNTIME_RATE   = line.DOWNTIME_RATE;
                lineExisting.STATUS          = line.STATUS;
            }

            SessionManager.EffLocation.Plant = plant;
            LocalOrg().EditObject            = null;
            DoLineList();
            pnlAdminEdit.Visible = false;
        }
        public void rptCO2Report_OnItemDataBound(object sender, RepeaterItemEventArgs e)
        {
            if (e.Item.ItemType == ListItemType.AlternatingItem || e.Item.ItemType == ListItemType.Item)
            {
                try
                {
                    PLANT plant = (PLANT)e.Item.DataItem;

                    Label lbl = (Label)e.Item.FindControl("lblLocation");
                    lbl.Text = plant.PLANT_NAME;

                    Repeater rpt = (Repeater)e.Item.FindControl("rptScope1Fuel");
                    List <EHSModel.GHGResult> fuelList = LocalGHGResultList().ResultList.Where(l => l.Plant.PLANT_ID == plant.PLANT_ID).ToList();
                    rpt.DataSource = fuelList.Where(l => l.EFMType != "P" && l.EFMType != "HW" && l.EFMType != "STEAM" && l.GasSeq == 1).Distinct().ToList();
                    rpt.DataBind();

                    rpt            = (Repeater)e.Item.FindControl("rptScope2Fuel");
                    rpt.DataSource = fuelList.Where(l => l.EFMType == "P" || l.EFMType == "HW" || l.EFMType == "STEAM" && l.GasSeq == 1).Distinct().ToList();
                    rpt.DataBind();
                }
                catch
                {
                    ;
                }
            }
        }
Exemplo n.º 7
0
        protected void lnkDisplayCustParts(object sender, EventArgs e)
        {
            PLANT      plant = (PLANT)SessionManager.EffLocation.Plant;
            CheckBox   cb;
            LinkButton lnk   = (LinkButton)sender;
            string     cmdID = lnk.CommandArgument;

            foreach (RepeaterItem r in rptCustPartHeader.Items)
            {
                Repeater rd = (Repeater)r.FindControl("rptCustPartDetail");
                lnk = (LinkButton)rd.Items[0].FindControl("lnkPartList");
                if (lnk.CommandArgument == cmdID)
                {
                    Ucl_PartList uclPartList = (Ucl_PartList)rd.Items[0].FindControl("uclPartList");
                    cb         = (CheckBox)rd.Items[0].FindControl("cbPartListSelect");
                    cb.Checked = cb.Checked == false ? true : false;
                    if (cb.Checked && !string.IsNullOrEmpty(lnk.CommandArgument))
                    {
                        uclPartList.BindPartList(SQMModelMgr.SelectTradingRelationshipList(new PSsqmEntities(), SessionManager.SessionContext.PrimaryCompany.COMPANY_ID, plant.PLANT_ID, 0, 1, Convert.ToDecimal(lnk.CommandArgument)));
                    }
                    else
                    {
                        uclPartList.BindPartList(null);
                    }
                }
            }
        }
        public void PopulateInitialForm()
        {
            PSsqmEntities entities = new PSsqmEntities();

            IncidentId = (IsEditContext) ? IncidentId : NewIncidentId;

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

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

                decimal typeId = (IsEditContext) ? EditIncidentTypeId : SelectedTypeId;

                // what the f**k does this do ?
                //formSteps = EHSIncidentMgr.GetStepsForincidentTypeId(typeId);
                //totalFormSteps = formSteps.Count();

                InitializeForm();
            }
        }
        protected void btnStatusSave_Click(object sender, EventArgs e)
        {
            Button btn = (Button)sender;

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

            string[] cmd = btn.CommandArgument.Split('~');             // recordType, recordID, recordSubID, taskStep, taskType

            EHSAuditQuestion auditQuestion = EHSAuditMgr.SelectAuditQuestion(Convert.ToInt32(cmd[0]), Convert.ToDecimal(cmd[1]));

            if (auditQuestion != null)
            {
                auditQuestion.Status            = ddlAnswerStatus.SelectedValue.ToString();
                auditQuestion.ResolutionComment = tbResolutionComment.Text.ToString();
                if (auditQuestion.Status.Equals("03"))
                {
                    // update the complete date with the local date/time of the plant
                    AUDIT    audit     = EHSAuditMgr.SelectAuditById(entities, auditQuestion.AuditId);
                    PLANT    plant     = SQMModelMgr.LookupPlant((decimal)audit.DETECT_PLANT_ID);
                    DateTime localTime = WebSiteCommon.LocalTime(DateTime.UtcNow, plant.LOCAL_TIMEZONE);
                    auditQuestion.CompleteDate = localTime;
                }
                EHSAuditMgr.UpdateAnswer(auditQuestion);
            }
            UpdateTaskList("update");
        }
Exemplo n.º 10
0
 public static BusinessLocation SetEffLocationPlant(PLANT plant)
 {
     if (EffLocation != null && plant != null)
     {
         EffLocation.Plant = plant;
     }
     return(SessionManager.EffLocation);
 }
Exemplo n.º 11
0
 public EHSProfile LoadPlantProfile(PLANT plant)
 {
     staticProfile = new EHSProfile().Load(plant.PLANT_ID, true);
     ToggleVisible(pnlEHSProfile);
     SetupProfilePanel();
     BindProfile(staticProfile);
     return(staticProfile);
 }
        private void DoLaborList()
        {
            PLANT plant = (PLANT)SessionManager.EffLocation.Plant;

            LocalOrg().LaborList = SQMModelMgr.SelectLaborTypeList(entities, (decimal)plant.COMPANY_ID, (decimal)plant.BUS_ORG_ID, plant.PLANT_ID);

            uclSubLists.BindLaborList(LocalOrg().LaborList);
        }
Exemplo n.º 13
0
        public void rptProgramPart_OnItemDataBound(object sender, RepeaterItemEventArgs e)
        {
            if (e.Item.ItemType == ListItemType.AlternatingItem || e.Item.ItemType == ListItemType.Item)
            {
                try
                {
                    PartData partData = (PartData)e.Item.DataItem;
                    PLANT    plant    = null;
                    Label    lbl1     = (Label)e.Item.FindControl("lblPartSource");
                    Label    lbl2     = (Label)e.Item.FindControl("lblPartSourceCode");

                    if (partData.Used.SUPP_PLANT_ID.HasValue)
                    {
                        if ((plant = staticPlantList.Where(l => l.PLANT_ID == partData.Used.SUPP_PLANT_ID).SingleOrDefault()) == null)
                        {
                            staticPlantList.Add((plant = SQMModelMgr.LookupPlant((decimal)partData.Used.SUPP_PLANT_ID)));
                        }
                        lbl1.Text = plant.PLANT_NAME;
                        lbl2.Text = plant.ADDRESS.FirstOrDefault().CITY;
                    }
                    else
                    {
                        if ((plant = staticPlantList.Where(l => l.PLANT_ID == partData.Used.PLANT_ID).SingleOrDefault()) == null)
                        {
                            staticPlantList.Add((plant = SQMModelMgr.LookupPlant((decimal)partData.Used.PLANT_ID)));
                        }
                        lbl1.Text = plant.PLANT_NAME;
                        lbl2.Text = plant.DUNS_CODE;
                    }

                    lbl1 = (Label)e.Item.FindControl("lblPartUsed");
                    lbl2 = (Label)e.Item.FindControl("lblPartUsedCode");
                    if (partData.Used.CUST_PLANT_ID.HasValue)
                    {
                        if ((plant = staticPlantList.Where(l => l.PLANT_ID == partData.Used.CUST_PLANT_ID).SingleOrDefault()) == null)
                        {
                            staticPlantList.Add((plant = SQMModelMgr.LookupPlant((decimal)partData.Used.CUST_PLANT_ID)));
                        }
                        lbl1.Text = plant.PLANT_NAME;
                        lbl2.Text = plant.ADDRESS.FirstOrDefault().CITY;
                    }
                    else
                    {
                        if ((plant = staticPlantList.Where(l => l.PLANT_ID == partData.Used.PLANT_ID).SingleOrDefault()) == null)
                        {
                            staticPlantList.Add((plant = SQMModelMgr.LookupPlant((decimal)partData.Used.PLANT_ID)));
                        }
                        lbl1.Text = plant.PLANT_NAME;
                        lbl2.Text = plant.DUNS_CODE;
                    }

                    GridView gv = (GridView)e.Item.FindControl("gvProgramPartList");
                    gv.DataSource = staticPartList.Where(l => l.Used.PLANT_ID == partData.Used.PLANT_ID && l.Used.SUPP_PLANT_ID == partData.Used.SUPP_PLANT_ID && l.Used.CUST_PLANT_ID == partData.Used.CUST_PLANT_ID).ToList();
                    gv.DataBind();
                }
                catch { }
            }
        }
Exemplo n.º 14
0
        private void SetupPage()
        {
            PLANT        plant  = (PLANT)SessionManager.EffLocation.Plant;
            BUSINESS_ORG busOrg = (BUSINESS_ORG)SessionManager.EffLocation.BusinessOrg;

            isEditMode            = false;
            LocalOrg().EditObject = null;
            DropDownList ddl;

            HiddenField hdCurrentActiveTab = (HiddenField)this.Form.Parent.FindControl("form1").FindControl("ContentPlaceHolder1").FindControl("hdCurrentActiveSecondaryTab");

            uclItemHdr.DisplayPlant(busOrg, plant);

            List <BUSINESS_ORG> parent_orgs = SQMModelMgr.SelectBusOrgList(entities, SessionManager.EffLocation.Company.COMPANY_ID, 0, true);

            ddl                = (DropDownList)hfBase.FindControl("ddlParentBusOrg");
            ddl.DataSource     = parent_orgs;
            ddl.DataTextField  = "ORG_NAME";
            ddl.DataValueField = "BUS_ORG_ID";
            ddl.DataBind();
            ddl.SelectedIndex = 0;

            if (SessionManager.EffLocation != null && SessionManager.EffLocation.BusinessOrg != null && ddl.Items.FindByValue(SessionManager.EffLocation.BusinessOrg.BUS_ORG_ID.ToString()) != null)
            {
                ddl.SelectedValue = SessionManager.EffLocation.BusinessOrg.BUS_ORG_ID.ToString();
            }

            ddlLocationType.Items.AddRange(WebSiteCommon.PopulateDropDownListItems("locationType"));

            ddlCountryCode.Items.AddRange(WebSiteCommon.PopulateDropDownListItems("countryCode"));
            ddlCountryCode.Items.Insert(0, new ListItem("", ""));

            ddlPowerSourcedRegion.Items.AddRange(WebSiteCommon.PopulateDropDownListItems("powerSourcedRegion"));
            ddlPowerSourcedRegion.Items.Insert(0, new ListItem("", ""));

            ddl = (DropDownList)hfBase.FindControl("ddlPlantCurrencyCodes");
            SQMBasePage.FillCurrencyDDL(ddl, "USD");

            ddl = (DropDownList)hfBase.FindControl("ddlPlantTimezone");
            List <Settings> time_zones = SQMSettings.TimeZone;

            ddl.DataSource     = time_zones;
            ddl.DataTextField  = "long_desc";
            ddl.DataValueField = "code";
            ddl.DataBind();
            ddl.SelectedValue = "035";

            ddlLocalLanguage.DataSource     = SQMModelMgr.SelectLanguageList(entities, true);
            ddlLocalLanguage.DataTextField  = "LANGUAGE_NAME";
            ddlLocalLanguage.DataValueField = "LANGUAGE_ID";
            ddlLocalLanguage.DataBind();
            ddlLocalLanguage.SelectedIndex = 0;

            SetStatusList("ddlPlantStatus", "A");

            tab_Click("lbPLantDetail_tab", "");
        }
Exemplo n.º 15
0
        protected void lnkPlantView_Click(object sender, EventArgs e)
        {
            PLANT plant = (PLANT)SessionManager.EffLocation.Plant;

            TextBox tbPlantName    = (TextBox)hfBase.FindControl("tbPlantName"); tbPlantName.Text = plant.PLANT_NAME;
            TextBox tbPlantDesc    = (TextBox)hfBase.FindControl("tbPlantDesc"); tbPlantDesc.Text = plant.DISP_PLANT_NAME;
            TextBox tbPlantLocCode = (TextBox)hfBase.FindControl("tbPlantLocCode"); tbPlantLocCode.Text = plant.DUNS_CODE;
            TextBox tbAltPlantCode = (TextBox)hfBase.FindControl("tbAltPlantCode"); tbAltPlantCode.Text = plant.ALT_DUNS_CODE;

            cbTrackFinData.Checked = (bool)plant.TRACK_FIN_DATA;
            cbTrackEWData.Checked  = (bool)plant.TRACK_EW_DATA;
            Label lblLastUpdate = (Label)hfBase.FindControl("lblPlantLastUpdate"); lblLastUpdate.Text = plant.LAST_UPD_BY;

            lblPlantLastUpdateDate.Text = SQMBasePage.FormatDate(WebSiteCommon.LocalTime((DateTime)plant.LAST_UPD_DT, SessionManager.UserContext.TimeZoneID), "d", false);
            // Label lblLastUpdateDate = (Label)hfBase.FindControl("lblPlantLastUpdateDate"); lblLastUpdateDate.Text = WebSiteCommon.LocalTime((DateTime)plant.LAST_UPD_DT, SessionManager.UserContext.TimeZoneID).ToString();

            LoadPlantSelects(plant);

            if (plant.ADDRESS != null)
            {
                ADDRESS address = plant.ADDRESS.FirstOrDefault();
                if (address != null)
                {
                    tbAddress1.Text = address.STREET1;
                    tbAddress2.Text = address.STREET2;
                    tbCity.Text     = address.CITY;
                    tbState.Text    = address.STATE_PROV;
                    tbPostal.Text   = address.POSTAL_CODE;
                }
            }

            int[] recList = new int[5] {
                30, 40, 45, 50, 90
            };
            PLANT_ACTIVE        pa = null;
            List <PLANT_ACTIVE> plantActiveList = new List <PLANT_ACTIVE>();

            foreach (int recType in recList)
            {
                PLANT_ACTIVE plantActive = new PLANT_ACTIVE();
                plantActive.PLANT_ID     = plant.PLANT_ID;
                plantActive.RECORD_TYPE  = recType;
                plantActive.ENABLE_EMAIL = true;
                if ((pa = plant.PLANT_ACTIVE.Where(p => p.RECORD_TYPE == recType).FirstOrDefault()) != null)
                {
                    plantActive.EFF_START_DATE       = pa.EFF_START_DATE;
                    plantActive.EFF_END_DATE         = pa.EFF_END_DATE;
                    plantActive.ENABLE_EMAIL         = pa.ENABLE_EMAIL;
                    plantActive.ENABLE_INACTIVE_HIST = pa.ENABLE_INACTIVE_HIST;
                }
                plantActiveList.Add(plantActive);
            }
            BindPlantActive(plantActiveList);

            LocalOrg().EditObject = plant;
        }
        private void DoSuppList()
        {
            PLANT plant = (PLANT)SessionManager.EffLocation.Plant;

            LocalOrg().PersonList = SQMModelMgr.SelectPlantPersonList((decimal)plant.COMPANY_ID, plant.PLANT_ID, "SQM");
            List <PartData> tradeList = SQMModelMgr.SelectTradingRelationshipList(entities, SessionManager.SessionContext.PrimaryCompany.COMPANY_ID, plant.PLANT_ID, 0, 2, 0);

            pnlB2B.Visible = true;
            uclCustList.BindSuppPartList(tradeList, LocalOrg().PersonList);
        }
        protected void uclAdminList_OnLaborClick(decimal laborID)
        {
            PLANT      plant = (PLANT)SessionManager.EffLocation.Plant;
            LABOR_TYPE labor = SQMModelMgr.LookupLaborType(entities, (decimal)plant.COMPANY_ID, (decimal)plant.BUS_ORG_ID, plant.PLANT_ID, laborID, "", false);

            uclSubLists.ToggleVisible(null);
            pnlAdminEdit.Visible = true;
            uclAdminEdit.BindLaborType(labor);
            LocalOrg().EditObject = labor;
        }
        protected void uclAdminList_OnDeptClick(decimal deptID)
        {
            PLANT      plant = (PLANT)SessionManager.EffLocation.Plant;
            DEPARTMENT dept  = SQMModelMgr.LookupDepartment(entities, (decimal)plant.COMPANY_ID, (decimal)plant.BUS_ORG_ID, (decimal)plant.PLANT_ID, deptID, "", false);

            uclSubLists.ToggleVisible(null);
            pnlAdminEdit.Visible = true;
            uclAdminEdit.BindDeptartment(dept);
            LocalOrg().EditObject = dept;
        }
Exemplo n.º 19
0
        protected decimal CreateReAudit(decimal auditId)
        {
            decimal       reauditId = 0;
            PSsqmEntities entities  = new PSsqmEntities();

            AUDIT oldAudit = EHSAuditMgr.SelectAuditById(entities, auditId);

            if (oldAudit != null)
            {
                // create the copy
                PLANT    auditPlant = SQMModelMgr.LookupPlant((decimal)oldAudit.DETECT_PLANT_ID);
                DateTime localTime  = WebSiteCommon.LocalTime(DateTime.UtcNow, auditPlant.LOCAL_TIMEZONE);
                AUDIT    reAudit    = new AUDIT()
                {
                    DETECT_COMPANY_ID = Convert.ToDecimal(oldAudit.DETECT_COMPANY_ID),
                    DETECT_BUS_ORG_ID = oldAudit.DETECT_BUS_ORG_ID,
                    DETECT_PLANT_ID   = oldAudit.DETECT_PLANT_ID,
                    DEPT_ID           = oldAudit.DEPT_ID,
                    AUDIT_TYPE        = oldAudit.AUDIT_TYPE,
                    CREATE_DT         = localTime,
                    CREATE_BY         = SessionManager.UserContext.Person.FIRST_NAME + " " + SessionManager.UserContext.Person.LAST_NAME,
                    DESCRIPTION       = oldAudit.DESCRIPTION,
                    CREATE_PERSON     = SessionManager.UserContext.Person.PERSON_ID,                 // do we want to set this to admin?
                    AUDIT_DT          = localTime,
                    AUDIT_TYPE_ID     = oldAudit.AUDIT_TYPE_ID,
                    AUDIT_PERSON      = SessionManager.UserContext.Person.PERSON_ID,
                    CURRENT_STATUS    = "A",
                    PERCENT_COMPLETE  = 0,
                    TOTAL_SCORE       = 0,
                    AUDITING_ID       = auditId
                };

                entities.AddToAUDIT(reAudit);
                entities.SaveChanges();
                reauditId = reAudit.AUDIT_ID;

                AUDIT_ANSWER            answer    = null;
                List <EHSAuditQuestion> questions = EHSAuditMgr.SelectAuditQuestionList(reAudit.AUDIT_TYPE_ID, 0, auditId);
                foreach (var q in questions)
                {
                    answer = new AUDIT_ANSWER()
                    {
                        AUDIT_ID               = reauditId,
                        AUDIT_QUESTION_ID      = q.QuestionId,
                        ANSWER_VALUE           = "",
                        ORIGINAL_QUESTION_TEXT = q.QuestionText,
                        //COMMENT = q.AnswerComment
                    };
                    entities.AddToAUDIT_ANSWER(answer);
                }
                entities.SaveChanges();
            }

            return(reauditId);
        }
Exemplo n.º 20
0
 public void DisplayPlant(BUSINESS_ORG busOrg, PLANT plant)
 {
     pnlPlantHdr.Visible      = true;
     lblPlantOrgName_out.Text = busOrg.ORG_NAME;
     if (plant != null)
     {
         lblPlantName_out.Text    = plant.PLANT_NAME;
         lblLocCodePlant_out.Text = plant.DUNS_CODE;
         lblLocationType_out.Text = WebSiteCommon.GetXlatValue("locationType", plant.LOCATION_TYPE);
     }
 }
Exemplo n.º 21
0
        private void LoadPlantSelects(PLANT plant)
        {
            List <BUSINESS_ORG> parent_orgs = SQMModelMgr.SelectBusOrgList(entities, SessionManager.EffLocation.Company.COMPANY_ID, 0, true);
            DropDownList        ddl         = (DropDownList)hfBase.FindControl("ddlParentBusOrg");

            if (plant.BUS_ORG_ID > 0)
            {
                ddl.SelectedValue = plant.BUS_ORG_ID.ToString();
            }

            if (ddlLocationType.Items.FindByValue(plant.LOCATION_TYPE) != null)
            {
                ddlLocationType.SelectedValue = plant.LOCATION_TYPE;
            }

            if (ddlCountryCode.Items.FindByValue(plant.LOCATION_CODE) != null)
            {
                ddlCountryCode.SelectedValue = plant.LOCATION_CODE;
            }

            if (ddlPowerSourcedRegion.Items.FindByValue(plant.COMP_INT_ID) != null)
            {
                ddlPowerSourcedRegion.SelectedValue = plant.COMP_INT_ID;
            }

            if (ddlLocalLanguage.Items.FindByValue(plant.LOCAL_LANGUAGE.ToString()) != null)
            {
                ddlLocalLanguage.SelectedValue = plant.LOCAL_LANGUAGE.ToString();
            }

            ddl = (DropDownList)hfBase.FindControl("ddlPlantCurrencyCodes");
            if (!string.IsNullOrEmpty(plant.CURRENCY_CODE))
            {
                ddl.SelectedValue = plant.CURRENCY_CODE;
            }

            ddl = (DropDownList)hfBase.FindControl("ddlPlantTimezone");
            if (!string.IsNullOrEmpty(plant.LOCAL_TIMEZONE))
            {
                ddl.SelectedValue = plant.LOCAL_TIMEZONE;
            }

            /*
             * ddl = (DropDownList)hfBase.FindControl("ddlPlantLanguage");
             * if (plant.LOCAL_LANGUAGE.HasValue)
             *   ddl.SelectedValue = plant.LOCAL_LANGUAGE.ToString();
             */
            SetStatusList("ddlPlantStatus", plant.STATUS);
        }
Exemplo n.º 22
0
        protected void lnkSaveSupp(object sender, EventArgs e)
        {
            PLANT         plant  = (PLANT)SessionManager.EffLocation.Plant;
            LinkButton    lnk    = (LinkButton)sender;
            string        cmdID  = lnk.CommandArgument;
            PSsqmEntities ctx    = new PSsqmEntities();
            NOTIFY        notify = null;

            foreach (RepeaterItem r in rptCustPartHeader.Items)
            {
                Repeater rd = (Repeater)r.FindControl("rptSuppPartDetail");
                lnk = (LinkButton)rd.Items[0].FindControl("lnkSaveSupp");
                if (lnk.CommandArgument == cmdID)
                {
                    RadComboBox ddl1 = (RadComboBox)rd.Items[0].FindControl("ddlQSNotify1");
                    RadComboBox ddl2 = (RadComboBox)rd.Items[0].FindControl("ddlQSNotify2");
                    HiddenField hf   = (HiddenField)rd.Items[0].FindControl("hfQSNotify");
                    notify = null;
                    if (!string.IsNullOrEmpty(hf.Value))
                    {
                        notify = SQMModelMgr.LookupNotifyRecord(ctx, Convert.ToDecimal(hf.Value));
                    }
                    if (notify == null)
                    {
                        notify = SQMModelMgr.CreateNotifyRecord(SessionManager.EffLocation.Company.COMPANY_ID, 0, SessionManager.EffLocation.Plant.PLANT_ID, TaskRecordType.SupplierQualityIncident, Convert.ToDecimal(cmdID));
                    }
                    if (ddl1.SelectedIndex < 1)
                    {
                        notify.NOTIFY_PERSON1 = null;
                    }
                    else
                    {
                        notify.NOTIFY_PERSON1 = Convert.ToDecimal(ddl1.SelectedValue);
                    }

                    if (ddl2.SelectedIndex < 1)
                    {
                        notify.NOTIFY_PERSON2 = null;
                    }
                    else
                    {
                        notify.NOTIFY_PERSON2 = Convert.ToDecimal(ddl2.SelectedValue);
                    }

                    int status = SQMModelMgr.UpdateNotifyRecord(ctx, notify);
                }
            }
        }
Exemplo n.º 23
0
 public EHSProfile LoadPlantProfile(PLANT plant)
 {
     SetLocalProfile(new EHSProfile().Load(plant.PLANT_ID, true, false));
     if (LocalProfile().Profile != null)
     {
         uclInputHdr.BindProfileSelectHdr(LocalProfile());
         SetupProfilePanel();
         BindProfile(LocalProfile());
         DisplayProfileMessage(null);
     }
     else
     {
         DisplayProfileMessage(lblProfileError);
     }
     return(LocalProfile());
 }
        protected void Page_Load(object sender, EventArgs e)
        {
            companyId = SessionManager.UserContext.WorkingLocation.Company.COMPANY_ID;

            if (Request.QueryString["inid"] != null && Request.QueryString["peid"] != null && Request.QueryString["plid"] != null)
            {
                incidentId = Convert.ToDecimal(Request.QueryString["inid"]);
                personId   = Convert.ToDecimal(Request.QueryString["peid"]);
                plantId    = Convert.ToDecimal(Request.QueryString["plid"]);

                if (personId == SessionManager.UserContext.Person.PERSON_ID)
                {
                    INCIDENT incident = (from v in entities.INCIDENT_VERIFICATION
                                         where
                                         v.INCIDENT_ID == incidentId &&
                                         v.PERSON_ID == personId &&
                                         v.PLANT_ID == plantId
                                         select(from i in entities.INCIDENT
                                                where
                                                i.INCIDENT_ID == incidentId
                                                select i).FirstOrDefault()
                                         ).FirstOrDefault();
                    PLANT plant = (from p in entities.PLANT where p.PLANT_ID == plantId select p).FirstOrDefault();

                    lblPlantLocation.Text        = plant.DISP_PLANT_NAME;
                    lblIncidentDate.Text         = incident.INCIDENT_DT.ToShortDateString();
                    lblIncidentInstructions.Text = incident.DESCRIPTION;

                    decimal probCaseId = (decimal)incident.VERIFY_PROBCASE_ID;

                    PopulateComments();

                    lblFullName.Text = SessionManager.UserContext.Person.FIRST_NAME + " " + SessionManager.UserContext.Person.LAST_NAME;

                    ltrDownloadReport.Text = BuildReport(probCaseId);
                    CheckSubmitDisabled();
                }
                else
                {
                    lblPageInstructions.Text = "INVALID ACCESS LEVEL.";
                    divPageBody.Visible      = false;
                }
            }
        }
Exemplo n.º 25
0
        protected void lnkSaveSupp(object sender, EventArgs e)
        {
            PLANT         plant = (PLANT)SessionManager.EffLocation.Plant;
            LinkButton    lnk   = (LinkButton)sender;
            string        cmdID = lnk.CommandArgument;
            PSsqmEntities ctx   = new PSsqmEntities();

            foreach (RepeaterItem r in rptCustPartHeader.Items)
            {
                Repeater rd = (Repeater)r.FindControl("rptSuppPartDetail");
                lnk = (LinkButton)rd.Items[0].FindControl("lnkSaveSupp");
                if (lnk.CommandArgument == cmdID)
                {
                    RadComboBox ddl1 = (RadComboBox)rd.Items[0].FindControl("ddlQSNotify1");
                    RadComboBox ddl2 = (RadComboBox)rd.Items[0].FindControl("ddlQSNotify2");
                    HiddenField hf   = (HiddenField)rd.Items[0].FindControl("hfQSNotify");
                }
            }
        }
        protected AUDIT_SCHEDULER UpdateAuditScheduler(decimal auditScheduleId)
        {
            AUDIT_SCHEDULER scheduler  = (from i in entities.AUDIT_SCHEDULER where i.AUDIT_SCHEDULER_ID == auditScheduleId select i).FirstOrDefault();
            PLANT           auditPlant = SQMModelMgr.LookupPlant(Convert.ToDecimal(hdnAuditLocation.Value.ToString()));

            if (scheduler != null)
            {
                scheduler.PLANT_ID      = auditPlant.PLANT_ID;
                scheduler.AUDIT_TYPE_ID = Convert.ToDecimal(rddlAuditType.SelectedValue.ToString());
                scheduler.DAY_OF_WEEK   = Convert.ToInt32(rddlDayOfWeek.SelectedValue.ToString());
                scheduler.JOBCODE_CD    = rddlAuditJobcodes.SelectedValue.ToString();
                scheduler.INACTIVE      = cbInactive.Checked;
                scheduler.UPDATE_DT     = DateTime.Now;
                scheduler.UPDATE_PERSON = SessionManager.UserContext.Person.PERSON_ID;
                entities.SaveChanges();
            }

            return(scheduler);
        }
Exemplo n.º 27
0
        public CalcsResult DaysElapsedLTC(COMPANY company, decimal[] plantArray)
        {
            CalcsResult results = new CalcsResult().Initialize();

            SQMMetricMgr metricMgr = new SQMMetricMgr().CreateNew(company, "HS", DateTime.Now, DateTime.Now, plantArray).Load(DateIntervalType.fuzzy, DateSpanOption.SelectRange);

            metricMgr.CalcsMethods(plantArray, "HS", "63", SStat.deltaDy.ToString(), 5, 1);
            results = metricMgr.ehsCtl.Results;
            if (!results.ValidResult)
            {
                PLANT plant = SQMModelMgr.LookupPlant(plantArray[0]);
                if (plant != null && plant.PLANT_START_DT.HasValue)
                {
                    results.Result      = (decimal)Math.Truncate(DateTime.Now.Subtract((DateTime)plant.PLANT_START_DT).TotalDays);
                    results.ValidResult = true;
                }
            }
            return(results);
        }
Exemplo n.º 28
0
        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");
            }
        }
Exemplo n.º 29
0
        public static int NotifyIncidentTaskAssigment(INCIDENT incident, TASK_STATUS theTask, string scopeAction)
        {
            int    status = 0;
            PLANT  plant  = SQMModelMgr.LookupPlant((decimal)incident.DETECT_PLANT_ID);
            PERSON person = SQMModelMgr.LookupPerson((decimal)theTask.RESPONSIBLE_ID, "");

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

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

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

            return(status);
        }
        protected AUDIT_SCHEDULER CreateNewAuditScheduler()
        {
            decimal auditScheduleId   = 0;
            PLANT   auditPlant        = SQMModelMgr.LookupPlant(Convert.ToDecimal(hdnAuditLocation.Value.ToString()));
            var     newAuditScheduler = new AUDIT_SCHEDULER()
            {
                DAY_OF_WEEK   = Convert.ToInt32(rddlDayOfWeek.SelectedValue.ToString()),
                INACTIVE      = false,
                JOBCODE_CD    = rddlAuditJobcodes.SelectedValue.ToString(),
                PLANT_ID      = auditPlant.PLANT_ID,
                CREATE_DT     = DateTime.Now,
                CREATE_PERSON = SessionManager.UserContext.Person.PERSON_ID,
                AUDIT_TYPE_ID = auditTypeId
            };

            entities.AddToAUDIT_SCHEDULER(newAuditScheduler);
            entities.SaveChanges();
            auditScheduleId = newAuditScheduler.AUDIT_SCHEDULER_ID;

            return(newAuditScheduler);
        }