using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using WebBasicInfo;
using Base;
using nspBase.Core;

public partial class admin_Basic_WebInfo : BasePage
{
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            Bind();
        }
    }

    private void Bind()
    {
        IWebBasicInfo RWeb = new RWebBasicInfo();
        TWebBasicInfo TWeb = RWeb.GateItem(); ;
        txtEmail.Text = TWeb.Email;
        txtEmailName.Text = TWeb.EmailName;
        txtEmailPass.Text = TWeb.EmailPass;
        txtEmailPass.Attributes.Add("value", TWeb.EmailPass);
        txtSMTP.Text = TWeb.SMTP;
    }

    protected void btnSave_Click(object sender, EventArgs e)
    {
        try
        {
            TWebBasicInfo TWeb = new TWebBasicInfo();
            TWeb.Email = txtEmail.Text;
            TWeb.EmailName = txtEmailName.Text;
            TWeb.EmailPass = txtEmailPass.Text;
            TWeb.SMTP = txtSMTP.Text;
            IWebBasicInfo RWeb = new RWebBasicInfo();
            RWeb.Update(TWeb);
            ShowMessage("网站配置保存成功！");
        }
        catch (Exception ex)
        {
            ShowMessage("网站配置保存失败!");
        }
    }
    protected void btnSubmit_Click(object sender, EventArgs e)
    {
        string Email = txtEmail.Text.Trim();
        string EmailName = txtEmailName.Text.Trim();
        string EmailPass = txtEmailPass.Text.Trim();
        string SMTP = txtSMTP.Text.Trim();
        string EmailTo = txtEmailTo.Text.Trim();
        string Message = clsEmail.SendMail(EmailTo, "测试", "测试", true, Email, EmailName, EmailPass, SMTP);
        lblMessage.Visible = true;
        lblMessage.Text = Message;
    }
}
