예제 #1
0
        protected void tab_Click(string tabID, string cmdArg)
        {
            if (tabID != null)
            {
                // setup for ps_admin.js to toggle the tab active/inactive display
                SetActiveTab(SessionManager.CurrentSecondaryTab = hfActiveTab.Value = tabID);

                pnlDetails.Visible = uclDocMgr.DocMgrPnl.Visible = pnlTargetList.Visible = pnlUomStd.Visible = false;
                COMPANY company = SQMModelMgr.LookupCompany(entities, SessionManager.EffLocation.Company.COMPANY_ID, "", false);

                switch (tabID)
                {
                case "lbCompanyDetail_tab":
                    pnlDetails.Visible = true;
                    if (ddlStatus.Items.FindByValue(company.STATUS) != null)
                    {
                        ddlStatus.SelectedValue = company.STATUS;
                    }
                    if (SessionManager.IsEffLocationPrimary() == true)
                    {
                        phUpdateCompany.Visible = false;
                        ddlStatus.Enabled       = false;
                    }
                    break;

                case "lbUomStds_tab":
                    pnlUomStd.Visible = true;
                    BindStdUnits(SessionManager.EffLocation.Company);
                    break;

                case "lbCompanyTargets_tab":
                    pnlTargetList.Visible = true;
                    targetList            = ViewModel.SelectTargets(entities, company.COMPANY_ID, 0);
                    BindTargetList(targetList);
                    if (ddlEffYear.Items.Count == 0)
                    {
                        ddlEffYear.Items.AddRange(WebSiteCommon.PopulateDropDownListNums(2005, 15));
                        ddlTargetStatus.Items.AddRange(WebSiteCommon.PopulateDropDownListItems("statusCodeDelete", "short"));
                        string[] targs = { "statScopeE", "statScopeHS", "statScopeQS" };
                        foreach (string scopelist in targs)
                        {
                            foreach (WebSiteCommon.SelectItem si in WebSiteCommon.PopulateListItems(scopelist))
                            {
                                if (string.IsNullOrEmpty(si.Value))
                                {
                                    RadComboBoxItem li = new RadComboBoxItem(si.Text, si.Text);
                                    li.IsSeparator = true;
                                    ddlTarget.Items.Add(li);
                                }
                                else
                                {
                                    ddlTarget.Items.Add(new RadComboBoxItem(si.Text, (si.Value + "|" + scopelist.Substring(9))));
                                }
                            }
                        }
                    }

                    break;

                default:
                    if (SessionManager.IsEffLocationPrimary())
                    {
                        uclDocMgr.BindDocMgr("SYS", 0, 0);
                    }
                    break;
                }
            }
        }
예제 #2
0
        protected void btnTargetSave_Click(object sender, EventArgs e)
        {
            bool   success;
            Button btn = (Button)sender;

            if (btn.CommandArgument == "save")
            {
                if (staticTarget.TARGET_ID < 1)
                {
                    staticTarget            = new PERSPECTIVE_TARGET();
                    staticTarget.COMPANY_ID = SessionManager.EffLocation.Company.COMPANY_ID;
                }
                else
                {
                    staticTarget = ViewModel.LookupTarget(entities, staticTarget.TARGET_ID);
                }

                string perspective = ddlTarget.SelectedValue.Substring(ddlTarget.SelectedValue.IndexOf('|') + 1);
                staticTarget.PERSPECTIVE = perspective;
                staticTarget.CALCS_SCOPE = ddlTarget.SelectedValue.Substring(0, ddlTarget.SelectedValue.IndexOf('|'));
                staticTarget.DESCR_LONG  = staticTarget.DESCR_SHORT = ddlTarget.SelectedItem.Text;
                if (!string.IsNullOrEmpty(tbTargetDescLong.Text))
                {
                    staticTarget.DESCR_LONG = tbTargetDescLong.Text;
                }
                staticTarget.SSTAT    = ddlStatType.SelectedValue;
                staticTarget.EFF_YEAR = Convert.ToInt32(ddlEffYear.SelectedValue);
                staticTarget.STATUS   = ddlTargetStatus.SelectedValue;

                if (btnABSMetric.Checked)
                {
                    staticTarget.DATE_SPAN = 0;
                }
                else if (btnYTDMetric.Checked)
                {
                    staticTarget.DATE_SPAN = 1;
                }
                else
                {
                    staticTarget.DATE_SPAN = 2;
                }

                decimal value;
                if (decimal.TryParse(tbTargetValue.Text, out value))
                {
                    staticTarget.TARGET_VALUE = value;
                    staticTarget.VALUE_IND    = true;
                }
                else
                {
                    staticTarget.TARGET_VALUE = Convert.ToDecimal(null);
                    staticTarget.VALUE_IND    = false;
                }

                if (btnTargetMax.Checked)
                {
                    staticTarget.MIN_MAX = 1;
                }
                else
                {
                    staticTarget.MIN_MAX = 0;
                }

                if ((staticTarget = ViewModel.UpdateTarget(entities, staticTarget, SessionManager.UserContext.UserName())) != null)
                {
                    PERSPECTIVE_TARGET target = null;
                    if ((target = targetList.FirstOrDefault(l => l.TARGET_ID == staticTarget.TARGET_ID)) == null)
                    {
                        targetList.Add(staticTarget);
                    }
                    else
                    {
                        if (staticTarget.EntityState == System.Data.EntityState.Detached || staticTarget.EntityState == System.Data.EntityState.Deleted)
                        {
                            targetList.Remove(target);
                        }
                        else
                        {
                            target = (PERSPECTIVE_TARGET)SQMModelMgr.CopyObjectValues(target, staticTarget, false);
                        }
                    }
                    BindTargetList(targetList);
                }
            }
            else
            {
                staticTarget = new PERSPECTIVE_TARGET();
                BindTarget(staticTarget);
            }

            pnlTargetEdit.Enabled = false;
            btnTargetSave.Enabled = btnTargetCancel.Enabled = false;
            udpList.Update();
            udpTarget.Update();
        }