private void PopulateRecordingInfo() { clsLoanRecording rec = new clsLoanRecording(this.loan.Property().Address()); if (rec.ID() >= 0) { if (this.loan.Property().State() == "PA") { this.ExpectedSalePriceTextField.IntValue = rec.Instrument(); this.RepaymentAmountTextField.IntValue = rec.Parcel(); } else { this.ExpectedSalePriceTextField.IntValue = rec.Book(); this.RepaymentAmountTextField.IntValue = rec.Page(); } } else { this.ExpectedSalePriceTextField.IntValue = 0; this.RepaymentAmountTextField.IntValue = 0; } }
private void GenerateDischargeLetter() { // identify template string destinationPath = "/Volumes/GoogleDrive/Shared Drives/Resilience/Documents/"; string templatePath = "/Volumes/GoogleDrive/Shared Drives/Resilience/Document Templates/"; switch (this.loan.Property().State()) { case "MD": templatePath += "Certificate of Satisfaction MD"; destinationPath += "Certificate of Satisfaction"; break; case "NJ": templatePath += "Discharge of Mortgage NJ"; destinationPath += "Discharge of Mortgage"; break; case "PA": templatePath += "Satisfaction of Mortgage PA"; destinationPath += "Discharge of Mortgage"; break; case "GA": templatePath += "Cancellation of Security Deed GA"; destinationPath += "Discharge of Mortgage"; break; default: templatePath += "Discharge of Mortgage GN"; destinationPath += "Discharge of Mortgage"; break; } templatePath += " " + this.lender.PathAbbreviation() + " " + this.borrower.PathAbbreviation() + ".docx"; destinationPath += " (" + this.AddressComboBox.StringValue + ").docx"; System.IO.File.Copy(templatePath, destinationPath, true); // find and replace using doc library // get/compute replacement values DateTime todayDate = DateTime.Today.Date; DateTime datedDate = this.loan.OriginationDate().Date; string county = this.loan.Property().County(); string address = this.loan.Property().Address(); string city = this.loan.Property().Town(); DateTime recordDate = (DateTime)this.RecordDatePicker.DateValue; // find and replace DocX newLetter = DocX.Load(destinationPath); if ((this.loan.Property().State() == "NJ") || (this.loan.Property().State() == "MD")) { string book = ExpectedSalePriceTextField.IntValue.ToString("#"); if (book == "0") { book = "____________"; } string pages = RepaymentAmountTextField.IntValue.ToString("#"); if (pages == "0") { pages = "____________"; } newLetter.ReplaceText("[TODAYDAY]", todayDate.Day.ToString()); newLetter.ReplaceText("[TODAYMONTH]", todayDate.ToString("MMMM")); newLetter.ReplaceText("[TODAYYEAR]", todayDate.ToString("yyyy")); newLetter.ReplaceText("[DATEDDATE]", datedDate.ToString("MMMM d, yyyy")); newLetter.ReplaceText("[RECORDDATE]", recordDate.ToString("MMMM d, yyyy")); newLetter.ReplaceText("[ADDRESS]", address); newLetter.ReplaceText("[BOOK]", book); newLetter.ReplaceText("[PAGES]", pages); newLetter.ReplaceText("[COUNTY]", county); newLetter.ReplaceText("[CITY]", city); clsLoanRecording lr = new clsLoanRecording(address); if (lr.ID() < 0) { lr = new clsLoanRecording(this.loan.ID(), Int32.Parse(book), Int32.Parse(pages), 0, 0, recordDate); lr.Save(); } } else if (this.loan.Property().State() == "PA") { string instrument = ExpectedSalePriceTextField.IntValue.ToString("#"); if (instrument == "0") { instrument = "____________"; } string parcel = RepaymentAmountTextField.IntValue.ToString("#"); if (parcel == "0") { parcel = "____________"; } newLetter.ReplaceText("[DATEDDATE]", datedDate.ToString("MMMM d, yyyy")); newLetter.ReplaceText("[RECORDDATE]", recordDate.ToString("MMMM d, yyyy")); newLetter.ReplaceText("[ADDRESS]", address); newLetter.ReplaceText("[CITY]", city); newLetter.ReplaceText("[COUNTY]", county); newLetter.ReplaceText("[TODAYDATE]", todayDate.ToString("MMMM d, yyyy")); newLetter.ReplaceText("[PARCEL]", parcel); newLetter.ReplaceText("[INSTRUMENT]", instrument); clsLoanRecording lr = new clsLoanRecording(address); if (lr.ID() < 0) { int a = Int32.Parse(instrument); int b = Int32.Parse(parcel); lr = new clsLoanRecording(this.loan.ID(), 0, 0, a, b, recordDate); lr.Save(); } } else if (this.loan.Property().State() == "GA") { // COMPLETE GA DISCHARGE FIND/REPLACES } // save new file newLetter.Save(); string destinationPath2 = "/Volumes/GoogleDrive/Shared Drives/"; destinationPath2 += this.lender.Name(); destinationPath2 += "/Loans/" + this.loan.Property().State() + "/" + address + ", " + city; destinationPath2 += "/Sale/Satisfaction of Mortgage (" + address + ").docx"; try { newLetter.SaveAs(destinationPath2); } catch { destinationPath2 = " FAILED"; } // notify this.StatusMessageTextField.StringValue = "Release Letter Created at:/n" + destinationPath; this.StatusMessageTextField.StringValue += "/n/nRelease Letter Copied to:/n" + destinationPath2; }