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 hqgl.user;
using Common;
public partial class general_email_Default : System.Web.UI.Page
{
    public string inbox="0", inboxnew="0", outbox="0", sentbox="0", sentdel="0", delbox="0", delboxnew="0",sum="0";
    public string uname = "";
    public HtmlImage img = null;
    //收件箱数，新邮件数，发件箱数，已发件箱数，收件人删除数，废件箱数，废件箱中的新邮件,总的邮件数
    protected void Page_Load(object sender, EventArgs e)
    {
        userchuli uch = new userchuli();
        uch.user_yanzheng();
        userchuli user = new userchuli();
        uname=user.user_loginname();
        DataLoad(uname);
        if (inboxnew!="0")
        {
            img = new HtmlImage();
            img.Src ="~/images/email_new.gif";
            PlaceHolder1.Controls.Add(img);
        }
    }
    /// <summary>
    /// 初始化数据收件箱数，新邮件数，发件箱数等
    /// </summary>
    public void DataLoad(string uname)
    {
        //下面是是收件箱
        string sql = "select count(*) from email where delete_flag='0' and to_id like '%###%'";
        sql = sql.Replace("###", uname);
        DbHelper db = new DbHelper();
        object count = db.ExecuteScalar(sql);
        if (count != null)
            inbox = count.ToString();
        //下面的是新邮件
        sql = "select count(*) from email where read_flag='0' and to_id like '%###%'";
        sql = sql.Replace("###", uname);
        count = db.ExecuteScalar(sql);
        if (count != null)
            inboxnew = count.ToString();
        //下面是发件箱
        //sql = "select count(*) from email where from_id like '%###%'";
        //sql = sql.Replace("###", uname);
        //count = db.ExecuteScalar(sql);
        //if (count != null)
        //    sentbox = count.ToString();
        sum =Convert.ToString(Convert.ToInt32(sentbox) + Convert.ToInt32(inbox));
    }
}
