|
@ -169,21 +169,21 @@ namespace CK.SCP.Controller |
|
|
{ |
|
|
{ |
|
|
using (ScpEntities db = EntitiesFactory.CreateScpInstance()) |
|
|
using (ScpEntities db = EntitiesFactory.CreateScpInstance()) |
|
|
{ |
|
|
{ |
|
|
return db.TA_ASK_SUBPART.Where(p=>p.AskBillNum==ASK&&string.IsNullOrEmpty(p.VendBatch)).ToList(); |
|
|
return db.TA_ASK_SUBPART.Where(p => p.AskBillNum == ASK && string.IsNullOrEmpty(p.VendBatch)).ToList(); |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
public static ResultObject<bool> Update_User_ErrorCount(string p_userName,int count ) |
|
|
public static ResultObject<bool> Update_User_ErrorCount(string p_userName, int count) |
|
|
{ |
|
|
{ |
|
|
ResultObject<bool> _ret = new ResultObject<bool>(); |
|
|
ResultObject<bool> _ret = new ResultObject<bool>(); |
|
|
try |
|
|
try |
|
|
{ |
|
|
{ |
|
|
using (AppBoxContext _appdb = EntitiesFactory.CreateAppBoxInstance()) |
|
|
using (AppBoxContext _appdb = EntitiesFactory.CreateAppBoxInstance()) |
|
|
{ |
|
|
{ |
|
|
var user = _appdb.Users.FirstOrDefault(p => p.Name == p_userName); |
|
|
var user = _appdb.Users.FirstOrDefault(p => p.Name == p_userName); |
|
|
if (user != null) |
|
|
if (user != null) |
|
|
{ |
|
|
{ |
|
|
user.ErrorCount = user.ErrorCount + 1; |
|
|
user.ErrorCount = user.ErrorCount + 1; |
|
|
if(user.ErrorCount== count) |
|
|
if (user.ErrorCount == count) |
|
|
{ |
|
|
{ |
|
|
user.Enabled = false; |
|
|
user.Enabled = false; |
|
|
_ret.Message = $"密码错误超过【{count}】次,账号已锁定请联系管理员"; |
|
|
_ret.Message = $"密码错误超过【{count}】次,账号已锁定请联系管理员"; |
|
@ -191,7 +191,7 @@ namespace CK.SCP.Controller |
|
|
else |
|
|
else |
|
|
{ |
|
|
{ |
|
|
_ret.Message = $"密码错误,再输入错【{count - user.ErrorCount}】次后账户将锁定!"; |
|
|
_ret.Message = $"密码错误,再输入错【{count - user.ErrorCount}】次后账户将锁定!"; |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
int state = _appdb.SaveChanges(); |
|
|
int state = _appdb.SaveChanges(); |
|
|
if (state != -1) |
|
|
if (state != -1) |
|
@ -367,7 +367,7 @@ namespace CK.SCP.Controller |
|
|
try |
|
|
try |
|
|
{ |
|
|
{ |
|
|
using (ScpEntities db = EntitiesFactory.CreateScpInstance()) |
|
|
using (ScpEntities db = EntitiesFactory.CreateScpInstance()) |
|
|
{ |
|
|
{ |
|
|
var askdetail = db.TB_ASK_DETAIL.Where(p => p.AskBillNum == ask).ToList(); |
|
|
var askdetail = db.TB_ASK_DETAIL.Where(p => p.AskBillNum == ask).ToList(); |
|
|
var subcount = db.TA_ASK_SUBPART.Count(p => p.AskBillNum == ask); |
|
|
var subcount = db.TA_ASK_SUBPART.Count(p => p.AskBillNum == ask); |
|
|
if (subcount == 0) |
|
|
if (subcount == 0) |
|
@ -377,19 +377,19 @@ namespace CK.SCP.Controller |
|
|
var sub = db.TA_SubPartCode.Where(p => p.PartCode == ak.PartCode).ToList(); |
|
|
var sub = db.TA_SubPartCode.Where(p => p.PartCode == ak.PartCode).ToList(); |
|
|
if (sub.Count() > 0) |
|
|
if (sub.Count() > 0) |
|
|
{ |
|
|
{ |
|
|
foreach(var su in sub) |
|
|
foreach (var su in sub) |
|
|
{ |
|
|
{ |
|
|
TA_ASK_SUBPART subpart = new TA_ASK_SUBPART(); |
|
|
TA_ASK_SUBPART subpart = new TA_ASK_SUBPART(); |
|
|
subpart.PartCode = su.PartCode; |
|
|
subpart.PartCode = su.PartCode; |
|
|
subpart.SubPartCode = su.SubPartCode; |
|
|
subpart.SubPartCode = su.SubPartCode; |
|
|
subpart.BOMedtiton = su.BOMedtiton; |
|
|
subpart.BOMedtiton = su.BOMedtiton; |
|
|
subpart.AskBillNum = ask; |
|
|
subpart.AskBillNum = ask; |
|
|
subpart.Qty = su.Qty; |
|
|
subpart.Qty = su.Qty; |
|
|
db.TA_ASK_SUBPART.AddOrUpdate(subpart); |
|
|
db.TA_ASK_SUBPART.AddOrUpdate(subpart); |
|
|
db.TA_SubPartCode.Remove(su); |
|
|
db.TA_SubPartCode.Remove(su); |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
@ -521,7 +521,7 @@ namespace CK.SCP.Controller |
|
|
_entity.TA_FACTORY.Add(f); |
|
|
_entity.TA_FACTORY.Add(f); |
|
|
_appdb.Users.Add(_entity); |
|
|
_appdb.Users.Add(_entity); |
|
|
_appdb.SaveChanges(); |
|
|
_appdb.SaveChanges(); |
|
|
|
|
|
|
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
@ -918,7 +918,7 @@ namespace CK.SCP.Controller |
|
|
throw e; |
|
|
throw e; |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
public static List<V_TB_INCOMPLETE_ASK> RejectQty_SUM(List<V_TB_INCOMPLETE_ASK> p_list) |
|
|
public static List<V_TB_INCOMPLETE_ASK> RejectQty_SUM(List<V_TB_INCOMPLETE_ASK> p_list) |
|
|
{ |
|
|
{ |
|
|
using (ScpEntities db = EntitiesFactory.CreateScpInstance()) |
|
|
using (ScpEntities db = EntitiesFactory.CreateScpInstance()) |
|
@ -1236,7 +1236,7 @@ namespace CK.SCP.Controller |
|
|
throw e; |
|
|
throw e; |
|
|
} |
|
|
} |
|
|
return _ret; |
|
|
return _ret; |
|
|
} |
|
|
} |
|
|
public static ResultObject<bool> Save_TB_ASK_DETAIL(List<TB_ASK_DETAIL> p_entitys, AskState p_state) |
|
|
public static ResultObject<bool> Save_TB_ASK_DETAIL(List<TB_ASK_DETAIL> p_entitys, AskState p_state) |
|
|
{ |
|
|
{ |
|
|
ResultObject<bool> _ret = new ResultObject<bool>(); |
|
|
ResultObject<bool> _ret = new ResultObject<bool>(); |
|
@ -1358,10 +1358,10 @@ namespace CK.SCP.Controller |
|
|
{ |
|
|
{ |
|
|
using (ScpEntities db = EntitiesFactory.CreateScpInstance()) |
|
|
using (ScpEntities db = EntitiesFactory.CreateScpInstance()) |
|
|
{ |
|
|
{ |
|
|
|
|
|
|
|
|
var ret= db.TB_ASK.Where(p => p.AskBillNum == p_entitys.AskBillNum).FirstOrDefault(); |
|
|
var ret = db.TB_ASK.Where(p => p.AskBillNum == p_entitys.AskBillNum).FirstOrDefault(); |
|
|
ret.Extend1 = p_entitys.Extend1; |
|
|
ret.Extend1 = p_entitys.Extend1; |
|
|
|
|
|
|
|
|
db.TB_ASK.AddOrUpdate(ret); |
|
|
db.TB_ASK.AddOrUpdate(ret); |
|
|
if (db.SaveChanges() != -1) |
|
|
if (db.SaveChanges() != -1) |
|
|
{ |
|
|
{ |
|
@ -1374,7 +1374,7 @@ namespace CK.SCP.Controller |
|
|
_ret.Result = false; |
|
|
_ret.Result = false; |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
catch (System.Data.Entity.Validation.DbEntityValidationException dbEx)//捕获实体验证异常
|
|
|
catch (System.Data.Entity.Validation.DbEntityValidationException dbEx)//捕获实体验证异常
|
|
|
{ |
|
|
{ |
|
|
var sb = new StringBuilder(); |
|
|
var sb = new StringBuilder(); |
|
@ -1425,13 +1425,13 @@ namespace CK.SCP.Controller |
|
|
} |
|
|
} |
|
|
return _ret; |
|
|
return _ret; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
/// <summary>
|
|
|
///
|
|
|
///
|
|
|
/// </summary>
|
|
|
/// </summary>
|
|
|
/// <param name="p_entitys"></param>
|
|
|
/// <param name="p_entitys"></param>
|
|
|
/// <returns></returns>
|
|
|
/// <returns></returns>
|
|
|
public static ResultObject<bool> Save_TB_PO(List<TB_PO> p_entitys) |
|
|
public static ResultObject<bool> Save_TB_PO(List<TB_PO> p_entitys) |
|
|
{ |
|
|
{ |
|
|
ResultObject<bool> _ret = new ResultObject<bool>(); |
|
|
ResultObject<bool> _ret = new ResultObject<bool>(); |
|
|
try |
|
|
try |
|
@ -1685,14 +1685,14 @@ namespace CK.SCP.Controller |
|
|
{ |
|
|
{ |
|
|
_tDetail.VendBatch = itm.VendBatch; |
|
|
_tDetail.VendBatch = itm.VendBatch; |
|
|
} |
|
|
} |
|
|
var subpart = db.TA_ASK_SUBPART.Where(p=>p.PartCode== itm.PartCode&&p.AskBillNum==itm.AskBillNum).ToList(); |
|
|
var subpart = db.TA_ASK_SUBPART.Where(p => p.PartCode == itm.PartCode && p.AskBillNum == itm.AskBillNum).ToList(); |
|
|
string str1 = ""; |
|
|
string str1 = ""; |
|
|
string str2 = ""; |
|
|
string str2 = ""; |
|
|
foreach(var sub in subpart) |
|
|
foreach (var sub in subpart) |
|
|
{ |
|
|
{ |
|
|
string str = sub.SubPartCode + "," + sub.BOMedtiton + "," + sub.VendBatch + "#"; |
|
|
string str = sub.SubPartCode + "," + sub.BOMedtiton + "," + sub.VendBatch + "#"; |
|
|
str2 = str2 + sub.VendBatch; |
|
|
str2 = str2 + sub.VendBatch; |
|
|
str1 = str1 + str; |
|
|
str1 = str1 + str; |
|
|
} |
|
|
} |
|
|
_tDetail.VendBatch = str1; |
|
|
_tDetail.VendBatch = str1; |
|
|
_tDetail.UpdateUser = str2; |
|
|
_tDetail.UpdateUser = str2; |
|
@ -1736,17 +1736,17 @@ namespace CK.SCP.Controller |
|
|
uni.Batch = _tDetail.Batch; |
|
|
uni.Batch = _tDetail.Batch; |
|
|
uni.Qty = _tDetail.Qty; |
|
|
uni.Qty = _tDetail.Qty; |
|
|
uni.State = 2; |
|
|
uni.State = 2; |
|
|
uni.CreateOper=_t.CreateUser; |
|
|
uni.CreateOper = _t.CreateUser; |
|
|
uni.CreateTime = DateTime.Now; |
|
|
uni.CreateTime = DateTime.Now; |
|
|
uni.PutTime= DateTime.Now; |
|
|
uni.PutTime = DateTime.Now; |
|
|
uni.VendId = _t.VendId; |
|
|
uni.VendId = _t.VendId; |
|
|
uni.PoUnit = _tDetail.PoUnit; |
|
|
uni.PoUnit = _tDetail.PoUnit; |
|
|
uni.LocUnit = _tDetail.PoUnit; |
|
|
uni.LocUnit = _tDetail.PoUnit; |
|
|
uni.ValidDate= DateTime.Now; |
|
|
uni.ValidDate = DateTime.Now; |
|
|
uni.ErpBillNum = _tDetail.PoBillNum; |
|
|
uni.ErpBillNum = _tDetail.PoBillNum; |
|
|
uni.ErpLineNum = _tDetail.PoLine; |
|
|
uni.ErpLineNum = _tDetail.PoLine; |
|
|
uni.VendBatch = sub.VendBatch; |
|
|
uni.VendBatch = sub.VendBatch; |
|
|
uni.PackQty= _tDetail.Qty; |
|
|
uni.PackQty = _tDetail.Qty; |
|
|
uni.Price = _tDetail.Price; |
|
|
uni.Price = _tDetail.Price; |
|
|
uni.UmConv = 1; |
|
|
uni.UmConv = 1; |
|
|
uni.Buyer = _t.ShipUser; |
|
|
uni.Buyer = _t.ShipUser; |
|
@ -1852,7 +1852,7 @@ namespace CK.SCP.Controller |
|
|
{ |
|
|
{ |
|
|
using (ScpEntities db = EntitiesFactory.CreateScpInstance()) |
|
|
using (ScpEntities db = EntitiesFactory.CreateScpInstance()) |
|
|
{ |
|
|
{ |
|
|
var po = db.TB_PO.FirstOrDefault(p=>p.PoBillNum==p_ask.PoBillNum); |
|
|
var po = db.TB_PO.FirstOrDefault(p => p.PoBillNum == p_ask.PoBillNum); |
|
|
TB_ASN _t = new TB_ASN(); |
|
|
TB_ASN _t = new TB_ASN(); |
|
|
_t.AsnBillNum = SCP_BILLCODE_CONTROLLER.MakeASNCode(); |
|
|
_t.AsnBillNum = SCP_BILLCODE_CONTROLLER.MakeASNCode(); |
|
|
_t.AskBillNum = p_ask.AskBillNum; |
|
|
_t.AskBillNum = p_ask.AskBillNum; |
|
@ -1883,7 +1883,7 @@ namespace CK.SCP.Controller |
|
|
var partgroup = db.TA_PART.Where(p => p.PartCode == itm.PartCode).FirstOrDefault(); |
|
|
var partgroup = db.TA_PART.Where(p => p.PartCode == itm.PartCode).FirstOrDefault(); |
|
|
_t.Extend3 = partgroup.PartGroup; |
|
|
_t.Extend3 = partgroup.PartGroup; |
|
|
} |
|
|
} |
|
|
db.TB_ASN.AddOrUpdate(p => p.AsnBillNum, _t); |
|
|
db.TB_ASN.AddOrUpdate(p => p.AsnBillNum, _t); |
|
|
List<TB_ASN_DETAIL> _list = new List<TB_ASN_DETAIL>(); |
|
|
List<TB_ASN_DETAIL> _list = new List<TB_ASN_DETAIL>(); |
|
|
foreach (var itm in p_order_list) |
|
|
foreach (var itm in p_order_list) |
|
|
{ |
|
|
{ |
|
@ -1893,21 +1893,21 @@ namespace CK.SCP.Controller |
|
|
_tDetail.PoLine = itm.PoLine; |
|
|
_tDetail.PoLine = itm.PoLine; |
|
|
_tDetail.PoUnit = itm.PoUnit; |
|
|
_tDetail.PoUnit = itm.PoUnit; |
|
|
_tDetail.Batch = itm.Batch; |
|
|
_tDetail.Batch = itm.Batch; |
|
|
if (itm.VendBatch=="55") |
|
|
if (itm.VendBatch == "55") |
|
|
{ |
|
|
{ |
|
|
_tDetail.VendBatch = ""; |
|
|
_tDetail.VendBatch = ""; |
|
|
} |
|
|
} |
|
|
else |
|
|
else |
|
|
{ |
|
|
{ |
|
|
_tDetail.VendBatch = itm.VendBatch; |
|
|
_tDetail.VendBatch = itm.VendBatch; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
if (_t.PoBillNum.Substring(0, 5) == "CYD03"&&_t.Site=="W21") |
|
|
if (_t.PoBillNum.Substring(0, 5) == "CYD03" && _t.Site == "W21") |
|
|
{ |
|
|
{ |
|
|
var podetail = db.TB_PO_DETAIL.FirstOrDefault(t=>t.PoBillNum==_t.PoBillNum&&t.PartCode==itm.PartCode&&t.PoLine==itm.PoLine); |
|
|
var podetail = db.TB_PO_DETAIL.FirstOrDefault(t => t.PoBillNum == _t.PoBillNum && t.PartCode == itm.PartCode && t.PoLine == itm.PoLine); |
|
|
_tDetail.VendBatch = podetail.SubSite + "," + podetail.Extend3 + "," + itm.VendBatch + "#"; |
|
|
_tDetail.VendBatch = podetail.SubSite + "," + podetail.Extend3 + "," + itm.VendBatch + "#"; |
|
|
} |
|
|
} |
|
|
_tDetail.UpdateUser= itm.VendBatch; |
|
|
_tDetail.UpdateUser = itm.VendBatch; |
|
|
_tDetail.PackQty = itm.PackQty == 0 ? 1 : itm.PackQty; |
|
|
_tDetail.PackQty = itm.PackQty == 0 ? 1 : itm.PackQty; |
|
|
_tDetail.PartCode = itm.PartCode; |
|
|
_tDetail.PartCode = itm.PartCode; |
|
|
_tDetail.State = (int)AsnState.New; |
|
|
_tDetail.State = (int)AsnState.New; |
|
@ -1925,21 +1925,21 @@ namespace CK.SCP.Controller |
|
|
_tDetail.UpdateInfo = itm.UpdateInfo; |
|
|
_tDetail.UpdateInfo = itm.UpdateInfo; |
|
|
_tDetail.ReceivedPort = itm.ReceivedPort; |
|
|
_tDetail.ReceivedPort = itm.ReceivedPort; |
|
|
_tDetail.GUID = Guid.NewGuid(); |
|
|
_tDetail.GUID = Guid.NewGuid(); |
|
|
_tDetail.SubSite = itm.SubSite; |
|
|
_tDetail.SubSite = itm.SubSite; |
|
|
_tDetail.Site = itm.Site; |
|
|
_tDetail.Site = itm.Site; |
|
|
_tDetail.Extend2 = itm.ReceivedQty.ToString(); |
|
|
_tDetail.Extend2 = itm.ReceivedQty.ToString(); |
|
|
_tDetail.Remark= itm.ReceivedQty.ToString(); |
|
|
_tDetail.Remark = itm.ReceivedQty.ToString(); |
|
|
_tDetail.UpdateInfo = itm.UpdateInfo; |
|
|
_tDetail.UpdateInfo = itm.UpdateInfo; |
|
|
var partgroup = db.TA_PART.Where(p => p.PartCode == itm.PartCode).FirstOrDefault(); |
|
|
var partgroup = db.TA_PART.Where(p => p.PartCode == itm.PartCode).FirstOrDefault(); |
|
|
var askdetail=db.TB_ASK_DETAIL.Where(p => p.PartCode == itm.PartCode&&p.AskBillNum==itm.AskBillNum).FirstOrDefault(); |
|
|
var askdetail = db.TB_ASK_DETAIL.Where(p => p.PartCode == itm.PartCode && p.AskBillNum == itm.AskBillNum).FirstOrDefault(); |
|
|
_tDetail.Extend3 = partgroup.PartGroup; |
|
|
_tDetail.Extend3 = partgroup.PartGroup; |
|
|
_tDetail.Extend1 =po.VendId; |
|
|
_tDetail.Extend1 = po.VendId; |
|
|
if (itm.Site == "U32") |
|
|
if (itm.Site == "U32") |
|
|
{ |
|
|
{ |
|
|
var _applin = db.TA_Appliance.FirstOrDefault(p=>p.PartNumber==itm.SubSite&&p.VendID==p_ask.VendId); |
|
|
var _applin = db.TA_Appliance.FirstOrDefault(p => p.PartNumber == itm.SubSite && p.VendID == p_ask.VendId); |
|
|
if (_applin != null) |
|
|
if (_applin != null) |
|
|
{ |
|
|
{ |
|
|
var _boxtype = db.TA_BOXTYPE.FirstOrDefault(p=>p.BoxType==_applin.BoxType&&p.Enabled==true); |
|
|
var _boxtype = db.TA_BOXTYPE.FirstOrDefault(p => p.BoxType == _applin.BoxType && p.Enabled == true); |
|
|
if (_boxtype != null) |
|
|
if (_boxtype != null) |
|
|
{ |
|
|
{ |
|
|
TB_ASN_PARTBOX PARTBOX = new TB_ASN_PARTBOX(); |
|
|
TB_ASN_PARTBOX PARTBOX = new TB_ASN_PARTBOX(); |
|
@ -1947,14 +1947,14 @@ namespace CK.SCP.Controller |
|
|
PARTBOX.PartCode = itm.PartCode; |
|
|
PARTBOX.PartCode = itm.PartCode; |
|
|
PARTBOX.BoxType = _boxtype.BoxType; |
|
|
PARTBOX.BoxType = _boxtype.BoxType; |
|
|
PARTBOX.Box = Convert.ToInt32(_tDetail.Qty) / Convert.ToInt32(_tDetail.PackQty); |
|
|
PARTBOX.Box = Convert.ToInt32(_tDetail.Qty) / Convert.ToInt32(_tDetail.PackQty); |
|
|
if(Convert.ToInt32(_tDetail.Qty) % Convert.ToInt32(_tDetail.PackQty) > 0) |
|
|
if (Convert.ToInt32(_tDetail.Qty) % Convert.ToInt32(_tDetail.PackQty) > 0) |
|
|
{ |
|
|
{ |
|
|
PARTBOX.Box = PARTBOX.Box + 1; |
|
|
PARTBOX.Box = PARTBOX.Box + 1; |
|
|
} |
|
|
} |
|
|
PARTBOX.SumBox = PARTBOX.Box; |
|
|
PARTBOX.SumBox = PARTBOX.Box; |
|
|
PARTBOX.PoBillNum = _t.PoBillNum; |
|
|
PARTBOX.PoBillNum = _t.PoBillNum; |
|
|
PARTBOX.VendId = _t.VendId; |
|
|
PARTBOX.VendId = _t.VendId; |
|
|
PARTBOX.ShipTime =DateTime.Parse(_t.ShipTime.ToString()).ToShortDateString(); |
|
|
PARTBOX.ShipTime = DateTime.Parse(_t.ShipTime.ToString()).ToShortDateString(); |
|
|
PARTBOX.Batch = _tDetail.Batch; |
|
|
PARTBOX.Batch = _tDetail.Batch; |
|
|
PARTBOX.PoLine = _tDetail.PoLine; |
|
|
PARTBOX.PoLine = _tDetail.PoLine; |
|
|
PARTBOX.PackQty = _tDetail.PackQty; |
|
|
PARTBOX.PackQty = _tDetail.PackQty; |
|
@ -1966,15 +1966,15 @@ namespace CK.SCP.Controller |
|
|
var ModelList = db.TA_CarModel.ToList(); |
|
|
var ModelList = db.TA_CarModel.ToList(); |
|
|
foreach (var model in ModelList) |
|
|
foreach (var model in ModelList) |
|
|
{ |
|
|
{ |
|
|
if(model.Model.Length<=askdetail.Extend2.Length) |
|
|
if (model.Model.Length <= askdetail.Extend2.Length) |
|
|
{ |
|
|
{ |
|
|
|
|
|
|
|
|
if (askdetail.Extend2.Contains(model.Model)) |
|
|
if (askdetail.Extend2.Contains(model.Model)) |
|
|
{ |
|
|
{ |
|
|
_tDetail.Extend1 = "FT"; |
|
|
_tDetail.Extend1 = "FT"; |
|
|
break; |
|
|
break; |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
_tDetail.Extend1 = "PT"; |
|
|
_tDetail.Extend1 = "PT"; |
|
|
} |
|
|
} |
|
@ -1991,16 +1991,16 @@ namespace CK.SCP.Controller |
|
|
{ |
|
|
{ |
|
|
_tDetail.Extend1 = "PT"; |
|
|
_tDetail.Extend1 = "PT"; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
} |
|
|
db.TB_ASN_DETAIL.Add(_tDetail); |
|
|
db.TB_ASN_DETAIL.Add(_tDetail); |
|
|
var _order_detail = db.TB_ASK_DETAIL.Where(p => p.UID == itm.UID).FirstOrDefault(); |
|
|
var _order_detail = db.TB_ASK_DETAIL.Where(p => p.UID == itm.UID).FirstOrDefault(); |
|
|
_order_detail.ShippedQty = (decimal)itm.ShippedQty; |
|
|
_order_detail.ShippedQty = (decimal)itm.ShippedQty; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
db.TB_ASK_DETAIL.AddOrUpdate(p => p.UID, _order_detail); |
|
|
db.TB_ASK_DETAIL.AddOrUpdate(p => p.UID, _order_detail); |
|
|
|
|
|
|
|
|
} |
|
|
} |
|
|
int state = db.SaveChanges(); |
|
|
int state = db.SaveChanges(); |
|
|
if (state != -1) |
|
|
if (state != -1) |
|
@ -2086,7 +2086,7 @@ namespace CK.SCP.Controller |
|
|
{ |
|
|
{ |
|
|
using (ScpEntities db = EntitiesFactory.CreateScpInstance()) |
|
|
using (ScpEntities db = EntitiesFactory.CreateScpInstance()) |
|
|
{ |
|
|
{ |
|
|
var _ls = p_list.Select(p => p.AskBillNum); |
|
|
var _ls = p_list.Select(p => p.AskBillNum); |
|
|
StringBuilder _buffer = new StringBuilder(); |
|
|
StringBuilder _buffer = new StringBuilder(); |
|
|
_buffer.Append(" select distinct (C.AskBillNum)from V_TB_ASK_DETAIL C"); |
|
|
_buffer.Append(" select distinct (C.AskBillNum)from V_TB_ASK_DETAIL C"); |
|
|
_buffer.Append(" left JOIN "); |
|
|
_buffer.Append(" left JOIN "); |
|
@ -2111,21 +2111,21 @@ namespace CK.SCP.Controller |
|
|
return p_list; |
|
|
return p_list; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
public static List<V_TB_ASK> GET_IS_COMPLETED_SEND1(List<V_TB_ASK> p_list,string lz) |
|
|
public static List<V_TB_ASK> GET_IS_COMPLETED_SEND1(List<V_TB_ASK> p_list, string lz) |
|
|
{ |
|
|
{ |
|
|
using (ScpEntities db = EntitiesFactory.CreateScpInstance()) |
|
|
using (ScpEntities db = EntitiesFactory.CreateScpInstance()) |
|
|
{ |
|
|
{ |
|
|
List<V_TB_ASK> lt = new List<V_TB_ASK>(); |
|
|
List<V_TB_ASK> lt = new List<V_TB_ASK>(); |
|
|
var _ls = p_list.Select(p => p.AskBillNum); |
|
|
var _ls = p_list.Select(p => p.AskBillNum); |
|
|
StringBuilder _buffer = new StringBuilder(); |
|
|
StringBuilder _buffer = new StringBuilder(); |
|
|
_buffer.Append(" select AskBillNum from V_TB_ASK_DETAIL "); |
|
|
_buffer.Append(" select AskBillNum from V_TB_ASK_DETAIL "); |
|
|
_buffer.Append($" WHERE Currency like '%{lz}%'"); |
|
|
_buffer.Append($" WHERE Currency like '%{lz}%'"); |
|
|
var _str = string.Format(_buffer.ToString(), string.Join("','", _ls.ToArray())); |
|
|
var _str = string.Format(_buffer.ToString(), string.Join("','", _ls.ToArray())); |
|
|
var _list = db.Database.SqlQuery<string>(_str).ToList(); |
|
|
var _list = db.Database.SqlQuery<string>(_str).ToList(); |
|
|
var ll= p_list.Where(p => _list.Contains(p.AskBillNum)).ToList(); |
|
|
var ll = p_list.Where(p => _list.Contains(p.AskBillNum)).ToList(); |
|
|
return ll; |
|
|
return ll; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
} |
|
|
} |
|
|
public static List<V_TB_ASK> GET_IS_COMPLETED_SEND2(List<V_TB_ASK> p_list, string lz) |
|
|
public static List<V_TB_ASK> GET_IS_COMPLETED_SEND2(List<V_TB_ASK> p_list, string lz) |
|
|
{ |
|
|
{ |
|
@ -2211,8 +2211,8 @@ namespace CK.SCP.Controller |
|
|
|
|
|
|
|
|
p_list.ForEach(itm => |
|
|
p_list.ForEach(itm => |
|
|
{ |
|
|
{ |
|
|
var maxtime = db.TB_ASN_DETAIL.Where(p=>p.PartCode==itm.PartCode&&p.State>-1).Select(t=>t.ProduceDate).Max(); |
|
|
var maxtime = db.TB_ASN_DETAIL.Where(p => p.PartCode == itm.PartCode && p.State > -1).Select(t => t.ProduceDate).Max(); |
|
|
|
|
|
|
|
|
itm.MaxTime = maxtime.ToString(); |
|
|
itm.MaxTime = maxtime.ToString(); |
|
|
groupList.ForEach(p => |
|
|
groupList.ForEach(p => |
|
|
{ |
|
|
{ |
|
@ -2400,7 +2400,7 @@ namespace CK.SCP.Controller |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public static void Get_V_TB_ASK_DETAIL_Sum(V_TB_ASK_DETAIL p_entity, Action<ResultObject<IQueryable<V_TB_ASK_DETAIL>>> p_action) |
|
|
public static void Get_V_TB_ASK_DETAIL_Sum(V_TB_ASK_DETAIL p_entity, Action<ResultObject<IQueryable<V_TB_ASK_DETAIL>>> p_action) |
|
|
{ |
|
|
{ |
|
|
|
|
|
|
|
@ -2650,327 +2650,317 @@ namespace CK.SCP.Controller |
|
|
{ |
|
|
{ |
|
|
using (ScpEntities db = EntitiesFactory.CreateScpInstance()) |
|
|
using (ScpEntities db = EntitiesFactory.CreateScpInstance()) |
|
|
{ |
|
|
{ |
|
|
|
|
|
switch (p_state) |
|
|
if (p_state == AskState.Close) |
|
|
|
|
|
{ |
|
|
{ |
|
|
var _ls = db.TB_ASK.Where(p => p_list.Contains(p.AskBillNum)).ToList(); |
|
|
case AskState.Close: |
|
|
if (_ls.Count > 0) |
|
|
var _ls = db.TB_ASK.Where(p => p_list.Contains(p.AskBillNum)).ToList(); |
|
|
{ |
|
|
if (_ls.Count > 0) |
|
|
_ls.ForEach(p => |
|
|
|
|
|
{ |
|
|
{ |
|
|
var _asnlist = db.TB_ASN.Where(x => x.AskBillNum == p.AskBillNum && x.State == (int)AsnState.New).ToList(); |
|
|
_ls.ForEach(p => |
|
|
if (_asnlist.Count > 0) |
|
|
|
|
|
{ |
|
|
{ |
|
|
_ret.State = ReturnStatus.Failed; |
|
|
var _asnlist = db.TB_ASN.Where(x => x.AskBillNum == p.AskBillNum && x.State == (int)AsnState.New).ToList(); |
|
|
_ret.Result = false; |
|
|
if (_asnlist.Count > 0) |
|
|
_ret.MessageList.Add(p.AskBillNum + "存在未发货的发货单!"); |
|
|
{ |
|
|
|
|
|
_ret.State = ReturnStatus.Failed; |
|
|
|
|
|
_ret.Result = false; |
|
|
|
|
|
_ret.MessageList.Add(p.AskBillNum + "存在未发货的发货单!"); |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
else |
|
|
|
|
|
{ |
|
|
|
|
|
p.State = (int)AskState.Close; |
|
|
|
|
|
var _list = db.TB_ASK_DETAIL.Where(itm => itm.AskBillNum == p.AskBillNum).ToList(); |
|
|
|
|
|
_list.ForEach(itm => itm.State = (int)AskState.Close); |
|
|
|
|
|
db.TB_ASK_DETAIL.AddOrUpdate(itm => itm.UID, _list.ToArray()); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
} |
|
|
} |
|
|
else |
|
|
); |
|
|
{ |
|
|
if (_ret.MessageList.Count == 0) |
|
|
p.State = (int)AskState.Close; |
|
|
{ |
|
|
var _list = db.TB_ASK_DETAIL.Where(itm => itm.AskBillNum == p.AskBillNum).ToList(); |
|
|
db.TB_ASK.AddOrUpdate(p => p.AskBillNum, _ls.ToArray()); |
|
|
_list.ForEach(itm => itm.State = (int)AskState.Close); |
|
|
|
|
|
db.TB_ASK_DETAIL.AddOrUpdate(itm => itm.UID, _list.ToArray()); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
); |
|
|
else |
|
|
if (_ret.MessageList.Count == 0) |
|
|
|
|
|
{ |
|
|
{ |
|
|
db.TB_ASK.AddOrUpdate(p => p.AskBillNum, _ls.ToArray()); |
|
|
_ret.State = ReturnStatus.Failed; |
|
|
|
|
|
_ret.Result = false; |
|
|
|
|
|
_ret.Message = "选择的记录,不能关闭!"; |
|
|
} |
|
|
} |
|
|
} |
|
|
break; |
|
|
else |
|
|
case AskState.Complete: |
|
|
{ |
|
|
var _ls1 = db.TB_ASK.Where(p => p_list.Contains(p.AskBillNum)).ToList(); |
|
|
_ret.State = ReturnStatus.Failed; |
|
|
int count1 = _ls1.Count(p => p.State == (int)AskState.Ship); |
|
|
_ret.Result = false; |
|
|
if (count1 == _ls1.Count && _ls1.Count > 0) |
|
|
_ret.Message = "选择的记录,不能关闭!"; |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
if (p_state == AskState.Complete) |
|
|
|
|
|
{ |
|
|
|
|
|
var _ls = db.TB_ASK.Where(p => p_list.Contains(p.AskBillNum)).ToList(); |
|
|
|
|
|
int count = _ls.Count(p => p.State == (int)AskState.Ship); |
|
|
|
|
|
if (count == _ls.Count && _ls.Count > 0) |
|
|
|
|
|
{ |
|
|
|
|
|
_ls.ForEach(p => |
|
|
|
|
|
{ |
|
|
{ |
|
|
var _asnlist = db.TB_ASN.Where(x => x.AskBillNum == p.AskBillNum && x.State == (int)AsnState.New).ToList(); |
|
|
_ls1.ForEach(p => |
|
|
if (_asnlist.Count > 0) |
|
|
|
|
|
{ |
|
|
{ |
|
|
_ret.MessageList.Add(p.AskBillNum + "存在未发货的发货单!"); |
|
|
var _asnlist = db.TB_ASN.Where(x => x.AskBillNum == p.AskBillNum && x.State == (int)AsnState.New).ToList(); |
|
|
} |
|
|
if (_asnlist.Count > 0) |
|
|
else |
|
|
{ |
|
|
{ |
|
|
_ret.MessageList.Add(p.AskBillNum + "存在未发货的发货单!"); |
|
|
p.State = (int)AskState.Complete; |
|
|
} |
|
|
var _list = db.TB_ASK_DETAIL.Where(itm => itm.AskBillNum == p.AskBillNum).ToList(); |
|
|
else |
|
|
_list.ForEach(itm => itm.State = (int)AskState.Complete); |
|
|
{ |
|
|
db.TB_ASK_DETAIL.AddOrUpdate(itm => itm.UID, _list.ToArray()); |
|
|
p.State = (int)AskState.Complete; |
|
|
|
|
|
var _list = db.TB_ASK_DETAIL.Where(itm => itm.AskBillNum == p.AskBillNum).ToList(); |
|
|
|
|
|
_list.ForEach(itm => itm.State = (int)AskState.Complete); |
|
|
|
|
|
db.TB_ASK_DETAIL.AddOrUpdate(itm => itm.UID, _list.ToArray()); |
|
|
|
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
); |
|
|
|
|
|
db.TB_ASK.AddOrUpdate(p => p.AskBillNum, _ls1.ToArray()); |
|
|
} |
|
|
} |
|
|
); |
|
|
else |
|
|
db.TB_ASK.AddOrUpdate(p => p.AskBillNum, _ls.ToArray()); |
|
|
|
|
|
} |
|
|
|
|
|
else |
|
|
|
|
|
{ |
|
|
|
|
|
_ret.State = ReturnStatus.Failed; |
|
|
|
|
|
_ret.Result = false; |
|
|
|
|
|
_ret.Message = "选择的记录非已发货状态,不能关闭!"; |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
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); |
|
|
|
|
|
if (count == _ls.Count && _ls.Count > 0) |
|
|
|
|
|
{ |
|
|
|
|
|
_ls.ForEach(p => |
|
|
|
|
|
{ |
|
|
{ |
|
|
p.State = (int)AskState.Confirm; |
|
|
_ret.State = ReturnStatus.Failed; |
|
|
var _list = db.TB_ASK_DETAIL.Where(itm => itm.AskBillNum == p.AskBillNum).ToList(); |
|
|
_ret.Result = false; |
|
|
_list.ForEach(itm => |
|
|
_ret.Message = "选择的记录非已发货状态,不能关闭!"; |
|
|
|
|
|
} |
|
|
|
|
|
break; |
|
|
|
|
|
case AskState.Confirm: |
|
|
|
|
|
var _ls2 = db.TB_ASK.Where(p => p_list.Contains(p.AskBillNum)).ToList(); |
|
|
|
|
|
int count2 = _ls2.Count(p => p.State == (int)AskState.Release); |
|
|
|
|
|
if (count2 == _ls2.Count && _ls2.Count > 0) |
|
|
|
|
|
{ |
|
|
|
|
|
_ls2.ForEach(p => |
|
|
{ |
|
|
{ |
|
|
|
|
|
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.State = (int)AskState.Confirm; |
|
|
|
|
|
|
|
|
itm.UpdateTime = DateTime.Now; |
|
|
itm.UpdateTime = DateTime.Now; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
); |
|
|
|
|
|
db.TB_ASK_DETAIL.AddOrUpdate(itm => itm.UID, _list.ToArray()); |
|
|
|
|
|
#region 供应商确认要货状态完成
|
|
|
|
|
|
//var _pendingList = db.TB_PENING_ITEMS.Where(itm => itm.ITEM_NO == p.AskBillNum).ToList();
|
|
|
|
|
|
//_pendingList.ForEach(itm => {
|
|
|
|
|
|
// itm.ITEM_STATE = (int)PENDING_STATE.COMPLETED;
|
|
|
|
|
|
// itm.ITEM_CONTENT = "要货看板已完成!";
|
|
|
|
|
|
//}
|
|
|
|
|
|
//);
|
|
|
|
|
|
//db.TB_PENING_ITEMS.AddOrUpdate(itm => itm.GUID, _pendingList.ToArray());
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
} |
|
|
); |
|
|
); |
|
|
db.TB_ASK_DETAIL.AddOrUpdate(itm => itm.UID, _list.ToArray()); |
|
|
db.TB_ASK.AddOrUpdate(p => p.AskBillNum, _ls2.ToArray()); |
|
|
#region 供应商确认要货状态完成
|
|
|
|
|
|
//var _pendingList = db.TB_PENING_ITEMS.Where(itm => itm.ITEM_NO == p.AskBillNum).ToList();
|
|
|
|
|
|
//_pendingList.ForEach(itm => {
|
|
|
|
|
|
// itm.ITEM_STATE = (int)PENDING_STATE.COMPLETED;
|
|
|
|
|
|
// itm.ITEM_CONTENT = "要货看板已完成!";
|
|
|
|
|
|
//}
|
|
|
|
|
|
//);
|
|
|
|
|
|
//db.TB_PENING_ITEMS.AddOrUpdate(itm => itm.GUID, _pendingList.ToArray());
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
} |
|
|
} |
|
|
); |
|
|
else |
|
|
db.TB_ASK.AddOrUpdate(p => p.AskBillNum, _ls.ToArray()); |
|
|
|
|
|
} |
|
|
|
|
|
else |
|
|
|
|
|
{ |
|
|
|
|
|
_ret.State = ReturnStatus.Failed; |
|
|
|
|
|
_ret.Result = false; |
|
|
|
|
|
_ret.Message = "选择的记录,有不是发布状态记录!"; |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
if (p_state == AskState.New) |
|
|
|
|
|
{ |
|
|
|
|
|
var _ls = db.TB_ASK.Where(p => p_list.Contains(p.AskBillNum)).ToList(); |
|
|
|
|
|
int count = _ls.Count(p => p.State == (int)AskState.Release); |
|
|
|
|
|
if (count == _ls.Count && _ls.Count > 0) |
|
|
|
|
|
{ |
|
|
|
|
|
_ls.ForEach(p => |
|
|
|
|
|
{ |
|
|
{ |
|
|
p.State = (int)AskState.New; |
|
|
_ret.State = ReturnStatus.Failed; |
|
|
var _list = db.TB_ASK_DETAIL.Where(itm => itm.AskBillNum == p.AskBillNum).ToList(); |
|
|
_ret.Result = false; |
|
|
_list.ForEach(itm => itm.State = (int)AskState.New); |
|
|
_ret.Message = "选择的记录,有不是发布状态记录!"; |
|
|
db.TB_ASK_DETAIL.AddOrUpdate(itm => itm.UID, _list.ToArray()); |
|
|
|
|
|
} |
|
|
} |
|
|
); |
|
|
break; |
|
|
db.TB_ASK.AddOrUpdate(p => p.AskBillNum, _ls.ToArray()); |
|
|
case AskState.New: |
|
|
} |
|
|
var _ls3 = db.TB_ASK.Where(p => p_list.Contains(p.AskBillNum)).ToList(); |
|
|
else |
|
|
int count3 = _ls3.Count(p => p.State == (int)AskState.Release); |
|
|
{ |
|
|
if (count3 == _ls3.Count && _ls3.Count > 0) |
|
|
_ret.State = ReturnStatus.Failed; |
|
|
|
|
|
_ret.Result = false; |
|
|
|
|
|
_ret.Message = "选择的记录,有不是发布状态记录!"; |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
if (p_state == AskState.Release) |
|
|
|
|
|
{ |
|
|
|
|
|
var _ls = db.TB_ASK.Where(p => p_list.Contains(p.AskBillNum)).ToList(); |
|
|
|
|
|
foreach (var mail in _ls) |
|
|
|
|
|
{ |
|
|
|
|
|
TB_SUPPLIER_MAIL mall = new TB_SUPPLIER_MAIL(); |
|
|
|
|
|
mall.State = 0; |
|
|
|
|
|
mall.SupplicerCode = mail.VendId; |
|
|
|
|
|
mall.MailBody = "有新的要货订单" + mail.AskBillNum; |
|
|
|
|
|
mall.Email = mail.PoBillNum; |
|
|
|
|
|
db.TB_SUPPLIER_MAIL.Add(mall); |
|
|
|
|
|
} |
|
|
|
|
|
int count = _ls.Count(p => p.State == (int)AskState.New); |
|
|
|
|
|
if (count > 0) |
|
|
|
|
|
{ |
|
|
|
|
|
_ls.ForEach(p => |
|
|
|
|
|
{ |
|
|
{ |
|
|
p.State = (int)AskState.Release; |
|
|
_ls3.ForEach(p => |
|
|
var _list = db.TB_ASK_DETAIL.Where(itm => itm.AskBillNum == p.AskBillNum).ToList(); |
|
|
|
|
|
_list.ForEach(itm => |
|
|
|
|
|
{ |
|
|
{ |
|
|
itm.State = (int)AskState.Release; |
|
|
p.State = (int)AskState.New; |
|
|
|
|
|
var _list = db.TB_ASK_DETAIL.Where(itm => itm.AskBillNum == p.AskBillNum).ToList(); |
|
|
|
|
|
_list.ForEach(itm => itm.State = (int)AskState.New); |
|
|
|
|
|
db.TB_ASK_DETAIL.AddOrUpdate(itm => itm.UID, _list.ToArray()); |
|
|
} |
|
|
} |
|
|
); |
|
|
); |
|
|
db.TB_ASK_DETAIL.AddOrUpdate(itm => itm.UID, _list.ToArray()); |
|
|
db.TB_ASK.AddOrUpdate(p => p.AskBillNum, _ls3.ToArray()); |
|
|
} |
|
|
} |
|
|
); |
|
|
else |
|
|
|
|
|
|
|
|
db.TB_ASK.AddOrUpdate(p => p.AskBillNum, _ls.ToArray()); |
|
|
|
|
|
} |
|
|
|
|
|
else |
|
|
|
|
|
{ |
|
|
|
|
|
_ret.State = ReturnStatus.Failed; |
|
|
|
|
|
_ret.Result = false; |
|
|
|
|
|
_ret.Message = "选择的记录,有不是新建状态记录!"; |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
if (p_state == AskState.Reject) |
|
|
|
|
|
{ |
|
|
|
|
|
var _ls = db.TB_ASK.Where(p => p_list.Contains(p.AskBillNum)).ToList(); |
|
|
|
|
|
int count = _ls.Count(p => p.State == (int)AskState.New || p.State == (int)AskState.Release); |
|
|
|
|
|
if (count == _ls.Count && _ls.Count > 0) |
|
|
|
|
|
{ |
|
|
|
|
|
_ls.ForEach(p => |
|
|
|
|
|
{ |
|
|
{ |
|
|
p.State = (int)AskState.Reject; |
|
|
_ret.State = ReturnStatus.Failed; |
|
|
p.IsDeleted = true; |
|
|
_ret.Result = false; |
|
|
var _list = db.TB_ASK_DETAIL.Where(itm => itm.AskBillNum == p.AskBillNum).ToList(); |
|
|
_ret.Message = "选择的记录,有不是发布状态记录!"; |
|
|
_list.ForEach(itm => |
|
|
} |
|
|
|
|
|
break; |
|
|
|
|
|
case AskState.Release: |
|
|
|
|
|
var _ls4 = db.TB_ASK.Where(p => p_list.Contains(p.AskBillNum)).ToList(); |
|
|
|
|
|
foreach (var mail in _ls4) |
|
|
|
|
|
{ |
|
|
|
|
|
TB_SUPPLIER_MAIL mall = new TB_SUPPLIER_MAIL(); |
|
|
|
|
|
mall.State = 0; |
|
|
|
|
|
mall.SupplicerCode = mail.VendId; |
|
|
|
|
|
mall.MailBody = "有新的要货订单" + mail.AskBillNum; |
|
|
|
|
|
mall.Email = mail.PoBillNum; |
|
|
|
|
|
db.TB_SUPPLIER_MAIL.Add(mall); |
|
|
|
|
|
} |
|
|
|
|
|
int count4 = _ls4.Count(p => p.State == (int)AskState.New); |
|
|
|
|
|
if (count4 > 0) |
|
|
|
|
|
{ |
|
|
|
|
|
_ls4.ForEach(p => |
|
|
{ |
|
|
{ |
|
|
itm.State = (int)AskState.Reject; |
|
|
p.State = (int)AskState.Release; |
|
|
itm.IsDeleted = true; |
|
|
var _list = db.TB_ASK_DETAIL.Where(itm => itm.AskBillNum == p.AskBillNum).ToList(); |
|
|
|
|
|
_list.ForEach(itm => |
|
|
|
|
|
{ |
|
|
|
|
|
itm.State = (int)AskState.Release; |
|
|
|
|
|
} |
|
|
|
|
|
); |
|
|
|
|
|
db.TB_ASK_DETAIL.AddOrUpdate(itm => itm.UID, _list.ToArray()); |
|
|
} |
|
|
} |
|
|
); |
|
|
); |
|
|
db.TB_ASK_DETAIL.AddOrUpdate(itm => itm.UID, _list.ToArray()); |
|
|
|
|
|
//#region 供应商要货代办作废
|
|
|
|
|
|
//var _pendingList = db.TB_PENING_ITEMS.Where(itm => itm.ITEM_NO == p.AskBillNum).ToList();
|
|
|
|
|
|
//db.TB_PENING_ITEMS.RemoveRange(_pendingList);
|
|
|
|
|
|
//#endregion
|
|
|
|
|
|
} |
|
|
|
|
|
); |
|
|
|
|
|
db.TB_ASK.AddOrUpdate(p => p.AskBillNum, _ls.ToArray()); |
|
|
|
|
|
} |
|
|
|
|
|
else |
|
|
|
|
|
{ |
|
|
|
|
|
_ret.State = ReturnStatus.Failed; |
|
|
|
|
|
_ret.Result = false; |
|
|
|
|
|
_ret.Message = "选择的记录,有不是新建或发布状态记录!"; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
db.TB_ASK.AddOrUpdate(p => p.AskBillNum, _ls4.ToArray()); |
|
|
if (p_state == AskState.CompleteForce) |
|
|
} |
|
|
{ |
|
|
else |
|
|
var _ls = db.TB_ASK.Where(p => p_list.Contains(p.AskBillNum) && p.IsDeleted == false).ToList(); |
|
|
|
|
|
int count = _ls.Count(p => p.State == (int)AskState.Confirm || p.State == (int)AskState.Ship); |
|
|
|
|
|
if (count == _ls.Count && _ls.Count > 0) |
|
|
|
|
|
{ |
|
|
|
|
|
_ls.ForEach(p => |
|
|
|
|
|
{ |
|
|
{ |
|
|
if (p.State == (int)AskState.Complete) |
|
|
_ret.State = ReturnStatus.Failed; |
|
|
|
|
|
_ret.Result = false; |
|
|
|
|
|
_ret.Message = "选择的记录,有不是新建状态记录!"; |
|
|
|
|
|
} |
|
|
|
|
|
break; |
|
|
|
|
|
case AskState.Reject: |
|
|
|
|
|
var _ls5 = db.TB_ASK.Where(p => p_list.Contains(p.AskBillNum)).ToList(); |
|
|
|
|
|
int count5 = _ls5.Count(p => p.State == (int)AskState.New || p.State == (int)AskState.Release); |
|
|
|
|
|
if (count5 == _ls5.Count && _ls5.Count > 0) |
|
|
|
|
|
{ |
|
|
|
|
|
_ls5.ForEach(p => |
|
|
{ |
|
|
{ |
|
|
p.State = (int)AskState.Reject; |
|
|
p.State = (int)AskState.Reject; |
|
|
p.IsDeleted = true; |
|
|
p.IsDeleted = true; |
|
|
} |
|
|
var _list = db.TB_ASK_DETAIL.Where(itm => itm.AskBillNum == p.AskBillNum).ToList(); |
|
|
// p.State = (int)AskState.CompleteForce;
|
|
|
_list.ForEach(itm => |
|
|
#region 修改发货单
|
|
|
|
|
|
var _asnList = db.TB_ASN.Where(itm => itm.IsDeleted == false && itm.AskBillNum == p.AskBillNum && itm.State == 0).ToList(); |
|
|
|
|
|
_asnList.ForEach(itm => |
|
|
|
|
|
{ |
|
|
|
|
|
itm.State = (int)AsnState.Reject; |
|
|
|
|
|
itm.IsDeleted = true; |
|
|
|
|
|
var _asnDetailList = db.TB_ASN_DETAIL.Where(asn => asn.IsDeleted == false && asn.AsnBillNum == itm.AsnBillNum).ToList(); |
|
|
|
|
|
_asnDetailList.ForEach(ad => |
|
|
|
|
|
{ |
|
|
{ |
|
|
itm.State = (int)AsnState.Reject; |
|
|
itm.State = (int)AskState.Reject; |
|
|
ad.IsDeleted = true; |
|
|
itm.IsDeleted = true; |
|
|
} |
|
|
} |
|
|
); |
|
|
); |
|
|
db.TB_ASN_DETAIL.AddOrUpdate(asndetail => asndetail.UID, _asnDetailList.ToArray()); |
|
|
db.TB_ASK_DETAIL.AddOrUpdate(itm => itm.UID, _list.ToArray()); |
|
|
}); |
|
|
//#region 供应商要货代办作废
|
|
|
db.TB_ASN.AddOrUpdate(_asnList.ToArray()); |
|
|
//var _pendingList = db.TB_PENING_ITEMS.Where(itm => itm.ITEM_NO == p.AskBillNum).ToList();
|
|
|
#endregion
|
|
|
//db.TB_PENING_ITEMS.RemoveRange(_pendingList);
|
|
|
var _list = db.TB_ASK_DETAIL.Where(itm => itm.AskBillNum == p.AskBillNum && itm.IsDeleted == false).ToList(); |
|
|
//#endregion
|
|
|
_list.ForEach(itm => |
|
|
} |
|
|
|
|
|
); |
|
|
|
|
|
db.TB_ASK.AddOrUpdate(p => p.AskBillNum, _ls5.ToArray()); |
|
|
|
|
|
} |
|
|
|
|
|
else |
|
|
|
|
|
{ |
|
|
|
|
|
_ret.State = ReturnStatus.Failed; |
|
|
|
|
|
_ret.Result = false; |
|
|
|
|
|
_ret.Message = "选择的记录,有不是新建或发布状态记录!"; |
|
|
|
|
|
} |
|
|
|
|
|
break; |
|
|
|
|
|
case AskState.CompleteForce: |
|
|
|
|
|
var _ls6 = db.TB_ASK.Where(p => p_list.Contains(p.AskBillNum) && p.IsDeleted == false).ToList(); |
|
|
|
|
|
int count6 = _ls6.Count(p => p.State == (int)AskState.Confirm || p.State == (int)AskState.Ship); |
|
|
|
|
|
if (count6 == _ls6.Count && _ls6.Count > 0) |
|
|
|
|
|
{ |
|
|
|
|
|
_ls6.ForEach(p => |
|
|
{ |
|
|
{ |
|
|
itm.AskQty = 0; |
|
|
if (p.State == (int)AskState.Complete) |
|
|
var asn = db.V_TB_ASN_DETAIL.Where(ask => ask.AskBillNum == itm.AskBillNum && ask.IsDeleted == false && (ask.State == (int)AsnState.Ship || ask.State == (int)AsnState.Receive)) |
|
|
|
|
|
.GroupBy(ask => new { ask.AskBillNum, ask.PoLine, ask.PartCode }) |
|
|
|
|
|
.Select(ask => new { AsSum = ask.Sum(itm1 => itm1.Qty), PoLine = ask.Key.PoLine, AskBillNum = ask.Key.AskBillNum, PartCode = ask.Key.PartCode }).ToList(); |
|
|
|
|
|
|
|
|
|
|
|
asn.ForEach(itm1 => |
|
|
|
|
|
{ |
|
|
{ |
|
|
if (itm1.AskBillNum == itm.AskBillNum && itm1.PoLine == itm.PoLine && itm1.PartCode == itm.PartCode) |
|
|
p.State = (int)AskState.Reject; |
|
|
|
|
|
p.IsDeleted = true; |
|
|
|
|
|
} |
|
|
|
|
|
// p.State = (int)AskState.CompleteForce;
|
|
|
|
|
|
#region 修改发货单
|
|
|
|
|
|
var _asnList = db.TB_ASN.Where(itm => itm.IsDeleted == false && itm.AskBillNum == p.AskBillNum && itm.State == 0).ToList(); |
|
|
|
|
|
_asnList.ForEach(itm => |
|
|
|
|
|
{ |
|
|
|
|
|
itm.State = (int)AsnState.Reject; |
|
|
|
|
|
itm.IsDeleted = true; |
|
|
|
|
|
var _asnDetailList = db.TB_ASN_DETAIL.Where(asn => asn.IsDeleted == false && asn.AsnBillNum == itm.AsnBillNum).ToList(); |
|
|
|
|
|
_asnDetailList.ForEach(ad => |
|
|
{ |
|
|
{ |
|
|
itm.AskQty = itm1.AsSum; |
|
|
itm.State = (int)AsnState.Reject; |
|
|
|
|
|
ad.IsDeleted = true; |
|
|
} |
|
|
} |
|
|
|
|
|
); |
|
|
|
|
|
db.TB_ASN_DETAIL.AddOrUpdate(asndetail => asndetail.UID, _asnDetailList.ToArray()); |
|
|
}); |
|
|
}); |
|
|
//itm.State = (int)AskState.CompleteForce;
|
|
|
db.TB_ASN.AddOrUpdate(_asnList.ToArray()); |
|
|
|
|
|
#endregion
|
|
|
|
|
|
var _list = db.TB_ASK_DETAIL.Where(itm => itm.AskBillNum == p.AskBillNum && itm.IsDeleted == false).ToList(); |
|
|
|
|
|
_list.ForEach(itm => |
|
|
|
|
|
{ |
|
|
|
|
|
itm.AskQty = 0; |
|
|
|
|
|
var asn = db.V_TB_ASN_DETAIL.Where(ask => ask.AskBillNum == itm.AskBillNum && ask.IsDeleted == false && (ask.State == (int)AsnState.Ship || ask.State == (int)AsnState.Receive)) |
|
|
|
|
|
.GroupBy(ask => new { ask.AskBillNum, ask.PoLine, ask.PartCode }) |
|
|
|
|
|
.Select(ask => new { AsSum = ask.Sum(itm1 => itm1.Qty), PoLine = ask.Key.PoLine, AskBillNum = ask.Key.AskBillNum, PartCode = ask.Key.PartCode }).ToList(); |
|
|
|
|
|
|
|
|
|
|
|
asn.ForEach(itm1 => |
|
|
|
|
|
{ |
|
|
|
|
|
if (itm1.AskBillNum == itm.AskBillNum && itm1.PoLine == itm.PoLine && itm1.PartCode == itm.PartCode) |
|
|
|
|
|
{ |
|
|
|
|
|
itm.AskQty = itm1.AsSum; |
|
|
|
|
|
} |
|
|
|
|
|
}); |
|
|
|
|
|
//itm.State = (int)AskState.CompleteForce;
|
|
|
|
|
|
} |
|
|
|
|
|
); |
|
|
|
|
|
db.TB_ASK_DETAIL.AddOrUpdate(itm => itm.UID, _list.ToArray()); |
|
|
} |
|
|
} |
|
|
); |
|
|
); |
|
|
db.TB_ASK_DETAIL.AddOrUpdate(itm => itm.UID, _list.ToArray()); |
|
|
db.TB_ASK.AddOrUpdate(p => p.AskBillNum, _ls6.ToArray()); |
|
|
} |
|
|
} |
|
|
); |
|
|
else |
|
|
db.TB_ASK.AddOrUpdate(p => p.AskBillNum, _ls.ToArray()); |
|
|
|
|
|
} |
|
|
|
|
|
else |
|
|
|
|
|
{ |
|
|
|
|
|
_ret.State = ReturnStatus.Failed; |
|
|
|
|
|
_ret.Result = false; |
|
|
|
|
|
_ret.Message = "选择的记录,有不是【已确认】或【已发货】状态,【发布状态】请用取消发布或看板作废!"; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
if (p_state == AskState.Receive) |
|
|
|
|
|
{ |
|
|
|
|
|
var _ls = db.TB_ASK.Where(p => p_list.Contains(p.AskBillNum)).ToList(); |
|
|
|
|
|
int count = _ls.Count(p => p.State == (int)AskState.New || p.State == (int)AskState.Release); |
|
|
|
|
|
if (count > 0) |
|
|
|
|
|
{ |
|
|
|
|
|
_ls.ForEach(p => |
|
|
|
|
|
{ |
|
|
{ |
|
|
p.State = (int)AskState.Receive; |
|
|
_ret.State = ReturnStatus.Failed; |
|
|
var _list = db.TB_ASK_DETAIL.Where(itm => itm.AskBillNum == p.AskBillNum).ToList(); |
|
|
_ret.Result = false; |
|
|
_list.ForEach(itm => |
|
|
_ret.Message = "选择的记录,有不是【已确认】或【已发货】状态,【发布状态】请用取消发布或看板作废!"; |
|
|
|
|
|
} |
|
|
|
|
|
break; |
|
|
|
|
|
case AskState.Receive: |
|
|
|
|
|
var _ls7 = db.TB_ASK.Where(p => p_list.Contains(p.AskBillNum)).ToList(); |
|
|
|
|
|
int count7 = _ls7.Count(p => p.State == (int)AskState.New || p.State == (int)AskState.Release); |
|
|
|
|
|
if (count7 > 0) |
|
|
|
|
|
{ |
|
|
|
|
|
_ls7.ForEach(p => |
|
|
{ |
|
|
{ |
|
|
itm.State = (int)AskState.Receive; |
|
|
p.State = (int)AskState.Receive; |
|
|
|
|
|
var _list = db.TB_ASK_DETAIL.Where(itm => itm.AskBillNum == p.AskBillNum).ToList(); |
|
|
|
|
|
_list.ForEach(itm => |
|
|
|
|
|
{ |
|
|
|
|
|
itm.State = (int)AskState.Receive; |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
); |
|
|
|
|
|
db.TB_ASK_DETAIL.AddOrUpdate(itm => itm.UID, _list.ToArray()); |
|
|
} |
|
|
} |
|
|
); |
|
|
); |
|
|
db.TB_ASK_DETAIL.AddOrUpdate(itm => itm.UID, _list.ToArray()); |
|
|
db.TB_ASK.AddOrUpdate(p => p.AskBillNum, _ls7.ToArray()); |
|
|
} |
|
|
} |
|
|
); |
|
|
else |
|
|
db.TB_ASK.AddOrUpdate(p => p.AskBillNum, _ls.ToArray()); |
|
|
|
|
|
} |
|
|
|
|
|
else |
|
|
|
|
|
{ |
|
|
|
|
|
_ret.State = ReturnStatus.Failed; |
|
|
|
|
|
_ret.Result = false; |
|
|
|
|
|
_ret.Message = "选择的记录,有不是新建或发布状态记录!"; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
if (p_state == AskState.NoConfirm) |
|
|
|
|
|
{ |
|
|
|
|
|
var _ls = db.TB_ASN.Where(p => p_list.Contains(p.AskBillNum) && p.IsDeleted == false).ToList(); |
|
|
|
|
|
if (_ls.Count == 0) |
|
|
|
|
|
{ |
|
|
|
|
|
var _askList = db.TB_ASK.Where(p => p_list.Contains(p.AskBillNum) && p.IsDeleted == false).ToList(); |
|
|
|
|
|
_askList.ForEach(p => |
|
|
|
|
|
{ |
|
|
{ |
|
|
p.State = (int)AskState.Release; |
|
|
_ret.State = ReturnStatus.Failed; |
|
|
var _list = db.TB_ASK_DETAIL.Where(itm => itm.AskBillNum == p.AskBillNum).ToList(); |
|
|
_ret.Result = false; |
|
|
_list.ForEach(itm => |
|
|
_ret.Message = "选择的记录,有不是新建或发布状态记录!"; |
|
|
|
|
|
} |
|
|
|
|
|
break; |
|
|
|
|
|
case AskState.NoConfirm: |
|
|
|
|
|
var _ls8 = db.TB_ASN.Where(p => p_list.Contains(p.AskBillNum) && p.IsDeleted == false).ToList(); |
|
|
|
|
|
if (_ls8.Count == 0) |
|
|
|
|
|
{ |
|
|
|
|
|
var _askList = db.TB_ASK.Where(p => p_list.Contains(p.AskBillNum) && p.IsDeleted == false).ToList(); |
|
|
|
|
|
_askList.ForEach(p => |
|
|
{ |
|
|
{ |
|
|
itm.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 => |
|
|
|
|
|
{ |
|
|
|
|
|
itm.State = (int)AskState.Release; |
|
|
|
|
|
} |
|
|
|
|
|
); |
|
|
|
|
|
db.TB_ASK_DETAIL.AddOrUpdate(itm => itm.UID, _list.ToArray()); |
|
|
} |
|
|
} |
|
|
); |
|
|
); |
|
|
db.TB_ASK_DETAIL.AddOrUpdate(itm => itm.UID, _list.ToArray()); |
|
|
db.TB_ASK.AddOrUpdate(p => p.AskBillNum, _askList.ToArray()); |
|
|
} |
|
|
} |
|
|
); |
|
|
else |
|
|
db.TB_ASK.AddOrUpdate(p => p.AskBillNum, _askList.ToArray()); |
|
|
{ |
|
|
} |
|
|
_ret.State = ReturnStatus.Failed; |
|
|
else |
|
|
_ret.Result = false; |
|
|
{ |
|
|
_ret.Message = "选择的记录已经有发货单据不能取消!"; |
|
|
_ret.State = ReturnStatus.Failed; |
|
|
} |
|
|
_ret.Result = false; |
|
|
break; |
|
|
_ret.Message = "选择的记录已经有发货单据不能取消!"; |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
} |
|
|
if (string.IsNullOrEmpty(_ret.Message)) |
|
|
if (string.IsNullOrEmpty(_ret.Message)) |
|
|
{ |
|
|
{ |
|
|