|
@ -12,6 +12,7 @@ using CK.SCP.Models.ScpEntity; |
|
|
using CK.SCP.Models.ScpEntity.ExcelImportEntity; |
|
|
using CK.SCP.Models.ScpEntity.ExcelImportEntity; |
|
|
using CK.SCP.Utils; |
|
|
using CK.SCP.Utils; |
|
|
using System.Data.Entity.Core; |
|
|
using System.Data.Entity.Core; |
|
|
|
|
|
using CK.SCP.Models.ScpEntity.ExcelExportEnttity; |
|
|
|
|
|
|
|
|
namespace CK.SCP.Controller |
|
|
namespace CK.SCP.Controller |
|
|
{ |
|
|
{ |
|
@ -167,7 +168,7 @@ namespace CK.SCP.Controller |
|
|
|
|
|
|
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
public static List<string> Get_V_TB_INVOICE_BY_TIME(string p_begin,string p_end,string p_po,string p_asn) |
|
|
public static List<string> Get_V_TB_INVOICE_BY_TIME(string p_begin, string p_end, string p_po, string p_asn) |
|
|
{ |
|
|
{ |
|
|
List<string> _list = new List<string>(); |
|
|
List<string> _list = new List<string>(); |
|
|
using (ScpEntities db = EntitiesFactory.CreateScpInstance()) |
|
|
using (ScpEntities db = EntitiesFactory.CreateScpInstance()) |
|
@ -190,9 +191,9 @@ namespace CK.SCP.Controller |
|
|
} |
|
|
} |
|
|
if (!string.IsNullOrEmpty(p_asn)) |
|
|
if (!string.IsNullOrEmpty(p_asn)) |
|
|
{ |
|
|
{ |
|
|
_builder.AppendFormat(" and A.AsnBillNum='{0}' \r\n",p_asn); |
|
|
_builder.AppendFormat(" and A.AsnBillNum='{0}' \r\n", p_asn); |
|
|
} |
|
|
} |
|
|
_list =db.Database.SqlQuery<string>(_builder.ToString()).ToList(); |
|
|
_list = db.Database.SqlQuery<string>(_builder.ToString()).ToList(); |
|
|
|
|
|
|
|
|
} |
|
|
} |
|
|
return _list; |
|
|
return _list; |
|
@ -212,11 +213,11 @@ namespace CK.SCP.Controller |
|
|
} |
|
|
} |
|
|
if (!string.IsNullOrEmpty(p_entity.InvcBillNum)) |
|
|
if (!string.IsNullOrEmpty(p_entity.InvcBillNum)) |
|
|
{ |
|
|
{ |
|
|
q = q.Where(p => p.InvcBillNum==p_entity.InvcBillNum); |
|
|
q = q.Where(p => p.InvcBillNum == p_entity.InvcBillNum); |
|
|
} |
|
|
} |
|
|
if (!string.IsNullOrEmpty(p_entity.VendId)) |
|
|
if (!string.IsNullOrEmpty(p_entity.VendId)) |
|
|
{ |
|
|
{ |
|
|
q = q.Where(p => p.VendId==p_entity.VendId); |
|
|
q = q.Where(p => p.VendId == p_entity.VendId); |
|
|
} |
|
|
} |
|
|
if (!string.IsNullOrEmpty(p_entity.VendName)) |
|
|
if (!string.IsNullOrEmpty(p_entity.VendName)) |
|
|
{ |
|
|
{ |
|
@ -270,9 +271,9 @@ namespace CK.SCP.Controller |
|
|
} |
|
|
} |
|
|
if (!string.IsNullOrEmpty(p_entity.AskCreateUser)) |
|
|
if (!string.IsNullOrEmpty(p_entity.AskCreateUser)) |
|
|
{ |
|
|
{ |
|
|
q = q.Where(p => p.AskCreateUser==p_entity.AskCreateUser); |
|
|
q = q.Where(p => p.AskCreateUser == p_entity.AskCreateUser); |
|
|
} |
|
|
} |
|
|
if (p_entity.InvoiceList!=null && p_entity.InvoiceList.Count>0) |
|
|
if (p_entity.InvoiceList != null && p_entity.InvoiceList.Count > 0) |
|
|
{ |
|
|
{ |
|
|
q = q.Where(p => p_entity.InvoiceList.Contains(p.InvcBillNum)); |
|
|
q = q.Where(p => p_entity.InvoiceList.Contains(p.InvcBillNum)); |
|
|
} |
|
|
} |
|
@ -964,7 +965,7 @@ namespace CK.SCP.Controller |
|
|
} |
|
|
} |
|
|
if (!string.IsNullOrEmpty(p_entity.InvcBillNum)) |
|
|
if (!string.IsNullOrEmpty(p_entity.InvcBillNum)) |
|
|
{ |
|
|
{ |
|
|
q = q.Where(p => p.InvcBillNum==(p_entity.InvcBillNum)); |
|
|
q = q.Where(p => p.InvcBillNum == (p_entity.InvcBillNum)); |
|
|
} |
|
|
} |
|
|
if (!string.IsNullOrEmpty(p_entity.PoBillNum)) |
|
|
if (!string.IsNullOrEmpty(p_entity.PoBillNum)) |
|
|
{ |
|
|
{ |
|
@ -1273,15 +1274,15 @@ namespace CK.SCP.Controller |
|
|
|
|
|
|
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
public static ResultObject<bool> CREATE_TB_INVOICE(V_TB_INVOICE p_entity,List<V_TB_RECEIVE_LIST> p_list) |
|
|
public static ResultObject<bool> CREATE_TB_INVOICE(V_TB_INVOICE p_entity, List<V_TB_RECEIVE_LIST> p_list) |
|
|
{ |
|
|
{ |
|
|
ResultObject<bool> _ret = new ResultObject<bool>(); |
|
|
ResultObject<bool> _ret = new ResultObject<bool>(); |
|
|
try |
|
|
try |
|
|
{ |
|
|
{ |
|
|
using (ScpEntities db = EntitiesFactory.CreateScpInstance()) |
|
|
using (ScpEntities db = EntitiesFactory.CreateScpInstance()) |
|
|
{ |
|
|
{ |
|
|
var _tax=db.TA_VENDER.Where(p => p.VendId == p_entity.VendId).Select(p => p.Tax).FirstOrDefault(); |
|
|
var _tax = db.TA_VENDER.Where(p => p.VendId == p_entity.VendId).Select(p => p.Tax).FirstOrDefault(); |
|
|
var _ls=p_list.Where(p => p.BillType_DESC == "索赔单").ToList(); |
|
|
var _ls = p_list.Where(p => p.BillType_DESC == "索赔单").ToList(); |
|
|
TB_INVOICE invoice = new TB_INVOICE(); |
|
|
TB_INVOICE invoice = new TB_INVOICE(); |
|
|
invoice.InvcBillNum = SCP_BILLCODE_CONTROLLER.MakeInvoiceCode(); |
|
|
invoice.InvcBillNum = SCP_BILLCODE_CONTROLLER.MakeInvoiceCode(); |
|
|
invoice.VendId = p_entity.VendId; |
|
|
invoice.VendId = p_entity.VendId; |
|
@ -1301,7 +1302,7 @@ namespace CK.SCP.Controller |
|
|
|
|
|
|
|
|
if (_ls.Count > 0) |
|
|
if (_ls.Count > 0) |
|
|
{ |
|
|
{ |
|
|
invoice.ContractPrice =0- _ls.Sum(p=>p.Price); |
|
|
invoice.ContractPrice = 0 - _ls.Sum(p => p.Price); |
|
|
} |
|
|
} |
|
|
else |
|
|
else |
|
|
{ |
|
|
{ |
|
@ -1310,12 +1311,13 @@ namespace CK.SCP.Controller |
|
|
invoice.BlancePrice = p_entity.BlancePrice; |
|
|
invoice.BlancePrice = p_entity.BlancePrice; |
|
|
db.TB_INVOICE.AddOrUpdate(invoice); |
|
|
db.TB_INVOICE.AddOrUpdate(invoice); |
|
|
|
|
|
|
|
|
p_list.ForEach(p => { |
|
|
p_list.ForEach(p => |
|
|
|
|
|
{ |
|
|
|
|
|
|
|
|
TB_INVOICE_DETAIL invocieDetail = new TB_INVOICE_DETAIL(); |
|
|
TB_INVOICE_DETAIL invocieDetail = new TB_INVOICE_DETAIL(); |
|
|
invocieDetail.Site = invoice.Site; |
|
|
invocieDetail.Site = invoice.Site; |
|
|
invocieDetail.SubSite = invoice.SubSite; |
|
|
invocieDetail.SubSite = invoice.SubSite; |
|
|
invocieDetail.InvcBillNum= invoice.InvcBillNum; |
|
|
invocieDetail.InvcBillNum = invoice.InvcBillNum; |
|
|
invocieDetail.AsnBillNum = p.AsnBillNum; |
|
|
invocieDetail.AsnBillNum = p.AsnBillNum; |
|
|
invocieDetail.PoBillNum = p.PoBillNum; |
|
|
invocieDetail.PoBillNum = p.PoBillNum; |
|
|
invocieDetail.PoLineNum = p.PoLine; |
|
|
invocieDetail.PoLineNum = p.PoLine; |
|
@ -1458,7 +1460,8 @@ namespace CK.SCP.Controller |
|
|
invoice.Tax = p_entity.Tax; |
|
|
invoice.Tax = p_entity.Tax; |
|
|
invoice.IsRed = false; |
|
|
invoice.IsRed = false; |
|
|
db.TB_INVOICE.AddOrUpdate(invoice); |
|
|
db.TB_INVOICE.AddOrUpdate(invoice); |
|
|
p_list.ForEach(p => { |
|
|
p_list.ForEach(p => |
|
|
|
|
|
{ |
|
|
|
|
|
|
|
|
TB_INVOICE_DETAIL invocieDetail = new TB_INVOICE_DETAIL(); |
|
|
TB_INVOICE_DETAIL invocieDetail = new TB_INVOICE_DETAIL(); |
|
|
invocieDetail.InvcBillNum = invoice.InvcBillNum; |
|
|
invocieDetail.InvcBillNum = invoice.InvcBillNum; |
|
@ -1480,13 +1483,13 @@ namespace CK.SCP.Controller |
|
|
invocieDetail.IsDeleted = false; |
|
|
invocieDetail.IsDeleted = false; |
|
|
invocieDetail.State = (int)InvoiceState.New; |
|
|
invocieDetail.State = (int)InvoiceState.New; |
|
|
invocieDetail.GUID = Guid.NewGuid(); |
|
|
invocieDetail.GUID = Guid.NewGuid(); |
|
|
invocieDetail.Remark =""; |
|
|
invocieDetail.Remark = ""; |
|
|
invocieDetail.IsRed = false; |
|
|
invocieDetail.IsRed = false; |
|
|
invocieDetail.BlancePrice = p.BlancePrice;//模具分摊价格
|
|
|
invocieDetail.BlancePrice = p.BlancePrice;//模具分摊价格
|
|
|
invocieDetail.DiscountPrice = p.DiscountPrice;//供应商价格
|
|
|
invocieDetail.DiscountPrice = p.DiscountPrice;//供应商价格
|
|
|
db.TB_INVOICE_DETAIL.AddOrUpdate(invocieDetail); |
|
|
db.TB_INVOICE_DETAIL.AddOrUpdate(invocieDetail); |
|
|
var _moldsharing = db.TA_MoldSharing.SingleOrDefault(t =>t.IsDeleted==false&& t.VendId == p.VendId.ToUpper() && t.PartCode == p.PartCode.ToUpper()&&t.Qty!=t.Count); |
|
|
var _moldsharing = db.TA_MoldSharing.SingleOrDefault(t => t.IsDeleted == false && t.VendId == p.VendId.ToUpper() && t.PartCode == p.PartCode.ToUpper() && t.Qty != t.Count); |
|
|
if(_moldsharing!=null ) |
|
|
if (_moldsharing != null) |
|
|
{ |
|
|
{ |
|
|
var _num = _moldsharing.Count + p.Qty; |
|
|
var _num = _moldsharing.Count + p.Qty; |
|
|
if (_moldsharing.Qty < _num) |
|
|
if (_moldsharing.Qty < _num) |
|
@ -1691,7 +1694,7 @@ namespace CK.SCP.Controller |
|
|
if (p_state == InvoiceState.FinanceReceive) |
|
|
if (p_state == InvoiceState.FinanceReceive) |
|
|
{ |
|
|
{ |
|
|
|
|
|
|
|
|
var _ary=db.TB_PENING_ITEMS.Where(itm => itm.INVOICE_NO == _entity.InvcBillNum).ToArray(); |
|
|
var _ary = db.TB_PENING_ITEMS.Where(itm => itm.INVOICE_NO == _entity.InvcBillNum).ToArray(); |
|
|
db.TB_PENING_ITEMS.RemoveRange(_ary); |
|
|
db.TB_PENING_ITEMS.RemoveRange(_ary); |
|
|
|
|
|
|
|
|
#region 财务审核通过任务新
|
|
|
#region 财务审核通过任务新
|
|
@ -1732,7 +1735,8 @@ namespace CK.SCP.Controller |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
var _list = db.TB_INVOICE_DETAIL.Where(p => p.InvcBillNum == p_billno).ToList(); |
|
|
var _list = db.TB_INVOICE_DETAIL.Where(p => p.InvcBillNum == p_billno).ToList(); |
|
|
_list.ForEach(p => { |
|
|
_list.ForEach(p => |
|
|
|
|
|
{ |
|
|
p.State = (int)p_state; |
|
|
p.State = (int)p_state; |
|
|
|
|
|
|
|
|
}); |
|
|
}); |
|
@ -1745,14 +1749,15 @@ namespace CK.SCP.Controller |
|
|
_entity.IsDeleted = true; |
|
|
_entity.IsDeleted = true; |
|
|
|
|
|
|
|
|
_list = db.TB_INVOICE_DETAIL.Where(p => p.InvcBillNum == p_billno).ToList(); |
|
|
_list = db.TB_INVOICE_DETAIL.Where(p => p.InvcBillNum == p_billno).ToList(); |
|
|
_list.ForEach(p => { |
|
|
_list.ForEach(p => |
|
|
|
|
|
{ |
|
|
p.State = (int)p_state; |
|
|
p.State = (int)p_state; |
|
|
p.IsDeleted = true; |
|
|
p.IsDeleted = true; |
|
|
}); |
|
|
}); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
db.TB_INVOICE_DETAIL.AddOrUpdate(p => p.UID, _list.ToArray()); |
|
|
db.TB_INVOICE_DETAIL.AddOrUpdate(p => p.UID, _list.ToArray()); |
|
|
db.TB_INVOICE.AddOrUpdate(p => p.UID,_entity); |
|
|
db.TB_INVOICE.AddOrUpdate(p => p.UID, _entity); |
|
|
|
|
|
|
|
|
if (string.IsNullOrEmpty(_ret.Message)) |
|
|
if (string.IsNullOrEmpty(_ret.Message)) |
|
|
{ |
|
|
{ |
|
@ -1830,7 +1835,7 @@ namespace CK.SCP.Controller |
|
|
return _ret; |
|
|
return _ret; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
public static ResultObject<bool> SAVE_TB_INVOICE_STATE(V_TB_INVOICE invoice, InvoiceState p_state,string p_username="", string p_flag = "") |
|
|
public static ResultObject<bool> SAVE_TB_INVOICE_STATE(V_TB_INVOICE invoice, InvoiceState p_state, string p_username = "", string p_flag = "") |
|
|
{ |
|
|
{ |
|
|
ResultObject<bool> _ret = new ResultObject<bool>(); |
|
|
ResultObject<bool> _ret = new ResultObject<bool>(); |
|
|
try |
|
|
try |
|
@ -1994,7 +1999,8 @@ namespace CK.SCP.Controller |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
var _list = db.TB_INVOICE_DETAIL.Where(p => p.InvcBillNum == invoice.InvcBillNum).ToList(); |
|
|
var _list = db.TB_INVOICE_DETAIL.Where(p => p.InvcBillNum == invoice.InvcBillNum).ToList(); |
|
|
_list.ForEach(p => { |
|
|
_list.ForEach(p => |
|
|
|
|
|
{ |
|
|
p.State = (int)p_state; |
|
|
p.State = (int)p_state; |
|
|
|
|
|
|
|
|
}); |
|
|
}); |
|
@ -2007,14 +2013,15 @@ namespace CK.SCP.Controller |
|
|
_entity.IsDeleted = true; |
|
|
_entity.IsDeleted = true; |
|
|
|
|
|
|
|
|
_list = db.TB_INVOICE_DETAIL.Where(p => p.InvcBillNum == invoice.InvcBillNum).ToList(); |
|
|
_list = db.TB_INVOICE_DETAIL.Where(p => p.InvcBillNum == invoice.InvcBillNum).ToList(); |
|
|
_list.ForEach(p => { |
|
|
_list.ForEach(p => |
|
|
|
|
|
{ |
|
|
p.State = (int)p_state; |
|
|
p.State = (int)p_state; |
|
|
p.IsDeleted = true; |
|
|
p.IsDeleted = true; |
|
|
if (!string.IsNullOrEmpty(p_flag))//修改分摊数量
|
|
|
if (!string.IsNullOrEmpty(p_flag))//修改分摊数量
|
|
|
{ |
|
|
{ |
|
|
var _moldsharing = db.TA_MoldSharing.SingleOrDefault(t =>t.IsDeleted==false&& t.VendId == invoice.VendId.ToUpper() && t.PartCode == p.PartCode.ToUpper()); |
|
|
var _moldsharing = db.TA_MoldSharing.SingleOrDefault(t => t.IsDeleted == false && t.VendId == invoice.VendId.ToUpper() && t.PartCode == p.PartCode.ToUpper()); |
|
|
var _ms_detail = db.TA_MoldSharing_Invoice.SingleOrDefault(t =>t.InvcGUID==p.GUID); |
|
|
var _ms_detail = db.TA_MoldSharing_Invoice.SingleOrDefault(t => t.InvcGUID == p.GUID); |
|
|
if (_moldsharing != null&& _ms_detail!=null) |
|
|
if (_moldsharing != null && _ms_detail != null) |
|
|
{ |
|
|
{ |
|
|
db.TA_MoldSharing_Invoice.Remove(_ms_detail); |
|
|
db.TA_MoldSharing_Invoice.Remove(_ms_detail); |
|
|
var _num = _moldsharing.Count - p.Qty; |
|
|
var _num = _moldsharing.Count - p.Qty; |
|
@ -2185,7 +2192,7 @@ namespace CK.SCP.Controller |
|
|
return _ret; |
|
|
return _ret; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
public static ResultObject<bool> SAVE_TB_INVOICE_APPLY(V_TB_INVOICE p_invoice, List<V_TB_INVOICE_DETAIL> p_list,string p_flag="") |
|
|
public static ResultObject<bool> SAVE_TB_INVOICE_APPLY(V_TB_INVOICE p_invoice, List<V_TB_INVOICE_DETAIL> p_list, string p_flag = "") |
|
|
{ |
|
|
{ |
|
|
ResultObject<bool> _ret = new ResultObject<bool>(); |
|
|
ResultObject<bool> _ret = new ResultObject<bool>(); |
|
|
List<string> _list = new List<string>(); |
|
|
List<string> _list = new List<string>(); |
|
@ -2193,7 +2200,7 @@ namespace CK.SCP.Controller |
|
|
{ |
|
|
{ |
|
|
using (ScpEntities db = EntitiesFactory.CreateScpInstance()) |
|
|
using (ScpEntities db = EntitiesFactory.CreateScpInstance()) |
|
|
{ |
|
|
{ |
|
|
var _bill=db.TB_INVOICE.Where(itm => itm.InvcBillNum == p_invoice.InvcBillNum).FirstOrDefault(); |
|
|
var _bill = db.TB_INVOICE.Where(itm => itm.InvcBillNum == p_invoice.InvcBillNum).FirstOrDefault(); |
|
|
_bill.InvoiceNum = p_invoice.InvoiceNum; |
|
|
_bill.InvoiceNum = p_invoice.InvoiceNum; |
|
|
_bill.ExpressNum = p_invoice.ExpressNum; |
|
|
_bill.ExpressNum = p_invoice.ExpressNum; |
|
|
_bill.ContractPrice = p_invoice.ContractPrice; |
|
|
_bill.ContractPrice = p_invoice.ContractPrice; |
|
@ -2210,10 +2217,11 @@ namespace CK.SCP.Controller |
|
|
_bill.UpdateTime = p_invoice.UpdateTime; |
|
|
_bill.UpdateTime = p_invoice.UpdateTime; |
|
|
} |
|
|
} |
|
|
db.TB_INVOICE.AddOrUpdate(p => p.InvcBillNum, _bill); |
|
|
db.TB_INVOICE.AddOrUpdate(p => p.InvcBillNum, _bill); |
|
|
p_list.ForEach(p => { |
|
|
p_list.ForEach(p => |
|
|
var _detail=db.TB_INVOICE_DETAIL.Where(itm => itm.UID == p.UID).FirstOrDefault(); |
|
|
{ |
|
|
|
|
|
var _detail = db.TB_INVOICE_DETAIL.Where(itm => itm.UID == p.UID).FirstOrDefault(); |
|
|
var _qty = _detail.Qty - p.Qty; |
|
|
var _qty = _detail.Qty - p.Qty; |
|
|
_detail.State =(int)p.State; |
|
|
_detail.State = (int)p.State; |
|
|
_detail.Qty = p.Qty; |
|
|
_detail.Qty = p.Qty; |
|
|
_detail.Price = p.Price; |
|
|
_detail.Price = p.Price; |
|
|
_detail.ContractPrice = p.ContractPrice; |
|
|
_detail.ContractPrice = p.ContractPrice; |
|
@ -2226,12 +2234,12 @@ namespace CK.SCP.Controller |
|
|
_detail.IsDeleted = true; |
|
|
_detail.IsDeleted = true; |
|
|
} |
|
|
} |
|
|
_detail.Remark = p.Remark; |
|
|
_detail.Remark = p.Remark; |
|
|
db.TB_INVOICE_DETAIL.AddOrUpdate(itm=>itm.UID,_detail); |
|
|
db.TB_INVOICE_DETAIL.AddOrUpdate(itm => itm.UID, _detail); |
|
|
if(!string.IsNullOrEmpty(p_flag))//修改发票数量对分摊数修改
|
|
|
if (!string.IsNullOrEmpty(p_flag))//修改发票数量对分摊数修改
|
|
|
{ |
|
|
{ |
|
|
var _ms = db.TA_MoldSharing.SingleOrDefault(t =>t.IsDeleted==false&& t.PartCode == _detail.PartCode && t.VendId == _bill.VendId); |
|
|
var _ms = db.TA_MoldSharing.SingleOrDefault(t => t.IsDeleted == false && t.PartCode == _detail.PartCode && t.VendId == _bill.VendId); |
|
|
var _ms_detail= db.TA_MoldSharing_Invoice.SingleOrDefault(t =>t.InvcGUID== _detail.GUID); |
|
|
var _ms_detail = db.TA_MoldSharing_Invoice.SingleOrDefault(t => t.InvcGUID == _detail.GUID); |
|
|
if (_ms != null&& _ms_detail!=null) |
|
|
if (_ms != null && _ms_detail != null) |
|
|
{ |
|
|
{ |
|
|
_ms.Count = _ms.Count - _qty; |
|
|
_ms.Count = _ms.Count - _qty; |
|
|
if (_ms.Count > _ms.Qty) |
|
|
if (_ms.Count > _ms.Qty) |
|
@ -2351,7 +2359,7 @@ namespace CK.SCP.Controller |
|
|
{ |
|
|
{ |
|
|
using (ScpEntities db = EntitiesFactory.CreateScpInstance()) |
|
|
using (ScpEntities db = EntitiesFactory.CreateScpInstance()) |
|
|
{ |
|
|
{ |
|
|
var _bill = db.TB_INVOICE.Where(itm => itm.InvcBillNum == p_invoice.InvcBillNum && itm.IsRed==true).FirstOrDefault(); |
|
|
var _bill = db.TB_INVOICE.Where(itm => itm.InvcBillNum == p_invoice.InvcBillNum && itm.IsRed == true).FirstOrDefault(); |
|
|
_bill.InvoiceNum = p_invoice.InvoiceNum; |
|
|
_bill.InvoiceNum = p_invoice.InvoiceNum; |
|
|
_bill.ExpressNum = p_invoice.ExpressNum; |
|
|
_bill.ExpressNum = p_invoice.ExpressNum; |
|
|
_bill.ContractPrice = p_invoice.ContractPrice; |
|
|
_bill.ContractPrice = p_invoice.ContractPrice; |
|
@ -2361,7 +2369,8 @@ namespace CK.SCP.Controller |
|
|
_bill.Remark = p_invoice.Remark; |
|
|
_bill.Remark = p_invoice.Remark; |
|
|
_bill.State = (int)p_invoice.State; |
|
|
_bill.State = (int)p_invoice.State; |
|
|
db.TB_INVOICE.AddOrUpdate(p => p.UID, _bill); |
|
|
db.TB_INVOICE.AddOrUpdate(p => p.UID, _bill); |
|
|
p_list.ForEach(p => { |
|
|
p_list.ForEach(p => |
|
|
|
|
|
{ |
|
|
var _detail = db.TB_INVOICE_DETAIL.Where(itm => itm.UID == p.UID).FirstOrDefault(); |
|
|
var _detail = db.TB_INVOICE_DETAIL.Where(itm => itm.UID == p.UID).FirstOrDefault(); |
|
|
_detail.State = (int)p.State; |
|
|
_detail.State = (int)p.State; |
|
|
_detail.Qty = p.Qty; |
|
|
_detail.Qty = p.Qty; |
|
@ -2458,7 +2467,7 @@ namespace CK.SCP.Controller |
|
|
using (ScpEntities db = EntitiesFactory.CreateScpInstance()) |
|
|
using (ScpEntities db = EntitiesFactory.CreateScpInstance()) |
|
|
{ |
|
|
{ |
|
|
|
|
|
|
|
|
TB_INVOICE _bill = db.TB_INVOICE.Where(itm => itm.InvcBillNum == p_invoice.InvcBillNum && itm.IsDeleted==false).FirstOrDefault(); |
|
|
TB_INVOICE _bill = db.TB_INVOICE.Where(itm => itm.InvcBillNum == p_invoice.InvcBillNum && itm.IsDeleted == false).FirstOrDefault(); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (_bill != null) |
|
|
if (_bill != null) |
|
@ -2542,7 +2551,7 @@ namespace CK.SCP.Controller |
|
|
_detail.BlancePrice = p.BlancePrice; |
|
|
_detail.BlancePrice = p.BlancePrice; |
|
|
_detail.DiscountPrice = p.DiscountPrice; |
|
|
_detail.DiscountPrice = p.DiscountPrice; |
|
|
_detail.DiscountRemark = p.DiscountRemark; |
|
|
_detail.DiscountRemark = p.DiscountRemark; |
|
|
_detail.IsRed =true; |
|
|
_detail.IsRed = true; |
|
|
|
|
|
|
|
|
db.TB_INVOICE_DETAIL.Add(_detail); |
|
|
db.TB_INVOICE_DETAIL.Add(_detail); |
|
|
}); |
|
|
}); |
|
@ -2705,7 +2714,7 @@ namespace CK.SCP.Controller |
|
|
} |
|
|
} |
|
|
return _ret; |
|
|
return _ret; |
|
|
} |
|
|
} |
|
|
public static ResultObject<bool> CaiWu_Return_Reason(string p_InvcBillNum,string p_Memo) |
|
|
public static ResultObject<bool> CaiWu_Return_Reason(string p_InvcBillNum, string p_Memo) |
|
|
{ |
|
|
{ |
|
|
ResultObject<bool> _ret = new ResultObject<bool>(); |
|
|
ResultObject<bool> _ret = new ResultObject<bool>(); |
|
|
try |
|
|
try |
|
@ -2908,7 +2917,7 @@ namespace CK.SCP.Controller |
|
|
return _ret; |
|
|
return _ret; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
public static ResultObject<bool> UpdateMemoByInvcBillNum(string p_InvcBillNum, string p_Memo, decimal p_blan, string p_inv,DateTime p_time) |
|
|
public static ResultObject<bool> UpdateMemoByInvcBillNum(string p_InvcBillNum, string p_Memo, decimal p_blan, string p_inv, DateTime p_time) |
|
|
{ |
|
|
{ |
|
|
ResultObject<bool> _ret = new ResultObject<bool>(); |
|
|
ResultObject<bool> _ret = new ResultObject<bool>(); |
|
|
try |
|
|
try |
|
@ -3167,11 +3176,11 @@ namespace CK.SCP.Controller |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
List<V_TB_INVOICE_DETAIL> _ls = db.V_TB_INVOICE_DETAIL.Where(p => p.InvcBillNum == p_InvcBillNum).ToList(); |
|
|
List<V_TB_INVOICE_DETAIL> _ls = db.V_TB_INVOICE_DETAIL.Where(p => p.InvcBillNum == p_InvcBillNum).ToList(); |
|
|
V_TB_INVOICE _bill= db.V_TB_INVOICE.Where(p => p.InvcBillNum == p_InvcBillNum).FirstOrDefault(); |
|
|
V_TB_INVOICE _bill = db.V_TB_INVOICE.Where(p => p.InvcBillNum == p_InvcBillNum).FirstOrDefault(); |
|
|
foreach (V_TB_INVOICE_DETAIL itm in _ls) |
|
|
foreach (V_TB_INVOICE_DETAIL itm in _ls) |
|
|
{ |
|
|
{ |
|
|
|
|
|
|
|
|
TS_UNI_API _api = UniApiController.CreateBy(_bill,itm ,UniApiType.Invoice); |
|
|
TS_UNI_API _api = UniApiController.CreateBy(_bill, itm, UniApiType.Invoice); |
|
|
_api.State = 1; |
|
|
_api.State = 1; |
|
|
db.TS_UNI_API.AddOrUpdate(_api); |
|
|
db.TS_UNI_API.AddOrUpdate(_api); |
|
|
itm.State = (int)p_state; |
|
|
itm.State = (int)p_state; |
|
@ -3279,7 +3288,7 @@ namespace CK.SCP.Controller |
|
|
var _invoice = db.TB_INVOICE.Where(p => p.InvcBillNum == p_entity.InvcBillNum).FirstOrDefault(); |
|
|
var _invoice = db.TB_INVOICE.Where(p => p.InvcBillNum == p_entity.InvcBillNum).FirstOrDefault(); |
|
|
var _invoicedetail = db.TB_INVOICE_DETAIL.Where(p => p.InvcBillNum == p_entity.InvcBillNum).FirstOrDefault(); |
|
|
var _invoicedetail = db.TB_INVOICE_DETAIL.Where(p => p.InvcBillNum == p_entity.InvcBillNum).FirstOrDefault(); |
|
|
|
|
|
|
|
|
if(_invoice !=null) |
|
|
if (_invoice != null) |
|
|
{ |
|
|
{ |
|
|
if (_invoicedetail != null) |
|
|
if (_invoicedetail != null) |
|
|
{ |
|
|
{ |
|
@ -3407,5 +3416,483 @@ namespace CK.SCP.Controller |
|
|
} |
|
|
} |
|
|
return _ret; |
|
|
return _ret; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 物料与供应商对应关系表
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
/// <param name="p_entity"></param>
|
|
|
|
|
|
/// <param name="p_action"></param>
|
|
|
|
|
|
public static void Get_V_TA_CheckPartsAndVend(V_TA_CheckPartsAndVend p_entity, Action<ResultObject<IQueryable<V_TA_CheckPartsAndVend>>> p_action) |
|
|
|
|
|
{ |
|
|
|
|
|
ResultObject<IQueryable<V_TA_CheckPartsAndVend>> _ret = new ResultObject<IQueryable<V_TA_CheckPartsAndVend>>(); |
|
|
|
|
|
try |
|
|
|
|
|
{ |
|
|
|
|
|
using (ScpEntities db = EntitiesFactory.CreateScpInstance()) |
|
|
|
|
|
{ |
|
|
|
|
|
IQueryable<V_TA_CheckPartsAndVend> q = db.V_TA_CheckPartsAndVend; |
|
|
|
|
|
if (!string.IsNullOrEmpty(p_entity.PartCode)) |
|
|
|
|
|
{ |
|
|
|
|
|
q = q.Where(p => p.PartCode == p_entity.PartCode); |
|
|
|
|
|
} |
|
|
|
|
|
if (!string.IsNullOrEmpty(p_entity.VendID)) |
|
|
|
|
|
{ |
|
|
|
|
|
q = q.Where(p => p.VendID == p_entity.VendID); |
|
|
|
|
|
} |
|
|
|
|
|
_ret.State = ReturnStatus.Succeed; |
|
|
|
|
|
_ret.Result = q; |
|
|
|
|
|
p_action(_ret); |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
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_INVOICE_CONTROLLER), "Get_V_TA_CheckPartsAndVend", 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_INVOICE_CONTROLLER), "Get_V_TA_CheckPartsAndVend", 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_INVOICE_CONTROLLER), "Get_V_TA_CheckPartsAndVend", 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_INVOICE_CONTROLLER), "Get_V_TA_CheckPartsAndVend", e.Message); |
|
|
|
|
|
throw e; |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 导入检查
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
/// <param name="db"></param>
|
|
|
|
|
|
/// <param name="p_excel"></param>
|
|
|
|
|
|
/// <param name="site"></param>
|
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
|
private static List<string> CheckExcelMode_VenderPart(ScpEntities db, SCP_CHECKPARTANDVENDER_EXPORT p_excel, string site) |
|
|
|
|
|
{ |
|
|
|
|
|
List<string> ErrorList = new List<string>(); |
|
|
|
|
|
if (!string.IsNullOrEmpty(p_excel.零件号)) |
|
|
|
|
|
{ |
|
|
|
|
|
int count = db.TA_PART.Count(p => p.PartCode == p_excel.零件号.Trim()); |
|
|
|
|
|
if (count == 0) |
|
|
|
|
|
{ |
|
|
|
|
|
ErrorList.Add(string.Format("零件编号【{0}】不存在!", p_excel.零件号)); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
if (!string.IsNullOrEmpty(p_excel.供应商)) |
|
|
|
|
|
{ |
|
|
|
|
|
int count1 = db.TA_VENDER.Count(p => p.VendId == p_excel.供应商.Trim()); |
|
|
|
|
|
if (count1 == 0) |
|
|
|
|
|
{ |
|
|
|
|
|
ErrorList.Add(string.Format("供应商【{0}】不存在!", p_excel.供应商)); |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
else if (string.IsNullOrEmpty(p_excel.零件号) || string.IsNullOrEmpty(p_excel.供应商)) |
|
|
|
|
|
{ |
|
|
|
|
|
ErrorList.Add(string.Format("零件号码【{0}】有填写为空!", p_excel.零件号)); |
|
|
|
|
|
} |
|
|
|
|
|
return ErrorList; |
|
|
|
|
|
} |
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 导入零件供应商对应关系表
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
/// <param name="p_order_list"></param>
|
|
|
|
|
|
/// <param name="site"></param>
|
|
|
|
|
|
/// <param name="p_creator"></param>
|
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
|
public static ResultObject<bool> EXCEL_VENDER_PART(List<SCP_CHECKPARTANDVENDER_EXPORT> p_order_list, string site, string p_creator) |
|
|
|
|
|
{ |
|
|
|
|
|
ResultObject<bool> _ret = new ResultObject<bool>(); |
|
|
|
|
|
try |
|
|
|
|
|
{ |
|
|
|
|
|
using (ScpEntities db = EntitiesFactory.CreateScpInstance()) |
|
|
|
|
|
{ |
|
|
|
|
|
int number = 1; |
|
|
|
|
|
List<string> lineError = new List<string>(); |
|
|
|
|
|
List<string> ErrorList = new List<string>(); |
|
|
|
|
|
var _lst = p_order_list; |
|
|
|
|
|
_lst.ForEach(p => |
|
|
|
|
|
{ |
|
|
|
|
|
var _count = _lst.Count(itm => itm.零件号 == p.零件号 && itm.供应商 == p.供应商); |
|
|
|
|
|
if (_count > 1) |
|
|
|
|
|
{ |
|
|
|
|
|
lineError.Add(string.Format("零件号码有重", p.零件号)); |
|
|
|
|
|
ErrorList = lineError; |
|
|
|
|
|
} |
|
|
|
|
|
}); |
|
|
|
|
|
_lst.ForEach(p => |
|
|
|
|
|
{ |
|
|
|
|
|
var _ls = CheckExcelMode_VenderPart(db, p, site); |
|
|
|
|
|
if (_ls.Count > 0) |
|
|
|
|
|
{ |
|
|
|
|
|
lineError.Add(number.ToString()); |
|
|
|
|
|
ErrorList.Add(string.Join("<br>", _ls.ToArray())); |
|
|
|
|
|
} |
|
|
|
|
|
number++; |
|
|
|
|
|
}); |
|
|
|
|
|
if (lineError.Count > 0) |
|
|
|
|
|
{ |
|
|
|
|
|
_ret.State = ReturnStatus.Failed; |
|
|
|
|
|
_ret.MessageList.AddRange(ErrorList); |
|
|
|
|
|
_ret.Result = false; |
|
|
|
|
|
} |
|
|
|
|
|
else |
|
|
|
|
|
{ |
|
|
|
|
|
_lst.ForEach(p => |
|
|
|
|
|
{ |
|
|
|
|
|
|
|
|
|
|
|
var _partdes = db.TA_CHECKPARTANDVEND.Count(t => t.PartCode == p.零件号.Trim() && t.VendID == p.供应商.Trim()); |
|
|
|
|
|
if (_partdes == 0) |
|
|
|
|
|
{ |
|
|
|
|
|
TA_CHECKPARTANDVEND _entity = new TA_CHECKPARTANDVEND(); |
|
|
|
|
|
_entity.PartCode = p.零件号.Trim(); |
|
|
|
|
|
_entity.VendID = p.供应商.Trim(); |
|
|
|
|
|
_entity.Model = p.车型.Trim(); |
|
|
|
|
|
db.TA_CHECKPARTANDVEND.Add(_entity); |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
else |
|
|
|
|
|
{ |
|
|
|
|
|
var _partde = db.TA_CHECKPARTANDVEND.SingleOrDefault(t => t.PartCode == p.零件号.Trim() && t.VendID == p.供应商.Trim()); |
|
|
|
|
|
|
|
|
|
|
|
_partde.PartCode = p.零件号.Trim(); |
|
|
|
|
|
_partde.VendID = p.供应商.Trim(); |
|
|
|
|
|
_partde.Model = p.车型.Trim(); |
|
|
|
|
|
db.TA_CHECKPARTANDVEND.AddOrUpdate(_partde); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}); |
|
|
|
|
|
if (_ret.MessageList.Count == 0) |
|
|
|
|
|
{ |
|
|
|
|
|
int state = db.SaveChanges(); |
|
|
|
|
|
if (state != -1) |
|
|
|
|
|
{ |
|
|
|
|
|
_ret.State = ReturnStatus.Succeed; |
|
|
|
|
|
_ret.Result = true; |
|
|
|
|
|
} |
|
|
|
|
|
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_INVOICE_CONTROLLER), "EXCEL_VENDER_PART", 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_INVOICE_CONTROLLER), "EXCEL_VENDER_PART", 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_INVOICE_CONTROLLER), "EXCEL_VENDER_PART", 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_INVOICE_CONTROLLER), "EXCEL_VENDER_PART", e.Message); |
|
|
|
|
|
_ret.Result = false; |
|
|
|
|
|
_ret.ErrorList.Add(e); |
|
|
|
|
|
} |
|
|
|
|
|
return _ret; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 删除
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
/// <param name="_ls"></param>
|
|
|
|
|
|
/// <param name="_ls1"></param>
|
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
|
public static ResultObject<bool> Del_VENDER_PART(string partcode, string vendid) |
|
|
|
|
|
{ |
|
|
|
|
|
ResultObject<bool> _ret = new ResultObject<bool>(); |
|
|
|
|
|
try |
|
|
|
|
|
{ |
|
|
|
|
|
using (ScpEntities db = EntitiesFactory.CreateScpInstance()) |
|
|
|
|
|
{ |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var _entity = db.TA_CHECKPARTANDVEND.FirstOrDefault(p => p.VendID == vendid && p.PartCode == partcode); |
|
|
|
|
|
if (_entity != null) |
|
|
|
|
|
{ |
|
|
|
|
|
db.TA_CHECKPARTANDVEND.Remove(_entity); |
|
|
|
|
|
if (db.SaveChanges() != -1) |
|
|
|
|
|
{ |
|
|
|
|
|
_ret.State = ReturnStatus.Succeed; |
|
|
|
|
|
_ret.Result = true; |
|
|
|
|
|
} |
|
|
|
|
|
else |
|
|
|
|
|
{ |
|
|
|
|
|
_ret.State = ReturnStatus.Failed; |
|
|
|
|
|
_ret.Result = false; |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
else |
|
|
|
|
|
{ |
|
|
|
|
|
_ret.State = ReturnStatus.Failed; |
|
|
|
|
|
_ret.Message = "请刷新后重新选择数据再进行删除!"; |
|
|
|
|
|
_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_INFO_CONTROLLER), "Del_VENDER_PART", 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_INFO_CONTROLLER), "Del_VENDER_PART", 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_INFO_CONTROLLER), "Del_VENDER_PART", 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.Result = false; |
|
|
|
|
|
_ret.ErrorList.Add(e); |
|
|
|
|
|
LogHelper.Writlog(LogHelper.LogType.Error, typeof(SCP_INFO_CONTROLLER), "Del_VENDER_PART", e.Message); |
|
|
|
|
|
throw e; |
|
|
|
|
|
} |
|
|
|
|
|
return _ret; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 保存零件供应商对应关系表
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
/// <param name="p_entitys"></param>
|
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
|
public static ResultObject<bool> Save_TA_CHECKPARTANDVEND(TA_CHECKPARTANDVEND p_entitys) |
|
|
|
|
|
{ |
|
|
|
|
|
ResultObject<bool> _ret = new ResultObject<bool>(); |
|
|
|
|
|
int pcount = 0; |
|
|
|
|
|
int vcount = 0; |
|
|
|
|
|
try |
|
|
|
|
|
{ |
|
|
|
|
|
using (ScpEntities db = EntitiesFactory.CreateScpInstance()) |
|
|
|
|
|
{ |
|
|
|
|
|
var appliance = db.TA_CHECKPARTANDVEND.FirstOrDefault(p => p.PartCode == p_entitys.PartCode && p.VendID == p_entitys.VendID); |
|
|
|
|
|
pcount = db.TA_PART.Count(q => q.PartCode == p_entitys.PartCode); |
|
|
|
|
|
if (pcount == 0) |
|
|
|
|
|
{ |
|
|
|
|
|
_ret.State = ReturnStatus.Failed; |
|
|
|
|
|
_ret.Message = "未找到零件号:" + p_entitys.PartCode; |
|
|
|
|
|
_ret.Result = false; |
|
|
|
|
|
return _ret; |
|
|
|
|
|
} |
|
|
|
|
|
vcount = db.TA_VENDER.Count(q => q.VendId == p_entitys.VendID); |
|
|
|
|
|
if (vcount == 0) |
|
|
|
|
|
{ |
|
|
|
|
|
_ret.State = ReturnStatus.Failed; |
|
|
|
|
|
_ret.Message = "未找到供应商:" + p_entitys.VendID; |
|
|
|
|
|
_ret.Result = false; |
|
|
|
|
|
return _ret; |
|
|
|
|
|
} |
|
|
|
|
|
if (appliance == null) |
|
|
|
|
|
{ |
|
|
|
|
|
TA_CHECKPARTANDVEND applianc = new TA_CHECKPARTANDVEND(); |
|
|
|
|
|
applianc.PartCode = p_entitys.PartCode; |
|
|
|
|
|
applianc.VendID = p_entitys.VendID; |
|
|
|
|
|
applianc.Model = p_entitys.Model; |
|
|
|
|
|
db.TA_CHECKPARTANDVEND.AddOrUpdate(applianc); |
|
|
|
|
|
} |
|
|
|
|
|
else |
|
|
|
|
|
{ |
|
|
|
|
|
appliance.Model = p_entitys.Model; |
|
|
|
|
|
db.TA_CHECKPARTANDVEND.AddOrUpdate(appliance); |
|
|
|
|
|
} |
|
|
|
|
|
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_INVOICE_CONTROLLER), "Save_TA_LANGUAGE", 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_INVOICE_CONTROLLER), "Save_TA_LANGUAGE", 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_INVOICE_CONTROLLER), "Save_TA_LANGUAGE", 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_INVOICE_CONTROLLER), "Save_TA_LANGUAGE", e.Message); |
|
|
|
|
|
_ret.Result = false; |
|
|
|
|
|
_ret.ErrorList.Add(e); |
|
|
|
|
|
throw e; |
|
|
|
|
|
} |
|
|
|
|
|
return _ret; |
|
|
|
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|