/// <summary> /// 页面数据绑定 /// </summary> private void PageDataBind() { var cateList = new d_cost_code_dal().GetListCostCode((int)DicEnum.COST_CODE_CATE.EXPENSE_CATEGORY); expense_cost_code_id.DataTextField = "name"; expense_cost_code_id.DataValueField = "id"; expense_cost_code_id.DataSource = cateList; expense_cost_code_id.DataBind(); var workList = new d_cost_code_dal().GetListCostCode((int)DicEnum.COST_CODE_CATE.GENERAL_ALLOCATION_CODE); cost_code_id.DataTextField = "name"; cost_code_id.DataValueField = "id"; cost_code_id.DataSource = workList; cost_code_id.DataBind(); var payTypeList = new d_general_dal().GetGeneralByTableId((int)GeneralTableEnum.PAYMENT_TYPE); payment_type_id.DataTextField = "name"; payment_type_id.DataValueField = "id"; payment_type_id.DataSource = payTypeList; payment_type_id.DataBind(); RDAddRep.Checked = true; rbAssProTask.Checked = true; }
/// <summary> /// 根据部门获取相对应的工作类型 /// </summary> private void GetWorkType(HttpContext context, long department_id) { var dccDal = new d_cost_code_dal(); var workTypeList = dccDal.GetCostCodeByWhere((int)DicEnum.COST_CODE_CATE.GENERAL_ALLOCATION_CODE, " and department_id =" + department_id); StringBuilder workTypeString = new StringBuilder(); workTypeString.Append("<option value='0'> </option>"); if (workTypeList != null && workTypeList.Count > 0) { foreach (var workType in workTypeList) { string billed = workType.show_on_invoice == (int)DicEnum.SHOW_ON_INVOICE.SHOW_DISBILLED ? "" : "(不计费)"; workTypeString.Append($"<option value='{workType.id}'>{workType.name}{billed}</option>"); } } var thisSet = new SysSettingBLL().GetSetById(SysSettingEnum.ALL_USER_ASSIGN_NODE_TOTAASL); if (thisSet != null && thisSet.setting_value == "1") { var noDepWorkTypeList = dccDal.GetCostCodeByWhere((int)DicEnum.COST_CODE_CATE.GENERAL_ALLOCATION_CODE, " and department_id is null"); if (noDepWorkTypeList != null && noDepWorkTypeList.Count > 0) { workTypeString.Append("<option value='0'>--------</option>"); foreach (var workType in noDepWorkTypeList) { string billed = workType.show_on_invoice == (int)DicEnum.SHOW_ON_INVOICE.SHOW_DISBILLED ? "" : "(不计费)"; workTypeString.Append($"<option value='{workType.id}'>{workType.name}{billed}</option>"); } } } context.Response.Write(workTypeString.ToString()); }
/// <summary> /// 获取工时可选的工作类型,排除年休假、私人时间、浮动时间三项 /// </summary> /// <returns></returns> public List <d_cost_code> GetTimeCostCodeList() { var list = new d_cost_code_dal().GetListCostCode((int)DicEnum.COST_CODE_CATE.INTERNAL_ALLOCATION_CODE); list = (from code in list where code.id != 25 && code.id != 35 && code.id != 27 select code).ToList(); return(list); }
/// <summary> /// 根据物料成本ID返回物料成本信息 /// </summary> /// <param name="context"></param> /// <param name="id"></param> public void RetuenCostCode(HttpContext context, long id) { var cost_code = new d_cost_code_dal().GetSingleCostCode(id); if (cost_code != null) { context.Response.Write(new EMT.Tools.Serialize().SerializeJson(cost_code)); } }
/// <summary> /// 根据类型获取相应的物料代码 /// </summary> private void GetCostCodeByType(HttpContext context, int type_id) { var codeList = new d_cost_code_dal().GetListCostCode(type_id); if (codeList != null && codeList.Count > 0) { context.Response.Write(new Tools.Serialize().SerializeJson(codeList)); } }
/// <summary> /// 根据ID 集合获取相应的服务信息 /// </summary> public void GetServicesByIds(HttpContext context) { var serviceIds = context.Request.QueryString["ids"]; if (!string.IsNullOrEmpty(serviceIds)) { var serList = new ivt_service_dal().GetServiceList($" and id in({serviceIds})"); if (serList != null && serList.Count > 0) { List <ServiceDto> serDtoList = new List <ServiceDto>(); var accBll = new CompanyBLL(); var dDal = new d_general_dal(); var dccDal = new d_cost_code_dal(); serList.ForEach(_ => { var thisDto = new ServiceDto() { id = _.id, name = _.name, description = _.description, unit_cost = (_.unit_cost ?? 0), unit_price = (_.unit_price ?? 0), cost_code_id = _.cost_code_id, period_type_id = _.period_type_id, vendor_id = _.vendor_account_id, }; if (_.vendor_account_id != null) { var thisVendor = accBll.GetCompany((long)_.vendor_account_id); if (thisVendor != null) { thisDto.vendor_name = thisVendor.name; } } if (_.period_type_id != null) { var thisType = dDal.FindNoDeleteById((long)_.period_type_id); if (thisType != null) { thisDto.period_type_name = thisType.name; } } var thisCode = dccDal.FindNoDeleteById(_.cost_code_id); if (thisCode != null) { thisDto.cost_code_name = thisCode.name; } serDtoList.Add(thisDto); }); context.Response.Write(new EMT.Tools.Serialize().SerializeJson(serDtoList)); } } }
/// <summary> /// 根据 物料代码Id 和 角色ID返回相关费率 /// </summary> public decimal?GetRateByCodeAndRole(long cost_code_id, long role_id) { decimal?rate = null; var dccDal = new d_cost_code_dal(); var srDal = new sys_role_dal(); var thisCostCode = dccDal.FindNoDeleteById(cost_code_id); var thisRole = srDal.FindNoDeleteById(role_id); if (thisCostCode != null && thisRole != null) { switch (thisCostCode.billing_method_id) { case (int)DicEnum.WORKTYPE_BILLING_METHOD.USE_ROLE_RATE: rate = thisRole.hourly_rate; break; case (int)DicEnum.WORKTYPE_BILLING_METHOD.FLOAT_ROLE_RATE: if (thisCostCode.rate_adjustment != null) { rate = (thisRole.hourly_rate + thisCostCode.rate_adjustment); } break; case (int)DicEnum.WORKTYPE_BILLING_METHOD.RIDE_ROLE_RATE: if (thisCostCode.rate_multiplier != null) { rate = (thisRole.hourly_rate * thisCostCode.rate_multiplier); } break; case (int)DicEnum.WORKTYPE_BILLING_METHOD.USE_UDF_ROLE_RATE: if (thisCostCode.custom_rate != null) { rate = thisCostCode.custom_rate; } break; case (int)DicEnum.WORKTYPE_BILLING_METHOD.BY_TIMES: if (thisCostCode.flat_rate != null) { rate = thisCostCode.flat_rate; } break; default: break; } } return(rate); }
protected List <crm_quote_item> degressionItem = null; // 成本的配置项 protected void Page_Load(object sender, EventArgs e) { try { #region 拉框赋值 stage_id.DataTextField = "show"; stage_id.DataValueField = "val"; stage_id.DataSource = dic.FirstOrDefault(_ => _.Key == "opportunity_stage").Value; stage_id.DataBind(); win_reason_type_id.DataTextField = "show"; win_reason_type_id.DataValueField = "val"; win_reason_type_id.DataSource = dic.FirstOrDefault(_ => _.Key == "oppportunity_win_reason_type").Value; win_reason_type_id.DataBind(); win_reason_type_id.Items.Insert(0, new ListItem() { Value = "0", Text = " ", Selected = true }); resource_id.DataTextField = "show"; resource_id.DataValueField = "val"; resource_id.DataSource = dic.FirstOrDefault(_ => _.Key == "sys_resource").Value; resource_id.DataBind(); competitor_id.DataTextField = "show"; competitor_id.DataValueField = "val"; competitor_id.DataSource = dic.FirstOrDefault(_ => _.Key == "competition").Value; competitor_id.DataBind(); competitor_id.Items.Insert(0, new ListItem() { Value = "0", Text = " ", Selected = true }); // period_type period_type.DataTextField = "show"; period_type.DataValueField = "val"; period_type.DataSource = dic.FirstOrDefault(_ => _.Key == "period_type").Value; period_type.DataBind(); period_type.Items.Insert(0, new ListItem() { Value = "0", Text = " ", Selected = true }); // notifi_temp 通知模板 var tempList = new sys_notify_tmpl_dal().GetTempByEvent(DicEnum.NOTIFY_EVENT.OPPORTUNITY_CLOSED); notifi_temp.DataTextField = "name"; notifi_temp.DataValueField = "id"; notifi_temp.DataSource = tempList; notifi_temp.DataBind(); #endregion var id = Request.QueryString["id"]; var account_id = Request.QueryString["account_id"]; if (!string.IsNullOrEmpty(id)) { if (string.IsNullOrEmpty(account_id)) { if (!IsPostBack) { opportunity_id.Enabled = false; } } opportunity = new crm_opportunity_dal().GetOpportunityById(long.Parse(id)); if (opportunity != null) { account = new CompanyBLL().GetCompany(opportunity.account_id); account_id = account.id.ToString(); } } if (!string.IsNullOrEmpty(account_id)) { account = new CompanyBLL().GetCompany(long.Parse(account_id)); var oppoList = new crm_opportunity_dal().FindOpHistoryByAccountId(long.Parse(account_id)); if (oppoList != null && oppoList.Count > 0) { opportunity_id.DataTextField = "name"; opportunity_id.DataValueField = "id"; opportunity_id.DataSource = oppoList; opportunity_id.DataBind(); } else { Response.Write("<script>alert('该客户还没有商机!');window.close();</script>"); } //opportunity_id.Items.Insert(0, new ListItem() { Value = "0", Text = " ", Selected = true }); if (string.IsNullOrEmpty(id)) { opportunity = oppoList[0]; } opportunity_id.SelectedValue = opportunity.id.ToString(); } if (!IsPostBack) { if (opportunity != null) { if (opportunity.status_id == (int)OPPORTUNITY_STATUS.CLOSED) { Response.Write("<script>if(!confirm('商机已被关闭,如果继续,系统会重复创建计费项和合同?')){window.close();}</script>"); } } if (opportunity.stage_id != null) { stage_id.SelectedValue = opportunity.stage_id.ToString(); } else { var stageList = new d_general_dal().GetGeneralByTableId((int)GeneralTableEnum.OPPORTUNITY_STATUS); var defaultStage = stageList.FirstOrDefault(_ => _.ext1 == "1"); if (defaultStage != null) { stage_id.SelectedValue = defaultStage.id.ToString(); } } // stage_id.SelectedValue = opportunity.stage_id == null ? "0" : opportunity.stage_id.ToString(); resource_id.SelectedValue = opportunity.resource_id.ToString(); competitor_id.SelectedValue = opportunity.competitor_id == null ? "0" : opportunity.competitor_id.ToString(); win_reason_type_id.SelectedValue = opportunity.win_reason_type_id == null ? "0" : opportunity.win_reason_type_id.ToString(); } // 折扣的下拉框不同于别的下拉框-- 需要去两个数据源去赋值 StringBuilder text = new StringBuilder(); var costCode = new d_cost_code_dal().GetListCostCode((int)COST_CODE_CATE.MATERIAL_COST_CODE); text.Append($"<option value='0'> </option>"); if (costCode != null && costCode.Count > 0) { foreach (var item in costCode) { text.Append($"<option value='{item.id}'>{item.name}</option>"); } } codeSelect.Value = text.ToString(); var disSource = ""; var disCostCode = costCode.Where(_ => _.id == (int)CostCode.NOTAXDISCOUNT || _.id == (int)CostCode.DISCOUNT).ToList(); if (disCostCode != null && disCostCode.Count > 0) { foreach (var item in disCostCode) { disSource += $"<option value='{item.id}'>{item.name}</option>"; } } disCodeSelct.Value = disSource; period_type.SelectedValue = ((int)QUOTE_ITEM_PERIOD_TYPE.MONTH).ToString(); primaryQuote = new QuoteBLL().GetPrimaryQuote(opportunity.id); if (primaryQuote != null) { if (!IsPostBack) { if (primaryQuote.project_id != null) // 判断该报价是否关联项目提案,如果关联,默认选中,不关联,灰掉,不可选 { activeproject.Checked = true; activeproject.Enabled = true; addRequest.Enabled = false; isaddRequest.Value = "1"; } else { activeproject.Checked = false; addRequest.Enabled = true; activeproject.Enabled = false; isactiveproject.Value = "1"; } } quoteItemList = new crm_quote_item_dal().GetQuoteItems($" and quote_id = {primaryQuote.id}"); if (quoteItemList != null && quoteItemList.Count > 0) { // 如果报价项中包含了服务 / 服务包、初始费用,则可以选中(默认不选) // 此功能需要具有合同模块权限以及修改合同服务/包权限 var isServiceChargeItem = quoteItemList.Where(_ => _.type_id == (int)QUOTE_ITEM_TYPE.SERVICE || _.type_id == (int)QUOTE_ITEM_TYPE.SERVICE_PACK || _.type_id == (int)QUOTE_ITEM_TYPE.START_COST).ToList(); if (!IsPostBack) { if (isServiceChargeItem != null && isServiceChargeItem.Count > 0) { // todo--需要判断用户权限 } else { addContractRequest.Enabled = false; isAddContractRequest.Value = "1"; addContractServices.Enabled = false; isaddContractServices.Value = "1"; } } proAndOneTimeItem = quoteItemList.Where(_ => _.optional != 1).Where(_ => _.type_id == (int)QUOTE_ITEM_TYPE.PRODUCT || _.type_id == (int)QUOTE_ITEM_TYPE.DISCOUNT).ToList(); if (!IsPostBack) { if (proAndOneTimeItem != null && proAndOneTimeItem.Count > 0) { isIncludePO.Checked = true; } else { IncludePO.Value = "1"; isIncludePO.Enabled = false; } } shipItem = quoteItemList.Where(_ => _.type_id == (int)QUOTE_ITEM_TYPE.DISTRIBUTION_EXPENSES && _.optional != 1).ToList(); if (!IsPostBack) { if (shipItem != null && shipItem.Count > 0) { isIncludeShip.Checked = true; } else { IncludeShip.Value = "1"; isIncludeShip.Enabled = false; } } degressionItem = quoteItemList.Where(_ => _.type_id == (int)QUOTE_ITEM_TYPE.DEGRESSION & _.optional != 1).ToList(); if (!IsPostBack) { if (degressionItem != null && degressionItem.Count > 0) { isIncludeCharges.Checked = true; } else { IncludeCharges.Value = "1"; isIncludeCharges.Enabled = false; } } jqueryCode.Value = ReturnJquery(); } else { // activeproject.Enabled = false; //isactiveproject.Value = "1"; addContractRequest.Enabled = false; isAddContractRequest.Value = "1"; addContractServices.Enabled = false; isaddContractServices.Value = "1"; IncludePO.Value = "1"; isIncludePO.Enabled = false; IncludeShip.Value = "1"; isIncludeShip.Enabled = false; IncludeCharges.Value = "1"; isIncludeCharges.Enabled = false; } } else { activeproject.Enabled = false; isactiveproject.Value = "1"; addContractRequest.Enabled = false; isAddContractRequest.Value = "1"; addContractServices.Enabled = false; isaddContractServices.Value = "1"; IncludePO.Value = "1"; isIncludePO.Enabled = false; IncludeShip.Value = "1"; isIncludeShip.Enabled = false; IncludeCharges.Value = "1"; isIncludeCharges.Enabled = false; } } catch (Exception msg) { Response.End(); } }
/// <summary> /// 新增预付 /// </summary> /// <param name="dto"></param> /// <param name="userId"></param> public bool NewPurchase(ContractBlockAddDto dto, long userId) { ctt_contract_cost_dal costDal = new ctt_contract_cost_dal(); string blkName = ""; if (dto.type == 1) { blkName = "时间"; } if (dto.type == 2) { blkName = "费用"; } if (dto.type == 3) { blkName = "事件"; } if (dto.isMonthly) // 每月计费 { // 检查必填项 if (dto.type == 2) { if (dto.amount == null) { return(false); } } else { if (dto.hours == null || dto.hourlyRate == null) { return(false); } } if (dto.endDate == null && dto.purchaseNum == null) { return(false); } // 检查起止日期和计费周期 if (dto.endDate != null && (DateTime)dto.endDate < dto.startDate) { return(false); } if (dto.endDate == null && dto.purchaseNum <= 0) { return(false); } DateTime dtBlockStart = dto.startDate; // 一个预付周期开始时间 DateTime dtBlockEnd = DateTime.MinValue; // 所有预付周期结束时间 if (dto.endDate != null) { dtBlockEnd = (DateTime)dto.endDate; } int blockNums = 0; // 已处理新增预付时间 while (true) { if (dto.endDate != null) // 按最后一个周期的结束时间判断 { if (dtBlockStart > dtBlockEnd) { break; } } else // 按周期个数判断 { if (blockNums >= (int)dto.purchaseNum) { break; } } // 新增预付 ctt_contract_block block = new ctt_contract_block(); block.id = dal.GetNextIdCom(); block.contract_id = dto.contractId; block.is_billed = 0; block.is_paid = 0; block.create_time = Tools.Date.DateHelper.ToUniversalTimeStamp(DateTime.Now); block.create_user_id = userId; block.update_user_id = userId; block.update_time = block.create_time; block.start_date = dtBlockStart; block.end_date = dtBlockStart.AddMonths(1).AddDays(-1); if (dto.type == 1 || dto.type == 3) { block.quantity = ((decimal)dto.hours) * 10000 / 10000; block.rate = ((decimal)dto.hourlyRate) * 100 / 100; } else if (dto.type == 2) { block.quantity = 1; block.rate = (decimal)dto.amount; } if ((bool)dto.firstPart && blockNums == 0) // 首月部分的处理 { block.end_date = new DateTime(dtBlockStart.Year, dtBlockStart.Month + 1, 1).AddDays(-1); // 结束日期为开始日期同月份的最后一天 /* 修改:所有周期的计费按一整周期算 */ //if (dto.type != 2) // block.quantity = (decimal)((int)(((decimal)(block.end_date.Day - block.start_date.Day + 1) / block.end_date.Day) * ((decimal)dto.hours) * 10000)) / 10000; // 预付数量按照天数比例计算 //else // block.rate = (decimal)((int)(((decimal)(block.end_date.Day - block.start_date.Day + 1) / block.end_date.Day) * block.rate * 10000)) / 10000; } if (dto.endDate != null && ((DateTime)dto.endDate) < block.end_date) // 设置了结束时间的处理 { block.end_date = (DateTime)dto.endDate; /* 修改:所有周期的计费按一整周期算 */ //if (dto.type != 2) // block.quantity = ((decimal)((block.end_date - block.start_date).Days + 1) // / DateTime.DaysInMonth(block.start_date.Year, block.start_date.Month)) // * ((decimal)dto.hours) * 10000 / 10000; // 预付数量按照天数比例计算 //else // block.rate = (decimal)((int)(((decimal)((block.end_date - block.start_date).Days + 1) // / DateTime.DaysInMonth(block.start_date.Year, block.start_date.Month)) * block.rate * 10000)) / 10000; } dtBlockStart = block.end_date.AddDays(1); // 下一周期的开始日期 ++blockNums; // 已处理周期数加1 // 可以延期 if (dto.delayDays != null && dto.delayDays > 0) { block.end_date = block.end_date.AddDays((int)dto.delayDays); } block.status_id = (sbyte)(dto.status ? 1 : 0); block.date_purchased = block.start_date; block.payment_number = dto.paymentNum; block.payment_type_id = dto.paymentType; block.description = dto.note; dal.Insert(block); OperLogBLL.OperLogAdd <ctt_contract_block>(block, block.id, userId, OPER_LOG_OBJ_CATE.CONTRACT_BLOCK, $"新增合同预付{blkName}"); // 新增合同成本 ctt_contract_cost cost = new ctt_contract_cost(); cost.id = costDal.GetNextIdCom(); cost.create_time = Tools.Date.DateHelper.ToUniversalTimeStamp(DateTime.Now); cost.create_user_id = userId; cost.update_time = cost.create_time; cost.update_user_id = userId; cost.contract_block_id = block.id; cost.contract_id = dto.contractId; List <d_cost_code> costCode; if (dto.type == 1) { costCode = new d_cost_code_dal().GetListCostCode((int)COST_CODE_CATE.BLOCK_PURCHASE); } else if (dto.type == 2) { costCode = new d_cost_code_dal().GetListCostCode((int)COST_CODE_CATE.RETAINER_PURCHASE); } else { costCode = new d_cost_code_dal().GetListCostCode((int)COST_CODE_CATE.TICKET_PURCHASE); } if (costCode == null || costCode.Count == 0) { throw new Exception("字典项缺失"); } cost.cost_code_id = costCode[0].id; cost.name = $"预付{blkName}[{block.start_date.ToShortDateString()}-{block.end_date.ToShortDateString()}]"; cost.date_purchased = block.date_purchased; cost.cost_type_id = (int)COST_TYPE.OPERATIONA; cost.status_id = (int)COST_STATUS.UNDETERMINED; cost.bill_status = 0; cost.is_billable = 1; cost.quantity = block.quantity; cost.unit_cost = 0; cost.unit_price = block.rate; cost.contract_block_id = block.id; cost.extended_price = (cost.quantity * cost.unit_price) * 100 / 100; if (dto.type == 1) { cost.sub_cate_id = (int)DicEnum.BILLING_ENTITY_SUB_TYPE.PREPAID_TIME; } else if (dto.type == 2) { cost.sub_cate_id = (int)DicEnum.BILLING_ENTITY_SUB_TYPE.PREPAID_COST; } else if (dto.type == 3) { cost.sub_cate_id = (int)DicEnum.BILLING_ENTITY_SUB_TYPE.EVENTS; } costDal.Insert(cost); OperLogBLL.OperLogAdd <ctt_contract_cost>(cost, cost.id, userId, OPER_LOG_OBJ_CATE.CONTRACT_COST, "新增合同成本"); } return(true); } else // 一次计费 { if (dto.type == 2) { if (dto.amount == null) { return(false); } } else { if (dto.hours == null || dto.hourlyRate == null) { return(false); } } if (dto.endDate == null) // 检查必填项 { return(false); } if ((DateTime)dto.endDate < dto.startDate) // 检查起止日期和计费周期 { return(false); } // 新增预付 ctt_contract_block block = new ctt_contract_block(); block.id = dal.GetNextIdCom(); block.contract_id = dto.contractId; block.is_billed = 0; block.is_paid = 0; block.create_time = Tools.Date.DateHelper.ToUniversalTimeStamp(DateTime.Now); block.create_user_id = userId; block.update_user_id = userId; block.update_time = block.create_time; block.start_date = dto.startDate; block.end_date = (DateTime)dto.endDate; if (dto.type == 1 || dto.type == 3) { block.quantity = ((decimal)dto.hours) * 10000 / 10000; block.rate = ((decimal)dto.hourlyRate) * 100 / 100; } else if (dto.type == 2) { block.quantity = 1; block.rate = (decimal)dto.amount; } block.status_id = (sbyte)(dto.status ? 1 : 0); block.date_purchased = dto.datePurchased; block.payment_number = dto.paymentNum; block.payment_type_id = dto.paymentType; block.description = dto.note; dal.Insert(block); OperLogBLL.OperLogAdd <ctt_contract_block>(block, block.id, userId, OPER_LOG_OBJ_CATE.CONTRACT_BLOCK, $"新增合同预付{blkName}"); // 新增合同成本 ctt_contract_cost cost = new ctt_contract_cost(); cost.id = costDal.GetNextIdCom(); cost.create_time = Tools.Date.DateHelper.ToUniversalTimeStamp(DateTime.Now); cost.create_user_id = userId; cost.update_time = cost.create_time; cost.update_user_id = userId; cost.contract_block_id = block.id; cost.contract_id = dto.contractId; List <d_cost_code> costCode; if (dto.type == 1) { costCode = new d_cost_code_dal().GetListCostCode((int)COST_CODE_CATE.BLOCK_PURCHASE); } else if (dto.type == 2) { costCode = new d_cost_code_dal().GetListCostCode((int)COST_CODE_CATE.RETAINER_PURCHASE); } else { costCode = new d_cost_code_dal().GetListCostCode((int)COST_CODE_CATE.TICKET_PURCHASE); } if (costCode == null || costCode.Count == 0) { throw new Exception("字典项缺失"); } cost.cost_code_id = costCode[0].id; cost.name = $"预付{blkName}[{block.start_date.ToShortDateString()}-{block.end_date.ToShortDateString()}]"; cost.date_purchased = block.date_purchased; cost.cost_type_id = (int)COST_TYPE.OPERATIONA; cost.status_id = (int)COST_STATUS.UNDETERMINED; cost.bill_status = 0; cost.is_billable = 1; cost.quantity = block.quantity; cost.unit_cost = 0; cost.unit_price = block.rate; cost.contract_block_id = block.id; cost.extended_price = (cost.quantity * cost.unit_price) * 100 / 100; if (dto.type == 1) { cost.sub_cate_id = (int)DicEnum.BILLING_ENTITY_SUB_TYPE.PREPAID_TIME; } else if (dto.type == 2) { cost.sub_cate_id = (int)DicEnum.BILLING_ENTITY_SUB_TYPE.PREPAID_COST; } else if (dto.type == 3) { cost.sub_cate_id = (int)DicEnum.BILLING_ENTITY_SUB_TYPE.EVENTS; } costDal.Insert(cost); OperLogBLL.OperLogAdd <ctt_contract_cost>(cost, cost.id, userId, OPER_LOG_OBJ_CATE.CONTRACT_COST, "新增合同成本"); return(true); } }
private ExpenseDto GetParam() { var param = new ExpenseDto(); if (RDAddRep.Checked) { var repTitle = Request.Form["title"]; var repEndDate = Request.Form["end_date"]; var reprAmount = Request.Form["report_amount"]; if (!string.IsNullOrEmpty(repTitle) && !string.IsNullOrEmpty(repEndDate)) { var expRep = new sdk_expense_report() { title = repTitle, end_date = DateTime.Parse(repEndDate), }; if (!string.IsNullOrEmpty(reprAmount)) { expRep.cash_advance_amount = decimal.Parse(reprAmount); } param.thisExpReport = expRep; } } else if (RDAddExiRep.Checked) { var expense_report_id = Request.Form["expense_report_id"]; if (!string.IsNullOrEmpty(expense_report_id)) { var expRep = new sdk_expense_report_dal().FindNoDeleteById(long.Parse(expense_report_id)); if (expRep != null) { param.thisExpReport = expRep; } } } var pageExp = new sdk_expense(); pageExp.add_date = DateTime.Parse(Request.Form["add_date"]); pageExp.is_billable = (sbyte)(isBillable.Checked?1:0); if (isShowWorkType) { var cost_code_id = Request.Form["cost_code_id"]; if (!string.IsNullOrEmpty(cost_code_id)) { pageExp.cost_code_id = long.Parse(cost_code_id); } } pageExp.description = Request.Form["description"]; pageExp.expense_cost_code_id = int.Parse(Request.Form["expense_cost_code_id"]); if (pageExp.expense_cost_code_id == (int)CostCode.ENTERTAINMENT_EXPENSE) { pageExp.location = Request.Form["location"]; } else if (pageExp.expense_cost_code_id == (int)CostCode.MILEAGE) { pageExp.from_loc = Request.Form["from_loc"]; pageExp.to_loc = Request.Form["to_loc"]; var odometer_start = Request.Form["odometer_start"]; if (!string.IsNullOrEmpty(odometer_start)) { pageExp.odometer_start = decimal.Parse(odometer_start); } pageExp.odometer_end = decimal.Parse(Request.Form["odometer_end"]); var miles = Request.Form["miles"]; if (!string.IsNullOrEmpty(miles)) { pageExp.miles = decimal.Parse(miles); } else { pageExp.miles = pageExp.odometer_end - pageExp.odometer_start; } } else { //var amount = long.Parse(Request.Form["amount"]); //var moneyHidden = Request.Form["moneyHidden"]; //if (!string.IsNullOrEmpty(moneyHidden)) //{ // var money = decimal.Parse(moneyHidden); // if (amount > money) // { // var overdraft_policy_id = Request.Form["overdraft_policy_id"]; // } // else // { // pageExp.amount = amount; // } //} //else //{ //pageExp.amount = amount; //} } pageExp.amount = decimal.Parse(Request.Form["amount"]); var esType = new d_cost_code_dal().FindNoDeleteById((long)pageExp.expense_cost_code_id); if (esType != null && esType.expense_type_id != null) { pageExp.type_id = (int)esType.expense_type_id; } pageExp.payment_type_id = int.Parse(Request.Form["payment_type_id"]); var thisPay = new d_general_dal().FindNoDeleteById(pageExp.payment_type_id); if (thisPay != null) { } pageExp.has_receipt = (sbyte)(hasReceipt.Checked?1:0); pageExp.account_id = long.Parse(Request.Form["account_id"]); if (rbAssTask.Checked) { var ticket_id = Request.Form["ticket_id"]; if (!string.IsNullOrEmpty(ticket_id)) { pageExp.task_id = long.Parse(ticket_id); } } else if (rbAssProTask.Checked) { pageExp.project_id = long.Parse(Request.Form["project_id"]); var task_id = Request.Form["task_id"]; if (!string.IsNullOrEmpty(task_id)) { pageExp.task_id = long.Parse(task_id); } } pageExp.purchase_order_no = Request.Form["purchase_order_no"]; if (!isAdd) { pageExp.id = thisExpense.id; pageExp.oid = thisExpense.oid; pageExp.create_user_id = thisExpense.create_user_id; pageExp.create_time = thisExpense.create_time; pageExp.is_approved = thisExpense.is_approved; pageExp.approve_and_post_user_id = thisExpense.approve_and_post_user_id; pageExp.approve_and_post_date = thisExpense.approve_and_post_date; pageExp.amountrate = thisExpense.amountrate; pageExp.purpose = thisExpense.purpose; pageExp.extacctitemid = thisExpense.extacctitemid; pageExp.web_service_date = thisExpense.web_service_date; pageExp.currency_id = thisExpense.currency_id; } param.thisExpense = pageExp; return(param); }
protected List <crm_quote_item> serviceItem = null; // 该报价下的服务报价项 protected void Page_Load(object sender, EventArgs e) { try { var quote_id = Request.QueryString["id"]; quote = new QuoteBLL().GetQuote(long.Parse(quote_id)); if (quote.is_primary_quote != 1) // 关闭报价只针对主报价 { Response.Write("<script>alert('关闭报价只针对主报价');window.close();</script>"); } //if (quote.project_id == null) //{ // Response.Write("<script>alert('请关联项目后进行关闭报价操作');window.close();</script>"); //} opportunity = new crm_opportunity_dal().GetOpportunityById(quote.opportunity_id); win_reason_type_id.DataTextField = "show"; win_reason_type_id.DataValueField = "val"; win_reason_type_id.DataSource = dic.FirstOrDefault(_ => _.Key == "oppportunity_win_reason_type").Value; win_reason_type_id.DataBind(); win_reason_type_id.Items.Insert(0, new ListItem() { Value = "0", Text = " ", Selected = true }); win_reason_type_id.SelectedValue = opportunity.win_reason_type_id == null ? "0" : opportunity.win_reason_type_id.ToString(); StringBuilder text = new StringBuilder(); var costCode = new d_cost_code_dal().GetListCostCode((int)COST_CODE_CATE.MATERIAL_COST_CODE); text.Append($"<option value='0'> </option>"); if (costCode != null && costCode.Count > 0) { foreach (var item in costCode) { text.Append($"<option value='{item.id}'>{item.name}</option>"); } } codeSelect.Value = text.ToString(); var disSource = ""; var disCostCode = costCode.Where(_ => _.id == 37 || _.id == 43).ToList(); if (disCostCode != null && disCostCode.Count > 0) { foreach (var item in disCostCode) { disSource += $"<option value='{item.id}'>{item.name}</option>"; } } disCodeSelct.Value = disSource; quoteItemList = new crm_quote_item_dal().GetQuoteItems($"and quote_id = {quote.id}"); quoteItemList = quoteItemList.Where(_ => _.optional == 0 && _.type_id != (int)QUOTE_ITEM_TYPE.COST && _.type_id != (int)QUOTE_ITEM_TYPE.SERVICE && _.type_id != (int)QUOTE_ITEM_TYPE.WORKING_HOURS).ToList(); if (quoteItemList != null && quoteItemList.Count > 0) { serviceItem = quoteItemList.Where(_ => _.type_id == (int)EMT.DoneNOW.DTO.DicEnum.QUOTE_ITEM_TYPE.SERVICE || _.type_id == (int)EMT.DoneNOW.DTO.DicEnum.QUOTE_ITEM_TYPE.START_COST).ToList(); if (serviceItem != null && serviceItem.Count > 0) { Response.Write("<script>alert('报价中包含服务/包、初始费用等,请使用关闭商机向导');window.close();</script>"); } jqueryCode.Value = ReturnJquery(); } } catch (Exception) { Response.End(); } }
protected void Page_Load(object sender, EventArgs e) { try { var eid = Request.QueryString["id"]; thisReport = new sdk_expense_report_dal().FindNoDeleteById(long.Parse(eid)); if (thisReport != null) { creRes = new sys_resource_dal().FindNoDeleteById(thisReport.create_user_id); if (thisReport.submit_user_id != null) { subRes = new sys_resource_dal().FindNoDeleteById((long)thisReport.submit_user_id); } var chooseDateString = Request.QueryString["startDate"]; if (!string.IsNullOrEmpty(chooseDateString)) { chooseStartDate = GetMonday(DateTime.Parse(chooseDateString)); } var allExpList = new sdk_expense_dal().GetExpByReport(thisReport.id); if (allExpList != null && allExpList.Count > 0) { if (chooseStartDate != null) { expList = allExpList.Where(_ => _.add_date >= chooseStartDate && _.add_date <= ((DateTime)chooseStartDate).AddDays(6)).ToList(); } } #region 完善日期下拉框信息 GetSelect(); // 获取日期下拉框 var choese = dateList.FirstOrDefault(_ => _.select == 1); if (choese == null) { dateList.Add(new DictionaryEntryDto() { select = 1, show = "选择日期", val = "" }); } else { dateList.Add(new DictionaryEntryDto() { show = "选择日期", val = "" }); } dateList = dateList.OrderBy(_ => _.val).ToList(); #endregion if (expList != null && expList.Count > 0) { var dccDal = new d_cost_code_dal(); // 获取到招待相关的费用 entertainList = expList.Where(_ => { if (_.cost_code_id != null) { var thisCost = dccDal.FindNoDeleteById((long)_.cost_code_id); if (thisCost != null && thisCost.expense_type_id == (int)DicEnum.EXPENSE_TYPE.ENTERTAINMENT_EXPENSES) { return(true); } } return(false); }).ToList(); if (entertainList != null && entertainList.Count > 0) { noEntertainList = expList.Where(_ => !entertainList.Any(el => el.id == _.id)).ToList(); } else { noEntertainList = expList; } } } else { Response.Write($"<script>alerl('未查询到相关报表,请刷新页面后重试!');window.close();</script>"); } } catch (Exception msg) { Response.Write($"<script>alerl('{msg.Message}');</script>"); } }