Exemplo n.º 1
0
        protected void Page_Load(object sender, EventArgs e)
        {
            intProfile       = Int32.Parse(Request.Cookies["profileid"].Value);
            oRequest         = new Requests(intProfile, dsn);
            oService         = new Services(intProfile, dsn);
            oServiceRequest  = new ServiceRequests(intProfile, dsn);
            oEnhancement     = new Enhancements(intProfile, dsn);
            oPage            = new Pages(intProfile, dsn);
            oResourceRequest = new ResourceRequest(intProfile, dsn);
            oStatusLevel     = new StatusLevels();
            oUser            = new Users(intProfile, dsn);
            oCustomized      = new Customized(intProfile, dsn);
            oFunction        = new Functions(intProfile, dsn, intEnvironment);
            oVariable        = new Variables(intEnvironment);
            if (Request.QueryString["applicationid"] != null && Request.QueryString["applicationid"] != "")
            {
                intApplication = Int32.Parse(Request.QueryString["applicationid"]);
            }
            if (Request.QueryString["pageid"] != null && Request.QueryString["pageid"] != "")
            {
                intPage = Int32.Parse(Request.QueryString["pageid"]);
            }
            if (Request.Cookies["application"] != null && Request.Cookies["application"].Value != "")
            {
                intApplication = Int32.Parse(Request.Cookies["application"].Value);
            }
            if (Request.QueryString["id"] != null && Request.QueryString["id"] != "")
            {
                intID = Int32.Parse(Request.QueryString["id"]);
            }
            if (Request.QueryString["old"] != null && Request.QueryString["old"] != "")
            {
                intIDold = Int32.Parse(Request.QueryString["old"]);
            }

            if (!IsPostBack)
            {
                LoadLists();
            }

            int intMenuTab = 0;

            if (Request.QueryString["menu_tab"] != null && Request.QueryString["menu_tab"] != "")
            {
                intMenuTab = Int32.Parse(Request.QueryString["menu_tab"]);
            }
            Tab oTab = new Tab("", intMenuTab, "divMenu1", true, false);

            oTab.AddTab("Enhancement Details", "");
            if (intID > 0)
            {
                panEnhancement.Visible = true;
                DataSet ds = oEnhancement.Get(intID);
                if (ds.Tables[0].Rows.Count > 0)
                {
                    panNew.Visible   = true;
                    trStatus.Visible = true;
                    lblTitle.Text    = "Edit Enhancement";
                    DataSet dsMessages = oEnhancement.GetMessages(intID);
                    if (!IsPostBack)
                    {
                        txtTitle.Text          = ds.Tables[0].Rows[0]["title"].ToString();
                        txtDescription.Text    = ds.Tables[0].Rows[0]["description"].ToString();
                        ddlUsers.SelectedValue = ds.Tables[0].Rows[0]["users"].ToString();
                        txtURL.Text            = ds.Tables[0].Rows[0]["url"].ToString();
                        if (ds.Tables[0].Rows[0]["url"].ToString() != "")
                        {
                            hypURL.Visible     = true;
                            hypURL.NavigateUrl = ds.Tables[0].Rows[0]["url"].ToString();
                        }
                        if (ds.Tables[0].Rows[0]["screenshot"].ToString() != "")
                        {
                            panUploaded.Visible   = true;
                            hypUpload.NavigateUrl = ds.Tables[0].Rows[0]["screenshot"].ToString();
                        }
                        else
                        {
                            panUpload.Visible = true;
                            hypUpload.Visible = false;
                        }
                        radRelease1.SelectedValue = ds.Tables[0].Rows[0]["release1"].ToString();
                        radRelease2.SelectedValue = ds.Tables[0].Rows[0]["release2"].ToString();
                        int intStatus = Int32.Parse(ds.Tables[0].Rows[0]["status"].ToString());
                        lblStatus.Text = oEnhancement.Status(intID);
                        int intRR = Int32.Parse(ds.Tables[0].Rows[0]["rrid"].ToString());
                        //foreach (DataRow drStep in dsSteps.Tables[0].Rows)
                        //{
                        //    if (drStep["requires_approval"].ToString() == "1" && drStep["approved"].ToString() == "")
                        //        boolApproved = false;
                        //    if (drStep["step"].ToString() == "1")
                        //        boolFunctionalReq = true;
                        //}

                        if (intStatus != (int)EnhancementStatus.Cancelled && intStatus != (int)EnhancementStatus.Completed && intStatus != (int)EnhancementStatus.Denied && intStatus != (int)EnhancementStatus.Duplicate)
                        {
                            trSave1.Visible           = true;
                            trSave2.Visible           = true;
                            btnCancel.Visible         = true;
                            btnUpdate.Visible         = true;
                            btnCancel.CommandArgument = intRR.ToString();
                            if (intStatus == (int)EnhancementStatus.UnderReview)
                            {
                                // Request is active but not yet assigned, so nobody is working on it yet.
                            }
                            else
                            {
                                btnUpdate.Enabled           = false;
                                trLocked.Visible            = true;
                                btnDeleteAttachment.Enabled = false;
                                oTab.AddTab("Functional Requirements", "");
                                DataSet dsSteps = oEnhancement.GetSteps(intID, 1, 0);
                                if (dsSteps.Tables[0].Rows.Count == 1 && dsSteps.Tables[0].Rows[0]["completed"].ToString() != "")
                                {
                                    DataSet dsDocuments = oEnhancement.GetDocuments(intID);
                                    hypFunctionalRequirements.NavigateUrl = dsDocuments.Tables[0].Rows[0]["path"].ToString();
                                    lblDays.Text    = dsDocuments.Tables[0].Rows[0]["days"].ToString();
                                    lblRelease.Text = DateTime.Parse(dsDocuments.Tables[0].Rows[0]["release"].ToString()).ToShortDateString();

                                    if (dsSteps.Tables[0].Rows[0]["approved"].ToString() == "" && dsSteps.Tables[0].Rows[0]["rejected"].ToString() == "")
                                    {
                                        trFunctionalRequirementsDocument.Visible = true;
                                        btnFunctionalApproving.Enabled           = true;
                                        btnFunctionalRejecting.Enabled           = true;
                                        btnFunctionalRejecting.Attributes.Add("onclick", "ShowHideDiv('" + trFunctionalReject.ClientID + "','inline');ShowHideDiv('" + trFunctionalButtons.ClientID + "','none');return false;");
                                        btnFunctionalCancelReject.Attributes.Add("onclick", "ShowHideDiv('" + trFunctionalReject.ClientID + "','none');ShowHideDiv('" + trFunctionalButtons.ClientID + "','inline');return false;");
                                        btnFunctionalApproving.Attributes.Add("onclick", "ShowHideDiv('" + trFunctionalApprove.ClientID + "','inline');ShowHideDiv('" + trFunctionalButtons.ClientID + "','none');return false;");
                                        btnFunctionalCancelApprove.Attributes.Add("onclick", "ShowHideDiv('" + trFunctionalApprove.ClientID + "','none');ShowHideDiv('" + trFunctionalButtons.ClientID + "','inline');return false;");
                                        btnFunctionalReject.Attributes.Add("onclick", "return ValidateText('" + txtFunctionalReject.ClientID + "','Specify why you are rejecting the functional requirements') && confirm('Rejecting the functional requirements document will cause delays in this enhancement being released.\\n\\nAre you sure you want to reject the functional requirements document?') && ProcessButton(this) && LoadWait();");
                                        btnFunctionalApprove.Attributes.Add("onclick", "return ValidateCheck('" + chkApprove.ClientID + "','You must accept the acknowledgement to approve the functional requirements') && ProcessButton(this) && LoadWait();");
                                    }
                                    else
                                    {
                                        trFunctionalButtons.Visible = false;
                                        trFunctionalStatus.Visible  = true;
                                        if (dsSteps.Tables[0].Rows[0]["approved"].ToString() != "")
                                        {
                                            imgFunctionalStatus.ImageUrl = "/images/bigCheckBox.gif";
                                            lblFunctionalStatus.Text     = "Approved on " + dsSteps.Tables[0].Rows[0]["approved"].ToString();
                                        }
                                        if (dsSteps.Tables[0].Rows[0]["rejected"].ToString() != "")
                                        {
                                            imgFunctionalStatus.ImageUrl = "/images/bigError2.gif";
                                            lblFunctionalStatus.Text     = "Rejected on " + dsSteps.Tables[0].Rows[0]["rejected"].ToString();
                                        }
                                    }
                                }
                                oTab.AddTab("Message Thread (" + dsMessages.Tables[0].Rows.Count.ToString() + ")", "");
                                oTab.AddTab("Log (" + oEnhancement.LoadLog(intID, rptLog, lblLog) + ")", "");
                            }
                            btnMessageReplyImage.Attributes.Add("onclick", "ShowHideDiv2('" + divMessageReply.ClientID + "');return false;");
                        }
                        else
                        {
                            btnDeleteAttachment.Visible = false;
                            btnMessageReplyImage.Attributes.Add("onclick", "alert('You can only post a message to an ACTIVE thread.\\n\\nSince this thread is no longer active, additional posts have been disabled');return false;");
                            btnMessageReply.Enabled = false;
                            if (ds.Tables[0].Rows[0]["reason"].ToString() != "")
                            {
                                trComments.Visible = true;
                                lblComments.Text   = ds.Tables[0].Rows[0]["reason"].ToString();
                            }
                        }
                        lblRequestBy.Text = oUser.GetFullName(intProfile);
                        lblRequestOn.Text = DateTime.Parse(ds.Tables[0].Rows[0]["created"].ToString()).ToString();
                    }
                    strMessages = oEnhancement.GetMessages(intID, false, "#E1FFE1");
                }
            }
            else if (intIDold > 0)
            {
                // OLD ENHANCEMENT (Read Only)
                panEnhancement.Visible = true;
                DataSet ds = oCustomized.GetEnhancementByID(intIDold);
                if (ds.Tables[0].Rows.Count > 0)
                {
                    panOld.Visible         = true;
                    lblTitle.Text          = "Edit Enhancement";
                    lblOldTitle.Text       = ds.Tables[0].Rows[0]["title"].ToString();
                    lblOldDescription.Text = ds.Tables[0].Rows[0]["description"].ToString();
                    lblOldModule.Text      = oPage.Get(Int32.Parse(ds.Tables[0].Rows[0]["pageid"].ToString()), "title");
                    lblOldNumUsers.Text    = ds.Tables[0].Rows[0]["num_users"].ToString();
                    if (ds.Tables[0].Rows[0]["url"].ToString() != "")
                    {
                        hypOldURL.NavigateUrl = ds.Tables[0].Rows[0]["url"].ToString();
                    }
                    else
                    {
                        hypOldURL.Visible = false;
                    }
                    if (ds.Tables[0].Rows[0]["path"].ToString() != "")
                    {
                        hypOldAttach.NavigateUrl = ds.Tables[0].Rows[0]["path"].ToString();
                    }
                    else
                    {
                        hypOldAttach.Visible = false;
                    }
                    lblOldStart.Text  = DateTime.Parse(ds.Tables[0].Rows[0]["startdate"].ToString()).ToShortDateString();
                    lblOldEnd.Text    = DateTime.Parse(ds.Tables[0].Rows[0]["enddate"].ToString()).ToShortDateString();
                    lblOldStatus.Text = oStatusLevel.HTMLSupport(Int32.Parse(ds.Tables[0].Rows[0]["status"].ToString()));
                    int intRelease = 0;
                    if (Int32.TryParse(ds.Tables[0].Rows[0]["release"].ToString(), out intRelease) == true && intRelease > 0)
                    {
                        lblOldRelease.Text = DateTime.Parse(oEnhancement.GetVersion(intRelease, "release")).ToLongDateString();
                    }
                    else
                    {
                        lblOldRelease.Text = "To Be Determined";
                    }
                    lblOldRequestedBy.Text = oUser.GetFullName(intProfile);
                    lblOldRequestedOn.Text = DateTime.Parse(ds.Tables[0].Rows[0]["created"].ToString()).ToString();

                    intRequest = Int32.Parse(ds.Tables[0].Rows[0]["requestid"].ToString());
                    oCustomized.UpdateEnhancementNew(intRequest, 0);
                    panMessage.Visible = (oCustomized.GetMessages(intRequest, 0).Tables[0].Rows.Count > 0);
                    strMessages        = oCustomized.GetMessages(intRequest, false, "#E1FFE1");
                    if (ds.Tables[0].Rows[0]["status"].ToString() == "2" || ds.Tables[0].Rows[0]["status"].ToString() == "7")
                    {
                        btnMessage.Attributes.Add("onclick", "ShowHideDiv2('" + divMessage.ClientID + "');return false;");
                    }
                    else
                    {
                        btnMessage.Attributes.Add("onclick", "alert('You can only post a message to an ACTIVE thread.\\n\\nSince this thread is no longer active, additional posts have been disabled');return false;");
                    }
                }
            }
            else
            {
                //panNoEnhancement.Visible = true;
                panEnhancement.Visible   = true;
                hypCommunity.NavigateUrl = oVariable.Community();
                panUpload.Visible        = true;
                lblRequestBy.Text        = oUser.GetFullName(intProfile);
                lblRequestOn.Text        = DateTime.Now.ToString();
                lblTitle.Text            = oPage.Get(intPage, "title");
                btnSave.Visible          = true;
                trSave1.Visible          = true;
                trSave2.Visible          = true;
                panNew.Visible           = true;
            }
            strMenuTab1 = oTab.GetTabs();

            btnSave.Attributes.Add("onclick", "return ValidateText('" + txtTitle.ClientID + "','Please enter a title')" +
                                   " && ValidateText('" + txtDescription.ClientID + "','Please enter a description')" +
                                   " && ValidateDropDown('" + ddlUsers.ClientID + "','Please make a selection for the number of users benefited')" +
                                   " && ValidateRadioList('" + radRelease1.ClientID + "','Please make a selection for your preferred release date')" +
                                   " && ValidateRadioList('" + radRelease2.ClientID + "','Please make a selection for your alternative release date')" +
                                   " && ProcessButton(this) && LoadWait()" +
                                   ";");
            btnUpdate.Attributes.Add("onclick", "return ValidateText('" + txtTitle.ClientID + "','Please enter a title')" +
                                     " && ValidateText('" + txtDescription.ClientID + "','Please enter a description')" +
                                     " && ValidateDropDown('" + ddlUsers.ClientID + "','Please make a selection for the number of users benefited')" +
                                     " && ValidateRadioList('" + radRelease1.ClientID + "','Please make a selection for your preferred release date')" +
                                     " && ValidateRadioList('" + radRelease2.ClientID + "','Please make a selection for your alternative release date')" +
                                     " && ProcessButton(this) && LoadWait()" +
                                     ";");
            btnCancel.Attributes.Add("onclick", "return confirm('WARNING: Any changes related to this enhancement and the ClearView system will be removed.\\n\\nAre you sure you want to cancel this enhancement?') && ProcessButton(this) && LoadWait();");
            btnResponse.Attributes.Add("onclick", "return ValidateText('" + txtResponse.ClientID + "','Please enter a response') && ProcessButton(this) && LoadWait();;");
            btnMessageReply.Attributes.Add("onclick", "return ValidateText('" + txtMessageReply.ClientID + "','Please enter a response') && ProcessButton(this) && LoadWait();;");
            btnDeleteAttachment.Attributes.Add("onclick", "return confirm('Are you sure you want to delete this file?') && ProcessButton(this) && LoadWait();;");
        }