 |
|
เรียงข้อมูล id จาก 2 dataGridView ให้โชว์ออกมาเหมือนกัน ยังไงครับ? |
|
 |
|
|
 |
 |
|
ทั้ง dataGridView1 และ dataGridView2
อยากให้แสดงผลของข้อมูล เหมือนกัน
เริ่มจากเลขสมาชิก น้อยสุด ไปมากสุด
ทั้ง 2 dataGridView ต้องทำยังไงครับ
เพราะเอา orderby ไปใส่ แล้วก็ยังเหมือนเดิม
Code (C#)
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();
Tag : .NET, LINQ, C#
|
|
 |
 |
 |
 |
Date :
2012-09-18 14:42:22 |
By :
โบโน |
View :
1709 |
Reply :
3 |
|
 |
 |
 |
 |
|
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
ตอนนี้มันแสดงผลยังไงครับ ลอง Capture หน้าจอมาให้ดูหน่อยครับ 
|
 |
 |
 |
 |
Date :
2012-09-18 20:50:25 |
By :
mr.win |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
ขอบคุณครับพี่วิน
ตารางบน เรียงข้อมูลตาม เลขสมาชิก จากน้อยไปมาก คือ เรียง c2 จากน้อยไปมาก เสร็จแล้ว จึงเรียง c1 ต่อจากน้อยไปมากต่อ
ส่วนตาราง ล่าง เรียง จาก สมาชิกคนแรกที่เริ่มกรองลงฐานข้อมูล จนถึงคนสุดท้ายที่กรอกลงฐานข้อมูล
ซึ่งข้อมูลช่อง c1 ในตารางบน กับ ช่องข้อมูล ปกติ ในตารางล่าง คือ เลขสมาชิกแบบปกติ
ส่วนข้อมูลช่อง c2 ในตารางบน กับข้อมูลช่อง คู่สมรส ในตารางล่าง คือ เลขสมาชิกแบบคู่สมรส

|
ประวัติการแก้ไข 2012-09-19 08:53:33 2012-09-19 08:54:16 2012-09-19 08:59:46 2012-09-19 09:00:27
 |
 |
 |
 |
Date :
2012-09-19 08:43:45 |
By :
โบโน |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
ช่วยด้วยครับ ท่านพี่ทั้งหลาย !
อยากให้ dataGridView1 แสดงผลเรียงลำดับข้อมูลเหมือน dataGridView2
หรือ dataGridView2 แสดงผลเรียงลำดับข้อมูลเหมือน dataGridView1 ก็ได้ครับ
Code (C#)
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();
|
ประวัติการแก้ไข 2012-12-04 14:56:46 2012-12-04 14:58:05 2012-12-04 14:59:07 2012-12-04 15:03:13
 |
 |
 |
 |
Date :
2012-12-04 14:51:34 |
By :
โบโน |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
|
|