private void SaveChangeRequest() { if (isPaymentDone == "0") { if (txtReason.Text.Trim() != string.Empty) { CamperApplication objCamperApplication = new CamperApplication(); structChangeDetails ChangeDetails = new structChangeDetails(); int requestID = 0; string strFJCID = Session["FJCID"].ToString(); int iUserId = Convert.ToInt32(Session["UsrID"]); ChangeDetails.FJCID = long.Parse(strFJCID); ChangeDetails.RequestType = ddlAdjustmentType.SelectedItem != null?Int32.Parse(ddlAdjustmentType.SelectedValue) : 0; if (ChangeDetails.RequestType == 1) //Cancellation request { int oldStatus = Int32.Parse(ddlStatus.SelectedValue); int newStatus = Convert.ToInt32(ConfigurationManager.AppSettings["Camper Declined to go Camp"]); if (oldStatus == (int)StatusInfo.PaymentRequested || oldStatus == (int)StatusInfo.CamperAttendedCamp) { newStatus = Convert.ToInt32(ConfigurationManager.AppSettings["Payment Cancellation Pending FJC approval"]); } ChangeDetails.Current_Status = newStatus; ChangeDetails.Original_Status = oldStatus; ChangeDetails.CampYearID = (int)Application["CampYear"] - 2008; ChangeDetails.Cancellation_Reason = txtReason.Text.Trim() != string.Empty ? txtReason.Text.Trim() : ""; ChangeDetails.SubmittedDate = DateTime.Now.ToString(); ChangeDetails.RequestStatus = int.Parse(Enum.Format(typeof(RequestStatus), RequestStatus.Submitted, "D")); //Is submit clicked or save & exit ChangeDetails.RequestID = 0; ChangeDetails.CreatedDate = DateTime.Now.ToString(); objCamperApplication.InsertChangeDetails(ChangeDetails, out requestID); //insert changerequest table ChangeDetails.RequestID = requestID; string strType = ChangeDetails.RequestType == 1 ? "Cancellation Request Submitted" : "Session Change Request Submitted"; objCamperApplication.UpdateDetailsOnRequestType(strFJCID, string.Empty, ChangeDetails.RequestID, "", strType, iUserId, null, null, ChangeDetails.RequestStatus); string url = Request.Url.GetLeftPart(UriPartial.Authority); url = url + ConfigurationManager.AppSettings["WorkQueueURL"].ToString(); string strScript = "<script language=javascript> alert('Application has been cancelled.For any details contact FJC');window.location='" + url + "';</script>"; if (!ClientScript.IsStartupScriptRegistered("clientScript")) { ClientScript.RegisterStartupScript(Page.GetType(), "clientScript", strScript); } } } else { lblErr.Text = "Please enter reason for cancellation. If you do <u>not</u> want to cancel this application, click “Work Queue?to abort this action."; } } }
private bool SaveChangeDetails(bool isSubmit, out string strMessage) { char[] ch = new char[1]; ch[0] = Convert.ToChar("$"); CamperApplication objCamperApplication = new CamperApplication(); structChangeDetails ChangeDetails = new structChangeDetails(); string oldGrant, newGrant, oldSession, newSession, reqComments, strCamperAnswers; bool bGrantChange, bFJCAmountPaid, sameAsExistingSession; int requestID = 0; sameAsExistingSession = bGrantChange = bFJCAmountPaid = false; strCamperAnswers = oldGrant = newGrant = oldSession = newSession = reqComments = string.Empty; ChangeDetails.FJCID = long.Parse(strFJCID); ChangeDetails.RequestType = rdBtnLstAdjustmentType.SelectedItem != null?Int32.Parse(rdBtnLstAdjustmentType.SelectedValue) : 0; ChangeDetails.Current_Status = UpdateStatus(out bGrantChange, out bFJCAmountPaid); ChangeDetails.Original_Status = Int32.TryParse(lblCurrStatus.Text, out ChangeDetails.Original_Status) ? Int32.Parse(lblCurrStatus.Text) : 0; //added by sreevani to get campyear id based on fjcid from database. string campYearId = objCamperApplication.getCampYearId(strFJCID); ChangeDetails.CampYearID = Convert.ToInt32(campYearId); if (ChangeDetails.RequestType == 1) //Cancellation request { ChangeDetails.Cancellation_Reason = txtCancelComments.Text.Trim(); if (iUserRole.ToString() == FJCAdminUserRole) { reqComments = txtComments.Text.Trim() != string.Empty ? txtComments.Text.Trim() : txtCancelComments.Text.Trim(); } else if (iUserRole.ToString() == FEDAdminUserRole) { reqComments = txtCancelComments.Text.Trim(); } } else if (ChangeDetails.RequestType == 2) //Session change request { if (!txtCampSession.Text.Equals(string.Empty)) { ChangeDetails.NewSession = txtCampSession.Text.Trim(); ChangeDetails.NewSession_StartDate = txtNewStartDate.Text.Trim(); ChangeDetails.NewSession_EndDate = txtNewEndDate.Text.Trim(); } else if (ddlCampSession.SelectedValue != "0" && ddlCampSession.SelectedIndex != -1) { ChangeDetails.NewSession = ddlCampSession.SelectedValue; ChangeDetails.NewSession_StartDate = lblSysNewStartDate.Text; ChangeDetails.NewSession_EndDate = lblSysNewEndDate.Text; } ChangeDetails.OldSession = lblSession.Text; ChangeDetails.OldSession_StartDate = lblStartDate.Text; ChangeDetails.OldSession_EndDate = lblEndDate.Text; sameAsExistingSession = IsNewSessionDetailsSameAsExisting(); if (sameAsExistingSession) { valobj.InnerHtml = "<ul><li>New session is the same as existing session, please change the session name or dates again.</li></ul>"; strMessage = ""; return(false); } ChangeDetails.NewGrantAmount = lblNewGrant.Text.TrimStart(ch) != string.Empty ? Convert.ToDouble(lblNewGrant.Text.TrimStart(ch)) : 0.0; ChangeDetails.OldGrantAmount = lblGrant.Text.TrimStart(ch) != string.Empty ? Convert.ToDouble(lblGrant.Text.TrimStart(ch)) : 0.0; oldSession = lblStartDate.Text + " - " + lblEndDate.Text; newSession = ChangeDetails.NewSession_StartDate + " - " + ChangeDetails.NewSession_EndDate; } if (isSubmit && (hdnRequestStatus.Value == "0" || String.IsNullOrEmpty(hdnRequestStatus.Value))) //Request not submitted { ChangeDetails.SubmittedDate = DateTime.Now.ToString(); } ChangeDetails.RequestStatus = isSubmit ? int.Parse(Enum.Format(typeof(RequestStatus), RequestStatus.Submitted, "D")):0; //Is submit clicked or save & exit ChangeDetails.RequestID = String.IsNullOrEmpty(hdnRequestID.Value) ? 0 : Int32.Parse(hdnRequestID.Value); if (hdnRequestStatus.Value == "0" || String.IsNullOrEmpty(hdnRequestStatus.Value)) { if (ChangeDetails.RequestID != 0) { objCamperApplication.UpdateChangeDetails(ChangeDetails); //update changerequest table } else { ChangeDetails.CreatedDate = DateTime.Now.ToString(); objCamperApplication.InsertChangeDetails(ChangeDetails, out requestID); //insert changerequest table hdnRequestID.Value = requestID.ToString(); } if (ChangeDetails.RequestStatus == 1) //if it is submit request { string strType = ChangeDetails.RequestType == 1 ? "Cancellation Request Submitted" : "Session Change Request Submitted"; if (ChangeDetails.Current_Status == ChangeDetails.Original_Status)//if the there is no change in status (session change request) then update new session details in tblcamperanswer table { if (pnlSystemSessionDates.Visible == true) { strCamperAnswers = ConstructCamperAnswers(ddlCampSession.SelectedValue, ChangeDetails.NewSession_StartDate, ChangeDetails.NewSession_EndDate); } else if (pnlManualSessionDates.Visible == true) { strCamperAnswers = ConstructCamperAnswers(txtCampSession.Text, ChangeDetails.NewSession_StartDate, ChangeDetails.NewSession_EndDate); } strCamperAnswers = string.IsNullOrEmpty(strCamperAnswers) ? null : strCamperAnswers; } objCamperApplication.UpdateDetailsOnRequestType(strFJCID, string.Empty, ChangeDetails.RequestID, strCamperAnswers, strType, iUserID, null, null, ChangeDetails.RequestStatus); strMessage = "Request has been submitted successfully."; } else { strMessage = "Request has been saved successfully."; } } else { strMessage = "Request " + lblRequestStatus.Text.ToLower() + ", cannot do any modifications."; } hdnNewRequest.Value = string.Empty; return(true); }