コード例 #1
0
        protected void btnMetricSave_Click(object sender, EventArgs e)
        {
            bool success;
            EHS_PROFILE_MEASURE pm = null;

            if (hfOper.Value == "add")
            {
                pm = staticProfile.AddMeasure(Convert.ToDecimal(WebSiteCommon.ParseItemValue(ddlMetricID.SelectedValue)), Convert.ToDecimal(ddlMetricResponsible.SelectedValue));
            }
            else
            {
                pm = staticProfile.Profile.EHS_PROFILE_MEASURE.FirstOrDefault(l => l.PRMR_ID == staticProfileMeasure.PRMR_ID);
            }

            pm.PLANT_ID   = staticProfile.Profile.PLANT_ID;
            pm.MEASURE_ID = Convert.ToDecimal(WebSiteCommon.ParseItemValue(ddlMetricID.SelectedValue));
            //pm.EHS_MEASURE = EHSModel.LookupEHSMeasure(new PSsqmEntities(), pm.MEASURE_ID, "");
            pm.MEASURE_PROMPT        = tbMetricPrompt.Text;
            pm.REG_STATUS            = ddlMetricRegStatus.SelectedValue;
            pm.UN_CODE               = ddlMetricDisposalCode.SelectedValue;
            pm.DEFAULT_CURRENCY_CODE = ddlMetricCurrency.SelectedValue;
            if (ddlMetricResponsible.SelectedIndex > 0)
            {
                pm.RESPONSIBLE_ID = Convert.ToDecimal(ddlMetricResponsible.SelectedValue);
            }
            else
            {
                pm.RESPONSIBLE_ID = Convert.ToDecimal(null);
            }

            pm.IS_REQUIRED       = cbMetricRequired.Checked;
            pm.NEG_VALUE_ALLOWED = cbMetricNegValue.Checked;

            if (cbUserUOM.Checked)
            {
                staticUOM.UOM_CATEGORY = "CUST";
                staticUOM.UOM_CD       = tbUserUOMCode.Text;
                staticUOM.UOM_NAME     = staticUOM.UOM_DESC = tbUserUOMName.Text;
                staticUOM.OWNER_ID     = staticProfile.Plant.PLANT_ID;
                double conversionFactor = 0;
                double.TryParse(tbUserUOMConversionFactor.Text.Trim(), out conversionFactor);
                if ((staticUOM = SQMResourcesMgr.UpdateUOM(new PSsqmEntities(), staticUOM, Convert.ToDecimal(WebSiteCommon.ParseItemValue(ddlUserUOMConvertTo.SelectedValue)), conversionFactor)) != null)
                {
                    SessionManager.UOMList.Add(staticUOM);
                    ddlMetricUOM.Items.Add(new ListItem(staticUOM.UOM_NAME, WebSiteCommon.PackItemValue(staticUOM.UOM_CATEGORY, staticUOM.UOM_ID.ToString())));
                    pm.DEFAULT_UOM = staticUOM.UOM_ID;
                }
                cbUserUOM.Checked = false;
            }
            else
            {
                pm.DEFAULT_UOM = Convert.ToDecimal(WebSiteCommon.ParseItemValue(ddlMetricUOM.SelectedValue));
            }

            BindProfile(staticProfile);
        }
コード例 #2
0
        private void SetupProfilePanel()
        {
            if (ddlMetricDisposalCode.Items.Count == 0)
            {
                ddlDayDue.Items.AddRange(WebSiteCommon.PopulateDropDownListNums(1, 31));
                ddlWarningDays.Items.AddRange(WebSiteCommon.PopulateDropDownListNums(0, 11));

                disposalList = EHSModel.SelectDisposalCodeList(true);
                ddlMetricDisposalCode.DataSource     = disposalList;
                ddlMetricDisposalCode.DataValueField = "UN_CODE";
                ddlMetricDisposalCode.DataTextField  = "UN_CODE";
                ddlMetricDisposalCode.DataBind();
                ddlMetricDisposalCode.Items.Insert(0, new ListItem(""));

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

                ddlMetricResponsible.DataSource     = SQMModelMgr.SelectPersonList(SessionManager.ActiveCompany().COMPANY_ID, 0, false);
                ddlMetricResponsible.DataValueField = "PERSON_ID";
                ddlMetricResponsible.DataTextField  = "EMAIL";
                ddlMetricResponsible.DataBind();
                ddlMetricResponsible.Items.Insert(0, new ListItem(""));
                ddlMetricResponsible.SelectedIndex = 0;

                ddlMetricCurrency.Items.AddRange(WebSiteCommon.PopulateDropDownListItems("currencyCode", "long"));
                ddlMetricCurrency.SelectedValue = "EUR";

                ddlMetricStatus.Items.AddRange(WebSiteCommon.PopulateDropDownListItems("statusCode"));

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

                measureList = EHSModel.SelectEHSMeasureList("", true);
                foreach (EHS_MEASURE measure in measureList)
                {
                    ddlMetricID.Items.Add(new ListItem(measure.MEASURE_NAME, WebSiteCommon.PackItemValue(measure.MEASURE_CATEGORY, measure.MEASURE_ID.ToString())));
                }
                ddlMetricID.Items.Insert(0, "");


                foreach (UOM uom in SessionManager.UOMList)
                {
                    if (uom.OWNER_ID.HasValue == false)
                    {
                        ddlMetricUOM.Items.Add(new ListItem(uom.UOM_NAME, WebSiteCommon.PackItemValue(uom.UOM_CATEGORY, uom.UOM_ID.ToString())));
                        ddlUserUOMConvertTo.Items.Add(new ListItem(uom.UOM_NAME, WebSiteCommon.PackItemValue(uom.UOM_CATEGORY, uom.UOM_ID.ToString())));
                    }
                }
                ListItem separator = new ListItem("---------------------", "");
                separator.Attributes.Add("disabled", "true");
                ddlMetricUOM.Items.Add(separator);
                foreach (UOM uom in SessionManager.UOMList)
                {
                    if ((uom.OWNER_ID.HasValue && uom.OWNER_ID == staticProfile.Plant.PLANT_ID))
                    {
                        ddlMetricUOM.Items.Add(new ListItem(uom.UOM_NAME, WebSiteCommon.PackItemValue(uom.UOM_CATEGORY, uom.UOM_ID.ToString())));
                    }
                }
                ddlMetricUOM.Items.Insert(0, "");
                ddlMetricUOM.SelectedIndex = 0;
            }
            UpdateListTitles();
        }
コード例 #3
0
        public int BindProfileMeasure(EHS_PROFILE_MEASURE pm)
        {
            int status = 0;

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

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

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

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

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

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

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

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

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

                tbWasteCode.Text = pm.WASTE_CODE;

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

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

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

            UpdateListTitles();
            pnlMetricEdit.Enabled = btnMetricCancel.Enabled = btnMetricSave.Enabled = UserContext.CheckUserPrivilege(SysPriv.config, SysScope.envdata);

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

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

            return(status);
        }
コード例 #4
0
        public int BindProfileMeasure(EHS_PROFILE_MEASURE pm)
        {
            int status = 0;

            divMetricUOM.Visible = true;
            divUserUOM.Visible   = false;
            if (pm == null)
            {
                ddlMetricCategory.SelectedIndex = ddlMetricID.SelectedIndex = ddlMetricDisposalCode.SelectedIndex = ddlMetricUOM.SelectedIndex = ddlMetricResponsible.SelectedIndex = 0;
                ddlMetricCurrency.SelectedValue = staticProfile.Plant.CURRENCY_CODE;
                lblMetricName.Text  = lblDisposalDesc.Text = "";
                tbMetricPrompt.Text = "";
            }
            else
            {
                staticProfileMeasure = pm;
                staticMeasure        = pm.EHS_MEASURE;

                //  ScriptManager.RegisterStartupScript(this, GetType(), "enablelist", "enableListItems('ddlMetricCategory','ddlMetricID'); enableListItems('ddlMetricUOMCategory','ddlMetricUOM');", true);

                ddlMetricCategory.SelectedValue = pm.EHS_MEASURE.MEASURE_CATEGORY;
                ddlMetricID.SelectedValue       = pm.EHS_MEASURE.MEASURE_CATEGORY + "|" + pm.EHS_MEASURE.MEASURE_ID.ToString();
                lblMetricName.Text  = pm.EHS_MEASURE.MEASURE_CD;
                tbMetricPrompt.Text = pm.MEASURE_PROMPT;
                ddlMetricRegStatus.SelectedValue    = pm.REG_STATUS;
                ddlMetricDisposalCode.SelectedValue = pm.UN_CODE;
                if (!string.IsNullOrEmpty(pm.UN_CODE))
                {
                    lblDisposalDesc.Text = disposalList.FirstOrDefault(l => l.UN_CODE == pm.UN_CODE).DESCRIPTION;
                }
                else
                {
                    lblDisposalDesc.Text = "";
                }

                if (pm.EHS_MEASURE.MEASURE_CATEGORY == "EUTL" || pm.EHS_MEASURE.MEASURE_CATEGORY == "PROD")
                {
                    tbWasteCode.Enabled = false;
                    tbWasteCode.Text    = "";
                }
                else
                {
                    tbWasteCode.Enabled = true;
                    tbWasteCode.Text    = pm.WASTE_CODE;
                }

                ddlMetricCurrency.SelectedValue = pm.DEFAULT_CURRENCY_CODE;
                if (pm.RESPONSIBLE_ID > 0)
                {
                    ddlMetricResponsible.SelectedValue = pm.RESPONSIBLE_ID.ToString();
                }
                if (pm.DEFAULT_UOM > 0)
                {
                    UOM uom = staticUOM = SessionManager.UOMList.FirstOrDefault(l => l.UOM_ID == pm.DEFAULT_UOM);
                    if (uom != null)
                    {
                        ddlMetricUOM.SelectedValue = WebSiteCommon.PackItemValue(uom.UOM_CATEGORY, uom.UOM_ID.ToString());
                        if (uom.UOM_CATEGORY == "CUST")
                        {
                            divUserUOM.Visible = true;
                            tbUserUOMName.Text = uom.UOM_NAME;
                            tbUserUOMCode.Text = uom.UOM_CD;
                            UOM_XREF xref = uom.UOM_XREF.FirstOrDefault();
                            if (xref != null)
                            {
                                UOM refUOM = SessionManager.UOMList.FirstOrDefault(l => l.UOM_ID == xref.UOM_TO);
                                if (refUOM != null)
                                {
                                    ddlUserUOMConvertTo.SelectedValue = WebSiteCommon.PackItemValue(refUOM.UOM_CATEGORY, refUOM.UOM_ID.ToString());
                                    tbUserUOMConversionFactor.Text    = SQMBasePage.FormatValue(xref.CONVERSION, 4);
                                }
                            }
                        }
                    }
                }

                ddlMetricStatus.SelectedValue = pm.STATUS;

                cbMetricNegValue.Checked = (bool)pm.NEG_VALUE_ALLOWED;
                cbMetricRequired.Checked = (bool)pm.IS_REQUIRED;
            }

            UpdateListTitles();
            pnlMetricEdit.Enabled = btnMetricCancel.Enabled = btnMetricSave.Enabled = true;

            return(status);
        }
コード例 #5
0
        private void SetupProfilePanel()
        {
            if (ddlMetricDisposalCode.Items.Count == 0)
            {
                ddlDayDue.Items.AddRange(WebSiteCommon.PopulateDropDownListNums(1, 31));
                ddlWarningDays.Items.AddRange(WebSiteCommon.PopulateDropDownListNums(0, 11));

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

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

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

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

                if (UserContext.CheckUserPrivilege(SysPriv.config, SysScope.envdata))
                {
                    ddlMetricStatus.Items.AddRange(WebSiteCommon.PopulateDropDownListItems("statusCodeDelete"));
                }
                else
                {
                    ddlMetricStatus.Items.AddRange(WebSiteCommon.PopulateDropDownListItems("statusCode"));
                }

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

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

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

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