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 JuSNS.Home;
using JuSNS.Model;
using JuSNS.Common;

namespace JuSNS.Web.home.ibase
{
    public partial class email : JuSNS.UI.Page.UserPage
	{
        JuSNS.Home.Space sp = new JuSNS.Home.Space();
        JuSNS.Home.MyInfo ac = new JuSNS.Home.MyInfo();
        protected void Page_Load(object sender, EventArgs e)
        {
                getInfo();
                string type = Request.Form["Type"];
                if (type == "Save")
                {
                    if (ac.UpdateEmailSet(Request.Form["ItemId"], Request.Form["Announce"], this.UserID, JuSNS.Common.Public.GetClientIP(), 0) >0)
                    {
                        Response.Write("设置成功!");
                        Response.End();
                    }
                }
        }

        /// <summary>
        /// 初始化
        /// </summary>
        public void getInfo()
        {
            DataTable dt = ac.getEmail(this.UserID, 1);//ItemID,Announce,PostTime
            if (dt != null && dt.Rows.Count > 0)
            {
                for (int i = 0; i < dt.Rows.Count; i++)
                {
                    string kk = dt.Rows[i]["Announce"].ToString();
                    if (dt.Rows[i]["Announce"].ToString() == "True")
                    {
                        #region 邮件通知设置开启
                        switch (int.Parse(dt.Rows[i]["ItemID"].ToString()))
                        {
                            case 1:
                                this.radYes0.Checked = true;
                                break;
                            case 2:
                                this.radYes1.Checked = true;
                                break;
                            case 3:
                                this.radYes2.Checked = true;
                                break;
                            case 4:
                                this.radYes3.Checked = true;
                                break;
                            case 5:
                                this.radYes4.Checked = true;
                                break;
                            case 6:
                                this.radYes5.Checked = true;
                                break;
                            case 7:
                                this.radYes6.Checked = true;
                                break;
                            case 8:
                                this.radYes7.Checked = true;
                                break;
                            case 9:
                                this.radYes8.Checked = true;
                                break;
                            case 10:
                                this.radYes9.Checked = true;
                                break;
                            case 11:
                                this.radYes10.Checked = true;
                                break;
                            case 12:
                                this.radYes11.Checked = true;
                                break;
                            case 13:
                                this.radYes12.Checked = true;
                                break;
                            case 14:
                                this.radYes13.Checked = true;
                                break;
                            case 15:
                                this.radYes14.Checked = true;
                                break;
                            case 16:
                                this.radYes15.Checked = true;
                                break;
                            case 17:
                                this.radYes16.Checked = true;
                                break;
                            case 18:
                                this.radYes17.Checked = true;
                                break;
                            case 19:
                                this.radYes18.Checked = true;
                                break;
                            case 20:
                                this.radYes19.Checked = true;
                                break;
                        }
                        #endregion
                    }
                    else if (dt.Rows[i]["Announce"].ToString() == "False")
                    {
                        #region 邮件通知设置关闭
                        switch (int.Parse(dt.Rows[i]["ItemID"].ToString()))
                        {
                            case 1:
                                this.radNo0.Checked = true;
                                break;
                            case 2:
                                this.radNo1.Checked = true;
                                break;
                            case 3:
                                this.radNo2.Checked = true;
                                break;
                            case 4:
                                this.radNo3.Checked = true;
                                break;
                            case 5:
                                this.radNo4.Checked = true;
                                break;
                            case 6:
                                this.radNo5.Checked = true;
                                break;
                            case 7:
                                this.radNo6.Checked = true;
                                break;
                            case 8:
                                this.radNo7.Checked = true;
                                break;
                            case 9:
                                this.radNo8.Checked = true;
                                break;
                            case 10:
                                this.radNo9.Checked = true;
                                break;
                            case 11:
                                this.radNo10.Checked = true;
                                break;
                            case 12:
                                this.radNo11.Checked = true;
                                break;
                            case 13:
                                this.radNo12.Checked = true;
                                break;
                            case 14:
                                this.radNo13.Checked = true;
                                break;
                            case 15:
                                this.radNo14.Checked = true;
                                break;
                            case 16:
                                this.radNo15.Checked = true;
                                break;
                            case 17:
                                this.radNo16.Checked = true;
                                break;
                            case 18:
                                this.radNo17.Checked = true;
                                break;
                            case 19:
                                this.radNo18.Checked = true;
                                break;
                            case 20:
                                this.radNo19.Checked = true;
                                break;
                        }
                        #endregion
                    }
                }
            }
            dt.Clear(); dt.Dispose();
        }
	}
}
