Esempio n. 1
0
        private ServiceCallDto GetParam()
        {
            var param      = new ServiceCallDto();
            var pageTicket = AssembleModel <sdk_task>();
            var startTime  = Request.Form["startTime"];
            var endTime    = Request.Form["endTime"];

            if (string.IsNullOrEmpty(startTime) || string.IsNullOrEmpty(endTime))
            {
                return(null);
            }
            pageTicket.estimated_begin_time = Tools.Date.DateHelper.ToUniversalTimeStamp(DateTime.Parse(startTime));
            pageTicket.estimated_end_time   = Tools.Date.DateHelper.ToUniversalTimeStamp(DateTime.Parse(endTime));
            param.thisTicket = pageTicket;

            var call = new sdk_service_call();

            call.start_time  = (long)pageTicket.estimated_begin_time;
            call.end_time    = (long)pageTicket.estimated_end_time;
            call.status_id   = (int)DicEnum.SERVICE_CALL_STATUS.NEW;
            call.account_id  = pageTicket.account_id;
            call.description = pageTicket.description;
            param.call       = call;
            if (tickUdfList != null && tickUdfList.Count > 0)
            {
                var list = new List <UserDefinedFieldValue>();
                foreach (var udf in tickUdfList)                            // 循环添加
                {
                    var new_udf = new UserDefinedFieldValue()
                    {
                        id    = udf.id,
                        value = string.IsNullOrEmpty(Request.Form[udf.id.ToString()]) ? null : Request.Form[udf.id.ToString()],
                    };
                    list.Add(new_udf);
                }
                param.udfList = list;
            }
            var OtherResId = Request.Form["OtherResId"];

            if (!string.IsNullOrEmpty(OtherResId))
            {
                param.resIds = new DispatchBLL().GetResByResDep(OtherResId);
            }
            return(param);
        }
Esempio n. 2
0
        protected bool noTime = false;      // 可以不输入开始结束时间(根据系统设置进行判断)
        protected void Page_Load(object sender, EventArgs e)
        {
            try
            {
                //  是否需要输入开始结束时间
                var isNeedTimeString = Request.QueryString["NoTime"];
                var noTimeSet        = new SysSettingBLL().GetSetById(SysSettingEnum.SDK_ENTRY_REQUIRED);
                if (!string.IsNullOrEmpty(isNeedTimeString))
                {
                    if (noTimeSet != null && noTimeSet.setting_value == "0")
                    {
                        noTime = true;
                    }
                }
                var callId = Request.QueryString["callId"];
                if (!string.IsNullOrEmpty(callId))
                {
                    thisCall = new sdk_service_call_dal().FindNoDeleteById(long.Parse(callId));
                }
                thisUser = new sys_resource_dal().FindNoDeleteById(GetLoginUserId());
                var resList = dic.FirstOrDefault(_ => _.Key == "sys_resource").Value as List <DictionaryEntryDto>;
                if (!IsPostBack)
                {
                    resource_id.DataTextField  = "show";
                    resource_id.DataValueField = "val";
                    var  entryProxySet = new SysSettingBLL().GetValueById(SysSettingEnum.SDK_ENTRY_PROXY);
                    bool isAgent       = false;
                    if (entryProxySet == ((int)DicEnum.PROXY_TIME_ENTRY.DISABLED).ToString())
                    {
                        if (resList != null && resList.Count > 0)
                        {
                            resList = resList.Where(_ => _.val == LoginUserId.ToString()).ToList();
                        }
                    }
                    else
                    {
                        var agentResList = new UserResourceBLL().GetAgentUser(LoginUserId, out isAgent);
                        if (agentResList != null && agentResList.Count > 0)
                        {
                            resList = (from a in agentResList
                                       select new DictionaryEntryDto()
                            {
                                val = a.id.ToString(), show = a.name
                            }).ToList();
                        }
                    }
                    resource_id.DataSource    = resList;
                    resource_id.SelectedValue = LoginUserId.ToString();
                    resource_id.DataBind();

                    var statusList = dic.FirstOrDefault(_ => _.Key == "ticket_status").Value as List <DictionaryEntryDto>;
                    //statusList.Remove(statusList.FirstOrDefault(_=>_.val==((int)DicEnum.TICKET_STATUS.NEW).ToString()));
                    status_id.DataTextField  = "show";
                    status_id.DataValueField = "val";
                    status_id.DataSource     = statusList;
                    status_id.DataBind();


                    cost_code_id.DataTextField  = "name";
                    cost_code_id.DataValueField = "id";
                    cost_code_id.DataSource     = new d_cost_code_dal().GetCostCodeByWhere((int)DicEnum.COST_CODE_CATE.GENERAL_ALLOCATION_CODE);
                    cost_code_id.DataBind();

                    notify_id.DataTextField  = "name";
                    notify_id.DataValueField = "id";
                    notify_id.DataSource     = new sys_notify_tmpl_dal().GetTempByEvent(DicEnum.NOTIFY_EVENT.TICKET_TIME_ENTRY_CREATED_EDITED);
                    notify_id.DataBind();
                }

                var taskId = Request.QueryString["task_id"];
                if (!string.IsNullOrEmpty(taskId))
                {
                    thisTask = new sdk_task_dal().FindNoDeleteById(long.Parse(taskId));
                }

                var id = Request.QueryString["id"];
                if (!string.IsNullOrEmpty(id))
                {
                    thisWorkEntry = new sdk_work_entry_dal().FindNoDeleteById(long.Parse(id));
                    if (thisWorkEntry != null)
                    {
                        if (thisWorkEntry.approve_and_post_date != null || thisWorkEntry.approve_and_post_user_id != null)
                        {
                            Response.Write("<script>alert('审批提交的工时不可以更改!');window.close();</script>");
                            Response.End();
                        }

                        if (!resList.Any(_ => _.val == thisWorkEntry.create_user_id.ToString()))
                        {
                            Response.Write("<script>alert('系统设置不能代理操作!');window.close();</script>");
                            return;
                        }
                        if (thisWorkEntry.end_time == null && noTimeSet != null && noTimeSet.setting_value == "0")
                        {
                            noTime = true;
                        }
                        entryList = new sdk_work_entry_dal().GetBatchList(thisWorkEntry.batch_id);
                        isAdd     = false;
                        thisTask  = new sdk_task_dal().FindNoDeleteById(thisWorkEntry.task_id);
                        if (!IsPostBack)
                        {
                            resource_id.ClearSelection();
                            resource_id.SelectedValue  = ((long)thisWorkEntry.resource_id).ToString();
                            cost_code_id.SelectedValue = ((long)thisWorkEntry.cost_code_id).ToString();
                            // status_id.SelectedValue = ((long)thisWorkEntry.)
                            // thisTask  = new crm_account_dal().FindNoDeleteById(thisWorkEntry.);
                        }

                        if (thisWorkEntry.contract_id != null)
                        {
                            thisContract = new ctt_contract_dal().FindNoDeleteById((long)thisWorkEntry.contract_id);
                        }
                        if (!IsPostBack)
                        {
                            isBilled.Checked  = thisWorkEntry.is_billable == 0;
                            ShowOnInv.Checked = thisWorkEntry.show_on_invoice == 1;
                            if (isBilled.Checked)
                            {
                                ShowOnInv.Enabled = true;
                            }
                        }
                    }
                    else
                    {
                        Response.Write("<script>alert('工时已被删除!')window.close();</script>");
                        Response.End();
                    }
                }
                #region 根据批次获取相关工时
                //var batchId = Request.QueryString["batchId"];
                //if (!string.IsNullOrEmpty(batchId))
                //{
                //    entryList = new sdk_work_entry_dal().GetBatchList(long.Parse(batchId));
                //    if(entryList!=null&& entryList.Count > 0)
                //    {
                //        thisWorkEntry = entryList[0];
                //        if (thisWorkEntry.approve_and_post_date != null || thisWorkEntry.approve_and_post_user_id != null)
                //        {
                //            Response.Write("<script>alert('审批提交的工时不可以更改!');window.close();</script>");
                //            Response.End();
                //        }

                //        if (!resList.Any(_ => _.val == thisWorkEntry.create_user_id.ToString()))
                //        {
                //            Response.Write("<script>alert('系统设置不能代理操作!')window.close();</script>");
                //            Response.End();
                //        }
                //        if (thisWorkEntry.end_time == null && noTimeSet != null && noTimeSet.setting_value == "0")
                //        {
                //            noTime = true;
                //        }
                //        entryList = new sdk_work_entry_dal().GetBatchList(thisWorkEntry.batch_id);
                //        isAdd = false;
                //        thisTask = new sdk_task_dal().FindNoDeleteById(thisWorkEntry.task_id);
                //        if (!IsPostBack)
                //        {
                //            resource_id.SelectedValue = ((long)thisWorkEntry.resource_id).ToString();
                //            cost_code_id.SelectedValue = ((long)thisWorkEntry.cost_code_id).ToString();
                //            // status_id.SelectedValue = ((long)thisWorkEntry.)
                //            // thisTask  = new crm_account_dal().FindNoDeleteById(thisWorkEntry.);

                //        }

                //        if (thisWorkEntry.contract_id != null)
                //        {
                //            thisContract = new ctt_contract_dal().FindNoDeleteById((long)thisWorkEntry.contract_id);
                //        }
                //        if (!IsPostBack)
                //        {
                //            isBilled.Checked = thisWorkEntry.is_billable == 0;
                //            ShowOnInv.Checked = thisWorkEntry.show_on_invoice == 1;
                //            if (isBilled.Checked)
                //            {
                //                ShowOnInv.Enabled = true;
                //            }
                //        }
                //    }
                //}
                #endregion
                if (thisTask != null)
                {
                    v_task      = new v_task_all_dal().FindById(thisTask.id);
                    thisProjetc = new pro_project_dal().FindNoDeleteById((long)thisTask.project_id);
                    if (thisProjetc != null)
                    {
                        thisAccount = new crm_account_dal().FindNoDeleteById(thisProjetc.account_id);
                        if (!IsPostBack)
                        {
                            status_id.SelectedValue = thisTask.status_id.ToString();
                        }
                    }
                }
                // 项目关联合同,并且合同中设置-工时录入需要输入开始结束时间
                if (thisProjetc != null && thisProjetc.contract_id != null)
                {
                    var thisCttContract = new ctt_contract_dal().FindNoDeleteById((long)thisProjetc.contract_id);
                    if (thisCttContract != null)
                    {
                        if (thisCttContract.timeentry_need_begin_end == 1)
                        {
                            noTime = false;
                        }
                    }
                }

                if (thisCall != null)
                {
                    showStartDate = EMT.Tools.Date.DateHelper.ConvertStringToDateTime(thisCall.start_time);
                    showEndDate   = EMT.Tools.Date.DateHelper.ConvertStringToDateTime(thisCall.end_time);
                }
                if (!string.IsNullOrEmpty(Request.QueryString["chooseDate"]))
                {
                    showStartDate = DateTime.Parse(Request.QueryString["chooseDate"]);
                    showEndDate   = DateTime.Parse(Request.QueryString["chooseDate"]);
                }
            }
            catch (Exception msg)
            {
                Response.Write($"<script>alert('{msg.Message}');window.close();</script>");
            }
        }
Esempio n. 3
0
        protected void Page_Load(object sender, EventArgs e)
        {
            try
            {
                showResList = new UserResourceBLL().GetAgentUser(LoginUserId, out isAllowAgentRes);

                isComplete = !string.IsNullOrEmpty(Request.QueryString["is_complete"]);
                if (!IsPostBack)
                {
                    GetPageDataBind();
                }
                var ticket_id = Request.QueryString["ticket_id"];
                if (!string.IsNullOrEmpty(ticket_id))
                {
                    thisTicket = new sdk_task_dal().FindNoDeleteById(long.Parse(ticket_id));
                    if (thisTicket != null)
                    {
                        if (thisTicket.contact_id != null)
                        {
                            thisContract = new ctt_contract_dal().FindNoDeleteById((long)thisTicket.contract_id);
                        }
                        if (thisTicket.cost_code_id != null)
                        {
                            cost_code_id.SelectedValue = thisTicket.cost_code_id.ToString();
                        }
                    }
                }
                var service_id = Request.QueryString["service_id"];
                if (!string.IsNullOrEmpty(service_id))
                {
                    thisCall = new sdk_service_call_dal().FindNoDeleteById(long.Parse(service_id));
                }
                var id = Request.QueryString["id"];
                if (!string.IsNullOrEmpty(id))
                {
                    ticketLabour = new sdk_work_entry_dal().FindNoDeleteById(long.Parse(id));
                    if (ticketLabour != null)
                    {
                        isAdd      = false;
                        thisTicket = new sdk_task_dal().FindNoDeleteById(ticketLabour.task_id);
                        if (ticketLabour.resource_id != null)
                        {
                            resource_id.SelectedValue = ((long)ticketLabour.resource_id).ToString();
                        }
                        if (ticketLabour.cost_code_id != null)
                        {
                            cost_code_id.ClearSelection();
                            cost_code_id.SelectedValue = ticketLabour.cost_code_id.ToString();
                        }
                        if (ticketLabour.role_id != null)
                        {
                            role_id.SelectedValue = ticketLabour.role_id.ToString();
                        }
                        if (ticketLabour.contract_id != null)
                        {
                            thisContract = new ctt_contract_dal().FindNoDeleteById((long)ticketLabour.contract_id);
                        }
                    }
                }

                if (thisTicket != null)
                {
                    thisAccount = new CompanyBLL().GetCompany(thisTicket.account_id);
                    if (!isComplete)
                    {
                        status_id.SelectedValue = (thisTicket.status_id).ToString();
                    }
                    else
                    {
                        status_id.SelectedValue = ((int)DicEnum.TICKET_STATUS.DONE).ToString();
                    }
                }
                else
                {
                    Response.Write("<script>alert('未查询到该工单信息!');window.close();</script>");
                }

                if (thisAccount != null)
                {
                    accAlert = new crm_account_alert_dal().FindAlert(thisAccount.id, DicEnum.ACCOUNT_ALERT_TYPE.COMPANY_DETAIL_ALERT);
                }
            }
            catch (Exception msg)
            {
                Response.Write("<script>alert('" + msg.Message + "');window.close();</script>");
            }
        }
Esempio n. 4
0
 protected void Page_Load(object sender, EventArgs e)
 {
     try
     {
         thisBookMark = new IndexBLL().GetSingBook(Request.RawUrl, LoginUserId);
         var callId   = Request.QueryString["callId"];
         var tickeTId = Request.QueryString["ticketId"];
         if (!string.IsNullOrEmpty(callId))
         {
             thisCall = new sdk_service_call_dal().FindNoDeleteById(long.Parse(callId));
         }
         if (!string.IsNullOrEmpty(tickeTId))
         {
             thisTicket = new sdk_task_dal().FindNoDeleteById(long.Parse(tickeTId));
         }
         if (thisTicket != null)
         {
             thisAccount = new CompanyBLL().GetCompany(thisTicket.account_id);
             if (thisTicket.contact_id != null)
             {
                 ticketCon = new crm_contact_dal().FindNoDeleteById((long)thisTicket.contact_id);
             }
             resList = new List <sys_resource>();
             var srDal = new sys_resource_dal();
             if (thisTicket.owner_resource_id != null)
             {
                 var priRes = srDal.FindNoDeleteById((long)thisTicket.owner_resource_id);
                 if (priRes != null)
                 {
                     resList.Add(priRes);
                 }
             }
             var other = srDal.GetResByTicket(thisTicket.id);
             if (other != null && other.Count > 0)
             {
                 resList.AddRange(other);
             }
         }
         if (thisCall != null && thisTicket != null)
         {
             thisCallTask = new sdk_service_call_task_dal().GetSingTaskCall(thisCall.id, thisTicket.id);
             thisAccount  = new CompanyBLL().GetCompany(thisCall.account_id);
         }
         var callTaskId = Request.Form["id"];
         if (!string.IsNullOrEmpty(callTaskId))
         {
             thisCallTask = new sdk_service_call_task_dal().FindNoDeleteById(long.Parse(callTaskId));
         }
         if (thisCallTask != null)
         {
             isAdd       = false;
             serResList  = new sdk_service_call_task_resource_dal().GetTaskResList(thisCallTask.id);
             callCreater = new sys_resource_dal().FindNoDeleteById(thisCallTask.id);
         }
         var timeNow = Tools.Date.DateHelper.ToUniversalTimeStamp(DateTime.Now);
         if (thisAccount != null)
         {
             if (thisAccount.resource_id != null)
             {
                 accMan = new sys_resource_dal().FindNoDeleteById((long)thisAccount.resource_id);
             }
             accCallList = new sdk_service_call_dal().GetCallByAccount(thisAccount.id);
             if (accCallList != null && accCallList.Count > 0)
             {
                 pageCallList = (from a in accCallList
                                 join b in statusList on a.status_id equals b.id
                                 select new CallDto {
                     id = a.id, startDate = EMT.Tools.Date.DateHelper.ConvertStringToDateTime(a.start_time).ToString("yyyy-MM-dd HH:mm"), endDate = EMT.Tools.Date.DateHelper.ConvertStringToDateTime(a.end_time).ToString("yyyy-MM-dd HH:mm"), statusId = a.status_id, statusName = b.name, isLimtThri = (timeNow - a.start_time) > (2592000000)
                 }).ToList();
                 // 2592000000 = 30 * 24 * 60 * 60 * 1000  30天的毫秒数
             }
         }
         else
         {
             Response.Write($"<script>alert('为获取到相关客户信息,请重新打开!');window.close();</script>");
             return;
         }
     }
     catch (Exception msg)
     {
         Response.Write($"<script>alert('{msg.Message}!');window.close();</script>");
     }
 }
Esempio n. 5
0
        protected void Page_Load(object sender, EventArgs e)
        {
            thisBookMark = new IndexBLL().GetSingBook(Request.RawUrl, LoginUserId);
            var id     = Request.QueryString["id"];
            var isCopy = Request.QueryString["copy"];

            if (!string.IsNullOrEmpty(id))
            {
                thisCall = new sdk_service_call_dal().FindNoDeleteById(long.Parse(id));
            }
            if (thisCall != null)
            {
                if (!string.IsNullOrEmpty(isCopy))
                {
                    isCop = true;
                }
                else
                {
                    isAdd = false;
                }
                thisAccount = new CompanyBLL().GetCompany(thisCall.account_id);
                taskSerList = new sdk_service_call_task_dal().GetTaskCall(thisCall.id);
                if (taskSerList != null && taskSerList.Count > 0)
                {
                    taskSerList.ForEach(_ => {
                        ticketIds += _.task_id.ToString() + ',';
                    });
                    if (!string.IsNullOrEmpty(ticketIds))
                    {
                        ticketIds = ticketIds.Substring(0, ticketIds.Length - 1);
                    }
                }
                if (!isAdd)
                {
                    #region 记录浏览历史
                    var history = new sys_windows_history()
                    {
                        title = "服务预定:" + Tools.Date.DateHelper.ConvertStringToDateTime(thisCall.start_time).ToString("yyyy-MM-dd HH:mm") + "~" + Tools.Date.DateHelper.ConvertStringToDateTime(thisCall.end_time).ToString("yyyy-MM-dd HH:mm") + thisAccount.name,
                        url   = Request.RawUrl,
                    };
                    new IndexBLL().BrowseHistory(history, LoginUserId);
                    #endregion
                }
            }

            if (!IsPostBack)
            {
            }
            else
            {
                var param = GetParam();
                if (param != null)
                {
                    bool result = false;
                    if (isAdd)
                    {
                        result = new TicketBLL().AddServiceCall(param, LoginUserId);
                    }
                    else
                    {
                        result = new TicketBLL().EditServiceCall(param, LoginUserId);
                    }
                    ClientScript.RegisterStartupScript(this.GetType(), "刷新父页面", $"<script>self.opener.location.reload();</script>");
                    ClientScript.RegisterStartupScript(this.GetType(), "提示信息", $"<script>alert('保存{(result ? "成功" : "失败")}!');</script>");
                    var saveType = Request.Form["SaveType"];
                    if (saveType == "save_close")
                    {
                        ClientScript.RegisterStartupScript(this.GetType(), "关闭窗口", $"<script>window.close();</script>");
                    }
                    else if (saveType == "save_new")
                    {
                        ClientScript.RegisterStartupScript(this.GetType(), "跳转", $"<script>location.href='ServiceCall';</script>");
                    }
                    else if (saveType == "work_book")  // todo 跳转到生成工作说明书界面
                    {
                        ClientScript.RegisterStartupScript(this.GetType(), "关闭窗口", $"<script>window.close();</script>");
                    }
                    else
                    {
                        ClientScript.RegisterStartupScript(this.GetType(), "跳转到编辑页面", $"<script>location.href='ServiceCall?id={param.call.id.ToString()}';</script>");
                    }
                }
                else
                {
                    ClientScript.RegisterStartupScript(this.GetType(), "提示", $"<script>alert('必填项丢失,请重新填写!');</script>");
                }
            }
        }
Esempio n. 6
0
        protected void Page_Load(object sender, EventArgs e)
        {
            try
            {
                thisUser = new sys_resource_dal().FindNoDeleteById(GetLoginUserId());
                var caDal  = new com_activity_dal();
                var stDal  = new sdk_task_dal();
                var ppDal  = new pro_project_dal();
                var accDal = new crm_account_dal();
                var ccDal  = new ctt_contract_dal();
                var id     = Request.QueryString["id"];
                if (!string.IsNullOrEmpty(id))
                {
                    thisNote = caDal.FindNoDeleteById(long.Parse(id));
                    if (thisNote != null)
                    {
                        isAdd = false;

                        thisNoteAtt = new com_attachment_dal().GetAttListByOid(thisNote.id);

                        thisTask = stDal.FindNoDeleteById(thisNote.object_id);
                        if (thisTask != null)
                        {
                            object_id = thisTask.id;
                            if (thisTask.type_id == (int)DicEnum.TASK_TYPE.SERVICE_DESK_TICKET)
                            {
                                isTicket   = true;
                                thisTask   = null;
                                thisTicket = stDal.FindNoDeleteById(thisNote.object_id);
                            }
                        }
                        else
                        {
                            thisProject = ppDal.FindNoDeleteById(thisNote.object_id);
                            if (thisProject != null)
                            {
                                isProject   = true;
                                object_id   = thisProject.id;
                                thisAccount = accDal.FindNoDeleteById(thisProject.account_id);
                            }
                            else
                            {
                                thisContract = ccDal.FindNoDeleteById(thisNote.object_id);
                                if (thisContract != null)
                                {
                                    isContract  = true;
                                    object_id   = thisContract.id;
                                    thisAccount = accDal.FindNoDeleteById(thisContract.account_id);
                                }
                            }
                        }
                    }
                }
                var taskId      = Request.QueryString["task_id"];
                var project_id  = Request.QueryString["project_id"];
                var contract_id = Request.QueryString["contract_id"];
                var ticket_id   = Request.QueryString["ticket_id"];
                var call_id     = Request.QueryString["call_id"];
                if (!string.IsNullOrEmpty(taskId))
                {
                    thisTask = stDal.FindNoDeleteById(long.Parse(taskId));
                }
                else if (!string.IsNullOrEmpty(project_id))
                {
                    thisProject = ppDal.FindNoDeleteById(long.Parse(project_id));
                    if (thisProject != null)
                    {
                        isProject   = true;
                        object_id   = thisProject.id;
                        thisAccount = accDal.FindNoDeleteById(thisProject.account_id);
                    }
                }
                else if (!string.IsNullOrEmpty(contract_id))
                {
                    thisContract = ccDal.FindNoDeleteById(long.Parse(contract_id));
                    if (thisContract != null)
                    {
                        object_id   = thisContract.id;
                        thisAccount = accDal.FindNoDeleteById(thisContract.account_id);
                        isContract  = true;
                    }
                }
                else if (!string.IsNullOrEmpty(ticket_id))
                {
                    thisTicket = stDal.FindNoDeleteById(long.Parse(ticket_id));
                }
                else if (!string.IsNullOrEmpty(call_id))
                {
                    thisCall = new sdk_service_call_dal().FindNoDeleteById(long.Parse(call_id));
                    if (thisCall != null)
                    {
                        isCall         = true;
                        thisAccount    = new CompanyBLL().GetCompany(thisCall.account_id);
                        callTicketList = stDal.GetTciketByCall(thisCall.id);
                        if (callTicketList != null && callTicketList.Count > 0)
                        {
                            thisTask = callTicketList[0];
                            if (callTicketList.Any(_ => _.id != thisTask.id && _.status_id != thisTask.status_id))
                            {
                                isMantStatus = true;
                            }
                            if (callTicketList.Any(_ => _.id != thisTask.id && _.account_id != thisTask.account_id))
                            {
                                isManyAccount = true;
                            }
                            if (callTicketList.Any(_ => _.id != thisTask.id && _.title != thisTask.title))
                            {
                                isManyTitle = true;
                            }
                        }
                        else
                        {
                            Response.Write("<script>alert('服务预定下暂无工单!');window.close();</script>");
                            return;
                        }
                    }
                }


                if (thisTask != null)
                {
                    thisAccount = accDal.FindNoDeleteById(thisTask.account_id);
                    object_id   = thisTask.id;
                    if (thisTask.type_id == (int)DicEnum.TASK_TYPE.PROJECT_PHASE)
                    {
                        isPhase = true;
                    }
                    task_creator = new sys_resource_dal().FindNoDeleteById(thisTask.create_user_id);
                    if (thisTask.project_id != null)
                    {
                        thisProject = ppDal.FindNoDeleteById((long)thisTask.project_id);
                        if (thisProject != null)
                        {
                            thisAccount = accDal.FindNoDeleteById(thisProject.account_id);
                        }
                    }
                }
                if (thisTicket != null)
                {
                    isTicket     = true;
                    object_id    = thisTicket.id;
                    task_creator = new sys_resource_dal().FindNoDeleteById(thisTicket.create_user_id);
                    thisAccount  = accDal.FindNoDeleteById(thisTicket.account_id);
                    if (thisTicket.contact_id != null)
                    {
                        thisContact = new crm_contact_dal().FindNoDeleteById((long)thisTicket.contact_id);
                    }
                }
                if (thisAccount == null)
                {
                    Response.End();
                }
                else
                {
                    if (thisAccount.resource_id != null)
                    {
                        thisAccManger = new sys_resource_dal().FindNoDeleteById((long)thisAccount.resource_id);
                    }
                }
                if (!IsPostBack)
                {
                    publish_type_id.DataTextField  = "name";
                    publish_type_id.DataValueField = "id";
                    var pushList = new d_general_dal().GetGeneralByTableId((int)GeneralTableEnum.NOTE_PUBLISH_TYPE);
                    if (pushList != null && pushList.Count > 0)
                    {
                        if (isProject)
                        {
                            pushList = pushList.Where(_ => _.ext2 == ((int)DicEnum.ACTIVITY_CATE.PROJECT_NOTE).ToString()).ToList();
                        }
                        else if (isContract)
                        {
                            pushList = pushList.Where(_ => _.ext2 == ((int)DicEnum.ACTIVITY_CATE.CONTRACT_NOTE).ToString()).ToList();
                        }
                        else if (isTicket)
                        {
                            pushList = pushList.Where(_ => _.ext2 == ((int)DicEnum.ACTIVITY_CATE.TASK_NOTE).ToString()).ToList();
                        }
                        else
                        {
                            pushList = pushList.Where(_ => _.ext2 == ((int)DicEnum.ACTIVITY_CATE.TASK_NOTE).ToString()).ToList();
                        }
                    }
                    publish_type_id.DataSource = pushList;
                    publish_type_id.DataBind();

                    status_id.DataTextField  = "show";
                    status_id.DataValueField = "val";
                    var statusList = dic.FirstOrDefault(_ => _.Key == "ticket_status").Value as List <DictionaryEntryDto>;
                    if (isMantStatus)
                    {
                        statusList.Add(new DictionaryEntryDto()
                        {
                            val = "0", show = "多个值,保持不变"
                        });
                    }
                    status_id.DataSource = statusList;
                    status_id.DataBind();
                    if (isMantStatus)
                    {
                        status_id.SelectedValue = "0";
                    }
                    else if (thisTask != null)
                    {
                        status_id.SelectedValue = thisTask.status_id.ToString();
                    }
                    else if (thisTicket != null)
                    {
                        status_id.SelectedValue = thisTicket.status_id.ToString();
                    }
                    action_type_id.DataTextField  = "name";
                    action_type_id.DataValueField = "id";
                    var actList = new d_general_dal().GetGeneralByTableId((int)GeneralTableEnum.ACTION_TYPE);
                    if (actList != null && actList.Count > 0)
                    {
                        if (isProject)
                        {
                            actList = actList.Where(_ => _.ext2 == ((int)DicEnum.ACTIVITY_CATE.PROJECT_NOTE).ToString()).ToList();
                        }
                        else if (isContract)
                        {
                            actList = actList.Where(_ => _.ext2 == ((int)DicEnum.ACTIVITY_CATE.CONTRACT_NOTE).ToString()).ToList();
                        }
                        else if (isTicket)
                        {
                            actList = actList.Where(_ => _.ext2 == ((int)DicEnum.ACTIVITY_CATE.TASK_NOTE).ToString()).ToList();
                        }
                        else
                        {
                            actList = actList.Where(_ => _.ext2 == ((int)DicEnum.ACTIVITY_CATE.TASK_NOTE).ToString()).ToList();
                        }
                    }
                    action_type_id.DataSource = actList;
                    action_type_id.DataBind();
                    if (thisNote != null)
                    {
                        if (!IsPostBack)
                        {
                            if (thisNote.publish_type_id != null)
                            {
                                publish_type_id.SelectedValue = thisNote.publish_type_id.ToString();
                            }
                            action_type_id.SelectedValue = thisNote.action_type_id.ToString();
                            isAnnounce.Checked           = thisNote.announce == 1;
                        }
                    }
                    else
                    {
                        if (isContract)
                        {
                            publish_type_id.SelectedValue = ((int)DicEnum.NOTE_PUBLISH_TYPE.CONTRACT_INTERNA_USER).ToString();
                        }
                    }

                    var tempList = new sys_notify_tmpl_dal().GetTempByEvent(DicEnum.NOTIFY_EVENT.NONE);
                    notify_id.DataTextField  = "name";
                    notify_id.DataValueField = "id";
                    notify_id.DataSource     = tempList;
                    notify_id.DataBind();
                }

                if (isProject)
                {
                    tmplList = new FormTemplateBLL().GetTmplByType((int)DicEnum.FORM_TMPL_TYPE.PROJECT_NOTE, LoginUserId);
                }
                else if (isTicket && thisTicket != null)
                {
                    tmplList = new FormTemplateBLL().GetTmplByType((int)DicEnum.FORM_TMPL_TYPE.TICKET_NOTE, LoginUserId);
                }
                else if (thisTask != null)
                {
                    tmplList = new FormTemplateBLL().GetTmplByType((int)DicEnum.FORM_TMPL_TYPE.TASK_NOTE, LoginUserId);
                }
            }
            catch (Exception msg)
            {
                Response.Write(msg);
                Response.End();
            }
        }