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;

public partial class etwuser_control_Left : System.Web.UI.UserControl
{
    public int num = 0;
    public int isreade = 0;
    public int Noreade = 0;
    public int NOfanyi = 0;
	public int delmun=0;
    public int delmun1 = 0;
    public int Emailnum = 0;
    public int Enum = 0;
    public int NOEmailnum = 0;
    protected void Page_Load(object sender, EventArgs e)
    {
        HttpCookie ChatCookie = Request.Cookies["cookChatuser"];
        HttpCookie GetCookie = Request.Cookies["cookEtwuser"];
        if (Request.Cookies["cookChatuser"] == null)
        {
            if (Request.Cookies["cookEtwuser"] == null)
            {
                Response.Redirect("../index.aspx");
            }
            else
            {
                DataSet ds1 = DbHelperSQL.Query("select userid from etw_user where username='" + GetCookie["username"] + "'");
                if (ds1.Tables[0].Rows.Count > 0)
                {
                   
                    num = (int)DbHelperSQL.GetSingle("select count(id) from etw_onlines where usernameid=" + ds1.Tables[0].Rows[0]["userid"] + " and yid!=-1 and id not in(select onlines_id from etw_repeat where usernameid=" + ds1.Tables[0].Rows[0]["userid"] + ")");
                    isreade = (int)DbHelperSQL.GetSingle("select count(id) from etw_onlines where usernameid=" + ds1.Tables[0].Rows[0]["userid"] + " and isdelete=0  and readed=1  and yid!=-1  and id not in(select onlines_id from etw_repeat where usernameid=" + ds1.Tables[0].Rows[0]["userid"] + ")");
                    Noreade = (int)DbHelperSQL.GetSingle("select count(id) from etw_onlines where usernameid=" + ds1.Tables[0].Rows[0]["userid"] + " and translate=0 and isdelete=0  and readed=0 and reply=0 and yid!=-1   and id not in(select onlines_id from etw_repeat where usernameid=" + ds1.Tables[0].Rows[0]["userid"] + ")");
                    NOfanyi = (int)DbHelperSQL.GetSingle("select count(id) from etw_onlines where usernameid=" + ds1.Tables[0].Rows[0]["userid"] + " and isdelete=0  and readed=0 and (translate!=0 or reply!=0) and yid!=-1 and id not in(select onlines_id from etw_repeat where usernameid=" + ds1.Tables[0].Rows[0]["userid"] + ")");
                    delmun = (int)DbHelperSQL.GetSingle("select count(id) from etw_onlines where isdelete=1 and yid!=-1  and  usernameid=" + ds1.Tables[0].Rows[0]["userid"] + " and id not in(select onlines_id from etw_repeat where usernameid=" + ds1.Tables[0].Rows[0]["userid"] + ")");               
                    delmun1 = (int)DbHelperSQL.GetSingle("select count(id) from etw_onlines where isdelete=1 and yid=-1  and  usernameid=" + ds1.Tables[0].Rows[0]["userid"] + " and id not in(select onlines_id from etw_repeat where usernameid=" + ds1.Tables[0].Rows[0]["userid"] + ")");
                    Emailnum = (int)DbHelperSQL.GetSingle("select count(id) from etw_onlines where usernameid=" + ds1.Tables[0].Rows[0]["userid"] + " and readed=1 and yid=-1 and isdelete=0  and id not in(select onlines_id from etw_repeat where usernameid=" + ds1.Tables[0].Rows[0]["userid"] + ")");
                    NOEmailnum = (int)DbHelperSQL.GetSingle("select count(id) from etw_onlines where usernameid=" + ds1.Tables[0].Rows[0]["userid"] + " and readed=0 and yid=-1 and isdelete=0  and id not in(select onlines_id from etw_repeat where usernameid=" + ds1.Tables[0].Rows[0]["userid"] + ")");
                    Enum = delmun1 + Emailnum + NOEmailnum;
                }
            }
        }
        else
        {
            DataSet ds = DbHelperSQL.Query("select id,userid from chat_user where username='" + ChatCookie["username"] + "'");
            if (ds.Tables[0].Rows.Count > 0)
            {
                num = (int)DbHelperSQL.GetSingle("select count(id) from etw_onlines where childuserid=" + ds.Tables[0].Rows[0]["id"] + " and id not in(select onlines_id from etw_repeat where usernameid=" + ds.Tables[0].Rows[0]["userid"] + ")");
                isreade = (int)DbHelperSQL.GetSingle("select count(id) from etw_onlines where childuserid=" + ds.Tables[0].Rows[0]["id"] + "  and isdelete=0 and childreaded=1 and yid!=-1  and id not in(select onlines_id from etw_repeat where usernameid=" + ds.Tables[0].Rows[0]["userid"] + ")");
                Noreade = (int)DbHelperSQL.GetSingle("select count(id) from etw_onlines where childuserid=" + ds.Tables[0].Rows[0]["id"] + "  and translate=0 and isdelete=0 and childreaded=0  and reply=0 and yid!=-1   and id not in(select onlines_id from etw_repeat where usernameid=" + ds.Tables[0].Rows[0]["userid"] + ")");
                NOfanyi = (int)DbHelperSQL.GetSingle("select count(id) from etw_onlines where childuserid=" + ds.Tables[0].Rows[0]["id"] + "  and isdelete=0 and childreaded=0 and (translate!=0 or reply!=0) and yid!=-1 and id not in(select onlines_id from etw_repeat where usernameid=" + ds.Tables[0].Rows[0]["userid"] + ")");
                delmun = (int)DbHelperSQL.GetSingle("select count(id) from etw_onlines where isdelete=1 and yid!=-1  and  childuserid=" + ds.Tables[0].Rows[0]["id"] + " and id not in(select onlines_id from etw_repeat where usernameid=" + ds.Tables[0].Rows[0]["userid"] + ")");
                delmun1 = (int)DbHelperSQL.GetSingle("select count(id) from etw_onlines where isdelete=1 and yid=-1  and  childuserid=" + ds.Tables[0].Rows[0]["id"] + " and id not in(select onlines_id from etw_repeat where usernameid=" + ds.Tables[0].Rows[0]["userid"] + ")");
                Emailnum = (int)DbHelperSQL.GetSingle("select count(id) from etw_onlines where childuserid=" + ds.Tables[0].Rows[0]["id"] + "and childreaded=1 and yid=-1 and isdelete=0 and id not in(select onlines_id from etw_repeat where usernameid=" + ds.Tables[0].Rows[0]["userid"] + ")");
                NOEmailnum = (int)DbHelperSQL.GetSingle("select count(id) from etw_onlines where childuserid=" + ds.Tables[0].Rows[0]["id"] + "and childreaded=0 and yid=-1 and isdelete=0 and id not in(select onlines_id from etw_repeat where usernameid=" + ds.Tables[0].Rows[0]["userid"] + ")");
                Enum = delmun1 + Emailnum + NOEmailnum;
            }
        }
    }
}
