// 初始化自定义字段值 private void InitValue(string colName) { var bll = new UserDefinedFieldsBLL(); var udfList = bll.GetUdf(DTO.DicEnum.UDF_CATE.CONTRACTS); udf = udfList.First(f => f.name.Equals(colName)); var udfValues = bll.GetUdfValue(DTO.DicEnum.UDF_CATE.CONTRACTS, contractId, udfList); udfValue = udfValues.First(v => v.id == udf.id).value; id.Value = udf.id.ToString(); contract_id.Value = contractId.ToString(); }
protected void Page_Load(object sender, EventArgs e) { var accountId = Request.QueryString["accountId"]; if (!string.IsNullOrEmpty(accountId)) { account = comBll.GetCompany(long.Parse(accountId)); } if (account == null) { Response.Write("<script>alert('为获取到客户信息');window.close();</script>"); return; } accLocation = new crm_location_dal().GetLocationByAccountId(account.id); if (accLocation != null) { var disDal = new d_district_dal(); if (accLocation.country_id != null) { var country = new DAL.d_country_dal().FindById((long)accLocation.country_id); countryName = country != null?country.country_name_display:""; } var province = disDal.FindById((long)accLocation.province_id); provinceName = province != null ? province.name : ""; var city = disDal.FindById((long)accLocation.city_id); cityName = city != null ? city.name : ""; var district = disDal.FindById((long)accLocation.district_id); districtName = district != null ? district.name : ""; } subAccountList = new crm_account_dal().GetSubsidiariesById(account.id); contactList = new crm_contact_dal().GetContactByAccountId(account.id); oppoList = new crm_opportunity_dal().FindOpHistoryByAccountId(account.id); companyUdfList = udfBLL.GetUdf(DicEnum.UDF_CATE.COMPANY); companyUdfValueList = udfBLL.GetUdfValue(DicEnum.UDF_CATE.COMPANY, account.id, companyUdfList); insProList = new crm_installed_product_dal().GetInsProAccoByProName(account.id); todoList = new com_activity_dal().GetNoCompleteTodo(account.id); noteList = new com_activity_dal().GetNoteByAccount(account.id); oppoUdfList = udfBLL.GetUdf(DicEnum.UDF_CATE.OPPORTUNITY); //var arr = new string[][] { new string[] { "上海", "张耀", "1" }, new string[] { "北京", "张耀", "1" }, new string[] { "上海", "朱飞", "1" } }; //var test = from i in Enumerable.Range(0, (int)arr.GetLongLength(0)) // from j in Enumerable.Range(0, (int)arr.GetLongLength(1)) // from k in Enumerable.Range(0, (int)arr.GetLongLength(2)) // select arr[i,j,k]; }
protected void Page_Load(object sender, EventArgs e) { string colName = Request.QueryString["colName"]; objectId = Convert.ToInt64(Request.QueryString["object_id"]); var objType = Request.QueryString["object_type"]; switch (objType) { case "project": cate = DicEnum.UDF_CATE.PROJECTS; break; default: break; } thisUdfInfo = new DAL.sys_udf_field_dal().GetInfoByCateAndName((int)cate, colName); //if (!IsPostBack) //{ var bll = new UserDefinedFieldsBLL(); var udfList = bll.GetUdf(cate); udf = udfList.First(f => f.name.Equals(colName)); var udfValues = bll.GetUdfValue(cate, objectId, udfList); udfValue = udfValues.First(v => v.id == udf.id).value; //} if (thisUdfInfo == null) // 没有找到该自定义相关信息,停止响应 { Response.End(); } }
protected void Page_Load(object sender, EventArgs e) { try { var ticketIds = Request.QueryString["ticketIds"]; var sdDal = new sdk_task_dal(); if (!string.IsNullOrEmpty(ticketIds)) { ticketList = sdDal.GetTicketByIds(ticketIds); } if (ticketList != null && ticketList.Count > 0) { if (ticketList.Count == 1) { isSingle = true; } else { isSingle = false; } thisTicket = ticketList[0]; } else { Response.Write("<script>alert('未查询到相关工单信息!');window.close();</script>"); return; } var udfBLL = new UserDefinedFieldsBLL(); if (thisTicket == null) { Response.Write("<script>alert('未查询到相关工单信息!');window.close();</script>"); } else { thisAccount = new CompanyBLL().GetCompany(thisTicket.account_id); thisUser = new sys_resource_dal().FindNoDeleteById(LoginUserId); #region 获取相关属性是否可以更改 if (ticketList.Any(_ => _.id != thisTicket.id)) { isManyTitle = true; } else { isManyTitle = false; } if (ticketList.Any(_ => _.id != thisTicket.id)) { isManydesc = true; } else { isManydesc = false; } if (ticketList.Any(_ => _.id != thisTicket.id && _.department_id != thisTicket.department_id)) { isManyDep = true; } else { isManyDep = false; } if (ticketList.Any(_ => _.id != thisTicket.id && _.issue_type_id != thisTicket.issue_type_id)) { isManyissType = true; } else { isManyissType = false; } if (ticketList.Any(_ => _.id != thisTicket.id && (_.owner_resource_id != thisTicket.owner_resource_id && _.role_id != thisTicket.role_id))) { isManyPri = true; } else { isManyPri = false; if (thisTicket.owner_resource_id != null && thisTicket.role_id != null) { thisPriRes = new sys_resource_dal().FindNoDeleteById((long)thisTicket.owner_resource_id); thisRole = new sys_role_dal().FindNoDeleteById((long)thisTicket.role_id); var resDepList = new sys_resource_department_dal().GetResDepByResAndRole((long)thisTicket.owner_resource_id, (long)thisTicket.role_id); if (resDepList != null && resDepList.Count > 0) { proResDep = resDepList[0]; } } } if (ticketList.Any(_ => _.id != thisTicket.id && _.cate_id != thisTicket.cate_id)) { isManyTicketCate = true; } else { isManyTicketCate = false; } if (ticketList.Any(_ => _.id != thisTicket.id && _.estimated_hours != thisTicket.estimated_hours)) { isManyEstHour = true; } else { isManyEstHour = false; } if (ticketList.Any(_ => _.id != thisTicket.id && _.estimated_end_time != thisTicket.estimated_end_time)) { isManyDueTime = true; } else { isManyDueTime = false; } if (ticketList.Any(_ => _.id != thisTicket.id && _.account_id != thisTicket.account_id)) { isManyAccount = true; } else { isManyAccount = false; } if (ticketList.Any(_ => _.id != thisTicket.id && _.contract_id != thisTicket.contract_id)) { isManyContract = true; } else { isManyContract = false; if (thisTicket.contract_id != null) { thisContract = new ctt_contract_dal().FindNoDeleteById((long)thisTicket.contract_id); } } if (ticketList.Any(_ => _.id != thisTicket.id && _.status_id != thisTicket.status_id)) { isManyStatus = true; } else { isManyStatus = false; } if (ticketList.Any(_ => _.id != thisTicket.id && _.service_id != thisTicket.service_id)) { isManySerivce = true; } else { isManySerivce = false; } if (ticketList.Any(_ => _.id != thisTicket.id && _.priority_type_id != thisTicket.priority_type_id)) { isManyPrio = true; } else { isManyPrio = false; } if (ticketList.Any(_ => _.id != thisTicket.id && _.cost_code_id != thisTicket.cost_code_id)) { isManyWork = true; } else { isManyWork = false; if (thisTicket.cost_code_id != null) { thisWorkType = new d_cost_code_dal().FindNoDeleteById((long)thisTicket.cost_code_id); } } if (ticketList.Any(_ => _.id != thisTicket.id && _.sub_issue_type_id != thisTicket.sub_issue_type_id)) { isManySubIssType = true; } else { isManySubIssType = false; } // protected bool isManyStatus; #endregion udfValue = udfBLL.GetUdfValue(DicEnum.UDF_CATE.TASK, thisTicket.id, udfTaskPara); if (udfTaskPara != null && udfTaskPara.Count > 0) { foreach (var udfTask in udfTaskPara) { var thisValue = ""; if (udfValue.FirstOrDefault(_ => _.id == udfTask.id) != null) { thisValue = udfValue.FirstOrDefault(_ => _.id == udfTask.id).value.ToString(); } var count = new UserDefinedFieldsBLL().GetSameValueCount(DicEnum.UDF_CATE.TASK, ticketIds, udfTask.col_name, thisValue.ToString()); if (count > 1 && (!isSingle)) { udfValue.FirstOrDefault(_ => _.id == udfTask.id).value = "多个值-保持不变"; } } } var otherResList = new sdk_task_resource_dal().GetTaskResByTaskId(thisTicket.id); if (otherResList != null && otherResList.Count > 0) { foreach (var item in otherResList) { if (item.resource_id != null && item.role_id != null) { var resDepList = new sys_resource_department_dal().GetResDepByResAndRole((long)item.resource_id, (long)item.role_id); if (resDepList != null && resDepList.Count > 0) { ticketResIds += resDepList[0].id + ","; } } } if (ticketResIds != "") { ticketResIds = ticketResIds.Substring(0, ticketResIds.Length - 1); } } } if (IsPostBack) { var stDal = new sdk_task_dal(); var ticBll = new TicketBLL(); var accBll = new CompanyBLL(); var notiResIds = new System.Text.StringBuilder(); foreach (var tic in ticketList) { var ticket = stDal.FindNoDeleteById(tic.id); if (ticket == null) { continue; } var user = UserInfoBLL.GetUserInfo(LoginUserId); #region 获取相关参数 #region 标题,描述,队列,主负责人 var pageTitle = ticket.title; if (!isManyTitle) { pageTitle = Request.Form["title"]; } var pageDesc = ticket.description; if (!isManydesc) { pageDesc = Request.Form["description"]; } var pageDepIdString = Request.Form["department_id"]; var pagePriResIdString = Request.Form["pri_res"]; if (string.IsNullOrEmpty(pageDepIdString) && string.IsNullOrEmpty(pagePriResIdString)) { Response.Write("<script>alert('队列和主负责人请填写其中一项!');</script>"); return; } long?pageDepId; if (!string.IsNullOrEmpty(pageDepIdString) && pageDepIdString != "0") { pageDepId = long.Parse(pageDepIdString); } else if (string.IsNullOrEmpty(pageDepIdString)) { pageDepId = null; } else { pageDepId = ticket.department_id; } long?pagePriResId; if (!string.IsNullOrEmpty(pagePriResIdString) && pagePriResIdString != "0") { pagePriResId = long.Parse(pagePriResIdString); } else if (string.IsNullOrEmpty(pagePriResIdString)) { pagePriResId = null; } else { pagePriResId = ticket.owner_resource_id; } #endregion #region 种类,预估时间,到期时间,合同名称 var pageCateId = ticket.cate_id; var pageCateIdString = Request.Form["ticket_cate"]; if (!string.IsNullOrEmpty(pageCateIdString) && pageCateIdString != "0") { pageCateId = int.Parse(pageCateIdString); } else if (string.IsNullOrEmpty(pagePriResIdString)) { Response.Write("<script>alert('请选择工单种类!');</script>"); return; } else { pageCateId = ticket.cate_id; } var estHours = ticket.estimated_hours; var pageEstHours = Request.Form["est_hours"]; if (!string.IsNullOrEmpty(pageEstHours) && pageEstHours.Trim() != "多个值-保持不变") { estHours = decimal.Parse(pageEstHours); } var dueTime = ticket.estimated_end_time; var pageDueTime = Request.Form["due_time"]; if (!string.IsNullOrEmpty(pageDueTime) && pageDueTime.Trim() != "多个值-保持不变") { dueTime = Tools.Date.DateHelper.ToUniversalTimeStamp(DateTime.Parse(pageDueTime)); } var contractName = ticket.contract_id; var pageContract = Request.Form["contractName"]; if (!string.IsNullOrEmpty(pageContract) && pageContract != "0") { contractName = long.Parse(pageContract); } else if (string.IsNullOrEmpty(pageContract)) { contractName = null; } #endregion #region 状态,服务包,优先级,工作类型,问题类型,子问题类型 var pageStatusId = ticket.status_id; var pageStuatusIdString = Request.Form["statusId"]; if (!string.IsNullOrEmpty(pageStuatusIdString) && pageStuatusIdString != "0") { pageStatusId = int.Parse(pageStuatusIdString); } else if (string.IsNullOrEmpty(pageStuatusIdString)) { Response.Write("<script>alert('请选择工单状态!');</script>"); return; } var pageServiceId = ticket.service_id; var pageServiceIdString = Request.Form["serviceId"]; if (!string.IsNullOrEmpty(pageServiceIdString) && pageServiceIdString != "0") { pageServiceId = int.Parse(pageServiceIdString); } else if (string.IsNullOrEmpty(pageServiceIdString)) { pageServiceId = null; } var pagePrioId = ticket.priority_type_id; var pagePrioIdString = Request.Form["priorityId"]; if (!string.IsNullOrEmpty(pagePrioIdString) && pagePrioIdString != "0") { pagePrioId = int.Parse(pagePrioIdString); } else if (string.IsNullOrEmpty(pagePrioIdString)) { Response.Write("<script>alert('请选择工单优先级!');</script>"); return; } var workTypeId = ticket.cost_code_id; var pageWorkTypeId = Request.Form["workTypeId"]; if (!string.IsNullOrEmpty(pageWorkTypeId) && pageWorkTypeId != "0") { workTypeId = long.Parse(pageWorkTypeId); } else if (string.IsNullOrEmpty(pageWorkTypeId)) { contractName = null; } var pageIssId = ticket.issue_type_id; var pageIssIdString = Request.Form["IssueType"]; if (!string.IsNullOrEmpty(pageIssIdString) && pageIssIdString != "0") { pageIssId = int.Parse(pageIssIdString); } else if (string.IsNullOrEmpty(pageIssIdString)) { Response.Write("<script>alert('请选择问题类型!');</script>"); return; } var pageSubIssId = ticket.sub_issue_type_id; var pageSubIssIdString = Request.Form["SubIssueType"]; if (!string.IsNullOrEmpty(pageSubIssIdString) && pageSubIssIdString != "0") { pageSubIssId = int.Parse(pageSubIssIdString); } else if (string.IsNullOrEmpty(pageSubIssIdString)) { Response.Write("<script>alert('请选择子问题类型!');</script>"); return; } #endregion #region 自定义字段相关 var thisUdfValue = udfBLL.GetUdfValue(DicEnum.UDF_CATE.TASK, tic.id, udfTaskPara); if (udfTaskPara != null && udfTaskPara.Count > 0) { var list = new List <UserDefinedFieldValue>(); foreach (var udf in udfTaskPara) { var new_udf = new UserDefinedFieldValue() { id = udf.id }; var thisvv = Request.Form[udf.id.ToString()]; if (udf.data_type == (int)DicEnum.UDF_DATA_TYPE.LIST) { if (thisvv == "0") { new_udf.value = thisUdfValue.FirstOrDefault(_ => _.id == udf.id) == null ? "" : thisUdfValue.FirstOrDefault(_ => _.id == udf.id).value; } else { new_udf.value = thisvv == "" ? null : thisvv; } } else { if (thisvv == "多个值-保持不变") { new_udf.value = thisUdfValue.FirstOrDefault(_ => _.id == udf.id) == null ? "" : thisUdfValue.FirstOrDefault(_ => _.id == udf.id).value; } else { new_udf.value = thisvv == "" ? null : thisvv; } } list.Add(new_udf); } udfBLL.UpdateUdfValue(DicEnum.UDF_CATE.TASK, udfTaskPara, ticket.id, list, user, DicEnum.OPER_LOG_OBJ_CATE.PROJECT_TASK); } #endregion #endregion #region 修改工单 ticket.title = pageTitle; ticket.description = pageDesc; ticket.department_id = pageDepId; long?roleId = null; if (pagePriResId != null) { var resDep = new sys_resource_department_dal().FindById((long)pagePriResId); if (resDep != null) { pagePriResId = resDep.resource_id; roleId = resDep.role_id; } else { pagePriResId = null; roleId = null; } } ticket.owner_resource_id = pagePriResId; ticket.role_id = roleId; ticket.cate_id = pageCateId; ticket.estimated_hours = estHours; ticket.estimated_end_time = dueTime; ticket.contract_id = contractName; ticket.status_id = pageStatusId; ticket.service_id = pageServiceId; ticket.priority_type_id = pagePrioId; ticket.cost_code_id = workTypeId; ticket.issue_type_id = pageIssId; ticket.sub_issue_type_id = pageSubIssId; ticBll.EditTicket(ticket, LoginUserId); #endregion #region 生成备注 ticBll.AddModifyTicketNote(ticket.id, LoginUserId); #endregion #region 单个工单时 修改其他员工相关 if (isSingle) { var OtherResId = Request.Form["OtherResId"]; ticBll.TicketResManage(ticket.id, OtherResId, LoginUserId); } #endregion #region 获取需要发送邮件的员工的Id if (CkPriRes.Checked && ticket.owner_resource_id != null) { notiResIds.Append(ticket.owner_resource_id + ","); } if (CKcreate.Checked) { notiResIds.Append(ticket.create_user_id + ","); } if (CKaccMan.Checked) { var thisAccount = accBll.GetCompany(ticket.account_id); if (thisAccount != null && thisAccount.resource_id != null) { notiResIds.Append(thisAccount.resource_id + ","); } } #endregion } #region 通知相关 if (CCMe.Checked) { notiResIds.Append(LoginUserId + ","); } var resIds = Request.Form["resIds"]; if (!string.IsNullOrEmpty(resIds)) { notiResIds.Append(resIds + ","); } var notify_id = Request.Form["notify_id"]; if (!string.IsNullOrEmpty(notify_id) && notify_id != "0") { } #endregion ClientScript.RegisterStartupScript(this.GetType(), "提示信息", "<script>alert('保存成功');self.opener.location.reload();window.close();</script>"); } } catch (Exception msg) { Response.Write("<script>alert('" + msg.Message + "!');window.close();</script>"); } }
protected void Page_Load(object sender, EventArgs e) { // 批量修改 // 1。多个任务 2.单个任务 try { var stDal = new sdk_task_dal(); var ppDal = new pro_project_dal(); var ids = Request.QueryString["taskIds"]; if (!string.IsNullOrEmpty(ids)) { idList = ids.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries); if (idList.Count() == 1) { var thisTask = stDal.FindNoDeleteById(long.Parse(idList[0])); if (thisTask != null) { if (!IsPostBack) { thisProject = ppDal.FindNoDeleteById((long)thisTask.project_id); titleValue = thisTask.title; statuValue = thisTask.status_id; priorityValue = thisTask.priority; estHoursValue = thisTask.estimated_hours; depValue = thisTask.department_id; // workTypeValue = thisTask. priResValue = thisTask.owner_resource_id; if (thisTask.is_visible_in_client_portal == 1) { if (thisTask.can_client_portal_user_complete_task == 1) { DisplayInCapYes.Checked = true; } else { DisplayInCapYesNoComplete.Checked = true; } } else { DisplayInCapNone.Checked = true; } } udfValue = new UserDefinedFieldsBLL().GetUdfValue(UDF_CATE.TASK, thisTask.id, udfTaskPara); taskList.Add(thisTask); } } else if (idList.Count() > 1) { taskList = stDal.GetTaskByIds(ids, $" and type_id in ({(int)DicEnum.TASK_TYPE.PROJECT_TASK},{(int)DicEnum.TASK_TYPE.PROJECT_ISSUE})"); if (taskList != null && taskList.Count > 0) { thisProject = ppDal.FindNoDeleteById((long)taskList[0].project_id); var firstTask = taskList[0]; taskList.Remove(firstTask); if (!IsPostBack) { udfValue = udfBLL.GetUdfValue(UDF_CATE.TASK, firstTask.id, udfTaskPara); if (udfTaskPara != null && udfTaskPara.Count > 0) { foreach (var udfTask in udfTaskPara) { var thisValue = ""; if (udfValue.FirstOrDefault(_ => _.id == udfTask.id) != null) { thisValue = udfValue.FirstOrDefault(_ => _.id == udfTask.id).value.ToString(); } var count = udfBLL.GetSameValueCount(UDF_CATE.TASK, ids, udfTask.col_name, thisValue.ToString()); if (count > 1) { udfValue.FirstOrDefault(_ => _.id == udfTask.id).value = "多个值-保持不变"; } else { } } } if (taskList.Any(_ => _.title != firstTask.title)) { titleValue = "多个值-保持不变"; } else { titleValue = firstTask.title; } if (taskList.Any(_ => _.status_id != firstTask.status_id)) { statuValue = 0; } else { statuValue = firstTask.status_id; } if (taskList.Any(_ => _.priority != firstTask.priority)) { priorityValue = null; } else { priorityValue = firstTask.priority; } #region 在页面上的显示设置 if (firstTask.is_visible_in_client_portal == 1) { if (taskList.Any(_ => _.is_visible_in_client_portal != firstTask.is_visible_in_client_portal)) { displayWayValue = "1"; } else { if (firstTask.can_client_portal_user_complete_task == 1) { if (taskList.Any(_ => _.can_client_portal_user_complete_task != firstTask.can_client_portal_user_complete_task)) { displayWayValue = "1"; } else { DisplayInCapYes.Checked = true; } } else { if (taskList.Any(_ => _.can_client_portal_user_complete_task != firstTask.can_client_portal_user_complete_task)) { displayWayValue = "1"; } else { DisplayInCapYesNoComplete.Checked = true; } } } } else { if (taskList.Any(_ => _.is_visible_in_client_portal != firstTask.is_visible_in_client_portal)) { displayWayValue = "1"; } else { DisplayInCapNone.Checked = true; } } if (!string.IsNullOrEmpty(displayWayValue)) { noChange.Checked = true; } #endregion #region 固定工作,固定时间的设置 if (taskList.Any(_ => _.estimated_type_id != firstTask.estimated_type_id)) { fixTypeValue = "1"; typeNoChange.Checked = true; } else { if (firstTask.estimated_type_id == (int)DicEnum.TIME_ENTRY_METHOD_TYPE.FIXWORK) { TaskTypeFixedWork.Checked = true; } else if (firstTask.estimated_type_id == (int)DicEnum.TIME_ENTRY_METHOD_TYPE.FIXDURATION) { TaskTypeFixedDuration.Checked = true; } } #endregion if (taskList.Any(_ => _.estimated_hours != firstTask.estimated_hours)) { estHoursValue = null; } else { estHoursValue = firstTask.estimated_hours; } if (taskList.Any(_ => _.department_id != firstTask.department_id)) { depValue = null; } else { depValue = firstTask.department_id; } if (taskList.Any(_ => _.owner_resource_id != firstTask.owner_resource_id)) { priResValue = 0; } else { priResValue = firstTask.owner_resource_id; } } } } if (!IsPostBack) { ThisPageDataBind(); } if (statuValue == 0) { status_id.Items.Insert(0, new ListItem() { Value = "0", Text = "多个选择-保持不变", Selected = true }); } else { status_id.SelectedValue = statuValue.ToString(); } if (depValue == null) { department_id.ClearSelection(); department_id.Items.Insert(0, new ListItem() { Value = "0", Text = "多个选择-保持不变", Selected = true }); } else { department_id.ClearSelection(); department_id.SelectedValue = depValue.ToString(); } } else { Response.End(); } } catch (Exception) { Response.End(); } }