Beispiel #1
0
    /// <summary>
    /// Send Mail, sends email about new ContentProvider (teacher) registration.
    /// </summary>
    /// <param name="entity"></param>
    /// <returns></returns>
    private string GetMailMessage(ContentProviderInfo entity)
    {
        //Subject line for e-mail.

        StringBuilder strBody = new StringBuilder();
        strBody.Append("<html><body>");

        //Contact Information.
        strBody.Append("<fieldset id='personal'>");
        strBody.Append("<legend><b>Contact Information</b></legend>");
        strBody.Append("<div><label for='firstname'><b>First name:</b></label> ");
        strBody.Append(entity.FirstName);
        strBody.Append(" </div>");
        strBody.Append("<div><label for='lastname'><b>Last name:</b></label> ");
        strBody.Append(entity.LastName);
        strBody.Append(" </div>");
        strBody.Append("<div><label for='day_phone'><b>Daytime Phone:</b></label> ");
        strBody.Append(entity.DaytimePhone);
        strBody.Append(" </div>");
        strBody.Append(" </div>");
        strBody.Append("<div><label for='eve_phone'><b>Evening Phone:</b></label> ");
        strBody.Append(entity.EveningPhone);
        strBody.Append(" </div>");
        strBody.Append("<label for='email'>");
        strBody.Append("<b>Email Address:</b></label> ");
        strBody.Append(entity.EmailAddress);
        strBody.Append("</fieldset>");

        //Company Information.
        strBody.Append("<fieldset id='company'>");
        strBody.Append("<legend><b>Company Information</b></legend>");
        strBody.Append("<div><label for='company_name'><b>Company Name:</b></label> ");
        strBody.Append(entity.CompanyName);
        strBody.Append(" </div>");
        strBody.Append("<div><label for='company_city'><b>Company City:</b></label> ");
        strBody.Append(entity.CompanyCity);
        strBody.Append(" </div>");
        strBody.Append("<div><label for='company_state'><b>Company State:</b></label> ");
        strBody.Append(entity.CompanyState);
        strBody.Append(" </div>");
        strBody.Append("<div><label for='company_country'><b>Company Country:</b></label> ");
        strBody.Append(entity.CompanyCountry);
        strBody.Append(" </div>");
        strBody.Append("<div><label for='company_started'><b>Started (year):</b></label> ");
        strBody.Append(entity.CompanyStartedYear);
        strBody.Append(" </div></fieldset>");

        //Other Information.
        strBody.Append("<fieldset id='other'>");
        strBody.Append("<legend><b>Other Information</b></legend>");
        strBody.Append("<div>");
        strBody.Append("<label for='other_course_amt'>");
        strBody.Append("<b>Do you have a merchant account ?</b></label> ");
        strBody.Append(entity.HaveMerchantAccount.ToString().ToUpper());
        strBody.Append(" </div>");
        strBody.Append("<div><label for='other_course_amt'><b>How many students are you anticipating ?</b></label> ");
        strBody.Append(entity.StudentsAnticipated);
        strBody.Append(" </div>");
        strBody.Append("<div><label for='other_course_amt'><b>How Many Courses are you planning on offering to your students?</b></label> ");
        strBody.Append(entity.CoursesOffered);
        strBody.Append(" </div>");
        strBody.Append("<div><label for='other_course_amt'><b>What kind of material would you like to offer?</b></label> ");
        strBody.Append("<br />");
        strBody.Append("Financial Education, Specialized Training, Company Specific Training");
        strBody.Append(" </div>");
        strBody.Append("<div><label for='other_course_amt'><b>Would you like to schedule a demo of the system?</b></label> ");
        strBody.Append(entity.ScheduleDemo);
        strBody.Append(" </div>");
        strBody.Append("<div><label for='comments'><b>Comments</b></label><br />");
        strBody.Append(entity.Comments);
        strBody.Append("</div></fieldset>");
        strBody.Append("</body></html>");


        // Send the message...

        return strBody.ToString();

    }
Beispiel #2
0
    /// <summary>
    /// ContentProvider(Teacher) Signup, Registers new teacher.
    /// </summary>
    /// <param name="sender"></param>
    /// <param name="e"></param>
    protected void SignupButton_Click(object sender, EventArgs e)
    {
        if (Page.IsValid)
        {
            string strSelectedMaterialItems = "";


            //Get selected materials list.
            if (chkBusinessEducation.Checked)
                strSelectedMaterialItems += chkBusinessEducation.Value + ",";

            if (chkCompanySpecificTraining.Checked)
                strSelectedMaterialItems += chkCompanySpecificTraining.Value + ",";

            if (chkFinancialEducation.Checked)
                strSelectedMaterialItems += chkFinancialEducation.Value + ",";

            if (chkSpecializedTraining.Checked)
                strSelectedMaterialItems += chkSpecializedTraining.Value + ",";

            if (chkTraditionalEducation.Checked)
                strSelectedMaterialItems += chkTraditionalEducation.Value + ",";

            strSelectedMaterialItems = strSelectedMaterialItems.TrimEnd(',');


            //Set properties.
            ContentProviderInfo entity = new ContentProviderInfo
            {
                Comments = CommentTextBox.Text,
                CompanyCity = CompanyCityTextBox.Text,
                CompanyCountry = CountryDropDown.SelectedItem.Value,
                CompanyName = CompanyNameTextBox.Text,
                CompanyStartedYear = int.Parse(CompanyStartedYearTextbox.Text),
                CompanyState = StateDropDown.SelectedItem.Value,
                CoursesOffered = CoursesOfferedDropDown.SelectedItem.Text,
                DaytimePhone = DaytimePhoneTextBox.Text,
                EmailAddress = EmailTextBox.Text,
                EveningPhone = EveningPhoneTextBox.Text,
                FirstName = FirstNameTextBox.Text,
                HaveMerchantAccount = chkHaveMerchantAccount.Checked,
                LastName = LastNameTextBox.Text,
                ScheduleDemo = Convert.ToInt32(chkScheduleDemo.Checked),
                StudentsAnticipated = StudentsAnticipatedDropDown.SelectedItem.Text,
                KindOfMaterialOffered = strSelectedMaterialItems,
            };

            try
            {
                //Insert record of new teacher into database.
                ContentProviderInfo.Insert(entity);

                string subject = string.Format("Content Provider Lead : {0}", entity.FirstName + " " + entity.LastName);

                MailMessage msg = new MailMessage("*****@*****.**", "*****@*****.**", subject, GetMailMessage(entity));
                msg.IsBodyHtml = true;
                msg.Priority = MailPriority.High;               
                new SmtpClient().Send(msg);   
            }
            catch (SqlException ex)
            {
                // log this error...
            }
            catch (SmtpException ex)
            {
                // log this error...
            }
            catch (Exception ex)
            {
                // log this error...
            }
            finally
            {
                // always redirect to the thanks page if it passes validation...
                Response.Redirect("~/Application/Thanks.aspx");
            }

        }
    }
        //public void Update()
        //{
        //    ContentProviderInfo.Update(this);
        //}

        #endregion

        #region [ Static Methods ]

        public static void Insert(ContentProviderInfo entity)
        {
            DbCommand cmd = SqlHelpers.CreateCommand(DataHelpers.ConnectionString, "dbo.mon_elrn_INSERT_CONTENTPROVIDER");

            cmd.AddInputParam("@FirstName", DbType.AnsiString, entity.FirstName);
            cmd.AddInputParam("@LastName", DbType.AnsiString, entity.LastName);
            cmd.AddInputParam("@DaytimePhone", DbType.AnsiString, entity.DaytimePhone);
            cmd.AddInputParam("@EveningPhone", DbType.AnsiString, entity.EveningPhone);
            cmd.AddInputParam("@EmailAddress", DbType.AnsiString, entity.EmailAddress);
            cmd.AddInputParam("@CompanyName", DbType.AnsiString, entity.CompanyName);
            cmd.AddInputParam("@CompanyCity", DbType.AnsiString, entity.CompanyCity);
            cmd.AddInputParam("@CompanyState", DbType.String, entity.CompanyState);
            cmd.AddInputParam("@CompanyCountry", DbType.String, entity.CompanyCountry);
            cmd.AddInputParam("@CompanyStartedYear", DbType.Int32, entity.CompanyStartedYear);
            cmd.AddInputParam("@HaveMerchantAccount", DbType.Boolean, entity.HaveMerchantAccount);
            cmd.AddInputParam("@StudentsAnticipated", DbType.AnsiString, entity.StudentsAnticipated);
            cmd.AddInputParam("@CoursesOffered", DbType.AnsiString, entity.CoursesOffered);
            cmd.AddInputParam("@KindOfMaterialOffered", DbType.AnsiString, entity.KindOfMaterialOffered);
            cmd.AddInputParam("@PercentageDesired", DbType.Int32, entity.PercentageDesired);
            cmd.AddInputParam("@ScheduleDemo", DbType.Int32, entity.ScheduleDemo);
            cmd.AddInputParam("@Comments", DbType.AnsiString, entity.Comments);

            entity.Id = Convert.ToInt32(SqlHelpers.ExecuteScalar(cmd));
        }