private void button9_Click(object sender, EventArgs e)
{
var nn = (from n in db.b_moneys
from m in db.b_startmoneys
from o in db.b_members
where
o.id_s == m.st_id_s
&& o.id_k == m.st_id_k
&& n.m_c_my >= m.st_date
orderby m.st_id_k ,m.st_id_s
group new { n, o } by o.id_id into g
let ปกติ = g.FirstOrDefault().o.id_s
let คู่สมรส = g.FirstOrDefault().o.id_k
let ชื่อ = g.FirstOrDefault().o.name
let สถานะ = g.FirstOrDefault().o.status1
select new
{
ปกติ,
คู่สมรส,
ชื่อ,
สถานะ,
ชำระ1 = g.Sum(m => Convert.ToInt32(m.n.m_c)),
ชำระ2 = g.Sum(m => Convert.ToInt32(m.n.m_c_m))
});
dataGridView2.DataSource = nn.ToList();
label6.Text = dataGridView2.RowCount.ToString();
var q13 = (from o in db.b_bills
group o by new { o.bill_id_s, o.bill_id_k } into g
let c0 = g.First().bill_user
let c1 = g.Key.bill_id_s
let c2 = g.Key.bill_id_k
let c3 = g.ToArray()
select new
{
c0,
c1,
c2,
c3
}
).Select(s => new
{
s.c0,
s.c1,
s.c2,
Total = s.c3.Sum(p => Convert.ToInt32(p.bill_money))
});
this.dataGridView1.DataSource = q13.ToList();
label5.Text = dataGridView1.RowCount.ToString();
var nn = (from n in db.b_moneys
from m in db.b_startmoneys
from o in db.b_members
where
o.id_s == m.st_id_s
&& o.id_k == m.st_id_k
&& n.m_c_my >= m.st_date
group new { n, o } by o.id_id into g
let ปกติ = g.FirstOrDefault().o.id_s.Trim()
let คู่สมรส = g.FirstOrDefault().o.id_k.Trim()
let ชื่อ = g.FirstOrDefault().o.name.Trim()
let สถานะ = g.FirstOrDefault().o.status1.Trim()
select new
{
ปกติ,
คู่สมรส,
ชื่อ,
สถานะ = g.FirstOrDefault().o.status1.Trim(),
ชำระ1 = g.Sum(m => Convert.ToInt32(m.n.m_c)),
ชำระ2 = g.Sum(m => Convert.ToInt32(m.n.m_c_m))
}).OrderBy(o => o.ปกติ);
dataGridView2.DataSource = nn.ToList();
label6.Text = dataGridView2.RowCount.ToString();
var q13 = (from o in db.b_bills
group o by new { o.bill_id_s, o.bill_id_k } into g
let c0 = g.First().bill_user
let c1 = g.Key.bill_id_s
let c2 = g.Key.bill_id_k
let c3 = g.ToArray()
select new
{
c0,
c1,
c2,
c3
}
).Select(s => new
{
s.c0,
s.c1,
s.c2,
Total = s.c3.Sum(p => Convert.ToInt32(p.bill_money))
});
this.dataGridView1.DataSource = q13.ToList();
label5.Text = dataGridView1.RowCount.ToString();