8,497
社区成员
发帖
与我相关
我的任务
分享
private void GvDataBind()
{
var contracts = from c in db.B_Contract_Out
join h in db.B_Hospital on c.HospitalID equals h.ID into ch
where c.C4 == "1"
from chs in ch.DefaultIfEmpty()
join u in db.sys_User on c.PrincipalUser equals u.UserID into cu
from cus in cu.DefaultIfEmpty()
orderby c.ContractDate descending
join p in db.B_PayRecord on c.ID equals p.ContractID into cp
from cps in cp.DefaultIfEmpty()
where c.AllMoney != Convert.ToDouble(cps.PayMoney)
//where c.AllMoney!= payedmoney
orderby c.ContractDate descending
select new { ArmNames = GetArmariumName(c.ID), ArmOutPrice = GetArmOutPrice(c.ID), c.C1, c.ID,
c.ContractDate,c.ContactNum, cus.U_CName, c.AllMoney, chs.HospitalName, qiankuan = GetQianKuan(Convert.ToDouble(c.AllMoney), c.ID) };
var query = from c in contracts
group c by c.ContactNum into g
select new { contactNum = g.Key, Sum = g.Sum(x => x.qiankuan) };
this.DataPager.RecordCount = contracts.Count();
this.DataPager.RecordCount = query.Count();
//.net的自定义分页
PagedDataSource pds = new PagedDataSource();
pds.AllowPaging = true;
pds.PageSize = PAGESIZE;
pds.CurrentPageIndex = DataPager.CurrentPageIndex - 1;
pds.DataSource = contracts.ToList();
pds.DataSource = query.ToList();
GvContract.DataSource = pds;
GvContract.DataBind();
}