private void btnDeleteCompanyEmail_Click(object sender, EventArgs e) { BECompanies.tbl_CompanyEmailsRow attribute; BPCompanyEmails bp = new BPCompanyEmails(); BECompanies DSCompanies = bp.SelectCompanyEmailsByCompanyID(CompanyID); attribute = DSCompanies.tbl_CompanyEmails.FindByCompanyEmailID(CompanyEmailID); attribute.Delete(); bp.Update(DSCompanies); ViewCompanyEmails(); }
public void CreateAndSendEmails(int orderID, string pdfFilePath) { BPOrders bpOrder = new BPOrders(); BPOrderDetails bpDetails = new BPOrderDetails(); BEOrders dsOrder = bpOrder.SelectOrdersByID(orderID); dsOrder.Merge(bpDetails.SelectOrderDetailsWithInventoryByOrderID(orderID)); BEOrders.tbl_OrdersRow order = (BEOrders.tbl_OrdersRow) dsOrder.tbl_Orders.Rows[0]; BPCompanyEmails bp = new BPCompanyEmails(); BPCompanies bpCompany = new BPCompanies(); BPCompanyAliases bpAliases = new BPCompanyAliases(); BECompanies ds = bp.SelectActiveCompanyEmailsByCompanyID(order.CompanyID); ds.Merge(bpCompany.SelectCompaniesByID(order.CompanyID)); ds.Merge(bpAliases.SelectCompanyColumnsByCompanyID(order.CompanyID)); BECompanies.tbl_CompanyAliasesRow aliases = (BECompanies.tbl_CompanyAliasesRow) ds.tbl_CompanyAliases.Rows[0]; BECompanies.tbl_CompaniesRow company; bool hasHuntingInventoryAccess = false; string CompanyImage = ""; if(ds.tbl_Companies.Count > 0) { company = (BECompanies.tbl_CompaniesRow) ds.tbl_Companies.Rows[0]; if (!company.IsCompanyImageIDNull()) { BPImages bpImages = new BPImages(); BEImages DSImages = bpImages.SelectByID(company.CompanyImageID); string imageName = DSImages.tbl_Images.FindByImageID(company.CompanyImageID).ImageName; CompanyImage = "<img src='" + companyLogoPath + "l_" + imageName + "' />"; } hasHuntingInventoryAccess = company.CompanyRentalInventory; } MailMessage mm = new MailMessage(); mm.Subject = "Confirmation of " + _EmailType.ToUpper() + " ID:" + orderID; foreach (BECompanies.tbl_CompanyEmailsRow row in ds.tbl_CompanyEmails.Rows) { mm.To += row.CompanyEmail + ";"; } mm.From = ConfigurationSettings.AppSettings.Get("AdministratorEmailFrom"); mm.Fields["http://schemas.microsoft.com/cdo/configuration/smtpserverport"] = Convert.ToInt32(ConfigurationSettings.AppSettings["SmtpServerPort"]); SmtpMail.SmtpServer = ConfigurationSettings.AppSettings.Get("SmtpServer"); string createOrder = ""; createOrder += "<!DOCTYPE HTML PUBLIC '-//W3C//DTD HTML 4.01//EN' 'http://www.w3.org/TR/html4/strict.dtd'>"; createOrder += "<Html><head><LINK href='" + cssLinkPath + "screen.css' type='text/css' rel='stylesheet'></head><body class='alignleft'><div class='top'></div><div class='wrap'>"; createOrder += "<table border='0' cellspacing='0' cellpadding='0' style='margin-bottom:10px;' class='tablewidth'><tr>"; createOrder += "<td><img src='" + huntingLogoPath + "' /></td>"; createOrder += "<td style='text-align:right;'>" + CompanyImage + "</td>"; createOrder += "</tr></table>"; //new order details table createOrder += "<table class='orderdetails tablewidth'>"; createOrder += "<tr><th colspan='4' class='heading'>Confirmation of " + _EmailType.ToUpper() + " ID: " + order.OrderID + "</th></tr><tr>"; createOrder += "<th width='20%'>Date</th>"; createOrder += "<td width='30%'>" + order.OrderDate.ToString("MMM d, yyyy h:mm tt") + "</td>"; createOrder += "<th width='20%'> </th>"; createOrder += "<td width='30%'> </td>"; createOrder += "</tr>"; createOrder += "<tr>"; if (_EmailType == "Order") { createOrder += "<th>Ordered By </th>"; } else { createOrder += "<th>Received By </th>"; } createOrder += "<td>" + order.OrderRequestedBy + "</td>"; createOrder += "<th width='16%'>Rig </th>"; createOrder += "<td width='34%'>" + order.OrderRigNumber + "</td>"; createOrder += "</tr>"; createOrder += "<tr>"; createOrder += "<th>Ship To </th>"; createOrder += "<td>" + order.OrderShipTo + "</td>"; createOrder += "<th>Job # </th>"; createOrder += "<td>" + order.OrderJobNumber + "</td>"; createOrder += "</tr>"; createOrder += "<tr>"; createOrder += "<th>Via </th>"; createOrder += "<td>" + order.OrderShipVIA + "</td>"; createOrder += "<th>Lease </th>"; createOrder += "<td>" + order.OrderLeaseNumber + "</td>"; createOrder += "</tr>"; createOrder += "<tr>"; if (_EmailType == "Order") { createOrder += "<th>Date Required </th>"; } else { createOrder += "<th>Date Received </th>"; } createOrder += "<td>" + order.OrderDateRequired.ToString("MMM d, yyyy") + "</td>"; if (_EmailType == "Order") { createOrder += "<th>Time Required</th>"; } else { createOrder += "<th>Time Received</th>"; } createOrder += "<td>" + order.OrderTimeRequired + "</td>"; createOrder += "</tr>"; createOrder += "<tr>"; createOrder += "<th>Comments</th>"; createOrder += "<td colspan='3'>" + order.OrderComments + "</td>"; createOrder += "</tr></table><div style='page-break-after:avoid'> </div>"; ArrayList columns = new ArrayList(); createOrder += "<table class='emailitemdetails'><tr>"; if(hasHuntingInventoryAccess) { createOrder += "<th width='40px'>B/R</th>"; columns.Add("BuyRentStatus"); } createOrder += "<th>" + aliases.ItemNumber + "</th>"; columns.Add("ItemNumber"); createOrder += "<th>" + aliases.Description + "</th>"; columns.Add("Description"); createOrder += "<th>" + aliases.Box + "</th>"; columns.Add("Box"); createOrder += "<th>" + aliases.Pin + "</th>"; columns.Add("Pin"); createOrder += "<th>" + aliases.MajorOD + "</th>"; columns.Add("MajorOD"); createOrder += "<th>" + aliases.MinorOD + "</th>"; columns.Add("MinorOD"); createOrder += "<th>" + aliases.InsideDiameter + "</th>"; columns.Add("InsideDiameter"); createOrder += "<th>" + aliases.SealtoSealLength + "</th>"; columns.Add("SealtoSealLength"); createOrder += "<th>" + aliases.FloatBore + "</th>"; columns.Add("FloatBore"); createOrder += "<th>" + aliases.Box2 + "</th>"; columns.Add("Box2"); createOrder += "<th>" + aliases.GeneralComments + "</th>"; columns.Add("GeneralComments"); if (!aliases.IsExtraColumn1Null()) { createOrder += "<th>" + aliases.ExtraColumn1 + "</th>"; columns.Add("ExtraColumn1"); } if (!aliases.IsExtraColumn2Null()) { createOrder += "<th>" + aliases.ExtraColumn2 + "</th>"; columns.Add("ExtraColumn2"); } if (!aliases.IsExtraColumn3Null()) { createOrder += "<th>" + aliases.ExtraColumn3 + "</th>"; columns.Add("ExtraColumn3"); } if (!aliases.IsExtraColumn4Null()) { createOrder += "<th>" + aliases.ExtraColumn4 + "</th>"; columns.Add("ExtraColumn4"); } if (!aliases.IsExtraColumn5Null()) { createOrder += "<th>" + aliases.ExtraColumn5 + "</th>"; columns.Add("ExtraColumn5"); } if (!aliases.IsExtraColumn6Null()) { createOrder += "<th>" + aliases.ExtraColumn6 + "</th>"; columns.Add("ExtraColumn6"); } if (!aliases.IsExtraColumn7Null()) { createOrder += "<th>" + aliases.ExtraColumn7 + "</th>"; columns.Add("ExtraColumn7"); } if (!aliases.IsExtraColumn8Null()) { createOrder += "<th>" + aliases.ExtraColumn8 + "</th>"; columns.Add("ExtraColumn8"); } if (!aliases.IsExtraColumn9Null()) { createOrder += "<th>" + aliases.ExtraColumn9 + "</th>"; columns.Add("ExtraColumn9"); } if (!aliases.IsExtraColumn10Null()) { createOrder += "<th>" + aliases.ExtraColumn10 + "</th>"; columns.Add("ExtraColumn10"); } createOrder += "<td class='lastcell'> </td></tr>"; int rowCount = 0; string strColor2 = ""; foreach (BEOrders.tbl_OrderDetailsRow item in dsOrder.tbl_OrderDetails.Rows) { rowCount += 1; if (rowCount % 2 == 0) { strColor2 = "#efefef"; } else { strColor2 = "#ffffff"; } createOrder += "<tr style='page-break-inside:avoid'>"; foreach (string col in columns) { if (item[col] != null && item[col].ToString() != "") { if(col == "BuyRentStatus") createOrder += "<td nowrap bgColor='" + strColor2 + "'>" + item[col].ToString() + "</td>"; else createOrder += "<td bgColor='" + strColor2 + "'>" + item[col].ToString() + "</td>"; } else { createOrder += "<td bgColor='" + strColor2 + "'> </td>"; } } createOrder += "<td class='lastcell'> </td></tr>"; } createOrder += "</table>"; createOrder += "<br><div style='page-break-inside:avoid;'><hr><table cellpadding='0' cellspacing='0' border='0' align='center'>"; createOrder += "<tr><td align='center'>"; createOrder += "If you require further clarification please call Mazz Oilfield Services. Customer Service at (403) 720-6299."; createOrder += "<br/>"; createOrder += " Thank you for using Mazz Oilfield Services Online!"; createOrder += "</td></tr></table><hr></div>"; createOrder += "<br><table class='shippingdept' style='width: 550px !important;' align='center'>"; createOrder += "<tr><th colspan='2' class='heading'>ORDER ID: " + order.OrderID + " - Shipping Verification</th></tr>"; createOrder += "<tr><th>Information Check List</th><th width='50%'>Shipper's Initial</td></th>"; createOrder += "<tr bgColor='#efefef'><td><img src='" + activeIconPath + "'> Check Box Connections</td><td> </td></tr>"; createOrder += "<tr><td><img src='" + activeIconPath + "'> Check Pin Connections</td><td> </td></tr>"; createOrder += "<tr bgColor='#efefef'><td><img src='" + activeIconPath + "'> Check Serial Numbers</td><td> </td></tr>"; createOrder += "<tr><td><img src='" + activeIconPath + "'> Gauge Float Bore</td><td> </td></tr>"; createOrder += "<tr bgColor='#efefef'><td><img src='" + activeIconPath + "'> Gauge UBHO Bore</td><td> </td></tr>"; createOrder += "<tr><td><img src='" + activeIconPath + "'> Check Protectors</td><td> </td></tr>"; createOrder += "</table><br>"; createOrder += "<br><table class='receiver' align='center'>"; createOrder += "<tr><td align='left'>All Items Verified and Thread Protectors Installed:</td><td align='center'>____________________________________</td></tr>"; createOrder += "<tr><td> </td><td align='center'>RECEIVER</td></tr>"; createOrder += "</table></br>"; createOrder += "</div><div class='bottom'></div>"; createOrder += "</body></html>"; string pdfFileName = "ConfirmOrderID_" + orderID + ".pdf"; string fullPDFFilePath = pdfFilePath + pdfFileName; ConvertHTMLToPDF(createOrder, fullPDFFilePath); try { mm.Body = "Please review the attached PDF file for Order Confirmation"; MailAttachment pdfAttachment = new MailAttachment(fullPDFFilePath); mm.Attachments.Add(pdfAttachment); mm.BodyFormat = MailFormat.Html; SmtpMail.Send(mm); if (File.Exists(fullPDFFilePath)) File.Delete(fullPDFFilePath); } catch (Exception ex) { ex.ToString(); // Response.Redirect (strMWRequestBad); //response.write "There was a problem sending the email"; } }
private void SaveCompanyEmails() { BECompanies.tbl_CompanyEmailsRow attribute; BPCompanyEmails bp = new BPCompanyEmails(); BECompanies DSCompanies = bp.SelectCompanyEmailsByCompanyID(CompanyID); if (CompanyEmailID == 0) { attribute = DSCompanies.tbl_CompanyEmails.Newtbl_CompanyEmailsRow(); } else { attribute = DSCompanies.tbl_CompanyEmails.FindByCompanyEmailID(CompanyEmailID); } attribute.CompanyID = CompanyID; attribute.CompanyEmail = txtCompanyEmail.Text; attribute.CompanyEmailActive = chkCompanyEmailActive.Checked; attribute.ModifiedByAdminID = Convert.ToInt32(OryxUser.OryxIdentity.MemberID); attribute.DateModified = DateTime.Now; if (CompanyEmailID == 0) { attribute.DateCreated = DateTime.Now; DSCompanies.tbl_CompanyEmails.Rows.Add(attribute); } bp.Update(DSCompanies); ViewCompanyEmails(); }
private void ViewCompanyEmails() { BPCompanyEmails bp = new BPCompanyEmails(); DSCompanies = bp.SelectCompanyEmailsByCompanyID(CompanyID); dgCompanyEmails.DataBind(); dgCompanyEmails.SelectedIndex = -1; tabViewCompanyEmails.Attributes["class"] = "current"; tabAddCompanyEmails.Attributes["class"] = ""; pnlAddCompanyEmails.Visible = false; pnlViewCompanyEmails.Visible = true; }
private void AddCompanyEmails() { if (CompanyEmailID != 0) { BPCompanyEmails bp = new BPCompanyEmails(); BECompanies.tbl_CompanyEmailsRow row = bp.SelectCompanyEmailsByCompanyID(CompanyID).tbl_CompanyEmails.FindByCompanyEmailID(CompanyEmailID); txtCompanyEmail.Text = row.CompanyEmail; chkCompanyEmailActive.Checked = row.CompanyEmailActive; btnDeleteCompanyEmail.Visible = true; } else { txtCompanyEmail.Text = ""; chkCompanyEmailActive.Checked = false; btnDeleteCompanyEmail.Visible = false; } tabAddCompanyEmails.Attributes["class"] = "current"; tabViewCompanyEmails.Attributes["class"] = ""; pnlViewCompanyEmails.Visible = false; pnlAddCompanyEmails.Visible = true; }
private void btnDelete_Click(object sender, EventArgs e) { if (CompanyID != Convert.ToInt32(System.Configuration.ConfigurationSettings.AppSettings.Get("OryxCompanyID"))) { //Delete Company BPCompanies bp = new BPCompanies(); BECompanies.tbl_CompaniesRow Company; DSCompanies = bp.SelectCompaniesByID(CompanyID); Company = DSCompanies.tbl_Companies.FindByCompanyID(CompanyID); Company.Delete(); bp.Update(DSCompanies); //Delete Company Aliases BPCompanyAliases bpAliases = new BPCompanyAliases(); DSCompanies = bpAliases.SelectCompanyAliasesByCompanyID(CompanyID); foreach (BECompanies.tbl_CompanyAliasesRow row in DSCompanies.tbl_CompanyAliases.Rows) { row.Delete(); } bpAliases.Update(DSCompanies); //Delete Company Emails BPCompanyEmails bpEmails = new BPCompanyEmails(); DSCompanies = bpEmails.SelectCompanyEmailsByCompanyID(CompanyID); foreach (BECompanies.tbl_CompanyEmailsRow row in DSCompanies.tbl_CompanyEmails.Rows) { row.Delete(); } bpEmails.Update(DSCompanies); Response.Redirect("BrowseCompanies.aspx"); } else { //TODO: Insert Message here stating that Oryx company Cannot be deleted, please see your web master } }
public void CreateAndSendEmails(int orderID) { BPOrders bpOrder = new BPOrders(); BPOrderDetails bpDetails = new BPOrderDetails(); BEOrders dsOrder = bpOrder.SelectOrdersByID(orderID); dsOrder.Merge(bpDetails.SelectOrderDetailsWithInventoryByOrderID(orderID)); BEOrders.tbl_OrdersRow order = (BEOrders.tbl_OrdersRow) dsOrder.tbl_Orders.Rows[0]; BPCompanyEmails bp = new BPCompanyEmails(); BPCompanies bpCompany = new BPCompanies(); BPCompanyAliases bpAliases = new BPCompanyAliases(); BECompanies ds = bp.SelectActiveCompanyEmailsByCompanyID(order.CompanyID); ds.Merge(bpCompany.SelectCompaniesByID(order.CompanyID)); ds.Merge(bpAliases.SelectCompanyColumnsByCompanyID(order.CompanyID)); BECompanies.tbl_CompanyAliasesRow aliases = (BECompanies.tbl_CompanyAliasesRow) ds.tbl_CompanyAliases.Rows[0]; BECompanies.tbl_CompaniesRow company; bool hasHuntingInventoryAccess = false; string CompanyImage = ""; if(ds.tbl_Companies.Count > 0) { company = (BECompanies.tbl_CompaniesRow) ds.tbl_Companies.Rows[0]; if (!company.IsCompanyImageIDNull()) { BPImages bpImages = new BPImages(); BEImages DSImages = bpImages.SelectByID(company.CompanyImageID); string imageName = DSImages.tbl_Images.FindByImageID(company.CompanyImageID).ImageName; CompanyImage = "<img src='" + companyLogoPath + "l_" + imageName + "' />"; } hasHuntingInventoryAccess = company.CompanyRentalInventory; } string createOrder = ""; createOrder += "<table border='0' cellspacing='0' cellpadding='0'><tr>"; createOrder += "<td><img src='" + huntingLogoPath + "' /></td>"; createOrder += "<td style='text-align:right;'>" + CompanyImage + "</td>"; createOrder += "</tr></table>"; createOrder += "<br>"; createOrder += "<table class='orderdetails'>"; createOrder += "<tr><th colspan='4' class='heading'>Confirmation of " + _EmailType.ToUpper() + " ID: " + order.OrderID + "</th></tr><tr>"; createOrder += "<th width='20%'>Date</th>"; createOrder += "<td width='30%'>" + order.OrderDate.ToString("MMM d, yyyy h:mm tt") + "</td>"; createOrder += "<th width='20%'> </th>"; createOrder += "<td width='30%'> </td>"; createOrder += "</tr>"; createOrder += "<tr>"; if (_EmailType == "Order") { createOrder += "<th>Ordered By </th>"; } else { createOrder += "<th>Transferred By </th>"; } createOrder += "<td>" + order.OrderRequestedBy + "</td>"; createOrder += "<th width='16%'>Rig </th>"; createOrder += "<td width='34%'>" + order.OrderRigNumber + "</td>"; createOrder += "</tr>"; createOrder += "<tr>"; createOrder += "<th>Ship To </th>"; createOrder += "<td>" + order.OrderShipTo + "</td>"; createOrder += "<th>Job # </th>"; createOrder += "<td>" + order.OrderJobNumber + "</td>"; createOrder += "</tr>"; createOrder += "<tr>"; createOrder += "<th>Via </th>"; createOrder += "<td>" + order.OrderShipVIA + "</td>"; createOrder += "<th>Lease </th>"; createOrder += "<td>" + order.OrderLeaseNumber + "</td>"; createOrder += "</tr>"; createOrder += "<tr>"; createOrder += "<th>Date Required </th>"; createOrder += "<td>" + order.OrderDateRequired.ToString("MMM d, yyyy") + "</td>"; createOrder += "<th>Time Required</th>"; createOrder += "<td>" + order.OrderTimeRequired + "</td>"; createOrder += "</tr>"; createOrder += "<tr>"; createOrder += "<th>Comments</th>"; createOrder += "<td colspan='3'>" + order.OrderComments + "</td>"; createOrder += "</tr></table>"; ArrayList columns = new ArrayList(); createOrder += "<br><table class='itemdetails'><tr>"; if(hasHuntingInventoryAccess) { createOrder += "<th width='40px' nowrap='true'>B/R</th>"; columns.Add("BuyRentStatus"); } createOrder += "<th>" + aliases.ItemNumber + "</th>"; columns.Add("ItemNumber"); createOrder += "<th>" + aliases.Description + "</th>"; columns.Add("Description"); createOrder += "<th>" + aliases.Box + "</th>"; columns.Add("Box"); createOrder += "<th>" + aliases.Pin + "</th>"; columns.Add("Pin"); createOrder += "<th>" + aliases.MajorOD + "</th>"; columns.Add("MajorOD"); createOrder += "<th>" + aliases.MinorOD + "</th>"; columns.Add("MinorOD"); createOrder += "<th>" + aliases.InsideDiameter + "</th>"; columns.Add("InsideDiameter"); createOrder += "<th>" + aliases.SealtoSealLength + "</th>"; columns.Add("SealtoSealLength"); createOrder += "<th>" + aliases.FloatBore + "</th>"; columns.Add("FloatBore"); createOrder += "<th>" + aliases.Box2 + "</th>"; columns.Add("Box2"); createOrder += "<th>" + aliases.GeneralComments + "</th>"; columns.Add("GeneralComments"); if (!aliases.IsExtraColumn1Null()) { createOrder += "<th>" + aliases.ExtraColumn1 + "</th>"; columns.Add("ExtraColumn1"); } if (!aliases.IsExtraColumn2Null()) { createOrder += "<th>" + aliases.ExtraColumn2 + "</th>"; columns.Add("ExtraColumn2"); } if (!aliases.IsExtraColumn3Null()) { createOrder += "<th>" + aliases.ExtraColumn3 + "</th>"; columns.Add("ExtraColumn3"); } if (!aliases.IsExtraColumn4Null()) { createOrder += "<th>" + aliases.ExtraColumn4 + "</th>"; columns.Add("ExtraColumn4"); } if (!aliases.IsExtraColumn5Null()) { createOrder += "<th>" + aliases.ExtraColumn5 + "</th>"; columns.Add("ExtraColumn5"); } if (!aliases.IsExtraColumn6Null()) { createOrder += "<th>" + aliases.ExtraColumn6 + "</th>"; columns.Add("ExtraColumn6"); } if (!aliases.IsExtraColumn7Null()) { createOrder += "<th>" + aliases.ExtraColumn7 + "</th>"; columns.Add("ExtraColumn7"); } if (!aliases.IsExtraColumn8Null()) { createOrder += "<th>" + aliases.ExtraColumn8 + "</th>"; columns.Add("ExtraColumn8"); } if (!aliases.IsExtraColumn9Null()) { createOrder += "<th>" + aliases.ExtraColumn9 + "</th>"; columns.Add("ExtraColumn9"); } if (!aliases.IsExtraColumn10Null()) { createOrder += "<th>" + aliases.ExtraColumn10 + "</th>"; columns.Add("ExtraColumn10"); } createOrder += "</tr>"; int rowCount = 0; string strColor2 = ""; foreach (BEOrders.tbl_OrderDetailsRow item in dsOrder.tbl_OrderDetails.Rows) { rowCount += 1; if (rowCount % 2 == 0) { strColor2 = "#efefef"; } else { strColor2 = "#ffffff"; } createOrder += "<tr class='tablerows' bgColor='" + strColor2 + "'>"; foreach (string col in columns) { if (item[col] != null && item[col].ToString() != "") { createOrder += "<td>" + item[col].ToString() + "</td>"; } else { createOrder += "<td> </td>"; } } createOrder += "</tr>"; } createOrder += "</table>"; createOrder += "<table cellpadding='0' cellspacing='0' border='0' align='center'>"; createOrder += "<tr><td align='center'>_________________________________________________</td></tr>"; createOrder += "<tr><td align='center'>"; createOrder += "If you require further clarification please call <br/>"; createOrder += "Mazz Oilfield Services. Customer Service at:<br>"; createOrder += "(403) 720-6299"; createOrder += "<br/><br/>"; createOrder += " Thank you for using Mazz Oilfield Services Online."; createOrder += "</td></tr></table>"; createOrder += "</div><div class='bottom'></div>"; Response.Write(createOrder); }