/// <summary>
        ///
        /// </summary>
        /// <param name="fields"></param>
        /// <param name="id"></param>
        /// <returns></returns>
        public bool UpdateInfo(string fields, long id)
        {
            WarehouseLocationInfo info = dal.GetInfo(id);

            if (info == null)
            {
                throw new Exception("MC:0x00000084");///数据错误
            }
            ///仓库
            info.WmNo = CommonBLL.GetFieldValue(fields, "WM_NO");
            WarehouseInfo warehouseInfo = new WarehouseDAL().GetWarehouseInfo(info.WmNo);

            if (warehouseInfo == null)
            {
                throw new Exception("MC:0x00000230");///仓库信息不存在
            }
            ///存储区
            info.ZoneNo = CommonBLL.GetFieldValue(fields, "ZONE_NO");
            ZonesInfo zonesInfo = new ZonesDAL().GetZonesInfo(info.ZoneNo, info.WmNo);

            if (zonesInfo == null)
            {
                throw new Exception("MC:0x00000500");///存储区不存在
            }
            ///库位名称
            info.StorageLocationName = CommonBLL.GetFieldValue(fields, "STORAGE_LOCATION_NAME");
            ///允许存储区代码在不同的仓库中重复使用
            string allow_zoneno_repeat_at_different_warehouse = new ConfigDAL().GetValueByCode("ALLOW_ZONENO_REPEAT_AT_DIFFERENT_WAREHOUSE");
            ///允许库位代码在不同的存储区中重复使用
            string allowDlocRepeatAtDifferentZone = new ConfigDAL().GetValueByCode("ALLOW_DLOC_REPEAT_AT_DIFFERENT_ZONE");

            ///数据校验
            ValidInfo(info, allow_zoneno_repeat_at_different_warehouse, allowDlocRepeatAtDifferentZone);
            return(dal.UpdateInfo(fields, id) > 0 ? true : false);
        }
Пример #2
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="id"></param>
        /// <param name="loginUser"></param>
        /// <returns></returns>
        public bool LogicDeleteInfo(long id, string loginUser)
        {
            ///校验对应是否已经维护了存储区TM_WMM_ZONES,已逻辑删除的存储区不在校验范围内
            int cnt = new ZonesDAL().GetCounts("[WM_NO] in (select [WAREHOUSE] from LES.[TM_BAS_WAREHOUSE] with(nolock) where [ID] = " + id + " and [VALID_FLAG] = 1)");

            if (cnt > 0)
            {
                throw new Exception("MC:0x00000720");///仓库下已有存储区,不允许删除
            }
            return(dal.LogicDelete(id, loginUser) > 0 ? true : false);
        }
        /// <summary>
        ///
        /// </summary>
        /// <param name="info"></param>
        /// <returns></returns>
        public long InsertInfo(WarehouseLocationInfo info)
        {
            WarehouseInfo warehouseInfo = new WarehouseDAL().GetWarehouseInfo(info.WmNo);

            if (warehouseInfo == null)
            {
                throw new Exception("MC:0x00000230");///仓库信息不存在
            }
            ZonesInfo zonesInfo = new ZonesDAL().GetZonesInfo(info.ZoneNo, info.WmNo);

            if (zonesInfo == null)
            {
                throw new Exception("MC:0x00000500");///存储区不存在
            }
            ///允许存储区代码在不同的仓库中重复使用
            string allow_zoneno_repeat_at_different_warehouse = new ConfigDAL().GetValueByCode("ALLOW_ZONENO_REPEAT_AT_DIFFERENT_WAREHOUSE");
            ///允许库位代码在不同的存储区中重复使用
            string allowDlocRepeatAtDifferentZone = new ConfigDAL().GetValueByCode("ALLOW_DLOC_REPEAT_AT_DIFFERENT_ZONE");

            ///数据校验
            ValidInfo(info, allow_zoneno_repeat_at_different_warehouse, allowDlocRepeatAtDifferentZone);
            return(dal.Add(info));
        }
Пример #4
0
 void DecreadesZones_Loaded(object sender, RoutedEventArgs e)
 {
     zoneDAL = new ZonesDAL(Library.JENDBManager);
     ReadDecreadesZone();
 }
Пример #5
0
        /// <summary>
        /// 执行导入EXCEL数据
        /// </summary>
        /// <param name="dataTable"></param>
        /// <param name="fieldNames"></param>
        /// <returns></returns>
        public bool ImportDataByExcel(DataTable dataTable, Dictionary <string, string> fieldNames, string loginUser)
        {
            List <ZonesInfo> zonesExcelInfos = CommonDAL.DatatableConvertToList <ZonesInfo>(dataTable).ToList();

            if (zonesExcelInfos.Count == 0)
            {
                throw new Exception("MC:1x00000043");///数据格式不符合导入规范
            }
            ///获取业务表中要变更的数据集合,准备对比
            List <ZonesInfo> zonesInfos = new ZonesDAL().GetList("" +
                                                                 "[ZONE_NO] in ('" + string.Join("','", zonesExcelInfos.Select(d => d.ZoneNo).ToArray()) + "')", string.Empty);
            ///仓库
            List <WarehouseInfo> warehouseInfos = new WarehouseDAL().GetList("" +
                                                                             "[WAREHOUSE] in ('" + string.Join("','", zonesExcelInfos.Select(d => d.WmNo).ToArray()) + "')", string.Empty);
            ///允许存储区代码在不同的仓库中重复使用
            string allow_zoneno_repeat_at_different_warehouse = new ConfigDAL().GetValueByCode("ALLOW_ZONENO_REPEAT_AT_DIFFERENT_WAREHOUSE");
            ///执行的SQL语句
            StringBuilder @string = new StringBuilder();

            List <string> fields = new List <string>(fieldNames.Keys);

            ///逐条处理中间表数据
            foreach (var zonesExcelInfo in zonesExcelInfos)
            {
                WarehouseInfo warehouseInfo = warehouseInfos.FirstOrDefault(d => d.Warehouse == zonesExcelInfo.WmNo);
                if (warehouseInfo == null)
                {
                    throw new Exception("MC:0x00000230");///仓库信息不存在
                }
                ///数据校验
                ValidInfo(zonesExcelInfo, allow_zoneno_repeat_at_different_warehouse);

                ///当前业务数据表中此工厂的该物流路线时需要新增
                ZonesInfo zonesInfo = zonesInfos.FirstOrDefault(d => d.ZoneNo == zonesExcelInfo.ZoneNo && d.WmNo == zonesExcelInfo.WmNo);
                if (zonesInfo == null)
                {
                    ///字段
                    string insertFieldString = string.Empty;
                    ///值
                    string insertValueString = string.Empty;
                    for (int i = 0; i < fields.Count; i++)
                    {
                        string valueStr = CommonDAL.GetFieldValueForSql <ZonesInfo>(zonesExcelInfo, fields[i]);
                        if (string.IsNullOrEmpty(valueStr))
                        {
                            throw new Exception("MC:1x00000043");///数据格式不符合导入规范
                        }
                        insertFieldString += "[" + fieldNames[fields[i]] + "],";
                        insertValueString += valueStr + ",";
                    }
                    ///
                    zonesExcelInfo.Fid = Guid.NewGuid();
                    ///判断业务主键是否重复,以防止EXCEL中有重复数据,适用于基础数据导入
                    @string.AppendLine("if not exists (select * from [LES].[TM_WMM_ZONES] with(nolock) where [ZONE_NO] = N'" + zonesExcelInfo.ZoneNo + "' and [VALID_FLAG] = 1) " +
                                       "insert into [LES].[TM_WMM_ZONES] " +
                                       "([FID]," + insertFieldString + "[CREATE_USER]," + "[CREATE_DATE]," + "[VALID_FLAG]) values " +
                                       "(N'" + zonesExcelInfo.Fid.GetValueOrDefault() + "'," + insertValueString + "N'" + loginUser + "'," + "GETDATE()," + "1);");

                    zonesInfos.Add(zonesExcelInfo);
                    continue;
                }

                if (string.IsNullOrEmpty(zonesExcelInfo.ZoneName))
                {
                    throw new Exception("MC:0x00000739");///存储区名称不能为空
                }
                if (string.IsNullOrEmpty(zonesExcelInfo.WmNo))
                {
                    throw new Exception("MC:0x00000528");///仓库代码不能为空
                }
                if (zonesExcelInfo.Settlementflag == null)
                {
                    throw new Exception("MC:0x00000529");///结算标记不能为空
                }
                ///值
                string valueString = string.Empty;
                for (int i = 0; i < fields.Count; i++)
                {
                    string valueStr = CommonDAL.GetFieldValueForSql <ZonesInfo>(zonesExcelInfo, fields[i]);
                    if (string.IsNullOrEmpty(valueStr))
                    {
                        throw new Exception("MC:1x00000043");///数据格式不符合导入规范
                    }
                    valueString += "[" + fieldNames[fields[i]] + "] = " + valueStr + ",";
                }
                @string.AppendLine("update [LES].[TM_WMM_ZONES] " +
                                   "set " + valueString + "[MODIFY_USER] = N'" + loginUser + "'," + "[MODIFY_DATE] = GETDATE() " +
                                   "where [FID] = N'" + zonesInfo.Fid.GetValueOrDefault() + "';");
            }
            ///执行
            using (var trans = new TransactionScope())
            {
                if (@string.Length > 0)
                {
                    CommonDAL.ExecuteNonQueryBySql(@string.ToString());
                }
                trans.Complete();
            }
            return(true);
        }
        /// <summary>
        /// 根据仓库信息同步供应商信息
        /// </summary>
        /// <param name="warehouseInfo"></param>
        public void SyncSupplierByWarehouse(WarehouseInfo warehouseInfo, string loginUser)
        {
            ///类型为内部仓库时不同步供应商信息
            if (warehouseInfo.WarehouseType.GetValueOrDefault() != (int)WarehouseTypeConstants.VMI)
            {
                return;
            }
            StringBuilder @string = new StringBuilder();
            ///是否存在供应商信息
            SupplierInfo supplierInfo = dal.GetSupplierInfo(warehouseInfo.Warehouse);

            if (supplierInfo == null)
            {
                supplierInfo              = new SupplierInfo();
                supplierInfo.Fid          = Guid.NewGuid();
                supplierInfo.SupplierNum  = warehouseInfo.Warehouse;
                supplierInfo.SupplierName = warehouseInfo.WarehouseName;
                supplierInfo.SupplierType = (int)SupplierTypeConstants.LogisticsSupplier;
                supplierInfo.ValidFlag    = true;
                supplierInfo.CreateUser   = loginUser;
                supplierInfo.CreateDate   = DateTime.Now;
                @string.AppendLine(SupplierDAL.GetInsertSql(supplierInfo));
            }
            else
            {
                ///当供应商类型为储运供应商时才更新其信息
                if (supplierInfo.SupplierType.GetValueOrDefault() == (int)SupplierTypeConstants.LogisticsSupplier)
                {
                    @string.AppendLine("update [LES].[TM_BAS_SUPPLIER] " +
                                       "set [SUPPLIER_NAME] = N'" + warehouseInfo.WarehouseName + "'," +
                                       "[MODIFY_USER] = N'" + loginUser + "'," +
                                       "[MODIFY_DATE] = GETDATE() " +
                                       "where [ID] = " + supplierInfo.Id + ";");
                }
            }
            ///同步创建或更新存储区信息
            ///获取相同代码的存储区
            ZonesInfo zonesInfo = new ZonesDAL().GetZonesInfo(warehouseInfo.Warehouse, warehouseInfo.Warehouse);

            if (zonesInfo == null)
            {
                zonesInfo                = new ZonesInfo();
                zonesInfo.ZoneNo         = warehouseInfo.Warehouse;
                zonesInfo.ZoneName       = warehouseInfo.WarehouseName;
                zonesInfo.WmNo           = warehouseInfo.Warehouse;
                zonesInfo.Plant          = warehouseInfo.Plant;
                zonesInfo.Settlementflag = false;
                zonesInfo.CreateUser     = loginUser;
                zonesInfo.CreateDate     = DateTime.Now;
                @string.AppendLine(ZonesDAL.GetInsertSql(zonesInfo));
            }
            else
            {
                @string.AppendLine("update [LES].[TM_WMM_ZONES] " +
                                   "set [ZONE_NAME] = N'" + warehouseInfo.WarehouseName + "'," +
                                   "[WM_NO] = N'" + warehouseInfo.Warehouse + "'," +
                                   "[PLANT] = N'" + warehouseInfo.Plant + "'," +
                                   "[MODIFY_USER] = N'" + loginUser + "'," +
                                   "[MODIFY_DATE] = GETDATE() " +
                                   "where [ID] = " + zonesInfo.Id + ";");
            }
            CommonDAL.ExecuteNonQueryBySql(@string.ToString());
        }