Esempio n. 1
0
        protected void Page_Load(object sender, EventArgs e)
        {
            AuthenticateUser();
            intProfile = Int32.Parse(Request.Cookies["profileid"].Value);

            oPage       = new Pages(intProfile, dsn);
            oUser       = new Users(intProfile, dsn);
            oTPM        = new TPM(intProfile, dsn, intEnvironment);
            oCustomized = new Customized(intProfile, dsn);
            oCost       = new Costs(intProfile, dsn);
            oVariable   = new Variables(intEnvironment);

            if (Request.QueryString["status"] != "" && Request.QueryString["status"] != null)
            {
                strStatus = Request.QueryString["status"];
            }

            if (Request.QueryString["id"] != "" && Request.QueryString["id"] != null)
            {
                intId = Int32.Parse(Request.QueryString["id"]);
            }

            if (Request.QueryString["work"] != "" && Request.QueryString["work"] != null)
            {
                intWorking = Int32.Parse(Request.QueryString["work"]);
            }

            if (Request.QueryString["exec"] != "" && Request.QueryString["exec"] != null)
            {
                intExecutive = Int32.Parse(Request.QueryString["exec"]);
            }


            if (!IsPostBack)
            {
                ds = oTPM.GetPCR(intId);
                int intRequest = Int32.Parse(ds.Tables[0].Rows[0]["requestid"].ToString());
                int intItem    = Int32.Parse(ds.Tables[0].Rows[0]["itemid"].ToString());
                int intNumber  = Int32.Parse(ds.Tables[0].Rows[0]["number"].ToString());
                int intParent  = Int32.Parse(ds.Tables[0].Rows[0]["id"].ToString());
                strPath = ds.Tables[0].Rows[0]["path"].ToString();

                dsResource = oCustomized.GetTPM(intRequest, intItem, intNumber);
                string   strCosts = dsResource.Tables[0].Rows.Count > 0 ? dsResource.Tables[0].Rows[0]["costs"].ToString() : "No Cost Center(s)";
                string[] strCost;
                char[]   strSplit = { '&' };
                strCost = strCosts.Split(strSplit);
                string strText = strCosts == "" ? "None" : "";
                foreach (string str in strCost)
                {
                    if (str != "")
                    {
                        strText += oCost.GetName(Int32.Parse(str)) + ";";
                    }
                }


                chkScope.Checked     = ds.Tables[0].Rows[0]["scope"].ToString() == "1" ? true : false;
                chkSchedule.Checked  = ds.Tables[0].Rows[0]["s"].ToString() == "1" ? true : false;
                chkFinancial.Checked = ds.Tables[0].Rows[0]["f"].ToString() == "1" ? true : false;

                divScope.Style["display"]     = chkScope.Checked ? "inline" : "none";
                divSchedule.Style["display"]  = chkSchedule.Checked ? "inline" : "none";
                divFinancial.Style["display"] = chkFinancial.Checked ? "inline" : "none";

                txtPCRScheduleDS.Text = ds.Tables[0].Rows[0]["sds"].ToString() != "" ? DateTime.Parse(ds.Tables[0].Rows[0]["sds"].ToString()).ToShortDateString() : "";
                txtPCRScheduleDE.Text = ds.Tables[0].Rows[0]["sde"].ToString() != "" ? DateTime.Parse(ds.Tables[0].Rows[0]["sde"].ToString()).ToShortDateString() : "";
                txtPCRSchedulePS.Text = ds.Tables[0].Rows[0]["sps"].ToString() != "" ? DateTime.Parse(ds.Tables[0].Rows[0]["sps"].ToString()).ToShortDateString() : "";
                txtPCRSchedulePE.Text = ds.Tables[0].Rows[0]["spe"].ToString() != "" ? DateTime.Parse(ds.Tables[0].Rows[0]["spe"].ToString()).ToShortDateString() : "";
                txtPCRScheduleES.Text = ds.Tables[0].Rows[0]["ses"].ToString() != "" ? DateTime.Parse(ds.Tables[0].Rows[0]["ses"].ToString()).ToShortDateString() : "";
                txtPCRScheduleEE.Text = ds.Tables[0].Rows[0]["see"].ToString() != "" ? DateTime.Parse(ds.Tables[0].Rows[0]["see"].ToString()).ToShortDateString() : "";
                txtPCRScheduleCS.Text = ds.Tables[0].Rows[0]["scs"].ToString() != "" ? DateTime.Parse(ds.Tables[0].Rows[0]["scs"].ToString()).ToShortDateString() : "";
                txtPCRScheduleCE.Text = ds.Tables[0].Rows[0]["sce"].ToString() != "" ? DateTime.Parse(ds.Tables[0].Rows[0]["sce"].ToString()).ToShortDateString() : "";

                chkPCRScheduleD.Checked = txtPCRScheduleDS.Text != "" || txtPCRScheduleDE.Text != "";
                chkPCRScheduleP.Checked = txtPCRSchedulePS.Text != "" || txtPCRSchedulePE.Text != "";
                chkPCRScheduleE.Checked = txtPCRScheduleES.Text != "" || txtPCRScheduleEE.Text != "";
                chkPCRScheduleC.Checked = txtPCRScheduleCS.Text != "" || txtPCRScheduleCE.Text != "";

                if (dsResource.Tables[0].Rows[0]["appsd"] == DBNull.Value || dsResource.Tables[0].Rows[0]["apped"] == DBNull.Value)
                {
                    chkPCRScheduleD.Enabled = false;
                    lblPCRScheduleD.Text    = "N / A";
                }
                else
                {
                    lblPCRScheduleD.Text = GetDate(dsResource.Tables[0].Rows[0]["appsd"].ToString()) + " - " + GetDate(dsResource.Tables[0].Rows[0]["apped"].ToString());
                }
                if (dsResource.Tables[0].Rows[0]["appsp"] == DBNull.Value || dsResource.Tables[0].Rows[0]["appep"] == DBNull.Value)
                {
                    chkPCRScheduleP.Enabled = false;
                    lblPCRScheduleP.Text    = "N / A";
                }
                else
                {
                    lblPCRScheduleP.Text = GetDate(dsResource.Tables[0].Rows[0]["appsp"].ToString()) + " - " + GetDate(dsResource.Tables[0].Rows[0]["appep"].ToString());
                }
                if (dsResource.Tables[0].Rows[0]["appse"] == DBNull.Value || dsResource.Tables[0].Rows[0]["appee"] == DBNull.Value)
                {
                    chkPCRScheduleE.Enabled = false;
                    lblPCRScheduleE.Text    = "N / A";
                }
                else
                {
                    lblPCRScheduleE.Text = GetDate(dsResource.Tables[0].Rows[0]["appse"].ToString()) + " - " + GetDate(dsResource.Tables[0].Rows[0]["appee"].ToString());
                }
                if (dsResource.Tables[0].Rows[0]["appsc"] == DBNull.Value || dsResource.Tables[0].Rows[0]["appec"] == DBNull.Value)
                {
                    chkPCRScheduleC.Enabled = false;
                    lblPCRScheduleC.Text    = "N / A";
                }
                else
                {
                    lblPCRScheduleC.Text = GetDate(dsResource.Tables[0].Rows[0]["appsc"].ToString()) + " - " + GetDate(dsResource.Tables[0].Rows[0]["appec"].ToString());
                }


                double dblAppDI = GetFloat(dsResource.Tables[0].Rows[0]["appid"].ToString());
                double dblAppDE = GetFloat(dsResource.Tables[0].Rows[0]["appexd"].ToString());
                double dblAppDH = GetFloat(dsResource.Tables[0].Rows[0]["apphd"].ToString());
                double dblAppD  = dblAppDI + dblAppDE + dblAppDH;
                lblPCRFinancialD.Text = "$" + dblAppD.ToString("N");


                double dblAppPI = GetFloat(dsResource.Tables[0].Rows[0]["appip"].ToString());
                double dblAppPE = GetFloat(dsResource.Tables[0].Rows[0]["appexp"].ToString());
                double dblAppPH = GetFloat(dsResource.Tables[0].Rows[0]["apphp"].ToString());
                double dblAppP  = dblAppPI + dblAppPE + dblAppPH;
                lblPCRFinancialP.Text = "$" + dblAppP.ToString("N");

                double dblAppEI = GetFloat(dsResource.Tables[0].Rows[0]["appie"].ToString());
                double dblAppEE = GetFloat(dsResource.Tables[0].Rows[0]["appexe"].ToString());
                double dblAppEH = GetFloat(dsResource.Tables[0].Rows[0]["apphe"].ToString());
                double dblAppE  = dblAppEI + dblAppEE + dblAppEH;
                lblPCRFinancialE.Text = "$" + dblAppE.ToString("N");


                double dblAppCI = GetFloat(dsResource.Tables[0].Rows[0]["appic"].ToString());
                double dblAppCE = GetFloat(dsResource.Tables[0].Rows[0]["appexc"].ToString());
                double dblAppCH = GetFloat(dsResource.Tables[0].Rows[0]["apphc"].ToString());
                double dblAppC  = dblAppCI + dblAppCE + dblAppCH;
                lblPCRFinancialC.Text = "$" + dblAppC.ToString("N");


                txtPCRFinancialD.Text = ds.Tables[0].Rows[0]["fd"].ToString();
                txtPCRFinancialP.Text = ds.Tables[0].Rows[0]["fp"].ToString();
                txtPCRFinancialE.Text = ds.Tables[0].Rows[0]["fe"].ToString();
                txtPCRFinancialC.Text = ds.Tables[0].Rows[0]["fc"].ToString();

                chkPCRFinancialD.Checked = txtPCRFinancialD.Text != "0";
                chkPCRFinancialP.Checked = txtPCRFinancialP.Text != "0";
                chkPCRFinancialE.Checked = txtPCRFinancialE.Text != "0";
                chkPCRFinancialC.Checked = txtPCRFinancialC.Text != "0";

                chkReason.Checked          = ds.Tables[0].Rows[0]["reasons"].ToString() != "";
                divReason.Style["display"] = chkReason.Checked ? "inline" : "none";
                string[] strReasons = ds.Tables[0].Rows[0]["reasons"].ToString().Split(';');
                foreach (string str in strReasons)
                {
                    for (int ii = 0; ii < chkPCRReason.Items.Count; ii++)
                    {
                        if (chkPCRReason.Items[ii].Value == str)
                        {
                            chkPCRReason.Items[ii].Selected = true;
                            break;
                        }
                    }
                }
                txtScopeComments.Text     = ds.Tables[0].Rows[0]["scopecomments"].ToString();
                txtScheduleComments.Text  = ds.Tables[0].Rows[0]["schcomments"].ToString();
                txtFinancialComments.Text = ds.Tables[0].Rows[0]["fincomments"].ToString();

                int intStatus = Int32.Parse(ds.Tables[0].Rows[0]["status"].ToString());
                if (intStatus == 1)
                {
                    strStatus = "Approved";
                }
                else if (intStatus == -1)
                {
                    strStatus = "Denied";
                }
                hdnStatus.Value = strStatus.ToUpper();
            }

            chkScope.Attributes.Add("onclick", "ShowHideDivCheck('" + divScope.ClientID + "',this);");
            chkSchedule.Attributes.Add("onclick", "ShowHideDivCheck('" + divSchedule.ClientID + "',this);");
            chkFinancial.Attributes.Add("onclick", "ShowHideDivCheck('" + divFinancial.ClientID + "',this);");
            chkReason.Attributes.Add("onclick", "ShowHideDivCheck('" + divReason.ClientID + "',this);");
            btnUpdate.Attributes.Add("onclick", "return ValidateStatus('" + hdnStatus.Value + "') && ValidatePCR('" + chkScope.ClientID + "'" +
                                     ",'" + chkSchedule.ClientID + "'" +
                                     ",'" + chkPCRScheduleD.ClientID + "'" +
                                     ",'" + txtPCRScheduleDS.ClientID + "'" +
                                     ",'" + txtPCRScheduleDE.ClientID + "'" +
                                     ",'" + chkPCRScheduleP.ClientID + "'" +
                                     ",'" + txtPCRSchedulePS.ClientID + "'" +
                                     ",'" + txtPCRSchedulePE.ClientID + "'" +
                                     ",'" + chkPCRScheduleE.ClientID + "'" +
                                     ",'" + txtPCRScheduleES.ClientID + "'" +
                                     ",'" + txtPCRScheduleEE.ClientID + "'" +
                                     ",'" + chkPCRScheduleC.ClientID + "'" +
                                     ",'" + txtPCRScheduleCS.ClientID + "'" +
                                     ",'" + txtPCRScheduleCE.ClientID + "'" +
                                     ",'" + chkFinancial.ClientID + "'" +
                                     ",'" + chkPCRFinancialD.ClientID + "'" +
                                     ",'" + txtPCRFinancialD.ClientID + "'" +
                                     ",'" + chkPCRFinancialP.ClientID + "'" +
                                     ",'" + txtPCRFinancialP.ClientID + "'" +
                                     ",'" + chkPCRFinancialE.ClientID + "'" +
                                     ",'" + txtPCRFinancialE.ClientID + "'" +
                                     ",'" + chkPCRFinancialC.ClientID + "'" +
                                     ",'" + txtPCRFinancialC.ClientID + "'" +
                                     ");");
            imgPCRScheduleCE.Attributes.Add("onclick", "return OpenCalendar('" + txtPCRScheduleCE.ClientID + "');");
            imgPCRScheduleCS.Attributes.Add("onclick", "return OpenCalendar('" + txtPCRScheduleCS.ClientID + "');");
            imgPCRScheduleDE.Attributes.Add("onclick", "return OpenCalendar('" + txtPCRScheduleDE.ClientID + "');");
            imgPCRScheduleDS.Attributes.Add("onclick", "return OpenCalendar('" + txtPCRScheduleDS.ClientID + "');");
            imgPCRScheduleEE.Attributes.Add("onclick", "return OpenCalendar('" + txtPCRScheduleEE.ClientID + "');");
            imgPCRScheduleES.Attributes.Add("onclick", "return OpenCalendar('" + txtPCRScheduleES.ClientID + "');");
            imgPCRSchedulePE.Attributes.Add("onclick", "return OpenCalendar('" + txtPCRSchedulePE.ClientID + "');");
            imgPCRSchedulePS.Attributes.Add("onclick", "return OpenCalendar('" + txtPCRSchedulePS.ClientID + "');");
            imgPCRFinancialC.Attributes.Add("onclick", "return OpenCalculator('" + txtPCRFinancialC.ClientID + "');");
            imgPCRFinancialD.Attributes.Add("onclick", "return OpenCalculator('" + txtPCRFinancialD.ClientID + "');");
            imgPCRFinancialE.Attributes.Add("onclick", "return OpenCalculator('" + txtPCRFinancialE.ClientID + "');");
            imgPCRFinancialP.Attributes.Add("onclick", "return OpenCalculator('" + txtPCRFinancialP.ClientID + "');");
        }