protected void Page_Load(object sender, EventArgs e)
        {
            String companyName = "";
                String personName = "";
                String email = "";
                String postCode = "";
                String phoneNumber = "";
                String enquiry = "";

                if (Request["companyName"] != null)
                    companyName = Request["companyName"];
                if (Request["personName"] != null)
                    personName = Request["personName"];
                if (Request["email"] != null)
                    email = Request["email"];
                if (Request["postCode"] != null)
                    postCode = Request["postCode"];
                if (Request["phoneNumber"] != null)
                    phoneNumber = Request["phoneNumber"];
                if (Request["enquiry"] != null)
                    enquiry = Request["enquiry"];

                UserEnquiry enquiryObj = new UserEnquiry
                {
                    companyName = companyName,
                    personName = personName,
                    email = email,
                    postCode = postCode,
                    phoneNumber = phoneNumber,
                    enquiry = enquiry
                };
                DatabaseContext.UserEnquiries.AddObject(enquiryObj);
                //            DatabaseContext.AddToUserEnquiries(enquiry);
                DatabaseContext.SaveChanges();

                MailMessage message = new MailMessage();
                message.To.Add(new MailAddress(email, personName));
                message.Body = "Company :" + companyName + "<br/>Person :" + personName + "<br/>Email :" + email + "<br/>Post Code : " + postCode + "<br/>Phone :" + phoneNumber + "<br/>Nature of Enquiry :" + enquiry;
                message.Subject = "Nature of Enquiry";
                message.IsBodyHtml = true;
                EmailUtility.SendEmail(message);
                //ErrorLabel.Visible = true;
                //ErrorLabel.Text = "Request Sent";
        }
 /// <summary>
 /// Deprecated Method for adding a new object to the UserEnquiries EntitySet. Consider using the .Add method of the associated ObjectSet&lt;T&gt; property instead.
 /// </summary>
 public void AddToUserEnquiries(UserEnquiry userEnquiry)
 {
     base.AddObject("UserEnquiries", userEnquiry);
 }
 /// <summary>
 /// Create a new UserEnquiry object.
 /// </summary>
 /// <param name="id">Initial value of the id property.</param>
 /// <param name="companyName">Initial value of the companyName property.</param>
 /// <param name="personName">Initial value of the personName property.</param>
 /// <param name="email">Initial value of the email property.</param>
 public static UserEnquiry CreateUserEnquiry(global::System.Int32 id, global::System.String companyName, global::System.String personName, global::System.String email)
 {
     UserEnquiry userEnquiry = new UserEnquiry();
     userEnquiry.id = id;
     userEnquiry.companyName = companyName;
     userEnquiry.personName = personName;
     userEnquiry.email = email;
     return userEnquiry;
 }
Exemplo n.º 4
0
 protected void submitButton_Click(object sender, ImageClickEventArgs e)
 {
     WestgateEntities DatabaseContext = new WestgateEntities();
     UserEnquiry enquiry = new UserEnquiry
     {
         companyName = CompanyTextID.Text,
         personName = PersonTextID.Text,
         email = EmailTextID.Text,
         postCode = PostTextID.Text,
         phoneNumber = PhoneTextID.Text,
         enquiry = EnquirySelectedId.SelectedItem.Text
     };
     DatabaseContext.UserEnquiries.AddObject(enquiry);
     //            DatabaseContext.AddToUserEnquiries(enquiry);
     DatabaseContext.SaveChanges();
     MailMessage message = new MailMessage();
     message.To.Add(new MailAddress(EmailTextID.Text, PersonTextID.Text));
     message.Body = "Company :" + CompanyTextID.Text + "<br/>Person :" + PersonTextID.Text + "<br/>Email :" + EmailTextID.Text + "<br/>Post Code : " + PostTextID.Text + "<br/>Phone :" + PhoneTextID.Text + "<br/>Nature of Enquiry :" + EnquirySelectedId.SelectedItem.Text;
     message.Subject = "Nature of Enquiry";
     message.IsBodyHtml = true;
     EmailUtility.SendEmail(message);
     ErrorLabel.Visible = true;
     ErrorLabel.Text = "Request Sent";
 }