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 etw_c_m_completeview : System.Web.UI.Page
{
    public string username = string.Empty;
    public string title = string.Empty;
    public string language = string.Empty;
    public string content = string.Empty;
    public string person = string.Empty;
    public string chatstr = string.Empty;
    public string mssage = string.Empty;
    public string lg = string.Empty;
    public string fujian = string.Empty;
    public string senddate = string.Empty;
    public string t_content = string.Empty;
    public int uid = 0;
    public int cid = 0;
    public int id = 0;
    protected void Page_Load(object sender, EventArgs e)
    {
        uid = Convert.ToInt32(Request.QueryString["userid"].ToString());
        cid = Convert.ToInt32(Request.QueryString["chatid"].ToString());
        id = Convert.ToInt32(Request.QueryString["id"].ToString());
        HttpCookie GetCookie = Request.Cookies["cook_admin"];
        if (Request.Cookies["cook_admin"] == null)
        {
            Response.Redirect("index.aspx");
        }
        if (!IsPostBack)
        {
            etwusername();
            translate();
        }

    }
    public void etwusername()
    {

        etw.etw_user lead = new etw.etw_user();
        lead.userid = uid;
        lead.GetModel();
        username = lead.company;


        etw.etw_onlines ols = new etw.etw_onlines();
        ols.id = cid;
        ols.GetModel();
        title = ols.title;
        language = china_lang(ols.language);
        int chatuserid = ols.childuserid;
        senddate = ols.senddate;


        etw.etw_translate etl = new etw.etw_translate();
        etl.id = id;
        etl.GetModel();
        content = etl.source_content;
        t_content = etl.trans_content;
        person = getusername(etl.personid.ToString());
        if (etl.fujian != null && etl.fujian != "")
        {
            fujian = " <a target='_blank' href='download.aspx?fujian=" + etl.fujian + "' style='text-decoration:none; color:#004080'><img src='images/downpic.gif' border='0' />下载 附件 </a>";
        }


        if (chatuserid == 0)
        {
            chatstr = "来自总帐户";
        }
        else
        {
            DataSet ds3 = DbHelperSQL.Query("select realname,username from chat_user where id='" + cid + "'");
            if (ds3.Tables[0].Rows.Count > 0)
            {
                chatstr = ds3.Tables[0].Rows[0]["realname"].ToString();
                chatstr = chatstr + "--" + ds3.Tables[0].Rows[0]["username"].ToString();
            }
            chatstr = "来自子帐户:" + chatstr;
        }


    }
   
    
    public string china_lang(string lang)
    {
        string chinalang;
        if (language == "0")
        {
            chinalang = "邮件,无法识别语言";
        }
        else
        {
            if (language == "null")
            {
                chinalang = "无法识别语言";
            }
            else
            {
                chinalang = Convert.ToString(DbHelperSQL.GetSingle("select language from etw_language where domain like '%" + lang + "%'"));

            }
        }
        return chinalang;
    }
    public string getusername(string personid)
    {
        string username = string.Empty;
        if (personid != "" && personid != null)
        {
            username = Convert.ToString(DbHelperSQL.GetSingle("select realname from etw_admin where id=" + Convert.ToInt32(personid) + ""));
        }
        return username;
    }

 
 
    protected void translate()
    {
        DataSet ds5 = DbHelperSQL.Query("select id,achivetime,personid,type,trans_content,source_content,fujian,trans_fujian from etw_translate where chatid='" + cid + "' and type=2 order by receivetime asc");
        if (ds5.Tables[0].Rows.Count > 0)
        {
            Repeater1.DataSource = ds5.Tables[0].DefaultView;
            Repeater1.DataBind();
        }
    }

    public string trans_fujian(string trnsfujian)
    {
        if (trnsfujian != null && trnsfujian != "")
        {
            trnsfujian = " <a target='_blank' href='download.aspx?fujian=" + trnsfujian + "' style='text-decoration:none; color:#004080'><img src='images/downpic.gif' border='0' />下载 附件 </a>";
        }
        return trnsfujian;
    }
}
