protected void btnQuery_Click(object sender, EventArgs e) { btnClearMX.Visible = true; itemMX.Visible = true; HZ.Visible = false; IList <BillDetail> result = TheBillMgr.LoadBill(this.BillNo, true).BillDetails; IList <BillDetail> ds = (from i in result where i.ActingBill.Item.Code == itemInList.SelectedValue select i).ToList(); itemMX.DataSource = ds; itemMX.DataBind(); tbshowTotal.Text = "零件总数:" + ds.Sum(i => i.BilledQty).ToString("0"); }
protected void btnTongji_Click(object sender, EventArgs e) { IList <BillDetail> result = TheBillMgr.LoadBill(this.BillNo, true).BillDetails; var gp = (from i in result group i by new { i.ActingBill.Item.Code, i.ActingBill.ReferenceItemCode, i.ActingBill.Item.Description } into g select new { g.Key.Code, g.Key.ReferenceItemCode, g.Key.Description, Amount = g.Sum(i => i.BilledQty) }).ToList(); HZ.DataSource = gp; HZ.DataBind(); HZ.Visible = true; field.Visible = true; mx.Visible = true; tbshowTotal.Text = "零件总数:" + gp.Sum(i => i.Amount).ToString("0"); itemInList.DataSource = gp.Select(i => i.Code); itemInList.DataBind(); itemMX.Visible = false; btnClearMX.Visible = false; }