Example #1
0
        /// <summary>
        /// Handles the Click event of the btnSave control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="EventArgs" /> instance containing the event data.</param>
        protected void btnSave_Click(object sender, EventArgs e)
        {
            EmailTemplateService emailTemplateService = new EmailTemplateService();
            EmailTemplate        emailTemplate;

            int emailTemplateId = int.Parse(hfEmailTemplateId.Value);

            if (emailTemplateId == 0)
            {
                emailTemplate = new EmailTemplate();
                emailTemplateService.Add(emailTemplate, CurrentPersonId);
            }
            else
            {
                emailTemplate = emailTemplateService.Get(emailTemplateId);
            }

            emailTemplate.Category = tbCategory.Text;
            emailTemplate.Title    = tbTitle.Text;
            emailTemplate.From     = tbFrom.Text;
            emailTemplate.To       = tbTo.Text;
            emailTemplate.Cc       = tbCc.Text;
            emailTemplate.Bcc      = tbBcc.Text;
            emailTemplate.Subject  = tbSubject.Text;
            emailTemplate.Body     = tbBody.Text;

            if (!emailTemplate.IsValid)
            {
                // Controls will render the error messages
                return;
            }

            emailTemplateService.Save(emailTemplate, CurrentPersonId);
            BindFilter();
            BindGrid();
            pnlDetails.Visible = false;
            pnlList.Visible    = true;
        }