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_biaoji : System.Web.UI.Page
{
    public string id = string.Empty;
    public string color = string.Empty;
    public string username = string.Empty;
    public string usernameid = string.Empty;
    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
            {
                username = GetCookie["username"];
                DataSet ds1 = DbHelperSQL.Query("select * from etw_user where username='" + username + "'");
                if (ds1.Tables[0].Rows.Count > 0)
                {
                    usernameid = ds1.Tables[0].Rows[0]["userid"].ToString();
                }
            }
        }
        else
        {
            username = ChatCookie["username"];
            DataSet ds2 = DbHelperSQL.Query("select * from chat_user where username='" + username + "'");
            if (ds2.Tables[0].Rows.Count > 0)
            {
                usernameid = ds2.Tables[0].Rows[0]["userid"].ToString();
            }
        }
        Fun.Funrecord(Request.Url.AbsoluteUri,Page.Request.UserHostAddress, usernameid);
        id = Request.Params["id"];
        color = Request.Params["color"];
        string[] strid = id.Split(new char[] { ',' });
        for (int i = 0; i < strid.Length; i++)
        {
            if (strid[i] != "")
            {
                DataSet ds = DbHelperSQL.Query("select * from etw_biaoji where online_id=" + strid[i] + "");
                etw.etw_biaoji lead = new etw.etw_biaoji();
                lead.color = color;
                if (ds.Tables[0].Rows.Count > 0)
                {
                    lead.id = Convert.ToInt32(ds.Tables[0].Rows[0]["id"].ToString());
                    lead.online_id = Convert.ToInt32(ds.Tables[0].Rows[0]["online_id"].ToString());
                    lead.usernameid = Convert.ToInt32(ds.Tables[0].Rows[0]["usernameid"].ToString());
                    lead.tran_id = Convert.ToInt32(ds.Tables[0].Rows[0]["tran_id"].ToString());
                    lead.is_tran = Convert.ToInt32(ds.Tables[0].Rows[0]["is_tran"].ToString());
                    lead.istop = Convert.ToInt32(ds.Tables[0].Rows[0]["istop"].ToString());
                    lead.flag = ds.Tables[0].Rows[0]["flag"].ToString();
                    lead.priority = Convert.ToInt32(ds.Tables[0].Rows[0]["priority"].ToString());
                    lead.Update();
                }
                else
                {
                    lead.online_id = Convert.ToInt32(strid[i]);
                    lead.usernameid = Convert.ToInt32(usernameid);
                    lead.Add();
                }
            }

        }
    }
}
