| | |
| | | */ |
| | | var TypeLot = "1, 5, 6, 7"; //批次可为空单据类型 |
| | | |
| | | int codeStrNum = 0; |
| | | try |
| | | { |
| | | if (model.Origin == "录入" || model.Origin == "导入") |
| | |
| | | && m.CreateTime.ToString("yyyyMM") == DateTime.Now.ToString("yyyyMM")).Max(m => m.BoxCodeStr); |
| | | if(string.IsNullOrWhiteSpace(maxBoxCodeStr)) |
| | | { |
| | | maxBoxCodeStr = "BK" + toDayTime.Substring(2, 4) + "0001"; |
| | | string codeEndStr = (1 + codeStrNum).ToString().PadLeft(4, '0'); |
| | | maxBoxCodeStr = "BK" + toDayTime.Substring(2, 4) + codeEndStr; |
| | | } |
| | | else |
| | | { |
| | | maxBoxCodeStr = "BK" + (int.Parse(maxBoxCodeStr.Replace("BK", "")) + 1).ToString(); |
| | | maxBoxCodeStr = "BK" + (int.Parse(maxBoxCodeStr.Replace("BK", "")) + 1 + codeStrNum).ToString(); |
| | | } |
| | | detailModel.BoxCodeStr = maxBoxCodeStr; |
| | | |
| | | codeStrNum++; |
| | | } |
| | | |
| | | // 判断是否已存在当前明细 |
| | |
| | | // DateTime lot22; |
| | | // if (!DateTime.TryParse(detailModel.Lot1, out lot12)) |
| | | // { |
| | | // throw new Exception("需要请验物料生产日期转换失败"); |
| | | // throw new Exception("需要请验料生产日期转换失败"); |
| | | // } |
| | | // if (!DateTime.TryParse(detailModel.Lot2, out lot22)) |
| | | // { |
| | |
| | | DateTime lot12; |
| | | if (!DateTime.TryParse(detailModel.Lot1, out lot12)) |
| | | { |
| | | throw new Exception("需要请验物料生产日期转换失败"); |
| | | throw new Exception("生产日期转换失败,请检查格式是否正确"); |
| | | } |
| | | lot1 = lot12.ToString("yyyy-MM-dd"); |
| | | } |
| | | if (!string.IsNullOrEmpty(lot2)) |
| | | { |
| | | DateTime lot22; |
| | | if (!DateTime.TryParse(detailModel.Lot1, out lot22)) |
| | | if (!DateTime.TryParse(detailModel.Lot2, out lot22)) |
| | | { |
| | | throw new Exception("需要请验物料生产日期转换失败"); |
| | | throw new Exception("到期日期转换失败,请检查格式是否正确"); |
| | | } |
| | | lot2 = lot22.ToString("yyyy-MM-dd"); |
| | | } |
| | |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | | Db.Ado.RollbackTran(); |
| | | throw new Exception(ex.Message); |
| | | } |
| | | } |
| | |
| | | DateTime lot12; |
| | | if (!DateTime.TryParse(detailModel.Lot1, out lot12)) |
| | | { |
| | | throw new Exception("需要请验物料生产日期转换失败"); |
| | | throw new Exception("生产日期转换失败,请检查格式是否正确"); |
| | | } |
| | | detailModel.Lot1 = lot12.ToString("yyyy-MM-dd"); |
| | | } |
| | | if (!string.IsNullOrEmpty(detailModel.Lot2)) |
| | | { |
| | | DateTime lot22; |
| | | if (!DateTime.TryParse(detailModel.Lot1, out lot22)) |
| | | if (!DateTime.TryParse(detailModel.Lot2, out lot22)) |
| | | { |
| | | throw new Exception("需要请验物料生产日期转换失败"); |
| | | throw new Exception("到期日期转换失败,请检查格式是否正确"); |
| | | } |
| | | detailModel.Lot2 = lot22.ToString("yyyy-MM-dd"); |
| | | } |
| | |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | | Db.Ado.RollbackTran(); |
| | | throw ex; |
| | | } |
| | | } |