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 alluntrans : System.Web.UI.Page
{
    public int page = 1;
    public string num = string.Empty;
    public string webmodify = string.Empty;
    public string replaycount = string.Empty;
    public string str = string.Empty;
    protected void Page_Load(object sender, EventArgs e)
    {
        HttpCookie GetCookie = Request.Cookies["cook_admin"];
        if (Request.Cookies["cook_admin"] == null)
        {
            Response.Redirect("index.aspx");
        }
        if (!IsPostBack)
        {
            EtwTranslate();
            EtwTranslist();
            BindDrpClass();
            untranslate();
        }
    }

    public void EtwTranslate()
    {
        DataSet ds = DbHelperSQL.Query("select t.id,u.company,case o.yid  when  '-1'  then '邮件' else  '留言' end as chat,t.receivetime,t.chatid,t.userid  from etw_translate t left join etw_user u  on t.userid=u.userid  left join etw_onlines o on t.chatid= o.id  where t.achivetime=0 and  t. language='0' ");
        if (ds.Tables[0].Rows.Count > 0)
        {
            Repeater1.DataSource = ds.Tables[0].DefaultView;
            Repeater1.DataBind();
        }
    }

    public void EtwTranslist()
    {
        DataSet ds1 = DbHelperSQL.Query("select t.id,u.company,t.priority,case o.yid  when  '-1'  then '邮件' else  '留言' end as chat,t.receivetime,l.language,t.chatid,t.userid   from etw_translate t left join etw_user u  on t.userid=u.userid  left join etw_onlines o on t.chatid= o.id left join etw_language l on t.language=l.domain  where achivetime='0'");
        if (ds1.Tables[0].Rows.Count > 0)
        {
            Repeater2.DataSource = ds1.Tables[0].DefaultView;
            Repeater2.DataBind();
        }
    }

    public string time(string timeStamp)
    {
        DateTime dtStart = TimeZone.CurrentTimeZone.ToLocalTime(new DateTime(1970, 1, 1));
        long lTime = long.Parse(timeStamp + "0000000");
        TimeSpan toNow = new TimeSpan(lTime);
        DateTime dtResult = dtStart.Add(toNow);
        return dtResult.ToString("yy-MM-dd HH:mm");
    }

    private void BindDrpClass()
    {

        langlist.Items.Add(new ListItem("语言", "0"));
        DataSet ds3 = DbHelperSQL.Query("select * from etw_language order by id");
        for (int i = 0; i < ds3.Tables[0].Rows.Count; i++)
        {
            langlist.Items.Add(new ListItem(ds3.Tables[0].Rows[i]["language"].ToString(), ds3.Tables[0].Rows[i]["domain"].ToString()));
        }
        langlist.DataBind();
    }
    protected void Button1_Click(object sender, EventArgs e)
    {
        string lang = langlist.SelectedValue.ToString();
        string where = string.Empty;
        if (lang != "0")
        {
            where = " and t.language='" + lang + "'";
        }
        if (company.Text.ToString() != null && company.Text.ToString() != "")
        {
            where = where + "and u.company like N'%" + company.Text.ToString() + "%'";
        }
        DataSet ds1 = DbHelperSQL.Query("select t.id,u.company,t.priority,case o.yid  when  '-1'  then '邮件' else  '留言' end as chat,t.receivetime,l.language,t.chatid,t.userid   from etw_translate t left join etw_user u  on t.userid=u.userid  left join etw_onlines o on t.chatid= o.id left join etw_language l on t.language=l.domain  where achivetime='0' " + where + "");
        if (ds1.Tables[0].Rows.Count > 0)
        {
            Repeater2.DataSource = ds1.Tables[0].DefaultView;
            Repeater2.DataBind();
        }
        else
        {
            Repeater2.DataBind();
        }
        untranslate();
    }
    public void untranslate()
    { 
      num = Convert.ToString( DbHelperSQL.GetSingle("select count(*) from etw_translate where achivetime=0"));
      webmodify = Convert.ToString(DbHelperSQL.GetSingle("select count(*) from etw_productupd where achivetime='0'"));
      replaycount = Convert.ToString(DbHelperSQL.GetSingle(" select count(*) from etw_suggest where replytime=0"));   
    }
    public string priority(string pid)
    {
     
        if (pid == "1")
        {
            str = "checked";
        }
        else
        {
            str = "";
        }

        return str;
    }

    public string pristr(string n,string m)
    {
        string str=string.Empty;
        if(n=="1")
        {
            str = "<span  style=\"color:#F00\"> 优先</span>";
        }else
        {
            str = m;
        }
        return str;
    }
}
