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.askmanage._controls
{
    public partial class ctl_pagerview : System.Web.UI.UserControl
    {
        public int i = 1;
        protected void Page_Load(object sender, EventArgs e)
        {

        }

        public string GetQuestionItemHtml(string questionid, string type, string sortmodel, string TelId)
        {
            string res = "";
            DataTable dt = new DataTable();
            try
            {
                string v = "";
                string arrquestionid = "";
                string arrquestionres = "";
                if (TelId != "" && TelId != null)
                {
                    try
                    {
                        Model.T_Call_TaskTelNum model = new BLL.T_Call_TaskTelNum().GetModel(Convert.ToInt32(TelId));
                        if (model != null)
                        {
                            arrquestionid = model.F_AskRes;
                            arrquestionres = model.F_AskInfo;
                            string[] arrid = arrquestionid.Split(',');
                            string[] arrres = arrquestionres.Split(',');
                            for (int i = 0; i < arrid.Length; i++)
                            {
                                if (arrid[i] == questionid)
                                {
                                    v = arrres[i];
                                    break;
                                }
                            }
                        }
                    }
                    catch
                    {
                    }
                }
                if (type == "1")
                {
                    res = "<textarea id=\"txtF_Title_" + questionid.Trim() + "\" name=\"txtF_Title_" + questionid.Trim() + "\" value=\"" + v + "\" cols=\"20\" rows=\"4\" class=\"txtInput normal\" style=\"width: 95%; height: 30px;\">" + v + "</textarea>";
                }
                else
                {
                    dt = new BLL.T_Ask_QuestionItems().GetList(" F_QuestionId=" + questionid.Trim() + " order by F_Sort ").Tables[0];
                    if (dt != null)
                    {
                        string[] arr1 = new string[] { "1", "2", "3", "4", "5", "6", "7", "8", "9", "10", "11", "12", "13", "14", "15", "16", "17", "18", "19", "20" };
                        string[] arr2 = new string[] { "A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L", "M", "N", "O", "P", "Q", "R", "S", "T" };
                        for (int i = 0; i < dt.Rows.Count; i++)
                        {
                            string check = "";

                            string code = "";
                            if (sortmodel == "1")
                            {
                                code = arr2[i];
                            }
                            else
                            {
                                code = arr1[i];
                            }

                            if (v != "")
                            {
                                try
                                {
                                    string[] arrchk = v.Split('|');
                                    for (int n = 0; n < arrchk.Length; n++)
                                    {
                                        if (arrchk[n] == dt.Rows[i]["F_ItemId"].ToString().Trim())
                                        {
                                            check = "checked";
                                            break;
                                        }
                                    }
                                }
                                catch
                                {
                                }
                            }

                            if (type == "2")
                            {
                                res += "<div style='float:left; padding-left:10px;'><input id=\"radio_" + dt.Rows[i]["F_ItemId"].ToString().Trim() + "\" " + check + " value=\"" + dt.Rows[i]["F_ItemId"].ToString().Trim() + "\" name=\"radio_name_" + questionid.Trim() + "\" type=\"radio\" /><label for=\"radio_" + dt.Rows[i]["F_ItemId"].ToString().Trim() + "\">&nbsp;" + code + "、" + dt.Rows[i]["F_ItemName"].ToString().Trim() + "</label></div>";
                            }
                            if (type == "3")
                            {
                                res += "<div style='float:left; padding-left:10px;'><input id=\"check_" + dt.Rows[i]["F_ItemId"].ToString().Trim() + "\" " + check + " value=\"" + dt.Rows[i]["F_ItemId"].ToString().Trim() + "\" name=\"check_name_" + questionid.Trim() + "_" + dt.Rows[i]["F_ItemId"].ToString().Trim() + "\" type=\"checkbox\" /><label for=\"check_" + dt.Rows[i]["F_ItemId"].ToString().Trim() + "\">&nbsp;" + code + "、" + dt.Rows[i]["F_ItemName"].ToString().Trim() + "</label></div>";
                            }
                        }
                    }
                }
            }
            catch (Exception ex)
            {
            }
            finally
            {
                dt.Clear();
                dt.Dispose();
            }
            if (res == "")
            {
                res = "&nbsp;";
            }
            return res;
        }
    }
}