Browse Source

北汽优化

master
qian 2 months ago
parent
commit
0b2fdfb438
  1. 210
      北京北汽/Controller/SCP_INVOICE_CONTROLLER.cs
  2. 1
      北京北汽/Models/ScpEntity/V_TB_ASK.cs
  3. 6
      北京北汽/SCP/Views/SupplierData/SCP_INVOICE.aspx.cs

210
北京北汽/Controller/SCP_INVOICE_CONTROLLER.cs

@ -161,6 +161,57 @@ namespace CK.SCP.Controller
} }
/// <summary>
/// 发票管理按供应商id 地点域查单号
/// </summary>
/// <param name="p_begin"></param>
/// <param name="p_end"></param>
/// <param name="p_po"></param>
/// <param name="p_asn"></param>
/// <param name="p_entity"></param>
/// <returns></returns>
public static List<string> Get_V_TB_INVOICE_BY_TIME_ANDENTITY(string p_begin, string p_end, string p_po, string p_asn, V_TB_INVOICE p_entity)
{
List<string> _list = new List<string>();
using (ScpEntities db = EntitiesFactory.CreateScpInstance())
{
StringBuilder _builder = new StringBuilder();
_builder.Append("SELECT DISTINCT InvcBillNum FROM TB_INVOICE_DETAIL a Inner join TB_RECEIVE B on A.RecvBillNum = B.RecvBillNum\r\n");
_builder.AppendFormat(" WHERE 1=1 \r\n");
if (!string.IsNullOrEmpty(p_begin))
{
_builder.AppendFormat(" and B.ShipTime >= cast('{0}' as datetime) \r\n", p_begin);
}
if (!string.IsNullOrEmpty(p_end))
{
_builder.AppendFormat(" and B.ShipTime <= cast('{0}' as datetime) \r\n", p_end);
}
if (!string.IsNullOrEmpty(p_po))
{
_builder.AppendFormat(" AND A.PoBillNum='{0}' \r\n", p_po);
}
if (!string.IsNullOrEmpty(p_asn))
{
_builder.AppendFormat(" and A.AsnBillNum='{0}' \r\n", p_asn);
}
if (!string.IsNullOrEmpty(p_entity.VendId))
{
_builder.AppendFormat(" and B.VendId = '{0}' \r\n ",p_entity.VendId);
}
if (!string.IsNullOrEmpty(p_entity.SubSite))
{
_builder.AppendFormat(" and B.SubSite = '{0}' \r\n ", p_entity.SubSite);
}
if (!string.IsNullOrEmpty(p_entity.Site))
{
_builder.AppendFormat(" and B.Site = '{0}' \r\n ", p_entity.Site);
}
_list = db.Database.SqlQuery<string>(_builder.ToString()).ToList();
}
return _list;
}
@ -190,12 +241,171 @@ namespace CK.SCP.Controller
{ {
_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;
} }
/// <summary>
/// 查询等于供应商的发票
/// </summary>
/// <param name="p_entity"></param>
/// <param name="p_action"></param>
public static void Get_V_TB_INVOICE_List_ByVendID(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.Contains(p_entity.InvcBillNum));
}
if (!string.IsNullOrEmpty(p_entity.VendId))
{
q = q.Where(p => p.VendId == 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_ByVendID", 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_ByVendID", 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_ByVendID", 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_ByVendID", e.Message);
throw e;
}
}
public static void Get_V_TB_INVOICE_List(V_TB_INVOICE p_entity, Action<ResultObject<IQueryable<V_TB_INVOICE>>> p_action) public static void Get_V_TB_INVOICE_List(V_TB_INVOICE p_entity, Action<ResultObject<IQueryable<V_TB_INVOICE>>> p_action)
{ {

1
北京北汽/Models/ScpEntity/V_TB_ASK.cs

@ -82,6 +82,7 @@ namespace CK.SCP.Models.ScpEntity
public string PartCode { get; set; } public string PartCode { get; set; }
[NotMapped] [NotMapped]
public string PartCodeDesc { get; set; } public string PartCodeDesc { get; set; }
public string Extend1 { get; set; }
#endregion #endregion
} }
} }

6
北京北汽/SCP/Views/SupplierData/SCP_INVOICE.aspx.cs

@ -42,7 +42,7 @@ namespace SCP.Views.SupplierData
public void BindInvoice() public void BindInvoice()
{ {
SearchInvoice(ret => SearchInvoice(ret =>
{ {
Grid_V_TB_INVOICE.RecordCount = ret.Count(); Grid_V_TB_INVOICE.RecordCount = ret.Count();
ret = SortAndPage(ret, Grid_V_TB_INVOICE); ret = SortAndPage(ret, Grid_V_TB_INVOICE);
//ret.ToList().ForEach(itm => //ret.ToList().ForEach(itm =>
@ -85,12 +85,12 @@ namespace SCP.Views.SupplierData
{ {
_entity.SubSite = CurrentUser.UserdSite; _entity.SubSite = CurrentUser.UserdSite;
} }
_entity.InvoiceList = SCP_INVOICE_CONTROLLER.Get_V_TB_INVOICE_BY_TIME(DP_CreateTime1.Text, DP_CreateTime2.Text,TXT_PO.Text,TXT_ASN.Text); _entity.InvoiceList = SCP_INVOICE_CONTROLLER.Get_V_TB_INVOICE_BY_TIME_ANDENTITY(DP_CreateTime1.Text, DP_CreateTime2.Text,TXT_PO.Text,TXT_ASN.Text, _entity);
if (string.IsNullOrEmpty(_entity.VendId)) if (string.IsNullOrEmpty(_entity.VendId))
{ {
return; return;
} }
SCP_INVOICE_CONTROLLER.Get_V_TB_INVOICE_List(_entity, (ret) => SCP_INVOICE_CONTROLLER.Get_V_TB_INVOICE_List_ByVendID(_entity, (ret) =>
{ {
if (ret.State == ReturnStatus.Succeed) if (ret.State == ReturnStatus.Succeed)
{ {

Loading…
Cancel
Save