|
|
@ -560,6 +560,161 @@ namespace CK.SCP.Controller |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// 通过 InvcBillNum 查询
|
|
|
|
/// </summary>
|
|
|
|
/// <param name="p_entity"></param>
|
|
|
|
/// <param name="p_action"></param>
|
|
|
|
public static void Get_V_TB_INVOICE_List_BYInvcBillNum(V_TB_INVOICE p_entity, Action<ResultObject<IQueryable<V_TB_INVOICE>>> p_action) |
|
|
|
{ |
|
|
|
ResultObject<IQueryable<V_TB_INVOICE>> _ret = new ResultObject<IQueryable<V_TB_INVOICE>>(); |
|
|
|
try |
|
|
|
{ |
|
|
|
using (ScpEntities db = EntitiesFactory.CreateScpInstance()) |
|
|
|
{ |
|
|
|
IQueryable<V_TB_INVOICE> q = db.V_TB_INVOICE; |
|
|
|
if (p_entity.UID != 0) |
|
|
|
{ |
|
|
|
q = q.Where(p => p.UID == p_entity.UID); |
|
|
|
} |
|
|
|
if (!string.IsNullOrEmpty(p_entity.InvcBillNum)) |
|
|
|
{ |
|
|
|
q = q.Where(p => p.InvcBillNum ==p_entity.InvcBillNum); |
|
|
|
} |
|
|
|
if (!string.IsNullOrEmpty(p_entity.VendId)) |
|
|
|
{ |
|
|
|
q = q.Where(p => p.VendId.Contains(p_entity.VendId)); |
|
|
|
} |
|
|
|
if (!string.IsNullOrEmpty(p_entity.VendName)) |
|
|
|
{ |
|
|
|
q = q.Where(p => p.VendName.Contains(p_entity.VendName)); |
|
|
|
} |
|
|
|
|
|
|
|
if (!string.IsNullOrEmpty(p_entity.InvoiceNum)) |
|
|
|
{ |
|
|
|
q = q.Where(p => p.InvoiceNum.Contains(p_entity.InvoiceNum)); |
|
|
|
} |
|
|
|
if (p_entity.BillStateList != null && p_entity.BillStateList.Count > 0) |
|
|
|
{ |
|
|
|
q = q.Where(p => p_entity.BillStateList.Contains(p.State)); |
|
|
|
} |
|
|
|
if (!string.IsNullOrEmpty(p_entity.Site)) |
|
|
|
{ |
|
|
|
q = q.Where(p => p.Site == p_entity.Site); |
|
|
|
} |
|
|
|
else if (p_entity.State != 0) |
|
|
|
{ |
|
|
|
q = q.Where(p => p.State == p_entity.State); |
|
|
|
} |
|
|
|
if (!string.IsNullOrEmpty(p_entity.Remark)) |
|
|
|
{ |
|
|
|
q = q.Where(p => p.Remark.Contains(p_entity.Remark)); |
|
|
|
} |
|
|
|
if (p_entity.Tax != null) |
|
|
|
{ |
|
|
|
q = q.Where(p => p.Tax == p_entity.Tax); |
|
|
|
} |
|
|
|
if (p_entity.TaxAmount != null) |
|
|
|
{ |
|
|
|
q = q.Where(p => p.TaxAmount == p_entity.TaxAmount); |
|
|
|
} |
|
|
|
if (p_entity.Amount != null) |
|
|
|
{ |
|
|
|
q = q.Where(p => p.Amount == p_entity.Amount); |
|
|
|
} |
|
|
|
if (p_entity.Total != null) |
|
|
|
{ |
|
|
|
q = q.Where(p => p.Total == p_entity.Total); |
|
|
|
} |
|
|
|
if (!string.IsNullOrEmpty(p_entity.ExpressNum)) |
|
|
|
{ |
|
|
|
q = q.Where(p => p.ExpressNum.Contains(p_entity.ExpressNum)); |
|
|
|
} |
|
|
|
if (p_entity.UserInAddress != null && p_entity.UserInAddress.Count > 0) |
|
|
|
{ |
|
|
|
q = q.Where(p => p_entity.UserInAddress.Contains(p.Site)); |
|
|
|
} |
|
|
|
|
|
|
|
if (!string.IsNullOrEmpty(p_entity.CreateUser)) |
|
|
|
{ |
|
|
|
q = q.Where(p => p.CreateUser.Contains(p_entity.CreateUser)); |
|
|
|
} |
|
|
|
if (p_entity.InvoiceList != null && p_entity.InvoiceList.Count > 0) |
|
|
|
{ |
|
|
|
q = q.Where(p => p_entity.InvoiceList.Contains(p.InvcBillNum)); |
|
|
|
} |
|
|
|
if (p_entity.EndTimeb != null) |
|
|
|
{ |
|
|
|
q = q.Where(p => p.EndTimeb == p_entity.EndTimeb); |
|
|
|
} |
|
|
|
if (p_entity.StartTime != null) |
|
|
|
{ |
|
|
|
q = q.Where(p => p.StartTime == p_entity.StartTime); |
|
|
|
} |
|
|
|
if (!string.IsNullOrEmpty(p_entity.SubSite)) |
|
|
|
{ |
|
|
|
q = q.Where(p => p.SubSite == p_entity.SubSite); |
|
|
|
} |
|
|
|
// q = q.Where(p => p_entity.IsRed == p.IsRed);
|
|
|
|
|
|
|
|
_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_TB_INVOICE_List_BYInvcBillNum", 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_TB_INVOICE_List_BYInvcBillNum", 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_TB_INVOICE_List_BYInvcBillNum", 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_TB_INVOICE_List_BYInvcBillNum", e.Message); |
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
public static void Get_V_TB_INVOICE_List(List<string> p_ls, Action<ResultObject<IQueryable<V_TB_INVOICE>>> p_action) |
|
|
|
{ |
|
|
@ -1004,6 +1159,171 @@ namespace CK.SCP.Controller |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// 通过InvcBillNum查询明细
|
|
|
|
/// </summary>
|
|
|
|
/// <param name="p_entity"></param>
|
|
|
|
/// <param name="p_action"></param>
|
|
|
|
public static void Get_V_TB_INVOICE_DETAIL_List_BYInvcBillNum(V_TB_INVOICE_DETAIL p_entity, Action<ResultObject<IQueryable<V_TB_INVOICE_DETAIL>>> p_action) |
|
|
|
{ |
|
|
|
ResultObject<IQueryable<V_TB_INVOICE_DETAIL>> _ret = new ResultObject<IQueryable<V_TB_INVOICE_DETAIL>>(); |
|
|
|
try |
|
|
|
{ |
|
|
|
using (ScpEntities db = EntitiesFactory.CreateScpInstance()) |
|
|
|
{ |
|
|
|
IQueryable<V_TB_INVOICE_DETAIL> q = db.V_TB_INVOICE_DETAIL; |
|
|
|
if (p_entity.UID != 0) |
|
|
|
{ |
|
|
|
q = q.Where(p => p.UID == p_entity.UID); |
|
|
|
} |
|
|
|
if (!string.IsNullOrEmpty(p_entity.InvcBillNum)) |
|
|
|
{ |
|
|
|
q = q.Where(p => p.InvcBillNum ==p_entity.InvcBillNum); |
|
|
|
} |
|
|
|
if (!string.IsNullOrEmpty(p_entity.PoBillNum)) |
|
|
|
{ |
|
|
|
q = q.Where(p => p.PoBillNum.Contains(p_entity.PoBillNum)); |
|
|
|
} |
|
|
|
if (p_entity.PoLineNum != 0) |
|
|
|
{ |
|
|
|
q = q.Where(p => p.PoLineNum == p_entity.PoLineNum); |
|
|
|
} |
|
|
|
if (!string.IsNullOrEmpty(p_entity.AsnBillNum)) |
|
|
|
{ |
|
|
|
q = q.Where(p => p.AsnBillNum.Contains(p_entity.AsnBillNum)); |
|
|
|
} |
|
|
|
if (!string.IsNullOrEmpty(p_entity.PartCode)) |
|
|
|
{ |
|
|
|
q = q.Where(p => p.PartCode.Contains(p_entity.PartCode)); |
|
|
|
} |
|
|
|
if (!string.IsNullOrEmpty(p_entity.Batch)) |
|
|
|
{ |
|
|
|
q = q.Where(p => p.Batch.Contains(p_entity.Batch)); |
|
|
|
} |
|
|
|
if (!string.IsNullOrEmpty(p_entity.VendBatch)) |
|
|
|
{ |
|
|
|
q = q.Where(p => p.VendBatch.Contains(p_entity.VendBatch)); |
|
|
|
} |
|
|
|
if (p_entity.Qty != 0) |
|
|
|
{ |
|
|
|
q = q.Where(p => p.Qty == p_entity.Qty); |
|
|
|
} |
|
|
|
if (!string.IsNullOrEmpty(p_entity.PoUnit)) |
|
|
|
{ |
|
|
|
q = q.Where(p => p.PoUnit.Contains(p_entity.PoUnit)); |
|
|
|
} |
|
|
|
if (p_entity.Price != 0) |
|
|
|
{ |
|
|
|
q = q.Where(p => p.Price == p_entity.Price); |
|
|
|
} |
|
|
|
if (!string.IsNullOrEmpty(p_entity.Currency)) |
|
|
|
{ |
|
|
|
q = q.Where(p => p.Currency.Contains(p_entity.Currency)); |
|
|
|
} |
|
|
|
if (p_entity.PackQty != null) |
|
|
|
{ |
|
|
|
q = q.Where(p => p.PackQty == p_entity.PackQty); |
|
|
|
} |
|
|
|
if (p_entity.State != null) |
|
|
|
{ |
|
|
|
q = q.Where(p => p.State == p_entity.State); |
|
|
|
} |
|
|
|
if (!string.IsNullOrEmpty(p_entity.InvoiceNum)) |
|
|
|
{ |
|
|
|
q = q.Where(p => p.InvoiceNum.Contains(p_entity.InvoiceNum)); |
|
|
|
} |
|
|
|
if (!string.IsNullOrEmpty(p_entity.ExpressNum)) |
|
|
|
{ |
|
|
|
q = q.Where(p => p.ExpressNum.Contains(p_entity.ExpressNum)); |
|
|
|
} |
|
|
|
if (!string.IsNullOrEmpty(p_entity.VendId)) |
|
|
|
{ |
|
|
|
q = q.Where(p => p.VendId.Contains(p_entity.VendId)); |
|
|
|
} |
|
|
|
if (!string.IsNullOrEmpty(p_entity.CurrencyDesc)) |
|
|
|
{ |
|
|
|
q = q.Where(p => p.CurrencyDesc.Contains(p_entity.CurrencyDesc)); |
|
|
|
} |
|
|
|
if (!string.IsNullOrEmpty(p_entity.Site)) |
|
|
|
{ |
|
|
|
q = q.Where(p => p.Site.Contains(p_entity.Site)); |
|
|
|
} |
|
|
|
if (p_entity.Tax != null) |
|
|
|
{ |
|
|
|
q = q.Where(p => p.Tax == p_entity.Tax); |
|
|
|
} |
|
|
|
if (!string.IsNullOrEmpty(p_entity.RecvBillNum)) |
|
|
|
{ |
|
|
|
q = q.Where(p => p.RecvBillNum.Contains(p_entity.RecvBillNum)); |
|
|
|
} |
|
|
|
if (!string.IsNullOrEmpty(p_entity.PartDesc1)) |
|
|
|
{ |
|
|
|
q = q.Where(p => p.PartDesc1.Contains(p_entity.PartDesc1)); |
|
|
|
} |
|
|
|
if (!string.IsNullOrEmpty(p_entity.CreateUser)) |
|
|
|
{ |
|
|
|
q = q.Where(p => p.CreateUser.Contains(p_entity.CreateUser)); |
|
|
|
} |
|
|
|
q = q.Where(p => p.IsRed == p_entity.IsRed); |
|
|
|
|
|
|
|
_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_TB_INVOICE_DETAIL_List_BYInvcBillNum", 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_TB_INVOICE_DETAIL_List_BYInvcBillNum", 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_TB_INVOICE_DETAIL_List_BYInvcBillNum", 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_TB_INVOICE_DETAIL_List_BYInvcBillNum", e.Message); |
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
public static void Get_V_TB_INVOICE_DETAIL_List(List<string> p_list, Action<ResultObject<IQueryable<V_TB_INVOICE_DETAIL>>> p_action) |
|
|
|
{ |
|
|
|