/// <summary> /// 增加仓库覆盖地区 /// </summary> /// <param name="warehouse">仓库地区关联实体</param> /// <returns>是否添加成功</returns> /// <remarks>2013-08-13 周瑜 创建</remarks> public override int Update(WhWarehouseArea warehouse) { return(Context.Update("WhWarehouseArea", warehouse) .AutoMap(x => x.SysNo) .Where(x => x.SysNo) .Execute()); }
/// <summary> /// 将该仓库设为选中地区的默认发货仓库 /// </summary> /// <param name="whWarehouseArea">地区仓库实体</param> /// <param name="status">是否默认仓库,默认:是</param> /// <returns>是否设置成功</returns> /// <remarks>2013-08-13 周瑜 创建</remarks> /// <remarks>2013-11-06 郑荣华 重构</remarks> public override int SetDefault(WhWarehouseArea whWarehouseArea, WarehouseStatus.是否默认仓库 status) { using (var context = Context.UseSharedConnection(true)) { if (status == WarehouseStatus.是否默认仓库.是) { const string sql = @"update WhWarehouseArea set IsDefault = @status , lastupdateby = @lastupdateby, lastupdatedate = @lastupdatedate where areasysno = @areasysno "; //先全改为否 context.Sql(sql) .Parameter("status", (int)WarehouseStatus.是否默认仓库.否) .Parameter("lastupdateby", whWarehouseArea.LastUpdateBy) .Parameter("lastupdatedate", whWarehouseArea.LastUpdateDate) .Parameter("areasysno", whWarehouseArea.AreaSysNo) .Execute(); } const string strSql = @"update WhWarehouseArea set IsDefault = @status , lastupdateby = @lastupdateby, lastupdatedate = @lastupdatedate where areasysno = @areasysno and warehousesysno = @warehousesysno"; return(context.Sql(strSql) .Parameter("status", (int)status) .Parameter("lastupdateby", whWarehouseArea.LastUpdateBy) .Parameter("lastupdatedate", whWarehouseArea.LastUpdateDate) .Parameter("areasysno", whWarehouseArea.AreaSysNo) .Parameter("warehousesysno", whWarehouseArea.WarehouseSysNo) .Execute()); } }
/// <summary> /// 将该仓库设为选中地区的默认发货仓库 /// </summary> /// <param name="whWarehouseArea">地区仓库实体</param> /// <param name="status">是否默认仓库,默认:是</param> /// <returns>是否设置成功</returns> /// <remarks>2013-08-13 周瑜 创建</remarks> public bool SetDefault(WhWarehouseArea whWarehouseArea, WarehouseStatus.是否默认仓库 status = WarehouseStatus.是否默认仓库.是) { SysLog.Instance.Info(LogStatus.系统日志来源.后台, "将该仓库设为选中地区的默认发货仓库", LogStatus.系统日志目标类型.仓库, whWarehouseArea.WarehouseSysNo); //清除仓库地区缓存 MemoryProvider.Default.Remove(KeyConstant.WhwarehouseAreaList); return(IWhWarehouseAreaDao.Instance.SetDefault(whWarehouseArea, status) > 0); }
/// <summary> /// 修改仓库覆盖地区 /// </summary> /// <param name="warehouse"></param> /// <returns>是否修改成功</returns> /// <remarks>2013-08-13 周瑜 创建</remarks> public bool Update(WhWarehouseArea warehouse) { SysLog.Instance.Info(LogStatus.系统日志来源.后台, "修改仓库覆盖地区", LogStatus.系统日志目标类型.仓库, warehouse.SysNo); //清除仓库地区缓存 MemoryProvider.Default.Remove(KeyConstant.WhwarehouseAreaList); return(IWhWarehouseAreaDao.Instance.Update(warehouse) > 0); }
/// <summary> /// 增加仓库覆盖地区 /// </summary> /// <param name="warehouse">仓库地区关联实体</param> /// <returns>新增记录的系统编号</returns> /// <remarks>2013-08-13 周瑜 创建</remarks> public override int Insert(WhWarehouseArea warehouse) { int id = 0; using (IDbContext context = Context.UseSharedConnection(true)) { var count = context.Sql( "select count(*) from whwarehousearea where areasysno = @areasysno and warehousesysno = @warehousesysno") .Parameter("areasysno", warehouse.AreaSysNo) .Parameter("warehousesysno", warehouse.WarehouseSysNo) .QuerySingle <int>(); if (count == 0) { id = context.Insert("WhWarehouseArea", warehouse) .AutoMap(x => x.SysNo) .ExecuteReturnLastId <int>("SysNo"); } } return(id); }
/// <summary> /// 将该仓库设为选中地区的默认发货仓库 /// </summary> /// <param name="whWarehouseArea">地区仓库实体</param> /// <param name="status">是否默认仓库,默认:是</param> /// <returns>是否设置成功</returns> /// <remarks>2013-08-13 周瑜 创建</remarks> public abstract int SetDefault(WhWarehouseArea whWarehouseArea, WarehouseStatus.是否默认仓库 status);
/// <summary> /// 增加仓库覆盖地区 /// </summary> /// <param name="warehouse">仓库地区关联实体</param> /// <returns>是否添加成功</returns> /// <remarks>2013-08-13 周瑜 创建</remarks> public abstract int Update(WhWarehouseArea warehouse);
/// <summary> /// 增加仓库覆盖地区 /// </summary> /// <param name="warehouse">仓库地区关联实体</param> /// <returns>新增记录的系统编号</returns> /// <remarks>2013-08-13 周瑜 创建</remarks> public abstract int Insert(WhWarehouseArea warehouse);
/// <summary> /// 仓库覆盖地区增加删除 /// </summary> /// <param name="areaSysNo">传入的地区系统编号 用","链接</param> /// <param name="warehouseSysNo">仓库系统编号</param> /// <param name="currentUserSysNo">当前用户系统编号</param> /// <returns></returns> /// <remarks>2013-08-12 周瑜 创建</remarks> /// <remarks>2013-11-06 郑荣华 重构 </remarks> /// <remarks>2013-11-21 沈强 修改 </remarks> public void SaveWarehouseArea(string areaSysNo, int warehouseSysNo, int currentUserSysNo) { if (areaSysNo == "") { areaSysNo = "0:0"; } var dtSysNo = areaSysNo.Split(','); var model = new WhWarehouseArea { CreatedBy = currentUserSysNo, CreatedDate = DateTime.Now, LastUpdateBy = currentUserSysNo, LastUpdateDate = DateTime.Now, WarehouseSysNo = warehouseSysNo, IsDefault = (int)WarehouseStatus.是否默认仓库.否 }; //var dicList = dtSysNo.ToDictionary(item => int.Parse(item.Split(':')[0]), item => int.Parse(item.Split(':')[1])); var dicList = new Dictionary <int, int>(); dtSysNo.ForEach(d => { var tmp = d.Split(':'); var key = int.Parse(tmp[0]); var value = int.Parse(tmp[1]); if (!dicList.ContainsKey(key)) { dicList.Add(key, value); } }); var list = dicList.Select(p => p.Key).ToList(); var areas = Basic.BasicAreaBo.Instance.GetAreaByWarehouse(warehouseSysNo); //var dicHadOwn = Basic.BasicAreaBo.Instance.GetAreaByWarehouse(warehouseSysNo) // .ToDictionary(item => item.SysNo, item => item.IsDefault); var dicHadOwn = new Dictionary <int, int>(); areas.ForEach(a => { if (!dicHadOwn.ContainsKey(a.SysNo)) { dicHadOwn.Add(a.SysNo, a.IsDefault); } }); var listHadOwn = dicHadOwn.Select(p => p.Key).ToList(); //当前情况 var listDel = listHadOwn.Except(list).ToList(); //要删除的 //要添加的 var dicListAdd = dicList.Where(item => !listHadOwn.Contains(item.Key)).ToDictionary(item => item.Key, item => item.Value); if (areaSysNo == "0:0") { dicListAdd.Remove(0); } //改状态dicList中不一样的,传入的为基准,去掉新加中未设为默认仓库的,去掉交集中状态相同的 var dicListExcept = dicList.Except(dicHadOwn).ToDictionary(item => item.Key, item => item.Value); //去掉交集中状态相同的 var dictemp = dicListAdd.Where(item => item.Value == 0).ToDictionary(item => item.Key, item => item.Value); // 新加中未设为默认仓库的 dicListExcept = dicListExcept.Except(dictemp).ToDictionary(item => item.Key, item => item.Value); // 事务,已经有的不插入、多余的要删除 foreach (var item in dicListAdd)//添加 { model.AreaSysNo = item.Key; Instance.Insert(model); } foreach (var item in listDel)//删除 { Instance.Delete(item, warehouseSysNo); } foreach (var item in dicListExcept)//改状态 { var warehouseArea = new WhWarehouseArea { WarehouseSysNo = warehouseSysNo, LastUpdateBy = currentUserSysNo, LastUpdateDate = DateTime.Now, AreaSysNo = item.Key }; Instance.SetDefault(warehouseArea, (WarehouseStatus.是否默认仓库)item.Value); } }