diff --git a/Controller/SCP_ASK_CONTROLLER.cs b/Controller/SCP_ASK_CONTROLLER.cs index e86c066..de89ec5 100644 --- a/Controller/SCP_ASK_CONTROLLER.cs +++ b/Controller/SCP_ASK_CONTROLLER.cs @@ -375,17 +375,25 @@ namespace CK.SCP.Controller { q = q.Where(p => p.PartDesc1.Contains(p_entity.PartDesc1)); } - if (p_entity.BeginTime != null) + if (p_entity.BeginTimeStart != null) { - q = q.Where(p => p.BeginTime >= p_entity.BeginTime); + q = q.Where(p => p.BeginTime >= p_entity.BeginTimeStart); } if (p_entity.BeginTimeEnd != null) { q = q.Where(p => p.BeginTime <= p_entity.BeginTimeEnd); } - if (p_entity.EndTime != null) + if (p_entity.EndTimeStart != null) { - q = q.Where(p => p.EndTime < p_entity.EndTime); + q = q.Where(p => p.EndTime >= p_entity.EndTimeStart); + } + if (p_entity.EndTimeEnd != null) + { + q = q.Where(p => p.EndTime <= p_entity.EndTimeEnd); + } + if (p_entity.VendId != null) + { + q = q.Where(p => p.VendId.Contains(p_entity.VendId)); } if (p_entity.UserInAddress != null && p_entity.UserInAddress.Count > 0) { @@ -797,7 +805,7 @@ namespace CK.SCP.Controller throw e; } return _ret; - } + } public static ResultObject Save_TB_ASK_DETAIL(List p_entitys, AskState p_state) { ResultObject _ret = new ResultObject(); @@ -912,12 +920,87 @@ namespace CK.SCP.Controller } return _ret; } - /// - /// - /// - /// - /// - public static ResultObject Save_TB_PO(List p_entitys) + public static ResultObject Update_TB_ASK(TB_ASK p_entitys) + { + ResultObject _ret = new ResultObject(); + try + { + using (ScpEntities db = EntitiesFactory.CreateScpInstance()) + { + + var ret= db.TB_ASK.Where(p => p.AskBillNum == p_entitys.AskBillNum).FirstOrDefault(); + ret.Extend1 = p_entitys.Extend1; + + db.TB_ASK.AddOrUpdate(ret); + if (db.SaveChanges() != -1) + { + _ret.State = ReturnStatus.Succeed; + _ret.Result = true; + } + else + { + _ret.State = ReturnStatus.Failed; + _ret.Result = false; + } + } + } + catch (System.Data.Entity.Validation.DbEntityValidationException dbEx)//捕获实体验证异常 + { + var sb = new StringBuilder(); + foreach (var error in dbEx.EntityValidationErrors.ToList()) + { + error.ValidationErrors.ToList().ForEach(i => + { + sb.AppendFormat("表:{0},字段:{1},信息:{2}\r\n", error.Entry.Entity.GetType().Name, i.PropertyName, i.ErrorMessage); + }); + } + _ret.State = ReturnStatus.Failed; + _ret.Result = false; + _ret.ErrorList.Add(dbEx); + LogHelper.Writlog(LogHelper.LogType.Error, typeof(SCP_ASK_CONTROLLER), "Save_TB_ASK_DETAIL", sb.ToString()); + throw new ScpException(ResultCode.DbEntityValidationException, sb.ToString(), "字段验证失败" + sb.ToString()); + } + catch (OptimisticConcurrencyException ex)//并发冲突异常 + { + _ret.State = ReturnStatus.Failed; + _ret.Result = false; + _ret.ErrorList.Add(ex); + LogHelper.Writlog(LogHelper.LogType.Error, typeof(SCP_ASK_CONTROLLER), "Save_TB_ASK_DETAIL", ex.ToString()); + throw new ScpException(ResultCode.Exception, "9999", ex.ToString()); + } + catch (ScpException ex) + { + _ret.State = ReturnStatus.Failed; + _ret.Result = false; + _ret.ErrorList.Add(ex); + LogHelper.Writlog(LogHelper.LogType.Error, typeof(SCP_ASK_CONTROLLER), "Save_TB_ASK_DETAIL", ex.ToString()); + if (ex.InnerException != null && ex.InnerException.GetType() == typeof(UpdateException)) + { + var inner = (UpdateException)ex.InnerException; + throw new ScpException(ResultCode.Exception, "0000", ex.ToString()); + } + else + { + if (ex.InnerException != null) throw ex.InnerException; + } + } + catch (Exception e) + { + _ret.State = ReturnStatus.Failed; + LogHelper.Writlog(LogHelper.LogType.Error, typeof(SCP_ASK_CONTROLLER), "Save_TB_ASK_DETAIL", e.Message); + _ret.Result = false; + _ret.ErrorList.Add(e); + throw e; + } + return _ret; + } + + /// + /// + /// + /// + /// + public static ResultObject Save_TB_PO(List p_entitys) { ResultObject _ret = new ResultObject(); try @@ -1140,6 +1223,7 @@ namespace CK.SCP.Controller _t.CreateTime = DateTime.Now; _t.CreateUser = p_buyer; _t.Site = p_ask.Site; + _t.SubSite = p_ask.SubSite; _t.Remark = p_ask.Remark; _t.State = (int)AsnState.New; _t.Remark = p_ask.Remark; @@ -1183,6 +1267,8 @@ namespace CK.SCP.Controller _tDetail.UpdateInfo = itm.UpdateInfo; _tDetail.ReceivedPort = itm.ReceivedPort; _tDetail.GUID = Guid.NewGuid(); + _tDetail.SubSite = itm.SubSite; + _tDetail.Site = itm.Site; db.TB_ASN_DETAIL.Add(_tDetail); var _order_detail = db.TB_ASK_DETAIL.Where(p => p.UID == itm.UID).FirstOrDefault(); _order_detail.ShippedQty = (decimal)itm.ShippedQty; @@ -1550,7 +1636,7 @@ namespace CK.SCP.Controller } } - + public static void Get_V_TB_ASK_DETAIL_Sum(V_TB_ASK_DETAIL p_entity, Action>> p_action) { @@ -1799,7 +1885,7 @@ namespace CK.SCP.Controller try { using (ScpEntities db = EntitiesFactory.CreateScpInstance()) - { + { if (p_state == AskState.Close) { var _ls = db.TB_ASK.Where(p => p_list.Contains(p.AskBillNum)).ToList(); @@ -1869,19 +1955,19 @@ namespace CK.SCP.Controller if (p_state == AskState.Confirm) { var _ls = db.TB_ASK.Where(p => p_list.Contains(p.AskBillNum)).ToList(); - int count = _ls.Count(p => p.State == (int)AskState.Release); + int count = _ls.Count(p => p.State == (int)AskState.Release); if (count == _ls.Count && _ls.Count > 0) { _ls.ForEach(p => { - p.State = (int)AskState.Confirm; + p.State = (int)AskState.Confirm; var _list = db.TB_ASK_DETAIL.Where(itm => itm.AskBillNum == p.AskBillNum).ToList(); _list.ForEach(itm => { itm.State = (int)AskState.Confirm; - itm.UpdateTime = DateTime.Now; + itm.UpdateTime = DateTime.Now; } ); @@ -1937,7 +2023,7 @@ namespace CK.SCP.Controller { _ls.ForEach(p => { - p.State = (int)AskState.Release; + p.State = (int)AskState.Release; var _list = db.TB_ASK_DETAIL.Where(itm => itm.AskBillNum == p.AskBillNum).ToList(); _list.ForEach(itm => { @@ -2081,7 +2167,7 @@ namespace CK.SCP.Controller _ret.Message = "选择的记录,有不是新建或发布状态记录!"; } - } + } if (p_state == AskState.NoConfirm) { var _ls = db.TB_ASN.Where(p => p_list.Contains(p.AskBillNum) && p.IsDeleted == false).ToList(); diff --git a/Controller/SCP_ASN_CONTROLLER.cs b/Controller/SCP_ASN_CONTROLLER.cs index a9b0bdd..47f2768 100644 --- a/Controller/SCP_ASN_CONTROLLER.cs +++ b/Controller/SCP_ASN_CONTROLLER.cs @@ -863,6 +863,7 @@ namespace CK.SCP.Controller _detail.LineNO = p.PoLine.ToString(); _detail.Memo = p.Remark; _detail.Batch = p.Batch; + _detail.VendBatch = p.VendBatch; _detail.DockCode = p.DockCode; _detail.ProjectId = _lst.Where(itm => itm.PartCode == p.PartCode).FirstOrDefault().ProjectId; _lsDetail.Add(_detail); @@ -1665,7 +1666,6 @@ namespace CK.SCP.Controller string _oldpartcode = ""; //上一个托盘所装零件编号 decimal _oldbox = 0; //上一个托盘箱数计数 string _oldpalletnum = "";//上一个托盘码 - List _listm = new List(); p_list.ForEach(p => { var _askDetail = db.TA_VEND_PART.Where @@ -1673,10 +1673,10 @@ namespace CK.SCP.Controller && itm.PartCode == p.PartCode ).FirstOrDefault(); if (_askDetail != null) - { + { var _palletPack = _askDetail.PalletPackQty; #region 补充未满托盘 - if (p.PartCode== _oldpartcode) + if (p.PartCode == _oldpartcode) { decimal _box1 = 0; int _TempQty1 = Convert.ToInt32(p.Qty); @@ -1697,7 +1697,7 @@ namespace CK.SCP.Controller _box1++; } } - if(_box1< _oldbox) + if (_box1 < _oldbox) { TB_PALLETS pallet = new TB_PALLETS(); pallet.AsnBillNum = p.AsnBillNum; @@ -1707,6 +1707,11 @@ namespace CK.SCP.Controller pallet.Box = Convert.ToInt32(_box1); pallet.Qty = p.Qty; pallet.PalletNum = _oldpalletnum; + pallet.BarCode = _oldpalletnum; + pallet.VendBatch = p.VendBatch; + pallet.PoBillLine = p.PoLine; + pallet.PoBillNum = p.PoBillNum; + pallet.ProduceDate = Convert.ToDateTime(p.ProduceDate); db.TB_PALLETS.Add(pallet); p.Qty = 0; } @@ -1718,10 +1723,15 @@ namespace CK.SCP.Controller pallet.Batch = p.Batch; pallet.VendId = p.VendId; pallet.Box = Convert.ToInt32(_oldbox); - pallet.Qty = _oldbox* _PackQty1; + pallet.Qty = _oldbox * _PackQty1; pallet.PalletNum = _oldpalletnum; + pallet.BarCode = _oldpalletnum; + pallet.VendBatch = p.VendBatch; + pallet.PoBillLine = p.PoLine; + pallet.PoBillNum = p.PoBillNum; + pallet.ProduceDate = Convert.ToDateTime(p.ProduceDate); db.TB_PALLETS.Add(pallet); - p.Qty = p.Qty- _oldbox * _PackQty1; + p.Qty = p.Qty - _oldbox * _PackQty1; } } #endregion @@ -1757,6 +1767,12 @@ namespace CK.SCP.Controller pallet.Box = Convert.ToInt32(_box); pallet.Qty = p.Qty; pallet.PalletNum = SCP_BILLCODE_CONTROLLER.MakePalletCode_QD(codenum); + pallet.BarCode = pallet.PalletNum; + pallet.VendBatch = p.VendBatch; + pallet.PoBillLine = p.PoLine; + pallet.PoBillNum = p.PoBillNum; + pallet.ProduceDate = Convert.ToDateTime(p.ProduceDate); + db.TB_PALLETS.Add(pallet); _oldpartcode = p.PartCode; _oldbox = Convert.ToInt32(_palletPack) - _box; @@ -1771,7 +1787,7 @@ namespace CK.SCP.Controller { _pallet++; } - for (int i = 1; i <= _pallet;i++) + for (int i = 1; i <= _pallet; i++) { TB_PALLETS pallet = new TB_PALLETS(); pallet.AsnBillNum = p.AsnBillNum; @@ -1779,6 +1795,11 @@ namespace CK.SCP.Controller pallet.Batch = p.Batch; pallet.VendId = p.VendId; pallet.PalletNum = SCP_BILLCODE_CONTROLLER.MakePalletCode_QD(codenum); + pallet.BarCode = pallet.PalletNum; + pallet.VendBatch = p.VendBatch; + pallet.PoBillLine = p.PoLine; + pallet.PoBillNum = p.PoBillNum; + pallet.ProduceDate = Convert.ToDateTime(p.ProduceDate); if (i == _pallet) { pallet.Box = Convert.ToInt32(_box - Convert.ToDecimal(_palletPack) * (_pallet - 1)); @@ -1802,17 +1823,27 @@ namespace CK.SCP.Controller _list.Add(_str); } }); - int state = db.SaveChanges(); - if (state != -1) - { - _ret.State = ReturnStatus.Succeed; - _ret.Result = true; + if (_list.Count == 0) + { + int state = db.SaveChanges(); + if (state != -1) + { + _ret.State = ReturnStatus.Succeed; + _ret.Result = true; + } + else + { + _ret.State = ReturnStatus.Failed; + _ret.Result = false; + _ret.MessageList = _list; + } } else { _ret.State = ReturnStatus.Failed; _ret.Result = false; - _ret.MessageList = _listm; + _ret.MessageList = _list; + } } } @@ -1866,6 +1897,256 @@ namespace CK.SCP.Controller } return _ret; } + + public static ResultObject Save_TB_PALLET_JZJH(List p_list) + { + ResultObject _ret = new ResultObject(); + try + { + using (ScpEntities db = EntitiesFactory.CreateScpInstance()) + { + List _list = new List(); + string _oldpartcode = ""; //上一个托盘所装零件编号 + decimal _oldbox = 0; //上一个托盘箱数计数 + string _oldpalletnum = "";//上一个托盘码 + string _oldpalletfullnum = "";//上一个托盘码 + p_list.ForEach(p => + { + var _askDetail = db.TA_VEND_PART.Where + (itm => itm.VendId == p.VendId + && itm.PartCode == p.PartCode + ).FirstOrDefault(); + if (_askDetail != null) + { + var _palletPack = _askDetail.PalletPackQty; + #region 补充未满托盘 + if (p.PartCode== _oldpartcode) + { + decimal _box1 = 0; + int _TempQty1 = Convert.ToInt32(p.Qty); + int _PackQty1 = Convert.ToInt32(p.PackQty); + if (_TempQty1 / _PackQty1 > 0) + { + int _count = _TempQty1 / _PackQty1; + _box1 += _count; + if (p.Qty % p.PackQty > 0) + { + _box1++; + } + } + else + { + if (_TempQty1 > 0) + { + _box1++; + } + } + if(_box1< _oldbox) + { + TB_PALLETS pallet = new TB_PALLETS(); + pallet.AsnBillNum = p.AsnBillNum; + pallet.PartCode = p.PartCode; + pallet.Batch = p.Batch; + pallet.VendId = p.VendId; + pallet.Box = Convert.ToInt32(_box1); + pallet.Qty = p.Qty; + pallet.PalletNum = _oldpalletnum; + pallet.BarCode = _oldpalletnum; + pallet.FullBarCode = _oldpalletfullnum; + pallet.VendBatch = p.VendBatch; + pallet.PoBillLine = p.PoLine; + pallet.PoBillNum = p.PoBillNum; + pallet.ProduceDate =Convert.ToDateTime( p.ProduceDate); + db.TB_PALLETS.Add(pallet); + p.Qty = 0; + } + else + { + TB_PALLETS pallet = new TB_PALLETS(); + pallet.AsnBillNum = p.AsnBillNum; + pallet.PartCode = p.PartCode; + pallet.Batch = p.Batch; + pallet.VendId = p.VendId; + pallet.Box = Convert.ToInt32(_oldbox); + pallet.Qty = _oldbox* _PackQty1; + pallet.PalletNum = _oldpalletnum; + pallet.BarCode = _oldpalletnum; + pallet.FullBarCode = _oldpalletfullnum; + pallet.VendBatch = p.VendBatch; + pallet.PoBillLine = p.PoLine; + pallet.PoBillNum = p.PoBillNum; + pallet.ProduceDate = Convert.ToDateTime(p.ProduceDate); + db.TB_PALLETS.Add(pallet); + p.Qty = p.Qty- _oldbox * _PackQty1; + } + } + #endregion + #region 新托盘 + if (p.Qty != 0) + { + decimal _box = 0; + int _TempQty = Convert.ToInt32(p.Qty); + int _PackQty = Convert.ToInt32(p.PackQty); + if (_TempQty / _PackQty > 0) + { + int _count = _TempQty / _PackQty; + _box += _count; + if (p.Qty % p.PackQty > 0) + { + _box++; + } + } + else + { + if (_TempQty > 0) + { + _box++; + } + } + if (_box <= _palletPack) + { + TB_PALLETS pallet = new TB_PALLETS(); + pallet.AsnBillNum = p.AsnBillNum; + pallet.PartCode = p.PartCode; + pallet.Batch = p.Batch; + pallet.VendId = p.VendId; + pallet.Box = Convert.ToInt32(_box); + pallet.Qty = p.Qty; + pallet.VendBatch = p.VendBatch; + pallet.PoBillLine = p.PoLine; + pallet.PoBillNum = p.PoBillNum; + pallet.ProduceDate = Convert.ToDateTime(p.ProduceDate); + var ret = SCP_BARCODE_CONTROLLER.CreatePallets(pallet); + if (ret.State == ReturnStatus.Succeed) + { + pallet.BarCode = pallet.PalletNum; + db.TB_PALLETS.Add(pallet); + _oldpartcode = p.PartCode; + _oldbox = Convert.ToInt32(_palletPack) - _box; + _oldpalletnum = pallet.PalletNum; + _oldpalletfullnum= pallet.FullBarCode; + } + } + else + { + decimal _pallet = 0; + _pallet += Convert.ToInt32(_box) / Convert.ToInt32(_palletPack); + if (_box % _palletPack > 0) + { + _pallet++; + } + for (int i = 1; i <= _pallet;i++) + { + TB_PALLETS pallet = new TB_PALLETS(); + pallet.AsnBillNum = p.AsnBillNum; + pallet.PartCode = p.PartCode; + pallet.Batch = p.Batch; + pallet.VendId = p.VendId; + pallet.VendBatch = p.VendBatch; + pallet.PoBillLine = p.PoLine; + pallet.PoBillNum = p.PoBillNum; + pallet.ProduceDate = Convert.ToDateTime(p.ProduceDate); + if (i == _pallet) + { + pallet.Box = Convert.ToInt32(_box - Convert.ToDecimal(_palletPack) * (_pallet - 1)); + pallet.Qty = p.Qty - Convert.ToDecimal(_palletPack) * (_pallet - 1) * _PackQty; + } + else + { + pallet.Box = Convert.ToInt32(_palletPack); + pallet.Qty = Convert.ToDecimal(_palletPack) * _PackQty; + } + var ret = SCP_BARCODE_CONTROLLER.CreatePallets(pallet); + if (ret.State == ReturnStatus.Succeed) + { + pallet.BarCode = pallet.PalletNum; + db.TB_PALLETS.Add(pallet); + } + } + } + } + #endregion + } + else + { + string _str = string.Format("零件号:{0},供应商编号:{1},没有维护托盘标包数!请先维护供应商零件信息", p.PartCode, p.VendBatch); + _list.Add(_str); + } + }); + int state = db.SaveChanges(); + if (_list.Count == 0) + { + if (state != -1) + { + _ret.State = ReturnStatus.Succeed; + _ret.Result = true; + } + else + { + _ret.State = ReturnStatus.Failed; + _ret.Result = false; + _ret.MessageList = _list; + } + } + else + { + _ret.State = ReturnStatus.Failed; + _ret.Result = false; + _ret.MessageList = _list; + } + + } + } + catch (System.Data.Entity.Validation.DbEntityValidationException dbEx)//捕获实体验证异常 + { + var sb = new StringBuilder(); + foreach (var error in dbEx.EntityValidationErrors.ToList()) + { + error.ValidationErrors.ToList().ForEach(i => + { + sb.AppendFormat("表:{0},字段:{1},信息:{2}\r\n", error.Entry.Entity.GetType().Name, i.PropertyName, i.ErrorMessage); + }); + } + _ret.State = ReturnStatus.Failed; + _ret.Result = false; + _ret.ErrorList.Add(dbEx); + LogHelper.Writlog(LogHelper.LogType.Error, typeof(SCP_ASN_CONTROLLER), "Save_TB_PALLET_JZJH", sb.ToString()); + throw new ScpException(ResultCode.DbEntityValidationException, sb.ToString(), "字段验证失败" + sb.ToString()); + } + catch (OptimisticConcurrencyException ex)//并发冲突异常 + { + _ret.State = ReturnStatus.Failed; + _ret.Result = false; + _ret.ErrorList.Add(ex); + LogHelper.Writlog(LogHelper.LogType.Error, typeof(SCP_ASN_CONTROLLER), "Save_TB_PALLET_JZJH", ex.ToString()); + throw new ScpException(ResultCode.Exception, "9999", ex.ToString()); + } + catch (ScpException ex) + { + _ret.State = ReturnStatus.Failed; + _ret.Result = false; + _ret.ErrorList.Add(ex); + LogHelper.Writlog(LogHelper.LogType.Error, typeof(SCP_ASN_CONTROLLER), "Save_TB_PALLET_JZJH", ex.ToString()); + if (ex.InnerException != null && ex.InnerException.GetType() == typeof(UpdateException)) + { + var inner = (UpdateException)ex.InnerException; + throw new ScpException(ResultCode.Exception, "0000", ex.ToString()); + } + else + { + if (ex.InnerException != null) throw ex.InnerException; + } + } + catch (Exception e) + { + _ret.State = ReturnStatus.Failed; + LogHelper.Writlog(LogHelper.LogType.Error, typeof(SCP_ASN_CONTROLLER), "Save_TB_PALLET", e.Message); + _ret.Result = false; + _ret.ErrorList.Add(e); + throw e; + } + return _ret; + } public static ResultObject Save_TB_CREATE_BARCODE_SYJB(List p_list) { ResultObject _ret = new ResultObject(); diff --git a/Controller/SCP_BARCODE_CONTROLLER.cs b/Controller/SCP_BARCODE_CONTROLLER.cs index 5f3544b..41741c6 100644 --- a/Controller/SCP_BARCODE_CONTROLLER.cs +++ b/Controller/SCP_BARCODE_CONTROLLER.cs @@ -594,6 +594,83 @@ namespace CK.SCP.Controller } return _ret; } + + public static ResultObject CreatePallets(TB_PALLETS p_entity, int cnt = 1) + { + ResultObject _ret = new ResultObject(); + try + { + using (ScpEntities db = EntitiesFactory.CreateScpInstance()) + { + var ret = GetPalletsRule(p_entity.PartCode, p_entity.Batch, cnt); + if (ret.State == ReturnStatus.Succeed) + { + var barcodeRule = ret.Result; + for (int i = cnt; i > 0; i--) + { + var createTime = ScpCache.GetServerTime(); + var code = GetLastPalletsBarCode(p_entity.PartCode, p_entity.Batch, barcodeRule.LastNumber - i + 1); + p_entity.PalletNum = code; + } + var fullCode = GetFullCode_Pallets(p_entity); + p_entity.FullBarCode = fullCode; + _ret.State = ReturnStatus.Succeed; + _ret.Result = p_entity; + } + else + { + _ret.State = ReturnStatus.Failed; + _ret.Message = "!"; + } + } + } + catch (System.Data.Entity.Validation.DbEntityValidationException dbEx)//ʵ֤쳣 + { + var sb = new StringBuilder(); + foreach (var error in dbEx.EntityValidationErrors.ToList()) + { + error.ValidationErrors.ToList().ForEach(i => + { + sb.AppendFormat("{0}ֶΣ{1}Ϣ{2}\r\n", error.Entry.Entity.GetType().Name, i.PropertyName, i.ErrorMessage); + }); + } + _ret.State = ReturnStatus.Failed; + _ret.ErrorList.Add(dbEx); + LogHelper.Writlog(LogHelper.LogType.Error, typeof(SCP_BARCODE_CONTROLLER), "CreateSmallBarcodeList", sb.ToString()); + throw new ScpException(ResultCode.DbEntityValidationException, sb.ToString(), "ֶ֤ʧ" + sb.ToString()); + } + catch (OptimisticConcurrencyException ex)//ͻ쳣 + { + _ret.State = ReturnStatus.Failed; + _ret.ErrorList.Add(ex); + LogHelper.Writlog(LogHelper.LogType.Error, typeof(SCP_BARCODE_CONTROLLER), "CreateSmallBarcodeList", ex.ToString()); + throw new ScpException(ResultCode.Exception, "9999", ex.ToString()); + } + catch (ScpException ex) + { + _ret.State = ReturnStatus.Failed; + _ret.ErrorList.Add(ex); + LogHelper.Writlog(LogHelper.LogType.Error, typeof(SCP_BARCODE_CONTROLLER), "CreateSmallBarcodeList", ex.ToString()); + if (ex.InnerException != null && ex.InnerException.GetType() == typeof(UpdateException)) + { + var inner = (UpdateException)ex.InnerException; + throw new ScpException(ResultCode.Exception, "0000", ex.ToString()); + } + else + { + if (ex.InnerException != null) throw ex.InnerException; + } + } + catch (Exception e) + { + _ret.State = ReturnStatus.Failed; + _ret.ErrorList.Add(e); + LogHelper.Writlog(LogHelper.LogType.Error, typeof(SCP_BARCODE_CONTROLLER), "CreateSmallBarcodeList", e.Message); + throw e; + } + return _ret; + } + public static ResultObject> CreateBarcodeList(V_TB_ASN_DETAIL p_entity, int cnt = 1) { @@ -751,6 +828,20 @@ namespace CK.SCP.Controller } return fullcode; } + + public static string GetFullCode_Pallets(TB_PALLETS barcode) + { + var fullcode = string.Empty; + switch (ScpCache.Config.άʽ) + { + case "1": + fullcode = + GetFullCode(barcode.PalletNum, barcode.Qty, barcode.VendId, barcode.VendBatch, barcode.PoBillNum, + barcode.PoBillLine, barcode.ProduceDate, barcode.AsnBillNum); + break; + } + return fullcode; + } public static string GetFullCode(TS_BARCODE barcode) { var fullcode = string.Empty; @@ -997,6 +1088,101 @@ namespace CK.SCP.Controller } return _ret; } + + private static ResultObject GetPalletsRule(string partcode, string batch, int cnt = 1) + { + ResultObject _ret = new ResultObject(); + try + { + using (ScpEntities db = EntitiesFactory.CreateScpInstance()) + { + + var ruleBatch = batch.Substring(0, 4); + var barcodeRule = db.TB_PALLETS_RULL.Find(partcode, ruleBatch); + if (barcodeRule == null) + { + barcodeRule = new TB_PALLETS_RULL + { + PartCode = partcode, + RuleBatch = ruleBatch, + LastNumber = cnt, + State = 0 + }; + } + else + { + barcodeRule.LastNumber += cnt; + } + + barcodeRule.LastBarCode = GetLastPalletsBarCode(partcode, batch, barcodeRule.LastNumber); + barcodeRule.LastTime = ScpCache.GetServerTime(); + + db.TB_PALLETS_RULL.AddOrUpdate(p => new { p.PartCode, p.RuleBatch }, barcodeRule); + if (db.SaveChanges() != -1) + { + _ret.State = ReturnStatus.Succeed; + _ret.Result = barcodeRule; + + } + else + { + _ret.State = ReturnStatus.Failed; + + } + } + } + catch (System.Data.Entity.Validation.DbEntityValidationException dbEx)//ʵ֤쳣 + { + var sb = new StringBuilder(); + + foreach (var error in dbEx.EntityValidationErrors.ToList()) + { + + error.ValidationErrors.ToList().ForEach(i => + { + sb.AppendFormat("{0}ֶΣ{1}Ϣ{2}\r\n", error.Entry.Entity.GetType().Name, i.PropertyName, i.ErrorMessage); + }); + } + _ret.State = ReturnStatus.Failed; + _ret.ErrorList.Add(dbEx); + LogHelper.Writlog(LogHelper.LogType.Error, typeof(SCP_BARCODE_CONTROLLER), "GetPalletsRule", sb.ToString()); + throw new ScpException(ResultCode.DbEntityValidationException, sb.ToString(), "ֶ֤ʧ" + sb.ToString()); + } + catch (OptimisticConcurrencyException ex)//ͻ쳣 + { + + _ret.State = ReturnStatus.Failed; + _ret.ErrorList.Add(ex); + LogHelper.Writlog(LogHelper.LogType.Error, typeof(SCP_BARCODE_CONTROLLER), "GetPalletsRule", ex.ToString()); + throw new ScpException(ResultCode.Exception, "9999", ex.ToString()); + } + catch (ScpException ex) + { + _ret.State = ReturnStatus.Failed; + _ret.ErrorList.Add(ex); + LogHelper.Writlog(LogHelper.LogType.Error, typeof(SCP_BARCODE_CONTROLLER), "GetPalletsRule", ex.ToString()); + + if (ex.InnerException != null && ex.InnerException.GetType() == typeof(UpdateException)) + { + var inner = (UpdateException)ex.InnerException; + + + throw new ScpException(ResultCode.Exception, "0000", ex.ToString()); + } + else + { + if (ex.InnerException != null) throw ex.InnerException; + } + } + catch (Exception e) + { + _ret.State = ReturnStatus.Failed; + _ret.ErrorList.Add(e); + LogHelper.Writlog(LogHelper.LogType.Error, typeof(SCP_BARCODE_CONTROLLER), "GetPalletsRule", e.Message); + throw e; + } + return _ret; + } private static string GetLastBarCode(string partcode, string batch, int lastnum) { @@ -1014,7 +1200,23 @@ namespace CK.SCP.Controller barcode += lastnum.ToString(ScpCache.Config.кŸʽ); return barcode; } + private static string GetLastPalletsBarCode(string partcode, string batch, int lastnum) + { + + var barcode = string.Empty; + barcode += partcode + ScpCache.Config.ָ; + if (ScpCache.Config.Ӧ̼) + { + barcode += batch + ScpCache.Config.ָ; + } + else + { + barcode += batch + ScpCache.Config.ָ; + } + barcode += lastnum.ToString(ScpCache.Config.кŸʽ); + return barcode; + } private static string GetLastSmallBarCode(string partcode, string batch, int lastnum) { diff --git a/Controller/SCP_BILLCODE_CONTROLLER.cs b/Controller/SCP_BILLCODE_CONTROLLER.cs index bfe208d..916e5ab 100644 --- a/Controller/SCP_BILLCODE_CONTROLLER.cs +++ b/Controller/SCP_BILLCODE_CONTROLLER.cs @@ -54,6 +54,19 @@ namespace CK.SCP.Controller return GetTablePK_QD("G", "TB_PALLETS", "PalletNum", "yyMMdd", 4,num); } + /// + /// 生成订单编号 + /// + /// + /// + public static string MakePoNum(int num = 1) + { + return GetTablePO("P", "TB_PO", "PoBillNum", 7, num); + } + public static string MakeASKCodeByNum(int num) + { + return GetTablePKByNum("K", "TB_ASK", "AskBillNum", "yyMMdd", 4, num); + } public static string MakeASKCode() { @@ -107,6 +120,60 @@ namespace CK.SCP.Controller return GetTablePK(p_Header, p_TableName, p_ColumnName, "yyMMdd",4); } + public static string GetTablePO(string Ext, string TableName, string ColName, int len, int num) + { + var _result = string.Empty; + try + { + using (ScpEntities db = EntitiesFactory.CreateScpInstance()) + { + + string sql = "select max(right(" + ColName + "," + len.ToString() + ")+" + num + ") from " + TableName + " where " + ColName + " like '%P[0-9]%' "; + DbRawSqlQuery result = db.Database.SqlQuery(sql); + var obj = result.FirstOrDefault(); + if (obj == null) + { + _result = Ext + num.ToString().PadLeft(len, '0'); + } + else + { + _result = Ext + result.FirstOrDefault().ToString().PadLeft(len, '0'); + } + } + } + catch (Exception e) + { + LogHelper.Writlog(LogHelper.LogType.Error, typeof(SCP_BILLCODE_CONTROLLER), "GetTablePK", e.Message); + } + return _result; + } + public static string GetTablePKByNum(string Ext, string TableName, string ColName, string Format, int len, int num) + { + var _result = string.Empty; + try + { + using (ScpEntities db = EntitiesFactory.CreateScpInstance()) + { + string time = Ext + DateTime.Now.ToString(Format); + string sql = "select max(right(" + ColName + "," + len.ToString() + ")+" + num + ") from " + TableName + " where " + ColName + " like '" + time + "%'"; + DbRawSqlQuery result = db.Database.SqlQuery(sql); + var obj = result.FirstOrDefault(); + if (obj == null) + { + _result = time + num.ToString().PadLeft(len, '0'); + } + else + { + _result = time + result.FirstOrDefault().ToString().PadLeft(len, '0'); + } + } + } + catch (Exception e) + { + LogHelper.Writlog(LogHelper.LogType.Error, typeof(SCP_BILLCODE_CONTROLLER), "GetTablePK", e.Message); + } + return _result; + } public static string GetTablePK(string Ext, string TableName, string ColName, string Format, int len) { var _result = string.Empty; diff --git a/Controller/SCP_DC_UNI_CONTROLLER.cs b/Controller/SCP_DC_UNI_CONTROLLER.cs index 61292f2..160fa00 100644 --- a/Controller/SCP_DC_UNI_CONTROLLER.cs +++ b/Controller/SCP_DC_UNI_CONTROLLER.cs @@ -395,45 +395,87 @@ namespace CK.SCP.Controller { switch (_task.TableName) { - //case "TED_POD": - // result = UpdatePo(db, scpdb, _task); - // break; + case "TED_PO_MSTR": + result = UpdatePo(db, scpdb, _task); + result.Message = _task.TaskID.ToString(); + Update_TEA_TASK_SUB(db, _task); + EntitiesFactory.SaveDb(scpdb); + EntitiesFactory.SaveDb(db); + EntitiesFactory.SaveDb(dc); + scope.Complete(); + break; case "TED_RECEIPT_MSTR": if (_task.Creator == "QAD") { - result = UpdateRecive(db, scpdb, _task); + result = UpdateReciveQAD(db, scpdb, _task); result.Message = _task.TaskID.ToString(); + Update_TEA_TASK_SUB(db, _task); + EntitiesFactory.SaveDb(scpdb); + EntitiesFactory.SaveDb(db); + EntitiesFactory.SaveDb(dc); + scope.Complete(); } else { - result = UpdateARRIVE(db, scpdb, _task); + result = UpdateRecive(db, scpdb, _task); result.Message = _task.TaskID.ToString(); + Update_TEA_TASK_SUB(db, _task); + EntitiesFactory.SaveDb(scpdb); + EntitiesFactory.SaveDb(db); + EntitiesFactory.SaveDb(dc); + scope.Complete(); } break; - case "TED_RETURN_MSTR": - result = UpdateReturn(db, scpdb, _task); - result.Message = _task.TaskID.ToString(); + case "TED_RETURN_MSTR": + result = UpdateARRIVE(db, scpdb, _task); + result.Message = _task.TaskID.ToString(); + Update_TEA_TASK_SUB(db, _task); + EntitiesFactory.SaveDb(scpdb); + EntitiesFactory.SaveDb(db); + EntitiesFactory.SaveDb(dc); + scope.Complete(); break; case "TES_SUPPLIER": result = UpdateSupplier(db, scpdb,authdb, _task); result.Message = _task.TaskID.ToString(); + Update_TEA_TASK_SUB(db, _task); + EntitiesFactory.SaveDb(scpdb); + EntitiesFactory.SaveDb(db); + EntitiesFactory.SaveDb(dc); + scope.Complete(); + break; + case "TES_SUPPLIER_PART": + result = UpdateSupplierPart(dc, db, scpdb, _task); + result.Message = _task.TaskID.ToString(); + Update_TEA_TASK_SUB(db, _task); + EntitiesFactory.SaveDb(scpdb); + EntitiesFactory.SaveDb(db); + EntitiesFactory.SaveDb(dc); + scope.Complete(); break; - //case "TES_SUPPLIER_PART": - // result = UpdateSupplierPart(dc, db, scpdb, _task); - // break; case "TES_PART_MSTR": result = UpdatePart(db, scpdb, _task); result.Message = _task.TaskID.ToString(); + Update_TEA_TASK_SUB(db, _task); + EntitiesFactory.SaveDb(scpdb); + EntitiesFactory.SaveDb(db); + EntitiesFactory.SaveDb(dc); + scope.Complete(); break; //case "TES_SITE": // result = UpdateFactory(db, scpdb, appscpdb, _task); // break; + case "TES_PURCHASE_PRICE": + result = UpdatePrice(db, scpdb, authdb, _task); + result.Message = _task.TaskID.ToString(); + Update_TEA_TASK_SUB(db, _task); + EntitiesFactory.SaveDb(scpdb); + EntitiesFactory.SaveDb(db); + EntitiesFactory.SaveDb(dc); + scope.Complete(); + break; } - Update_TEA_TASK_SUB(db, _task); - EntitiesFactory.SaveDb(scpdb); - EntitiesFactory.SaveDb(db); - EntitiesFactory.SaveDb(dc); - scope.Complete(); + // p_action(result); result.State = ReturnStatus.Succeed; result.Result = true; @@ -774,7 +816,7 @@ namespace CK.SCP.Controller } - public static ResultObject UpdateRecive(ExchangeCenterContext db, ScpEntities scpdb, TEA_TASK_SUB p_entity) + public static ResultObject UpdateReciveQAD(ExchangeCenterContext db, ScpEntities scpdb, TEA_TASK_SUB p_entity) { ResultObject _ret = new ResultObject(); try @@ -816,23 +858,25 @@ namespace CK.SCP.Controller } scpRcv = new TB_RECEIVE_QAD { - RecvBillNum = detail.ReceiveNbr,//收货单号 + RecvBillNum = detail.ReceiveNbr,//收货单号 + ErpRecvBillNum = detail.ReceiveNbr, State = istate, Remark = "", CreateTime = detail.ReceiptDate == null ? DateTime.Now : (DateTime)detail.ReceiptDate,//创建日期 CreateUser = detail.CreateUser,//创建用户 IsDeleted = false, GUID = detail.TaskID, - BillType = 0 - }; + BillType = 0, + Site = detail.Domain,//地点 + SubSite = detail.Site,//域 + }; scpRcvList.Add(scpRcv); } scpRcv.PoBillNum = detail.PurchaseOrder;//采购单 scpRcv.AsnBillNum = detail.ASN;//发货单号 - scpRcv.Site = detail.Domain;//地点 scpRcv.VendId = detail.Supplier;//供货商名称 scpRcv.ShipTime = detail.ReceiptDate;//收货日期 - scpRcv.SubSite = detail.Site; + scpdb.TB_RECEIVE_QAD.AddOrUpdate(scpRcvList.ToArray()); } @@ -864,6 +908,7 @@ namespace CK.SCP.Controller //} scpRcvDetail = new TB_RECEIVE_DETAIL_QAD(); scpRcvDetail.RecvBillNum = detail.ReceiveNbr;//收货单号 + scpRcvDetail.ErpRecvBillNum = detail.ReceiveNbr;//收货单号 scpRcvDetail.PoBillNum = detail.PurchaseOrder;//采购单 scpRcvDetail.PoLine = detail.Line;//订单行 scpRcvDetail.PartCode = detail.PartCode;//零件号 @@ -871,37 +916,32 @@ namespace CK.SCP.Controller scpRcvDetail.VendBatch = detail.SupplierLot;//供应商批号 scpRcvDetail.PoUnit = detail.Um;//采购单位 scpRcvDetail.LocUnit = detail.logisticsUm;//物流单位 - //收货总量 //DockCode = ?,//收货口 + scpRcvDetail.Qty = detail.ReceiveQuantity; + //收货总量 //DockCode = ?,//收货口 scpRcvDetail.State = 1;// (int)FormState.关闭, - scpRcvDetail.Remark = detail.Remark; scpRcvDetail.CreateTime = detail.CreateTime == null ? DateTime.Now : (DateTime)detail.CreateTime;//创建日期 scpRcvDetail.CreateUser = detail.CreateUser;//创建用户 scpRcvDetail.IsDeleted = false; scpRcvDetail.GUID = detail.TaskID; scpRcvDetail.BillType = 0; + scpRcvDetail.Remark = detail.Remark; scpRcvDetail.SubSite = detail.Shipto; scpRcvDetail.Site = detail.Domain; - //scpRcvDetail.Currency = detail.Currency; - //scpRcvDetail.Currencyamount = detail.Currencyamount; - //scpRcvDetail.ExchangeRate = detail.Exchangerate==null?"1":detail.Exchangerate.Value.ToString(); - //scpRcvDetail.ExchangeRate1 = detail.Exchangerate2 == null ? "1" : detail.Exchangerate2.Value.ToString(); - //scpRcvDetail.ExchangeRateType = detail.Exchangeratetype; - //scpRcvDetail.WorkOrderID = detail.WorkOrderID; - //scpRcvDetail.POSite = detail.Posite; - //scpRcvDetail.POCost = detail.Purchasecost; - //scpRcvDetail.POStandardCost = detail.Purchasestandardcost; - //scpRcvDetail.ReceiptType = detail.receipttype; - //scpRcvDetail.ReturnReasonCode = detail.Returnreason; - //scpRcvDetail.Requestedby = detail.Requestby; - //scpRcvDetail.TaxEnvironment = detail.Taxenvironment; - //scpRcvDetail.TaxIn = detail.taxin; - //scpRcvDetail.TaxUsage = detail.Taxusage; - //scpRcvDetail.TaxClass = detail.Taxclass; - //scpRcvDetail.PurchaseType = detail.Purchasetype; - //scpRcvDetail.UMConversion = detail.Umconversion; - scpRcveDetailList.Add(scpRcvDetail); + scpRcvDetail.PurCost = detail.Purchasecost; + scpRcvDetail.StdCost = detail.Purchasestandardcost; + scpRcvDetail.Rate = detail.Exchangerate; + scpRcvDetail.Tax = detail.Taxclass; + scpRcvDetail.CurAmt = detail.Currencyamount; + scpRcvDetail.DockCode =detail.Location; } - scpRcvDetail.Qty = detail.ReceiveQuantity; + scpRcvDetail.RecvBillNum = detail.ReceiveNbr;//收货单号; + + scpRcvDetail.CurAmt = detail.Currencyamount; + scpRcvDetail.PurCost = detail.Purchasecost; + scpRcvDetail.StdCost = detail.Purchasestandardcost; + scpRcvDetail.Rate = detail.Exchangerate; + scpRcvDetail.Tax = detail.Taxclass; + scpRcveDetailList.Add(scpRcvDetail); } // var _str=JsonHelper.GetJson>(scpRcveDetailList); scpdb.TB_RECEIVE_DETAIL_QAD.AddOrUpdate(scpRcveDetailList.ToArray()); @@ -921,18 +961,17 @@ namespace CK.SCP.Controller } return _ret; } + - - public static ResultObject UpdateARRIVE(ExchangeCenterContext db, ScpEntities scpdb, TEA_TASK_SUB p_entity) + public static ResultObject UpdateRecive(ExchangeCenterContext db, ScpEntities scpdb, TEA_TASK_SUB p_entity) { ResultObject _ret = new ResultObject(); try { - var _reciveList = db.TED_RECEIPT_MSTR.Where(p => p.TaskID == p_entity.TaskID && !string.IsNullOrEmpty(p.ReceiveNbr)).ToList(); + var _reciveList = db.TED_RECEIPT_MSTR.Where(p => p.TaskID == p_entity.TaskID).ToList(); var _scpPoDetailList = new List(); foreach (var detail in _reciveList) { - var scpRcv = scpdb.TB_RECEIVE.SingleOrDefault(p => p.RecvBillNum != null && p.RecvBillNum == detail.ReceiveNbr && p.Site == detail.Domain && p.SubSite == detail.Site); var scpRcvList = new List(); bool isRerviceOk = false; @@ -964,9 +1003,128 @@ namespace CK.SCP.Controller { istate = (int)FormState.开放; } - scpRcv = new TB_RECEIVE + scpRcv = new TB_RECEIVE { - RecvBillNum = detail.ReceiveNbr,//收货单号 + RecvBillNum = detail.ReceiveNbr,//收货单号 + State = istate, + Remark = "", + CreateTime = detail.ReceiptDate == null ? DateTime.Now : (DateTime)detail.ReceiptDate,//创建日期 + CreateUser = detail.CreateUser,//创建用户 + IsDeleted = false, + GUID = detail.TaskID, + BillType = 0 + }; + scpRcvList.Add(scpRcv); + } + scpRcv.PoBillNum = detail.PurchaseOrder;//采购单 + scpRcv.AsnBillNum = detail.ASN;//发货单号 + scpRcv.Site = detail.Domain;//地点 + scpRcv.VendId = detail.Supplier;//供货商名称 + scpRcv.ShipTime = detail.ReceiptDate;//收货日期 + scpRcv.SubSite = detail.Site; + scpdb.TB_RECEIVE.AddOrUpdate(scpRcvList.ToArray()); + } + + var scpRcveDetailList = new List(); + var _reciveDetailList = db.TED_RECEIPT_DET.Where(p => p.TaskID == p_entity.TaskID).ToList(); + foreach (var detail in _reciveDetailList) + { + var poLineNum = Convert.ToInt32(detail.Line); + var scpRcvDetail = + scpdb.TB_RECEIVE_DETAIL.FirstOrDefault( + p => p.RecvBillNum == detail.ReceiveNbr && + p.PoBillNum == detail.PurchaseOrder && + p.PoLine == detail.Line && + p.PartCode == detail.PartCode + + && p.SubSite == detail.Site + ); + if (scpRcvDetail == null) + { + scpRcvDetail = new TB_RECEIVE_DETAIL(); + scpRcvDetail.RecvBillNum = detail.ReceiveNbr;//收货单号 + scpRcvDetail.PoBillNum = detail.PurchaseOrder;//采购单 + scpRcvDetail.PoLine = detail.Line;//订单行 + scpRcvDetail.PartCode = detail.PartCode;//零件号 + scpRcvDetail.Batch = detail.Lot;//批次 + scpRcvDetail.VendBatch = detail.SupplierLot;//供应商批号 + scpRcvDetail.PoUnit = detail.Um;//采购单位 + scpRcvDetail.LocUnit = detail.logisticsUm;//物流单位 + //收货总量 //DockCode = ?,//收货口 + scpRcvDetail.State = 1;// (int)FormState.关闭, + scpRcvDetail.Remark = detail.Remark; + scpRcvDetail.CreateTime = detail.CreateTime == null ? DateTime.Now : (DateTime)detail.CreateTime;//创建日期 + scpRcvDetail.CreateUser = detail.CreateUser;//创建用户 + scpRcvDetail.IsDeleted = false; + scpRcvDetail.GUID = detail.TaskID; + scpRcvDetail.BillType = 0; + scpRcvDetail.SubSite = detail.Shipto; + scpRcvDetail.Site = detail.Domain; + scpRcveDetailList.Add(scpRcvDetail); + } + scpRcvDetail.Qty = detail.ReceiveQuantity; + } + // var _str=JsonHelper.GetJson>(scpRcveDetailList); + scpdb.TB_RECEIVE_DETAIL.AddOrUpdate(scpRcveDetailList.ToArray()); + _ret.State = ReturnStatus.Succeed; + _ret.MessageList.Add(string.Format("QAD收货单更新{0}任务编号{1}", _reciveDetailList.Count().ToString(), p_entity.TaskID)); + _ret.Result = true; + // var retDetail=UpdateReciveDetail(db, scpdb, p_entity); + } + catch (Exception e) + { + _ret.State = ReturnStatus.Failed; + LogHelper.Writlog(LogHelper.LogType.Error, typeof(TEA_TASK_SUB), "UpdateRecive", e.Message); + _ret.Result = false; + _ret.ErrorList.Add(e); + _ret.MessageList.Add(string.Format("QAD收货单更新失败任务编号{0}", p_entity.TaskID)); + throw e; + } + return _ret; + } + public static ResultObject UpdateARRIVE(ExchangeCenterContext db, ScpEntities scpdb, TEA_TASK_SUB p_entity) + { + ResultObject _ret = new ResultObject(); + try + { + var _reciveList = db.TED_RECEIPT_MSTR.Where(p => p.TaskID == p_entity.TaskID && !string.IsNullOrEmpty(p.ReceiveNbr)).ToList(); + var _scpPoDetailList = new List(); + foreach (var detail in _reciveList) + { + var scpRcv = scpdb.TB_ARRIVE.SingleOrDefault(p => p.ArrvBillNum != null && p.ArrvBillNum == detail.ReceiveNbr && p.Site == detail.Domain /*&& p.SubSite == detail.Site*/); + var scpRcvList = new List(); + bool isRerviceOk = false; + if (!string.IsNullOrEmpty(detail.Site) && !string.IsNullOrEmpty(detail.Domain)) + { + string _domain = detail.Domain; + string _site = detail.Site; + List configs = scpdb.TA_FACTORY_CONFIG.Where(p => p.FactoryId == _domain).ToList(); + foreach (TA_FACTORY_CONFIG cfg in configs) + { + TA_CONFIG tacfg = scpdb.TA_CONFIG.Where(p => p.UID == cfg.ConfigId).SingleOrDefault(); + if (tacfg != null && !string.IsNullOrEmpty(tacfg.ParamName) && tacfg.ParamName == "收货自动审核") + { + if ("允许" == tacfg.ParamValue) + { + isRerviceOk = true; + } + } + } + } + if (scpRcv == null) + { + int istate = 0; + if (isRerviceOk == false) + { + istate = (int)FormState.关闭; + } + else + { + istate = (int)FormState.开放; + } + scpRcv = new TB_ARRIVE + { + ArrvBillNum = detail.ReceiveNbr,//收货单号 State = istate, Remark = "", CreateTime = detail.CreateTime == null ? DateTime.Now : (DateTime)detail.CreateTime,//创建日期 @@ -982,32 +1140,32 @@ namespace CK.SCP.Controller if (!string.IsNullOrEmpty(detail.ASN)) { - var _entity=scpdb.TB_ASN.Where(p => p.AsnBillNum == detail.ASN).FirstOrDefault(); + var _entity = scpdb.TB_ASN.Where(p => p.AsnBillNum == detail.ASN).FirstOrDefault(); if (_entity != null) { _entity.State = 4; } } scpRcv.Site = detail.Domain;//地点 - scpRcv.VendId = detail.Supplier;//供货商名称 + scpRcv.VendId = detail.Supplier.Trim();//供货商名称 scpRcv.ShipTime = detail.ReceiptDate;//收货日期 - scpRcv.SubSite = detail.Site; - scpdb.TB_RECEIVE.AddOrUpdate(scpRcvList.ToArray()); + // scpRcv.SubSite = detail.Site; + scpdb.TB_ARRIVE.AddOrUpdate(scpRcvList.ToArray()); } - var scpRcveDetailList = new List(); + var scpRcveDetailList = new List(); var _reciveDetailList = db.TED_RECEIPT_DET.Where(p => p.TaskID == p_entity.TaskID && !string.IsNullOrEmpty(p.ReceiveNbr)).ToList(); foreach (var detail in _reciveDetailList) { var poLineNum = Convert.ToInt32(detail.Line); var scpRcvDetail = - scpdb.TB_RECEIVE_DETAIL.SingleOrDefault( - p => p.RecvBillNum == detail.ReceiveNbr && + scpdb.TB_ARRIVE_DETAIL.SingleOrDefault( + p => p.ArrvBillNum == detail.ReceiveNbr && p.PoBillNum == detail.PurchaseOrder && p.PoLine == detail.Line && p.PartCode == detail.PartCode && p.Batch == detail.Lot - &&p.SubSite==detail.Site + //&& p.SubSite == detail.Site ); if (scpRcvDetail == null) { @@ -1021,9 +1179,9 @@ namespace CK.SCP.Controller //{ // istate = (int)FormState.开放; //} - scpRcvDetail = new TB_RECEIVE_DETAIL(); - scpRcvDetail.RecvBillNum = detail.ReceiveNbr;//收货单号 - scpRcvDetail.PoBillNum = detail.PurchaseOrder;//采购单 + scpRcvDetail = new TB_ARRIVE_DETAIL(); + scpRcvDetail.ArrvBillNum = detail.ReceiveNbr;//收货单号 + scpRcvDetail.PoBillNum = detail.PurchaseOrder.Trim();//采购单 scpRcvDetail.PoLine = detail.Line;//订单行 scpRcvDetail.PartCode = detail.PartCode;//零件号 scpRcvDetail.Batch = detail.Lot;//批次 @@ -1038,13 +1196,13 @@ namespace CK.SCP.Controller scpRcvDetail.IsDeleted = false; scpRcvDetail.GUID = detail.TaskID; scpRcvDetail.BillType = 0; - scpRcvDetail.SubSite = detail.Site; - scpRcvDetail.Site = detail.Domain; + // scpRcvDetail.SubSite = detail.Site; + // scpRcvDetail.Site = detail.Domain; scpRcveDetailList.Add(scpRcvDetail); } } - var _str = JsonHelper.GetJson>(scpRcveDetailList); - scpdb.TB_RECEIVE_DETAIL.AddOrUpdate(scpRcveDetailList.ToArray()); + var _str = JsonHelper.GetJson>(scpRcveDetailList); + scpdb.TB_ARRIVE_DETAIL.AddOrUpdate(scpRcveDetailList.ToArray()); _ret.State = ReturnStatus.Succeed; _ret.MessageList.Add(string.Format("到货单更新{0}任务编号{1}", _reciveDetailList.Count().ToString(), p_entity.TaskID)); _ret.Result = true; @@ -1153,7 +1311,7 @@ namespace CK.SCP.Controller //_add.VatDebitLC = _vinvoice.BlancePrice.Value;//税额调整 //_add.VatDebitTC = _vinvoice.ContractPrice.Value; // _addList.Add(_add); - } + } if ((_vinvoice.BlancePrice != null && _vinvoice.BlancePrice.Value != 0)) { _invMast.InvoiceAmountTC = (_vinvoice.TaxAmount == null ? 0 : _vinvoice.TaxAmount.Value) + _vinvoice.BlancePrice.Value; @@ -1182,8 +1340,8 @@ namespace CK.SCP.Controller _entity.TaskID = p_taskId; _entity.CommandType = "A"; _entity.DataID = Guid.NewGuid(); - _entity.Domain = _invDetail.Site.Trim(); - _entity.Site = _invDetail.SubSite.Trim(); + _entity.Domain = _invDetail.Site; + _entity.Site = _invDetail.SubSite; _entity.PartCode = _invDetail.PartCode; _entity.Tax = _invDetail.Tax.ToString(); _detList.Add(_entity); @@ -1197,7 +1355,7 @@ namespace CK.SCP.Controller DataCount = p_invoiceList.Count, TaskID = p_taskId, TableName = "TED_INVOICE_MSTR", - Site = _vinvoice.SubSite.Trim(), + Site = _vinvoice.SubSite, Domain = _vinvoice.Site, CreateTime = _api.CreateTime, CreateUser = _api.CreateOper, @@ -1227,154 +1385,7 @@ namespace CK.SCP.Controller return _ret; } - - - public static ResultObject UpdateReturn(ExchangeCenterContext db, ScpEntities scpdb, TEA_TASK_SUB p_entity) - { - ResultObject _ret = new ResultObject(); - try - { - var _reciveList = db.TED_RETURN_MSTR.Where(p => p.TaskID == p_entity.TaskID && !string.IsNullOrEmpty(p.ReturnNbr)).ToList(); - var _scpPoDetailList = new List(); - foreach (var detail in _reciveList) - { - var scpRcv = scpdb.TB_RECEIVE.SingleOrDefault(p => p.RecvBillNum != null && p.RecvBillNum == detail.ReturnNbr && p.Site == detail.Domain && p.SubSite == detail.Site); - var scpRcvList = new List(); - bool isRerviceOk = false; - if (!string.IsNullOrEmpty(detail.Site) && !string.IsNullOrEmpty(detail.Domain)) - { - string _domain = detail.Domain; - string _site = detail.Site; - List configs = scpdb.TA_FACTORY_CONFIG.Where(p => p.FactoryId == _domain).ToList(); - foreach (TA_FACTORY_CONFIG cfg in configs) - { - TA_CONFIG tacfg = scpdb.TA_CONFIG.Where(p => p.UID == cfg.ConfigId).SingleOrDefault(); - if (tacfg != null && !string.IsNullOrEmpty(tacfg.ParamName) && tacfg.ParamName == "收货自动审核") - { - if ("允许" == tacfg.ParamValue) - { - isRerviceOk = true; - } - } - } - } - if (scpRcv == null) - { - int istate = 0; - if (isRerviceOk == false) - { - istate = (int)FormState.关闭; - } - else - { - istate = (int)FormState.开放; - } - scpRcv = new TB_RECEIVE - { - RecvBillNum = detail.ReturnNbr,//收货单号 - State = istate, - Remark = "", - CreateTime = detail.CreateTime == null ? DateTime.Now : (DateTime)detail.CreateTime,//创建日期 - CreateUser = detail.CreateUser,//创建用户 - IsDeleted = false, - GUID = detail.TaskID, - BillType = 1 - }; - scpRcvList.Add(scpRcv); - } - scpRcv.PoBillNum = detail.PurchaseOrder;//采购单 - scpRcv.AsnBillNum = detail.ASN;//发货单号 - - if (!string.IsNullOrEmpty(detail.ASN)) - { - var _entity=scpdb.TB_ASN.Where(p => p.AsnBillNum == detail.ASN).FirstOrDefault(); - if (_entity != null) - { - _entity.State = 4; - } - } - scpRcv.Site = detail.Domain;//地点 - scpRcv.VendId = detail.Supplier;//供货商名称 - scpRcv.ShipTime = detail.ReturnDate;//收货日期 - scpRcv.SubSite = detail.Site; - scpdb.TB_RECEIVE.AddOrUpdate(scpRcvList.ToArray()); - } - - var scpRcveDetailList = new List(); - var _reciveDetailList = db.TED_RETURN_DET.Where(p => p.TaskID == p_entity.TaskID ).ToList(); - var _recive = db.TED_RETURN_MSTR.Where(p => p.TaskID == p_entity.TaskID && !string.IsNullOrEmpty(p.ReturnNbr)).FirstOrDefault(); - if (_recive != null) - { - foreach (var detail in _reciveDetailList) - { - detail.ReturnNbr = _recive.ReturnNbr; - var poLineNum = Convert.ToInt32(detail.Line); - var scpRcvDetail = - scpdb.TB_RECEIVE_DETAIL.SingleOrDefault( - p => p.RecvBillNum == detail.ReturnNbr && - p.PoBillNum == detail.PurchaseOrder && - p.PoLine == detail.Line && - p.PartCode == detail.PartCode && - p.Batch == detail.Lot - && p.SubSite == detail.Site - ); - if (scpRcvDetail == null) - { - - //int istate = 0; - //if (isRerviceOk == false) - //{ - // istate = (int)FormState.关闭; - //} - //else - //{ - // istate = (int)FormState.开放; - //} - scpRcvDetail = new TB_RECEIVE_DETAIL(); - scpRcvDetail.RecvBillNum = detail.ReturnNbr;//收货单号 - scpRcvDetail.PoBillNum = detail.PurchaseOrder;//采购单 - scpRcvDetail.PoLine = detail.Line;//订单行 - scpRcvDetail.PartCode = detail.PartCode;//零件号 - scpRcvDetail.Batch = detail.Lot;//批次 - scpRcvDetail.VendBatch = detail.SupplierLot;//供应商批号 - scpRcvDetail.PoUnit = detail.Um;//采购单位 - scpRcvDetail.LocUnit = detail.logisticsUm;//物流单位 - scpRcvDetail.Qty = detail.ReturnQuantity;//收货总量 //DockCode = ?,//收货口 - scpRcvDetail.State = 1;// (int)FormState.关闭, - scpRcvDetail.Remark = detail.Remark; - scpRcvDetail.CreateTime = detail.CreateTime == null ? DateTime.Now : (DateTime)detail.CreateTime;//创建日期 - scpRcvDetail.CreateUser = detail.CreateUser;//创建用户 - scpRcvDetail.IsDeleted = false; - scpRcvDetail.GUID = detail.TaskID; - scpRcvDetail.BillType = 1; - scpRcvDetail.SubSite = detail.Site; - scpRcvDetail.Site = detail.Domain; - - scpRcveDetailList.Add(scpRcvDetail); - } - } - var _str = JsonHelper.GetJson>(scpRcveDetailList); - scpdb.TB_RECEIVE_DETAIL.AddOrUpdate(scpRcveDetailList.ToArray()); - } - _ret.State = ReturnStatus.Succeed; - _ret.MessageList.Add(string.Format("退货单更新{0}任务编号{1}", _reciveDetailList.Count().ToString(), p_entity.TaskID)); - _ret.Result = true; - // var retDetail=UpdateReciveDetail(db, scpdb, p_entity); - } - catch (Exception e) - { - _ret.State = ReturnStatus.Failed; - LogHelper.Writlog(LogHelper.LogType.Error, typeof(TEA_TASK_SUB), "UpdateRecive", e.Message); - _ret.Result = false; - _ret.ErrorList.Add(e); - _ret.MessageList.Add(string.Format("退货单更新失败任务编号{0}", p_entity.TaskID)); - throw e; - } - return _ret; - - } - - + public static ResultObject UpdatePoDetail(ExchangeCenterContext db, ScpEntities scpdb, TEA_TASK_SUB p_entity) { ResultObject _ret = new ResultObject(); @@ -1434,55 +1445,141 @@ namespace CK.SCP.Controller try { var _poList = db.TED_PO_MSTR.Where(p => p.TaskID == p_entity.TaskID).ToList(); - var _scpPolist = new List(); foreach (var po in _poList) { - var _po = scpdb.TB_PO.SingleOrDefault(p => p.ErpBillNum == po.PurchaseOrder && p.Site == po.Domain); - if (_po == null) + var scpPo = scpdb.TB_PO.SingleOrDefault(p => p.PoBillNum != null && p.PoBillNum == po.PurchaseOrder && p.Site == po.Domain && p.SubSite == po.Site); + var scpPoList = new List(); + + if (scpPo == null) { int temp; - _po = new TB_PO + scpPo = new TB_PO { PoBillNum = po.PurchaseOrder,//订单号 ErpBillNum = po.PurchaseOrder,//ERP订单号 - VendId = po.Supplier,//供应商编号 + VendId = po.Supplier.ToUpper(),//供应商编号 ModType = Int32.TryParse(po.ModeType, out temp) ? temp : (int?)null, //单据类型(1:日程单,2:离散订单) Contacter = po.Contact,//联系人 Site = po.Domain,//地点 - State = (int)FormState.开放,//状态 + SubSite = po.Site, + State = po.Status, Remark = po.Remark,//说明 CreateTime = po.CreateTime == null ? DateTime.Now : (DateTime)po.CreateTime,//创建日期 CreateUser = po.CreateUser,//创建用户 IsDeleted = false, - GUID =po.TaskID, - BeginTime = po.OrderDate == null ? DateTime.Now : po.OrderDate,//创建日期 + GUID = System.Guid.NewGuid(), + BeginTime = po.OrderDate == null ? DateTime.Now : (DateTime)po.OrderDate,//创建日期 EndTime = po.DueDate//收货结束时间 }; - int _count = _scpPolist.Count(p => p.ErpBillNum == po.PurchaseOrder && p.Site == po.Domain ); - if (_count == 0) + scpPoList.Add(scpPo); + } + scpPo.Contacter = po.Contact;//联系人 + scpPo.Buyer = po.Buyer; + scpPo.BuyerPhone = po.BuyerPhone; + scpPo.UpdateTime = DateTime.Now;//更新日期 + scpPo.UpdateUser = "QAD";//更新用户 + scpPo.State = po.Status; + scpdb.TB_PO.AddOrUpdate(scpPoList.ToArray()); + } + var scpPoDetailList = new List(); + var _poDetailList = db.TED_POD_DET.Where(p => p.TaskID == p_entity.TaskID).ToList(); + foreach (var podetail in _poDetailList) + { + var poLineNum = Convert.ToInt32(podetail.Line); + var scpPoDetail =scpdb.TB_PO_DETAIL.SingleOrDefault( + p => p.PoBillNum == podetail.PurchaseOrder && p.PoLine == poLineNum && p.Site == podetail.Domain&&p.SubSite==podetail.Site); + if (scpPoDetail == null) + { + scpPoDetail = new TB_PO_DETAIL { - _scpPolist.Add(_po); - } + PoBillNum = podetail.PurchaseOrder,//订单号 + PoLine = poLineNum,//订单行 + IsDeleted = false, + GUID = System.Guid.NewGuid() + }; + scpPoDetailList.Add(scpPoDetail); } - _po.Contacter = po.Contact; - _po.Buyer = _po.Buyer; - _po.BuyerPhone = _po.BuyerPhone; - _po.UpdateTime = _po.UpdateTime;//更新日期 - _po.UpdateUser = _po.UpdateUser;//更新用户 + scpPoDetail.PartCode = podetail.PartCode.ToUpper();//零件号-物料号 + scpPoDetail.PlanQty = podetail.Qty;//订货数量-采购量 + scpPoDetail.BeginTime = podetail.StartDate;//收货开始时间 + scpPoDetail.EndTime = podetail.EndDate;//收货结束时间 + scpPoDetail.PoUnit = podetail.PoUm;//采购单位 + scpPoDetail.LocUnit = podetail.LocUm.ToUpper();//存储单位 + scpPoDetail.DockCode = podetail.Location; + scpPoDetail.Price = podetail.Price; + scpPoDetail.Currency = podetail.Currency;//币种 + scpPoDetail.PackQty = podetail.PackQty;//标包数量 + scpPoDetail.UnConv = podetail.Conv;//转换率 + scpPoDetail.State = Convert.ToInt32(podetail.Status);//状态 + scpPoDetail.Site = podetail.Domain; + scpPoDetail.SubSite = podetail.Site; + scpPoDetail.CreateTime = podetail.CreateTime == null ? DateTime.Now : (DateTime)podetail.CreateTime;//创建日期 + scpPoDetail.CreateUser = podetail.CreateUser;//创建用户 + scpPoDetail.UpdateTime = DateTime.Now;//更新日期 + scpPoDetail.UpdateUser = "QAD";//更新用户 + if (scpPoDetail.PlanQty != 0 && scpPoDetail.PlanQty <= scpPoDetail.ReceivedQty)scpPoDetail.State = (int)FormState.关闭; } - scpdb.TB_PO.AddOrUpdate(_scpPolist.ToArray()); + scpdb.TB_PO_DETAIL.AddOrUpdate(scpPoDetailList.ToArray()); + _ret.State = ReturnStatus.Succeed; + _ret.MessageList.Add(string.Format("QAD订单更新{0}任务编号{1}", _poDetailList.Count().ToString(), p_entity.TaskID)); + _ret.Result = true; } catch (Exception e) { _ret.State = ReturnStatus.Failed; - LogHelper.Writlog(LogHelper.LogType.Error, typeof(TEA_TASK_SUB), "Save_TEA_TASK_SUB", e.Message); + LogHelper.Writlog(LogHelper.LogType.Error, typeof(TEA_TASK_SUB), "UpdatePo", e.Message); _ret.Result = false; _ret.ErrorList.Add(e); + _ret.MessageList.Add(string.Format("QAD订单更新失败任务编号{0}", p_entity.TaskID)); throw e; } return _ret; } + /// + /// 价格 + /// + /// + /// + /// + /// + public static ResultObject UpdatePrice(ExchangeCenterContext db, ScpEntities scpdb, AppBoxContext authdb, TEA_TASK_SUB p_entity) + { + ResultObject _ret = new ResultObject(); + try + { + var _pricelistqad = db.TES_PURCHASE_PRICE.Where(p => p.TaskID == p_entity.TaskID).ToList(); + var _pricelistscp = new List(); + foreach (var price in _pricelistqad) + { + var _price = new TB_PRICE + { + VendId = price.SupplierCode, + Unit = price.Um, + PartCode = price.PartCode, + Site = price.Site, + Remarks = price.Remark, + StartTime = price.Start, + EndTime = price.ExpireDate, + Curr = price.Currency + }; + _price.Amt = price.Amount; + _pricelistscp.Add(_price); + } + scpdb.TB_PRICE.AddOrUpdate(_pricelistscp.ToArray()); + _ret.State = ReturnStatus.Succeed; + _ret.MessageList.Add(string.Format("更新表{0}任务ID{1}成功!", "TES_PURCHASE_PRICE", p_entity.TaskID)); + } + catch (Exception e) + { + _ret.State = ReturnStatus.Failed; + LogHelper.Writlog(LogHelper.LogType.Error, typeof(TEA_TASK_SUB), "UpdatePrice", e.Message); + _ret.Result = false; + _ret.ErrorList.Add(e); + throw e; + } + return _ret; + } /// /// 更新供应商 /// @@ -1519,11 +1616,11 @@ namespace CK.SCP.Controller //_supplier.Contacter = supplier.ContactName;//联系人 //_supplier.Phone = supplier.Telephone.ToString();//电话 //_supplier.Fax = supplier.Fax.ToString();//传真 - //_supplier.SubSite = string.IsNullOrEmpty(supplier.Site)?"BJ01" : supplier.Site;//域 - _supplier.Site = string.IsNullOrEmpty(supplier.Domain)?"BJBMPT": supplier.Domain;//域 - //_supplier.Tax = Convert.ToDecimal(supplier.TaxInCity);//税率 + //_supplier.SubSite = string.IsNullOrEmpty(supplier.Site)?"BJ01" : supplier.Site;//域 + _supplier.Site = supplier.Domain;//域 + _supplier.Tax = Convert.ToDecimal(supplier.TaxClass/100);//税率 - _supplier.Remark = supplier.TaskID.ToString();//任务ID + _supplier.Remark = supplier.TaskID.ToString();//任务ID var vendname = string.Format("{0}@{1}",_supplier.VendId.ToUpper(), _supplier.Site.ToUpper()); var _first = authdb.Users.Where(p => p.Name == vendname).FirstOrDefault(); @@ -1602,10 +1699,10 @@ namespace CK.SCP.Controller var _supplierpart = scpdb.TA_VEND_PART.SingleOrDefault(p => p.VendId == supplierpart.Supplier && p.PartCode == supplierpart.PartCode && p.VendPartCode == supplierpart.SupplierPart && p.Site == supplierpart.Domain ); if (_supplierpart == null) { - var _pack = dc.TS_PACK.SingleOrDefault(p => p.PartCode == supplierpart.PartCode && p.Site == supplierpart.Domain && p.Site == supplierpart.Site); - if (_pack != null) - { - } + // var _pack = dc.TS_PACK.SingleOrDefault(p => p.PartCode == supplierpart.PartCode && p.Site == supplierpart.Domain && p.Site == supplierpart.Site); + //if (_pack != null) + //{ + //} _supplierpart = new TA_VEND_PART { VendId = supplierpart.Supplier.ToUpper(),//供应商编号 @@ -1800,12 +1897,368 @@ namespace CK.SCP.Controller return _ret; } - + public static ResultObject WritePo(List p_order_list, string site, string p_creator, DateTime p_time, BillModType p_modtype, string subsite, string p_chineseName, string p_buyerPhone) + { + ResultObject _ret = new ResultObject(); + using (var scope = + new TransactionScope(TransactionScopeOption.Required, new TransactionOptions() + { + IsolationLevel = System.Transactions.IsolationLevel.Serializable, + Timeout = new TimeSpan(0, 20, 0) + })) + { + try + { + ScpEntities scpdb = EntitiesFactory.CreateScpInstance(); + ExchangeCenterContext db = EntitiesFactory.CreateExchangeCenterInstance(); + var OrderList = p_order_list.GroupBy(p => p.订单编号).ToList(); + string _polist = ""; + int _num = 1; + OrderList.ForEach((p) => + { + Guid taskid = Guid.NewGuid(); + var list = p.ToList(); + if (list.Count > 0) + { + #region 日程单 + if (p_modtype == BillModType.Contract) + { + var _entity = list.FirstOrDefault(); + var _po = scpdb.TB_PO.SingleOrDefault(t => t.PoBillNum == _entity.订单编号/* && t.State == state*/ && t.Site == site && t.SubSite == subsite && t.VendId == _entity.供应商编号.ToUpper()); + if (_po == null) + { + _po = new TB_PO { GUID = Guid.NewGuid(), PoBillNum = _entity.订单编号.ToUpper(), State = (int)PoState.Open, Site = site, SubSite = subsite, VendId = _entity.供应商编号.Trim().ToUpper() }; + } + _po.ErpBillNum = _entity.订单编号.Trim().ToUpper(); ; + _po.ModType = (int)p_modtype; + _po.Contacter = p_chineseName;// _entity.联系人; + _po.Buyer = p_chineseName;// _entity.联系人; + _po.Site = site.Trim().ToUpper(); + _po.BuyerPhone = p_buyerPhone; + _po.Remark = _entity.备注; + _po.IsDeleted = false; + _po.CreateTime = DateTime.Now; + _po.CreateUser = p_creator; + _po.BeginTime = string.IsNullOrEmpty(_entity.订单创建时间) ? DateTime.Now : DateTime.Parse(_entity.订单创建时间); + _po.EndTime = string.IsNullOrEmpty(_entity.要求到货日期) ? DateTime.Now.AddYears(10) : DateTime.Parse(_entity.要求到货日期); + scpdb.TB_PO.AddOrUpdate(_po); + TED_PO_MSTR _po_mstr = new TED_PO_MSTR(); + _po_mstr.GUID = Guid.NewGuid(); + _po_mstr.PurchaseOrder = _entity.订单编号.Trim().ToUpper(); + _po_mstr.Supplier = _entity.供应商编号.Trim().ToUpper(); + _po_mstr.Contact = p_chineseName;// _entity.联系人; + _po_mstr.ShipTo = subsite.Trim().ToUpper();//发往 + _po_mstr.OrderDate = string.IsNullOrEmpty(_entity.订单创建时间) ? DateTime.Now : DateTime.Parse(_entity.订单创建时间); + _po_mstr.DueDate = string.IsNullOrEmpty(_entity.要求到货日期) ? DateTime.Now : DateTime.Parse(_entity.要求到货日期); + _po_mstr.StartDate = string.IsNullOrEmpty(_entity.订单开始时间) ? DateTime.Now : DateTime.Parse(_entity.订单开始时间);//订单日期 + _po_mstr.EndDate = string.IsNullOrEmpty(_entity.订单截至日期) ? DateTime.Now.AddYears(10) : DateTime.Parse(_entity.订单截至日期); + _po_mstr.MadeIn = ""; + _po_mstr.Confirm = true; + _po_mstr.Buyer = p_chineseName;//_entity.采购员; + _po_mstr.BuyerPhone = p_buyerPhone;// _entity.采购员电话; + _po_mstr.Status = (int)PoState.Open; + _po_mstr.ScheduledOrder = true; + _po_mstr.CreateUser = p_creator; + _po_mstr.CreateTime = p_time; + _po_mstr.Remark = _entity.备注; ; + _po_mstr.TaskID = taskid; + _po_mstr.Domain = site.Trim().ToUpper(); + _po_mstr.ModeType = ((int)p_modtype).ToString(); + _po_mstr.Site = subsite.Trim().ToUpper(); + _po_mstr.DataID = Guid.NewGuid(); + _po_mstr.Pricelist = _entity.供应商编号.ToUpper().Trim() + subsite.Trim().Substring(1, 1) + subsite.Substring(3, 1).Trim(); + _po_mstr.Taxclass = _entity.税率; + _po_mstr.CommandType = "A"; + db.TED_PO_MSTR.Add(_po_mstr); + list.ForEach((itm) => + { + int _poline = Int32.Parse(itm.行号); + var _PO_Detail = scpdb.TB_PO_DETAIL.FirstOrDefault(t => t.PartCode == itm.零件号 && t.PoLine == _poline && t.PoBillNum == itm.订单编号 /*&& t.State == state*/ && t.Site == site && t.SubSite == subsite); + TED_PO_DET _PO_Detail_Det = new TED_PO_DET(); + _PO_Detail_Det.GUID = Guid.NewGuid(); + _PO_Detail_Det.PurchaseOrder = itm.订单编号.Trim().ToUpper(); + _PO_Detail_Det.Line = Int32.Parse(itm.行号); + _PO_Detail_Det.Currency = "CNY"; + _PO_Detail_Det.PoType = itm.订单类型; + _PO_Detail_Det.PartCode = itm.零件号.Trim().ToUpper(); + _PO_Detail_Det.Qty = decimal.Parse(itm.数量); + _PO_Detail_Det.QtyOpen = 0; + _PO_Detail_Det.PackQty = 1; + _PO_Detail_Det.Currency = itm.币种; + _PO_Detail_Det.Price = string.IsNullOrEmpty(itm.单价) ? 0 : decimal.Parse(itm.单价); + var _part = scpdb.TA_PART.FirstOrDefault(part => part.PartCode == itm.零件号.Trim().ToUpper()); + if (_part == null) + { + _PO_Detail_Det.PoUm = itm.单位; + _PO_Detail_Det.LocUm = itm.单位; + } + else + { + _PO_Detail_Det.PoUm = _part.Unit; + _PO_Detail_Det.LocUm = _part.Unit; + } + _PO_Detail_Det.Conv = 1; + _PO_Detail_Det.DueDate = string.IsNullOrEmpty(itm.要求到货日期) ? DateTime.Now : DateTime.Parse(itm.要求到货日期); + _PO_Detail_Det.Status = (int)PoState.Open; + _PO_Detail_Det.CreateTime = DateTime.Parse(itm.订单创建时间); + _PO_Detail_Det.StartDate = string.IsNullOrEmpty(itm.零件开始时间) ? p_time : DateTime.Parse(itm.零件开始时间); + _PO_Detail_Det.EndDate = string.IsNullOrEmpty(itm.零件截至日期) ? DateTime.Now.AddYears(10) : DateTime.Parse(itm.零件截至日期); + _PO_Detail_Det.CreateUser = p_creator; + _PO_Detail_Det.TaskID = taskid; + if (_PO_Detail != null) + { + _PO_Detail_Det.CommandType = "U"; + } + else + { + _PO_Detail = new TB_PO_DETAIL { GUID = Guid.NewGuid(), PartCode = itm.零件号.Trim().ToUpper(), PoLine = _poline, PoBillNum = itm.订单编号.Trim().ToUpper(), State = (int)PoState.Open, Site = site, SubSite = subsite }; + _PO_Detail_Det.CommandType = "A"; + } + _PO_Detail_Det.DataID = Guid.NewGuid(); + _PO_Detail_Det.Domain = site.Trim().ToUpper(); + _PO_Detail_Det.Site = subsite.Trim().ToUpper(); + _PO_Detail_Det.Workorderlot = itm.加工单号; + _PO_Detail_Det.PoType = itm.订单类型; + _PO_Detail_Det.Operation = string.IsNullOrEmpty(itm.工序) ? 0 : int.Parse(itm.工序); + _PO_Detail_Det.Location = itm.库位; + _PO_Detail_Det.Firmdays = string.IsNullOrEmpty(itm.固定天数) ? 7 : int.Parse(itm.固定天数); + _PO_Detail_Det.Scheduledays = string.IsNullOrEmpty(itm.日程天数) ? 7 : int.Parse(itm.日程天数); + _PO_Detail_Det.Scheduleweeks = string.IsNullOrEmpty(itm.日程周数) ? 2 : int.Parse(itm.日程周数); + _PO_Detail_Det.Schedulemonth = string.IsNullOrEmpty(itm.日程月数) ? 1 : int.Parse(itm.日程月数); + _PO_Detail_Det.Supplieritem = itm.供应商零件; + _PO_Detail_Det.Dliverypatterncode = itm.发货样式; + _PO_Detail_Det.Deliverytimecode = itm.发货时间样式; + _PO_Detail_Det.Transportdays = string.IsNullOrEmpty(itm.运输周期) ? 0 : int.Parse(itm.运输周期); + _PO_Detail_Det.Pricelist = _entity.供应商编号.Trim().ToUpper() + subsite.Substring(1, 1) + subsite.Substring(3, 1); + db.TED_POD_DET.Add(_PO_Detail_Det); + _PO_Detail.Currency = "CNY"; + _PO_Detail.PoUnit = itm.单位; + _PO_Detail.CreateTime = DateTime.Now; + _PO_Detail.CreateUser = p_creator; + _PO_Detail.BeginTime = string.IsNullOrEmpty(itm.订单创建时间) ? DateTime.Now : DateTime.Parse(itm.订单创建时间); + _PO_Detail.EndTime = string.IsNullOrEmpty(itm.要求到货日期) ? DateTime.Now.AddYears(10) : DateTime.Parse(itm.要求到货日期); + _PO_Detail.PlanQty = decimal.Parse(itm.数量); + _PO_Detail.IsDeleted = false; + _PO_Detail.LocUnit = itm.单位; + _PO_Detail.PoUnit = itm.单位; + _PO_Detail.UnConv = 1; + _PO_Detail.Remark = itm.备注; + _PO_Detail.Price = string.IsNullOrEmpty(itm.单价) ? 0 : decimal.Parse(itm.单价); + scpdb.TB_PO_DETAIL.AddOrUpdate(_PO_Detail); + }); + _polist = _polist + _po.PoBillNum + ","; + } + #endregion + #region 离散单 (离散单只增加不修改) + if (p_modtype == BillModType.Non_Contract) + { + var _entity = list.FirstOrDefault(); + TB_PO _po = new TB_PO(); + _po.GUID = Guid.NewGuid(); + _po.PoBillNum = SCP_BILLCODE_CONTROLLER.MakePoNum(_num); + _po.State = (int)PoState.Open; + _po.Site = site.Trim().ToUpper(); + _po.SubSite = subsite.Trim().ToUpper(); + _po.VendId = _entity.供应商编号.Trim().ToUpper(); + _po.ErpBillNum = _po.PoBillNum; + _po.ModType = (int)p_modtype; + _po.Contacter = p_chineseName;// _entity.联系人; + _po.Buyer = p_chineseName;// _entity.联系人; + _po.BuyerPhone = p_buyerPhone; + _po.Site = site.Trim().ToUpper(); + _po.Remark = _entity.备注; + _po.IsDeleted = false; + _po.CreateTime = DateTime.Now; + _po.CreateUser = p_creator; + _po.BeginTime = string.IsNullOrEmpty(_entity.订单创建时间) ? DateTime.Now : DateTime.Parse(_entity.订单创建时间); + _po.EndTime = string.IsNullOrEmpty(_entity.要求到货日期) ? DateTime.Now.AddYears(10) : DateTime.Parse(_entity.要求到货日期); + scpdb.TB_PO.AddOrUpdate(_po); + TB_ASK _ask = new TB_ASK(); + _ask.AskBillNum = SCP_BILLCODE_CONTROLLER.MakeASKCodeByNum(_num); + _ask.GUID = Guid.NewGuid(); + _ask.PoBillNum = _po.PoBillNum; + _ask.VendId = _entity.供应商编号.Trim().ToUpper(); + _ask.IsDeleted = false; + _ask.CreateTime = DateTime.Now; + _ask.CreateUser = p_creator; + _ask.Site = site.Trim().ToUpper(); + _ask.ReceivedPort = "";//交货口 + _ask.State = (int)AskState.New; + _ask.Remark = _entity.备注; + _ask.ModType = (int)p_modtype; + _ask.ErpBillNum = _po.PoBillNum; + _ask.BeginTime = p_time; + _ask.EndTime = DateTime.Parse(_entity.要求到货日期); + _ask.Buyer = p_chineseName; + _ask.BuyerPhone = p_buyerPhone; + _ask.SubSite = subsite; + scpdb.TB_ASK.Add(_ask); + + TED_PO_MSTR _po_mstr = new TED_PO_MSTR(); + _po_mstr.GUID = Guid.NewGuid(); + _po_mstr.PurchaseOrder = _po.PoBillNum; + _po_mstr.Supplier = _entity.供应商编号.Trim().ToUpper(); + _po_mstr.Contact = p_chineseName;// _entity.联系人; + _po_mstr.ShipTo = subsite.Trim().ToUpper();//发往 + _po_mstr.OrderDate = string.IsNullOrEmpty(_entity.订单创建时间) ? DateTime.Now : DateTime.Parse(_entity.订单创建时间); + _po_mstr.DueDate = string.IsNullOrEmpty(_entity.要求到货日期) ? DateTime.Now : DateTime.Parse(_entity.要求到货日期); + _po_mstr.StartDate = string.IsNullOrEmpty(_entity.订单开始时间) ? DateTime.Now : DateTime.Parse(_entity.订单开始时间);//订单日期 + _po_mstr.EndDate = string.IsNullOrEmpty(_entity.订单截至日期) ? DateTime.Now.AddYears(10) : DateTime.Parse(_entity.订单截至日期); + _po_mstr.MadeIn = ""; + _po_mstr.Confirm = true; + _po_mstr.Buyer = p_chineseName;// _entity.采购员; + _po_mstr.BuyerPhone = p_buyerPhone;// _entity.采购员电话; + _po_mstr.Status = (int)PoState.Open; + _po_mstr.ScheduledOrder = false; + _po_mstr.CreateUser = p_creator; + _po_mstr.CreateTime = p_time; + _po_mstr.Remark = _entity.备注; ; + _po_mstr.TaskID = taskid; + _po_mstr.CommandType = "A"; + _po_mstr.Domain = site.Trim().ToUpper(); + _po_mstr.ModeType = ((int)p_modtype).ToString(); + _po_mstr.Site = subsite.Trim().ToUpper(); + _po_mstr.DataID = Guid.NewGuid(); + _po_mstr.Pricelist = _entity.供应商编号.ToUpper().Trim() + subsite.Substring(1, 1) + subsite.Substring(3, 1); + _po_mstr.Taxclass = _entity.税率; + db.TED_PO_MSTR.Add(_po_mstr); + + int _number = 1; + list.ForEach((itm) => + { + TB_PO_DETAIL _PO_Detail = new TB_PO_DETAIL(); + _PO_Detail.GUID = Guid.NewGuid(); + _PO_Detail.PartCode = itm.零件号.Trim().ToUpper(); + _PO_Detail.PoLine = _number; + _PO_Detail.PoBillNum = _po.PoBillNum; + _PO_Detail.State = (int)PoState.Open; + _PO_Detail.Site = site.Trim().ToUpper(); + _PO_Detail.SubSite = subsite.Trim().ToUpper(); + _PO_Detail.Currency = "CNY"; + _PO_Detail.PoUnit = itm.单位; + _PO_Detail.Remark = itm.备注; + _PO_Detail.CreateTime = DateTime.Now; + _PO_Detail.CreateUser = p_creator; + _PO_Detail.BeginTime = string.IsNullOrEmpty(itm.订单创建时间) ? DateTime.Now : DateTime.Parse(itm.订单创建时间); + _PO_Detail.EndTime = string.IsNullOrEmpty(itm.要求到货日期) ? DateTime.Now.AddYears(10) : DateTime.Parse(itm.要求到货日期); + _PO_Detail.PlanQty = decimal.Parse(itm.数量); + _PO_Detail.IsDeleted = false; + _PO_Detail.LocUnit = itm.单位; + _PO_Detail.PoUnit = itm.单位; + _PO_Detail.UnConv = 1; + _PO_Detail.Price = string.IsNullOrEmpty(itm.单价) ? 0 : decimal.Parse(itm.单价); + _PO_Detail.TempQty = decimal.Parse(itm.数量); + TB_ASK_DETAIL _tDetail = new TB_ASK_DETAIL(); + _tDetail.Remark = itm.备注; + _tDetail.PoBillNum = _po.PoBillNum; + _tDetail.AskBillNum = _ask.AskBillNum; + _tDetail.PoLine = _number; + _tDetail.PoUnit = itm.单位; + _tDetail.CreateTime = DateTime.Now; + _tDetail.CreateUser = p_creator; + _tDetail.PartCode = itm.零件号.ToUpper().Trim(); + _tDetail.ReceivedPort = ""; + _tDetail.BeginTime = p_time; + _tDetail.EndTime = Convert.ToDateTime(itm.要求到货日期); + _tDetail.TempQty = 0; + _tDetail.AskQty = Decimal.Parse(itm.数量); + _tDetail.IsDeleted = false; + _tDetail.LocUnit = itm.单位; + _tDetail.UnConv = 1; + _tDetail.State = (int)PoState.Open; + _tDetail.SubSite = subsite.Trim().ToUpper(); + _tDetail.Site = site.Trim().ToUpper(); + _tDetail.Price = Decimal.Parse(itm.单价); + _tDetail.GUID = Guid.NewGuid(); + _tDetail.Currency = itm.币种; + scpdb.TB_ASK_DETAIL.Add(_tDetail); + scpdb.TB_PO_DETAIL.AddOrUpdate(_PO_Detail); + TED_PO_DET _PO_Detail_Det = new TED_PO_DET(); + _PO_Detail_Det.GUID = Guid.NewGuid(); + _PO_Detail_Det.PurchaseOrder = _po.PoBillNum; + _PO_Detail_Det.Line = _number; + _PO_Detail_Det.Currency = "CNY"; + _PO_Detail_Det.PoType = itm.订单类型; + _PO_Detail_Det.PartCode = itm.零件号.Trim().ToUpper(); + _PO_Detail_Det.Qty = decimal.Parse(itm.数量); + _PO_Detail_Det.QtyOpen = 0; + _PO_Detail_Det.PackQty = 1; + _PO_Detail_Det.Currency = itm.币种; + _PO_Detail_Det.Price = string.IsNullOrEmpty(itm.单价) ? 0 : decimal.Parse(itm.单价); + _PO_Detail_Det.PoUm = itm.单位; + _PO_Detail_Det.LocUm = itm.单位; + _PO_Detail_Det.Conv = 1; + _PO_Detail_Det.DueDate = string.IsNullOrEmpty(itm.要求到货日期) ? DateTime.Now : DateTime.Parse(itm.要求到货日期); + _PO_Detail_Det.Status = (int)PoState.Open; + _PO_Detail_Det.CreateTime = DateTime.Parse(itm.订单创建时间); + _PO_Detail_Det.StartDate = string.IsNullOrEmpty(itm.零件开始时间) ? p_time : DateTime.Parse(itm.零件开始时间); + _PO_Detail_Det.EndDate = string.IsNullOrEmpty(itm.零件截至日期) ? DateTime.Now.AddYears(10) : DateTime.Parse(itm.零件截至日期); + _PO_Detail_Det.CreateUser = p_creator; + _PO_Detail_Det.TaskID = taskid; + _PO_Detail_Det.CommandType = "A"; + _PO_Detail_Det.DataID = Guid.NewGuid(); + _PO_Detail_Det.Domain = site.Trim().ToUpper(); + _PO_Detail_Det.Site = subsite.Trim().ToUpper(); + _PO_Detail_Det.Workorderlot = itm.加工单号; + _PO_Detail_Det.PoType = itm.订单类型; + _PO_Detail_Det.Operation = string.IsNullOrEmpty(itm.工序) ? 0 : int.Parse(itm.工序); + _PO_Detail_Det.Location = itm.库位; + _PO_Detail_Det.Firmdays = string.IsNullOrEmpty(itm.固定天数) ? 7 : int.Parse(itm.固定天数); + _PO_Detail_Det.Scheduledays = string.IsNullOrEmpty(itm.日程天数) ? 7 : int.Parse(itm.日程天数); + _PO_Detail_Det.Scheduleweeks = string.IsNullOrEmpty(itm.日程周数) ? 2 : int.Parse(itm.日程周数); + _PO_Detail_Det.Schedulemonth = string.IsNullOrEmpty(itm.日程月数) ? 1 : int.Parse(itm.日程月数); + _PO_Detail_Det.Supplieritem = itm.供应商零件; + _PO_Detail_Det.Dliverypatterncode = itm.发货样式; + _PO_Detail_Det.Deliverytimecode = itm.发货时间样式; + _PO_Detail_Det.Transportdays = string.IsNullOrEmpty(itm.运输周期) ? 0 : int.Parse(itm.运输周期); + _PO_Detail_Det.Pricelist = _entity.供应商编号.ToUpper() + subsite.Substring(1, 1) + subsite.Substring(3, 1); + db.TED_POD_DET.Add(_PO_Detail_Det); + _number++; + }); + _polist = _polist + _po.PoBillNum + ","; + } + #endregion + } + var ret = CREATE_TEA_TASK_SUB(db, true, new TEA_TASK_SUB() + { + DataCount = 1, + TaskID = taskid, + TableName = "TED_PO_MSTR", + Site = subsite.Trim().ToUpper(), + Domain = site.Trim().ToUpper(), + CreateTime = p_time, + CreateUser = p_creator, + Creator = "SCP", + }); + _num++; + Thread.Sleep(10); + } + ); + EntitiesFactory.SaveDb(scpdb); + EntitiesFactory.SaveDb(db); + scope.Complete(); + _ret.State = ReturnStatus.Succeed; + _ret.Result = true; + _ret.Message = _polist; + + } + catch (Exception e) + { + _ret.State = ReturnStatus.Failed; + LogHelper.Writlog(LogHelper.LogType.Error, typeof(TEA_TASK_SUB), "InsterPo", e.Message); + _ret.Result = false; + _ret.Message = e.InnerException.Message; + scope.Dispose(); + + } + } + return _ret; + } //public static ResultObject UpdateTES_PURCHASE_PRICE(List p_list, string domain, string site, string name, bool flag,int ConfirmState) //{ - + // ResultObject _ret = new ResultObject(); // if (ConfirmState!=(int)PriceState.FConfirm) // { @@ -1819,7 +2272,7 @@ namespace CK.SCP.Controller // ExchangeCenterContext db = EntitiesFactory.CreateExchangeCenterInstance(); // List _teslist = new List(); // var _ls = scpdb.V_TB_PRICE.Where(p => p_list.Contains(p.UID)).ToList(); - + // foreach (var _price in _ls) // { // Guid _taskguid = Guid.NewGuid(); @@ -1921,7 +2374,7 @@ namespace CK.SCP.Controller // ScpEntities scpdb = EntitiesFactory.CreateScpInstance(); // ExchangeCenterContext db = EntitiesFactory.CreateExchangeCenterInstance(); // var OrderList = p_order_list.GroupBy(p => p.订单编号).ToList(); - // string _polist = ""; + // string _polist = ""; // int _num = 1; // OrderList.ForEach((p) => // { @@ -1933,7 +2386,7 @@ namespace CK.SCP.Controller // if (p_modtype == BillModType.Contract) // { // var _entity = list.FirstOrDefault(); - // var _po = scpdb.TB_PO.SingleOrDefault(t => t.PoBillNum == _entity.订单编号/* && t.State == state*/ && t.Site == site && t.SubSite == subsite && t.VendId == _entity.供应商编号.ToUpper()); + // var _po = scpdb.TB_PO.SingleOrDefault(t => t.PoBillNum == _entity.订单编号/* && t.State == state*/ && t.Site == site && t.SubSite == subsite && t.VendId == _entity.供应商编号.ToUpper()); // TED_PO_MSTR _po_mstr = new TED_PO_MSTR(); // _po_mstr.GUID = Guid.NewGuid(); // _po_mstr.PurchaseOrder = _entity.订单编号.Trim().ToUpper(); @@ -1971,7 +2424,7 @@ namespace CK.SCP.Controller // } // db.TED_PO_MSTR.Add(_po_mstr); - // _po.ErpBillNum = _entity.订单编号.Trim().ToUpper();; + // _po.ErpBillNum = _entity.订单编号.Trim().ToUpper(); ; // _po.ModType = (int)p_modtype; // _po.Contacter = p_chineseName;// _entity.联系人; // _po.Buyer = p_chineseName;// _entity.联系人; @@ -2014,7 +2467,7 @@ namespace CK.SCP.Controller // else // { // _PO_Detail_Det.PoUm = _part.Unit; - // _PO_Detail_Det.LocUm =_part.Unit; + // _PO_Detail_Det.LocUm = _part.Unit; // } // _PO_Detail_Det.Conv = 1; // _PO_Detail_Det.DueDate = string.IsNullOrEmpty(itm.要求到货日期) ? DateTime.Now : DateTime.Parse(itm.要求到货日期); @@ -2037,7 +2490,7 @@ namespace CK.SCP.Controller // _PO_Detail_Det.Domain = site.Trim().ToUpper(); // _PO_Detail_Det.Site = subsite.Trim().ToUpper(); // _PO_Detail_Det.Workorderlot = itm.加工单号; - // _PO_Detail_Det.PoType = itm.订单类型; + // _PO_Detail_Det.PoType = itm.订单类型; // _PO_Detail_Det.Operation = string.IsNullOrEmpty(itm.工序) ? 0 : int.Parse(itm.工序); // _PO_Detail_Det.Location = itm.库位; // _PO_Detail_Det.Firmdays = string.IsNullOrEmpty(itm.固定天数) ? 7 : int.Parse(itm.固定天数); @@ -2064,7 +2517,7 @@ namespace CK.SCP.Controller // _PO_Detail.Remark = itm.备注; // _PO_Detail.Price = string.IsNullOrEmpty(itm.单价) ? 0 : decimal.Parse(itm.单价); // _PO_Detail.Workorderlot = string.IsNullOrEmpty(itm.加工单号) ? 0 : int.Parse(itm.加工单号); - // _PO_Detail.PoType =itm.订单类型; + // _PO_Detail.PoType = itm.订单类型; // _PO_Detail.Operation = string.IsNullOrEmpty(itm.工序) ? 0 : int.Parse(itm.工序); // _PO_Detail.Location = itm.库位; // _PO_Detail.Firmdays = string.IsNullOrEmpty(itm.固定天数) ? 7 : int.Parse(itm.固定天数); @@ -2128,7 +2581,7 @@ namespace CK.SCP.Controller // scpdb.TB_ASK.Add(_ask); // TED_PO_MSTR _po_mstr = new TED_PO_MSTR(); // _po_mstr.GUID = Guid.NewGuid(); - + // _po_mstr.PurchaseOrder = _po.PoBillNum; // _po_mstr.Supplier = _entity.供应商编号.Trim().ToUpper(); // _po_mstr.Contact = p_chineseName;// _entity.联系人; @@ -2283,7 +2736,7 @@ namespace CK.SCP.Controller // scope.Complete(); // _ret.State = ReturnStatus.Succeed; // _ret.Result = true; - // _ret.Message= _polist; + // _ret.Message = _polist; // } // catch (Exception e) @@ -2460,7 +2913,7 @@ namespace CK.SCP.Controller // { // Guid taskid = Guid.NewGuid(); // TED_PO_MSTR item = new TED_PO_MSTR(); - + // var _mstr = scpdb.TB_PO.FirstOrDefault(t => t.PoBillNum == _num && t.State == (int)PoState.Open); // if (_mstr!= null) // { diff --git a/Controller/SCP_INVOICE_CONTROLLER.cs b/Controller/SCP_INVOICE_CONTROLLER.cs index 190c381..ad98597 100644 --- a/Controller/SCP_INVOICE_CONTROLLER.cs +++ b/Controller/SCP_INVOICE_CONTROLLER.cs @@ -212,7 +212,7 @@ namespace CK.SCP.Controller } if (!string.IsNullOrEmpty(p_entity.InvcBillNum)) { - q = q.Where(p => p.InvcBillNum.Contains(p_entity.InvcBillNum)); + q = q.Where(p => p.InvcBillNum==p_entity.InvcBillNum); } if (!string.IsNullOrEmpty(p_entity.VendId)) { @@ -497,11 +497,11 @@ namespace CK.SCP.Controller { q = q.Where(p => p.VendName.Contains(p_entity.VendName)); } - if (p_entity.BeginTime != null && !p_entity.BeginTime.ToString().Contains("0001/1/1")) + if (p_entity.BeginTime != null && !p_entity.BeginTime.ToString("yyyy-M-d").Contains("0001-1-1")) { q = q.Where(p => p.CreateTime >= p_entity.BeginTime); } - if (p_entity.EndTime != null && !p_entity.EndTime.ToString().Contains("0001/1/1")) + if (p_entity.EndTime != null && !p_entity.EndTime.ToString("yyyy-M-d").Contains("0001-1-1")) { q = q.Where(p => p.CreateTime <= p_entity.EndTime); } @@ -628,7 +628,7 @@ namespace CK.SCP.Controller } if (!string.IsNullOrEmpty(p_entity.InvcBillNum)) { - q = q.Where(p => p.InvcBillNum.Contains(p_entity.InvcBillNum)); + q = q.Where(p => p.InvcBillNum==(p_entity.InvcBillNum)); } if (!string.IsNullOrEmpty(p_entity.PoBillNum)) { @@ -714,7 +714,7 @@ namespace CK.SCP.Controller { q = q.Where(p => p.CreateUser.Contains(p_entity.CreateUser)); } - q = q.Where(p => p.IsRed == p_entity.IsRed); + // q = q.Where(p => p.IsRed == p_entity.IsRed); _ret.State = ReturnStatus.Succeed; _ret.Result = q; @@ -956,6 +956,7 @@ namespace CK.SCP.Controller invoice.CreateUser = p_entity.CreateUser; invoice.CreateTime = DateTime.Now; invoice.Site = p_entity.Site; + invoice.SubSite = p_entity.SubSite; invoice.State = (int)InvoiceState.New; invoice.IsDeleted = false; invoice.GUID = Guid.NewGuid(); @@ -976,6 +977,8 @@ namespace CK.SCP.Controller p_list.ForEach(p => { TB_INVOICE_DETAIL invocieDetail = new TB_INVOICE_DETAIL(); + invocieDetail.Site = invoice.Site; + invocieDetail.SubSite = invoice.SubSite; invocieDetail.InvcBillNum= invoice.InvcBillNum; invocieDetail.AsnBillNum = p.AsnBillNum; invocieDetail.PoBillNum = p.PoBillNum; @@ -1097,6 +1100,7 @@ namespace CK.SCP.Controller { ResultObject _ret = new ResultObject(); List _list = new List(); + List _listpartcode = new List();//超过分摊零件集合 try { using (ScpEntities db = EntitiesFactory.CreateScpInstance()) @@ -1151,8 +1155,12 @@ namespace CK.SCP.Controller var _num = _moldsharing.Count + p.Qty; if (_moldsharing.Qty < _num) { - string _str ="供应商"+ _moldsharing .VendId+ "零件名称"+ _moldsharing.PartCode+"超过分摊数量"+ (_num- _moldsharing.Qty).ToString(); - _list.Add(_str); + string _str = "供应商" + _moldsharing.VendId + "零件名称" + _moldsharing.PartCode + "超过分摊数量,分摊数量剩余" + (_moldsharing.Qty - _moldsharing.Count).ToString(); + if (!_listpartcode.Contains(_moldsharing.PartCode)) + { + _listpartcode.Add(_moldsharing.PartCode); + _list.Add(_str); + } } else { diff --git a/Controller/SCP_PLAN_CONTROLLER.cs b/Controller/SCP_PLAN_CONTROLLER.cs index 7598f01..d16706a 100644 --- a/Controller/SCP_PLAN_CONTROLLER.cs +++ b/Controller/SCP_PLAN_CONTROLLER.cs @@ -877,8 +877,8 @@ namespace CK.SCP.Controller } } if (column.ColumnName == "计划天数") - { - if (dr["计划天数"] != null) + { + if (dr["计划天数"] != null) { _dayList.Add(dr["计划天数"].ToString().Trim()); } @@ -922,6 +922,10 @@ namespace CK.SCP.Controller { _ret.MessageList.Add("版本号、计划天数、零件编码、订单编号、行号、供应商编码、域、单位为必填列"); } + if (string.IsNullOrEmpty(_dayList.FirstOrDefault().ToString())) + { + _ret.MessageList.Add("计划天数不能为空!"); + } #endregion if (_ret.MessageList.Count == 0) { @@ -1023,6 +1027,8 @@ namespace CK.SCP.Controller { if (_dayList.Count > 0) { + + var _askday = int.Parse(_dayList.FirstOrDefault()); var _planDayList = _ls.Select(p => p.EndTime).Distinct(); if (_askday > _planDayList.Count()) diff --git a/Controller/SCP_PO_CONTROLLER.cs b/Controller/SCP_PO_CONTROLLER.cs index d366f22..4db65b5 100644 --- a/Controller/SCP_PO_CONTROLLER.cs +++ b/Controller/SCP_PO_CONTROLLER.cs @@ -12,6 +12,7 @@ using CK.SCP.Utils; using System.Data.Entity.Core; using CK.SCP.Models.ScpEntity.ExcelExportEnttity; using System.Text.RegularExpressions; +using System.Threading; namespace CK.SCP.Controller { @@ -634,9 +635,622 @@ namespace CK.SCP.Controller return ErrorList; } + public static ResultObject Save_EXCEL_PO_MOD(List p_order_list, string site, string p_creator, DateTime p_time, BillModType p_modtype, string subsite, string p_chineseName, string p_buyerPhone) + { + ResultObject _ret = new ResultObject(); + try + { + using (ScpEntities db = EntitiesFactory.CreateScpInstance()) + { + List lineError = new List(); + List ErrorList = new List(); + var _lst = p_order_list; + string _polist = ""; + int _num = 1; + var OrderList = _lst.GroupBy(p => p.订单编号).ToList(); + OrderList.ForEach((p) => + { + var list = p.ToList(); + if (list.Count > 0) + { + #region 日程单 + if (p_modtype == BillModType.Contract) + { + var _entity = list.FirstOrDefault(); + var _po = db.TB_PO.SingleOrDefault(t => t.PoBillNum == _entity.订单编号/* && t.State == state*/ && t.Site == site && t.SubSite == subsite && t.VendId == _entity.供应商编号.ToUpper()) ?? + new TB_PO { GUID = Guid.NewGuid(), PoBillNum = _entity.订单编号.ToUpper(), State = (int)PoState.Open, Site = site, SubSite = subsite, VendId = _entity.供应商编号.ToUpper() }; + _po.ErpBillNum = _entity.订单编号.ToUpper(); + _po.ModType = (int)p_modtype; + _po.Contacter = p_chineseName;// _entity.联系人; + _po.Buyer = p_chineseName;// _entity.联系人; + _po.BuyerPhone = p_buyerPhone; + _po.Site = site; + _po.Remark = _entity.备注; + _po.IsDeleted = false; + _po.CreateTime = DateTime.Parse(_entity.订单创建时间); + _po.CreateUser = p_creator; + _po.BeginTime = string.IsNullOrEmpty(_entity.订单创建时间) ? DateTime.Now : DateTime.Parse(_entity.订单创建时间); + _po.EndTime = string.IsNullOrEmpty(_entity.要求到货日期) ? DateTime.Now.AddYears(30) : DateTime.Parse(_entity.要求到货日期); + db.TB_PO.AddOrUpdate(_po); + list.ForEach((itm) => + { + int _poline = Int32.Parse(itm.行号); + var _PO_Detail = db.TB_PO_DETAIL.FirstOrDefault(t => t.PartCode == itm.零件号 && t.PoLine == _poline && t.PoBillNum == itm.订单编号 /*&& t.State == state*/ && t.Site == site && t.SubSite == subsite) ?? + new TB_PO_DETAIL { GUID = Guid.NewGuid(), PartCode = itm.零件号.ToUpper(), PoLine = _poline, PoBillNum = itm.订单编号.ToUpper(), State = (int)PoState.Open, Site = site, SubSite = subsite }; + _PO_Detail.Currency = "CNY"; + _PO_Detail.PoUnit = itm.单位; + _PO_Detail.CreateTime = DateTime.Parse(itm.订单创建时间); + _PO_Detail.CreateUser = p_creator; + _PO_Detail.BeginTime = string.IsNullOrEmpty(_entity.订单创建时间) ? DateTime.Now : DateTime.Parse(_entity.订单创建时间); + _PO_Detail.EndTime = string.IsNullOrEmpty(_entity.要求到货日期) ? DateTime.Now.AddYears(30) : DateTime.Parse(_entity.要求到货日期); + _PO_Detail.PlanQty = decimal.Parse(itm.数量); + _PO_Detail.IsDeleted = false; + _PO_Detail.LocUnit = itm.单位; + _PO_Detail.PoUnit = itm.单位; + _PO_Detail.UnConv = 1; + _PO_Detail.Price = string.IsNullOrEmpty(itm.单价) ? 0 : decimal.Parse(itm.单价); + db.TB_PO_DETAIL.AddOrUpdate(_PO_Detail); + }); + _polist = _polist + _po.PoBillNum + ","; + } + #endregion + #region 离散单 + if (p_modtype == BillModType.Non_Contract) + { + var _entity = list.FirstOrDefault(); + TB_PO _po = new TB_PO(); + _po.GUID = Guid.NewGuid(); + _po.PoBillNum = SCP_BILLCODE_CONTROLLER.MakePoNum(_num); + _po.State = (int)PoState.Open; + _po.Site = site; + _po.SubSite = subsite; + _po.VendId = _entity.供应商编号.ToUpper(); + _po.ErpBillNum = _po.PoBillNum; + _po.ModType = (int)p_modtype; + _po.Contacter = p_chineseName;// _entity.联系人; + _po.Buyer = p_chineseName;// _entity.联系人; + _po.BuyerPhone = p_buyerPhone; + _po.Site = site; + _po.Remark = _entity.备注; + _po.IsDeleted = false; + _po.CreateTime = DateTime.Parse(_entity.订单创建时间); + _po.CreateUser = p_creator; + _po.BeginTime = string.IsNullOrEmpty(_entity.订单创建时间) ? DateTime.Now : DateTime.Parse(_entity.订单创建时间); + _po.EndTime = string.IsNullOrEmpty(_entity.要求到货日期) ? DateTime.Now.AddYears(30) : DateTime.Parse(_entity.要求到货日期); + db.TB_PO.AddOrUpdate(_po); + TB_ASK _ask = new TB_ASK(); + _ask.AskBillNum = SCP_BILLCODE_CONTROLLER.MakeASKCodeByNum(_num); + _ask.GUID = Guid.NewGuid(); + _ask.PoBillNum = _po.PoBillNum; + _ask.VendId = _entity.供应商编号.ToUpper(); + _ask.IsDeleted = false; + _ask.CreateTime = DateTime.Now; + _ask.CreateUser = p_creator; + _ask.Site = site; + _ask.ReceivedPort = "";//交货口 + _ask.State = (int)AskState.New; + _ask.Remark = _entity.备注; + _ask.ModType = (int)p_modtype; + _ask.ErpBillNum = _po.PoBillNum; + _ask.BeginTime = p_time; + _ask.EndTime = DateTime.Parse(_entity.要求到货日期); + _ask.Buyer = p_chineseName; + _ask.BuyerPhone = p_buyerPhone; + _ask.SubSite = subsite; + db.TB_ASK.Add(_ask); + int _number = 1; + list.ForEach((itm) => + { + TB_PO_DETAIL _PO_Detail = new TB_PO_DETAIL(); + _PO_Detail.GUID = Guid.NewGuid(); + _PO_Detail.PartCode = itm.零件号.Trim().ToUpper(); + _PO_Detail.PoLine = _number; + _PO_Detail.PoBillNum = _po.PoBillNum; + _PO_Detail.State = (int)PoState.Open; + _PO_Detail.Site = site; + _PO_Detail.SubSite = subsite; + _PO_Detail.Currency = "CNY"; + _PO_Detail.PoUnit = itm.单位; + _PO_Detail.CreateTime = DateTime.Parse(itm.订单创建时间); + _PO_Detail.CreateUser = p_creator; + _PO_Detail.BeginTime = string.IsNullOrEmpty(_entity.订单创建时间) ? DateTime.Now : DateTime.Parse(_entity.订单创建时间); + _PO_Detail.EndTime = string.IsNullOrEmpty(_entity.要求到货日期) ? DateTime.Now.AddYears(30) : DateTime.Parse(_entity.要求到货日期); + _PO_Detail.PlanQty = decimal.Parse(itm.数量); + _PO_Detail.IsDeleted = false; + _PO_Detail.LocUnit = itm.单位; + _PO_Detail.PoUnit = itm.单位; + _PO_Detail.UnConv = 1; + _PO_Detail.Price = string.IsNullOrEmpty(itm.单价) ? 0 : decimal.Parse(itm.单价); + _PO_Detail.TempQty = decimal.Parse(itm.数量); + TB_ASK_DETAIL _tDetail = new TB_ASK_DETAIL(); + _tDetail.Remark = itm.备注; + _tDetail.PoBillNum = _po.PoBillNum; + _tDetail.AskBillNum = _ask.AskBillNum; + _tDetail.PoLine = _number; + _tDetail.PoUnit = itm.单位; + _tDetail.CreateTime = DateTime.Now; + _tDetail.CreateUser = p_creator; + _tDetail.PartCode = itm.零件号.Trim().ToUpper(); + _tDetail.ReceivedPort = ""; + _tDetail.BeginTime = p_time; + _tDetail.EndTime = Convert.ToDateTime(itm.要求到货日期); + _tDetail.TempQty = 0; + _tDetail.AskQty = Decimal.Parse(itm.数量); + _tDetail.IsDeleted = false; + _tDetail.LocUnit = itm.单位; + _tDetail.UnConv = 1; + _tDetail.State = (int)PoState.Open; + _tDetail.SubSite = subsite; + _tDetail.Site = site; + _tDetail.Price = Decimal.Parse(itm.单价); + _tDetail.GUID = Guid.NewGuid(); + _tDetail.Currency = itm.币种; + db.TB_ASK_DETAIL.Add(_tDetail); + db.TB_PO_DETAIL.AddOrUpdate(_PO_Detail); + _number++; + }); + _polist = _polist + _po.PoBillNum + "
"; + } + #endregion + } + else + { + _ret.MessageList.Add("订单导入有误!"); + return; + } + _num++; + Thread.Sleep(10); + } + ); + if (_ret.MessageList.Count == 0) + { + int state = db.SaveChanges(); + if (state != -1) + { + _ret.State = ReturnStatus.Succeed; + _ret.Result = true; + _ret.Message = _polist; + } + else + { + _ret.State = ReturnStatus.Failed; + _ret.Result = false; + } + } + else + { + _ret.State = ReturnStatus.Failed; + _ret.Result = false; + } + } + } + catch (System.Data.Entity.Validation.DbEntityValidationException dbEx)//捕获实体验证异常 + { + var sb = new StringBuilder(); + + foreach (var error in dbEx.EntityValidationErrors.ToList()) + { + + error.ValidationErrors.ToList().ForEach(i => + { + sb.AppendFormat("表:{0},字段:{1},信息:{2}\r\n", error.Entry.Entity.GetType().Name, i.PropertyName, i.ErrorMessage); + }); + } + _ret.State = ReturnStatus.Failed; + _ret.Result = false; + _ret.ErrorList.Add(dbEx); + LogHelper.Writlog(LogHelper.LogType.Error, typeof(SCP_PO_CONTROLLER), "EXCEL_PO_MOD", sb.ToString()); + throw new ScpException(ResultCode.DbEntityValidationException, sb.ToString(), "字段验证失败" + sb.ToString()); + } + catch (OptimisticConcurrencyException ex)//并发冲突异常 + { + + _ret.State = ReturnStatus.Failed; + _ret.Result = false; + _ret.ErrorList.Add(ex); + LogHelper.Writlog(LogHelper.LogType.Error, typeof(SCP_PO_CONTROLLER), "EXCEL_PO_MOD", ex.ToString()); + throw new ScpException(ResultCode.Exception, "9999", ex.ToString()); + } + catch (ScpException ex) + { + + + _ret.State = ReturnStatus.Failed; + _ret.Result = false; + _ret.ErrorList.Add(ex); + LogHelper.Writlog(LogHelper.LogType.Error, typeof(SCP_PO_CONTROLLER), "EXCEL_PO_MOD", ex.ToString()); + + if (ex.InnerException != null && ex.InnerException.GetType() == typeof(UpdateException)) + { + var inner = (UpdateException)ex.InnerException; + + + throw new ScpException(ResultCode.Exception, "0000", ex.ToString()); + } + else + { + if (ex.InnerException != null) throw ex.InnerException; + } + } + catch (Exception e) + { + _ret.State = ReturnStatus.Failed; + LogHelper.Writlog(LogHelper.LogType.Error, typeof(SCP_PO_CONTROLLER), "EXCEL_PO_MOD", e.Message); + _ret.Result = false; + _ret.ErrorList.Add(e); + throw e; + } + return _ret; + + } + + public static ResultObject Check_EXCEL_PO_MOD(List p_order_list, BillModType p_modtype, string site, string subsite) + { + ResultObject _ret = new ResultObject(); + try + { + using (ScpEntities db = EntitiesFactory.CreateScpInstance()) + { + int number = 1; + List lineError = new List(); + List ErrorList = new List(); + var _lst = p_order_list; + p_order_list.ForEach(p => + { + var _count1 = _lst.Count(itm => itm.订单编号 == p.订单编号 && itm.行号 == p.行号); + var _count2 = _lst.Count(itm => itm.订单编号 == p.订单编号 && itm.零件号 == p.零件号); + if (_count1 > 1 && p_modtype == BillModType.Contract) + { + lineError.Add(string.Format("导入订单编号【{0}】行号【{1}】有重复", p.订单编号, p.行号)); + ErrorList = lineError; + } + if (_count2 > 1) + { + lineError.Add(string.Format("导入订单编号【{0}】零件编码【{1}】有重复", p.订单编号, p.零件号)); + ErrorList = lineError; + } + }); + p_order_list.ForEach + (p => + { + var _ls = CheckExcelMode_Po(db, p, p_modtype, site, subsite); + if (_ls.Count > 0) + { + lineError.Add(number.ToString()); + ErrorList.Add(string.Join("
", _ls.ToArray())); + } + number++; + }); + if (lineError.Count > 0) + { + _ret.State = ReturnStatus.Failed; + _ret.MessageList.AddRange(ErrorList); + _ret.Result = false; + } + else + { + _ret.State = ReturnStatus.Succeed; + _ret.Result = true; + } + } + } + catch (System.Data.Entity.Validation.DbEntityValidationException dbEx)//捕获实体验证异常 + { + var sb = new StringBuilder(); + foreach (var error in dbEx.EntityValidationErrors.ToList()) + { + + error.ValidationErrors.ToList().ForEach(i => + { + sb.AppendFormat("表:{0},字段:{1},信息:{2}\r\n", error.Entry.Entity.GetType().Name, i.PropertyName, i.ErrorMessage); + }); + } + _ret.State = ReturnStatus.Failed; + _ret.Result = false; + _ret.ErrorList.Add(dbEx); + LogHelper.Writlog(LogHelper.LogType.Error, typeof(SCP_PO_CONTROLLER), "EXCEL_PO_MOD", sb.ToString()); + throw new ScpException(ResultCode.DbEntityValidationException, sb.ToString(), "字段验证失败" + sb.ToString()); + } + catch (OptimisticConcurrencyException ex)//并发冲突异常 + { + + _ret.State = ReturnStatus.Failed; + _ret.Result = false; + _ret.ErrorList.Add(ex); + LogHelper.Writlog(LogHelper.LogType.Error, typeof(SCP_PO_CONTROLLER), "EXCEL_PO_MOD", ex.ToString()); + throw new ScpException(ResultCode.Exception, "9999", ex.ToString()); + } + catch (ScpException ex) + { + + + _ret.State = ReturnStatus.Failed; + _ret.Result = false; + _ret.ErrorList.Add(ex); + LogHelper.Writlog(LogHelper.LogType.Error, typeof(SCP_PO_CONTROLLER), "EXCEL_PO_MOD", ex.ToString()); + + if (ex.InnerException != null && ex.InnerException.GetType() == typeof(UpdateException)) + { + var inner = (UpdateException)ex.InnerException; + + + throw new ScpException(ResultCode.Exception, "0000", ex.ToString()); + } + else + { + if (ex.InnerException != null) throw ex.InnerException; + } + } + catch (Exception e) + { + _ret.State = ReturnStatus.Failed; + LogHelper.Writlog(LogHelper.LogType.Error, typeof(SCP_PO_CONTROLLER), "EXCEL_PO_MOD", e.Message); + _ret.Result = false; + _ret.ErrorList.Add(e); + throw e; + } + return _ret; + + } + /// + /// 订单导入检查 + /// + /// + /// + /// + private static List CheckExcelMode_Po(ScpEntities db, SCP_PO_EXPORT_IMPORT_MODEL p_excel, BillModType p_modtype, string site = null, string subsite = null) + { + List ErrorList = new List(); + + decimal _result = 0; + if (!decimal.TryParse(p_excel.数量, out _result)) + { + ErrorList.Add(string.Format("订单编号【{0}】零件编号【{1}】数量填写有问题", p_excel.订单编号, p_excel.数量)); + } + var _checkpart = db.TA_PART.FirstOrDefault(p => p.PartCode == p_excel.零件号); + if (_checkpart != null) + { + if (_checkpart.State.ToUpper() != "SP") + { + p_excel.单位 = _checkpart.Unit; + } + else + { + ErrorList.Add(string.Format("订单编号为【{0}】的零件编号【{1}】零件表零件停用,无法导入!", p_excel.订单编号, p_excel.零件号)); + } + } + else + { + ErrorList.Add(string.Format("订单编号为【{0}】的零件编号【{1}】零件表里无数据,无法导入!", p_excel.订单编号, p_excel.零件号)); + } + + DateTime _d = DateTime.Now; + + #region 日程单验证 + + + + if (p_modtype == BillModType.Contract) + { + if (string.IsNullOrEmpty(p_excel.订单编号) || string.IsNullOrEmpty(p_excel.行号) || string.IsNullOrEmpty(p_excel.订单创建时间) || + string.IsNullOrEmpty(p_excel.要求到货日期) || string.IsNullOrEmpty(p_excel.零件号) || string.IsNullOrEmpty(p_excel.数量)) + { + ErrorList.Add(string.Format("分组【{1}】零件名称【{0}】有填写为空!", p_excel.零件号, p_excel.订单编号)); + } + else + { + if (!string.IsNullOrEmpty(p_excel.零件截至日期)) + { + DateTime year = DateTime.Parse(p_excel.零件截至日期); + if (year.Year > 2049) + { + ErrorList.Add(string.Format("订单编号【{2}】零件名称【{0}】供应编码【{1}】的零件截止日期必须大于等于2049年!", p_excel.零件号, p_excel.供应商编号, p_excel.订单编号)); + } + } + if (!string.IsNullOrEmpty(p_excel.订单截至日期)) + { + DateTime year = DateTime.Parse(p_excel.订单截至日期); + if (year.Year > 2049) + { + ErrorList.Add(string.Format("订单编号【{2}】零件名称【{0}】供应编码【{1}】的订单截止日期必须大于等于2049年!", p_excel.零件号, p_excel.供应商编号, p_excel.订单编号)); + } + } + string _ponumber = p_excel.供应商编号.ToUpper() + subsite.Substring(1, 1) + subsite.Substring(3, 1); + if (p_excel.订单编号.ToUpper() != _ponumber.ToUpper()) + { + ErrorList.Add(string.Format("订单编号【{0}】行号【{1}】零件号【{2}】的订单编号不正确,请更换订单编号!", p_excel.订单编号, p_excel.行号, p_excel.零件号)); + } + + int _polinr = Int32.Parse(p_excel.行号); + var _partlist = db.TB_PO_DETAIL.Where(p => p.PoBillNum == p_excel.订单编号 && p.PartCode == p_excel.零件号 && p.PoLine != _polinr).ToList(); + if (_partlist.Count > 0) + { + ErrorList.Add(string.Format("订单编号【{0}】零件号【{1}】已经存在(系统:行号-【{2}】),请更换零件号!", p_excel.订单编号, p_excel.零件号, _partlist[0].PoLine)); + } + int linecount = db.TB_PO_DETAIL.Count(p => p.PoBillNum == p_excel.订单编号 && p.PoLine == _polinr && p.PartCode != p_excel.零件号); + if (linecount > 0) + { + ErrorList.Add(string.Format("订单编号【{0}】行号【{1}】已经存在,请更换行号!", p_excel.订单编号, p_excel.行号)); + } + var checkcount = db.TB_PRICE.Where(p => p.PartCode == p_excel.零件号 && p.Site == site && p.VendId == p_excel.供应商编号 && p.StartTime <= DateTime.Now && DateTime.Now <= p.EndTime).ToList(); + if (checkcount.Count == 0) + { + ErrorList.Add(string.Format("零件名称【{0}】供应编码【{1}】价格表没有维护信息!", p_excel.零件号, p_excel.供应商编号)); + } + else + { + p_excel.单价 = checkcount[0].Amt.ToString(); + p_excel.单位 = checkcount[0].Unit; + p_excel.币种 = checkcount[0].Curr; + } + + if (p_excel.数量 != "0") + { + ErrorList.Add(string.Format("订单编号【{2}】零件名称【{0}】供应编码【{1}】的要货数量应该为零!", p_excel.零件号, p_excel.供应商编号, p_excel.订单编号)); + } + if (DateTime.TryParse(p_excel.订单创建时间, out _d) && DateTime.TryParse(p_excel.订单创建时间, out _d)) + { + if (DateTime.Parse(p_excel.要求到货日期) < DateTime.Parse(p_excel.订单创建时间)) + { + ErrorList.Add(string.Format("订单编号【{2}】零件名称【{0}】供应编码【{1}】要求到货日期不能小于订单创建时间日期!", p_excel.零件号, p_excel.供应商编号, p_excel.订单编号)); + } + } + else + { + ErrorList.Add(string.Format("订单编号【{2}】零件名称【{0}】供应编码【{1}】的订单创建日期或要求到货日期要求为文本格式!", p_excel.零件号, p_excel.供应商编号, p_excel.订单编号)); + } + if (!Regex.IsMatch(p_excel.税率, "^[0-9]{1,2}$")) + { + ErrorList.Add(string.Format("订单编号【{2}】零件名称【{0}】供应编码【{1}】税率最大应为2位整数!", p_excel.零件号, p_excel.供应商编号, p_excel.订单编号)); + } + if (!string.IsNullOrEmpty(p_excel.订单类型)) + { + if (p_excel.订单类型.ToUpper() == "S") + { + if (string.IsNullOrEmpty(p_excel.加工单号) || !Regex.IsMatch(p_excel.加工单号, "^[0-9]{1,8}$")) + { + ErrorList.Add(string.Format("订单编号【{2}】零件名称【{0}】供应编码【{1}】加工单最大8位整数!", p_excel.零件号, p_excel.供应商编号, p_excel.订单编号)); + } + if (string.IsNullOrEmpty(p_excel.工序) || !Regex.IsMatch(p_excel.工序, "^[0-9]{1,6}$")) + { + ErrorList.Add(string.Format("订单编号【{2}】零件名称【{0}】供应编码【{1}】工序最大6位整数!", p_excel.零件号, p_excel.供应商编号, p_excel.订单编号)); + } + } + else + { + ErrorList.Add(string.Format("{0}订单类型必须填写为S为转包订单,不填写为正常订单", p_excel.订单编号)); + } + //注释结束 + } + if (!string.IsNullOrEmpty(p_excel.库位) && p_excel.库位.Length > 8) + { + ErrorList.Add(string.Format("订单编号【{2}】零件名称【{0}】供应编码【{1}】库位最大8位字符!", p_excel.零件号, p_excel.供应商编号, p_excel.订单编号)); + } + if (!string.IsNullOrEmpty(p_excel.固定天数) && !Regex.IsMatch(p_excel.固定天数, "^[0-9]{1,4}$")) + { + ErrorList.Add(string.Format("订单编号【{2}】零件名称【{0}】供应编码【{1}】固定天数最大4位整数!", p_excel.零件号, p_excel.供应商编号, p_excel.订单编号)); + } + if (!string.IsNullOrEmpty(p_excel.日程天数) && !Regex.IsMatch(p_excel.日程天数, "^[0-9]{1,3}$")) + { + ErrorList.Add(string.Format("订单编号【{2}】零件名称【{0}】供应编码【{1}】日程天数最大3位整数!", p_excel.零件号, p_excel.供应商编号, p_excel.订单编号)); + } + if (!string.IsNullOrEmpty(p_excel.日程周数) && !Regex.IsMatch(p_excel.日程周数, "^[0-9]{1,3}$")) + { + ErrorList.Add(string.Format("订单编号【{2}】零件名称【{0}】供应编码【{1}】日程周数最大3位整数!", p_excel.零件号, p_excel.供应商编号, p_excel.订单编号)); + } + if (!string.IsNullOrEmpty(p_excel.日程月数) && !Regex.IsMatch(p_excel.日程月数, "^[0-9]{1,3}$")) + { + ErrorList.Add(string.Format("订单编号【{2}】零件名称【{0}】供应编码【{1}】日程月数最大3位整数!", p_excel.零件号, p_excel.供应商编号, p_excel.订单编号)); + } + if (!string.IsNullOrEmpty(p_excel.发货样式) && p_excel.发货样式.Length > 2) + { + ErrorList.Add(string.Format("订单编号【{2}】零件名称【{0}】供应编码【{1}】发货样式最大2位字符!", p_excel.零件号, p_excel.供应商编号, p_excel.订单编号)); + } + if (!string.IsNullOrEmpty(p_excel.发货时间样式) && p_excel.发货时间样式.Length > 2) + { + ErrorList.Add(string.Format("订单编号【{2}】零件名称【{0}】供应编码【{1}】发货时间样式最大2位字符!", p_excel.零件号, p_excel.供应商编号, p_excel.订单编号)); + } + if (!string.IsNullOrEmpty(p_excel.运输周期) && !Regex.IsMatch(p_excel.运输周期, "^[0-9]{1,3}$")) + { + ErrorList.Add(string.Format("订单编号【{2}】零件名称【{0}】供应编码【{1}】运输周期最大3位整数!", p_excel.零件号, p_excel.供应商编号, p_excel.订单编号)); + } + if (!string.IsNullOrEmpty(p_excel.库位) && p_excel.库位.Length > 8) + { + ErrorList.Add(string.Format("订单编号【{2}】零件名称【{0}】供应编码【{1}】库位最大8位字符!", p_excel.零件号, p_excel.供应商编号, p_excel.订单编号)); + } + } + } + #endregion + #region 离散单验证 + + if (p_modtype == BillModType.Non_Contract) + { + if (/*string.IsNullOrEmpty(p_excel.订单编号) ||string.IsNullOrEmpty(p_excel.行号) ||*/ string.IsNullOrEmpty(p_excel.订单截至日期) || + string.IsNullOrEmpty(p_excel.要求到货日期) || string.IsNullOrEmpty(p_excel.零件号) || string.IsNullOrEmpty(p_excel.数量) || + string.IsNullOrEmpty(p_excel.订单创建时间)/* || string.IsNullOrEmpty(p_excel.税率)*/) + { + ErrorList.Add(string.Format("分组【{1}】零件名称【{0}】有填写为空!", p_excel.零件号, p_excel.订单编号)); + } + else + { + decimal a = decimal.Parse(p_excel.数量); + if (a <= 0) + { + ErrorList.Add(string.Format("订单编号【{2}】零件名称【{0}】供应编码【{1}】的数量不能小于等于0", p_excel.零件号, p_excel.供应商编号, p_excel.订单编号)); + } + if (!string.IsNullOrEmpty(p_excel.零件截至日期)) + { + DateTime year = DateTime.Parse(p_excel.零件截至日期); + if (year.Year > 2049) + { + ErrorList.Add(string.Format("订单编号【{2}】零件名称【{0}】供应编码【{1}】的零件截止日期必须大于等于2049年!", p_excel.零件号, p_excel.供应商编号, p_excel.订单编号)); + } + } + if (!string.IsNullOrEmpty(p_excel.订单截至日期)) + { + DateTime year = DateTime.Parse(p_excel.订单截至日期); + if (year.Year > 2049) + { + ErrorList.Add(string.Format("订单编号【{2}】零件名称【{0}】供应编码【{1}】的订单截止日期必须大于等于2049年!", p_excel.零件号, p_excel.供应商编号, p_excel.订单编号)); + } + } + var checkcount = db.TB_PRICE.Where(p => p.PartCode == p_excel.零件号 && p.Site == site&& p.VendId == p_excel.供应商编号 && p.StartTime <= DateTime.Now && DateTime.Now <= p.EndTime).ToList(); + if (checkcount.Count == 0) + { + ErrorList.Add(string.Format("零件名称【{0}】供应编码【{1}】价格表没有维护信息!", p_excel.零件号, p_excel.供应商编号)); + } + else + { + p_excel.单价 = checkcount[0].Amt.ToString(); + p_excel.单位 = checkcount[0].Unit; + p_excel.币种 = checkcount[0].Curr; + } + //if (!Regex.IsMatch(p_excel.税率, "^[0-9]{1,2}$")) + //{ + // ErrorList.Add(string.Format("订单编号【{2}】零件名称【{0}】供应编码【{1}】税率最大2位整数!", p_excel.零件号, p_excel.供应商编号, p_excel.订单编号)); + //} + if (DateTime.TryParse(p_excel.订单创建时间, out _d) && DateTime.TryParse(p_excel.订单创建时间, out _d)) + { + if (DateTime.Parse(p_excel.要求到货日期) < DateTime.Parse(p_excel.订单创建时间)) + { + ErrorList.Add(string.Format("订单编号【{2}】零件名称【{0}】供应编码【{1}】要求到货日期不能小于订单创建时间日期!", p_excel.零件号, p_excel.供应商编号, p_excel.订单编号)); + } + } + else + { + ErrorList.Add(string.Format("订单编号【{2}】零件名称【{0}】供应编码【{1}】的订单创建日期或要求到货日期要求为文本格式!", p_excel.零件号, p_excel.供应商编号, p_excel.订单编号)); + } + if (!string.IsNullOrEmpty(p_excel.订单类型)) + { + if (p_excel.订单类型.ToUpper() != "S" && p_excel.订单类型.ToUpper() != "M") + { + ErrorList.Add(string.Format("订单编号【{2}】零件名称【{0}】供应编码【{1}】的订单类型只能为M或S!", p_excel.零件号, p_excel.供应商编号, p_excel.订单编号)); + } + //注释结束 + if (p_excel.订单类型.ToUpper() == "S") + { + if (string.IsNullOrEmpty(p_excel.加工单号) || !Regex.IsMatch(p_excel.加工单号, "^[0-9]{1,8}$")) + { + ErrorList.Add(string.Format("订单编号【{2}】零件名称【{0}】供应编码【{1}】加工单最大8位整数!", p_excel.零件号, p_excel.供应商编号, p_excel.订单编号)); + } + if (string.IsNullOrEmpty(p_excel.工序) || !Regex.IsMatch(p_excel.工序, "^[0-9]{1,6}$")) + { + ErrorList.Add(string.Format("订单编号【{2}】零件名称【{0}】供应编码【{1}】工序最大6位整数!", p_excel.零件号, p_excel.供应商编号, p_excel.订单编号)); + } + } + } + if (!string.IsNullOrEmpty(p_excel.库位) && p_excel.库位.Length > 8) + { + ErrorList.Add(string.Format("订单编号【{2}】零件名称【{0}】供应编码【{1}】库位最大8位字符!", p_excel.零件号, p_excel.供应商编号, p_excel.订单编号)); + } + } + } + #endregion + return ErrorList; + } private static List CheckExcelMode(ScpEntities db, SCP_PO_DETAIL_EXPORT_MODEL p_excel) { List ErrorList = new List(); @@ -1772,7 +2386,7 @@ namespace CK.SCP.Controller _PO_Detail.CreateUser = p_creator; _PO_Detail.PartCode = itm.零件号.ToUpper(); _PO_Detail.BeginTime = p_time; - _PO_Detail.EndTime = DateTime.Parse(_entity.要求到货日期); + _PO_Detail.EndTime = DateTime.Parse(itm.要求到货日期); _PO_Detail.PlanQty = decimal.Parse(itm.数量); _PO_Detail.IsDeleted = false; _PO_Detail.LocUnit = itm.单位; @@ -1781,6 +2395,7 @@ namespace CK.SCP.Controller _PO_Detail.State = (int)PoState.Open; _PO_Detail.Price = string.IsNullOrEmpty(itm.单价) ? 0 : decimal.Parse(itm.单价); _PO_Detail.GUID = Guid.NewGuid(); + _PO_Detail.Site = site; db.TB_PO_DETAIL.Add(_PO_Detail); // _number++; }); @@ -2169,6 +2784,7 @@ namespace CK.SCP.Controller _tDetail.Price = itm.Price; _tDetail.GUID = Guid.NewGuid(); _tDetail.Currency = itm.Currency; + _tDetail.Site = itm.Site; _tDetail.SubSite = itm.SubSite; _tDetail.Extend1 = itm.Extend1; _tDetail.Extend2 = itm.Extend2; diff --git a/Controller/SCP_RECEIVE_CONTROLLER.cs b/Controller/SCP_RECEIVE_CONTROLLER.cs index 55afc5d..d3cfe45 100644 --- a/Controller/SCP_RECEIVE_CONTROLLER.cs +++ b/Controller/SCP_RECEIVE_CONTROLLER.cs @@ -101,12 +101,13 @@ namespace CK.SCP.Controller if (p_entity.UserInAddress != null && p_entity.UserInAddress.Count > 0) { q = q.Where(p => p_entity.UserInAddress.Contains(p.Site)); - } - if (p_entity.ShipTimeStart != null && !p_entity.ShipTimeStart.ToString().Contains("0001/1/1")) + } + + if (p_entity.ShipTimeStart != null && !p_entity.ShipTimeStart.ToString("yyyy-M-d").Contains("0001-1-1")) { q = q.Where(p => p.ShipTime >= p_entity.ShipTimeStart); } - if (p_entity.ShipTimeEnd != null && !p_entity.ShipTimeEnd.ToString().Contains("0001/1/1")) + if (p_entity.ShipTimeEnd != null && !p_entity.ShipTimeEnd.ToString("yyyy-M-d").Contains("0001-1-1")) { q = q.Where(p => p.ShipTime <= p_entity.ShipTimeEnd); } diff --git a/Controller/SCP_TA_LANGUAGE_CONTROLLER.cs b/Controller/SCP_TA_LANGUAGE_CONTROLLER.cs index 3896726..0b68e5b 100644 --- a/Controller/SCP_TA_LANGUAGE_CONTROLLER.cs +++ b/Controller/SCP_TA_LANGUAGE_CONTROLLER.cs @@ -208,14 +208,16 @@ namespace CK.SCP.Controller - public static ResultObject Del_TA_LANGUAGE(TA_LANGUAGE p_entity) + public static ResultObject Del_TA_LANGUAGE(string _ls) { ResultObject _ret = new ResultObject(); try { using (ScpEntities db = EntitiesFactory.CreateScpInstance()) { - var _entity = db.TA_LANGUAGE.Where(itm => itm.GUID == p_entity.GUID).FirstOrDefault(); + + + var _entity = db.TA_LANGUAGE.Where(p=>p.UID.ToString()==_ls).FirstOrDefault(); db.TA_LANGUAGE.Remove(_entity); if (db.SaveChanges() != -1) @@ -292,8 +294,6 @@ namespace CK.SCP.Controller } - - + } - diff --git a/Controller/SCP_TB_VENDER_CONTROLLER.cs b/Controller/SCP_TB_VENDER_CONTROLLER.cs index 8759e26..68621a1 100644 --- a/Controller/SCP_TB_VENDER_CONTROLLER.cs +++ b/Controller/SCP_TB_VENDER_CONTROLLER.cs @@ -53,7 +53,14 @@ namespace CK.SCP.Controller return query.ToList(); } } - + public static List Getlist(List lsVenderID,List p_list) + { + using (ScpEntities db = EntitiesFactory.CreateScpInstance()) + { + var query = db.TA_VENDER.Where(p => lsVenderID.Contains(p.VendId)&& p_list.Contains(p.Site)); + return query.ToList(); + } + } public static TA_VENDER GetVender(string p_VenderID,string p_Site) { diff --git a/Controller/SCP_V_TA_VEND_PART_CONTROLLER.cs b/Controller/SCP_V_TA_VEND_PART_CONTROLLER.cs index 6db144a..0a2d5c7 100644 --- a/Controller/SCP_V_TA_VEND_PART_CONTROLLER.cs +++ b/Controller/SCP_V_TA_VEND_PART_CONTROLLER.cs @@ -71,7 +71,14 @@ namespace CK.SCP.Controller { q = q.Where(p => p.PartDesc.Contains(p_entity.PartDesc)); } - + if (p_entity.UserInAddress != null && p_entity.UserInAddress.Count > 0) + { + q = q.Where(p => p_entity.UserInAddress.Contains(p.Site)); + } + if (p_entity.UserInVendIds != null && p_entity.UserInVendIds.Count > 0) + { + q = q.Where(p => p_entity.UserInVendIds.Contains(p.VendId)); + } _ret.State = ReturnStatus.Succeed; _ret.Result = q; diff --git a/Controller/SCP_WMS_CONTROLLER.cs b/Controller/SCP_WMS_CONTROLLER.cs index cddace8..a5d4117 100644 --- a/Controller/SCP_WMS_CONTROLLER.cs +++ b/Controller/SCP_WMS_CONTROLLER.cs @@ -208,6 +208,10 @@ namespace CK.SCP.Controller { q = q.Where(p => p.PartCode.Contains(p_entity.PartCode)); } + if (!string.IsNullOrEmpty(p_entity.VendId)) + { + q = q.Where(p => p.VendId.Contains(p_entity.VendId)); + } if (p_entity.UserInVendIds != null && p_entity.UserInVendIds.Count > 0) { q = q.Where(p => p_entity.UserInVendIds.Contains(p.VendId)); @@ -283,6 +287,10 @@ namespace CK.SCP.Controller { q = q.Where(p => p.PartCode.Contains(p_entity.PartCode)); } + if (!string.IsNullOrEmpty(p_entity.VendId)) + { + q = q.Where(p => p.VendId.Contains(p_entity.VendId)); + } if (p_entity.UserInVendIds != null && p_entity.UserInVendIds.Count > 0) { q = q.Where(p => p_entity.UserInVendIds.Contains(p.VendId)); diff --git a/Models/AppBoxEntity/User.cs b/Models/AppBoxEntity/User.cs index 0050037..1278da1 100644 --- a/Models/AppBoxEntity/User.cs +++ b/Models/AppBoxEntity/User.cs @@ -98,7 +98,7 @@ namespace CK.SCP.Models.AppBoxEntity public Dictionary ConfigList { set; get; } [NotMapped] - public List SiteList { set; get; } + public List SubSiteList { set; get; } [NotMapped] public string UsedDomain { set; get; } diff --git a/Models/CK.SCP.Models.csproj b/Models/CK.SCP.Models.csproj index f42c58a..b6c0c90 100644 --- a/Models/CK.SCP.Models.csproj +++ b/Models/CK.SCP.Models.csproj @@ -345,6 +345,7 @@ + diff --git a/Models/ScpCache.cs b/Models/ScpCache.cs index feb222c..97f1bed 100644 --- a/Models/ScpCache.cs +++ b/Models/ScpCache.cs @@ -286,7 +286,7 @@ namespace CK.SCP.Models public static string GetPartDesc1(string partCode,string p_site) { - var _ta = PartList.SingleOrDefault(p => p.PartCode == partCode && p.Site==p_site); + var _ta = PartList.SingleOrDefault(p => p.PartCode == partCode && p.Site.ToUpper()==p_site.ToUpper()); if (_ta != null) { return _ta.PartDesc1 + _ta.PartDesc2; @@ -313,8 +313,11 @@ namespace CK.SCP.Models public bool 条码包含供应商简称 { get; set; } = false; public string 二维码格式 { get; set; } = "1"; - public string 条码序列号格式 { get; set; } = "000000"; + public string 条码序列号格式 { get; set; } = "000000"; + public string 托码序列号格式 { get; set; } = "700000"; public string 小包装条码序列号格式 { get; set; } = "600000"; public bool 负数发票 { get; set; } = false; + public bool 开票数量限制 { get; set; } = true; + public bool 数据中心接口 { get; set; } = false; } } \ No newline at end of file diff --git a/Models/ScpEntities.cs b/Models/ScpEntities.cs index e567092..d734b7e 100644 --- a/Models/ScpEntities.cs +++ b/Models/ScpEntities.cs @@ -96,6 +96,7 @@ namespace CK.SCP.Models public virtual DbSet V_TB_REJECT_DETAIL { get; set; } public virtual DbSet TS_BARCODE_RULE { get; set; } public virtual DbSet TS_BARCODE_RULE_SMALL { get; set; } + public virtual DbSet TB_PALLETS_RULL { get; set; } public virtual DbSet V_TB_INVOICE_DETAIL { get; set; } public virtual DbSet V_TB_INVOICE { get; set; } public virtual DbSet V_TB_INVOICE_DETAIL_RED { get; set; } diff --git a/Models/ScpEntity/ExcelExportEnttity/SCP_PO_DETAIL_EXPORT.cs b/Models/ScpEntity/ExcelExportEnttity/SCP_PO_DETAIL_EXPORT.cs index 231aaef..66aea79 100644 --- a/Models/ScpEntity/ExcelExportEnttity/SCP_PO_DETAIL_EXPORT.cs +++ b/Models/ScpEntity/ExcelExportEnttity/SCP_PO_DETAIL_EXPORT.cs @@ -81,6 +81,22 @@ namespace CK.SCP.Models.ScpEntity.ExcelExportEnttity public string 要求到货日期 { get; set; } public string 备注 { get; set; } public string 币种 { set; get; } - + public string 订单类型 { get; set; } + public string 税率 { get; set; } + public string 加工单号 { get; set; } + public string 工序 { get; set; } + public string 库位 { get; set; } + public string 固定天数 { get; set; } + public string 日程天数 { get; set; } + public string 日程周数 { get; set; } + public string 日程月数 { get; set; } + public string 供应商零件 { get; set; } + public string 发货样式 { get; set; } + public string 发货时间样式 { get; set; } + public string 运输周期 { get; set; } + public string 零件开始时间 { get; set; } + public string 零件截至日期 { get; set; } + public string 订单开始时间 { get; set; } + public string 订单截至日期 { get; set; } } } diff --git a/Models/ScpEntity/TB_ASN_DETAIL.cs b/Models/ScpEntity/TB_ASN_DETAIL.cs index c541e00..4b9ed93 100644 --- a/Models/ScpEntity/TB_ASN_DETAIL.cs +++ b/Models/ScpEntity/TB_ASN_DETAIL.cs @@ -56,5 +56,6 @@ namespace CK.SCP.Models.ScpEntity public string Extend2 { get; set; } public string Extend3 { get; set; } public string SubSite { get; set; } + public string Site { get; set; } } } diff --git a/Models/ScpEntity/TB_INVOICE.cs b/Models/ScpEntity/TB_INVOICE.cs index 13671bb..98a2951 100644 --- a/Models/ScpEntity/TB_INVOICE.cs +++ b/Models/ScpEntity/TB_INVOICE.cs @@ -16,6 +16,8 @@ namespace CK.SCP.Models.ScpEntity [StringLength(50)] public string Site { get; set; } [StringLength(50)] + public string SubSite { get; set; } + [StringLength(50)] public string InvoiceNum { get; set; } [StringLength(50)] public string ExpressNum { get; set; } diff --git a/Models/ScpEntity/TB_INVOICE_DETAIL.cs b/Models/ScpEntity/TB_INVOICE_DETAIL.cs index 0879727..a7cd28e 100644 --- a/Models/ScpEntity/TB_INVOICE_DETAIL.cs +++ b/Models/ScpEntity/TB_INVOICE_DETAIL.cs @@ -52,7 +52,10 @@ namespace CK.SCP.Models.ScpEntity [StringLength(50)] public string DiscountRemark { get; set; } public Nullable IsRed { get; set; } - + [StringLength(50)] + public string Site { get; set; } + [StringLength(50)] + public string SubSite { get; set; } } } diff --git a/Models/ScpEntity/TB_PALLETS.cs b/Models/ScpEntity/TB_PALLETS.cs index fe9a351..6b85b92 100644 --- a/Models/ScpEntity/TB_PALLETS.cs +++ b/Models/ScpEntity/TB_PALLETS.cs @@ -16,11 +16,20 @@ namespace CK.SCP.Models.ScpEntity [StringLength(50)] public string AsnBillNum { get; set; } public string PalletNum { get; set; } + public string BarCode { get; set; } + public string FullBarCode { get; set; } public string PartCode { get; set; } public string Batch { get; set; } public string VendId { get; set; } public int Box { get; set; } public decimal Qty { get; set; } + //--新添加 + public string VendBatch { get; set; } + + public string PoBillNum { get; set; } + public int PoBillLine { get; set; } + [Column(TypeName = "datetime2")] + public DateTime ProduceDate { get; set; } } } diff --git a/Models/ScpEntity/TB_PALLETS_RULL.cs b/Models/ScpEntity/TB_PALLETS_RULL.cs new file mode 100644 index 0000000..24d3d1b --- /dev/null +++ b/Models/ScpEntity/TB_PALLETS_RULL.cs @@ -0,0 +1,33 @@ +using System; +using System.ComponentModel.DataAnnotations; +using System.ComponentModel.DataAnnotations.Schema; + + +namespace CK.SCP.Models.ScpEntity +{ + public partial class TB_PALLETS_RULL + { + [DatabaseGenerated(DatabaseGeneratedOption.Computed)] + public int UID { get; set; } + + [Key] + [Column(Order = 0)] + [StringLength(50)] + public string PartCode { get; set; } + + [Key] + [Column(Order = 1)] + [StringLength(50)] + public string RuleBatch { get; set; } + + public int LastNumber { get; set; } + + [Required(AllowEmptyStrings = true)] + [StringLength(500)] + public string LastBarCode { get; set; } + + public DateTime LastTime { get; set; } + + public int State { get; set; } + } +} diff --git a/Models/ScpEntity/TB_PRICE.cs b/Models/ScpEntity/TB_PRICE.cs index 17c1534..88213b1 100644 --- a/Models/ScpEntity/TB_PRICE.cs +++ b/Models/ScpEntity/TB_PRICE.cs @@ -27,7 +27,7 @@ namespace CK.SCP.Models.ScpEntity public string Extend1 { get; set; } public string Extend2 { get; set; } public string Extend3 { get; set; } - public int State { get; set; } - public decimal? VendAmt { get; set; } + //public int State { get; set; } + //public decimal? VendAmt { get; set; } } } diff --git a/Models/ScpEntity/V_ASN_PRINT.cs b/Models/ScpEntity/V_ASN_PRINT.cs index 2d54c3f..a46ca33 100644 --- a/Models/ScpEntity/V_ASN_PRINT.cs +++ b/Models/ScpEntity/V_ASN_PRINT.cs @@ -40,7 +40,7 @@ namespace CK.SCP.Models.ScpEntity public string Memo { get; set; } public string DockCode { get; set; } public string Batch { get; set; } - + public string VendBatch { get; set; } public string ProjectId { get; set; } public string DockCode_Desc => ScpCache.PortList.Where(p => p.PORT_NO == DockCode).FirstOrDefault() == null ? "" : ScpCache.PortList.Where(p => p.PORT_NO == DockCode).FirstOrDefault().PORT_DESCRIPTION; diff --git a/Models/ScpEntity/V_TA_VEND_PART.cs b/Models/ScpEntity/V_TA_VEND_PART.cs index 56e93dc..415288c 100644 --- a/Models/ScpEntity/V_TA_VEND_PART.cs +++ b/Models/ScpEntity/V_TA_VEND_PART.cs @@ -36,5 +36,11 @@ namespace CK.SCP.Models.ScpEntity public string ProjectId { get; set; } [NotMapped] public string PartDesc { get; set; } + [NotMapped] + public List UserInAddress { set; get; } + + [NotMapped] + public List UserInVendIds { set; get; } + } } diff --git a/Models/ScpEntity/V_TB_RECEIVE_LIST.cs b/Models/ScpEntity/V_TB_RECEIVE_LIST.cs index bb0e3cc..61845a4 100644 --- a/Models/ScpEntity/V_TB_RECEIVE_LIST.cs +++ b/Models/ScpEntity/V_TB_RECEIVE_LIST.cs @@ -31,6 +31,7 @@ namespace CK.SCP.Models.ScpEntity public System.Guid GUID { get; set; } public string AsnBillNum { get; set; } public string Site { get; set; } + public string SubSite { get; set; } public string VendId { get; set; } public Nullable ShipTime { get; set; } public string OperName { get; set; } diff --git a/Models/UniApiEntity/xxwms_rc_det.cs b/Models/UniApiEntity/xxwms_rc_det.cs index cd7ddd8..290adee 100644 --- a/Models/UniApiEntity/xxwms_rc_det.cs +++ b/Models/UniApiEntity/xxwms_rc_det.cs @@ -51,11 +51,11 @@ namespace CK.SCP.Models.UniApiEntity public string xxwms_rc_loc { get; set; } [Required(AllowEmptyStrings = true)] - [StringLength(2)] + [StringLength(8)] public string xxwms_rc_po_um { get; set; } [Required(AllowEmptyStrings = true)] - [StringLength(2)] + [StringLength(8)] public string xxwms_rc_loc_um { get; set; } public decimal xxwms_rc_conv { get; set; } diff --git a/SCP/Admin/UNIAPI.aspx b/SCP/Admin/UNIAPI.aspx index c0e292a..fc562e6 100644 --- a/SCP/Admin/UNIAPI.aspx +++ b/SCP/Admin/UNIAPI.aspx @@ -40,7 +40,7 @@ - + diff --git a/SCP/Admin/UNIAPI.aspx.designer.cs b/SCP/Admin/UNIAPI.aspx.designer.cs index 4d1f2fb..6cb9aee 100644 --- a/SCP/Admin/UNIAPI.aspx.designer.cs +++ b/SCP/Admin/UNIAPI.aspx.designer.cs @@ -7,11 +7,13 @@ // //------------------------------------------------------------------------------ -namespace SCP.Admin { - - - public partial class UNIAPI { - +namespace SCP.Admin +{ + + + public partial class UNIAPI + { + /// /// form1 控件。 /// @@ -20,7 +22,7 @@ namespace SCP.Admin { /// 若要进行修改,请将字段声明从设计器文件移到代码隐藏文件。 /// protected global::System.Web.UI.HtmlControls.HtmlForm form1; - + /// /// Panel1 控件。 /// @@ -29,16 +31,16 @@ namespace SCP.Admin { /// 若要进行修改,请将字段声明从设计器文件移到代码隐藏文件。 /// protected global::FineUI.Panel Panel1; - + /// - /// Toolbar2 控件。 + /// Toolbar1 控件。 /// /// /// 自动生成的字段。 /// 若要进行修改,请将字段声明从设计器文件移到代码隐藏文件。 /// - protected global::FineUI.Toolbar Toolbar2; - + protected global::FineUI.Toolbar Toolbar1; + /// /// DDL_State 控件。 /// @@ -47,25 +49,34 @@ namespace SCP.Admin { /// 若要进行修改,请将字段声明从设计器文件移到代码隐藏文件。 /// protected global::FineUI.DropDownList DDL_State; - + /// - /// TXT_billnum 控件。 + /// BtnSearch 控件。 /// /// /// 自动生成的字段。 /// 若要进行修改,请将字段声明从设计器文件移到代码隐藏文件。 /// - protected global::FineUI.TextArea TXT_billnum; - + protected global::FineUI.Button BtnSearch; + /// - /// BtnSearch 控件。 + /// Toolbar2 控件。 /// /// /// 自动生成的字段。 /// 若要进行修改,请将字段声明从设计器文件移到代码隐藏文件。 /// - protected global::FineUI.Button BtnSearch; - + protected global::FineUI.Toolbar Toolbar2; + + /// + /// TXT_billnum 控件。 + /// + /// + /// 自动生成的字段。 + /// 若要进行修改,请将字段声明从设计器文件移到代码隐藏文件。 + /// + protected global::FineUI.TextArea TXT_billnum; + /// /// Grid 控件。 /// diff --git a/SCP/Admin/default.aspx b/SCP/Admin/default.aspx index b1b8587..79a4b5d 100644 --- a/SCP/Admin/default.aspx +++ b/SCP/Admin/default.aspx @@ -11,14 +11,14 @@
- - + - + --%> - + - diff --git a/SCP/Admin/default.aspx.cs b/SCP/Admin/default.aspx.cs index 9abdb72..4a2b7f7 100644 --- a/SCP/Admin/default.aspx.cs +++ b/SCP/Admin/default.aspx.cs @@ -30,7 +30,7 @@ namespace SCP.admin public void BindData() { SearchData(ret => { - if (CurrentUser.RoleList !=null && CurrentUser.RoleList.Contains("供应商")) + if (CurrentUser.RoleList !=null && CurrentUser.RoleList.Contains("供应商")&& !CurrentUser.RoleList.Contains("管理员")) { ret = SetV_INFO(ret); } diff --git a/SCP/Business/PageBase.cs b/SCP/Business/PageBase.cs index aeb3343..5e44e61 100644 --- a/SCP/Business/PageBase.cs +++ b/SCP/Business/PageBase.cs @@ -145,7 +145,27 @@ namespace SCP return queryIntValue; } + public void BindVenderByUser(DropDownList p_dl) + { + var _entity = CurrentUser.VenderList; + var _p = CurrentUser.FactoryList; + if (_entity.Count>0) + { + var ls = SCP_TB_VENDER_CONTROLLER.Getlist(_entity,_p); + var lsVender = ls; + lsVender.ForEach(p => + { + p.VendName = string.Format("{0}({1})", p.VendName, p.VendId); + }); + p_dl.DataSource = lsVender; + p_dl.DataTextField = "VendName"; + p_dl.DataValueField = "VendId"; + p_dl.DataBind(); + p_dl.Items.Insert(0, new FineUI.ListItem("--无供应商--", string.Empty)); + } + + } protected void BindVender(DropDownList p_dl) { var _entity = CurrentUser.FactoryList; @@ -595,7 +615,7 @@ namespace SCP _currentUser.RoleList = _currentUser.Roles.Select(p => p.Name).ToList(); var _userVerders = DB.VenderUsers.Where(p => p.UserId == _currentUser.ID).Select(p => p.VenderId).ToList(); _currentUser.FactoryList = _factoryList; - _currentUser.SiteList = _siteList; + _currentUser.SubSiteList = _siteList; _currentUser.VenderList = _userVerders; _currentUser.ConfigList = new Dictionary(); if (_currentUser.FactoryList.Count > 0) diff --git a/SCP/Common/MailHelper.cs b/SCP/Common/MailHelper.cs index 6009803..6872f9d 100644 --- a/SCP/Common/MailHelper.cs +++ b/SCP/Common/MailHelper.cs @@ -101,6 +101,41 @@ namespace SCP.Common } } } + + public static void SendMails(string p_VendId, string p_Content, string p_title) + { + using (AppBoxContext db = EntitiesFactory.CreateAppBoxInstance()) + { + StringBuilder _buffer = new StringBuilder(); + _buffer.Append("SELECT b.Email "); + _buffer.Append(" FROM VenderUsers AS a INNER JOIN "); + _buffer.Append(" Users AS b ON a.UserId = b.ID INNER JOIN "); + _buffer.Append(" RoleUsers AS g ON a.UserId = g.UserID INNER JOIN "); + _buffer.Append(" Roles AS h ON g.RoleID = h.ID "); + _buffer.AppendFormat(" WHERE(h.Name = '供应商' and a.VenderId in ({0}) and b.enabled=1 ) ", p_VendId); + var _userList = db.Database.SqlQuery(_buffer.ToString()).ToList(); + //var _vender = ScpCache.VenderList.Where(itm => itm.VendId == p_VendId).FirstOrDefault(); + if (_userList != null && _userList.Count > 0) + { + foreach (var itm in _userList) + { + string mails = ""; + mails += itm + ","; + if (mails != "") + { + mails = mails.Substring(0, mails.Length - 1); + } + string mailbody = ""; + mailbody += "尊敬的供应商
"; + mailbody += "你好!

"; + mailbody += "" + p_Content + " ,请到供应商SCP网站" + ConfigurationManager.AppSettings["ResetPassWord"] + "打开查看下载!
"; + mailbody += "



日期:" + DateTime.Now; + MyWebSmtpMail webmail = new MyWebSmtpMail(); + webmail.Send(mails, mailbody, p_title); + } + } + } + } /// /// 发邮件给采购 /// diff --git a/SCP/Default.aspx.designer.cs b/SCP/Default.aspx.designer.cs index c06ac5b..2409434 100644 --- a/SCP/Default.aspx.designer.cs +++ b/SCP/Default.aspx.designer.cs @@ -7,11 +7,13 @@ // //------------------------------------------------------------------------------ -namespace SCP { - - - public partial class _default { - +namespace SCP +{ + + + public partial class _default + { + /// /// form1 控件。 /// @@ -20,7 +22,7 @@ namespace SCP { /// 若要进行修改,请将字段声明从设计器文件移到代码隐藏文件。 /// protected global::System.Web.UI.HtmlControls.HtmlForm form1; - + /// /// div1 控件。 /// @@ -29,7 +31,7 @@ namespace SCP { /// 若要进行修改,请将字段声明从设计器文件移到代码隐藏文件。 /// protected global::System.Web.UI.HtmlControls.HtmlGenericControl div1; - + /// /// Label1 控件。 /// @@ -38,7 +40,7 @@ namespace SCP { /// 若要进行修改,请将字段声明从设计器文件移到代码隐藏文件。 /// protected global::System.Web.UI.HtmlControls.HtmlGenericControl Label1; - + /// /// factory 控件。 /// @@ -47,7 +49,7 @@ namespace SCP { /// 若要进行修改,请将字段声明从设计器文件移到代码隐藏文件。 /// protected global::System.Web.UI.HtmlControls.HtmlSelect factory; - + /// /// div_1 控件。 /// @@ -56,7 +58,7 @@ namespace SCP { /// 若要进行修改,请将字段声明从设计器文件移到代码隐藏文件。 /// protected global::System.Web.UI.HtmlControls.HtmlGenericControl div_1; - + /// /// lb_name 控件。 /// @@ -65,7 +67,7 @@ namespace SCP { /// 若要进行修改,请将字段声明从设计器文件移到代码隐藏文件。 /// protected global::System.Web.UI.HtmlControls.HtmlGenericControl lb_name; - + /// /// textName 控件。 /// @@ -74,7 +76,7 @@ namespace SCP { /// 若要进行修改,请将字段声明从设计器文件移到代码隐藏文件。 /// protected global::System.Web.UI.HtmlControls.HtmlInputText textName; - + /// /// div_3 控件。 /// @@ -83,7 +85,7 @@ namespace SCP { /// 若要进行修改,请将字段声明从设计器文件移到代码隐藏文件。 /// protected global::System.Web.UI.HtmlControls.HtmlGenericControl div_3; - + /// /// lb_mobile 控件。 /// @@ -92,7 +94,7 @@ namespace SCP { /// 若要进行修改,请将字段声明从设计器文件移到代码隐藏文件。 /// protected global::System.Web.UI.HtmlControls.HtmlGenericControl lb_mobile; - + /// /// textMobile 控件。 /// @@ -101,7 +103,7 @@ namespace SCP { /// 若要进行修改,请将字段声明从设计器文件移到代码隐藏文件。 /// protected global::System.Web.UI.HtmlControls.HtmlInputGenericControl textMobile; - + /// /// lab1 控件。 /// @@ -110,7 +112,7 @@ namespace SCP { /// 若要进行修改,请将字段声明从设计器文件移到代码隐藏文件。 /// protected global::System.Web.UI.HtmlControls.HtmlGenericControl lab1; - + /// /// textUserName 控件。 /// @@ -119,7 +121,7 @@ namespace SCP { /// 若要进行修改,请将字段声明从设计器文件移到代码隐藏文件。 /// protected global::System.Web.UI.HtmlControls.HtmlInputText textUserName; - + /// /// div_2 控件。 /// @@ -128,7 +130,7 @@ namespace SCP { /// 若要进行修改,请将字段声明从设计器文件移到代码隐藏文件。 /// protected global::System.Web.UI.HtmlControls.HtmlGenericControl div_2; - + /// /// lb_Mail 控件。 /// @@ -137,7 +139,7 @@ namespace SCP { /// 若要进行修改,请将字段声明从设计器文件移到代码隐藏文件。 /// protected global::System.Web.UI.HtmlControls.HtmlGenericControl lb_Mail; - + /// /// textEmail 控件。 /// @@ -146,7 +148,7 @@ namespace SCP { /// 若要进行修改,请将字段声明从设计器文件移到代码隐藏文件。 /// protected global::System.Web.UI.HtmlControls.HtmlInputGenericControl textEmail; - + /// /// lab2 控件。 /// @@ -155,7 +157,7 @@ namespace SCP { /// 若要进行修改,请将字段声明从设计器文件移到代码隐藏文件。 /// protected global::System.Web.UI.HtmlControls.HtmlGenericControl lab2; - + /// /// textPassword 控件。 /// @@ -164,7 +166,7 @@ namespace SCP { /// 若要进行修改,请将字段声明从设计器文件移到代码隐藏文件。 /// protected global::System.Web.UI.HtmlControls.HtmlInputPassword textPassword; - + /// /// div_4 控件。 /// @@ -173,7 +175,7 @@ namespace SCP { /// 若要进行修改,请将字段声明从设计器文件移到代码隐藏文件。 /// protected global::System.Web.UI.HtmlControls.HtmlGenericControl div_4; - + /// /// lb_PwdNew 控件。 /// @@ -182,7 +184,7 @@ namespace SCP { /// 若要进行修改,请将字段声明从设计器文件移到代码隐藏文件。 /// protected global::System.Web.UI.HtmlControls.HtmlGenericControl lb_PwdNew; - + /// /// textPassword1 控件。 /// @@ -191,7 +193,7 @@ namespace SCP { /// 若要进行修改,请将字段声明从设计器文件移到代码隐藏文件。 /// protected global::System.Web.UI.HtmlControls.HtmlInputText textPassword1; - + /// /// div_5 控件。 /// @@ -200,7 +202,7 @@ namespace SCP { /// 若要进行修改,请将字段声明从设计器文件移到代码隐藏文件。 /// protected global::System.Web.UI.HtmlControls.HtmlGenericControl div_5; - + /// /// lb_PwdConf 控件。 /// @@ -209,7 +211,7 @@ namespace SCP { /// 若要进行修改,请将字段声明从设计器文件移到代码隐藏文件。 /// protected global::System.Web.UI.HtmlControls.HtmlGenericControl lb_PwdConf; - + /// /// textConfim 控件。 /// @@ -218,7 +220,7 @@ namespace SCP { /// 若要进行修改,请将字段声明从设计器文件移到代码隐藏文件。 /// protected global::System.Web.UI.HtmlControls.HtmlInputText textConfim; - + /// /// btn_pass 控件。 /// @@ -227,7 +229,7 @@ namespace SCP { /// 若要进行修改,请将字段声明从设计器文件移到代码隐藏文件。 /// protected global::System.Web.UI.HtmlControls.HtmlInputButton btn_pass; - + /// /// btn_Login 控件。 /// @@ -236,7 +238,7 @@ namespace SCP { /// 若要进行修改,请将字段声明从设计器文件移到代码隐藏文件。 /// protected global::System.Web.UI.WebControls.Button btn_Login; - + /// /// btn_MailLogin 控件。 /// @@ -245,7 +247,7 @@ namespace SCP { /// 若要进行修改,请将字段声明从设计器文件移到代码隐藏文件。 /// protected global::System.Web.UI.WebControls.Button btn_MailLogin; - + /// /// btn_back 控件。 /// @@ -254,7 +256,7 @@ namespace SCP { /// 若要进行修改,请将字段声明从设计器文件移到代码隐藏文件。 /// protected global::System.Web.UI.HtmlControls.HtmlInputButton btn_back; - + /// /// factoryValue 控件。 /// @@ -263,7 +265,7 @@ namespace SCP { /// 若要进行修改,请将字段声明从设计器文件移到代码隐藏文件。 /// protected global::System.Web.UI.HtmlControls.HtmlInputText factoryValue; - + /// /// p_content 控件。 /// @@ -272,7 +274,7 @@ namespace SCP { /// 若要进行修改,请将字段声明从设计器文件移到代码隐藏文件。 /// protected global::System.Web.UI.HtmlControls.HtmlGenericControl p_content; - + /// /// p_title4 控件。 /// @@ -281,7 +283,7 @@ namespace SCP { /// 若要进行修改,请将字段声明从设计器文件移到代码隐藏文件。 /// protected global::System.Web.UI.HtmlControls.HtmlGenericControl p_title4; - + /// /// p_title1 控件。 /// @@ -290,7 +292,7 @@ namespace SCP { /// 若要进行修改,请将字段声明从设计器文件移到代码隐藏文件。 /// protected global::System.Web.UI.HtmlControls.HtmlAnchor p_title1; - + /// /// p_title2 控件。 /// @@ -299,7 +301,7 @@ namespace SCP { /// 若要进行修改,请将字段声明从设计器文件移到代码隐藏文件。 /// protected global::System.Web.UI.HtmlControls.HtmlAnchor p_title2; - + /// /// p_title3 控件。 /// @@ -308,7 +310,16 @@ namespace SCP { /// 若要进行修改,请将字段声明从设计器文件移到代码隐藏文件。 /// protected global::System.Web.UI.HtmlControls.HtmlAnchor p_title3; - + + /// + /// Versiontxt 控件。 + /// + /// + /// 自动生成的字段。 + /// 若要进行修改,请将字段声明从设计器文件移到代码隐藏文件。 + /// + protected global::System.Web.UI.HtmlControls.HtmlInputText Versiontxt; + /// /// PageManager1 控件。 /// diff --git a/SCP/Properties/AssemblyInfo.cs b/SCP/Properties/AssemblyInfo.cs index 1d95458..532507f 100644 --- a/SCP/Properties/AssemblyInfo.cs +++ b/SCP/Properties/AssemblyInfo.cs @@ -31,5 +31,5 @@ using System.Runtime.InteropServices; // // 可以指定所有值,也可以使用“修订号”和“内部版本号”的默认值, // 方法是按如下所示使用 "*": -[assembly: AssemblyVersion("1.0.0.0")] -[assembly: AssemblyFileVersion("1.0.0.0")] +[assembly: AssemblyVersion("1.21.0204.1")] +[assembly: AssemblyFileVersion("1.21.0204.1")] diff --git a/SCP/SCP.csproj b/SCP/SCP.csproj index a26a188..12b8095 100644 --- a/SCP/SCP.csproj +++ b/SCP/SCP.csproj @@ -253,6 +253,7 @@ + @@ -264,7 +265,8 @@ - + + @@ -2933,6 +2935,8 @@ + + @@ -2944,12 +2948,18 @@ + + + + + + @@ -5007,12 +5017,19 @@ SCP_FACTORY_EDIT.aspx - - SCP_LANGUAGE.aspx + + SCP_LANGUAGE_1.aspx ASPXCodeBehind - - SCP_LANGUAGE.aspx + + SCP_LANGUAGE_1.aspx + + + SCP_LANGUAGE_DETAIL.aspx + ASPXCodeBehind + + + SCP_LANGUAGE_DETAIL.aspx SCP_MoldSharing.aspx @@ -5193,6 +5210,20 @@ SCP_FORECAST.aspx + + SCP_INVOICE.aspx + ASPXCodeBehind + + + SCP_INVOICE.aspx + + + SCP_INVOICE_EDIT.aspx + ASPXCodeBehind + + + SCP_INVOICE_EDIT.aspx + SCP_PART_LIFE.aspx ASPXCodeBehind @@ -5269,6 +5300,13 @@ SCP_ASK_UNCOMPLETE.aspx + + SCP_RECEIVE_LIST.aspx + ASPXCodeBehind + + + SCP_RECEIVE_LIST.aspx + SCP_UNI_API.aspx ASPXCodeBehind @@ -5276,6 +5314,27 @@ SCP_UNI_API.aspx + + SCP_QUALITY_CREATE.aspx + ASPXCodeBehind + + + SCP_QUALITY_CREATE.aspx + + + SCP_QUALITY_MANAGER.aspx + ASPXCodeBehind + + + SCP_QUALITY_MANAGER.aspx + + + SCP_SQE.aspx + ASPXCodeBehind + + + SCP_SQE.aspx + SCP_ARRIVE_REPORT.aspx ASPXCodeBehind @@ -5311,6 +5370,20 @@ PlanMonth.aspx + + SCP_ARRIVE.aspx + ASPXCodeBehind + + + SCP_ARRIVE.aspx + + + SCP_ARRIVE_DETAIL.aspx + ASPXCodeBehind + + + SCP_ARRIVE_DETAIL.aspx + SCP_FORECAST.aspx ASPXCodeBehind diff --git a/SCP/VersionUpdateInfo.txt b/SCP/VersionUpdateInfo.txt new file mode 100644 index 0000000..e05d660 --- /dev/null +++ b/SCP/VersionUpdateInfo.txt @@ -0,0 +1,15 @@ + +//////////// + +Version: 1.21.0128.1 + Info: TB_INVOICE 添加 SubSite + V_TB_RECEIVE_LIST 添加 SubSite + TB_INVOIC 添加 SubSite和Site + 登陆界面添加版本号 +//////////// +//////////// + +Version: 1.21.0204.1 + Info: TB_PRICE 去掉 State/VendAmt + 添加订单导入并且自动创建要货看板传接口共呢 +//////////// \ No newline at end of file diff --git a/SCP/Views/BasicData/Part.aspx b/SCP/Views/BasicData/Part.aspx index a8a34a1..7cc3006 100644 --- a/SCP/Views/BasicData/Part.aspx +++ b/SCP/Views/BasicData/Part.aspx @@ -10,7 +10,7 @@ - + diff --git a/SCP/Views/BasicData/SCP_INFO_EDIT.aspx.cs b/SCP/Views/BasicData/SCP_INFO_EDIT.aspx.cs index c0e6b35..b97369e 100644 --- a/SCP/Views/BasicData/SCP_INFO_EDIT.aspx.cs +++ b/SCP/Views/BasicData/SCP_INFO_EDIT.aspx.cs @@ -100,7 +100,7 @@ namespace SCP.BasicData protected void Button3_OnClick(object sender, EventArgs e) { Int32 id = GetQueryIntValue("id"); - + string mailVendIds = ""; if (id != -1) { User modelUsers = DB.Users.FirstOrDefault(p => p.Name == txtSupplierCode.SelectedValue); @@ -179,6 +179,7 @@ namespace SCP.BasicData { model.SupplierCode = GetSupplierCodes("All"); model.SupplierName = GetSupplierNames("All"); + mailVendIds = GetSupplierCodes_Mail("All"); } else { @@ -189,8 +190,9 @@ namespace SCP.BasicData return; } - model.SupplierCode = GetSupplierCodes("Some"); + model.SupplierCode = GetSupplierCodes("Some"); model.SupplierName = GetSupplierNames("Some"); + mailVendIds = GetSupplierCodes_Mail("Some"); } // model.FactoryCode=txt 用户登陆名字 model.Content = txtContent.Text; @@ -209,6 +211,7 @@ namespace SCP.BasicData var ret = SCP_INFO_CONTROLLER.SaveInfo(model); if (ret.State == ReturnStatus.Succeed) { + SCP.Common.MailManager.SendMails(mailVendIds, "信息发布:" + model.Content, CurrentUser.FactoryList.FirstOrDefault()); Alert.ShowInParent("保存成功!"); PageContext.RegisterStartupScript(ActiveWindow.GetHideRefreshReference()); @@ -259,6 +262,41 @@ namespace SCP.BasicData } } + private string GetSupplierCodes_Mail(string type) + { + string strResult = ""; + + if ("All".Equals(type)) + { + foreach (FineUI.ListItem vender in txtSupplierCode.Items) + { + if (string.IsNullOrEmpty(strResult)) + { + strResult ="'"+ vender.Value+"'"; + } + else + { + strResult = strResult + "," + "'" + vender.Value + "'"; + } + } + } + else if ("Some".Equals(type)) + { + foreach (FineUI.ListItem item in txtSupplierCode.SelectedItemArray) + { + if (string.IsNullOrEmpty(strResult)) + { + strResult = "'" + item.Value + "'"; + } + else + { + strResult = strResult + "," + "'" + item.Value + "'"; + } + } + } + + return strResult; + } private string GetSupplierCodes(string type) { diff --git a/SCP/Views/BasicData/SCP_LANGUAGE.aspx b/SCP/Views/BasicData/SCP_LANGUAGE.aspx deleted file mode 100644 index 141f7dd..0000000 --- a/SCP/Views/BasicData/SCP_LANGUAGE.aspx +++ /dev/null @@ -1,112 +0,0 @@ -<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="SCP_LANGUAGE.aspx.cs" Inherits="SCP.BasicData.SCP_LANGUAGE" %> - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/SCP/Views/BasicData/SCP_LANGUAGE.aspx.cs b/SCP/Views/BasicData/SCP_LANGUAGE.aspx.cs deleted file mode 100644 index 99890cb..0000000 --- a/SCP/Views/BasicData/SCP_LANGUAGE.aspx.cs +++ /dev/null @@ -1,209 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Web; -using System.Web.UI; -using System.Web.UI.WebControls; -using CK.SCP.Models.ScpEntity; -using CK.SCP.Utils; -using CK.SCP.Controller; -using FineUI; - -namespace SCP.BasicData -{ - public partial class SCP_LANGUAGE : PageBase - { - private List _list=new List(); - public int num; - protected void Page_Load(object sender, EventArgs e) - { - if (!IsPostBack) - { - BindData(); - } - } - - public void BindData() - { - _list = SearchData(); - var list = Sort(_list.AsQueryable(), Grid_TA_LANGUAGE); - Grid_TA_LANGUAGE.DataSource = list; - Grid_TA_LANGUAGE.RecordCount = list.Count(); - Grid_TA_LANGUAGE.DataBind(); - } - - //导出 - public void BtnOutPut_OnClick(object sender, EventArgs e) - { - //var _ret = Controller.SCP_TA_LANGUAGE_CONTROLLER.Get_TA_LANGUAGE_List(new TA_LANGUAGE()); - //if (_ret.State == ReturnStatus.Succeed) - //{ - // _list = _ret.Result; - // var list = Sort(_list.AsQueryable(), Grid_TA_LANGUAGE).ToList(); - - // Dictionary cellheader = new Dictionary(){ - // { "AddressNo", "地点编号" }, - // { "Region", "所属区域" }, - // { "AccountingUnit", "会计单位" }, - // { "AddressDescription", "地点描述" } - //}; - // string url = EntityListToExcel2003(cellheader, list, "地址"); - //} - } - - //查询 - protected void btnSearch_OnClick(object sender, EventArgs e) - { - BindData(); - } - public List SearchData() - { - TA_LANGUAGE _entity = new TA_LANGUAGE(); - _entity.GUID = TXT_GUID.Text; - _entity.CH = TXT_CH.Text; - - var _ret =SCP_TA_LANGUAGE_CONTROLLER.Get_TA_LANGUAGE_List(_entity); - if (_ret.State == ReturnStatus.Succeed) - { - _list = _ret.Result; - - } - else - { - _list = new List(); - } - - return _list; - - } - //显示 - protected void btnShow_OnClick(object sender, EventArgs e) - { - //gp1.Hidden = false; - } - //关闭 - protected void btnClose_OnClick(object sender, EventArgs e) - { - //gp1.Hidden = true; - } - - protected void Grid1_OnPageIndexChange(object sender, GridPageEventArgs e) - { - Grid_TA_LANGUAGE.PageIndex = e.NewPageIndex; - } - - protected void Grid1_OnSort(object sender, GridSortEventArgs e) - { - - _list = SearchData(); - var list = Sort(_list.AsQueryable(), Grid_TA_LANGUAGE); - Grid_TA_LANGUAGE.DataSource = list; - Grid_TA_LANGUAGE.RecordCount = list.Count(); - Grid_TA_LANGUAGE.DataBind(); - } - - protected void Btn_Add_Click(object sender, EventArgs e) - { - - TXT_GUID.Text=Guid.NewGuid().ToString("N").ToUpper(); - TXT_CH.Text=string.Empty; - TXT_EN.Text=string.Empty; - TXT_RU.Text=string.Empty; - TXT_DE.Text=string.Empty; - TXT_FR.Text=string.Empty; - TXT_AR.Text=string.Empty; - TXT_JP.Text = string.Empty; - CB_IsDeleted.Checked = false; - - } - - protected void Grid_TA_LANGUAGE_RowSelect(object sender, GridRowSelectEventArgs e) - { - object[] rowDataKeys = Grid_TA_LANGUAGE.DataKeys[e.RowIndex]; - TA_LANGUAGE _entity = new TA_LANGUAGE(); - _entity.UID = ConvertHelper.To(rowDataKeys[0]); - _entity.GUID = rowDataKeys[1] as string; - _entity.CH = rowDataKeys[2] as string; - _entity.EN = rowDataKeys[3] as string; - _entity.RU = rowDataKeys[4] as string; - _entity.DE = rowDataKeys[5] as string; - _entity.FR = rowDataKeys[6] as string; - _entity.EL = rowDataKeys[7] as string; - _entity.AR = rowDataKeys[8] as string; - _entity.JP = rowDataKeys[9] as string; - _entity.IsDeleted = ConvertHelper.To(rowDataKeys[10]); - TXT_GUID.Text = _entity.GUID; - TXT_CH.Text = _entity.CH; - TXT_EN.Text = _entity.EN; - TXT_RU.Text = _entity.RU; - TXT_DE.Text = _entity.DE; - TXT_FR.Text = _entity.FR; - TXT_AR.Text = _entity.AR; - TXT_JP.Text = _entity.JP; - CB_IsDeleted.Checked = _entity.IsDeleted; - } - - - - protected void Btn_Save_Click(object sender, EventArgs e) - { - TA_LANGUAGE _entity = new TA_LANGUAGE(); - _entity.GUID = TXT_GUID.Text; - _entity.CH = TXT_CH.Text; - _entity.EN = TXT_EN.Text; - _entity.RU = TXT_RU.Text; - _entity.DE = TXT_DE.Text; - _entity.FR = TXT_FR.Text; - _entity.AR = TXT_AR.Text; - _entity.JP = TXT_JP.Text; - _entity.IsDeleted = CB_IsDeleted.Checked; - var ret=SCP_TA_LANGUAGE_CONTROLLER.Get_TA_LANGUAGE_List(new TA_LANGUAGE { CH = TXT_CH.Text }); - if (ret.State == ReturnStatus.Succeed) - { - - if (ret.Result.Count > 0) - { - Alert.ShowInTop("中文名称重复!"); - return; - } - else - { - var ret1 = SCP_TA_LANGUAGE_CONTROLLER.Save_TA_LANGUAGE(new List() { _entity }); - if (ret1.State == ReturnStatus.Succeed) - { - var _ret = SCP_TA_LANGUAGE_CONTROLLER.Get_TA_LANGUAGE_List(new TA_LANGUAGE()); - if (_ret.State == ReturnStatus.Succeed) - { - _list = _ret.Result; - var list = Sort(_list.AsQueryable(), Grid_TA_LANGUAGE); - Grid_TA_LANGUAGE.DataSource = list; - Grid_TA_LANGUAGE.RecordCount = list.Count(); - Grid_TA_LANGUAGE.DataBind(); - - } - } - - } - - } - - - } - - protected void Btn_Delete_Click(object sender, EventArgs e) - { - var ret = SCP_TA_LANGUAGE_CONTROLLER.Del_TA_LANGUAGE(new TA_LANGUAGE { GUID = TXT_GUID.Text }); - if (ret.State == ReturnStatus.Succeed) - { - BindData(); - } - - - } - - protected void BtnSearch_Click(object sender, EventArgs e) - { - BindData(); - } - } -} \ No newline at end of file diff --git a/SCP/Views/BasicData/SCP_LANGUAGE_1.aspx b/SCP/Views/BasicData/SCP_LANGUAGE_1.aspx new file mode 100644 index 0000000..facf185 --- /dev/null +++ b/SCP/Views/BasicData/SCP_LANGUAGE_1.aspx @@ -0,0 +1,78 @@ +<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="SCP_LANGUAGE_1.aspx.cs" Inherits="SCP.Views.BasicData.SCP_LANGUAGE_1" %> + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +