| | |
| | | private object Checkdata(DataTable dt) |
| | | { |
| | | DataSet ds = new DataSet(); |
| | | string error = ""; |
| | | for (int i = 0; i < dt.Rows.Count; i++) |
| | | { |
| | | //组织 |
| | | ds = oCn.RunProcReturn("select * from Xt_ORGANIZATIONS where Hname='" + dt.Rows[i]["组织"].ToString() + "' ", "Xt_ORGANIZATIONS"); |
| | | if (ds.Tables[0].Rows.Count == 0) |
| | | { |
| | | objJsonResult.code = "0"; |
| | | objJsonResult.count = 0; |
| | | objJsonResult.Message = $"第{(i + 1)}行,组织为{dt.Rows[i]["组织"].ToString()}不存在!"; |
| | | objJsonResult.data = null; |
| | | return objJsonResult; |
| | | error = error+ $"第{(i + 1)}行,组织为{dt.Rows[i]["组织"].ToString()}不存在!"; |
| | | } |
| | | |
| | | //供应商 |
| | | ds = oCn.RunProcReturn("select * from Gy_Supplier where Hname='" + dt.Rows[i]["供应商"].ToString() + "' ", "Gy_Supplier"); |
| | | if (ds.Tables[0].Rows.Count == 0) |
| | | { |
| | | objJsonResult.code = "0"; |
| | | objJsonResult.count = 0; |
| | | objJsonResult.Message = $"第{(i + 1)}行,供应商为{dt.Rows[i]["供应商"].ToString()}不存在!"; |
| | | objJsonResult.data = null; |
| | | return objJsonResult; |
| | | error = error + $"第{(i + 1)}行,供应商为{dt.Rows[i]["供应商"].ToString()}不存在!"; |
| | | } |
| | | |
| | | //收料仓库 |
| | | ds = oCn.RunProcReturn("select * from Gy_Warehouse where Hname='" + dt.Rows[i]["收料仓库"].ToString() + "' ", "Gy_Warehouse"); |
| | | if (ds.Tables[0].Rows.Count == 0) |
| | | { |
| | | objJsonResult.code = "0"; |
| | | objJsonResult.count = 0; |
| | | objJsonResult.Message = $"第{(i + 1)}行,收料仓库为{dt.Rows[i]["收料仓库"].ToString()}不存在!"; |
| | | objJsonResult.data = null; |
| | | return objJsonResult; |
| | | error = error + $"第{(i + 1)}行,收料仓库为{dt.Rows[i]["收料仓库"].ToString()}不存在!"; |
| | | } |
| | | |
| | | //物料编码 |
| | | if (!DBUtility.ClsPub.AllowNumber(dt.Rows[i]["物料编码"].ToString())) |
| | | { |
| | | objJsonResult.code = "0"; |
| | | objJsonResult.count = 0; |
| | | objJsonResult.Message = "物料代码中不能出现连续‘.’并且首位末位不能为‘.’!"; |
| | | objJsonResult.data = null; |
| | | return objJsonResult; |
| | | error = error + "物料代码中不能出现连续‘.’并且首位末位不能为‘.’!"; |
| | | } |
| | | ds = oCn.RunProcReturn("select * from Gy_Material where HNumber='" + dt.Rows[i]["物料编码"].ToString() + "' ", "Gy_Material"); |
| | | if (ds.Tables[0].Rows.Count == 0) |
| | | { |
| | | objJsonResult.code = "0"; |
| | | objJsonResult.count = 0; |
| | | objJsonResult.Message = $"第{(i + 1)}行,物料编码为{dt.Rows[i]["物料编码"].ToString()}不存在!"; |
| | | objJsonResult.data = null; |
| | | return objJsonResult; |
| | | error = error + $"第{(i + 1)}行,物料编码为{dt.Rows[i]["物料编码"].ToString()}不存在!"; |
| | | } |
| | | |
| | | //数量 |
| | | if (dt.Rows[i]["数量"].ToString() == "0") |
| | | { |
| | | objJsonResult.code = "0"; |
| | | objJsonResult.count = 0; |
| | | objJsonResult.Message = $"第{(i + 1)}行,数量不为0!"; |
| | | objJsonResult.data = null; |
| | | return objJsonResult; |
| | | error = error + $"第{(i + 1)}行,数量不为0!"; |
| | | } |
| | | |
| | | //判断导入物料的数量是否大于单据物料的总和数量 |
| | |
| | | { |
| | | objJsonResult.code = "0"; |
| | | objJsonResult.count = 0; |
| | | objJsonResult.Message = $"第{(i + 1)}行导入数量大于采购订单合计数量,请找采购员申请做采购订单!"; |
| | | error = error + $"第{(i + 1)}行导入数量大于采购订单合计数量,请找采购员申请做采购订单!"; |
| | | objJsonResult.data = null; |
| | | return objJsonResult; |
| | | } |
| | | } |
| | | else |
| | | { |
| | | objJsonResult.code = "0"; |
| | | objJsonResult.count = 0; |
| | | objJsonResult.Message = $"第{(i + 1)}行,匹配不到数据信息!"; |
| | | objJsonResult.data = null; |
| | | return objJsonResult; |
| | | error = error + $"第{(i + 1)}行,物料编码:{dt.Rows[i]["物料编码"].ToString()},包装标识:{dt.Rows[i]["包装标识"].ToString()},采购订单可用数量:0,小于订单总需求数量:{dt.Rows[i]["数量"].ToString()},匹配不到数据信息!"; |
| | | } |
| | | } |
| | | |
| | | objJsonResult.code = "1"; |
| | | objJsonResult.count = 1; |
| | | objJsonResult.Message = "没有问题"; |
| | | objJsonResult.data = null; |
| | | return objJsonResult; |
| | | if (error == "") |
| | | { |
| | | objJsonResult.code = "1"; |
| | | objJsonResult.count = 1; |
| | | objJsonResult.Message = "没有问题"; |
| | | objJsonResult.data = null; |
| | | return objJsonResult; |
| | | } |
| | | else |
| | | { |
| | | objJsonResult.code = "0"; |
| | | objJsonResult.count = 0; |
| | | objJsonResult.Message = error; |
| | | objJsonResult.data = null; |
| | | return objJsonResult; |
| | | } |
| | | } |
| | | #endregion |
| | | |