private bool SendEmailNotification(BidDetails biddetails, PurchaseOfficerInfo info) { bool success = false; string subject = "Trans-Asia : Notification"; try { if (!MailHelper.SendEmail(MailTemplate.GetDefaultSMTPServer(), MailHelper.ChangeToFriendlyName(biddetails.Creator, biddetails.CreatorEmail), MailHelper.ChangeToFriendlyName(info.Supervisor, info.EmailAdd), subject, CreateNotificationBody(), MailTemplate.GetTemplateLinkedResources(this))) { // if sending failed LogHelper.EventLogHelper.Log("Bid > Send Notification : Sending Failed to " + info.EmailAdd, System.Diagnostics.EventLogEntryType.Error); } else { // if sending successful LogHelper.EventLogHelper.Log("Bid > Send Notification : Email Sent to " + info.EmailAdd, System.Diagnostics.EventLogEntryType.Information); } success = true; } catch (Exception ex) { success = false; LogHelper.EventLogHelper.Log("Bid > Send Notification : " + ex.Message, System.Diagnostics.EventLogEntryType.Error); } return(success); }
protected PurchaseOfficerInfo ConvertRow(DataRow dr) { PurchaseOfficerInfo ad = new PurchaseOfficerInfo(); if (dr != null) { if (dr.Table.Columns.Count != 0) { if (dr.Table.Columns.Contains("PurchasingID")) { ad.PurchasingID = int.Parse(dr.Table.Rows[0]["PurchasingID"].ToString()); } if (dr.Table.Columns.Contains("Supervisor")) { ad.Supervisor = dr.Table.Rows[0]["Supervisor"].ToString(); } if (dr.Table.Columns.Contains("EmailAdd")) { ad.EmailAdd = dr.Table.Rows[0]["EmailAdd"].ToString(); } } else { throw new EmptyInputException("Data row contains no columns"); } } else { throw new EmptyInputException("Data row is null."); } return(ad); }
protected void btnOk_Click(object sender, EventArgs e) { try { BidDetails details = GetBidItemDetails(int.Parse(Session["BidRefNo"].ToString())); PurchaseOfficerInfo info = GetPurchaseOfficerInfo(Convert.ToInt32(details.BuyerID.ToString())); if (SendEmailNotification(details, info)) { Session["Message"] = "Notification sent successfully."; } else { // failed Session["Message"] = "Failed to send notification. Please try again or contact adminitrator for assistance."; } } catch { // failed Session["Message"] = "Failed to send notification. Please try again or contact adminitrator for assistance."; } ClearVars(); Response.Redirect("index.aspx"); }
public PurchaseOfficerInfo(DataRow dr) { PurchaseOfficerInfo ad = new PurchaseOfficerInfo(); ad = ConvertRow(dr); PurchasingID = ad.PurchasingID; Supervisor = ad.Supervisor; EmailAdd = ad.EmailAdd; }
private PurchaseOfficerInfo GetPurchaseOfficerInfo(int buyerid) { DataTable dt = SqlHelper.ExecuteDataset(connstring, "sp_GetBuyerSupervisorInfo", new SqlParameter[] { new SqlParameter("@BuyerId", buyerid) }).Tables[0]; PurchaseOfficerInfo info = new PurchaseOfficerInfo(); if (dt.Rows.Count > 0) { info = new PurchaseOfficerInfo(dt.Rows[0]); } return(info); }