private void button8_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
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
let ชำระ1 = g.Sum(m => Convert.ToInt32(m.n.m_c))
let ชำระ2 = g.Sum(m => Convert.ToInt32(m.n.m_c_m))
select new
{
ปกติ ,
คู่สมรส,
ชื่อ ,
สถานะ ,
ชำระ1 ,
ชำระ2
}).OrderBy(o => o.ปกติ);
dataGridView2.DataSource = nn.ToList();
label6.Text = dataGridView2.RowCount.ToString();
}
private void button8_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
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
let ชำระ1 = g.Sum(m => Convert.ToInt32(m.n.m_c))
let ชำระ2 = g.Sum(m => Convert.ToInt32(m.n.m_c_m))
select new
{
ปกติ ,
คู่สมรส,
ชื่อ ,
สถานะ ,
ชำระ1 ,
ชำระ2
}).OrderBy(a => a.ปกติ).ThenBy(b => b.คู่สมรส);