/// <summary> /// 获取到该客户的项目提案信息 /// </summary> private void GetAccountProject(HttpContext context, long account_id) { var proList = new pro_project_dal().GetProjectListByAcc(account_id); if (proList != null && proList.Count > 0) { // 筛选项目提案 proList = proList.Where(_ => _.type_id == (int)DicEnum.PROJECT_TYPE.PROJECT_DAY).ToList(); StringBuilder proText = new StringBuilder(); proText.Append("<option value='0'>请选择一个项目提案</option>"); foreach (var pro in proList) { proText.Append($"<option value='{pro.id}'>{pro.name}</option>"); } context.Response.Write(proText.ToString()); } }
protected string pageShowType = ""; // 页面过滤数据类型 --默认展示全部的数据(过滤阶段,完成等信息) protected void Page_Load(object sender, EventArgs e) { try { var id = Request.QueryString["project_id"]; thisProject = new pro_project_dal().FindNoDeleteById(long.Parse(id)); if (thisProject != null) { pageShowType = Request.QueryString["pageShowType"]; taskList = new sdk_task_dal().GetProjectTask(thisProject.id); var isTran = Request.QueryString["isTranTemp"]; if ((!string.IsNullOrEmpty(isTran))) //thisProject.type_id != (int)DicEnum.PROJECT_TYPE.TEMP && { isTransTemp = true; } if (!IsPostBack) { var tempList = new pro_project_dal().GetTempList(); // 项目模板 --project_temp if (tempList != null && tempList.Count > 0) { project_temp.DataTextField = "name"; project_temp.DataValueField = "id"; project_temp.DataSource = tempList; project_temp.DataBind(); } organization_location_id.DataTextField = "name"; organization_location_id.DataValueField = "id"; organization_location_id.DataSource = dic.FirstOrDefault(_ => _.Key == "org_location").Value; organization_location_id.DataBind(); useResource_daily_hours.Checked = thisProject.use_resource_daily_hours == 1; excludeWeekend.Checked = thisProject.exclude_weekend == 1; excludeHoliday.Checked = thisProject.exclude_holiday == 1; warnTime_off.Checked = thisProject.warn_time_off == 1; } // if (!int.TryParse(Request.QueryString["cat"], out catId)) var catIdString = Request.QueryString["CatID"]; if (string.IsNullOrEmpty(catIdString)) { catId = (int)DicEnum.QUERY_CATE.PROJECT_TASK; } else { catId = int.Parse(catIdString); } // if (!long.TryParse(Request.QueryString["type"], out queryTypeId)) var queryTypeIdString = Request.QueryString["QeryTypeId"]; if (string.IsNullOrEmpty(queryTypeIdString)) { queryTypeId = (int)QueryType.PROJECT_TASK; //queryTypeId = (int)QueryType.PROJECT_PHASE; } else { queryTypeId = int.Parse(queryTypeIdString); } if (catId == 0 || queryTypeId == 0) { Response.Close(); return; } // 一个query_type下只有一个group时可以不传参gruop_id if (paraGroupId == 0) { var groups = bll.GetQueryGroup(catId); foreach (var g in groups) { if (g.query_type_id == queryTypeId) { if (paraGroupId != 0) // 一个query_type下有多个group,不能判断使用哪个 { Response.Close(); return; } paraGroupId = g.id; } } } // if (!long.TryParse(Request.QueryString["id"], out objId)) objId = thisProject.id; QueryData(); CalcTableWidth(); } else { Response.End(); } } catch (Exception msg) { Response.End(); } }
protected SdkWorkEntryDto GetParam() { SdkWorkEntryDto para = new SdkWorkEntryDto(); var pageEntry = AssembleModel <sdk_work_entry>(); //var pageRecord = AssembleModel<sdk_work_record>(); //var startTime = Request.Form["startTime"]; //var endTime = Request.Form["endTime"]; //var date = Request.Form["tmeDate"]; //if(!string.IsNullOrEmpty(startTime)&& !string.IsNullOrEmpty(endTime) && !string.IsNullOrEmpty(date)) //{ // var starString = date + " " + startTime; // var endString = date + " " + endTime; // var startDate = DateTime.Parse(starString); // var endDate = DateTime.Parse(endString); // if (endDate < startDate) // { // endDate = endDate.AddDays(1); // } // var startLong = Tools.Date.DateHelper.ToUniversalTimeStamp(startDate); // var endLong = Tools.Date.DateHelper.ToUniversalTimeStamp(endDate); // pageEntry.start_time = startLong; // pageEntry.end_time = endLong; // //pageRecord.start_time = startLong; // //pageRecord.end_time = endLong; //} var PageEntryIds = Request.Form["PageEntryIds"]; if (!string.IsNullOrEmpty(PageEntryIds)) { var entArr = PageEntryIds.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries); List <PageEntryDto> entDtoList = new List <PageEntryDto>(); //var hours_worked = Request.Form["hours_worked"]; foreach (var thisEntArrId in entArr) { var thisSum = Request.Form["summ_" + thisEntArrId]; var thisIne = Request.Form["inter_" + thisEntArrId]; var thisDate = Request.Form["entry_date_" + thisEntArrId]; var thisHour = Request.Form["entry_work_hour_" + thisEntArrId]; var thisHoured = Request.Form["entry_worked_" + thisEntArrId]; if (string.IsNullOrEmpty(thisDate)) { continue; } #region 开始结束时间 var startTime = Request.Form["entry_start_date_" + thisEntArrId]; var endTime = Request.Form["entry_end_date_" + thisEntArrId]; long?startLongDate = null; long?endLongDate = null; if (!string.IsNullOrEmpty(startTime) && !string.IsNullOrEmpty(endTime)) { var starString = thisDate + " " + startTime; var endString = thisDate + " " + endTime; var startDate = DateTime.Parse(starString); var endDate = DateTime.Parse(endString); if (endDate < startDate) { endDate = endDate.AddDays(1); } startLongDate = Tools.Date.DateHelper.ToUniversalTimeStamp(startDate); endLongDate = Tools.Date.DateHelper.ToUniversalTimeStamp(endDate); } #endregion var thisOffSet = Request.Form["entry_offset_" + thisEntArrId]; var thisBill = Request.Form["entry_billed_" + thisEntArrId]; decimal?bill = null; if (!string.IsNullOrEmpty(thisBill)) { bill = decimal.Parse(thisBill); } if ((!string.IsNullOrEmpty(thisHour) || !string.IsNullOrEmpty(thisHoured)) && !string.IsNullOrEmpty(thisDate)) { entDtoList.Add(new PageEntryDto() { id = long.Parse(thisEntArrId), sumNote = thisSum, ineNote = thisIne, time = DateTime.Parse(thisDate), startDate = startLongDate, endDate = endLongDate, workHours = !string.IsNullOrEmpty(thisHour)? decimal.Parse(thisHour): decimal.Parse(thisHoured), offset = !string.IsNullOrEmpty(thisOffSet)?decimal.Parse(thisOffSet) :0, billHours = bill, }); } } para.pagEntDtoList = entDtoList; } if (pageEntry.contract_id != null && pageEntry.service_id != null) { var thisConSer = new ctt_contract_service_dal().GetServiceByConSerId((long)pageEntry.contract_id, (long)pageEntry.service_id); if (thisConSer != null) { pageEntry.service_id = thisConSer.id; } else { pageEntry.service_id = null; } } else { pageEntry.service_id = null; } var pageProject = new pro_project_dal().FindNoDeleteById(long.Parse(Request.Form["project_id"])); if (pageProject != null) { //if (pageProject.type_id == (int)DicEnum.PROJECT_TYPE.IN_PROJECT) //{ // //pageRecord.entry_type_id = (int)DicEnum.WORK_ENTRY_TYPE.COMPAMY_IN_ENTRY; //} //else //{ // pageRecord.entry_type_id = (int)DicEnum.WORK_ENTRY_TYPE.PROJECT_ENTRY; //} } pageEntry.show_on_invoice = (sbyte)(ShowOnInv.Checked ? 1 : 0); pageEntry.is_billable = (sbyte)(isBilled.Checked?0:1); if (!isAdd) { thisWorkEntry.contract_id = pageEntry.contract_id; thisWorkEntry.task_id = pageEntry.task_id; thisWorkEntry.service_id = pageEntry.service_id; thisWorkEntry.resource_id = pageEntry.resource_id; thisWorkEntry.role_id = pageEntry.role_id; thisWorkEntry.cost_code_id = pageEntry.cost_code_id; thisWorkEntry.start_time = pageEntry.start_time; thisWorkEntry.end_time = pageEntry.end_time; thisWorkEntry.hours_worked = pageEntry.hours_worked; thisWorkEntry.hours_billed = pageEntry.hours_billed; thisWorkEntry.offset_hours = pageEntry.offset_hours; thisWorkEntry.internal_notes = pageEntry.internal_notes; thisWorkEntry.summary_notes = pageEntry.summary_notes; thisWorkEntry.is_billable = pageEntry.is_billable; thisWorkEntry.show_on_invoice = pageEntry.show_on_invoice; para.workEntry = thisWorkEntry; //if (thisWorkEntry != null) //{ // var thisWorkRecord = new sdk_work_record_dal().FindNoDeleteById((long)thisWorkEntry.work_record_id); // if (thisWorkRecord != null) // { // //thisWorkRecord.contract_id = pageRecord.contract_id; // //thisWorkRecord.task_id = pageRecord.task_id; // //thisWorkRecord.resource_id = pageRecord.resource_id; // //thisWorkRecord.entry_type_id = pageRecord.entry_type_id; // //thisWorkRecord.role_id = pageRecord.role_id; // //thisWorkRecord.cost_code_id = pageRecord.cost_code_id; // //thisWorkRecord.start_time = pageRecord.start_time; // //thisWorkRecord.end_time = pageRecord.end_time; // //para.wordRecord = thisWorkRecord; // } //} } else { para.workEntry = pageEntry; // para.wordRecord = pageRecord; } var remain_hours = Request.Form["remain_hours"]; if (!string.IsNullOrEmpty(remain_hours)) { para.remain_hours = decimal.Parse(remain_hours); } var status_id = Request.Form["status_id"]; if (!string.IsNullOrEmpty(status_id)) { para.status_id = int.Parse(status_id); } #region 通知相关 var notify_id = Request.Form["notify_id"]; if (!string.IsNullOrEmpty(notify_id)) { para.notify_id = int.Parse(notify_id); para.contact_ids = Request.Form["contact_ids"]; para.resIds = Request.Form["resIds"]; para.otherEmail = Request.Form["otherEmail"]; para.subjects = Request.Form["subjects"]; para.AdditionalText = Request.Form["AdditionalText"]; } #endregion return(para); }
/// <summary> /// 页面数据源配置 /// </summary> private void PageDataBind() { line_of_business_id.DataTextField = "show"; line_of_business_id.DataValueField = "val"; line_of_business_id.DataSource = dic.FirstOrDefault(_ => _.Key == "project_line_of_business").Value; line_of_business_id.DataBind(); line_of_business_id.Items.Insert(0, new ListItem() { Value = "0", Text = " ", Selected = true }); temp_line_of_business_id.DataTextField = "show"; temp_line_of_business_id.DataValueField = "val"; temp_line_of_business_id.DataSource = dic.FirstOrDefault(_ => _.Key == "project_line_of_business").Value; temp_line_of_business_id.DataBind(); temp_line_of_business_id.Items.Insert(0, new ListItem() { Value = "0", Text = " ", Selected = true }); type_id.DataTextField = "show"; type_id.DataValueField = "val"; var thisTypeList = dic.FirstOrDefault(_ => _.Key == "project_type").Value as List <DictionaryEntryDto>; if (!string.IsNullOrEmpty(isTemp)) // 是否是模板 { var temp = thisTypeList.FirstOrDefault(_ => _.val == ((int)DicEnum.PROJECT_TYPE.TEMP).ToString()); if (temp != null) { thisTypeList = new List <DictionaryEntryDto>() { temp }; if (GetLimitValue(AuthLimitEnum.PROTemplatesAdd) == DicEnum.LIMIT_TYPE_VALUE.NO960) { thisTypeList.Remove(temp); } } } else { var temp = thisTypeList.FirstOrDefault(_ => _.val == ((int)DicEnum.PROJECT_TYPE.TEMP).ToString()); if (temp != null) { thisTypeList.Remove(temp); } var benchmark = thisTypeList.FirstOrDefault(_ => _.val == ((int)DicEnum.PROJECT_TYPE.BENCHMARK).ToString()); if (benchmark != null) { thisTypeList.Remove(benchmark); } // 权限过滤,部分不可新增则不显示。 if (GetLimitValue(AuthLimitEnum.PROClientAdd) == DicEnum.LIMIT_TYPE_VALUE.NO960) { var cline = thisTypeList.FirstOrDefault(_ => _.val == ((int)DicEnum.PROJECT_TYPE.ACCOUNT_PROJECT).ToString()); if (cline != null) { thisTypeList.Remove(cline); } var inter = thisTypeList.FirstOrDefault(_ => _.val == ((int)DicEnum.PROJECT_TYPE.IN_PROJECT).ToString()); if (inter != null) { thisTypeList.Remove(inter); } } if (GetLimitValue(AuthLimitEnum.PROProposalAdd) == DicEnum.LIMIT_TYPE_VALUE.NO960) { var popal = thisTypeList.FirstOrDefault(_ => _.val == ((int)DicEnum.PROJECT_TYPE.PROJECT_DAY).ToString()); if (popal != null) { thisTypeList.Remove(popal); } } } type_id.DataSource = thisTypeList; type_id.DataBind(); thisType = Request.QueryString["type_id"]; if (!string.IsNullOrEmpty(thisType)) { type_id.SelectedValue = thisType; } temp_type_id.DataTextField = "show"; temp_type_id.DataValueField = "val"; temp_type_id.DataSource = thisTypeList; temp_type_id.DataBind(); status_id.DataTextField = "show"; status_id.DataValueField = "val"; status_id.DataSource = dic.FirstOrDefault(_ => _.Key == "project_status").Value; status_id.DataBind(); owner_resource_id.DataTextField = "show"; owner_resource_id.DataValueField = "val"; owner_resource_id.DataSource = dic.FirstOrDefault(_ => _.Key == "sys_resource").Value; owner_resource_id.DataBind(); owner_resource_id.Items.Insert(0, new ListItem() { Value = "0", Text = " ", Selected = true }); // temp_owner_resource_id temp_owner_resource_id.DataTextField = "show"; temp_owner_resource_id.DataValueField = "val"; temp_owner_resource_id.DataSource = dic.FirstOrDefault(_ => _.Key == "sys_resource").Value; temp_owner_resource_id.DataBind(); temp_owner_resource_id.Items.Insert(0, new ListItem() { Value = "0", Text = " ", Selected = true }); department_id.DataTextField = "name"; department_id.DataValueField = "id"; department_id.DataSource = dic.FirstOrDefault(_ => _.Key == "department").Value; department_id.DataBind(); department_id.Items.Insert(0, new ListItem() { Value = "0", Text = " ", Selected = true }); temp_department_id.DataTextField = "name"; temp_department_id.DataValueField = "id"; temp_department_id.DataSource = dic.FirstOrDefault(_ => _.Key == "department").Value; temp_department_id.DataBind(); temp_department_id.Items.Insert(0, new ListItem() { Value = "0", Text = " ", Selected = true }); organization_location_id.DataTextField = "name"; organization_location_id.DataValueField = "id"; organization_location_id.DataSource = dic.FirstOrDefault(_ => _.Key == "org_location").Value; organization_location_id.DataBind(); template_id.DataTextField = "name"; template_id.DataValueField = "id"; template_id.DataSource = new sys_notify_tmpl_dal().GetTempByEvent(DicEnum.NOTIFY_EVENT.PROJECT_CREATED); template_id.DataBind(); if (string.IsNullOrEmpty(isTemp)) { var tempList = new pro_project_dal().GetTempList(); // 项目模板 --project_temp if (tempList != null && tempList.Count > 0) { project_temp.DataTextField = "name"; project_temp.DataValueField = "id"; project_temp.DataSource = tempList; project_temp.DataBind(); } } }
/// <summary> /// 检查员工的可用性 /// </summary> private void CheckResAvailability(HttpContext context) { // 在同一项目下校验 try { var project_id = context.Request.QueryString["project_id"]; var resId = context.Request.QueryString["res_id"]; var startTime = context.Request.QueryString["startTime"]; // 开始时间 var endTime = context.Request.QueryString["endTime"]; var days = context.Request.QueryString["days"]; // 持续时间 var thisTaskRpeHour = context.Request.QueryString["thisTaskRpeHour"]; // 这个员工在这个任务中的日工作时间 if (!string.IsNullOrEmpty(project_id) && !string.IsNullOrEmpty(resId) && !string.IsNullOrEmpty(startTime) && !string.IsNullOrEmpty(endTime) && !string.IsNullOrEmpty(thisTaskRpeHour)) { var project = new pro_project_dal().FindNoDeleteById(long.Parse(project_id)); var taskList = new sdk_task_dal().GetListByProAndRes(long.Parse(project_id), long.Parse(resId)); int readDays = 0; var startDate = DateTime.Parse(startTime); var endDate = DateTime.Parse(endTime); if (!string.IsNullOrEmpty(days)) { readDays = int.Parse(days); endDate = new BLL.TaskBLL().RetrunMaxTime(project.id, startDate, readDays); } else { readDays = new BLL.TaskBLL().GetDayByTime(Tools.Date.DateHelper.ToUniversalTimeStamp(startDate), Tools.Date.DateHelper.ToUniversalTimeStamp(endDate), long.Parse(project_id)); } if (readDays != 0) { // 员工在这个项目中应该工作的时长 var totalHours = readDays * (decimal)project.resource_daily_hours; if (taskList != null && taskList.Count > 0) { var startDateLong = Tools.Date.DateHelper.ToUniversalTimeStamp(startDate); var thisList = taskList.Where(_ => (_.type_id == (int)DTO.DicEnum.TASK_TYPE.PROJECT_ISSUE || _.type_id == (int)DTO.DicEnum.TASK_TYPE.PROJECT_TASK) && (_.estimated_begin_time <Tools.Date.DateHelper.ToUniversalTimeStamp(endDate) && _.estimated_end_time> startDateLong)).ToList(); if (thisList != null && thisList.Count > 0) { // 员工在这些天中已经分配的时长 var taskTotalHours = thisList.Sum(_ => { var thisDays = (decimal)_.hours_per_resource * GetDiffDays(startDate, endDate, Tools.Date.DateHelper.ConvertStringToDateTime((long)_.estimated_begin_time), Tools.Date.DateHelper.ConvertStringToDateTime((long)_.estimated_end_time), project.id); if (thisDays == 0 || _.hours_per_resource == null) { return(0); } else { // 计算员工平均工作时长 TimeSpan ts1 = new TimeSpan(Tools.Date.DateHelper.ConvertStringToDateTime((long)_.estimated_begin_time).Ticks); TimeSpan ts2 = new TimeSpan(Tools.Date.DateHelper.ConvertStringToDateTime((long)_.estimated_end_time).Ticks); var allDays = ts1.Subtract(ts2).Duration().Days; return(((decimal)_.hours_per_resource / allDays) * thisDays); } }); // 员工的剩余时长 var shengyuHours = totalHours - taskTotalHours; var preHours = decimal.Parse(thisTaskRpeHour); var result = shengyuHours > preHours; context.Response.Write(new { result = result, reason = shengyuHours.ToString("#0.00") }); } } } //pageTask.estimated_duration = ts.Days + 1; } } catch (Exception) { } }
protected void Page_Load(object sender, EventArgs e) { try { thisBookMark = new IndexBLL().GetSingBook(Request.RawUrl, LoginUserId); tmplList = new FormTemplateBLL().GetTmplByType((int)DicEnum.FORM_TMPL_TYPE.QUOTE, LoginUserId); var id = Request.QueryString["id"]; dic = new QuoteBLL().GetField(); #region 拉框配置数据源 tax_region_id.DataValueField = "val"; tax_region_id.DataTextField = "show"; tax_region_id.DataSource = dic.FirstOrDefault(_ => _.Key == "taxRegion").Value; tax_region_id.DataBind(); tax_region_id.Items.Insert(0, new ListItem() { Value = "0", Text = " ", Selected = true }); payment_term_id.DataValueField = "val"; payment_term_id.DataTextField = "show"; payment_term_id.DataSource = dic.FirstOrDefault(_ => _.Key == "payment_term").Value; payment_term_id.DataBind(); payment_term_id.Items.Insert(0, new ListItem() { Value = "0", Text = " ", Selected = true }); payment_type_id.DataValueField = "val"; payment_type_id.DataTextField = "show"; payment_type_id.DataSource = dic.FirstOrDefault(_ => _.Key == "payment_type").Value; payment_type_id.DataBind(); payment_type_id.Items.Insert(0, new ListItem() { Value = "0", Text = " ", Selected = true }); shipping_type_id.DataValueField = "val"; shipping_type_id.DataTextField = "show"; shipping_type_id.DataSource = dic.FirstOrDefault(_ => _.Key == "payment_ship_type").Value; shipping_type_id.DataBind(); shipping_type_id.Items.Insert(0, new ListItem() { Value = "0", Text = " ", Selected = true }); quote_tmpl_id.DataValueField = "id"; quote_tmpl_id.DataTextField = "name"; quote_tmpl_id.DataSource = dic.FirstOrDefault(_ => _.Key == "quote_tmpl").Value; quote_tmpl_id.DataBind(); quote_tmpl_id.Items.Insert(0, new ListItem() { Value = "0", Text = " ", Selected = true }); var prolist = new pro_project_dal().GetProjectList(); // project_id //project_id.DataValueField = "id"; //project_id.DataTextField = "name"; //project_id.DataSource = prolist; //project_id.DataBind(); //project_id.Items.Insert(0, new ListItem() { Value = "0", Text = " ", Selected = true }); #endregion if (!string.IsNullOrEmpty(id)) { if (AuthBLL.GetUserQuoteAuth(LoginUserId, LoginUser.security_Level_id, Convert.ToInt64(id)).CanEdit == false) { Response.End(); return; } quote = new crm_quote_dal().GetQuote(Convert.ToInt64(id)); if (quote != null) { if (string.IsNullOrEmpty(Request.QueryString["copy"])) { isAdd = false; } } } else { var opportunity_id = Request.QueryString["quote_opportunity_id"]; if (!string.IsNullOrEmpty(opportunity_id)) { opportunity = new crm_opportunity_dal().GetOpportunityById(long.Parse(opportunity_id)); account = new CompanyBLL().GetCompany(opportunity.account_id); } } if (!IsPostBack) { if (!isAdd) { account = new CompanyBLL().GetCompany(quote.account_id); if (account != null) { tax_region_id.SelectedValue = account.tax_region_id != null?account.tax_region_id.ToString() : "0"; payment_term_id.SelectedValue = quote.payment_term_id != null?quote.payment_term_id.ToString() : "0"; payment_type_id.SelectedValue = quote.payment_type_id != null?quote.payment_type_id.ToString() : "0"; //shipping_type_id shipping_type_id.SelectedValue = quote.shipping_type_id != null?quote.shipping_type_id.ToString() : "0"; quote_tmpl_id.SelectedValue = quote.quote_tmpl_id != null?quote.quote_tmpl_id.ToString() : "0"; //project_id.SelectedValue = quote.project_id!=null ? quote.project_id.ToString() : "0"; BillLocation.Checked = quote.bill_to_location_id == quote.sold_to_location_id; ShipLocation.Checked = quote.ship_to_location_id == quote.sold_to_location_id; } #region 记录浏览历史 var history = new sys_windows_history() { title = $"编辑报价:" + quote.name + " " + (account != null ? account.name : ""), url = Request.RawUrl, }; new IndexBLL().BrowseHistory(history, LoginUserId); #endregion } } } catch (Exception) { Response.End(); } }
/// <summary> /// 新增附件 /// </summary> /// <param name="objType">对象类型</param> /// <param name="objId">对象id</param> /// <param name="typeId">附件类型</param> /// <param name="title">附件名</param> /// <param name="attLink">附件内容</param> /// <param name="fileName">上传的文件名</param> /// <param name="fileSaveName">文件保存服务器的名称</param> /// <param name="contentType">文件类型</param> /// <param name="size">文件大小</param> /// <param name="userId"></param> /// <returns></returns> public bool AddAttachment(int objType, long objId, int typeId, string title, string attLink, string fileName, string fileSaveName, string contentType, int size, long userId, string pubTypeId = "") { com_attachment att = new com_attachment(); att.object_type_id = objType; att.object_id = objId; // 备注和附件的下级备注和附件不能再添加附件 if (objType == (int)DicEnum.ATTACHMENT_OBJECT_TYPE.NOTES) { var note = new com_activity_dal().FindById(objId); if (note.object_type_id == (int)DicEnum.OBJECT_TYPE.NOTES) { att.object_type_id = (int)DicEnum.ATTACHMENT_OBJECT_TYPE.NOTES; att.object_id = note.object_id; } else if (note.object_type_id == (int)DicEnum.OBJECT_TYPE.ATTACHMENT) { att.object_type_id = (int)DicEnum.ATTACHMENT_OBJECT_TYPE.ATTACHMENT; att.object_id = note.object_id; } } else if (objType == (int)DicEnum.ATTACHMENT_OBJECT_TYPE.ATTACHMENT) { var attachment = dal.FindById(objId); if (attachment.object_type_id == (int)DicEnum.ATTACHMENT_OBJECT_TYPE.NOTES) { att.object_type_id = (int)DicEnum.ATTACHMENT_OBJECT_TYPE.NOTES; att.object_id = attachment.object_id; } else if (attachment.object_type_id == (int)DicEnum.ATTACHMENT_OBJECT_TYPE.ATTACHMENT) { att.object_type_id = (int)DicEnum.ATTACHMENT_OBJECT_TYPE.ATTACHMENT; att.object_id = attachment.object_id; } } else if (objType == (int)DicEnum.ATTACHMENT_OBJECT_TYPE.LABOUR) { var labour = new sdk_work_entry_dal().FindById(objId); if (labour.parent_id != null) { att.object_type_id = (int)DicEnum.ATTACHMENT_OBJECT_TYPE.LABOUR; att.object_id = (long)labour.parent_id; } else if (labour.parent_attachment_id != null) { att.object_type_id = (int)DicEnum.ATTACHMENT_OBJECT_TYPE.ATTACHMENT; att.object_id = (long)labour.parent_attachment_id; } else if (labour.parent_note_id != null) { att.object_type_id = (int)DicEnum.ATTACHMENT_OBJECT_TYPE.NOTES; att.object_id = (long)labour.parent_note_id; } } if (att.object_type_id == (int)DicEnum.ATTACHMENT_OBJECT_TYPE.ATTACHMENT) { var attachment = dal.FindById(att.object_id); att.account_id = attachment.account_id; att.parent_id = attachment.id; } else if (att.object_type_id == (int)DicEnum.ATTACHMENT_OBJECT_TYPE.NOTES) { var note = new com_activity_dal().FindById(att.object_id); att.account_id = note.account_id; } else if (att.object_type_id == (int)DicEnum.ATTACHMENT_OBJECT_TYPE.OPPORTUNITY) { var opp = new crm_opportunity_dal().FindById(att.object_id); att.account_id = opp.account_id; } else if (att.object_type_id == (int)DicEnum.ATTACHMENT_OBJECT_TYPE.SALES_ORDER) { var so = new crm_sales_order_dal().FindById(att.object_id); var opp = new crm_opportunity_dal().FindById(so.opportunity_id); att.account_id = opp.account_id; } else if (att.object_type_id == (int)DicEnum.ATTACHMENT_OBJECT_TYPE.CONTRACT) { var contract = new ctt_contract_dal().FindById(att.object_id); att.account_id = contract.account_id; } else if (att.object_type_id == (int)DicEnum.ATTACHMENT_OBJECT_TYPE.COMPANY) { att.account_id = att.object_id; } else if (att.object_type_id == (int)DicEnum.ATTACHMENT_OBJECT_TYPE.PROJECT) { var project = new pro_project_dal().FindNoDeleteById(att.object_id); att.account_id = project.account_id; } else if (att.object_type_id == (int)DicEnum.ATTACHMENT_OBJECT_TYPE.EXPENSE_REPORT) { // 从报表添加附件 - 默认使用声联(oid=0) 的客户 var defaultAccount = new CompanyBLL().GetDefaultAccount(); att.account_id = defaultAccount.id; } else if (att.object_type_id == (int)DicEnum.ATTACHMENT_OBJECT_TYPE.TASK) { var task = new sdk_task_dal().FindNoDeleteById(att.object_id); if (task != null) { att.account_id = task.account_id; #region 更新客户最后活动时间 crm_account thisAccount = new CompanyBLL().GetCompany(task.account_id); if (thisAccount != null) { thisAccount.last_activity_time = Tools.Date.DateHelper.ToUniversalTimeStamp(DateTime.Now); new CompanyBLL().EditAccount(thisAccount, userId); } #endregion } if (!string.IsNullOrEmpty(pubTypeId)) { att.publish_type_id = int.Parse(pubTypeId); } } else if (att.object_type_id == (int)DicEnum.ATTACHMENT_OBJECT_TYPE.LABOUR) { var labour = new sdk_work_entry_dal().FindNoDeleteById(att.object_id); if (labour == null) { return(false); } var ticket = new sdk_task_dal().FindNoDeleteById(labour.task_id); if (ticket == null) { return(false); } att.account_id = ticket.account_id; } else if (att.object_type_id == (int)DicEnum.ATTACHMENT_OBJECT_TYPE.KNOWLEDGE) { var thisArt = new sdk_kb_article_dal().FindNoDeleteById(att.object_id); if (thisArt == null) { return(false); } att.account_id = thisArt.account_id; } else if (att.object_type_id == (int)DicEnum.ATTACHMENT_OBJECT_TYPE.RESOURCE) { } else if (att.object_type_id == (int)DicEnum.ATTACHMENT_OBJECT_TYPE.CONFIGITEM) { crm_installed_product insPro = new crm_installed_product_dal().FindNoDeleteById(att.object_id); if (insPro == null) { return(false); } att.account_id = insPro.account_id; } else { return(false); } att.id = dal.GetNextIdCom(); att.create_time = Tools.Date.DateHelper.ToUniversalTimeStamp(); att.create_user_id = userId; att.update_time = att.create_time; att.update_user_id = userId; att.title = title; att.type_id = typeId; if (typeId == (int)DicEnum.ATTACHMENT_TYPE.FILE_LINK || typeId == (int)DicEnum.ATTACHMENT_TYPE.FOLDER_LINK) { att.uncpath = attLink; att.filename = @"file://" + attLink; } else if (typeId == (int)DicEnum.ATTACHMENT_TYPE.URL) { if (attLink.IndexOf(@"http://") == 0) { attLink = attLink.Remove(0, 7); att.urlpath = attLink; att.filename = @"http://" + attLink; } else if (attLink.IndexOf(@"https://") == 0) { attLink = attLink.Remove(0, 8); att.urlpath = attLink; att.filename = @"https://" + attLink; } else { att.urlpath = attLink; att.filename = @"http://" + attLink; } } else if (typeId == (int)DicEnum.ATTACHMENT_TYPE.ATTACHMENT) { att.href = fileSaveName; att.filename = fileName; att.sizeinbyte = size; att.content_type = contentType; } else { return(false); } dal.Insert(att); OperLogBLL.OperLogAdd <com_attachment>(att, att.id, userId, DicEnum.OPER_LOG_OBJ_CATE.ATTACHMENT, "新增附件"); return(true); }
protected void Page_Load(object sender, EventArgs e) { 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); thisTicket = stDal.FindNoDeleteById(thisNote.object_id); if (thisTicket != null) { object_id = thisTicket.id; } else { thisProject = ppDal.FindNoDeleteById(thisNote.object_id); if (thisProject != null) { object_id = thisProject.id; thisAccount = accDal.FindNoDeleteById(thisProject.account_id); } else { thisContract = ccDal.FindNoDeleteById(thisNote.object_id); if (thisContract != null) { object_id = thisContract.id; thisAccount = accDal.FindNoDeleteById(thisContract.account_id); } } } } } var ticketId = Request.QueryString["ticket_id"]; if (!string.IsNullOrEmpty(ticketId)) { thisTicket = stDal.FindNoDeleteById(long.Parse(ticketId)); } if (thisTicket != null) { object_id = thisTicket.id; if (thisTicket.type_id == (int)DicEnum.TASK_TYPE.PROJECT_PHASE) { // isPhase = true; } if (thisTicket.contact_id != null) { thisContact = new crm_contact_dal().FindNoDeleteById((long)thisTicket.contact_id); } thisAccount = accDal.FindNoDeleteById(thisTicket.account_id); ticket_creator = new sys_resource_dal().FindNoDeleteById(thisTicket.create_user_id); if (!IsPostBack) { //status_id.SelectedValue = thisTicket.status_id.ToString(); } if (thisTicket.project_id != null) { thisProject = ppDal.FindNoDeleteById((long)thisTicket.project_id); if (thisProject != null && thisAccount != null) { thisAccount = accDal.FindNoDeleteById(thisProject.account_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) { pushList = pushList.Where(_ => _.ext2 == ((int)DicEnum.ACTIVITY_CATE.TICKET_NOTE).ToString()).ToList(); } publish_type_id.DataSource = pushList; publish_type_id.DataBind(); status_id.DataTextField = "show"; status_id.DataValueField = "val"; status_id.DataSource = dic.FirstOrDefault(_ => _.Key == "ticket_status").Value; status_id.DataBind(); 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); 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(); } } //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(); } }
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(); } }
/// <summary> /// 取消配送 /// </summary> /// <param name="costPdtIds">成本产品id</param> /// <param name="userId"></param> /// <returns></returns> public string PurchaseUnShip(string costPdtIds, long userId) { ctt_contract_cost_product_dal cstPdtDal = new ctt_contract_cost_product_dal(); var pdtList = cstPdtDal.FindListBySql <ctt_contract_cost_product>($"select * from ctt_contract_cost_product where id in({costPdtIds})"); if (pdtList == null || pdtList.Count == 0) { return(""); } ctt_contract_cost_dal costDal = new ctt_contract_cost_dal(); ivt_transfer_dal tsfDal = new ivt_transfer_dal(); ctt_contract_dal cttDal = new ctt_contract_dal(); pro_project_dal proDal = new pro_project_dal(); sdk_task_dal tskDal = new sdk_task_dal(); ivt_warehouse_product_sn_dal lctPdtSnDal = new ivt_warehouse_product_sn_dal(); ivt_transfer_sn_dal tsfSnDal = new ivt_transfer_sn_dal(); foreach (var pdt in pdtList) { // 修改成本产品状态 var pdtOld = cstPdtDal.FindById(pdt.id); pdt.status_id = (int)DicEnum.CONTRACT_COST_PRODUCT_STATUS.PENDING_DISTRIBUTION; pdt.update_time = Tools.Date.DateHelper.ToUniversalTimeStamp(); pdt.shipping_time = null; pdt.update_user_id = userId; cstPdtDal.Update(pdt); OperLogBLL.OperLogUpdate(OperLogBLL.CompareValue <ctt_contract_cost_product>(pdtOld, pdt), pdt.id, userId, DicEnum.OPER_LOG_OBJ_CATE.CTT_CONTRACT_COST_PRODUCT, "成本产品配送"); // 修改成本状态 var cost = costDal.FindById(pdt.contract_cost_id); if (cost.status_id == (int)DicEnum.COST_STATUS.ALREADY_DELIVERED) { var costOld = costDal.FindById(pdt.contract_cost_id); cost.status_id = (int)DicEnum.COST_STATUS.PENDING_DELIVERY; cost.update_time = Tools.Date.DateHelper.ToUniversalTimeStamp(); cost.update_user_id = userId; costDal.Update(cost); OperLogBLL.OperLogUpdate(OperLogBLL.CompareValue <ctt_contract_cost>(costOld, cost), cost.id, userId, DicEnum.OPER_LOG_OBJ_CATE.CONTRACT_COST, "取消配送修改成本状态"); } // 新建库存转移信息 ivt_transfer tsf = new ivt_transfer(); tsf.id = tsfDal.GetNextIdCom(); tsf.update_time = Tools.Date.DateHelper.ToUniversalTimeStamp(); tsf.update_user_id = userId; tsf.create_time = tsf.update_time; tsf.create_user_id = userId; tsf.type_id = (int)DicEnum.INVENTORY_TRANSFER_TYPE.PROJECT; tsf.product_id = (long)cost.product_id; tsf.quantity = 0 - pdt.quantity; if (cost.contract_id != null) { tsf.to_account_id = cttDal.FindById((long)cost.contract_id).account_id; } else if (cost.project_id != null) { tsf.to_account_id = proDal.FindById((long)cost.project_id).account_id; } else if (cost.task_id != null) { tsf.to_account_id = tskDal.FindById((long)cost.task_id).account_id; } tsf.to_contract_id = cost.contract_id; tsf.to_project_id = cost.project_id; tsf.to_task_id = cost.task_id; tsf.from_warehouse_id = (long)pdt.warehouse_id; tsfDal.Insert(tsf); OperLogBLL.OperLogAdd <ivt_transfer>(tsf, tsf.id, userId, DicEnum.OPER_LOG_OBJ_CATE.INVENTORY_ITEM_TRANSFER, "取消配送新建库存转移"); // 保存库存数修改 var lctPdt = dal.FindSignleBySql <ivt_warehouse_product>($"select * from ivt_warehouse_product where product_id={cost.product_id} and warehouse_id={(long)pdt.warehouse_id} and delete_time=0"); if (lctPdt != null) { var lctPdtOld = dal.FindById(lctPdt.id); lctPdt.quantity = lctPdt.quantity + pdt.quantity; lctPdt.update_time = Tools.Date.DateHelper.ToUniversalTimeStamp(); lctPdt.update_user_id = userId; dal.Update(lctPdt); OperLogBLL.OperLogUpdate(OperLogBLL.CompareValue <ivt_warehouse_product>(lctPdtOld, lctPdt), lctPdt.id, userId, DicEnum.OPER_LOG_OBJ_CATE.INVENTORY_ITEM, "修改库存产品库存数"); var sns = costDal.FindListBySql <string>($"select sn from ctt_contract_cost_product_sn where contract_cost_product_id={pdt.id} and delete_time=0"); if (sns == null || sns.Count == 0) { continue; } foreach (var sn in sns) { ivt_warehouse_product_sn lctPdtSn = new ivt_warehouse_product_sn(); lctPdtSn.id = lctPdtSnDal.GetNextIdCom(); lctPdtSn.create_time = Tools.Date.DateHelper.ToUniversalTimeStamp(); lctPdtSn.create_user_id = userId; lctPdtSn.update_time = lctPdtSn.create_time; lctPdtSn.update_user_id = userId; lctPdtSn.warehouse_product_id = lctPdt.id; lctPdtSn.sn = sn; lctPdtSnDal.Insert(lctPdtSn); OperLogBLL.OperLogAdd <ivt_warehouse_product_sn>(lctPdtSn, lctPdtSn.id, userId, DicEnum.OPER_LOG_OBJ_CATE.INVENTORY_ITEM_SN, "取消配送产品新增库存产品串号"); ivt_transfer_sn tsfSn = new ivt_transfer_sn(); tsfSn.id = tsfSnDal.GetNextIdCom(); tsfSn.sn = sn; tsfSn.transfer_id = tsf.id; tsfSn.create_time = Tools.Date.DateHelper.ToUniversalTimeStamp(); tsfSn.create_user_id = userId; tsfSn.update_time = tsfSn.create_time; tsfSn.update_user_id = userId; tsfSnDal.Insert(tsfSn); OperLogBLL.OperLogAdd <ivt_transfer_sn>(tsfSn, tsfSn.id, userId, DicEnum.OPER_LOG_OBJ_CATE.INVENTORY_ITEM_TRANSFER_SN, "取消配送产品新增转移产品串号"); } } } return(""); }
/// <summary> /// 配送 /// </summary> /// <param name="costPdtIds">成本产品id</param> /// <param name="isEditSaleOrder">是否修改销售订单状态</param> /// <param name="userId"></param> /// <returns></returns> public string PurchaseShip(string costPdtIds, bool isEditSaleOrder, long userId) { ctt_contract_cost_product_dal cstPdtDal = new ctt_contract_cost_product_dal(); var pdtList = cstPdtDal.FindListBySql <ctt_contract_cost_product>($"select * from ctt_contract_cost_product where id in({costPdtIds})"); if (pdtList == null || pdtList.Count == 0) { return(""); } foreach (var pdt in pdtList) { if (pdt.status_id != (int)DicEnum.CONTRACT_COST_PRODUCT_STATUS.PENDING_DISTRIBUTION) { return("状态为“待配送”的成本产品才能配送"); } } ctt_contract_cost_dal costDal = new ctt_contract_cost_dal(); ivt_transfer_dal tsfDal = new ivt_transfer_dal(); ctt_contract_dal cttDal = new ctt_contract_dal(); pro_project_dal proDal = new pro_project_dal(); sdk_task_dal tskDal = new sdk_task_dal(); ivt_warehouse_product_sn_dal lctPdtSnDal = new ivt_warehouse_product_sn_dal(); ivt_transfer_sn_dal tsfSnDal = new ivt_transfer_sn_dal(); foreach (var pdt in pdtList) { var pdtOld = cstPdtDal.FindById(pdt.id); pdt.status_id = (int)DicEnum.CONTRACT_COST_PRODUCT_STATUS.DISTRIBUTION; pdt.update_time = Tools.Date.DateHelper.ToUniversalTimeStamp(); pdt.shipping_time = pdt.update_time; pdt.update_user_id = userId; cstPdtDal.Update(pdt); OperLogBLL.OperLogUpdate(OperLogBLL.CompareValue <ctt_contract_cost_product>(pdtOld, pdt), pdt.id, userId, DicEnum.OPER_LOG_OBJ_CATE.CTT_CONTRACT_COST_PRODUCT, "成本产品配送"); var cost = costDal.FindById(pdt.contract_cost_id); var cnt = dal.FindSignleBySql <int>($"select count(0) from ctt_contract_cost_product where contract_cost_id={pdt.contract_cost_id} and status_id<>{(int)DicEnum.CONTRACT_COST_PRODUCT_STATUS.DISTRIBUTION} and delete_time=0"); if (cnt == 0) // 产品全部已配送,修改成本状态 { var costOld = costDal.FindById(pdt.contract_cost_id); cost.status_id = (int)DicEnum.COST_STATUS.ALREADY_DELIVERED; cost.update_time = Tools.Date.DateHelper.ToUniversalTimeStamp(); cost.update_user_id = userId; costDal.Update(cost); OperLogBLL.OperLogUpdate(OperLogBLL.CompareValue <ctt_contract_cost>(costOld, cost), cost.id, userId, DicEnum.OPER_LOG_OBJ_CATE.CONTRACT_COST, "修改成本状态已配送"); } ivt_transfer transfer = new ivt_transfer(); transfer.id = tsfDal.GetNextIdCom(); transfer.create_time = Tools.Date.DateHelper.ToUniversalTimeStamp(); transfer.create_user_id = userId; transfer.update_time = transfer.create_time; transfer.update_user_id = userId; transfer.product_id = (long)cost.product_id; transfer.type_id = (int)DicEnum.INVENTORY_TRANSFER_TYPE.PROJECT; transfer.from_warehouse_id = (long)pdt.warehouse_id; transfer.quantity = pdt.quantity; if (cost.contract_id != null) { transfer.to_account_id = cttDal.FindById((long)cost.contract_id).account_id; } else if (cost.project_id != null) { transfer.to_account_id = proDal.FindById((long)cost.project_id).account_id; } else if (cost.task_id != null) { transfer.to_account_id = tskDal.FindById((long)cost.task_id).account_id; } transfer.to_contract_id = cost.contract_id; transfer.to_project_id = cost.project_id; transfer.to_task_id = cost.task_id; tsfDal.Insert(transfer); OperLogBLL.OperLogAdd <ivt_transfer>(transfer, transfer.id, userId, DicEnum.OPER_LOG_OBJ_CATE.INVENTORY_ITEM_TRANSFER, "产品配送转移库存"); // 保存库存数修改 var lctPdt = dal.FindSignleBySql <ivt_warehouse_product>($"select * from ivt_warehouse_product where product_id={cost.product_id} and warehouse_id={(long)pdt.warehouse_id} and delete_time=0"); if (lctPdt != null) { var lctPdtOld = dal.FindById(lctPdt.id); lctPdt.quantity = lctPdt.quantity - pdt.quantity; lctPdt.update_time = Tools.Date.DateHelper.ToUniversalTimeStamp(); lctPdt.update_user_id = userId; dal.Update(lctPdt); OperLogBLL.OperLogUpdate(OperLogBLL.CompareValue <ivt_warehouse_product>(lctPdtOld, lctPdt), lctPdt.id, userId, DicEnum.OPER_LOG_OBJ_CATE.INVENTORY_ITEM, "修改库存产品库存数"); var sns = costDal.FindListBySql <string>($"select sn from ctt_contract_cost_product_sn where contract_cost_product_id={pdt.id} and delete_time=0"); if (sns == null || sns.Count == 0) { continue; } foreach (var sn in sns) { var lctPdtSn = lctPdtSnDal.FindSignleBySql <ivt_warehouse_product_sn>($"select * from ivt_warehouse_product_sn where sn='{sn}' and warehouse_product_id={lctPdt.id}"); lctPdtSn.delete_time = Tools.Date.DateHelper.ToUniversalTimeStamp(); lctPdtSn.delete_user_id = userId; lctPdtSnDal.Update(lctPdtSn); OperLogBLL.OperLogDelete <ivt_warehouse_product_sn>(lctPdtSn, lctPdtSn.id, userId, DicEnum.OPER_LOG_OBJ_CATE.INVENTORY_ITEM_SN, "配送产品删除库存产品串号"); ivt_transfer_sn tsfSn = new ivt_transfer_sn(); tsfSn.id = tsfSnDal.GetNextIdCom(); tsfSn.sn = sn; tsfSn.transfer_id = transfer.id; tsfSn.create_time = Tools.Date.DateHelper.ToUniversalTimeStamp(); tsfSn.create_user_id = userId; tsfSn.update_time = tsfSn.create_time; tsfSn.update_user_id = userId; tsfSnDal.Insert(tsfSn); OperLogBLL.OperLogAdd <ivt_transfer_sn>(tsfSn, tsfSn.id, userId, DicEnum.OPER_LOG_OBJ_CATE.INVENTORY_ITEM_TRANSFER_SN, "配送产品新增转移产品串号"); } } } return(""); }
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(); } }
public ERROR_CODE CloseQuote(long user_id, QuoteCloseDto param) { // 此向导将会把产品、一次性折扣、配送、成本转为计费项。可选项和费用不会被转换。如果有产品,会生成销售订单。 // 报价中如果有服务 / 包或初始费用,将不会被转换为计费项,也不会创建定期服务合同 // 如果商机状态已经是“关闭”或“已实施”,将会为此商机生成重复的计费项。 // 报价项中如果有物料代码为空的,则需要设置。如果没有需要配置的,则此界面不显示 // 计费项将会生成,是否需要创建发票 // 打开新建的销售订单(链接)——如果创建了销售单才显示 // 关闭报价是关闭商机的另一种方式, // -- 必填项校验-- 根据系统设置来判断 TODO var user = UserInfoBLL.GetUserInfo(user_id); // 1.更新商机信息 #region 1.更新商机信息 // 根据系统设置来选择商机的阶段-- todo param.opportunity.status_id = (int)DicEnum.OPPORTUNITY_STATUS.CLOSED; var stageList = new d_general_dal().GetGeneralByTableId((int)GeneralTableEnum.OPPORTUNITY_STATUS); var defaultStage = stageList.FirstOrDefault(_ => _.ext1 == "1"); if (defaultStage != null) { param.opportunity.stage_id = defaultStage.id; } var old_opportunity = new crm_opportunity_dal().GetOpportunityById(param.opportunity.id); new crm_opportunity_dal().Update(param.opportunity); new sys_oper_log_dal().Insert(new sys_oper_log() { user_cate = "用户", user_id = user_id, name = user.name, phone = user.mobile == null ? "" : user.mobile, oper_time = Tools.Date.DateHelper.ToUniversalTimeStamp(DateTime.Now), oper_object_cate_id = (int)OPER_LOG_OBJ_CATE.OPPORTUNITY, oper_object_id = param.opportunity.id,// 操作对象id oper_type_id = (int)OPER_LOG_TYPE.UPDATE, oper_description = _dal.CompareValue(old_opportunity, param.opportunity), remark = "修改商机信息" }); #endregion // 2.更新客户信息 #region 2.更新客户信息 var account = new CompanyBLL().GetCompany(param.quote.account_id); if (account.type_id != (int)DicEnum.ACCOUNT_TYPE.CUSTOMER) { account.type_id = (int)DicEnum.ACCOUNT_TYPE.CUSTOMER; new crm_account_dal().Update(account); new sys_oper_log_dal().Insert(new sys_oper_log() { user_cate = "用户", user_id = user_id, name = user.name, phone = user.mobile == null ? "" : user.mobile, oper_time = Tools.Date.DateHelper.ToUniversalTimeStamp(DateTime.Now), oper_object_cate_id = (int)OPER_LOG_OBJ_CATE.CUSTOMER, oper_object_id = param.quote.account_id,// 操作对象id oper_type_id = (int)OPER_LOG_TYPE.UPDATE, oper_description = _dal.CompareValue(new CompanyBLL().GetCompany(param.quote.account_id), account), remark = "修改客户信息" }); } #endregion long?contact_id = null; if (param.opportunity.contact_id != null) { crm_contact contact = new ContactBLL().GetContact((long)param.opportunity.contact_id); if (contact.is_active == 1) { contact_id = contact.id; } } // 3.保存项目信息 #region 3.如果项目关联了项目提案,修改项目提案信息 if (param.quote.project_id != null) { var project = new pro_project_dal().GetProjectById((long)param.quote.project_id); if (project != null) { if (project.type_id != (int)PROJECT_TYPE.ACCOUNT_PROJECT) { project.type_id = (int)PROJECT_TYPE.ACCOUNT_PROJECT; project.update_time = Tools.Date.DateHelper.ToUniversalTimeStamp(DateTime.Now); project.update_user_id = user.id; new sys_oper_log_dal().Insert(new sys_oper_log() { user_cate = "用户", user_id = (int)user.id, name = user.name, phone = user.mobile == null ? "" : user.mobile, oper_time = Tools.Date.DateHelper.ToUniversalTimeStamp(DateTime.Now), oper_object_cate_id = (int)OPER_LOG_OBJ_CATE.PROJECT, oper_object_id = project.id,// 操作对象id oper_type_id = (int)OPER_LOG_TYPE.UPDATE, oper_description = _dal.CompareValue(new pro_project_dal().GetProjectById((long)param.quote.project_id), project), remark = "修改项目提案类型" }); new pro_project_dal().Update(project); } param.project_id = project.id; } string costIds = ""; new OpportunityBLL().InsertContract(param.dic, param.opportunity, user, null, out costIds, param.project_id, null); if (!string.IsNullOrEmpty(costIds)) { var aapBLL = new ApproveAndPostBLL(); costIds = costIds.Substring(0, costIds.Length - 1); var costList = costIds.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries); foreach (var costId in costList) { // 审批并提交 aapBLL.Post_Charges(int.Parse(costId), int.Parse(DateTime.Now.ToString("yyyyMMdd")), user); } } } #endregion // 4.新增工单信息 #region 4.如果报价未关联项目提案,有需要转换的计费项 // todo 关联sdk_ticket #endregion // 5.转换为工单/项目成本 #region 5.转换为工单/项目成本 // todo 关联sdk_ticket_charge // 一次性折扣根据需要拆分为两行——收税的、不收税的,分别计算折扣额。计算时仍然按照全部周期为一次性的报价项,而不是排除了服务和工时等报价项。 #endregion // 将报价项转换为计费项 #region 将报价项转换为计费项并审批提交 todo-需要项目ID 或者工单ID才可以进行操作 //string costIds =""; //new OpportunityBLL().InsertContract(param.dic,param.opportunity,user,null,out costIds, param.project_id,null); //if (!string.IsNullOrEmpty(costIds)) //{ // var aapBLL = new ApproveAndPostBLL(); // costIds = costIds.Substring(0,costIds.Length-1); // var costList = costIds.Split(new char[] { ','},StringSplitOptions.RemoveEmptyEntries); // foreach (var costId in costList) // { // // 审批并提交 // aapBLL.Post_Charges(int.Parse(costId),int.Parse(DateTime.Now.ToString("yyyyMMdd")),user); // } //} #endregion // 6.新增销售订单 #region 6.当有产品/一次性折扣、成本、配送转为计费项时,销售订单就会自动生成。Crm_sales_order if (param.dic != null && param.dic.Count > 0) { var saleOrder = new crm_sales_order_dal().GetSingleSalesOrderByWhere($" and opportunity_id = {param.opportunity.id} "); if (saleOrder == null) { saleOrder = new crm_sales_order() { id = _dal.GetNextIdCom(), opportunity_id = param.opportunity.id, status_id = (int)SALES_ORDER_STATUS.OPEN, contact_id = contact_id, owner_resource_id = param.opportunity.resource_id, begin_date = DateTime.Now, create_user_id = user.id, update_user_id = user.id, create_time = Tools.Date.DateHelper.ToUniversalTimeStamp(DateTime.Now), update_time = Tools.Date.DateHelper.ToUniversalTimeStamp(DateTime.Now), }; new crm_sales_order_dal().Insert(saleOrder); new sys_oper_log_dal().Insert(new sys_oper_log() { user_cate = "用户", user_id = (int)user.id, name = user.name, phone = user.mobile == null ? "" : user.mobile, oper_time = Tools.Date.DateHelper.ToUniversalTimeStamp(DateTime.Now), oper_object_cate_id = (int)OPER_LOG_OBJ_CATE.SALE_ORDER, oper_object_id = saleOrder.id,// 操作对象id oper_type_id = (int)OPER_LOG_TYPE.ADD, oper_description = _dal.AddValue(saleOrder), remark = "关闭报价,新增销售订单" }); param.saleOrderId = saleOrder.id; } } #endregion // 7.新增项目备注 #region 7.转为项目计费项时,会生成备注 if (param.quote.project_id != null) { com_activity addActivity = new com_activity() { id = _dal.GetNextIdCom(), cate_id = (int)ACTIVITY_CATE.PROJECT_NOTE, action_type_id = (int)ACTIVITY_TYPE.PROJECT_NOTE, parent_id = null, object_id = (long)param.quote.project_id, object_type_id = (int)OBJECT_TYPE.PROJECT, // todo发布范围 account_id = param.opportunity.account_id, contact_id = contact_id, resource_id = param.opportunity.resource_id, contract_id = contact_id, opportunity_id = param.opportunity.id, ticket_id = null, // todo 标题 description = $"", // todo 内容描述拼接 status_id = null, complete_description = null, complete_time = null, create_user_id = user.id, create_time = Tools.Date.DateHelper.ToUniversalTimeStamp(DateTime.Now), update_user_id = user.id, update_time = Tools.Date.DateHelper.ToUniversalTimeStamp(DateTime.Now), is_system_generate = 1, }; new com_activity_dal().Insert(addActivity); new sys_oper_log_dal().Insert(new sys_oper_log() { user_cate = "用户", user_id = (int)user.id, name = user.name, phone = user.mobile == null ? "" : user.mobile, oper_time = Tools.Date.DateHelper.ToUniversalTimeStamp(DateTime.Now), oper_object_cate_id = (int)OPER_LOG_OBJ_CATE.ACTIVITY, oper_object_id = addActivity.id,// 操作对象id oper_type_id = (int)OPER_LOG_TYPE.ADD, oper_description = _dal.AddValue(addActivity), remark = "商机关闭,新增项目备注" }); } #endregion // 8.新增备注(商机关闭) #region 8.商机关闭时,会自动生成备注 com_activity closeOppoActivity = new com_activity() { id = _dal.GetNextIdCom(), cate_id = (int)ACTIVITY_CATE.NOTE, action_type_id = (int)ACTIVITY_TYPE.OPPORTUNITYUPDATE, parent_id = null, object_id = param.opportunity.id, object_type_id = (int)OBJECT_TYPE.OPPORTUNITY, account_id = param.opportunity.account_id, contact_id = contact_id, resource_id = param.opportunity.resource_id, contract_id = null, // todo 如果转为合同成本,则为“合同”;否则为空 opportunity_id = param.opportunity.id, ticket_id = null, start_date = Tools.Date.DateHelper.ToUniversalTimeStamp(DateTime.Parse(DateTime.Now.ToShortDateString() + " 12:00:00")), // todo 从页面获取时间,去页面时间的12:00:00 end_date = Tools.Date.DateHelper.ToUniversalTimeStamp(DateTime.Parse(DateTime.Now.ToShortDateString() + " 12:00:00")), description = $"关闭时间:{DateTime.Now.ToString("dd/MM/yyyy")}/r通知人:{user.email}/r主题:{param.opportunity.name}已经关闭/r内容:商机关闭向导定义", // todo 内容描述拼接 status_id = null, complete_description = null, complete_time = null, create_user_id = user.id, create_time = Tools.Date.DateHelper.ToUniversalTimeStamp(DateTime.Now), update_user_id = user.id, update_time = Tools.Date.DateHelper.ToUniversalTimeStamp(DateTime.Now), is_system_generate = 1, }; new com_activity_dal().Insert(closeOppoActivity); new sys_oper_log_dal().Insert(new sys_oper_log() { user_cate = "用户", user_id = (int)user.id, name = user.name, phone = user.mobile == null ? "" : user.mobile, oper_time = Tools.Date.DateHelper.ToUniversalTimeStamp(DateTime.Now), oper_object_cate_id = (int)OPER_LOG_OBJ_CATE.ACTIVITY, oper_object_id = closeOppoActivity.id,// 操作对象id oper_type_id = (int)OPER_LOG_TYPE.ADD, oper_description = _dal.AddValue(closeOppoActivity), remark = "新增关闭商机的备注" }); #endregion return(ERROR_CODE.SUCCESS); }