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_replysuggestdetails : System.Web.UI.Page
{
    public int lid = 0;
    public string company = string.Empty;
    public string abouts = string.Empty;
    public string suggest = string.Empty;
    public string addtime = string.Empty;
    public int userid = 0;
    public string wancheng = string.Empty;
    public string phreply = string.Empty;
    protected void Page_Load(object sender, EventArgs e)
    {

        if (Request.QueryString["lid"].ToString() != null)
        {
            lid = Convert.ToInt32(Request.QueryString["lid"].ToString());
            if (!Page.IsPostBack)
            {
                etw.etw_suggest lead = new etw.etw_suggest();
                lead.id = lid;
                lead.GetModel();
                userid = lead.userid;
                abouts = lead.abouts;
                suggest = lead.suggest;
                addtime = lead.addtime;
                phreply = lead.phreply.ToString();
                if (lead.replytime != null && lead.replytime != "" && lead.replytime != "0")
                {
                    wancheng = lead.etwreply + "<br /> <span style='color:#ff0000;font-weight:bold;'>完成时间:" + lead.replytime + "</span>";
                    etwreplytxt.Visible = false;
                    Button1.Visible = false;
                }
                if (phreply == "1")
                {
                    Button3.Visible = true;
                    Button2.Visible = false;
                }
                else
                {
                    Button3.Visible = false;
                    Button2.Visible = true;
                }
                DataSet ds = DbHelperSQL.Query("select company from etw_user where userid=" + userid);
                if (ds.Tables[0].Rows.Count > 0)
                {
                    company = ds.Tables[0].Rows[0]["company"].ToString();
                }
            }
        }
    }
    public string get_phreply(string phreply)
    {
        string zhuangtai;
        if (phreply == "0")
        {
            zhuangtai = "<span style='color:#ff0000;font-weight:bold;'>你还未给客户电话回复</span>";
        }
        else
        {
            zhuangtai = "<span style='font-weight:bold;'>你已经给客户回复过电话</span>";
        }
        return zhuangtai;
    }
    protected void Button1_Click(object sender, EventArgs e)
    {
        etw.etw_suggest lead = new etw.etw_suggest();
        lead.id = lid;
        lead.etwreply = Fun.Encode(etwreplytxt.Text.Trim());
        lead.replytime = Fun.GetDateTime();
        lead.Update_etwreply();
        Fun.JsAlerT("回复成功！", "replysuggest.aspx");
    }
    protected void Button2_Click(object sender, EventArgs e)
    {
        etw.etw_suggest lead = new etw.etw_suggest();
        lead.id = lid;
        lead.phreply = 1;
        lead.Update_phreply();
        Fun.JsAlerT("更新成功", "replysuggestdetails.aspx?lid=" + lid);
    }
    protected void Button3_Click(object sender, EventArgs e)
    {
        etw.etw_suggest lead = new etw.etw_suggest();
        lead.id = lid;
        lead.phreply = 0;
        lead.Update_phreply();
        Fun.JsAlerT("更新成功", "replysuggestdetails.aspx?lid=" + lid);
    }
}
