/// <summary> /// 批量新增产品相关报价项 /// </summary> public void AddQuoteItemByProduct(HttpContext context, string ids, int quote_id) { if (!string.IsNullOrEmpty(ids)) { var itemDal = new crm_quote_item_dal(); var productIds = ids.Split(new Char[] { ',' }, StringSplitOptions.RemoveEmptyEntries); foreach (var productId in productIds) { var product = new ProductBLL().GetProduct(long.Parse(productId)); if (product != null) { crm_quote_item thisQuoteItem = new crm_quote_item() { id = itemDal.GetNextIdCom(), name = product.name, type_id = (int)DTO.DicEnum.QUOTE_ITEM_TYPE.PRODUCT, object_id = product.id, description = product.description, unit_price = product.unit_price, unit_cost = product.unit_cost, unit_discount = 0, quantity = 1, quote_id = quote_id, period_type_id = product.period_type_id, create_time = Tools.Date.DateHelper.ToUniversalTimeStamp(DateTime.Now), create_user_id = LoginUserId, update_time = Tools.Date.DateHelper.ToUniversalTimeStamp(DateTime.Now), update_user_id = LoginUserId, optional = 0, }; itemDal.Insert(thisQuoteItem); new sys_oper_log_dal().Insert(new sys_oper_log() { user_cate = "用户", user_id = (int)LoginUserId, name = LoginUser.name, phone = LoginUser.mobile, oper_time = Tools.Date.DateHelper.ToUniversalTimeStamp(DateTime.Now), oper_object_cate_id = (int)OPER_LOG_OBJ_CATE.QUOTE_ITEM, oper_object_id = thisQuoteItem.id,// 操作对象id oper_type_id = (int)OPER_LOG_TYPE.ADD, oper_description = itemDal.AddValue(thisQuoteItem), remark = "添加报价项", }); } } context.Response.Write("true"); } else { context.Response.Write("false"); } }
private static int SortCycle(crm_quote_item item, crm_quote_item item2) { // 按照月、季度、半年、年、一次性 顺序 if (item.period_type_id == (int)QUOTE_ITEM_PERIOD_TYPE.ONE_TIME || item2.period_type_id == (int)QUOTE_ITEM_PERIOD_TYPE.ONE_TIME) { return(620); } else if (item.period_type_id == null || item2.period_type_id == null) { return(599); } else { return((int)item.period_type_id); } }
// 计算出该报价下的所有一次姓报价项中不包含税的报价项的折扣 public decimal GetOneTimeMoney(List <crm_quote_item> oneTimeList, crm_quote_item qItem) { decimal totalMoney = 0; var AllTotalMoney = GetAllMoney(oneTimeList); var noTaxItem = oneTimeList.Where(_ => _.period_type_id == null).ToList(); totalMoney = GetAllMoney(noTaxItem); if (qItem.discount_percent != null) { totalMoney = totalMoney * (decimal)qItem.discount_percent; } else { totalMoney = totalMoney * ((decimal)qItem.unit_discount / AllTotalMoney); } return(totalMoney); }
// 计算出该报价下的所有一次姓报价项中包含税的报价项的折扣 public decimal GetOneTimeMoneyTax(List <crm_quote_item> oneTimeList, crm_quote_item qItem) { // 按照金钱扣除的折扣转换成为百分比进行运算-- 暂时处理待测试 // 折扣记录两种计费项。一个是一次性报价项当中含有税的,一个一次性报价项当中不含有税的 // 折扣的计费项命名 为含税和不含税这两种 // 计费项的名称命名为报价项的名称 decimal totalMoney = 0; var AllTotalMoney = GetAllMoney(oneTimeList); var taxItem = oneTimeList.Where(_ => _.period_type_id != null).ToList(); totalMoney = GetAllMoney(taxItem); if (qItem.discount_percent != null) { totalMoney = totalMoney * (decimal)qItem.discount_percent; } else { totalMoney = totalMoney * ((decimal)qItem.unit_discount / AllTotalMoney); } return(totalMoney); }
/// <summary> /// 在销售订单下新增 /// </summary> /// <returns></returns> public ERROR_CODE InsertBySale(crm_quote_item param, long user_id) { return(ERROR_CODE.SUCCESS); }
/// <summary> /// 新增报价项 /// </summary> /// <param name="quote_item"></param> /// <param name="user_id"></param> /// <returns></returns> public ERROR_CODE Insert(crm_quote_item quote_item, Dictionary <long, int> wareDic, long user_id, bool isSaleOrder = false, long?saleOrderId = null) { if (quote_item.type_id != (int)DicEnum.QUOTE_ITEM_TYPE.DISCOUNT) { if (quote_item.unit_price == null || quote_item.unit_cost == null || quote_item.quantity == null || quote_item.unit_discount == null) { return(ERROR_CODE.PARAMS_ERROR); } if (string.IsNullOrEmpty(quote_item.name)) { return(ERROR_CODE.PARAMS_ERROR); } } else { if (string.IsNullOrEmpty(quote_item.name)) { return(ERROR_CODE.PARAMS_ERROR); } if (quote_item.discount_percent == null && quote_item.unit_discount == null) { return(ERROR_CODE.PARAMS_ERROR); } } var user = UserInfoBLL.GetUserInfo(user_id); if (user == null) { return(ERROR_CODE.USER_NOT_FIND); } quote_item.id = _dal.GetNextIdCom(); quote_item.tax_cate_id = quote_item.tax_cate_id == 0 ? null : quote_item.tax_cate_id; quote_item.period_type_id = quote_item.period_type_id == 0 ? null : quote_item.period_type_id; quote_item.create_time = Tools.Date.DateHelper.ToUniversalTimeStamp(DateTime.Now); quote_item.update_time = Tools.Date.DateHelper.ToUniversalTimeStamp(DateTime.Now); quote_item.create_user_id = user_id; quote_item.update_user_id = user_id; _dal.Insert(quote_item); 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.QUOTE_ITEM, oper_object_id = quote_item.id,// 操作对象id oper_type_id = (int)OPER_LOG_TYPE.ADD, oper_description = _dal.AddValue(quote_item), remark = "保存报价项信息" }); var oDal = new crm_opportunity_dal(); var oppo = oDal.GetOpByItemID(quote_item.id); if (oppo != null && oppo.use_quote == 1) { if (quote_item.optional != 1 && quote_item.type_id != (int)DicEnum.QUOTE_ITEM_TYPE.DISCOUNT && quote_item.type_id != (int)DicEnum.QUOTE_ITEM_TYPE.DISTRIBUTION_EXPENSES) { decimal?changeRevenue = quote_item.quantity * ((quote_item.unit_price ?? 0) - (quote_item.unit_discount ?? 0)); decimal?changeCost = quote_item.quantity * quote_item.unit_cost; switch (quote_item.period_type_id) { case (int)DicEnum.QUOTE_ITEM_PERIOD_TYPE.ONE_TIME: oppo.one_time_revenue += (changeRevenue ?? 0); oppo.one_time_cost += (changeCost ?? 0); break; case (int)DicEnum.QUOTE_ITEM_PERIOD_TYPE.MONTH: oppo.monthly_revenue += (changeRevenue ?? 0); oppo.monthly_cost += (changeCost ?? 0); break; case (int)DicEnum.QUOTE_ITEM_PERIOD_TYPE.QUARTER: oppo.quarterly_revenue += (changeRevenue ?? 0); oppo.quarterly_cost += (changeCost ?? 0); break; case (int)DicEnum.QUOTE_ITEM_PERIOD_TYPE.HALFYEAR: oppo.semi_annual_revenue += (changeRevenue ?? 0); oppo.semi_annual_cost += (changeCost ?? 0); break; case (int)DicEnum.QUOTE_ITEM_PERIOD_TYPE.YEAR: oppo.yearly_revenue += (changeRevenue ?? 0); oppo.yearly_cost += (changeCost ?? 0); break; default: break; } // var udfDto = new UserDefinedFieldsBLL().GetUdf(DicEnum.UDF_CATE.OPPORTUNITY); // var udfValue = OpportunityAddOrUpdateDto param = new OpportunityAddOrUpdateDto() { general = oppo, udf = null, notify = null }; new OpportunityBLL().Update(param, user.id); } } if (quote_item.type_id == (int)QUOTE_ITEM_TYPE.PRODUCT) { if (wareDic != null && wareDic.Count > 0) { var irDal = new ivt_reserve_dal(); var iwDal = new ivt_warehouse_dal(); foreach (var thisPageWare in wareDic) { var thisWareHouse = iwDal.FindNoDeleteById(thisPageWare.Key); if (thisWareHouse != null && thisPageWare.Value != 0) { var thisReserve = new ivt_reserve() { id = irDal.GetNextIdCom(), create_time = Tools.Date.DateHelper.ToUniversalTimeStamp(DateTime.Now), update_time = Tools.Date.DateHelper.ToUniversalTimeStamp(DateTime.Now), create_user_id = user_id, update_user_id = user_id, quote_item_id = quote_item.id, warehouse_id = thisPageWare.Key, quantity = thisPageWare.Value, resource_id = thisWareHouse.resource_id, }; irDal.Insert(thisReserve); OperLogBLL.OperLogAdd <ivt_reserve>(thisReserve, thisReserve.id, user_id, OPER_LOG_OBJ_CATE.WAREHOUSE_RESERVE, "新增库存预留"); } } } } if (isSaleOrder && saleOrderId != null && (quote_item.type_id == (int)DicEnum.QUOTE_ITEM_TYPE.PRODUCT || quote_item.type_id == (int)DicEnum.QUOTE_ITEM_TYPE.DEGRESSION || quote_item.type_id == (int)DicEnum.QUOTE_ITEM_TYPE.DISTRIBUTION_EXPENSES)) { var cccDal = new ctt_contract_cost_dal(); var costList = cccDal.GetListBySaleOrderId((long)saleOrderId); if (costList != null && costList.Count > 0) { int status_id = 0; long cost_code_id = (long)quote_item.object_id; long?product_id = null; if (quote_item.type_id == (int)QUOTE_ITEM_TYPE.PRODUCT) { product_id = quote_item.object_id; status_id = (int)COST_STATUS.PENDING_PURCHASE; var thisProduct = new ivt_product_dal().FindNoDeleteById((long)quote_item.object_id); if (thisProduct != null) { cost_code_id = thisProduct.cost_code_id; } else { return(ERROR_CODE.ERROR); } var appSet = new SysSettingBLL().GetSetById(DTO.SysSettingEnum.CTT_COST_APPROVAL_VALUE); if (appSet != null && !string.IsNullOrEmpty(appSet.setting_value) && thisProduct.does_not_require_procurement == 0) // 该产品走采购流程,并且价格大于设置,则带审批 { if (((decimal)quote_item.quantity * (decimal)quote_item.unit_price) > decimal.Parse(appSet.setting_value)) // 金额超出(待审批) { status_id = (int)COST_STATUS.PENDING_APPROVAL; } } } else { status_id = (int)COST_STATUS.PENDING_DELIVERY; } ctt_contract_cost cost = new ctt_contract_cost() { id = _dal.GetNextIdCom(), opportunity_id = costList[0].opportunity_id, quote_item_id = quote_item.id, cost_code_id = cost_code_id, product_id = product_id, name = quote_item.name, description = quote_item.description, date_purchased = DateTime.Now, is_billable = 1, bill_status = 0, cost_type_id = (int)COST_TYPE.OPERATIONA, status_id = status_id, quantity = quote_item.quantity ?? 0, unit_price = (quote_item.unit_price ?? 0) - (quote_item.unit_discount ?? 0), unit_cost = quote_item.unit_cost, extended_price = ((quote_item.unit_price ?? 0) - (quote_item.unit_discount ?? 0)) * quote_item.quantity, 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), project_id = costList[0].project_id, contract_id = costList[0].contract_id, task_id = costList[0].task_id, sub_cate_id = costList[0].sub_cate_id, }; cccDal.Insert(cost); OperLogBLL.OperLogAdd <ctt_contract_cost>(cost, cost.id, user_id, OPER_LOG_OBJ_CATE.CONTRACT_COST, "新增成本"); if (quote_item.type_id == (int)QUOTE_ITEM_TYPE.PRODUCT) { var ccBll = new ContractCostBLL(); var irDal = new ivt_reserve_dal(); var thisPro = new ivt_product_dal().FindNoDeleteById((long)quote_item.object_id); var thisProResList = irDal.GetListByItemId(quote_item.id); if (thisProResList != null && thisProResList.Count > 0 && thisPro != null) { foreach (var thisProRes in thisProResList) { ccBll.AddCostProduct(cost.id, thisPro.id, thisProRes.warehouse_id, thisProRes.quantity, "", "", user.id); irDal.SoftDelete(thisProRes, user.id); OperLogBLL.OperLogDelete <ivt_reserve>(thisProRes, thisProRes.id, user.id, OPER_LOG_OBJ_CATE.WAREHOUSE_RESERVE, "删除产品预留"); } ccBll.ChangCostStatus(cost.id, user_id); } } } } return(ERROR_CODE.SUCCESS); }
/// <summary> /// 编辑报价项 /// </summary> /// <param name="quote_item"></param> /// <param name="user_id"></param> /// <returns></returns> public ERROR_CODE Update(crm_quote_item quote_item, Dictionary <long, int> wareDic, long user_id, bool isSaleOrder = false, long?saleOrderId = null) { if (quote_item.type_id != (int)DicEnum.QUOTE_ITEM_TYPE.DISCOUNT) { if (quote_item.unit_price == null || quote_item.unit_cost == null || quote_item.quantity == null || quote_item.unit_discount == null) { return(ERROR_CODE.PARAMS_ERROR); } if (string.IsNullOrEmpty(quote_item.name)) { return(ERROR_CODE.PARAMS_ERROR); } } else { if (string.IsNullOrEmpty(quote_item.name)) { return(ERROR_CODE.PARAMS_ERROR); } if (quote_item.discount_percent == null && quote_item.unit_discount == null) { return(ERROR_CODE.PARAMS_ERROR); } } var user = UserInfoBLL.GetUserInfo(user_id); if (user == null) { return(ERROR_CODE.USER_NOT_FIND); } var old_quote_item = _dal.GetQuoteItem(quote_item.id); int?oldPeriod = old_quote_item.period_type_id; quote_item.oid = old_quote_item.oid; quote_item.update_user_id = user_id; quote_item.update_time = Tools.Date.DateHelper.ToUniversalTimeStamp(DateTime.Now); quote_item.tax_cate_id = quote_item.tax_cate_id == 0 ? null : quote_item.tax_cate_id; _dal.Update(quote_item); 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.QUOTE_ITEM, oper_object_id = quote_item.id,// 操作对象id oper_type_id = (int)OPER_LOG_TYPE.UPDATE, oper_description = _dal.CompareValue(old_quote_item, quote_item), remark = "编辑报价项信息" }); var oDal = new crm_opportunity_dal(); var oppo = oDal.GetOpByItemID(quote_item.id); if (oppo != null && oppo.use_quote == 1) { if (quote_item.optional != 1 && quote_item.type_id != (int)DicEnum.QUOTE_ITEM_TYPE.DISCOUNT && quote_item.type_id != (int)DicEnum.QUOTE_ITEM_TYPE.DISTRIBUTION_EXPENSES) { decimal?changeRevenue = quote_item.quantity * quote_item.unit_price; decimal?changeCost = quote_item.quantity * quote_item.unit_cost; decimal?oldChangeRevenue = old_quote_item.quantity * ((old_quote_item.unit_price ?? 0) - (old_quote_item.unit_discount ?? 0)); decimal?oldChangeCost = old_quote_item.quantity * old_quote_item.unit_cost; switch (oldPeriod) { case (int)DicEnum.QUOTE_ITEM_PERIOD_TYPE.ONE_TIME: oppo.one_time_revenue = oppo.one_time_revenue - (oldChangeRevenue ?? 0); oppo.one_time_cost = oppo.one_time_cost - (oldChangeCost ?? 0); break; case (int)DicEnum.QUOTE_ITEM_PERIOD_TYPE.MONTH: oppo.one_time_revenue = oppo.one_time_revenue - (oldChangeRevenue ?? 0); oppo.one_time_cost = oppo.one_time_cost - (oldChangeCost ?? 0); break; case (int)DicEnum.QUOTE_ITEM_PERIOD_TYPE.QUARTER: oppo.one_time_revenue = oppo.one_time_revenue - (oldChangeRevenue ?? 0); oppo.one_time_cost = oppo.one_time_cost - (oldChangeCost ?? 0); break; case (int)DicEnum.QUOTE_ITEM_PERIOD_TYPE.HALFYEAR: oppo.one_time_revenue = oppo.one_time_revenue - (oldChangeRevenue ?? 0); oppo.one_time_cost = oppo.one_time_cost - (oldChangeCost ?? 0); break; case (int)DicEnum.QUOTE_ITEM_PERIOD_TYPE.YEAR: oppo.one_time_revenue = oppo.one_time_revenue - (oldChangeRevenue ?? 0); oppo.one_time_cost = oppo.one_time_cost - (oldChangeCost ?? 0); break; default: break; } switch (quote_item.period_type_id) { case (int)DicEnum.QUOTE_ITEM_PERIOD_TYPE.ONE_TIME: oppo.one_time_revenue += (changeRevenue ?? 0); oppo.one_time_cost += (changeCost ?? 0); break; case (int)DicEnum.QUOTE_ITEM_PERIOD_TYPE.MONTH: oppo.monthly_revenue += (changeRevenue ?? 0); oppo.monthly_cost += (changeCost ?? 0); break; case (int)DicEnum.QUOTE_ITEM_PERIOD_TYPE.QUARTER: oppo.quarterly_revenue += (changeRevenue ?? 0); oppo.quarterly_cost += (changeCost ?? 0); break; case (int)DicEnum.QUOTE_ITEM_PERIOD_TYPE.HALFYEAR: oppo.semi_annual_revenue += (changeRevenue ?? 0); oppo.semi_annual_cost += (changeCost ?? 0); break; case (int)DicEnum.QUOTE_ITEM_PERIOD_TYPE.YEAR: oppo.yearly_revenue += (changeRevenue ?? 0); oppo.yearly_cost += (changeCost ?? 0); break; default: break; } // var udfDto = new UserDefinedFieldsBLL().GetUdf(DicEnum.UDF_CATE.OPPORTUNITY); // var udfValue = OpportunityAddOrUpdateDto param = new OpportunityAddOrUpdateDto() { general = oppo, udf = null, notify = null }; new OpportunityBLL().Update(param, user.id); } } if (quote_item.type_id == (int)QUOTE_ITEM_TYPE.PRODUCT) { var irDal = new ivt_reserve_dal(); var iwDal = new ivt_warehouse_dal(); var oldReserList = irDal.GetListByItemId(quote_item.id); if (wareDic != null && wareDic.Count > 0) { if (oldReserList != null && oldReserList.Count > 0) { foreach (var thisPageWare in wareDic) { var thisWareHouse = iwDal.FindNoDeleteById(thisPageWare.Key); var thisOldReser = oldReserList.FirstOrDefault(_ => _.warehouse_id == thisPageWare.Key); if (thisOldReser != null) { oldReserList.Remove(thisOldReser); if (thisWareHouse != null) { if (thisPageWare.Value == 0) { irDal.SoftDelete(thisOldReser, user_id); OperLogBLL.OperLogDelete <ivt_reserve>(thisOldReser, thisOldReser.id, user_id, OPER_LOG_OBJ_CATE.WAREHOUSE_RESERVE, "删除库存预留"); continue; } if (thisOldReser.quantity != thisPageWare.Value || thisOldReser.resource_id != thisWareHouse.resource_id) { thisOldReser.quantity = thisPageWare.Value; thisOldReser.resource_id = thisWareHouse.resource_id; var thisOld = irDal.FindNoDeleteById(thisOldReser.id); irDal.Update(thisOldReser); OperLogBLL.OperLogUpdate <ivt_reserve>(thisOldReser, thisOld, thisOldReser.id, user_id, OPER_LOG_OBJ_CATE.WAREHOUSE_RESERVE, "修改库存预留"); } } } else { if (thisWareHouse != null && thisPageWare.Value != 0) { var thisReserve = new ivt_reserve() { id = irDal.GetNextIdCom(), create_time = Tools.Date.DateHelper.ToUniversalTimeStamp(DateTime.Now), update_time = Tools.Date.DateHelper.ToUniversalTimeStamp(DateTime.Now), create_user_id = user_id, update_user_id = user_id, quote_item_id = quote_item.id, warehouse_id = thisPageWare.Key, quantity = thisPageWare.Value, resource_id = thisWareHouse.resource_id, }; irDal.Insert(thisReserve); OperLogBLL.OperLogAdd <ivt_reserve>(thisReserve, thisReserve.id, user_id, OPER_LOG_OBJ_CATE.WAREHOUSE_RESERVE, "新增库存预留"); } } } } else { foreach (var thisPageWare in wareDic) { var thisWareHouse = iwDal.FindNoDeleteById(thisPageWare.Key); if (thisWareHouse != null) { var thisReserve = new ivt_reserve() { id = irDal.GetNextIdCom(), create_time = Tools.Date.DateHelper.ToUniversalTimeStamp(DateTime.Now), update_time = Tools.Date.DateHelper.ToUniversalTimeStamp(DateTime.Now), create_user_id = user_id, update_user_id = user_id, quote_item_id = quote_item.id, warehouse_id = thisPageWare.Key, quantity = thisPageWare.Value, resource_id = thisWareHouse.resource_id, }; irDal.Insert(thisReserve); OperLogBLL.OperLogAdd <ivt_reserve>(thisReserve, thisReserve.id, user_id, OPER_LOG_OBJ_CATE.WAREHOUSE_RESERVE, "新增库存预留"); } } } } if (oldReserList != null && oldReserList.Count > 0) { oldReserList.ForEach(_ => { irDal.SoftDelete(_, user_id); OperLogBLL.OperLogDelete <ivt_reserve>(_, _.id, user_id, OPER_LOG_OBJ_CATE.WAREHOUSE_RESERVE, "删除库存预留"); }); } } if (isSaleOrder && saleOrderId != null && (quote_item.type_id == (int)DicEnum.QUOTE_ITEM_TYPE.PRODUCT || quote_item.type_id == (int)DicEnum.QUOTE_ITEM_TYPE.DEGRESSION || quote_item.type_id == (int)DicEnum.QUOTE_ITEM_TYPE.DISTRIBUTION_EXPENSES)) { var cccDal = new ctt_contract_cost_dal(); var thisCost = cccDal.GetSinBuQuoteItem(quote_item.id); if (thisCost != null) { long?product_id = thisCost.product_id; int status_id = thisCost.status_id; long cost_code_id = thisCost.cost_code_id; if (quote_item.type_id == (int)QUOTE_ITEM_TYPE.PRODUCT) { product_id = quote_item.object_id; status_id = thisCost.status_id; var thisProduct = new ivt_product_dal().FindNoDeleteById((long)quote_item.object_id); if (thisProduct != null) { cost_code_id = thisProduct.cost_code_id; } else { return(ERROR_CODE.ERROR); } if (status_id != (int)COST_STATUS.UNDETERMINED && status_id != (int)COST_STATUS.PENDING_APPROVAL && status_id != (int)COST_STATUS.CANCELED) { if (thisCost.quantity != quote_item.quantity) { status_id = (int)COST_STATUS.PENDING_PURCHASE; var appSet = new SysSettingBLL().GetSetById(DTO.SysSettingEnum.CTT_COST_APPROVAL_VALUE); if (appSet != null && !string.IsNullOrEmpty(appSet.setting_value) && thisProduct.does_not_require_procurement == 0) { if (((decimal)quote_item.quantity * (decimal)quote_item.unit_price) > decimal.Parse(appSet.setting_value)) // 金额超出(待审批) { status_id = (int)COST_STATUS.PENDING_APPROVAL; } } } } } thisCost.product_id = product_id; thisCost.cost_code_id = cost_code_id; thisCost.name = quote_item.name; thisCost.description = quote_item.description; thisCost.unit_price = (quote_item.unit_price ?? 0) - (quote_item.unit_discount ?? 0); thisCost.unit_cost = quote_item.unit_cost; thisCost.quantity = quote_item.quantity; thisCost.status_id = status_id; var olderCost = cccDal.FindNoDeleteById(thisCost.id); cccDal.Update(thisCost); OperLogBLL.OperLogUpdate <ctt_contract_cost>(thisCost, olderCost, thisCost.id, user_id, OPER_LOG_OBJ_CATE.CONTRACT_COST, "修改成本"); if (quote_item.type_id == (int)QUOTE_ITEM_TYPE.PRODUCT) { var ccBll = new ContractCostBLL(); var irDal = new ivt_reserve_dal(); var thisPro = new ivt_product_dal().FindNoDeleteById((long)quote_item.object_id); var thisProResList = irDal.GetListByItemId(quote_item.id); if (thisProResList != null && thisProResList.Count > 0 && thisPro != null) { foreach (var thisProRes in thisProResList) { ccBll.AddCostProduct(thisCost.id, thisPro.id, thisProRes.warehouse_id, thisProRes.quantity, "", "", user.id); irDal.SoftDelete(thisProRes, user.id); OperLogBLL.OperLogDelete <ivt_reserve>(thisProRes, thisProRes.id, user.id, OPER_LOG_OBJ_CATE.WAREHOUSE_RESERVE, "删除产品预留"); } ccBll.ChangCostStatus(thisCost.id, user_id); } } } } return(ERROR_CODE.SUCCESS); }
protected long quote_id; // 报价ID protected void Page_Load(object sender, EventArgs e) { try { isSaleOrder = !string.IsNullOrEmpty(Request.QueryString["isSaleOrder"]); var sId = Request.QueryString["sale_order_id"]; if (!string.IsNullOrEmpty(sId)) { saleOrderId = long.Parse(sId); } type = Request.QueryString["type_id"]; // 报价项类型 var quote_id = Request.QueryString["quote_id"]; // 报价ID 需要根据报价ID 添加报价项 if (!string.IsNullOrEmpty(quote_id)) { this.quote_id = long.Parse(quote_id); } var quote_item_id = Request.QueryString["id"]; thisQuoteId.Value = quote_id; dic = new QuoteItemBLL().GetField(); if (!string.IsNullOrEmpty(quote_item_id)) { quote_item = new crm_quote_item_dal().GetQuoteItem(long.Parse(quote_item_id)); if (quote_item != null) { if (quote_item.quote_id != null) { this.quote_id = (long)quote_item.quote_id; } isAdd = false; if (!IsPostBack) { _optional.Checked = quote_item.optional == 1; } ItemTypeId.Value = quote_item.type_id.ToString(); switch (quote_item.type_id) // todo 不同类型的报价项 { case (int)QUOTE_ITEM_TYPE.WORKING_HOURS: type = "工时"; break; case (int)QUOTE_ITEM_TYPE.COST: type = "费用"; break; case (int)QUOTE_ITEM_TYPE.DEGRESSION: type = "成本"; break; case (int)QUOTE_ITEM_TYPE.DISCOUNT: type = "折扣"; break; case (int)QUOTE_ITEM_TYPE.PRODUCT: type = "产品"; break; case (int)QUOTE_ITEM_TYPE.DISTRIBUTION_EXPENSES: type = "配送费用"; break; case (int)QUOTE_ITEM_TYPE.SERVICE: type = "服务"; break; case (int)QUOTE_ITEM_TYPE.START_COST: type = "初始费用"; break; default: break; } #region 记录浏览历史 var accountName = ""; if (quote_item.quote_id != null) { var quote = new crm_quote_dal().FindNoDeleteById((long)quote_item.quote_id); if (quote != null) { var account = new CompanyBLL().GetCompany(quote.account_id); accountName = account != null ? account.name : ""; } } var history = new sys_windows_history() { title = $"编辑报价项:" + quote_item.name + " " + accountName, url = Request.RawUrl, }; new IndexBLL().BrowseHistory(history, LoginUserId); #endregion } } else { ItemTypeId.Value = type; switch (Convert.ToInt64(type)) // todo 不同类型的报价项 { case (int)QUOTE_ITEM_TYPE.WORKING_HOURS: type = "工时"; break; case (int)QUOTE_ITEM_TYPE.COST: type = "费用"; break; case (int)QUOTE_ITEM_TYPE.DEGRESSION: type = "成本"; break; case (int)QUOTE_ITEM_TYPE.DISCOUNT: type = "折扣"; break; case (int)QUOTE_ITEM_TYPE.PRODUCT: type = "产品"; break; case (int)QUOTE_ITEM_TYPE.DISTRIBUTION_EXPENSES: type = "配送费用"; break; case (int)QUOTE_ITEM_TYPE.SERVICE: type = "服务"; break; case (int)QUOTE_ITEM_TYPE.START_COST: type = "初始费用"; break; default: Response.End(); // 未传类型,暂不创建 break; } } //if (string.IsNullOrEmpty(quote_id)) //{ // //Response.End(); //} // var type_id = Convert.ToInt64(type); #region 拉框配置数据源 // 税收种类 tax_cate_id.DataTextField = "show"; tax_cate_id.DataValueField = "val"; tax_cate_id.DataSource = dic.FirstOrDefault(_ => _.Key == "quote_item_tax_cate").Value; tax_cate_id.DataBind(); tax_cate_id.Items.Insert(0, new ListItem() { Value = "0", Text = " ", Selected = true }); // 期间类型 period_type_id.DataTextField = "show"; period_type_id.DataValueField = "val"; period_type_id.DataSource = dic.FirstOrDefault(_ => _.Key == "quote_item_period_type").Value; period_type_id.DataBind(); period_type_id.Items.Insert(0, new ListItem() { Value = "0", Text = " ", Selected = true }); period_type_id.SelectedValue = ((int)QUOTE_ITEM_PERIOD_TYPE.ONE_TIME).ToString(); period_type_id.Enabled = true; #endregion if (!isAdd) { if (quote_item.tax_cate_id != null) { tax_cate_id.SelectedValue = quote_item.tax_cate_id.ToString(); } if (quote_item.period_type_id != null) { period_type_id.SelectedValue = quote_item.period_type_id.ToString(); } if (quote_item.type_id == (int)DTO.DicEnum.QUOTE_ITEM_TYPE.PRODUCT) { thisReserList = new ivt_reserve_dal().GetListByItemId(quote_item.id); } } } catch (Exception) { Response.End(); } }