/// <summary> /// InsertInfo /// </summary> /// <param name="info"></param> /// <returns></returns> public long InsertInfo(PartsStockInfo info) { ///入库包装数量⑧不能小于等于零,当入库包装型号⑦不为空时入库包装数量⑧为必填项 if (!string.IsNullOrEmpty(info.InboundPackageModel) && info.InboundPackage.GetValueOrDefault() <= 0) { throw new Exception("MC:0x00000089");///当入库包装型号不为空时入库包装数量必须大于零 } ///最小库存 小于等于 安全库存 小于 最大库存,最小库存必须大于等于零 if (info.Min.GetValueOrDefault() > info.SafeStock.GetValueOrDefault()) { throw new Exception("MC:0x00000090");///最小库存不能大于安全库存 } //if (info.IsOutput == true) //{ // if (info.SynchronousWmNo == "" || info.SynchronousZoneNo == "") // throw new Exception("MC:0x00000439");///当同步出库标记为是时,同步出库仓库,存储区为必填项 //} if (info.SafeStock.GetValueOrDefault() >= 0 && info.Max.GetValueOrDefault() > 0 && info.SafeStock.GetValueOrDefault() >= info.Max.GetValueOrDefault()) { throw new Exception("MC:0x00000091");///安全库存不能大于等于最大库存 } ///相同物料号②、供应商代码①、仓库代码⑨、存储区代码⑩、库位代码⑪的数据不允许重复 int cnt = dal.GetCounts("[PART_NO] = N'" + info.PartNo + "' and [SUPPLIER_NUM] = N'" + info.SupplierNum + "' and [WM_NO] = N'" + info.WmNo + "' and [ZONE_NO] = N'" + info.ZoneNo + "'" + (string.IsNullOrEmpty(info.Dloc) ? string.Empty : " and [DLOC] = N'" + info.Dloc + "'")); if (cnt > 0) { throw new Exception("MC:0x00000094");///相同物料号、供应商代码、仓库代码、存储区代码、库位代码的数据不允许重复 } ///若该标记为true时,需要校验该仓库存储区下所有物料的同步出库仓库、同步出库存储区必须相同,是否同步出库默认为false string sameZoneSameFinalZoneValidFlag = new ConfigDAL().GetValueByCode("SAME_ZONE_SAME_FINAL_ZONE_VALID_FLAG"); //if (Convert.ToBoolean(sameZoneSameFinalZoneValidFlag) == true ) //{ // //判断数据库中是否存在 仓库、存储区、是否同步出库 如果没有跳过如果有进行判断是否同步出库仓库、同步出库存储区一致 // int count = new PartsStockDAL().GetCounts("[WM_NO] = N'" + info.WmNo + "' and[ZONE_NO] = N'" + info.ZoneNo ); // if (count != 0) // { // count = new PartsStockDAL().GetCounts("[WM_NO] = N'" + info.WmNo + "' and[ZONE_NO] = N'" + info.ZoneNo + "' and [IS_OUTPUT] = N'" + info.IsOutput + "' and [SYNCHRONOUS_WM_NO] = N'" + info.SynchronousWmNo + "' and [SYNCHRONOUS_ZONE_NO] = N'" + info.SynchronousZoneNo + "'"); // if (count == 0) // throw new Exception("MC:0x00000438");///需要校验该仓库存储区下所有物料的同步出库仓库、同步出库存储区必须相同 // } //} return(dal.Add(info)); }