private new void Paint(int thu, int tietBD, int soTiet, string lop, string monHoc) { try { switch (soTiet) { case 1: MotTiet motTiet = new MotTiet(); motTiet.PhongHoc = lop; motTiet.MonHoc = monHoc; motTiet.Location = new Point(XThu[thu], YTiet[tietBD]); pnChinh.Controls.Add(motTiet); motTiet.BringToFront(); break; case 2: HaiTiet haiTiet = new HaiTiet(); haiTiet.PhongHoc = lop; haiTiet.MonHoc = monHoc; haiTiet.Location = new Point(XThu[thu], YTiet[tietBD]); pnChinh.Controls.Add(haiTiet); haiTiet.BringToFront(); break; case 3: BaTiet baTiet = new BaTiet(); baTiet.PhongHoc = lop; baTiet.MonHoc = monHoc; baTiet.Location = new Point(XThu[thu], YTiet[tietBD]); pnChinh.Controls.Add(baTiet); baTiet.BringToFront(); break; case 4: BonTiet bonTiet = new BonTiet(); bonTiet.PhongHoc = lop; bonTiet.MonHoc = monHoc; bonTiet.Location = new Point(XThu[thu], YTiet[tietBD]); pnChinh.Controls.Add(bonTiet); bonTiet.BringToFront(); break; case 5: NamTiet namTiet = new NamTiet(); namTiet.PhongHoc = lop; namTiet.MonHoc = monHoc; namTiet.Location = new Point(XThu[thu], YTiet[tietBD]); pnChinh.Controls.Add(namTiet); namTiet.BringToFront(); break; } } catch (Exception ex) { throw ex; } }
//mode == 0: đề nghị chưa được xếp thời khóa biểu //mode == 1: thời khóa biểu đang đucợ xếp nhưng chưa lưu vào CSDL //mode == 2: thời khóa biểu đã lưu vào CSDL rồi private new void Paint(string maPC, int maBuoiHoc, int thu, int tietBD, int soTiet, string monHoc, string giangVien, string lop, int mode, string maGV, string maMH) { try { switch (soTiet) { case 1: MotTiet motTiet = new MotTiet(); motTiet.PhongHoc = lop; motTiet.MonHoc = monHoc + "\n" + giangVien; motTiet.Location = new Point(XThu[thu], YTiet[tietBD]); if (mode == 0) //de nghi { motTiet.Cursor = Cursors.Hand; motTiet.Controls.Remove(motTiet.lblMonHoc); motTiet.Controls.Remove(motTiet.lblPhong); motTiet.Click += new EventHandler(XepTKB); } else if (mode == 1) //dang xep { motTiet.lblMonHoc.Cursor = Cursors.Hand; motTiet.lblMonHoc.Click += new EventHandler(RemoveTKB); motTiet.BackColor = Color.PaleTurquoise; ThongTinChiTietTKB(motTiet.lblMonHoc, motTiet.toolTipController1, monHoc, tietBD, soTiet, lop, maGV, giangVien, maMH); } else //da xep roi { motTiet.BackColor = Color.Gold; ThongTinChiTietTKB(motTiet.lblMonHoc, motTiet.toolTipController1, monHoc, tietBD, soTiet, lop, maGV, giangVien, maMH); motTiet.lblMonHoc.Cursor = Cursors.Hand; motTiet.lblMonHoc.Click += new EventHandler(XoaTKBDaXep); } motTiet.Name = "1" + ngayDauTuan.AddDays((int)thu).ToString("dd/MM/yyyy") + tietBD.ToString() + soTiet.ToString() + mode.ToString() + maPC + maBuoiHoc.ToString(); pnChinh.Controls.Add(motTiet); motTiet.BringToFront(); break; case 2: HaiTiet haiTiet = new HaiTiet(); haiTiet.PhongHoc = lop; haiTiet.MonHoc = monHoc + "\n" + giangVien; haiTiet.Location = new Point(XThu[thu], YTiet[tietBD]); if (mode == 0) //de nghi { haiTiet.Cursor = Cursors.Hand; haiTiet.Controls.Remove(haiTiet.lblMonHoc); haiTiet.Controls.Remove(haiTiet.lblPhong); haiTiet.Click += new EventHandler(XepTKB); } else if (mode == 1) //dang xep { haiTiet.lblMonHoc.Cursor = Cursors.Hand; haiTiet.lblMonHoc.Click += new EventHandler(RemoveTKB); haiTiet.BackColor = Color.PaleTurquoise; ThongTinChiTietTKB(haiTiet.lblMonHoc, haiTiet.toolTipController1, monHoc, tietBD, soTiet, lop, maGV, giangVien, maMH); } else //da xep roi { haiTiet.BackColor = Color.Gold; ThongTinChiTietTKB(haiTiet.lblMonHoc, haiTiet.toolTipController1, monHoc, tietBD, soTiet, lop, maGV, giangVien, maMH); haiTiet.lblMonHoc.Cursor = Cursors.Hand; haiTiet.lblMonHoc.Click += new EventHandler(XoaTKBDaXep); } haiTiet.Name = "2" + ngayDauTuan.AddDays((int)thu).ToString("dd/MM/yyyy") + tietBD.ToString() + soTiet.ToString() + mode.ToString() + maPC + maBuoiHoc.ToString(); pnChinh.Controls.Add(haiTiet); haiTiet.BringToFront(); break; case 3: BaTiet baTiet = new BaTiet(); baTiet.PhongHoc = lop; baTiet.MonHoc = monHoc + "\n" + giangVien; baTiet.Location = new Point(XThu[thu], YTiet[tietBD]); if (mode == 0) //de nghi { baTiet.Cursor = Cursors.Hand; baTiet.Controls.Remove(baTiet.lblMonHoc); baTiet.Controls.Remove(baTiet.lblPhong); baTiet.Click += new EventHandler(XepTKB); } else if (mode == 1) //dang xep { baTiet.lblMonHoc.Cursor = Cursors.Hand; baTiet.lblMonHoc.Click += new EventHandler(RemoveTKB); baTiet.BackColor = Color.PaleTurquoise; ThongTinChiTietTKB(baTiet.lblMonHoc, baTiet.toolTipController1, monHoc, tietBD, soTiet, lop, maGV, giangVien, maMH); } else //da xep roi { baTiet.BackColor = Color.Gold; ThongTinChiTietTKB(baTiet.lblMonHoc, baTiet.toolTipController1, monHoc, tietBD, soTiet, lop, maGV, giangVien, maMH); baTiet.lblMonHoc.Cursor = Cursors.Hand; baTiet.lblMonHoc.Click += new EventHandler(XoaTKBDaXep); } baTiet.Name = "3" + ngayDauTuan.AddDays((int)thu).ToString("dd/MM/yyyy") + tietBD.ToString() + soTiet.ToString() + mode.ToString() + maPC + maBuoiHoc.ToString(); pnChinh.Controls.Add(baTiet); baTiet.BringToFront(); break; case 4: BonTiet bonTiet = new BonTiet(); bonTiet.PhongHoc = lop; bonTiet.MonHoc = monHoc + "\n" + giangVien; bonTiet.Location = new Point(XThu[thu], YTiet[tietBD]); if (mode == 0) //de nghi { bonTiet.Cursor = Cursors.Hand; bonTiet.Controls.Remove(bonTiet.lblMonHoc); bonTiet.Controls.Remove(bonTiet.lblPhong); bonTiet.Click += new EventHandler(XepTKB); } else if (mode == 1) //dang xep { bonTiet.lblMonHoc.Cursor = Cursors.Hand; bonTiet.lblMonHoc.Click += new EventHandler(RemoveTKB); bonTiet.BackColor = Color.PaleTurquoise; ThongTinChiTietTKB(bonTiet.lblMonHoc, bonTiet.toolTipController1, monHoc, tietBD, soTiet, lop, maGV, giangVien, maMH); } else //da xep roi { bonTiet.BackColor = Color.Gold; ThongTinChiTietTKB(bonTiet.lblMonHoc, bonTiet.toolTipController1, monHoc, tietBD, soTiet, lop, maGV, giangVien, maMH); bonTiet.lblMonHoc.Cursor = Cursors.Hand; bonTiet.lblMonHoc.Click += new EventHandler(XoaTKBDaXep); } bonTiet.Name = "4" + ngayDauTuan.AddDays((int)thu).ToString("dd/MM/yyyy") + tietBD.ToString() + soTiet.ToString() + mode.ToString() + maPC + maBuoiHoc.ToString(); pnChinh.Controls.Add(bonTiet); bonTiet.BringToFront(); break; case 5: NamTiet namTiet = new NamTiet(); namTiet.PhongHoc = lop; namTiet.MonHoc = monHoc + "\n" + giangVien; namTiet.Location = new Point(XThu[thu], YTiet[tietBD]); if (mode == 0) //de nghi { namTiet.Cursor = Cursors.Hand; namTiet.Controls.Remove(namTiet.lblMonHoc); namTiet.Controls.Remove(namTiet.lblPhong); namTiet.Click += new EventHandler(XepTKB); } else if (mode == 1) //dang xep { namTiet.lblMonHoc.Cursor = Cursors.Hand; namTiet.lblMonHoc.Click += new EventHandler(RemoveTKB); namTiet.BackColor = Color.PaleTurquoise; ThongTinChiTietTKB(namTiet.lblMonHoc, namTiet.toolTipController1, monHoc, tietBD, soTiet, lop, maGV, giangVien, maMH); } else //da xep roi { namTiet.BackColor = Color.Gold; ThongTinChiTietTKB(namTiet.lblMonHoc, namTiet.toolTipController1, monHoc, tietBD, soTiet, lop, maGV, giangVien, maMH); namTiet.lblMonHoc.Cursor = Cursors.Hand; namTiet.lblMonHoc.Click += new EventHandler(XoaTKBDaXep); } namTiet.Name = "5" + ngayDauTuan.AddDays((int)thu).ToString("dd/MM/yyyy") + tietBD.ToString() + soTiet.ToString() + mode.ToString() + maPC + maBuoiHoc.ToString(); pnChinh.Controls.Add(namTiet); namTiet.BringToFront(); break; } } catch (Exception ex) { throw ex; } }
//mode == 2: thời khóa biểu đã lưu vào CSDL rồi private new void Paint(string maPC, int maBuoiHoc, int thu, int tietBD, int soTiet, string monHoc, string lop, string phong, int mode, string diaChi) { try { switch (soTiet) { case 1: MotTiet motTiet = new MotTiet(); motTiet.PhongHoc = phong; motTiet.MonHoc = monHoc; motTiet.Location = new Point(XThu[thu], YTiet[tietBD]); motTiet.BackColor = Color.Gold; ThongTinChiTietTKB(motTiet.lblMonHoc, motTiet.toolTipController1, monHoc, tietBD, soTiet, lop, phong, diaChi); motTiet.lblMonHoc.Cursor = Cursors.Hand; motTiet.Name = "1" + ngayDauTuan.AddDays((int)thu).ToString("dd/MM/yyyy") + tietBD.ToString() + soTiet.ToString() + mode.ToString() + maPC + maBuoiHoc.ToString(); pnChinh.Controls.Add(motTiet); motTiet.BringToFront(); break; case 2: HaiTiet haiTiet = new HaiTiet(); haiTiet.PhongHoc = phong; haiTiet.MonHoc = monHoc; haiTiet.Location = new Point(XThu[thu], YTiet[tietBD]); haiTiet.BackColor = Color.Gold; ThongTinChiTietTKB(haiTiet.lblMonHoc, haiTiet.toolTipController1, monHoc, tietBD, soTiet, lop, phong, diaChi); haiTiet.lblMonHoc.Cursor = Cursors.Hand; haiTiet.Name = "2" + ngayDauTuan.AddDays((int)thu).ToString("dd/MM/yyyy") + tietBD.ToString() + soTiet.ToString() + mode.ToString() + maPC + maBuoiHoc.ToString(); pnChinh.Controls.Add(haiTiet); haiTiet.BringToFront(); break; case 3: BaTiet baTiet = new BaTiet(); baTiet.PhongHoc = phong; baTiet.MonHoc = monHoc; baTiet.Location = new Point(XThu[thu], YTiet[tietBD]); baTiet.BackColor = Color.Gold; ThongTinChiTietTKB(baTiet.lblMonHoc, baTiet.toolTipController1, monHoc, tietBD, soTiet, lop, phong, diaChi); baTiet.lblMonHoc.Cursor = Cursors.Hand; baTiet.Name = "3" + ngayDauTuan.AddDays((int)thu).ToString("dd/MM/yyyy") + tietBD.ToString() + soTiet.ToString() + mode.ToString() + maPC + maBuoiHoc.ToString(); pnChinh.Controls.Add(baTiet); baTiet.BringToFront(); break; case 4: BonTiet bonTiet = new BonTiet(); bonTiet.PhongHoc = phong; bonTiet.MonHoc = monHoc; bonTiet.Location = new Point(XThu[thu], YTiet[tietBD]); bonTiet.BackColor = Color.Gold; ThongTinChiTietTKB(bonTiet.lblMonHoc, bonTiet.toolTipController1, monHoc, tietBD, soTiet, lop, phong, diaChi); bonTiet.lblMonHoc.Cursor = Cursors.Hand; bonTiet.Name = "4" + ngayDauTuan.AddDays((int)thu).ToString("dd/MM/yyyy") + tietBD.ToString() + soTiet.ToString() + mode.ToString() + maPC + maBuoiHoc.ToString(); pnChinh.Controls.Add(bonTiet); bonTiet.BringToFront(); break; case 5: NamTiet namTiet = new NamTiet(); namTiet.PhongHoc = phong; namTiet.MonHoc = monHoc; namTiet.Location = new Point(XThu[thu], YTiet[tietBD]); namTiet.BackColor = Color.Gold; ThongTinChiTietTKB(namTiet.lblMonHoc, namTiet.toolTipController1, monHoc, tietBD, soTiet, lop, phong, diaChi); namTiet.lblMonHoc.Cursor = Cursors.Hand; namTiet.Name = "5" + ngayDauTuan.AddDays((int)thu).ToString("dd/MM/yyyy") + tietBD.ToString() + soTiet.ToString() + mode.ToString() + maPC + maBuoiHoc.ToString(); pnChinh.Controls.Add(namTiet); namTiet.BringToFront(); break; } } catch (Exception ex) { throw ex; } }
//mode == 0 không có dạy //mode == 1: có dạy private new void Paint(string maPC, int maBuoiHoc, int thu, int tietBD, int soTiet, string monHoc, string giangVien, string lop, int mode, string diaChi) { try { switch (soTiet) { case 1: MotTiet motTiet = new MotTiet(); motTiet.PhongHoc = lop; motTiet.MonHoc = monHoc; motTiet.Location = new Point(XThu[thu], YTiet[tietBD]); if (mode == 0) //ko có dạy { motTiet.BackColor = Color.Gold; motTiet.lblMonHoc.Click += new EventHandler(XuLy); } else //có dạy { motTiet.BackColor = Color.LightSalmon; } ThongTinChiTietTKB(motTiet.lblMonHoc, motTiet.toolTipController1, monHoc, tietBD, soTiet, giangVien, lop, diaChi, mode); motTiet.lblMonHoc.Cursor = Cursors.Hand; motTiet.Name = "1" + ngayDauTuan.AddDays((int)thu).ToString("dd/MM/yyyy") + tietBD.ToString() + soTiet.ToString() + mode.ToString() + maPC + maBuoiHoc.ToString(); pnChinh.Controls.Add(motTiet); motTiet.BringToFront(); break; case 2: HaiTiet haiTiet = new HaiTiet(); haiTiet.PhongHoc = lop; haiTiet.MonHoc = monHoc; haiTiet.Location = new Point(XThu[thu], YTiet[tietBD]); if (mode == 0) //ko có dạy { haiTiet.BackColor = Color.Gold; haiTiet.lblMonHoc.Click += new EventHandler(XuLy); } else //có dạy { haiTiet.BackColor = Color.LightSalmon; } ThongTinChiTietTKB(haiTiet.lblMonHoc, haiTiet.toolTipController1, monHoc, tietBD, soTiet, giangVien, lop, diaChi, mode); haiTiet.lblMonHoc.Cursor = Cursors.Hand; haiTiet.Name = "2" + ngayDauTuan.AddDays((int)thu).ToString("dd/MM/yyyy") + tietBD.ToString() + soTiet.ToString() + mode.ToString() + maPC + maBuoiHoc.ToString(); pnChinh.Controls.Add(haiTiet); haiTiet.BringToFront(); break; case 3: BaTiet baTiet = new BaTiet(); baTiet.PhongHoc = lop; baTiet.MonHoc = monHoc; baTiet.Location = new Point(XThu[thu], YTiet[tietBD]); if (mode == 0) //ko có dạy { baTiet.BackColor = Color.Gold; baTiet.lblMonHoc.Click += new EventHandler(XuLy); } else //có dạy { baTiet.BackColor = Color.LightSalmon; } ThongTinChiTietTKB(baTiet.lblMonHoc, baTiet.toolTipController1, monHoc, tietBD, soTiet, giangVien, lop, diaChi, mode); baTiet.lblMonHoc.Cursor = Cursors.Hand; baTiet.Name = "3" + ngayDauTuan.AddDays((int)thu).ToString("dd/MM/yyyy") + tietBD.ToString() + soTiet.ToString() + mode.ToString() + maPC + maBuoiHoc.ToString(); pnChinh.Controls.Add(baTiet); baTiet.BringToFront(); break; case 4: BonTiet bonTiet = new BonTiet(); bonTiet.PhongHoc = lop; bonTiet.MonHoc = monHoc; bonTiet.Location = new Point(XThu[thu], YTiet[tietBD]); if (mode == 0) //ko có dạy { bonTiet.BackColor = Color.Gold; bonTiet.lblMonHoc.Click += new EventHandler(XuLy); } else //có dạy { bonTiet.BackColor = Color.LightSalmon; } ThongTinChiTietTKB(bonTiet.lblMonHoc, bonTiet.toolTipController1, monHoc, tietBD, soTiet, giangVien, lop, diaChi, mode); bonTiet.lblMonHoc.Cursor = Cursors.Hand; bonTiet.Name = "4" + ngayDauTuan.AddDays((int)thu).ToString("dd/MM/yyyy") + tietBD.ToString() + soTiet.ToString() + mode.ToString() + maPC + maBuoiHoc.ToString(); pnChinh.Controls.Add(bonTiet); bonTiet.BringToFront(); break; case 5: NamTiet namTiet = new NamTiet(); namTiet.PhongHoc = lop; namTiet.MonHoc = monHoc; namTiet.Location = new Point(XThu[thu], YTiet[tietBD]); if (mode == 0) //ko có dạy { namTiet.BackColor = Color.Gold; namTiet.lblMonHoc.Click += new EventHandler(XuLy); } else //có dạy { namTiet.BackColor = Color.LightSalmon; } ThongTinChiTietTKB(namTiet.lblMonHoc, namTiet.toolTipController1, monHoc, tietBD, soTiet, giangVien, lop, diaChi, mode); namTiet.lblMonHoc.Cursor = Cursors.Hand; namTiet.Name = "5" + ngayDauTuan.AddDays((int)thu).ToString("dd/MM/yyyy") + tietBD.ToString() + soTiet.ToString() + mode.ToString() + maPC + maBuoiHoc.ToString(); pnChinh.Controls.Add(namTiet); namTiet.BringToFront(); break; } } catch (Exception ex) { throw ex; } }
public bool ThemBuoiHoc(Thu thu, int tietBD, int soTiet, string monHoc, string phong) { try { if (tietBD < 0 || tietBD > 9) { throw new Exception("Tiết bắt đầu không hợp lệ."); } if (soTiet < 1 || soTiet > 5) { throw new Exception("Số tiết không hợp lệ."); } //kiem tra co trung ko foreach (BuoiHoc b in buoiHocs) { if (b.Ngay == ngayDauTuan.AddDays((int)thu) && tietBD < (b.SoTiet + b.TietDB)) { return(false); } } switch (soTiet) { case 1: MotTiet motTiet = new MotTiet(); motTiet.PhongHoc = phong; motTiet.MonHoc = monHoc; motTiet.Location = new Point(XThu[(int)thu], YTiet[tietBD]); pnChinh.Controls.Add(motTiet); motTiet.BringToFront(); break; case 2: HaiTiet haiTiet = new HaiTiet(); haiTiet.PhongHoc = phong; haiTiet.MonHoc = monHoc; haiTiet.Location = new Point(XThu[(int)thu], YTiet[tietBD]); pnChinh.Controls.Add(haiTiet); haiTiet.BringToFront(); break; case 3: BaTiet baTiet = new BaTiet(); baTiet.PhongHoc = phong; baTiet.MonHoc = monHoc; baTiet.Location = new Point(XThu[(int)thu], YTiet[tietBD]); pnChinh.Controls.Add(baTiet); baTiet.BringToFront(); break; case 4: BonTiet bonTiet = new BonTiet(); bonTiet.PhongHoc = phong; bonTiet.MonHoc = monHoc; bonTiet.Location = new Point(XThu[(int)thu], YTiet[tietBD]); pnChinh.Controls.Add(bonTiet); bonTiet.BringToFront(); break; case 5: NamTiet namTiet = new NamTiet(); namTiet.PhongHoc = phong; namTiet.MonHoc = monHoc; namTiet.Location = new Point(XThu[(int)thu], YTiet[tietBD]); pnChinh.Controls.Add(namTiet); namTiet.BringToFront(); break; } buoiHocs.Add(new BuoiHoc() { Ngay = ngayDauTuan.AddDays((int)thu), SoTiet = soTiet, TietDB = tietBD }); return(true); } catch (Exception ex) { throw ex; } }