Ejemplo n.º 1
0
        public void BindProdFieldsList(EHSProfile profile, string acctFields)
        {
            Dictionary <string, string> fieldList = new Dictionary <string, string>();

            string[] fieldNames = { "OPER_COST", "REVENUE", "TIME_WORKED", "RECORDED_CASES", "TIME_LOST_CASES" }; // default fields to display

            if (!string.IsNullOrEmpty(acctFields))                                                                // desired fields to display
            {
                fieldNames = acctFields.Split(',');
                if (profile.InputPeriod.PlantAccounting != null)
                {
                    var PropertyInfos = profile.InputPeriod.PlantAccounting.GetType().GetProperties();
                    foreach (System.Reflection.PropertyInfo pInfo in PropertyInfos)
                    {
                        if (fieldNames.Contains(pInfo.Name))
                        {
                            object obj = pInfo.GetValue(profile.InputPeriod.PlantAccounting, null);
                            if (obj != null)
                            {
                                fieldList.Add(pInfo.Name, SQMBasePage.FormatValue((decimal)obj, 2));
                            }
                            else
                            {
                                fieldList.Add(pInfo.Name, "");
                            }
                        }
                    }
                    pnlProdList.Visible   = true;
                    gvProdList.DataSource = fieldList;
                    gvProdList.DataBind();
                }
            }
        }
Ejemplo n.º 2
0
        protected void lnkDisplayInputs(object sender, EventArgs e)
        {
            EHSProfile  profile = null;
            LinkButton  lnk     = (LinkButton)sender;
            string      cmdID   = lnk.CommandArgument;
            string      id      = lnk.ID;
            CheckBox    cb;
            EHSCalcsCtl esMgr = new EHSCalcsCtl().CreateNew(SessionManager.FYStartDate().Month, DateSpanOption.SelectRange);

            foreach (RepeaterItem r in rptProfile.Items)
            {
                Repeater rptStatus = (Repeater)r.FindControl("rptProfileStatus");
                foreach (RepeaterItem item in rptStatus.Items)
                {
                    lnk = (LinkButton)item.FindControl("lnkInputs");
                    if (lnk.CommandArgument == cmdID)
                    {
                        profile = LocalProfileList().Where(l => l.Plant.PLANT_ID == Convert.ToDecimal(cmdID)).FirstOrDefault();
                        Ucl_MetricList ucl = (Ucl_MetricList)item.FindControl("uclInputsList");
                        if (id.Contains("Inputs"))
                        {
                            cb         = (CheckBox)item.FindControl("cbInputsSelect");
                            cb.Checked = cb.Checked == false ? true : false;
                            if (cb.Checked)
                            {
                                ucl.BindInputsList(profile);
                                ucl.BindHistoryList(null, null);
                                //  cb.Focus();
                            }
                            else
                            {
                                ucl.BindInputsList(null);
                            }
                        }
                        else
                        {
                            cb         = (CheckBox)item.FindControl("cbHistorySelect");
                            cb.Checked = cb.Checked == false ? true : false;
                            if (cb.Checked)
                            {
                                esMgr.LoadMetricHistory(new decimal[1] {
                                    profile.Plant.PLANT_ID
                                }, profile.InputPeriod.PeriodDate, profile.InputPeriod.PeriodDate, DateIntervalType.month, false);
                                ucl.BindHistoryList(profile, esMgr.MetricHst);
                                ucl.BindInputsList(null);
                                //  cb.Focus();
                            }
                            else
                            {
                                ucl.BindHistoryList(null, null);
                            }
                        }

                        break;
                    }
                }
            }

            ((LinkButton)sender).Focus();
        }
        public int BindInputsList(EHSProfile profile)
        {
            int status = 0;

            if (profile != null && profile.InputPeriod.InputsList.Count > 0)
            {
                currentProfile               = profile;
                pnlInputsList.Visible        = true;
                hfInputsListPeriodDate.Value = profile.InputPeriod.PeriodDate.ToShortDateString();
                hfInputsListPlantID.Value    = profile.Plant.PLANT_ID.ToString();

                List <EHS_PROFILE_INPUT> inputsList = new List <EHS_PROFILE_INPUT>();
                foreach (EHS_PROFILE_MEASURE metric in profile.Profile.EHS_PROFILE_MEASURE.OrderBy(l => l.EHS_MEASURE.MEASURE_CATEGORY).ThenBy(l => l.EHS_MEASURE.MEASURE_CD).ToList())
                {
                    inputsList.AddRange(profile.InputPeriod.GetPeriodInputList(metric.PRMR_ID));
                }

                gvInputsList.DataSource = inputsList;
                gvInputsList.DataBind();
                if (gvInputsList.Rows.Count > 15)
                {
                    divInputsGVScroll.Attributes["class"] = "scrollArea";
                }
            }
            else
            {
                pnlInputsList.Visible   = false;
                gvInputsList.DataSource = null;
                gvInputsList.DataBind();
            }

            return(status);
        }
Ejemplo n.º 4
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());
        }
Ejemplo n.º 5
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);
         }
     }
 }
Ejemplo n.º 6
0
        public void LoadProfileInput()
        {
            divProfilePeriodScrollRepeater.Visible = true;
            SetLocalProfileList(new List <EHSProfile>());

            foreach (RadComboBoxItem item in SQMBasePage.GetComboBoxCheckedItems(ddlExportPlantSelect))
            {
                if (radExportDateSelect1.SelectedDate != null)
                {
                    EHSProfile profile = new EHSProfile().Load(Convert.ToDecimal(item.Value), false, true);
                    if (profile.Profile != null)
                    {
                        profile.LoadPeriod((DateTime)radExportDateSelect1.SelectedDate);
                        profile.MapPlantAccountingInputs(true, true);
                        LocalProfileList().Add(profile);
                    }
                }
            }
            rptProfile.DataSource = LocalProfileList();
            rptProfile.DataBind();

            if (UserContext.GetMaxScopePrivilege(SysScope.envdata) <= SysPriv.config)
            {
                btnRollupAll.Visible = true;
            }
        }
        public int BindHistoryList(EHSProfile profile, List <EHS_METRIC_HISTORY> historyList)
        {
            int status = 0;

            if (profile != null && historyList.Count > 0)
            {
                currentProfile            = profile;
                pnlHSTMetricsList.Visible = true;

                gvHSTMetricsList.DataSource = historyList.OrderBy(l => l.EHS_MEASURE.MEASURE_CATEGORY).ThenBy(l => l.EHS_MEASURE.MEASURE_CD).ToList();
                gvHSTMetricsList.DataBind();
                if (gvHSTMetricsList.Rows.Count > 15)
                {
                    divHSTMetricsGVScroll.Attributes["class"] = "scrollArea";
                }
            }
            else
            {
                pnlHSTMetricsList.Visible   = false;
                gvHSTMetricsList.DataSource = null;
                gvHSTMetricsList.DataBind();
            }

            return(status);
        }
Ejemplo n.º 8
0
        private void BindProfile(EHSProfile profile)
        {
            if (profile != null)
            {
                ddlDayDue.SelectedValue      = LocalProfile().Profile.DAY_DUE.ToString();
                ddlWarningDays.SelectedValue = LocalProfile().Profile.REMINDER_DAYS.ToString();
                if (LocalProfile().Profile.APPROVER_ID > 0 && ddlFinalApprover.Items.FindByValue(LocalProfile().Profile.APPROVER_ID.ToString()) != null)
                {
                    ddlFinalApprover.SelectedValue = LocalProfile().Profile.APPROVER_ID.ToString();
                }
                else
                {
                    ddlFinalApprover.SelectedIndex = 0;
                }

                if (LocalProfile().Profile.DISPLAY_OPTION.HasValue)
                {
                    ddlDisplayOrder.SelectedIndex = (int)LocalProfile().Profile.DISPLAY_OPTION;
                }

                if (LocalProfile().Profile.EHS_PROFILE_FACT != null && LocalProfile().Profile.EHS_PROFILE_FACT.Count > 0)
                {
                    if (ddlNormFact.Items.FindByValue(LocalProfile().Profile.EHS_PROFILE_FACT.FirstOrDefault().FACTOR_ID.ToString()) != null)
                    {
                        ddlNormFact.SelectedValue = LocalProfile().Profile.EHS_PROFILE_FACT.FirstOrDefault().FACTOR_ID.ToString();
                    }
                }
                else
                {
                    EHS_PROFILE_MEASURE factMetric = null;
                    try
                    {
                        factMetric = profile.Profile.EHS_PROFILE_MEASURE.Where(l => l.EHS_MEASURE.MEASURE_CATEGORY == "FACT").FirstOrDefault();
                    }
                    catch { }
                    if (factMetric != null && ddlNormFact.Items.FindByValue(factMetric.EHS_MEASURE.MEASURE_ID.ToString()) != null)
                    {
                        ddlNormFact.SelectedValue = factMetric.EHS_MEASURE.MEASURE_ID.ToString();
                    }
                    else
                    {
                        ddlNormFact.SelectedIndex = 0;
                    }
                }

                if (ddlMetricCurrency.Items.FindByValue(LocalProfile().Plant.CURRENCY_CODE) != null)
                {
                    ddlMetricCurrency.SelectedValue = LocalProfile().Plant.CURRENCY_CODE;
                }

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

                UpdateMetricList(profile);

                pnlMetricEdit.Visible = false;
                //pnlProfileEdit.Visible = true;
            }
        }
Ejemplo n.º 9
0
 public EHSProfile LoadPlantProfile(PLANT plant)
 {
     staticProfile = new EHSProfile().Load(plant.PLANT_ID, true);
     ToggleVisible(pnlEHSProfile);
     SetupProfilePanel();
     BindProfile(staticProfile);
     return(staticProfile);
 }
Ejemplo n.º 10
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);
        }
Ejemplo n.º 11
0
        protected int GenerateInputsReport()
        {
            int        status  = 0;
            EHSProfile profile = new EHSProfile().Load(PlantIDS[0], false, true);

            SessionManager.TempObject = profile;

            uclInputs.BindPeriodList(uclInputs.SelectProfilePeriodList(profile, (DateTime)radDateFrom.SelectedDate, (DateTime)radDateTo.SelectedDate).OrderByDescending(l => l.PeriodDate).ToList());
            divInputs.Visible = true;
            return(status);
        }
Ejemplo n.º 12
0
        protected void btnRollup_Click(object sender, EventArgs e)
        {
            Button btn = (Button)sender;

            uclProgress.BindProgressDisplay(100, "Finalizing: ");
            int progressValue = 10;

            uclProgress.UpdateDisplay(1, progressValue, "Calculating...");

            if (LocalProfileList() != null && LocalProfileList().Count > 0)
            {
                try
                {
                    EHSProfile profile    = LocalProfileList().Where(l => l.Plant.PLANT_ID == Convert.ToDecimal(btn.CommandArgument)).FirstOrDefault();
                    DateTime   endDate    = profile.InputPeriod.PeriodDate;
                    DateTime   periodDate = profile.InputPeriod.PeriodDate;

                    if (btn.ClientID.Contains("YTD"))
                    {
                        periodDate = new DateTime(profile.InputPeriod.PeriodDate.Year, 1, 1);
                    }

                    int progressDelta = 70 / Math.Max(1, ((endDate.Year - periodDate.Year) * 12 + endDate.Month - periodDate.Month));

                    while (periodDate <= endDate)
                    {
                        progressValue += progressDelta;
                        uclProgress.UpdateDisplay(1, progressValue, periodDate.ToShortDateString());

                        if (profile.InputPeriod.PeriodDate != periodDate)
                        {
                            profile.LoadPeriod(periodDate);
                        }

                        if (profile.ValidPeriod())
                        {
                            if (!profile.InputPeriod.PlantAccounting.APPROVAL_DT.HasValue)
                            {
                                profile.InputPeriod.PlantAccounting.APPROVAL_DT = DateTime.UtcNow;
                                profile.InputPeriod.PlantAccounting.APPROVER_ID = SessionManager.UserContext.Person.PERSON_ID;
                            }
                            //profile.UpdateMetricHistory();
                            profile.UpdateMetricHistory(periodDate);  // new roll-up logic
                            periodDate = periodDate.AddMonths(1);
                        }
                    }
                    uclProgress.ProgressComplete();
                    ScriptManager.RegisterStartupScript(this, GetType(), "showalert", "alertResult('hfAlertSaveSuccess');", true);
                    LoadProfileInput();
                }
                catch { }
            }
        }
Ejemplo n.º 13
0
        public List <EHSProfilePeriod> SelectProfilePeriodList(EHSProfile profile, DateTime fromDate, DateTime toDate)
        {
            List <EHSProfilePeriod> periodList = new List <EHSProfilePeriod>();

            foreach (WebSiteCommon.DatePeriod pd in WebSiteCommon.CalcDatePeriods(fromDate, toDate, DateIntervalType.month, DateSpanOption.SelectRange, ""))
            {
                profile.LoadPeriod(pd.FromDate);
                // profile.MapPlantAccountingInputs(true, true);
                periodList.Add(profile.InputPeriod);
            }

            return(periodList);
        }
Ejemplo n.º 14
0
 public void BindProfileSelectHdr(EHSProfile profile)
 {
     ToggleVisible(pnlProfileSelectHdr);
     if (profile == null)
     {
         lblLocCodePlant_out.Text = lblLocationType_out.Text = lblProfileUpdateBy_out.Text = lblProfileUpdate_out.Text = "";
     }
     else
     {
         lblLocCodePlant_out.Text    = profile.Plant.DUNS_CODE;
         lblLocationType_out.Text    = WebSiteCommon.GetXlatValue("locationType", profile.Plant.LOCATION_TYPE);
         lblProfileUpdateBy_out.Text = profile.Profile.LAST_UPD_BY;
         lblProfileUpdate_out.Text   = SQMBasePage.FormatDate((DateTime)profile.Profile.LAST_UPD_DT, "d", false);
     }
 }
Ejemplo n.º 15
0
        private void BindProfile(EHSProfile profile)
        {
            if (profile != null)
            {
                gvMetricList.DataSource = profile.Profile.EHS_PROFILE_MEASURE.OrderBy(l => l.EHS_MEASURE.MEASURE_CD);
                gvMetricList.DataBind();
                SQMBasePage.SetGridViewDisplay(gvMetricList, lblMetricListEmpty, divMetricListGVScroll, -1, 0);

                ddlDayDue.SelectedValue      = staticProfile.Profile.DAY_DUE.ToString();
                ddlWarningDays.SelectedValue = staticProfile.Profile.REMINDER_DAYS.ToString();

                ddlMetricCurrency.SelectedValue = staticProfile.Plant.CURRENCY_CODE;
                pnlMetricEdit.Enabled           = btnMetricCancel.Enabled = btnMetricSave.Enabled = false;
                btnProfileMeasureNew.Enabled    = true;
            }
        }
Ejemplo n.º 16
0
        public void BindProfileInputHdr(EHSProfile profile)
        {
            ToggleVisible(pnlProfileInputHdr);
            lblPlantName_out.Text  = profile.Plant.PLANT_NAME;
            lblPeriodFrom_out.Text = SQMBasePage.FormatDate(profile.InputPeriod.PeriodDate, "MM/yyyy", false);
            lblDueDate_out.Text    = SQMBasePage.FormatDate(profile.InputPeriod.DueDate.AddMonths(1), "d", false);
            DateTime   lastUpdateDate;
            TaskStatus status = profile.PeriodStatus(new string[0] {
            }, true, out lastUpdateDate);

            lblInputStatus1_out.Text = profile.InputPeriod.NumRequiredComplete.ToString();
            lblInputStatus2_out.Text = profile.InputPeriod.NumRequired.ToString();

            lblLastUpdateBy_out.Text = lblLastUpdate_out.Text = "";
            EHS_PROFILE_INPUT lastinput = profile.InputPeriod.GetLastInput();

            if (lastinput == null || lastinput.LAST_UPD_DT.HasValue == false)
            {
                if (profile.InputPeriod.PlantAccounting != null && !string.IsNullOrEmpty(profile.InputPeriod.PlantAccounting.LAST_UPD_BY))
                {
                    lblLastUpdateBy_out.Text = profile.InputPeriod.PlantAccounting.LAST_UPD_BY;
                    if (profile.InputPeriod.PlantAccounting.LAST_UPD_DT.HasValue)
                    {
                        lblLastUpdate_out.Text = SQMBasePage.FormatDate((DateTime)profile.InputPeriod.PlantAccounting.LAST_UPD_DT, "", false);
                    }
                }
            }
            else
            {
                lblLastUpdateBy_out.Text = lastinput.LAST_UPD_BY;
                lblLastUpdate_out.Text   = SQMBasePage.FormatDate((DateTime)lastinput.LAST_UPD_DT, "", false);
            }

            CURRENCY_XREF exchangeRate = profile.InputPeriod.PeriodExchangeRate(profile.Plant);

            if (exchangeRate != null && exchangeRate.EFF_MONTH > 0)
            {
                phRateStatus.Visible = true;
                lblCurrency.Text     = profile.Plant.CURRENCY_CODE;
                lblRateStatus.Text   = (System.Environment.NewLine + SQMBasePage.FormatDate(new DateTime(exchangeRate.EFF_YEAR, exchangeRate.EFF_MONTH, DateTime.DaysInMonth(exchangeRate.EFF_YEAR, exchangeRate.EFF_MONTH)), "d", false));
            }
        }
Ejemplo n.º 17
0
        public void rptProfile_OnItemDataBound(object sender, RepeaterItemEventArgs e)
        {
            if (e.Item.ItemType == ListItemType.AlternatingItem || e.Item.ItemType == ListItemType.Item)
            {
                try
                {
                    EHSProfile profile = (EHSProfile)e.Item.DataItem;
                    Label      lbl     = (Label)e.Item.FindControl("lblLocation");
                    lbl.Text = profile.Plant.PLANT_NAME;

                    List <EHSProfile> periodList = new List <EHSProfile>();
                    periodList.Add(profile);
                    Repeater rpt = (Repeater)e.Item.FindControl("rptProfileStatus");
                    rpt.DataSource = periodList;
                    rpt.DataBind();
                }
                catch (Exception ex)
                {
                    ;
                }
            }
        }
        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();
        }
Ejemplo n.º 19
0
        private void UpdateMetricList(EHSProfile profile)
        {
            if (profile != null)
            {
                switch (profile.Profile.DISPLAY_OPTION)
                {
                case 1:
                    gvMetricList.DataSource = profile.Profile.EHS_PROFILE_MEASURE.OrderBy(l => l.EHS_MEASURE.MEASURE_CD);
                    break;

                case 2:
                    gvMetricList.DataSource = profile.Profile.EHS_PROFILE_MEASURE.OrderBy(l => l.EHS_MEASURE.MEASURE_NAME);
                    break;

                default:
                    gvMetricList.DataSource = profile.Profile.EHS_PROFILE_MEASURE.OrderBy(l => l.EHS_MEASURE.MEASURE_CATEGORY).ThenBy(l => l.EHS_MEASURE.MEASURE_CD);
                    break;
                }

                gvMetricList.DataBind();
                SQMBasePage.SetGridViewDisplay(gvMetricList, lblMetricListEmpty, divMetricListGVScroll, -1, 0);
            }
        }
Ejemplo n.º 20
0
        public void LoadMetricHistory()
        {
            SetLocalProfileList(new List <EHSProfile>());

            foreach (RadComboBoxItem item in SQMBasePage.GetComboBoxCheckedItems(ddlExportPlantSelect))
            {
                if (radExportDateSelect1.SelectedDate != null)
                {
                    EHSProfile profile = new EHSProfile().Load(Convert.ToDecimal(item.Value), false, true);
                    if (profile.Profile != null)
                    {
                        LocalProfileList().Add(profile);

                        DateTime fromDate = (DateTime)radExportDateSelect1.SelectedDate;
                        DateTime toDate   = new DateTime(radExportDateSelect2.SelectedDate.Value.Year, radExportDateSelect2.SelectedDate.Value.Month, DateTime.DaysInMonth(radExportDateSelect1.SelectedDate.Value.Year, radExportDateSelect1.SelectedDate.Value.Month));

                        EHSCalcsCtl esMgr = new EHSCalcsCtl().CreateNew(SessionManager.FYStartDate().Month, DateSpanOption.SelectRange).LoadMetricHistory(new decimal[1] {
                            profile.Plant.PLANT_ID
                        }, fromDate, toDate, DateIntervalType.month, false);
                        uclHistoryList.BindHistoryList(profile, esMgr.MetricHst);
                    }
                }
            }
        }
Ejemplo n.º 21
0
 public void BindProfile(EHSProfile profile)
 {
     currentProfile = profile;
 }
Ejemplo n.º 22
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());
        }
Ejemplo n.º 23
0
        public void rptProfileStatus_OnItemDataBound(object sender, RepeaterItemEventArgs e)
        {
            if (e.Item.ItemType == ListItemType.AlternatingItem || e.Item.ItemType == ListItemType.Item)
            {
                Label lbl;
                try
                {
                    EHSProfile profile = (EHSProfile)e.Item.DataItem;

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

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

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

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

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

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

                        if (profile.InputPeriod.PlantAccounting.APPROVER_ID.HasValue && profile.InputPeriod.PlantAccounting.APPROVAL_DT.HasValue)
                        {
                            lbl       = (Label)e.Item.FindControl("lblFinalStatus");
                            lbl.Text  = SQMModelMgr.FormatPersonListItem(SQMModelMgr.LookupPerson((decimal)profile.InputPeriod.PlantAccounting.APPROVER_ID, ""));
                            lbl.Text += " ";
                            lbl.Text += SQMBasePage.FormatDate((DateTime)profile.InputPeriod.PlantAccounting.APPROVAL_DT, "", false);
                        }
                    }
                }
                catch (Exception ex)
                {
                    ;
                }
            }
        }
Ejemplo n.º 24
0
 EHSProfile SetLocalProfile(EHSProfile profile)
 {
     SessionManager.CurrentObject = profile;
     return(LocalProfile());
 }