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.workordermanage._controls
{
    public partial class ctl_workordernote : System.Web.UI.UserControl
    {
        protected void Page_Load(object sender, EventArgs e)
        {

        }
        protected string getUserName(object instanceid)
        {
            string strUserName = "";
            DataTable workorderbase =
                new BLL.T_Wo_WorkOrderBase().GetList("F_INSTANCEID=" + instanceid).Tables[0];
            List<Model.T_Wo_WorkOrderConstructor> constructorlist =
                new BLL.T_Wo_WorkOrderConstructor().GetModelList("F_WORKORDERID=" + workorderbase.Rows[0]["F_WORKORDERID"]);
            foreach (Model.T_Wo_WorkOrderConstructor constructor in constructorlist)
            {
                int id = Convert.ToInt32(constructor.F_USERID);
                Model.T_Sys_UserAccount user = new BLL.T_Sys_UserAccount().GetModel(id);
                if (user != null)
                {
                    if (constructor.F_ISMAIN == 1)
                        strUserName += user.F_UserName + "(主负责人);";
                    else
                        strUserName += user.F_UserName + ";";
                }
            }
            return strUserName.TrimEnd(';');
        }
        protected string getHistoryInfo(object historyid, string type)
        {
            DataTable historyinfo = new BLL.T_Wo_WorkOrderHistoryInfo().GetList("F_HISTORYID=" + historyid).Tables[0];
            if (historyinfo.Rows.Count > 0)
            {
                switch (type)
                {
                    case "Estimated":
                        if (historyinfo.Rows[0]["F_ESTIMATED"] != null)
                            return historyinfo.Rows[0]["F_ESTIMATED"].ToString();
                        else return "";
                    case "Knowledge":
                        if (historyinfo.Rows[0]["F_KNOWLEDGE"] != null)
                        {
                            if (historyinfo.Rows[0]["F_KNOWLEDGE"].ToString() == "0")
                                return "是";
                            else return "否";
                        }
                        else return "";
                    case "ExamineType":
                        if (historyinfo.Rows[0]["F_EXAMINETYPE"] != null)
                        {
                            string zjjd = "";
                            if (!string.IsNullOrWhiteSpace(historyinfo.Rows[0]["F_EXAMINETYPE"].ToString()))
                                zjjd = "<tr style=\"height: 25px;\"><th style=\"height: 25px; padding: 0px 8px 0px 0px;\">直接结单说明：</th><td style=\"height: 25px; padding: 2px 0px 0px 8px;\" colspan=\"5\"><input type=\"text\" readonly class=\"txtInput normal\" style=\"width: 80%;\" value=\"" + historyinfo.Rows[0]["F_EXAMINETYPE"].ToString() + "\" /></td></tr>";
                            return zjjd;
                        }
                        else return "";
                    default:
                        return "";
                }
            }
            else return "";
        }
        protected string getFileExist(object hisid)
        {
            if (hisid != null)
            {
                List<Model.T_Wo_WorkOrderFiles> list =
                    new BLL.T_Wo_WorkOrderFiles().GetModelList("F_HOISTYID='" + hisid.ToString() + "'");
                if (list.Count > 0)
                {
                    string str = "";
                    foreach (Model.T_Wo_WorkOrderFiles tw in list)
                    {
                        str += "<a href=\"" + tw.F_PATH + "\">" + tw.F_NAME+ "</a><br/>";
                    }
                    return str;
                }
                else return "无附件";
            }
            else return "无附件";
        }
        protected string getWorkOrderBaseInfo(object instanceid, string type)
        {
            DataTable dt = new BLL.T_Wo_WorkOrderBase().GetList("F_INSTANCEID=" + instanceid.ToString()).Tables[0];
            if (dt.Rows.Count > 0)
            {
                switch (type)
                {
                    case "F_WORKORDERFROM":
                        if (dt.Rows[0]["F_WORKORDERFROM"] != null)
                            return dt.Rows[0]["F_WORKORDERFROM"].ToString();
                        else return "";
                    case "F_REPAIRMANNAME":
                        if (dt.Rows[0]["F_REPAIRMANNAME"] != null)
                            return dt.Rows[0]["F_REPAIRMANNAME"].ToString();
                        else return "";
                    case "F_REPAIRMANPHONE":
                        if (dt.Rows[0]["F_REPAIRMANPHONE"] != null)
                            return dt.Rows[0]["F_REPAIRMANPHONE"].ToString();
                        else return "";
                    case "F_REPAIRLEVELNAME":
                        if (dt.Rows[0]["F_REPAIRLEVELNAME"] != null)
                            return dt.Rows[0]["F_REPAIRLEVELNAME"].ToString();
                        else return "";
                    case "F_CONTENT":
                        if (dt.Rows[0]["F_CONTENT"] != null)
                            return dt.Rows[0]["F_CONTENT"].ToString();
                        else return "";
                    case "F_REPAIRREQUEST":
                        if (dt.Rows[0]["F_REPAIRREQUEST"] != null)
                            return dt.Rows[0]["F_REPAIRREQUEST"].ToString();
                        else return "";
                    case "F_CODE":
                        if (dt.Rows[0]["F_CODE"] != null)
                            return dt.Rows[0]["F_CODE"].ToString();
                        else return "";
                    case "F_STANDARDADDRESS":
                        if (dt.Rows[0]["F_STANDARDADDRESS"] != null)
                            return dt.Rows[0]["F_STANDARDADDRESS"].ToString();
                        else return "";
                    default:
                        return "";
                }
            }
            else return "";
        }
    }
}