Ejemplo n.º 1
0
    protected void btnUpdateStatus_OnClick(object sender, EventArgs e)
    {
        DataSet             dsChangeDetails = objCamperApplication.GetChangeRequestDetails(strFJCID);
        structChangeDetails ChangeDetails   = new structChangeDetails();
        string strReason = txtareaUpdateComments.Text;

        if (!string.IsNullOrEmpty(strReason))
        {
            if (dsChangeDetails.Tables[0].Rows.Count > 0)
            {
                ChangeDetails = objCamperApplication.SetChangeDetailsFromDataRow(dsChangeDetails.Tables[0].Rows[0]);
            }
            if (ddlRequestStatus.SelectedValue == Enum.Format(typeof(RequestStatus), RequestStatus.ClosedOrApproved, "D"))
            {
                if (sessionModifiedPenFJCApprovalStatus == ChangeDetails.Current_Status.ToString())
                {
                    string strNewFJCID = string.Empty;
                    string answers     = ConstructCamperAnswers(ChangeDetails.NewSession, ChangeDetails.NewSession_StartDate, ChangeDetails.NewSession_EndDate);
                    objCamperApplication.CopyCamperApplicationForSessionChange(strFJCID, out strNewFJCID, Int32.Parse(secApprovalStatus), Convert.ToInt32(sessionModifiedCreditPending));
                    Session["FJCID"] = strNewFJCID;
                    objCamperApplication.InsertCamperAnswers(strNewFJCID, answers, iUserID.ToString(), strReason);
                    objCamperApplication.UpdateDetailsOnRequestType(strFJCID, strNewFJCID, ChangeDetails.RequestID, "", "Old application cancelled and new application created with second approval status", iUserID, null, null, Int32.Parse(Enum.Format(typeof(RequestStatus), RequestStatus.ClosedOrApproved, "D")));
                }
                else if (cancellationPendingApprovalStatus == ChangeDetails.Current_Status.ToString())
                {
                    string strNewFJCID = string.Empty;
                    objCamperApplication.UpdateStatus(strFJCID, Int32.Parse(cancellationPaymentCreditPending), strReason, iUserID);
                    objCamperApplication.UpdateDetailsOnRequestType(strFJCID, string.Empty, ChangeDetails.RequestID, "", "Cancellation request approved and the payment will be applied for credit.", iUserID, null, null, Int32.Parse(Enum.Format(typeof(RequestStatus), RequestStatus.ClosedOrApproved, "D")));
                }
            }
            else if (ddlRequestStatus.SelectedValue == Enum.Format(typeof(RequestStatus), RequestStatus.Rejected, "D"))
            {
                string strCamperAnswers = string.Empty;
                if (ChangeDetails.RequestType == 2)
                {
                    strCamperAnswers = ConstructCamperAnswers(ChangeDetails.OldSession, ChangeDetails.OldSession_StartDate, ChangeDetails.OldSession_EndDate);
                }

                objCamperApplication.UpdateDetailsOnRequestType(strFJCID, string.Empty, ChangeDetails.RequestID, strCamperAnswers, string.Empty, iUserID, null, null, Int32.Parse(Enum.Format(typeof(RequestStatus), RequestStatus.Rejected, "D")));
            }
            valobj.InnerHtml    = "";
            spnComments.Visible = false;
            string strMessage = ddlRequestStatus.SelectedValue == "3" ? "Request has been approved." : "Request has been rejected.";
            strScript = "<script language=javascript>" + (strMessage != string.Empty ? "alert('" + strMessage + "');" : string.Empty) + "window.opener.location.href = window.opener.location.href;" +
                        "if (window.opener.progressWindow)" +
                        "{    window.opener.progressWindow.close()" +
                        "}    window.close();</script>";
            if (!ClientScript.IsStartupScriptRegistered("clientScript"))
            {
                ClientScript.RegisterStartupScript(Page.GetType(), "clientScript", strScript);
            }
        }
        else
        {
            valobj.InnerHtml    = "<ul><li>Please enter comments</li></ul>";
            spnComments.Visible = true;
        }
    }