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>"); } }
protected void Page_Load(object sender, EventArgs e) { try { var id = Request.QueryString["id"]; thisTask = new sdk_task_dal().FindNoDeleteById(long.Parse(id)); if (thisTask != null && thisTask.project_id != null) { thisBookMark = new IndexBLL().GetSingBook(Request.Url.LocalPath + "?id=" + id, LoginUserId); tvbDto.Add(new DictionaryEntryDto("type", "类型", 0)); tvbDto.Add(new DictionaryEntryDto("time", "操作时间", 0)); tvbDto.Add(new DictionaryEntryDto("resouName", "员工", 0)); tvbDto.Add(new DictionaryEntryDto("workHours", "实际工作时间", 0)); tvbDto.Add(new DictionaryEntryDto("notTiltle", "说明/标题", 0)); tvbDto.Add(new DictionaryEntryDto("billabled", "是否计费", 0)); tvbDto.Add(new DictionaryEntryDto("billed", "已计费", 0)); expDto.Add(new DictionaryEntryDto("type_id", "类型", 0)); expDto.Add(new DictionaryEntryDto("add_date", "费用日期", 0)); expDto.Add(new DictionaryEntryDto("create_user_id", "创建人", 0)); expDto.Add(new DictionaryEntryDto("expense_cost_code_id", "费用类别", 0)); expDto.Add(new DictionaryEntryDto("amount", "总额", 0)); expDto.Add(new DictionaryEntryDto("is_billable", "计费的", 0)); expDto.Add(new DictionaryEntryDto("approve_and_post_user_id", "已计费", 0)); v_task = new v_task_all_dal().FindById(thisTask.id); if (thisTask.type_id == (int)DicEnum.TASK_TYPE.PROJECT_ISSUE) { taskType = "问题"; } else if (thisTask.type_id == (int)DicEnum.TASK_TYPE.PROJECT_TASK) { taskType = "任务"; } else { Response.End(); } #region 记录浏览历史 var account = new CompanyBLL().GetCompany(thisTask.account_id); var history = new sys_windows_history() { title = $"查看{taskType}:" + (thisProject != null ? thisProject.name : "") + " " + thisTask.title + " " + (account != null ? account.name : ""), url = Request.RawUrl, }; new IndexBLL().BrowseHistory(history, LoginUserId); #endregion thisProject = new pro_project_dal().FindNoDeleteById((long)thisTask.project_id); if (thisProject != null) { thisAccount = new crm_account_dal().FindNoDeleteById(thisProject.account_id); if (thisProject.contract_id != null) { thisContract = new ctt_contract_dal().FindNoDeleteById((long)thisProject.contract_id); } } thisTaskResList = new sdk_task_resource_dal().GetTaskResByTaskId(thisTask.id); var roleList = dic.FirstOrDefault(_ => _.Key == "role").Value as List <sys_role>; var sysList = dic.FirstOrDefault(_ => _.Key == "sys_resource").Value as List <DictionaryEntryDto>; #region 工时备注附件 var tasEntryList = new sdk_work_entry_dal().GetByTaskId(thisTask.id); if (tasEntryList != null && tasEntryList.Count > 0) { var newList = (from a in tasEntryList join b in roleList on a.role_id equals b.id join c in sysList on a.resource_id equals long.Parse(c.val) select new TaskViewDto { id = a.id, type = "entry", time = Tools.Date.DateHelper.ConvertStringToDateTime((long)(a.end_time ?? a.start_time)), resouName = c.show + "(" + b.name + ")", workHours = a.hours_worked, notTiltle = a.summary_notes, billabled = a.is_billable == 1?"✓":"", billed = a.approve_and_post_date == null?"": "✓", startDate = Tools.Date.DateHelper.ConvertStringToDateTime((long)a.start_time), workTypeId = a.cost_code_id, contractId = a.contract_id, showOnInv = a.show_on_invoice == 1, serviceId = a.service_id }).ToList(); tvdList.AddRange(newList); } var conAttDal = new com_attachment_dal(); var allTaskAttList = new List <com_attachment>(); var taskNoteList = new com_activity_dal().GetActiList($" and (task_id ={thisTask.id} or object_id={thisTask.id} )"); if (taskNoteList != null && taskNoteList.Count > 0) { var newList = (from a in taskNoteList join c in sysList on a.resource_id equals long.Parse(c.val) into temp from tt in temp.DefaultIfEmpty() select new TaskViewDto { id = a.id, type = "note", time = Tools.Date.DateHelper.ConvertStringToDateTime(a.create_time), resouName = tt == null ? "" : tt.show, notTiltle = a.name, noteDescr = a.description }).ToList(); tvdList.AddRange(newList); foreach (var thisTaskNote in taskNoteList) { var thisNoteAttList = conAttDal.GetAttListByOid(thisTaskNote.id); if (thisNoteAttList != null && thisNoteAttList.Count > 0) { allTaskAttList.AddRange(thisNoteAttList); } } } var taskAttList = conAttDal.GetAttListByOid(thisTask.id); if (taskAttList != null && taskAttList.Count > 0) { allTaskAttList.AddRange(taskAttList); } if (allTaskAttList.Count > 0) { var newList = (from a in allTaskAttList join c in sysList on a.create_user_id equals long.Parse(c.val) into temp from tt in temp.DefaultIfEmpty() select new TaskViewDto { id = a.id, type = "atach", time = Tools.Date.DateHelper.ConvertStringToDateTime(a.create_time), resouName = tt == null?"":tt.show, notTiltle = a.title, fileType = a.type_id }).ToList(); tvdList.AddRange(newList); } if (tvdList != null && tvdList.Count > 0) { tvbOrder = Request.QueryString["tvbOrder"]; tvdList = tvdList.OrderBy(_ => _.time).ToList(); if (!string.IsNullOrEmpty(tvbOrder)) { var tvbOrderArr = tvbOrder.Split(new char[] { '_' }, StringSplitOptions.RemoveEmptyEntries); var orderFile = tvbDto.FirstOrDefault(_ => _.val == tvbOrderArr[0]); if (tvbOrderArr[1] == "desc") { //tvdList = (from a in tvdList // orderby tvbOrderArr[0] descending // select a).ToList(); tvdList.Sort(delegate(TaskViewDto t1, TaskViewDto t2) { return(GetObjectPropertyValue(t2, tvbOrderArr[0]).CompareTo(GetObjectPropertyValue(t1, tvbOrderArr[0]))); }); orderFile.select = orderFile != null ? 2 : orderFile.select; } else { //tvdList = (from a in tvdList // orderby tvbOrderArr[0] // select a).ToList(); tvdList.Sort(delegate(TaskViewDto t1, TaskViewDto t2) { return(GetObjectPropertyValue(t1, tvbOrderArr[0]).CompareTo(GetObjectPropertyValue(t2, tvbOrderArr[0]))); }); orderFile.select = orderFile != null ? 1 : orderFile.select; } } } #endregion #region 费用 taskExpList = new sdk_expense_dal().GetExpByTaskId(thisTask.id); if (taskExpList != null && taskExpList.Count > 0) { taskExpList = taskExpList.OrderByDescending(_ => _.add_date).ToList(); expOrder = Request.QueryString["expOrder"]; if (!string.IsNullOrEmpty(expOrder)) { var expOrderArr = expOrder.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries); var orderFile = expDto.FirstOrDefault(_ => _.val == expOrderArr[0]); if (expOrderArr[1] == "desc") { //taskExpList = (from a in taskExpList // orderby expOrderArr[0] descending // select a).ToList(); taskExpList.Sort(delegate(sdk_expense t1, sdk_expense t2) { return(GetObjectPropertyValue(t2, expOrderArr[0]).CompareTo(GetObjectPropertyValue(t1, expOrderArr[0]))); }); orderFile.select = orderFile != null ? 2 : orderFile.select; } else { //taskExpList = (from a in taskExpList // orderby expOrderArr[0] // select a).ToList(); taskExpList.Sort(delegate(sdk_expense t1, sdk_expense t2) { return(GetObjectPropertyValue(t1, expOrderArr[0]).CompareTo(GetObjectPropertyValue(t2, expOrderArr[0]))); }); orderFile.select = orderFile != null ? 1 : orderFile.select; } } } #endregion } else { Response.End(); } } catch (Exception msg) { Response.End(); } }