protected void UpdateSupplierInfo(int LogItemID) { JD_LimitPriceApply_LogDal logdal = new JD_LimitPriceApply_LogDal(); JD_LimitPriceApply_Log logmodel = logdal.Detail(LogItemID); if (logmodel != null) { JD_CuPriceDetail model = Detail(logmodel.ParentID); //供应商编号不相等 禁用原来的铜价信息 if (logmodel.SupplierCode != model.SupplierCode) { #region 新增铜价阶梯价记录 JD_CuPriceDetail newmodel = model; newmodel.SupplierCode = logmodel.SupplierCode; newmodel.SupplierName = logmodel.SupplierName; newmodel.EffectiveDate = DateTime.Now; newmodel.IsDeleted = 0; Add(newmodel); #endregion //禁用原来的铜价信息 model.IsDeleted = 1; Update(model); } } }
public void UpdateParentID() { try { string sql = " select distinct TaskID from [dbo].[JD_LimitPriceApply_Log] where ApplyType='3' and ParentID=0 order by TaskID asc "; JD_LimitPriceApply_LogDal limtdal = new JD_LimitPriceApply_LogDal(); DataView dv = DBUtil.Query(sql, connectionString).Tables[0].DefaultView; foreach (DataRowView dr in dv) { string DataSql = string.Format(@"select * from[dbo].[JD_LimitPriceApply_Log] where ApplyType = '3' and ParentID = 0 and TaskID = '{0}'", dr["TaskID"].ToString()); DataView Newdv = DBUtil.Query(DataSql, connectionString).Tables[0].DefaultView; int Count = 0; foreach (DataRowView drchild in Newdv) { //偶数行 更新Parent if (Count % 2 == 1) { int ItemID = Convert.ToInt32(drchild["ItemID"].ToString()); JD_LimitPriceApply_Log limlogNew = limtdal.Detail(ItemID); JD_LimitPriceApply_Log limlog = limtdal.Detail(ItemID - 1); if (limlog != null) { JD_CuPriceDetail detailMol = Detail(limlog.SupplierCode, limlog.ItemCode, limlog.BeginCuPrice, limlog.EndCuPrice, limlog.FromCount, limlog.EndCount); limlogNew.ParentID = detailMol.ItemID; limtdal.Update(limlogNew); } } Count++; } } } catch (Exception ex) { common.WriteLogs("铜价阶梯价服务错误:" + ex.Message); } finally { } }
/// <summary> /// 根据限价日志的ID 批量处理 /// </summary> /// <param name="ItemID"></param> /// JD_LimitPriceApply 数据 更新至JD_CuPriceDetail中 public void HandleCuPrice(int ItemID, string FileName, int TaskID) { JD_LimitPriceApply_LogDal logdal = new JD_LimitPriceApply_LogDal(); JD_LimitPriceApply_Log Logmodel = logdal.Detail(ItemID); JD_CuPriceDetailDal detaildal = new JD_CuPriceDetailDal(); JD_CuPriceDetail detailmodel = new JD_CuPriceDetail(); string ErrorMsg = string.Empty; int CuPriceID = 0; try { if (Logmodel != null) { #region 本地集成 switch (Logmodel.ApplyType) { case "1": //新增 #region 新增 //判断是否存在 若存在 更新单价 detailmodel = Detail(Logmodel.SupplierCode, Logmodel.ItemCode, Logmodel.BeginCuPrice, Logmodel.EndCuPrice, Logmodel.FromCount, Logmodel.EndCount); if (detailmodel != null && !string.IsNullOrEmpty(detailmodel.SupplierCode)) { detailmodel.Price = Logmodel.Price; detailmodel.PriceRemarks = Logmodel.PriceRemarks; detailmodel.EffectiveDate = DateTime.Now; Update(detailmodel); } else { //不存在 更新 CuPriceID = detaildal.Add(new JD_CuPriceDetail { ItemName = Logmodel.ItemName, ItemCode = Logmodel.ItemCode, FUnit = Logmodel.FUnit, BeginCuPrice = Logmodel.BeginCuPrice, EndCuPrice = Logmodel.EndCuPrice, FromCount = Logmodel.FromCount, EndCount = Logmodel.EndCount, SupplierName = Logmodel.SupplierName, SupplierCode = Logmodel.SupplierCode, CoinType = Logmodel.CoinType, Price = Logmodel.Price, MOQ = Logmodel.MOQ, PPQ = Logmodel.PPQ, LimitTimes = Logmodel.LimitTimes, FModel = Logmodel.FModel, CreateTime = DateTime.Now, Operater = Logmodel.Operater, PackageInfo = Logmodel.PackageInfo, //CostPrice = Logmodel.CostPrice, //CostCoinType = Logmodel.CostCoinType, CostPrice = Logmodel.Price, CostCoinType = Logmodel.CoinType, PriceRemarks = Logmodel.PriceRemarks, EffectiveDate = DateTime.Now }); Logmodel.ParentID = CuPriceID; } #endregion break; case "2": //删除 #region 除 detailmodel = Detail(Logmodel.SupplierCode, Logmodel.ItemCode, Logmodel.BeginCuPrice, Logmodel.EndCuPrice, Logmodel.FromCount, Logmodel.EndCount); if (detailmodel != null && !string.IsNullOrEmpty(detailmodel.SupplierCode)) { detailmodel.IsDeleted = 1; detailmodel.EffectiveDate = DateTime.Now; Update(detailmodel); } #endregion break; case "3": //涨价 case "4": //降价 //2018-11-19 阶梯价更新时 数量也被修改 所以用ItemID确定唯一性 //detailmodel = Detail(Logmodel.SupplierCode, Logmodel.ItemCode, Logmodel.BeginCuPrice, Logmodel.EndCuPrice, Logmodel.FromCount, Logmodel.EndCount); detailmodel = Detail(Logmodel.ParentID); if (detailmodel != null && !string.IsNullOrEmpty(detailmodel.SupplierCode)) { detailmodel.Price = Logmodel.Price; //2018-10-29 单价和限价不做区分 //detailmodel.CostPrice = Logmodel.CostPrice; detailmodel.CostPrice = Logmodel.Price; //2018-10-18 价格变更中还要包括铜价和数量的变更 detailmodel.BeginCuPrice = Logmodel.BeginCuPrice; detailmodel.EndCuPrice = Logmodel.EndCuPrice; detailmodel.FromCount = Logmodel.FromCount; detailmodel.EndCount = Logmodel.EndCount; detailmodel.EffectiveDate = DateTime.Now; detailmodel.CoinType = Logmodel.CoinType; //detailmodel.MOQ = Logmodel.MOQ; //detailmodel.PPQ = Logmodel.PPQ; //detailmodel.LimitTimes = Logmodel.LimitTimes; Update(detailmodel); } //2018-10-17 如果供应商变更了,需要IsDeleted原来的数据,并新增数据 UpdateSupplierInfo(Logmodel.ItemID); break; case "5": //其他变更 除了价格的变更 //2018-10-17 已不存在其他变更 #region 除了价格的变更 料号和供应商不能变 detailmodel = Detail(Logmodel.SupplierCode, Logmodel.ItemCode, Logmodel.BeginCuPrice, Logmodel.EndCuPrice, Logmodel.FromCount, Logmodel.EndCount); if (detailmodel != null && !string.IsNullOrEmpty(detailmodel.SupplierCode)) { detailmodel.FUnit = Logmodel.FUnit; detailmodel.BeginCuPrice = Logmodel.BeginCuPrice; detailmodel.EndCuPrice = Logmodel.EndCuPrice; detailmodel.FromCount = Logmodel.FromCount; detailmodel.EndCount = Logmodel.EndCount; detailmodel.CoinType = Logmodel.CoinType; detailmodel.MOQ = Logmodel.MOQ; detailmodel.PPQ = Logmodel.PPQ; detailmodel.LimitTimes = Logmodel.LimitTimes; detailmodel.FModel = Logmodel.FModel; detailmodel.Operater = Logmodel.Operater; detailmodel.PackageInfo = Logmodel.PackageInfo; detailmodel.CostCoinType = Logmodel.CostCoinType; Update(detailmodel); } #endregion break; } #endregion #region K3物料集成 UpdateItemInfo(Logmodel.MOQ, Logmodel.PPQ, Logmodel.PackageInfo, Logmodel.ItemCode, ItemID.ToString()); #endregion } } catch (Exception ex) { ErrorMsg = ex.Message; common.WriteLogs(FileName, ItemID.ToString(), "Error:" + ex.Message); } finally { //更新状态 Logmodel.IsUpdate = "1"; Logmodel.UpdateTime = DateTime.Now; logdal.Update(Logmodel); if (!string.IsNullOrEmpty(ErrorMsg)) { common.AddLogQueue(TaskID, "JD_LimitPriceApply_Log", ItemID, "SQL", ErrorMsg, false); } else { common.AddLogQueue(TaskID, "JD_LimitPriceApply_Log", ItemID, "SQL", "操作成功", true); } } }