示例#1
0
        private void btnXemTKB_Click(object sender, EventArgs e)
        {
            this.Dispose();
            XemTKB tkb = new XemTKB();

            tkb.ShowDialog();
        }
示例#2
0
 private void btnXemTKB_Click(object sender, EventArgs e)
 {
     if (btnXemTKB.Enabled == true)
     {
         XemTKB xtkb = new XemTKB();
         XepThoiKhoaBieuEntities xl = new XepThoiKhoaBieuEntities();
         for (int ni = 0; ni < 6; ni++)
         {
             xtkb.dgvTKB.Rows.Add();
             if (ni == 0)
             {
                 xtkb.dgvTKB.Rows[ni].Cells[0].Value = "Thứ 2";
             }
             if (ni == 1)
             {
                 xtkb.dgvTKB.Rows[ni].Cells[0].Value = "Thứ 3";
             }
             if (ni == 2)
             {
                 xtkb.dgvTKB.Rows[ni].Cells[0].Value = "Thứ 4";
             }
             if (ni == 3)
             {
                 xtkb.dgvTKB.Rows[ni].Cells[0].Value = "Thứ 5";
             }
             if (ni == 4)
             {
                 xtkb.dgvTKB.Rows[ni].Cells[0].Value = "Thứ 6";
             }
             if (ni == 5)
             {
                 xtkb.dgvTKB.Rows[ni].Cells[0].Value = "Thứ 7";
             }
         }
         var tenl =
             from d in xl.Lops
             select d;
         int cel = 1;
         foreach (var lh in tenl)
         {
             xtkb.dgvTKB.Columns[cel].HeaderText = lh.TenLop;
             string t2   = null;
             string t3   = null;
             string t4   = null;
             string t5   = null;
             string t6   = null;
             string t7   = null;
             int    dem2 = 1;
             int    dem3 = 1;
             int    dem4 = 1;
             int    dem5 = 1;
             int    dem6 = 1;
             int    dem7 = 1;
             var    ttkb =
                 from d in tkb
                 where d.MaLop == lh.MaLop
                 orderby d.MaTiet
                 select d;
             foreach (var t in ttkb)
             {
                 if (t.MaTiet <= 10)
                 {
                     var tenm =
                         from d in xl.MonHocs
                         where d.MaMH == t.MaMH
                         select d;
                     foreach (var gv in tenm)
                     {
                         if (dem2 < 4)
                         {
                             t2 += gv.TenMH + ", ";
                         }
                         else
                         {
                             t2 += gv.TenMH;
                         }
                         dem2++;
                     }
                     if (Compare(lh.TenLop.ToString(), "12") == true ||
                         (Compare(lh.TenLop.ToString(), "11") == true && lh.MaBan == 1))
                     {
                         if (dem2 == 5)
                         {
                             t2 = "Chào cờ, " + t2;
                         }
                     }
                     else
                     {
                         if (dem2 == 5)
                         {
                             t2 += ", Chào cờ";
                         }
                     }
                     xtkb.dgvTKB.Rows[0].Cells[cel].Value = t2;
                 }
                 else if (t.MaTiet > 10 && t.MaTiet <= 20)
                 {
                     var tenm =
                         from d in xl.MonHocs
                         where d.MaMH == t.MaMH
                         select d;
                     foreach (var gv in tenm)
                     {
                         if (dem3 < 5)
                         {
                             t3 += gv.TenMH + ", ";
                         }
                         else
                         {
                             t3 += gv.TenMH;
                         }
                         dem3++;
                     }
                     xtkb.dgvTKB.Rows[1].Cells[cel].Value = t3;
                 }
                 else if (t.MaTiet > 20 && t.MaTiet <= 30)
                 {
                     var tenm =
                         from d in xl.MonHocs
                         where d.MaMH == t.MaMH
                         select d;
                     foreach (var gv in tenm)
                     {
                         if (dem4 < 5)
                         {
                             t4 += gv.TenMH + ", ";
                         }
                         else
                         {
                             t4 += gv.TenMH;
                         }
                         dem4++;
                     }
                     xtkb.dgvTKB.Rows[2].Cells[cel].Value = t4;
                 }
                 else if (t.MaTiet > 30 && t.MaTiet <= 40)
                 {
                     var tenm =
                         from d in xl.MonHocs
                         where d.MaMH == t.MaMH
                         select d;
                     foreach (var gv in tenm)
                     {
                         if (dem5 < 5)
                         {
                             t5 += gv.TenMH + ", ";
                         }
                         else
                         {
                             t5 += gv.TenMH;
                         }
                         dem5++;
                     }
                     xtkb.dgvTKB.Rows[3].Cells[cel].Value = t5;
                 }
                 else if (t.MaTiet > 40 && t.MaTiet <= 50)
                 {
                     var tenm =
                         from d in xl.MonHocs
                         where d.MaMH == t.MaMH
                         select d;
                     foreach (var gv in tenm)
                     {
                         if (dem6 < 4)
                         {
                             t6 += gv.TenMH + ", ";
                         }
                         else
                         {
                             t6 += gv.TenMH;
                         }
                         dem6++;
                     }
                     xtkb.dgvTKB.Rows[4].Cells[cel].Value = t6;
                 }
                 else if (t.MaTiet > 50 && t.MaTiet <= 60)
                 {
                     var tenm =
                         from d in xl.MonHocs
                         where d.MaMH == t.MaMH
                         select d;
                     foreach (var gv in tenm)
                     {
                         if (dem7 < 3)
                         {
                             t7 += gv.TenMH + ", ";
                         }
                         else
                         {
                             t7 += gv.TenMH;
                         }
                         dem7++;
                     }
                     xtkb.dgvTKB.Rows[5].Cells[cel].Value = t7;
                 }
             }
             cel++;
         }
         xtkb.ShowDialog();
     }
 }