Exemplo n.º 1
0
        /// <summary>
        /// Send email to the current client to confirm the items in the current order, and the deliver date
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void btnConfirmOrder_Click(object sender, EventArgs e)
        {
            DropDownList _ddlThisContact = (DropDownList)dvOrderHeader.FindControl("ddlContacts");

            ContactEmailDetails _thisContact = GetEmailDetails(_ddlThisContact.SelectedItem.Value);

            if (_thisContact != null)
            {
                EmailCls     _email         = new EmailCls();
                DropDownList _ddlDeliveryBy = (DropDownList)dvOrderHeader.FindControl("ddlToBeDeliveredBy"); // who is delivering this

                string _DeliveryDate  = dvOrderHeaderGetLabelValue("lblRequiredByDate");                     // date it will be dispatched / delivered"
                string _PurchaseOrder = dvOrderHeaderGetLabelValue("lblPurchaseOrder");
                string _Notes         = dvOrderHeaderGetLabelValue("lblNotes");

                if (_thisContact.EmailAddress != "")
                {
                    _email.SetEmailFromTo(CONST_FROMEMAIL, _thisContact.EmailAddress);
                    if (_thisContact.altEmailAddress != "")
                    {
                        _email.SetEmailCC(_thisContact.altEmailAddress);
                    }
                }
                else if (_thisContact.altEmailAddress != "")
                {
                    _email.SetEmailFromTo(CONST_FROMEMAIL, _thisContact.altEmailAddress);
                }
                else
                {
                    ltrlStatus.Text = "no email address found";
                    TrackerDotNet.classes.showMessageBox _NoMsgBx = new classes.showMessageBox(this.Page, "Email FAILED: ", ltrlStatus.Text);
                    upnlNewOrderItem.Update();
                    return; // no email address so quit
                }
                // send a BCC to orders to confirm
                _email.SetEmailBCC(CONST_FROMEMAIL);
                // set subject and body
                _email.SetEmailSubject("Order Confirmation");

                string _AddressedTo = "Coffee Lover";
                if (_thisContact.FirstName != "")
                {
                    _AddressedTo = _thisContact.FirstName.Trim();
                    if (_thisContact.altFirstName != "")
                    {
                        _AddressedTo += " and " + _thisContact.altFirstName.Trim();
                    }
                }
                else if (_thisContact.altFirstName != "")
                {
                    _AddressedTo = _thisContact.altFirstName.Trim();
                }

                _email.AddStrAndNewLineToBody("Dear " + _AddressedTo + ",<br />");
                if (_ddlThisContact.SelectedValue.Equals(NewOrderDetail.CONST_ZZNAME_DEFAULTID))
                {
                    _email.AddStrAndNewLineToBody("We confirm you order below:");
                }
                else
                {
                    _email.AddStrAndNewLineToBody("We confirm the following order for " + _ddlThisContact.SelectedItem.Text + ":");
                }
                _email.AddToBody("<ul>");
                foreach (GridViewRow _gv in gvOrderLines.Rows)
                {
                    DropDownList _gvItemDLL       = (DropDownList)_gv.FindControl("ddlItemDesc");
                    Label        _gvItemQty       = (Label)_gv.FindControl("lblQuantityOrdered");
                    DropDownList _gvItemPackaging = (DropDownList)_gv.FindControl("ddlPackaging");
                    // need to check for serivce / note and add the note using the same logic as we have for the delivery sheet
                    if (GetItemSortOrderID(_gvItemDLL.SelectedValue) == ItemTypeTbl.CONST_NEEDDESCRIPTION_SORT_ORDER)
                    {
                        // if we are already use the notes field for name, check if there is a ":" seperator, and then only use what is after
                        if (_Notes.Contains(":"))
                        {
                            _Notes = _Notes.Substring(_Notes.IndexOf(":") + 1).Trim();
                        }

                        int _Start = _Notes.IndexOf(OrderDetail.CONST_EMAILDELIMITERSTART);
                        if (_Start >= 0)
                        {
                            int _End = _Notes.IndexOf(OrderDetail.CONST_EMAILDELIMITEREND);
                            if (_End >= 0)
                            {
                                _Notes = String.Concat(_Notes.Substring(0, _Start), ";", _Notes.Substring(_End + 2));
                            }
                        }

                        _email.AddFormatToBody("<li>{0}</li>", _Notes);
                    }
                    else
                    {
                        string _UnitsAndQty = AddUnitsToQty(_gvItemDLL.SelectedValue, _gvItemQty.Text);
                        if (_gvItemPackaging.SelectedIndex == 0)
                        {
                            _email.AddFormatToBody("<li>{0} of {1}</li>", _UnitsAndQty, _gvItemDLL.SelectedItem.Text);
                        }
                        else
                        {
                            _email.AddFormatToBody("<li>{0} of {1} - Preperation note: {2}</li>", _UnitsAndQty, _gvItemDLL.SelectedItem.Text, _gvItemPackaging.SelectedItem.Text);
                        }
                    }
                }
                _email.AddStrAndNewLineToBody("</ul>");

                if (!string.IsNullOrEmpty(_PurchaseOrder))
                {
                    if (_PurchaseOrder.EndsWith(TrackerTools.CONST_POREQUIRED))
                    {
                        _email.AddStrAndNewLineToBody("<b>NOTE</b>: We are still waiting for a Purchase Order number from you.<br />");
                    }
                    else
                    {
                        _email.AddStrAndNewLineToBody(string.Format("This order has purchase order: {0}, allocated to it.<br />", _PurchaseOrder));
                    }
                }
                if (_ddlDeliveryBy.SelectedItem.Text == CONST_DELIVERYTYPEISCOLLECTION)
                {
                    _email.AddStrAndNewLineToBody("The order will be ready for collection on: " + _DeliveryDate);
                }
                else if (_ddlDeliveryBy.SelectedItem.Text == CONST_DELIVERYTYPEISCOURIER)
                {
                    _email.AddStrAndNewLineToBody("The order will be dispatched on: " + _DeliveryDate + ".");
                }
                else
                {
                    _email.AddStrAndNewLineToBody("The order will be delivered on: " + _DeliveryDate + ".");
                }

                // Add a footer
                MembershipUser _currMember = Membership.GetUser();
                string         _from       = string.IsNullOrEmpty(_currMember.UserName) ? "the Quaffee Team" : " from the Quaffee Team (" + UpCaseFirstLetter(_currMember.UserName) + ")";

                _email.AddStrAndNewLineToBody("<br />Sent automatically by Quaffee's order and tracking System.<br /><br />Sincerely " + _from + " ([email protected])");
                if (_email.SendEmail())
                {
                    ltrlStatus.Text = "Email Sent to: " + _AddressedTo;
                }
                else
                {
                    showMessageBox _msg = new showMessageBox(this.Page, "error", "error sending email: " + _email.myResults);
                    ltrlStatus.Text = "Email was not sent!";
                }

                TrackerDotNet.classes.showMessageBox _MsgBx = new classes.showMessageBox(this.Page, "Email Confirmation", ltrlStatus.Text);
                upnlNewOrderItem.Update();
            }
        }
Exemplo n.º 2
0
        /// <summary>
        /// Send email to the current client to confirm the items in the current order, and the deliver date
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void btnConfirmOrder_Click(object sender, EventArgs e)
        {
            DropDownList _ddlThisContact = (DropDownList)dvOrderHeader.FindControl("ddlContacts");

            ContactDetails.ContactEmailDetails _thisContact = GetContactsEmailDetails(_ddlThisContact.SelectedItem.Value);
            if (_thisContact != null)
            {
                EmailCls     _email           = new EmailCls();
                DropDownList _ddlDeliveryBy   = (DropDownList)dvOrderHeader.FindControl("ddlToBeDeliveredBy"); // who is delivering this
                Label        _lblDeliveryDate = (Label)dvOrderHeader.FindControl("lblRequiredByDate");         // date it will be dispatched / delivered"

                if (_thisContact.EmailAddress != "")
                {
                    _email.SetEmailFromTo(CONST_FROMEMAIL, _thisContact.EmailAddress);
                    if (_thisContact.altEmailAddress != "")
                    {
                        _email.SetEmailCC(_thisContact.altEmailAddress);
                    }
                }
                else if (_thisContact.altEmailAddress != "")
                {
                    _email.SetEmailFromTo(CONST_FROMEMAIL, _thisContact.altEmailAddress);
                }
                else
                {
                    return; // no email address so quit
                }
                // send a BCC to orders to confirm
                _email.SetEmailBCC(CONST_FROMEMAIL);
                // set subject and body
                _email.SetEmailSubject("Order Confirmation");
                _email.AddStrAndNewLineToBody("Dear " + ((_thisContact.FirstName != "") ? _thisContact.FirstName : ((_thisContact.altFirstName != "") ? _thisContact.altFirstName : "Coffee Lover")) + ",<br />");
                _email.AddStrAndNewLineToBody("We confirm the following order for " + _ddlThisContact.SelectedItem.Text + ":");
                _email.AddToBody("<ul>");
                foreach (GridViewRow _gv in gvOrderLines.Rows)
                {
                    DropDownList _gvItemDesc      = (DropDownList)_gv.FindControl("ddlItemDesc");
                    Label        _gvItemQty       = (Label)_gv.FindControl("lblQuantityOrdered");
                    DropDownList _gvItemPackaging = (DropDownList)_gv.FindControl("ddlPackaging");
                    // need to check for serivce / note and add the note using the same logic as we have for the delivery sheet
                    if (_gvItemPackaging.SelectedIndex == 0)
                    {
                        _email.AddFormatToBody("<li>{0} x {1}</li>", _gvItemQty.Text, _gvItemDesc.SelectedItem.Text);
                    }
                    else
                    {
                        _email.AddFormatToBody("<li>{0} x {1} - Preperation note: {2}</li>", _gvItemQty.Text, _gvItemDesc.SelectedItem.Text, _gvItemPackaging.SelectedItem.Text);
                    }
                }
                _email.AddStrAndNewLineToBody("</ul>");

                if (_ddlDeliveryBy.SelectedItem.Text == CONST_DELIVERYTYPEISCOLLECTION)
                {
                    _email.AddStrAndNewLineToBody("Will be ready for collection on: " + _lblDeliveryDate.Text);
                }
                else if (_ddlDeliveryBy.SelectedItem.Text == CONST_DELIVERYTYPEISCOURIER)
                {
                    _email.AddStrAndNewLineToBody("Will be dispatched on: " + _lblDeliveryDate.Text + ".");
                }
                else
                {
                    _email.AddStrAndNewLineToBody("Will be delivered on: " + _lblDeliveryDate.Text + ".");
                }

                // Add a footer
                _email.AddStrAndNewLineToBody("<br />Sent automatically by Quaffee's order and tracking System.<br /><br />Sincerely Quaffee Team ([email protected])");
                if (_email.SendEmail())
                {
                    ltrlStatus.Text = "Email Sent to: " + _thisContact.EmailAddress;
                }
                else
                {
                    ltrlStatus.Text = "Email was not sent!";
                }
            }
        }