using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;

namespace HySoft.BaseCallCenter.Web.calloutmanage._controls
{
    public partial class callplanresultdata : System.Web.UI.UserControl
    {
        private string _paginationBar;
        /// <summary>
        /// 分页信息html
        /// </summary>
        public string PaginationBar
        {
            get { return _paginationBar; }
            set { _paginationBar = value; }
        }
        private string _f_askInfo;
        /// <summary>
        /// html
        /// </summary>
        public string F_AskRes
        {
            get { return _f_askInfo; }
            set { _f_askInfo = value; }
        }
        public int i = 0;
        protected void Page_Load(object sender, EventArgs e)
        {

        }

        public string GetRes(string askres)
        {
            string res = "";
            if (F_AskRes != null)
            {
                if (F_AskRes != "")
                {
                    int c = 0;
                    foreach (string ask in F_AskRes.Split(','))
                    {
                        res += "<td style=\"vertical-align: middle; border-top: 0px solid #CCCCCC; border-bottom: 1px solid #CCCCCC;";
                        res += "border-left: 1px solid #CCCCCC; border-right: 1px solid #CCCCCC; padding-left: 2px;";
                        res += "height: 18px; padding-top: 3px; padding-bottom: 3px;\">";
                        res += "&nbsp;";
                        try
                        {
                            string arrid = askres.Split(',')[c];
                            switch (ask.Split('|')[1])
                            {
                                case "1":
                                    //问答
                                    res += arrid;
                                    break;
                                case "2":
                                    //单选
                                    res += new BLL.T_Ask_QuestionItems().GetModel(Convert.ToInt32(arrid)).F_ItemName;
                                    break;
                                case "3":
                                    //多选
                                    DataTable dt=new DataTable();
                                    try
                                    {
                                        dt = new BLL.T_Ask_QuestionItems().GetList(" F_ItemId in(" + arrid.Replace("|", ",") + ") ").Tables[0];
                                        foreach (DataRow dr in dt.Rows)
                                        {
                                            res += dr["F_ItemName"].ToString().Trim() + ";";
                                        }
                                    }
                                    catch
                                    { }
                                    finally
                                    {
                                        dt.Clear();
                                        dt.Dispose();
                                    }
                                    break;
                            }
                        }
                        catch
                        {
                        }
                        c++;
                        res += "</td>";
                    }
                }
            }
            return res;
        }

        public string GetTitle(int r, string taskid)
        {
            i++;
            string res="";
            DataTable dt = new DataTable();
            try
            {
                if (r == 0)
                {
                    string pagerid = "";
                    Model.T_CTI_Task model = new BLL.T_CTI_Task().GetModel(Convert.ToInt32(taskid));
                    if (model != null)
                    {
                        if (model.y_TkModelId != 0)
                        {
                            pagerid = model.y_TkModelId.ToString();
                        }
                    }
                    if (pagerid.Trim() != "")
                    {
                        string itemtable = "T_Ask_PagerItems";
                        string questionidname = "F_QuestionId";
                        string sortname = "F_Sort";
                        string itemidname = "F_ItemId";
                        string key = "T_Ask_PagerItems.F_ItemId";
                        string sql = " and [T_Ask_PagerItems].[F_PagerId]=" + pagerid + " ";
                        int recordCount = 0;
                        dt = BLL.PagerBLL.GetListPager(
                            "vw_Ask_Question LEFT OUTER JOIN " + itemtable + " ON vw_Ask_Question.F_QuestionId = " + itemtable + "." + questionidname + " ",
                            key,
                            "vw_Ask_Question.*, '' as TelId," + itemtable + "." + sortname + " as F_Sort," + itemtable + "." + itemidname + " as F_ItemId",
                            " and F_DeleteFlag=0 " + sql,
                            "ORDER BY " + itemtable + "." + sortname + " ",
                            100,
                            1,
                            true,
                            out recordCount);
                    }
                    res += "<tr style=\"text-align: center;\">";
                    res += "<td style=\"height: 18px; background-color: #D5EDFE; border-left: 1px solid #CCCCCC;";
                    res += "border-right: 1px solid #CCCCCC; border-top: 1px solid #CCCCCC; border-bottom: 1px solid #CCCCCC;";
                    res += "padding: 3px 3px 3px 3px; text-align: center;\">";
                    res += "外呼计划";
                    res += "</td>";
                    res += "<td style=\"height: 18px; background-color: #D5EDFE; border-left: 1px solid #CCCCCC;";
                    res += "border-right: 1px solid #CCCCCC; border-top: 1px solid #CCCCCC; border-bottom: 1px solid #CCCCCC;";
                    res += "padding: 3px 3px 3px 3px; text-align: center;\">";
                    res += "号码";
                    res += "</td>";
                    res += "<td style=\"height: 18px; background-color: #D5EDFE; border-left: 1px solid #CCCCCC;";
                    res += "border-right: 1px solid #CCCCCC; border-top: 1px solid #CCCCCC; border-bottom: 1px solid #CCCCCC;";
                    res += "padding: 3px 3px 3px 3px; text-align: center;\">";
                    res += "名称";
                    res += "</td>";
                    res += "<td style=\"height: 18px; background-color: #D5EDFE; border-left: 1px solid #CCCCCC;";
                    res += "border-right: 1px solid #CCCCCC; border-top: 1px solid #CCCCCC; border-bottom: 1px solid #CCCCCC;";
                    res += "padding: 3px 3px 3px 3px; text-align: center;\">";
                    res += "门店";
                    res += "</td>";
                    res += "<td style=\"height: 18px; background-color: #D5EDFE; border-left: 1px solid #CCCCCC;";
                    res += "border-right: 1px solid #CCCCCC; border-top: 1px solid #CCCCCC; border-bottom: 1px solid #CCCCCC;";
                    res += "padding: 3px 3px 3px 3px; text-align: center;\">";
                    res += "回访坐席";
                    res += "</td>";
                    res += "<td style=\"height: 18px; background-color: #D5EDFE; border-left: 1px solid #CCCCCC;";
                    res += "border-right: 1px solid #CCCCCC; border-top: 1px solid #CCCCCC; border-bottom: 1px solid #CCCCCC;";
                    res += "padding: 3px 3px 3px 3px; text-align: center;\">";
                    res += "呼叫状态";
                    res += "</td>";
                    res += "<td style=\"height: 18px; background-color: #D5EDFE; border-left: 1px solid #CCCCCC;";
                    res += "border-right: 1px solid #CCCCCC; border-top: 1px solid #CCCCCC; border-bottom: 1px solid #CCCCCC;";
                    res += "padding: 3px 3px 3px 3px; text-align: center;\">";
                    res += "呼叫结果";
                    res += "</td>";
                    //<td style=\"height: 18px; background-color: #D5EDFE; border-left: 1px solid #CCCCCC;
                    //    border-right: 1px solid #CCCCCC; border-top: 1px solid #CCCCCC; border-bottom: 1px solid #CCCCCC;
                    //    padding: 3px 3px 3px 3px; text-align: center;\">
                    //    购物时遇到导购是否主动问好
                    //</td>
                    int count = dt.Rows.Count;
                    F_AskRes="";
                    foreach (DataRow dr in dt.Rows)
                    {
                        res += "<td style=\"height: 18px; background-color: #D5EDFE; border-left: 1px solid #CCCCCC;";
                        res += "border-right: 1px solid #CCCCCC; border-top: 1px solid #CCCCCC; border-bottom: 1px solid #CCCCCC;";
                        res += "padding: 3px 3px 3px 3px; text-align: center;\">";
                        res += "&nbsp;" + dr["F_Title"].ToString().Trim() + "";
                        res += "</td>";
                        F_AskRes += dr["F_QuestionId"].ToString().Trim() + "|" + dr["F_Type"].ToString().Trim() + ",";
                    }
                    F_AskRes += "!@#";
                    F_AskRes = F_AskRes.Replace(",!@#", "").Replace("!@#", "");
                    res += "</tr>";
                }
            }
            catch
            { }
            finally
            {
                dt.Clear();
                dt.Dispose();
            }
            return res;
        }
    }
}