Esempio n. 1
0
        /// <summary>
        /// Handles the Delete event of the gEmailTemplates control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="RowEventArgs" /> instance containing the event data.</param>
        protected void gEmailTemplates_Delete(object sender, RowEventArgs e)
        {
            EmailTemplateService emailTemplateService = new EmailTemplateService();
            EmailTemplate        emailTemplate        = emailTemplateService.Get((int)gEmailTemplates.DataKeys[e.RowIndex]["id"]);

            if (emailTemplate != null)
            {
                emailTemplateService.Delete(emailTemplate, CurrentPersonId);
                emailTemplateService.Save(emailTemplate, CurrentPersonId);
            }

            BindGrid();
        }
Esempio n. 2
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;
        }