8,497
社区成员
发帖
与我相关
我的任务
分享
private bool FiltVisitor(VisitingInfo v, string visitorName, string visitorCorp, string revEmpName,
string fromVisitTime, string toVisitTime, string token)
{
bool ret = true;
if (!string.IsNullOrEmpty(visitorName))
ret &= v.VisitorName.Contains(visitorName);
if (!string.IsNullOrEmpty(visitorCorp))
ret &= v.VisitorCorp.Contains(visitorCorp);
if (!string.IsNullOrEmpty(revEmpName))
ret &= v.RevEmpName.Contains(revEmpName);
if (!string.IsNullOrEmpty(fromVisitTime))
ret &= v.VisitorComeTime >= Convert.ToDateTime(fromVisitTime);
if (!string.IsNullOrEmpty(toVisitTime))
ret &= v.VisitorComeTime <= Convert.ToDateTime(toVisitTime);
return ret;
}
System.Linq.Expressions.Expression<Func<VisitingInfo, bool>> exp = v =>
FiltVisitor(v, visitorName, visitorCorp, revEmpName, fromVisitTime, toVisitTime, token);
result.Data = this.GetVisitingInfo(fromVisitTime, toVisitTime).VisitingInfos.AsEnumerable().Where(exp.Compile());
var query1 =
(from t in ds.Tables[0].AsEnumerable()
where Convert.ToInt32(t.Field<string>("gather_month")) <= b1
select new { user_no = t.Field<string>("user_no") }).Distinct();
var query2 =
(from t in ds.Tables[0].AsEnumerable()
group t by t.Field<string>("user_no") into g
let fact_charge = g.Sum(p => p.Field<decimal>("fact_charge"))
where fact_charge > c
select new { user_no = g.Key }).Distinct();
var query3 =
(from t in ds.Tables[0].AsEnumerable()
group t by t.Field<string>("user_no") into g
where g.Count() > d
select new { user_no = g.Key }).Distinct();
var query4=
(from t in ds.Tables[0].AsEnumerable()
where t.Field<string>("volpage").Substring(0, 7)==f.ToString()
select new { user_no = t.Field<string>("user_no") }).Distinct();
var refer =
from t in ds.Tables[0].AsEnumerable()
.Where(x => b >= 0 ? query1.AsEnumerable().Select(p => p.user_no).Contains (x.Field<string>("user_no")) : true)
.Where(x => c >= 0 && c != 1000000000 ? query2.AsEnumerable().Select(p => p.user_no).Contains(x.Field<string>("user_no")) : true)
.Where(x => d >= 0 && d != 1000000000 ? query3.AsEnumerable().Select(p => p.user_no).Contains(x.Field<string>("user_no")) : true)
.Where(x => f != "" ? query4.AsEnumerable().Select(p => p.user_no).Contains(x.Field<string>("user_no")) : true)
.Where(x => h =="1" ? x.Field<string>("DY_flag") == "1":true)
.OrderBy(o => o.Field<string>("volpage")).OrderBy(p=>p.Field<string>("user_no")).OrderBy(q=>q.Field<string>("gather_month"))
select t;
if (refer.Count() == 0) //判断refer的记录是否为0
{
CreateColumnFooter();
CreateGroupFooter(1);
MessageBox.Show("没有符合此条件的选项,请重新输入", "信息提示", System.Windows.Forms.MessageBoxButtons.OK, System.Windows.Forms.MessageBoxIcon.Warning);
}
else
{
DataView filter = refer.AsDataView();
this.fpSpread1_Sheet1.DataSource = filter;}
var query4 =
from t in ds.Tables[0].AsEnumerable()
where query.Any(o=>o.user_no.ToString().Contains(t.Field<string>("user_no")))
orderby t.Field<string>("volpage"), t.Field<string>("user_no"), t.Field<string>("gather_month")
select t;