protected void UpdateRecord(string PayPalStatus, string mailToName, string Address, string Address1, string City, string State, string Zip, string Note, string PP_PaymentId, string PP_Response) { try { GiftCertificateController controller = new GiftCertificateController(); GiftCertificateInfo item = new GiftCertificateInfo(); item.ItemId = Convert.ToInt32(Request.QueryString["itemId"].ToString());// itemId; item.MailTo = mailToName; item.MailToAddress = Address; item.MailToAddress1 = Address1; item.MailToCity = City; item.MailToState = State; item.MailToZip = Zip; item.Notes = Note; item.PaypalPaymentState = PayPalStatus; item.PP_PaymentId = PP_PaymentId; item.PP_Response = PP_Response; controller.GiftCertUpdateWithPayPalReponse(item); //if (cbxEmailPurchaser.Checked) //{ // EmailPurchaser(); //} //Response.Redirect(Globals.NavigateURL(PortalSettings.ActiveTab.TabID, "List", "mid=" + ModuleId.ToString()), true); } catch (Exception ex) { Exceptions.ProcessModuleLoadException(this, ex); } }
protected void GridView1_RowDeleting(object sender, GridViewDeleteEventArgs e) { int itemID = (int)GridView1.DataKeys[e.RowIndex].Value; GiftCertificateController controller = new GiftCertificateController(); controller.DeleteGiftCert(this.ModuleId, itemID); FillGrid(); }
public void FillGrid() { try { if (Request.QueryString["currentpage"] != null) { _CurrentPage = Convert.ToInt32(Request.QueryString["currentpage"].ToString()); } else { _CurrentPage = 1; } List <GiftCertificateInfo> items; GiftCertificateController controller = new GiftCertificateController(); items = controller.GetGiftCerts(this.ModuleId, DateTime.Parse(txtStartDate.Text.ToString()), DateTime.Parse(txtEndDate.Text.ToString())); PagedDataSource objPagedDataSource = new PagedDataSource(); objPagedDataSource.DataSource = items; if (objPagedDataSource.PageCount > 0) { objPagedDataSource.PageSize = PageSize; objPagedDataSource.CurrentPageIndex = _CurrentPage - 1; objPagedDataSource.AllowPaging = true; } //bind the data GridView1.DataSource = objPagedDataSource; GridView1.DataBind(); if (PageSize == 0 || items.Count <= PageSize) { PagingControl1.Visible = false; } else { PagingControl1.Visible = true; PagingControl1.TotalRecords = items.Count; PagingControl1.PageSize = PageSize; PagingControl1.CurrentPage = _CurrentPage; PagingControl1.TabID = TabId; PagingControl1.QuerystringParams = "ctl=List&mid=" + this.ModuleId; } } catch (Exception ex) { Exceptions.ProcessModuleLoadException(this, ex); } }
protected void cmdDelete_Click(object sender, EventArgs e) { try { if (!Null.IsNull(itemId)) { GiftCertificateController controller = new GiftCertificateController(); controller.DeleteGiftCert(this.ModuleId, itemId); Response.Redirect(Globals.NavigateURL(PortalSettings.ActiveTab.TabID, "List", "mid=" + ModuleId.ToString()), true); // Response.Redirect(Globals.NavigateURL(), true); } } catch (Exception ex) { Exceptions.ProcessModuleLoadException(this, ex); } }
public void GetGiftCertRecord(int itemID) { try { //check we have an item to lookup if (!Null.IsNull(itemId)) { //load the item GiftCertificateController controller = new GiftCertificateController(); item = controller.GetGiftCert(itemId); if (item != null) { if (item.PaypalPaymentState.ToString().Length > 0) { Response.Redirect(Globals.NavigateURL("Access Denied"), true); } TextInfo textInfo = new CultureInfo("en-US", false).TextInfo; //NumberToWords(Int32.Parse(item.CertAmount.ToString())).ToString() lblCertAmount.Text = String.Format("{0:f2}", item.CertAmount) + " - " + textInfo.ToTitleCase(NumberToWords(Int32.Parse(item.CertAmount.ToString())).ToString()).ToString() + " Dollars"; lblRecipient.Text = item.ToName; lblPurchaser.Text = item.FromName + "<br />" + item.FromEmail + "<br />" + item.FromPhone; lblMailingTo.Text = item.MailTo + "<br />" + item.MailToAddress; if (item.MailToAddress1.ToString().Length > 0) { lblMailingTo.Text += "<br />" + item.MailToAddress1; } lblMailingTo.Text += "<br />" + item.MailToCity + ", " + item.MailToState + " " + item.MailToZip; string MailAddress = ""; MailAddress = item.ToName + Environment.NewLine + item.MailToAddress + " " + item.MailToAddress1 + Environment.NewLine + item.MailToCity + ", " + item.MailToState + " " + item.MailToZip; lblNotes.Text = item.Notes; } else { Response.Redirect(Globals.NavigateURL(), true); } } } catch (Exception ex) { Exceptions.ProcessModuleLoadException(this, ex); } }
protected void cmdUpdate_Click(object sender, EventArgs e) { try { GiftCertificateController controller = new GiftCertificateController(); GiftCertificateInfo item = new GiftCertificateInfo(); item.IsProcessed = Convert.ToBoolean(isProcessed.SelectedValue.ToString()); item.ItemId = itemId; item.ModuleId = this.ModuleId; item.UpdatedByUserID = this.UserId; item.ToName = txtRecipientName.Text.ToString(); item.CertAmount = Convert.ToDouble(txtCertAmount.Text.ToString()); item.MailTo = txtMailToName.Text.ToString(); item.MailToAddress = txtToAddress.Text.ToString(); item.MailToAddress1 = txtToAddress1.Text.ToString(); item.MailToCity = txtToCity.Text.ToString(); item.MailToState = ddlStatesRecipient.SelectedValue.ToString(); item.MailToZip = txtToZip.Text.ToString(); item.MailTo = txtMailToName.Text.ToString(); item.FromName = txtFromName.Text.ToString(); item.FromPhone = txtFromPhone.Text.ToString(); item.FromEmail = txtFromEmail.Text.ToString(); item.Notes = txtSpecialInstructions.Text.ToString(); controller.GiftCertUpdateGiftCert(item); //.UpdateGiftCert(item); // Response.Redirect("MakePayment.aspx", true); if (cbxEmailPurchaser.Checked) { EmailPurchaser(); } //Response.Redirect(Globals.NavigateURL(), true); Response.Redirect(Globals.NavigateURL(PortalSettings.ActiveTab.TabID, "List", "mid=" + ModuleId.ToString()), true); } catch (Exception ex) { Exceptions.ProcessModuleLoadException(this, ex); } }
public void GetGiftCertRecord(int itemID) { try { //check we have an item to lookup if (!Null.IsNull(itemId)) { //load the item GiftCertificateController controller = new GiftCertificateController(); GiftCertificateInfo item = controller.GetGiftCert(itemId); if (item != null) { txtCertAmount.Text = String.Format("{0:f2}", item.CertAmount); txtToName.Text = item.ToName; txtFromName.Text = item.FromName; txtFromEmail.Text = item.FromEmail; txtFromPhone.Text = item.FromPhone; txtMailToName.Text = item.MailTo; txtToAddress.Text = item.MailToAddress; txtToAddress1.Text = item.MailToAddress1; txtToCity.Text = item.MailToCity; ddlStatesRecipient.SelectedValue = item.MailToState; txtToZip.Text = item.MailToZip; txtNotes.Text = item.Notes; Page.Validate(); if (item.PaypalPaymentState.ToString().Length > 0) { Response.Redirect(Globals.NavigateURL("Access Denied"), true); } } else { Response.Redirect(Globals.NavigateURL(), true); } } } catch (Exception ex) { Exceptions.ProcessModuleLoadException(this, ex); } }
protected void LinkButton1_Click(object sender, EventArgs e) { try { GiftCertificateController controller = new GiftCertificateController(); GiftCertificateInfo item = new GiftCertificateInfo(); item.ModuleId = this.ModuleId; item.ItemId = Convert.ToInt32(Request.QueryString["itemId"].ToString());// itemId; item.MailTo = txtMailToName.Text.ToString(); item.MailToAddress = txtToAddress.Text.ToString(); item.MailToAddress1 = txtToAddress1.Text.ToString(); item.MailToCity = txtToCity.Text.ToString(); item.MailToState = ddlStatesRecipient.SelectedValue.ToString(); item.MailToZip = txtToZip.Text.ToString(); controller.GiftCertUpdateShipAddress(item); lblResults.Text = "<b>Shipping Address Updated"; lblResults.Text += "</b><br><br>The gift certificate will be mailed to: <br><br>" + txtMailToName.Text.ToString(); lblResults.Text += "<br>" + txtToAddress.Text.ToString(); if (txtToAddress1.Text.ToString().Length > 1) { lblResults.Text += "<br>" + txtToAddress1.Text.ToString(); } lblResults.Text += "<br>" + txtToCity.Text.ToString(); lblResults.Text += ", " + ddlStatesRecipient.SelectedValue.ToString(); lblResults.Text += " " + txtToZip.Text.ToString(); SendGiftCertEmailAddressUpdated(Int32.Parse(Request.QueryString["itemId"].ToString())); } catch (Exception ex) { Exceptions.ProcessModuleLoadException(this, ex); } }
protected void Page_Load(object sender, EventArgs e) { try { LoadSettings(); if (_isAuthorized) { } else { Response.Redirect(Globals.NavigateURL("Access Denied"), true); } if (Request.QueryString["ItemId"] != null) { itemId = Int32.Parse(Request.QueryString["ItemId"]); } if (!IsPostBack) { //load the data into the control the first time //we hit this page GetDropDownLists(); LoadModuleTitle(); cmdDelete.Attributes.Add("onClick", "javascript:return confirm('" + Localization.GetString("DeleteItem") + "');"); //check we have an item to lookup if (!Null.IsNull(itemId)) { //load the item GiftCertificateController controller = new GiftCertificateController(); GiftCertificateInfo item = controller.GetGiftCert(itemId); if (item != null) { // Response.Write(item); //lblMailToRec.Text = item.MailTo; txtCertAmount.Text = String.Format("{0:f2}", item.CertAmount); isProcessed.SelectedIndex = Convert.ToInt32(item.IsProcessed); txtFromEmail.Text = item.FromEmail; txtFromName.Text = item.FromName; txtFromPhone.Text = item.FromPhone; ddlStatesRecipient.SelectedValue = item.MailToState; txtMailToName.Text = item.MailTo; txtToAddress.Text = item.MailToAddress; txtToAddress1.Text = item.MailToAddress1; txtToCity.Text = item.MailToCity; txtToZip.Text = item.MailToZip; txtRecipientName.Text = item.ToName; txtSpecialInstructions.Text = item.Notes; txtPaypalPaymentStatee.Text = item.PaypalPaymentState.ToUpper(); if (txtPaypalPaymentStatee.Text.ToString() == "APPROVED") { lblOrderStatus.Text = "PAYMENT " + txtPaypalPaymentStatee.Text.ToString(); } else { lblOrderStatus.Text = "<span style='color:Red;'>NO RECORD OF PAYMENT</span>"; } txtPP_PaymentId.Text = item.PP_PaymentId; txtPP_Response.Text = item.PP_Response; string MailAddress = ""; string line2Address = ""; if (item.MailToAddress1.ToString().Length > 1) { line2Address = Environment.NewLine + item.MailToAddress1.ToString(); } MailAddress = item.MailTo + Environment.NewLine + item.MailToAddress + line2Address.ToString() + Environment.NewLine + item.MailToCity + ", " + item.MailToState + " " + item.MailToZip; txtMailingAddresses.Text = MailAddress.ToString(); } else { Response.Redirect(Globals.NavigateURL(), true); } } else { cmdDelete.Visible = false; } } } catch (Exception ex) { Exceptions.ProcessModuleLoadException(this, ex); } }
public void Init() { var giftDetails = new List <GiftCertificateDetail>() { new GiftCertificateDetail { GiftCertificateID = 1, AccountNumber = 1, BillOfLoading = "1", Detail = new Detail { DetailID = 1, Name = "WFP" }, CommodityID = 1, Commodity = new Commodity() { CommodityID = 1, Name = "CSB" } } }; ; var gifts = new List <GiftCertificate>() { new GiftCertificate() { GiftCertificateID = 1, ProgramID = 1, ReferenceNo = "1", ShippingInstructionID = 1, ShippingInstruction = new ShippingInstruction() { ShippingInstructionID = 1, Value = "SI-001" }, DonorID = 1, Donor = new Donor() { DonorID = 1, Name = "WFP" }, GiftCertificateDetails = giftDetails }, new GiftCertificate() { GiftCertificateID = 1, ProgramID = 1, ReferenceNo = "1", ShippingInstructionID = 1, ShippingInstruction = new ShippingInstruction() { ShippingInstructionID = 1, Value = "SI-001" }, DonorID = 1, Donor = new Donor() { DonorID = 1, Name = "WFP" }, GiftCertificateDetails = giftDetails }, new GiftCertificate() { GiftCertificateID = 1, ProgramID = 1, ReferenceNo = "1", ShippingInstructionID = 1, ShippingInstruction = new ShippingInstruction() { ShippingInstructionID = 1, Value = "SI-001" }, DonorID = 1, Donor = new Donor() { DonorID = 1, Name = "WFP" }, GiftCertificateDetails = giftDetails } }; var commonService = new Mock <ICommonService>(); commonService.Setup( t => t.GetCommodities(It.IsAny <Expression <Func <Commodity, bool> > >(), It.IsAny <Func <IQueryable <Commodity>, IOrderedQueryable <Commodity> > >(), It.IsAny <string>())).Returns(new List <Commodity>() { new Commodity() { CommodityID = 1, Name = "CSB" } }); commonService.Setup( t => t.GetCommodityTypes(It.IsAny <Expression <Func <CommodityType, bool> > >(), It.IsAny <Func <IQueryable <CommodityType>, IOrderedQueryable <CommodityType> > >(), It.IsAny <string>())).Returns(new List <CommodityType>() { new CommodityType() { CommodityTypeID = 1, Name = "CSB++" } }); commonService.Setup( t => t.GetDetails(It.IsAny <Expression <Func <Detail, bool> > >(), It.IsAny <Func <IQueryable <Detail>, IOrderedQueryable <Detail> > >(), It.IsAny <string>())).Returns(new List <Detail>() { new Detail() { DetailID = 1, Name = "CSB" } }); commonService.Setup( t => t.GetDonors(It.IsAny <Expression <Func <Donor, bool> > >(), It.IsAny <Func <IQueryable <Donor>, IOrderedQueryable <Donor> > >(), It.IsAny <string>())).Returns(new List <Donor>() { new Donor() { DonorID = 1, Name = "WFP" } }); commonService.Setup( t => t.GetPrograms(It.IsAny <Expression <Func <Program, bool> > >(), It.IsAny <Func <IQueryable <Program>, IOrderedQueryable <Program> > >(), It.IsAny <string>())).Returns(new List <Program>() { new Program() { ProgramID = 1, Name = "PSNP" } }); var giftCertificateService = new Mock <IGiftCertificateService>(); giftCertificateService.Setup(t => t.IsSINumberNewOrEdit(It.IsAny <string>(), It.IsAny <int>())).Returns(true); giftCertificateService.Setup(t => t.Get(It.IsAny <Expression <Func <GiftCertificate, bool> > >(), It.IsAny <Func <IQueryable <GiftCertificate>, IOrderedQueryable <GiftCertificate> > >(), It.IsAny <string>())).Returns(gifts); giftCertificateService.Setup(t => t.AddGiftCertificate(It.IsAny <GiftCertificate>())).Returns(true); var giftCertificateDetailService = new Mock <IGiftCertificateDetailService>(); var transactionService = new Mock <ITransactionService>(); var letterTemplateService = new Mock <ILetterTemplateService>(); transactionService.Setup(t => t.PostGiftCertificate(It.IsAny <int>())).Returns(true); var userAccountService = new Mock <IUserAccountService>(); userAccountService.Setup(t => t.GetUserInfo(It.IsAny <string>())).Returns(new UserInfo() { UserName = "******", DatePreference = "en" }); var fakeContext = new Mock <HttpContextBase>(); var identity = new GenericIdentity("User"); var principal = new GenericPrincipal(identity, null); fakeContext.Setup(t => t.User).Returns(principal); var controllerContext = new Mock <ControllerContext>(); controllerContext.Setup(t => t.HttpContext).Returns(fakeContext.Object); UnitOfWork _unitOfWork = new UnitOfWork(); var log = new Mock <ILog>(); var shippingInstruction = new List <ShippingInstruction> { new ShippingInstruction { ShippingInstructionID = 1, Value = "40401/32664.23" }, new ShippingInstruction { ShippingInstructionID = 2, Value = "00020272" } }; var shippingInstructionService = new Mock <IShippingInstructionService>(); shippingInstructionService.Setup(m => m.GetAllShippingInstruction()).Returns(shippingInstruction); _giftCertificateController = new GiftCertificateController(giftCertificateService.Object, giftCertificateDetailService.Object, commonService.Object, transactionService.Object, letterTemplateService.Object, _unitOfWork, userAccountService.Object, shippingInstructionService.Object, log.Object); _giftCertificateController.ControllerContext = controllerContext.Object; }
public void SendGiftCertEmail(int _itemID) { try { //load the item GiftCertificateController controller = new GiftCertificateController(); GiftCertificateInfo item = controller.GetGiftCert(_itemID); if (item != null) { GiftCertificateSettings settingsData = new GiftCertificateSettings(this.TabModuleId); string RedirectURL = "http://" + Request.Url.Host + "/Success/TabID/" + settingsData.RedirectPage + "/Default.aspx"; // BUILD E-MAIL BODY string EmailContent = ""; EmailContent += "<dl>"; EmailContent += "<dt><strong>" + Localization.GetString("lblCertAmount.Text", LocalResourceFile) + "</strong></dt>"; EmailContent += "<dd>" + String.Format("{0:c}", item.CertAmount) + "<br /> </dd>"; // EmailContent += "<br clear=all>"; EmailContent += "<dt><strong>" + Localization.GetString("lblToName.Text", LocalResourceFile) + "</strong></dt>"; EmailContent += "<dd>" + item.ToName.ToString() + "<br /> </dd>"; EmailContent += "</dl>"; // EmailContent += "<br clear=all>"; EmailContent += "<dl>"; EmailContent += "<dt><strong>" + Localization.GetString("lblFromName.Text", LocalResourceFile) + "</strong></dt>"; EmailContent += "<dd>" + item.FromName.ToString(); EmailContent += "<br>" + item.FromPhone.ToString(); EmailContent += "<br>" + item.FromEmail.ToString(); EmailContent += "<br /> </dd>"; EmailContent += "</dl>"; // EmailContent += "<br clear=all>"; EmailContent += "<dl>"; EmailContent += "<dt><strong>" + Localization.GetString("lblMailTo.Text", LocalResourceFile) + "</strong></dt>"; EmailContent += "<dd>" + item.MailTo.ToString(); EmailContent += "<br>" + item.MailToAddress.ToString(); if (item.MailToAddress1.ToString().Length > 1) { EmailContent += "<br>" + item.MailToAddress1.ToString(); } EmailContent += "<br>" + item.MailToCity.ToString() + ", " + item.MailToState.ToString() + " " + item.MailToZip.ToString(); EmailContent += "<br /> </dd>"; EmailContent += "</dl>"; // EmailContent += "<br clear=all>"; EmailContent += "<dl>"; EmailContent += "<dt><strong>" + Localization.GetString("emailNotes.Text", LocalResourceFile) + "</strong></dt>"; EmailContent += "<dd>" + item.Notes.ToString() + "<br /> </dd>"; EmailContent += "</dl>"; EmailContent += "<p>Page Submitted: " + Globals.NavigateURL() + "</p>"; //EMAIL THE PURCHASER string EmailFrom = ""; if (settingsData.EmailFrom.Length > 1) { EmailFrom = settingsData.EmailFrom.ToString(); } else { EmailFrom = PortalSettings.Email.ToString(); } // NEW string SMTPUserName = DotNetNuke.Entities.Controllers.HostController.Instance.GetString("SMTPUsername"); string[] emptyStringArray = new string[0]; DotNetNuke.Services.Mail.Mail.SendMail(SMTPUserName.ToString(), item.FromEmail.Trim().ToString(), "", "", EmailFrom.ToString(), DotNetNuke.Services.Mail.MailPriority.Normal, settingsData.EmailSubject.ToString(), DotNetNuke.Services.Mail.MailFormat.Html, System.Text.Encoding.ASCII, EmailContent.ToString(), emptyStringArray, "", "", "", "", true); // EMAIL THE settingsData.EmailNotify // ADD NOTE for ADMINS . . . . EmailContent += "<p><b>Administrators must log in to process gift certificate.</b></p>"; if (settingsData.EmailNotify.Length > 1) { string FromPurchaserEmail = item.FromEmail.ToString(); string emailAddress = settingsData.EmailNotify.Replace(" ", ""); string[] valuePair = emailAddress.Split(new char[] { ';' }); // string[] emailAttachemnts = null ; for (int i = 0; i <= valuePair.Length - 1; i++) { DotNetNuke.Services.Mail.Mail.SendMail(SMTPUserName.ToString(), valuePair[i].Trim().ToString(), "", "", FromPurchaserEmail.ToString(), DotNetNuke.Services.Mail.MailPriority.Normal, "New Order - " + settingsData.EmailSubject.ToString(), DotNetNuke.Services.Mail.MailFormat.Html, System.Text.Encoding.ASCII, EmailContent.ToString(), emptyStringArray, "", "", "", "", true); //MailFrom, MailTo, Cc, Bcc, ReplyTo, Priority, Subject, BodyFormat, BodyEncoding, Body, Attachments, SMTPServer, SMTPAuthentication, SMTPUsername, SMTPPassword, SMTPEnableSSL } } string TempAddUserRole = ""; if (settingsData.AddUserRole != null) { TempAddUserRole = settingsData.AddUserRole; } ////CREATE USER ACCOUNT //if (settingsData.AddUserRole.Length > 0) //{ // CreateNewUser(txtFromName.Text, txtFromEmail.Text, TempAddUserRole); //} //if (settingsData.RedirectPage.Length > 0) //{ // Response.Redirect(RedirectURL.ToString(), true); // Response.Redirect(settingsData.RedirectPage, true); //} //else //{ // Response.Redirect(Globals.NavigateURL(), true); //} } else { Response.Redirect(Globals.NavigateURL(), true); } } catch (Exception ex) { Exceptions.ProcessModuleLoadException(this, ex); } }
public void SendGiftCertEmailAddressUpdated(int _itemID) { try { //load the item GiftCertificateController controller = new GiftCertificateController(); GiftCertificateInfo item = controller.GetGiftCert(_itemID); if (item != null) { GiftCertificateSettings settingsData = new GiftCertificateSettings(this.TabModuleId); string RedirectURL = "http://" + Request.Url.Host + "/Success/TabID/" + settingsData.RedirectPage + "/Default.aspx"; // BUILD E-MAIL BODY string EmailContent = ""; EmailContent += "<dl>"; EmailContent += "<dt><strong>" + Localization.GetString("lblCertAmount.Text", LocalResourceFile) + "</strong></dt>"; EmailContent += "<dd>" + String.Format("{0:c}", item.CertAmount) + "<br /> </dd>"; EmailContent += "<dt><strong>" + Localization.GetString("lblToName.Text", LocalResourceFile) + "</strong></dt>"; EmailContent += "<dd>" + item.ToName.ToString() + "<br /> </dd>"; EmailContent += "</dl>"; EmailContent += "<dl>"; EmailContent += "<dt><strong>" + Localization.GetString("lblFromName.Text", LocalResourceFile) + "</strong></dt>"; EmailContent += "<dd>" + item.FromName.ToString(); EmailContent += "<br>" + item.FromPhone.ToString(); EmailContent += "<br>" + item.FromEmail.ToString(); EmailContent += "<br /> </dd>"; EmailContent += "</dl>"; EmailContent += "<dl>"; EmailContent += "<dt><strong>" + Localization.GetString("lblMailTo.Text", LocalResourceFile) + "</strong></dt>"; EmailContent += "<dd>" + item.MailTo.ToString(); EmailContent += "<br>" + item.MailToAddress.ToString(); if (item.MailToAddress1.ToString().Length > 1) { EmailContent += "<br>" + item.MailToAddress1.ToString(); } EmailContent += "<br>" + item.MailToCity.ToString() + ", " + item.MailToState.ToString() + " " + item.MailToZip.ToString(); EmailContent += "<br /> </dd>"; EmailContent += "</dl>"; EmailContent += "<dl>"; EmailContent += "<dt><strong>" + Localization.GetString("emailNotes.Text", LocalResourceFile) + "</strong></dt>"; EmailContent += "<dd>" + item.Notes.ToString() + "<br /> </dd>"; EmailContent += "</dl>"; EmailContent += "<p>Page Submitted: " + Globals.NavigateURL() + "</p>"; //EMAIL THE PURCHASER string EmailFrom = ""; if (settingsData.EmailFrom.Length > 1) { EmailFrom = settingsData.EmailFrom.ToString(); } else { EmailFrom = PortalSettings.Email.ToString(); } string SMTPUserName = DotNetNuke.Entities.Controllers.HostController.Instance.GetString("SMTPUsername"); // string[] emailAttachemnts1 = null; string[] emailAttachemnts1 = new string[0]; DotNetNuke.Services.Mail.Mail.SendMail(SMTPUserName.ToString(), item.FromEmail.ToString().Trim(), "", "", EmailFrom.ToString(), DotNetNuke.Services.Mail.MailPriority.Normal, "Address Correction - " + settingsData.EmailSubject.ToString(), DotNetNuke.Services.Mail.MailFormat.Html, System.Text.ASCIIEncoding.ASCII, EmailContent.ToString(), emailAttachemnts1, string.Empty, string.Empty, string.Empty, string.Empty, true); // DotNetNuke.Services.Mail.Mail.SendMail(EmailFrom.ToString(), item.FromEmail.ToString(), "", "Address Correction - " + settingsData.EmailSubject, EmailContent.ToString(), "", "HTML", "", "", "", ""); // EMAIL THE settingsData.EmailNotify // ADD NOTE for ADMINS . . . . EmailContent += "<p><b>Administrators must log in to process gift certificate.</b></p>"; if (settingsData.EmailNotify.ToString().Length > 1) { string FromPurchaserEmail = item.FromEmail.ToString(); string emailAddress = settingsData.EmailNotify.Replace(" ", ""); string[] valuePair = emailAddress.Split(new char[] { ';' }); //string SMTPUserName = DotNetNuke.Entities.Controllers.HostController.Instance.GetString("SMTPUsername"); for (int i = 0; i <= valuePair.Length - 1; i++) { // DotNetNuke.Services.Mail.Mail.SendMail(FromPurchaserEmail, valuePair[i].ToString().Trim(), "", "Address Correction - " + settingsData.EmailSubject, EmailContent.ToString(), "", "HTML", "", "", "", ""); DotNetNuke.Services.Mail.Mail.SendMail(SMTPUserName.ToString(), valuePair[i].ToString().Trim(), "", "", FromPurchaserEmail.ToString(), DotNetNuke.Services.Mail.MailPriority.Normal, "Address Correction - " + settingsData.EmailSubject, DotNetNuke.Services.Mail.MailFormat.Html, System.Text.Encoding.Default, EmailContent.ToString(), emailAttachemnts1, "", "", "", "", true); } } } else { Response.Redirect(Globals.NavigateURL(), true); } } catch (Exception ex) { Exceptions.ProcessModuleLoadException(this, ex); } }
void Init() { var giftCerfificate = new List <GiftCertificate> { new GiftCertificate { GiftCertificateID = 1, GiftDate = new DateTime(12 / 12 / 2013), DonorID = 2, SINumber = "12121", ReferenceNo = "45461212", Vessel = "MAERSK UTAH", ETA = new DateTime(11 / 11 / 2012), IsPrinted = false, ProgramID = 1, DModeOfTransport = 14, PortName = "Djibouti" }, new GiftCertificate { GiftCertificateID = 2, GiftDate = new DateTime(12 / 12 / 2013), DonorID = 1, SINumber = "963258", ReferenceNo = "478547", Vessel = "MSC MARYLENA", ETA = new DateTime(11 / 11 / 2012), IsPrinted = false, ProgramID = 2, DModeOfTransport = 14, PortName = "Djibouti" } }; var giftCerfificateService = new Mock <IGiftCertificateService>(); giftCerfificateService.Setup(t => t.GetAllGiftCertificate()).Returns(giftCerfificate); var commodities = new List <Commodity> { new Commodity { CommodityID = 1, Name = "Cereal", CommodityCode = "CER", CommodityTypeID = 1, ParentID = null }, new Commodity { CommodityID = 5, Name = "Wheat", CommodityCode = null, CommodityTypeID = 1, ParentID = 1 }, }; var commodityService = new Mock <ICommodityService>(); commodityService.Setup(t => t.GetAllCommodity()).Returns(commodities); var userProfiles = new List <UserProfile> { new UserProfile { UserProfileID = 1, UserName = "******", Password = "******", Email = "*****@*****.**" }, new UserProfile { UserProfileID = 2, UserName = "******", Password = "******", Email = "*****@*****.**" }, }; var userProfileService = new Mock <IUserProfileService>(); userProfileService.Setup(t => t.GetAllUserProfile()).Returns(userProfiles); var receiptAllocation = new List <ReceiptAllocation> { new ReceiptAllocation { ReceiptAllocationID = new Guid("f4df54545"), PartitionID = 0, IsCommited = false, ETA = new DateTime(12 / 12 / 2013), ProjectNumber = "WFP 12000/682.4", GiftCertificateDetailID = null, CommodityID = 1, SINumber = "00016252-P1", UnitID = 1, QuantityInUnit = 412312, QuantityInMT = 12, HubID = 1, DonorID = 2, ProgramID = 1, CommoditySourceID = 1, IsClosed = false, PurchaseOrder = "231200801p", SupplierName = "kality(faffa F.S.C)", SourceHubID = 5, OtherDocumentationRef = null, Remark = null } }; var receiptAllocationService = new Mock <IReceiptAllocationService>(); receiptAllocationService.Setup(t => t.GetAllReceiptAllocation()).Returns(receiptAllocation); var commodityTypes = new List <CommodityType> { new CommodityType { CommodityTypeID = 1, Name = "Food" }, new CommodityType { CommodityTypeID = 2, Name = "Non Food" } }; var commodityTypeService = new Mock <ICommodityTypeService>(); commodityTypeService.Setup(t => t.GetAllCommodityType()).Returns(commodityTypes); var detail = new List <Detail> { new Detail { DetailID = 1, Name = "Birr", Description = null, MasterID = 1, SortOrder = 1 }, new Detail { DetailID = 2, Name = "Birr", Description = null, MasterID = 2, SortOrder = 2 } }; var detailService = new Mock <IDetailService>(); detailService.Setup(t => t.GetAllDetail()).Returns(detail); var donor = new List <Donor> { new Donor { DonorID = 1, Name = "WFP", DonorCode = "WFP", IsResponsibleDonor = true, IsSourceDonor = true, LongName = "UN - World Food Program" }, new Donor { DonorID = 2, Name = "USAID", DonorCode = "UAD", IsResponsibleDonor = false, IsSourceDonor = true, LongName = "United States Agency For International Development" } }; var donorService = new Mock <IDonorService>(); donorService.Setup(t => t.GetAllDonor()).Returns(donor); var program = new List <Program> { new Program { ProgramID = 1, Name = "PSNP" }, new Program { ProgramID = 2, Name = "Relief" } }; var programService = new Mock <IProgramService>(); programService.Setup(t => t.GetAllProgram()).Returns(program); var giftCertificateDetail = new List <GiftCertificateDetail> { new GiftCertificateDetail { GiftCertificateDetailID = 1, PartitionID = 0, TransactionGroupID = 0, GiftCertificateID = 1, CommodityID = 1, WeightInMT = 12345, BillOfLoading = "MSCDJ639709", AccountNumber = 6281, EstimatedPrice = 806490, EstimatedTax = 12, YearPurchased = 2012, DFundSourceID = 6, DCurrencyID = 1, DBudgetTypeID = 9, ExpiryDate = new DateTime(12 / 12 / 2014) } }; var giftCertificateDetailService = new Mock <IGiftCertificateDetailService>(); giftCertificateDetailService.Setup(t => t.GetAllGiftCertificateDetail()).Returns(giftCertificateDetail); _giftCertificateController = new GiftCertificateController(giftCerfificateService.Object, commodityService.Object, userProfileService.Object, receiptAllocationService.Object, detailService.Object, commodityTypeService.Object, donorService.Object, programService.Object, giftCertificateDetailService.Object); }
public int AddNewGiftCert() { try { GiftCertificateController controller = new GiftCertificateController(); GiftCertificateInfo item = new GiftCertificateInfo(); item.CertAmount = Convert.ToDouble(txtCertAmount.Text.ToString().Replace("$", "").ToString()); item.ToName = txtToName.Text.ToString(); // item.MailToAddress item.MailToAddress = txtToAddress.Text.ToString(); item.MailToAddress1 = txtToAddress1.Text.ToString(); item.MailToCity = txtToCity.Text.ToString(); item.MailToState = ddlStatesRecipient.SelectedValue.ToString(); item.MailToZip = txtToZip.Text.ToString(); item.MailTo = txtMailToName.Text.ToString(); item.FromUserID = this.UserId; item.FromName = txtFromName.Text.ToString(); item.FromPhone = txtFromPhone.Text.ToString(); item.FromEmail = txtFromEmail.Text.ToString(); item.Notes = txtNotes.Text.ToString(); item.ModuleId = this.ModuleId; item.CreatedByUserID = this.UserId; item.UpdatedByUserID = this.UserId; // ADD THE RECORD int MyNewID = Null.NullInteger; // if (!Null.IsNull(itemId)) if (itemId > 0) { MyNewID = itemId; item.ItemId = itemId; item.IsProcessed = false; // item.UpdatedByUserID = this.UserId; controller.GiftCertUpdateGiftCert(item); } else { MyNewID = controller.GiftCertAddGiftCert(item); } // string myNewGiftCertID = Convert.ToString(MyNewID); return(MyNewID); } catch (Exception ex) { Exceptions.ProcessModuleLoadException(this, ex); return(0); } }
public void MakeGiftCert(int itemID) { try { GiftCertificateInfo item; //load the item GiftCertificateController controller = new GiftCertificateController(); item = controller.GetGiftCert(itemId); string CertAmountWords = ""; string MailToAddressField = ""; string CertAmountNumber = ""; if (item != null) { if (item.PaypalPaymentState.ToString().Length == 0) { Response.Redirect(Globals.NavigateURL("Access Denied"), true); } TextInfo textInfo = new CultureInfo("en-US", false).TextInfo; CertAmountWords = textInfo.ToTitleCase(NumberToWords(Int32.Parse(item.CertAmount.ToString())).ToString()).ToString() + " Dollars" + Environment.NewLine; CertAmountNumber = "$" + String.Format("{0:f2}", item.CertAmount).ToString(); MailToAddressField = item.MailTo.ToString() + Environment.NewLine + item.MailToAddress.ToString() + Environment.NewLine + item.MailToCity.ToString() + ", " + item.MailToState.ToString() + " " + item.MailToZip.ToString(); _CertNotes = item.Notes.ToString(); } string myPortalName = this.PortalSettings.PortalName.ToString(); Document document = new Document(); document.Info.Author = "Joseph Aucoin"; document.Info.Keywords = "Gift Certificate"; document.Info.Title = myPortalName.ToString() + " Gift Certificate"; // Get the A4 page size MigraDoc.DocumentObjectModel.Unit width, height; PageSetup.GetPageSize(PageFormat.Letter, out width, out height); // Add a section to the document and configure it such that it will be in the centre // of the page Section section = document.AddSection(); section.PageSetup.PageHeight = height; section.PageSetup.PageWidth = width; section.PageSetup.LeftMargin = 20; section.PageSetup.RightMargin = 10; section.PageSetup.TopMargin = 20; // height / 2; //++++++++++++++++++++++++++++++ //++++++++++++++++++++++++++++++ //++++++++++++++++++++++++++++++ // ADD LOGO string myLogo = PortalSettings.HomeDirectoryMapPath + _CertLogo.ToString(); // "Images\\Chapins-Logo.png"; MigraDoc.DocumentObjectModel.Shapes.Image image = section.Headers.Primary.AddImage(myLogo.ToString()); image.LockAspectRatio = true; image.RelativeVertical = MigraDoc.DocumentObjectModel.Shapes.RelativeVertical.Line; image.RelativeHorizontal = MigraDoc.DocumentObjectModel.Shapes.RelativeHorizontal.Margin; image.Top = MigraDoc.DocumentObjectModel.Shapes.ShapePosition.Top; image.Left = MigraDoc.DocumentObjectModel.Shapes.ShapePosition.Right; image.WrapFormat.Style = MigraDoc.DocumentObjectModel.Shapes.WrapStyle.Through; MigraDoc.DocumentObjectModel.Tables.Table HeaderTable = new MigraDoc.DocumentObjectModel.Tables.Table(); HeaderTable.Borders.Width = 0; // Default to show borders 1 pixel wide Column HeaderTable.LeftPadding = 10; HeaderTable.RightPadding = 10; HeaderTable.Borders.Left.Visible = false; HeaderTable.Borders.Right.Visible = false; // Add 1 columns float myColumnWidth = ((section.PageSetup.PageWidth - section.PageSetup.LeftMargin - section.PageSetup.RightMargin) / 2); // ((width / 2) - 10); MigraDoc.DocumentObjectModel.Tables.Column column0 = HeaderTable.AddColumn(myColumnWidth); MigraDoc.DocumentObjectModel.Tables.Row row1 = HeaderTable.AddRow(); row1.Cells[0].Elements.AddParagraph(_CertReturnAddress.ToString()); row1.Cells[0].Format.Alignment = ParagraphAlignment.Left; section.Add(HeaderTable); /// SPACING MigraDoc.DocumentObjectModel.Paragraph paragraph = section.AddParagraph(); paragraph.Format.LineSpacingRule = MigraDoc.DocumentObjectModel.LineSpacingRule.Exactly; paragraph.Format.LineSpacing = MigraDoc.DocumentObjectModel.Unit.FromMillimeter(30.0); // section.Add(paragraph); //++++++++++++++++++++++++++++++ // ADD ANOTHER TABLE FOR MAIL TO ADDRESS // Create a table so that we can draw the horizontal lines MigraDoc.DocumentObjectModel.Tables.Table tableMailToAddress = new MigraDoc.DocumentObjectModel.Tables.Table(); tableMailToAddress.Borders.Width = 0; // Default to show borders 1 pixel wide Column tableMailToAddress.LeftPadding = 20; tableMailToAddress.RightPadding = 10; // float myColumnWidth100percent = (width - 10); var column = tableMailToAddress.AddColumn((section.PageSetup.PageWidth - section.PageSetup.LeftMargin - section.PageSetup.RightMargin)); double fontHeight = 20; Font font = new Font("Times New Roman", fontHeight); // Add a row with a single cell for the first line MigraDoc.DocumentObjectModel.Tables.Row row = tableMailToAddress.AddRow(); MigraDoc.DocumentObjectModel.Tables.Cell cell = row.Cells[0]; cell = row.Cells[0]; cell.Format.Font.Color = Colors.Black; cell.Format.Alignment = ParagraphAlignment.Left; cell.Format.Font.ApplyFont(font); cell.AddParagraph(MailToAddressField.ToString()); section.Add(tableMailToAddress); // ADD SPACER+++++++++++++++++++++++++++++++++++++++ MigraDoc.DocumentObjectModel.Paragraph paragraph1 = section.AddParagraph(); paragraph1.Format.LineSpacingRule = MigraDoc.DocumentObjectModel.LineSpacingRule.Exactly; paragraph1.Format.LineSpacing = MigraDoc.DocumentObjectModel.Unit.FromMillimeter(20.0); // ADD ANOTHER TABLE FOR CERT // Create a table so that we can draw the horizontal lines MigraDoc.DocumentObjectModel.Tables.Table tableCert = new MigraDoc.DocumentObjectModel.Tables.Table(); tableCert.Borders.Width = 0; // Default to show borders 1 pixel wide Column tableCert.LeftPadding = 10; tableCert.RightPadding = 10; tableCert.Borders.Right.Visible = true; // float myColumnWidth100percent = (width - 10); float sectionWidth = section.PageSetup.PageWidth - section.PageSetup.LeftMargin - section.PageSetup.RightMargin; float columnWidth = sectionWidth; var columnCert = tableCert.AddColumn(columnWidth); columnCert.Format.Alignment = ParagraphAlignment.Center; double fontHeightCert = 30; Font fontCert = new Font("Times New Roman", fontHeightCert); // Add a row with a single cell for the first line MigraDoc.DocumentObjectModel.Tables.Row rowCert = tableCert.AddRow(); MigraDoc.DocumentObjectModel.Tables.Cell cellCert = rowCert.Cells[0]; cellCert.Format.Font.Color = Colors.Black; cellCert.Format.Font.ApplyFont(fontCert); cellCert.Borders.Left.Visible = false; cellCert.Borders.Right.Visible = false; cellCert.Borders.Bottom.Visible = false; cellCert.AddParagraph(_CertBannerText.ToString()); // Add a row with a single cell for the second line rowCert = tableCert.AddRow(); cellCert = rowCert.Cells[0]; cellCert.Format.Font.Color = Colors.Black; cellCert.Format.Alignment = ParagraphAlignment.Center; cellCert.Format.Font.ApplyFont(fontCert); cellCert.Borders.Left.Visible = false; cellCert.Borders.Right.Visible = false; cellCert.Borders.Top.Visible = false; cellCert.AddParagraph(CertAmountWords.ToString()); // 3RD LINE // Add a row with a single cell for the third line rowCert = tableCert.AddRow(); cellCert = rowCert.Cells[0]; Font fontCertDetails = new Font("Times New Roman", 20); cellCert.Format.Font.Color = Colors.Black; cellCert.Format.Alignment = ParagraphAlignment.Left; cellCert.Format.Font.ApplyFont(fontCertDetails); cellCert.Borders.Left.Visible = false; cellCert.Borders.Right.Visible = false; cellCert.Borders.Top.Visible = false; cellCert.Format.SpaceBefore = MigraDoc.DocumentObjectModel.Unit.FromMillimeter(10.0); cellCert.Format.LeftIndent = MigraDoc.DocumentObjectModel.Unit.FromMillimeter(15.0); cellCert.AddParagraph("Date:" + item.CreatedDate.ToShortDateString() + Environment.NewLine + "Presented to: " + item.ToName.ToString() + Environment.NewLine + "From: " + item.FromName.ToString() + Environment.NewLine + "Amount: " + CertAmountNumber.ToString()); //////////////////////////////// // 4th LINE // Add a row with a single cell for the forth line rowCert = tableCert.AddRow(); cellCert = rowCert.Cells[0]; Font fontCertSignature = new Font("Arial", 12); cellCert.Format.Font.Color = Colors.Black; cellCert.Format.Alignment = ParagraphAlignment.Left; cellCert.Format.Font.ApplyFont(fontCertSignature); cellCert.Borders.Left.Visible = false; cellCert.Borders.Right.Visible = false; cellCert.Borders.Top.Visible = false; cellCert.Format.SpaceBefore = MigraDoc.DocumentObjectModel.Unit.FromMillimeter(10.0); cellCert.Format.LeftIndent = MigraDoc.DocumentObjectModel.Unit.FromMillimeter(15.0); cellCert.AddParagraph("Authorized Signature: __________________________________________________"); //////////////////////////////// // 5th LINE // Add a row with a single cell for the fifth line rowCert = tableCert.AddRow(); cellCert = rowCert.Cells[0]; Font fontCertInvoiceNumber = new Font("Arial", 10); cellCert.Format.Font.Color = Colors.Black; cellCert.Format.Alignment = ParagraphAlignment.Center; cellCert.Format.Font.ApplyFont(fontCertInvoiceNumber); cellCert.Borders.Left.Visible = false; cellCert.Borders.Right.Visible = false; cellCert.Borders.Top.Visible = false; // cellCert.Format.AddTabStop("16cm", TabAlignment.Right); cellCert.Format.SpaceBefore = MigraDoc.DocumentObjectModel.Unit.FromMillimeter(3.0); //cellCert.Format.LeftIndent = MigraDoc.DocumentObjectModel.Unit.FromMillimeter(15.0); cellCert.AddParagraph("Certificate Number 00" + item.ItemId.ToString()); document.LastSection.Add(tableCert); if (item.Notes.ToString().Trim().Length > 0) { //+++++++++ ADD PARAGRAPH FOR BUYER NOTES MigraDoc.DocumentObjectModel.Paragraph paragraphFooter = section.AddParagraph(); paragraphFooter.Format.LineSpacingRule = MigraDoc.DocumentObjectModel.LineSpacingRule.Exactly; paragraphFooter.Format.LineSpacing = MigraDoc.DocumentObjectModel.Unit.FromMillimeter(8.0); paragraphFooter.Format.SpaceBefore = MigraDoc.DocumentObjectModel.Unit.FromMillimeter(10.0); paragraphFooter.AddText("NOTES:" + Environment.NewLine + _CertNotes.ToString()); } Paragraph footerText = new Paragraph(); footerText.Format.Alignment = ParagraphAlignment.Center; footerText.AddText(_CertFooterText.ToString()); section.Footers.Primary.Add(footerText); // Create a renderer PdfDocumentRenderer pdfRenderer = new PdfDocumentRenderer(); // Associate the MigraDoc document with a renderer pdfRenderer.Document = document; // Layout and render document to PDF pdfRenderer.RenderDocument(); string pdfFilename = PortalSettings.HomeDirectoryMapPath + _PdfFilesFolder.ToString() + "Cert" + itemId.ToString() + ".pdf"; if (File.Exists(pdfFilename)) { File.Delete(pdfFilename); } pdfRenderer.PdfDocument.Save(pdfFilename); bool watermarkIsNeeded = false; if (_CertWatermark.ToString().Trim().Length > 1) { watermarkIsNeeded = true; } if (watermarkIsNeeded) { PdfDocument pdfIn = PdfReader.Open(pdfFilename, PdfDocumentOpenMode.Import); PdfDocument pdfOut = new PdfDocument(); for (int i = 0; i < pdfIn.PageCount; i++) { PdfPage pg = pdfIn.Pages[i]; pg = pdfOut.AddPage(pg); // WATERMARK TEXT string draftFlagStr = _CertWatermark.ToString(); // Get an XGraphics object for drawing beneath the existing content XGraphics gfx = XGraphics.FromPdfPage(pg, XGraphicsPdfPageOptions.Prepend); // Get the size (in point) of the text XFont fontWM = new XFont("Verdana", 62, XFontStyle.Bold); XSize size = gfx.MeasureString(draftFlagStr, fontWM); // Define a rotation transformation at the center of the page gfx.TranslateTransform(pg.Width / 2, pg.Height / 2); gfx.RotateTransform(-Math.Atan(pg.Height / pg.Width) * 180 / Math.PI); gfx.TranslateTransform(-pg.Width / 2, -pg.Height / 2); // Create a string format XStringFormat format = new XStringFormat(); format.Alignment = XStringAlignment.Near; format.LineAlignment = XLineAlignment.Near; // Create a dimmed red brush XBrush brush = new XSolidBrush(XColor.FromArgb(32, 0, 0, 255)); // Draw the string gfx.DrawString(draftFlagStr, fontWM, brush, new XPoint((pg.Width - size.Width) / 2, (pg.Height - size.Height) / 2), format); } pdfOut.Save(pdfFilename); } // Save and show the document // pdfRenderer.PdfDocument.Save("TestDocument.pdf"); Process.Start("explorer.exe", pdfFilename); HyperLinkPDF.Visible = true; HyperLinkPDF.NavigateUrl = PortalSettings.HomeDirectory + _PdfFilesFolder.ToString() + "Cert" + itemId.ToString() + ".pdf"; } catch (Exception ex) { Exceptions.ProcessModuleLoadException(this, ex); } }