diff --git a/北京北汽/Controller/SCP_INVOICE_CONTROLLER.cs b/北京北汽/Controller/SCP_INVOICE_CONTROLLER.cs index 98f5b27..cba7ac0 100644 --- a/北京北汽/Controller/SCP_INVOICE_CONTROLLER.cs +++ b/北京北汽/Controller/SCP_INVOICE_CONTROLLER.cs @@ -161,6 +161,57 @@ namespace CK.SCP.Controller } + /// + /// 发票管理按供应商id 地点域查单号 + /// + /// + /// + /// + /// + /// + /// + public static List 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 _list = new List(); + 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(_builder.ToString()).ToList(); + + } + return _list; + } @@ -190,12 +241,171 @@ namespace CK.SCP.Controller { _builder.AppendFormat(" and A.AsnBillNum='{0}' \r\n",p_asn); } + _list =db.Database.SqlQuery(_builder.ToString()).ToList(); } return _list; } + /// + /// 查询等于供应商的发票 + /// + /// + /// + public static void Get_V_TB_INVOICE_List_ByVendID(V_TB_INVOICE p_entity, Action>> p_action) + { + ResultObject> _ret = new ResultObject>(); + try + { + using (ScpEntities db = EntitiesFactory.CreateScpInstance()) + { + IQueryable 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>> p_action) { diff --git a/北京北汽/Models/ScpEntity/V_TB_ASK.cs b/北京北汽/Models/ScpEntity/V_TB_ASK.cs index 15ffd0a..844d802 100644 --- a/北京北汽/Models/ScpEntity/V_TB_ASK.cs +++ b/北京北汽/Models/ScpEntity/V_TB_ASK.cs @@ -82,6 +82,7 @@ namespace CK.SCP.Models.ScpEntity public string PartCode { get; set; } [NotMapped] public string PartCodeDesc { get; set; } + public string Extend1 { get; set; } #endregion } } diff --git a/北京北汽/SCP/Views/SupplierData/SCP_INVOICE.aspx.cs b/北京北汽/SCP/Views/SupplierData/SCP_INVOICE.aspx.cs index c817559..e3d72f5 100644 --- a/北京北汽/SCP/Views/SupplierData/SCP_INVOICE.aspx.cs +++ b/北京北汽/SCP/Views/SupplierData/SCP_INVOICE.aspx.cs @@ -42,7 +42,7 @@ namespace SCP.Views.SupplierData public void BindInvoice() { SearchInvoice(ret => - { + { Grid_V_TB_INVOICE.RecordCount = ret.Count(); ret = SortAndPage(ret, Grid_V_TB_INVOICE); //ret.ToList().ForEach(itm => @@ -85,12 +85,12 @@ namespace SCP.Views.SupplierData { _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)) { 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) {