Exemplo n.º 1
0
 protected void btnCopyProfile_Click(object sender, EventArgs e)
 {
     if (ddlCopyProfile.SelectedIndex > -1)
     {
         try
         {
             EHSProfile profile = new EHSProfile();
             profile.Profile = profile.LookupProfile(LocalProfile().Entities, Convert.ToDecimal(ddlCopyProfile.SelectedValue));
             foreach (EHS_PROFILE_MEASURE metric in profile.Profile.EHS_PROFILE_MEASURE)
             {
                 EHS_PROFILE_MEASURE newMetric         = new EHS_PROFILE_MEASURE();
                 decimal             defaultResponible = ddlDefaultResponsible.SelectedIndex > 0 ? Convert.ToDecimal(ddlDefaultResponsible.SelectedValue) : 0;
                 LocalProfile().CopyMeasure(metric, LocalProfile().Plant.PLANT_ID, defaultResponible);
             }
             if (!LocalProfile().Profile.APPROVER_ID.HasValue)
             {
                 LocalProfile().Profile.APPROVER_ID = profile.Profile.APPROVER_ID;
             }
             EHSProfile.UpdateProfile(LocalProfile());
             LoadPlantProfile(LocalProfile().Plant);
         }
         catch
         {
             DisplayProfileMessage(lblCopyError);
         }
     }
 }
Exemplo n.º 2
0
        protected void btnProfileSave_Click(object sender, EventArgs e)
        {
            LocalProfile().Profile.DAY_DUE        = Convert.ToInt32(ddlDayDue.SelectedValue);
            LocalProfile().Profile.REMINDER_DAYS  = Convert.ToInt32(ddlWarningDays.SelectedValue);
            LocalProfile().Profile.APPROVER_ID    = Convert.ToInt32(ddlFinalApprover.SelectedValue);
            LocalProfile().Profile.DISPLAY_OPTION = ddlDisplayOrder.SelectedIndex;

            if (LocalProfile().Profile.EHS_PROFILE_FACT != null)
            {
                LocalProfile().Profile.EHS_PROFILE_FACT.Clear();
            }

            if (ddlNormFact.SelectedIndex > 0)
            {
                LocalProfile().Profile.EHS_PROFILE_FACT.Add(LocalProfile().AddFactor("norm", "", Convert.ToDecimal(ddlNormFact.SelectedValue)));
                LocalProfile().Profile.EHS_PROFILE_FACT.Add(LocalProfile().AddFactor("normCost", "", Convert.ToDecimal(ddlNormFact.SelectedValue)));
            }

            LocalProfile().Profile.UTIL_MONTH_SPAN = LocalProfile().Profile.WASTE_MONTH_SPAN = Convert.ToInt32(WebSiteCommon.GetXlatValue("invoiceSpan", "MINDATE"));

            if (EHSProfile.UpdateProfile(LocalProfile()) >= 0)
            {
                ScriptManager.RegisterStartupScript(this, GetType(), "showalert", "alertResult('hfAlertSaveSuccess');", true);
            }
            BindProfile(LocalProfile());
        }
Exemplo n.º 3
0
        protected void btnProfileSave_Click(object sender, EventArgs e)
        {
            staticProfile.Profile.DAY_DUE       = Convert.ToInt32(ddlDayDue.SelectedValue);
            staticProfile.Profile.REMINDER_DAYS = Convert.ToInt32(ddlWarningDays.SelectedValue);

            staticProfile = EHSProfile.UpdateProfile(staticProfile);
            BindProfile(staticProfile);
        }
        protected void lnkMetricInput_Click(object sender, EventArgs e)
        {
            string     cmdID = "";
            LinkButton lnk;

            if (sender.GetType().ToString().ToUpper().Contains("LINK"))
            {
                lnk   = (LinkButton)sender;
                cmdID = lnk.CommandArgument;
            }
            else
            {
                ImageButton btn = (ImageButton)sender;
                cmdID = btn.CommandArgument;
            }

            EHS_PROFILE_INPUT input = LocalProfile().InputPeriod.InputsList[0];

            input.LAST_UPD_DT = DateTime.UtcNow;
            EHSProfile.UpdateProfile(LocalProfile());

            foreach (RepeaterItem item in rptProfilePeriod.Items)
            {
                lnk = (LinkButton)item.FindControl("lnkMetricCD");
                if (lnk.CommandArgument == cmdID)
                {
                    SaveInputs(Convert.ToDecimal(cmdID), false);

                    Repeater            rpt    = (Repeater)item.FindControl("rptProfileInput");
                    EHS_PROFILE_MEASURE metric = LocalProfile().GetMeasure(Convert.ToDecimal(lnk.CommandArgument));
                    LocalProfile().CreatePeriodInput(LocalProfile().InputPeriod, metric, true);
                    rpt.DataSource = LocalProfile().InputPeriod.GetPeriodInputList(metric.PRMR_ID);
                    rpt.DataBind();
                }
            }

            BindSharedCalendars();
        }
Exemplo n.º 5
0
        protected void btnMetricSave_Click(object sender, EventArgs e)
        {
            bool success;
            bool measureChanged    = false;
            bool reqdError         = false;
            EHS_PROFILE_MEASURE pm = null;

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

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

            decimal measureID = 0;

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

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

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

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

            pm.STATUS = ddlMetricStatus.SelectedValue;

            pm.IS_REQUIRED = cbMetricRequired.Checked;

            decimal uomID = 0;

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

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

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

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

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

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

            // validate

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

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

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

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

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

            EHSProfile.UpdateProfile(LocalProfile());

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

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

            btnMetricClear_Click(null, null);
            BindProfile(LocalProfile());
        }