using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml;
using TopWinCMS.BLL;
using TopWinCMS.Common;
using TopWinCMS.Model;
namespace TopWinCMS.WebUI.Admin.ControlPanel
{
    public partial class TopWinCMSEmailSetting : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                RightsCheck.CheckWorkPower("S_3");
                try
                {
                    ReadMailConfigXML();
                }
                catch (Exception Ex)
                {
                    MsgBox.Alert(Ex.Message.Replace(@"\", @"\\"), UpdatePanel1);
                }
            }
        }

        #region eMail
        private void ReadMailConfigXML()
        {
            CB_MailSend.Checked = eMailConfig.MailSend;
            TB_MailFrom.Text = eMailConfig.MailFrom;
            TB_MailFromName.Text = eMailConfig.MailFromName;
            TB_MailDomain.Text = eMailConfig.MailDomain;
            TB_MailServerUserName.Text = eMailConfig.MailServerUserName;
            TB_MailServerPassWord.Text = eMailConfig.MailServerPassWord;
        }

        private void WriteMailConfigXML()
        {
            eMailConfig.MailSend = CB_MailSend.Checked;
            eMailConfig.MailFrom = TB_MailFrom.Text;
            eMailConfig.MailFromName = TB_MailFromName.Text;
            eMailConfig.MailDomain = TB_MailDomain.Text;
            eMailConfig.MailServerUserName = TB_MailServerUserName.Text;
            eMailConfig.MailServerPassWord = TB_MailServerPassWord.Text;
        }
        #endregion

        protected void BT_OK_Click(object sender, EventArgs e)
        {
            try
            {
                WriteMailConfigXML();
            }
            catch (Exception Ex)
            {
                MsgBox.Alert(Ex.Message.Replace(@"\", @"\\"), UpdatePanel1);
            }
        }
    }
}