Example #1
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));
            }
        }
        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)
                {
                    ;
                }
            }
        }