private void TKBLop_CellBeginEdit(object sender, DevExpress.XtraSpreadsheet.SpreadsheetCellCancelEventArgs e) { Cell cell = e.Cell; if (!cellMap.ContainsKey(cell.GetReferenceA1())) { return; } TietHoc tiet = cellMap[cell.GetReferenceA1()]; if (tiet.ngayNghi != null) { return; } //Nạp xlsx để xem chi tiết using (FileStream stream = new FileStream(@"tietViewer.xlsx", FileMode.Open)) { spreadsheetChiTiet.LoadDocument(stream, DocumentFormat.Xlsx); wbChiTiet = spreadsheetChiTiet.Document; wsChiTiet = wbChiTiet.Worksheets[0]; } Lop lop = new Lop(); lop.giangDuong = "0"; TietHocRendering render = new TietHocRendering(lop, 20); wsChiTiet["A1"].SetRichText(render.tietToRich(tiet, "hocKy", 12)); wsChiTiet.FreezePanes(0, 0); //Khoá ô hiển thị lblThu.Text = dateToThu(tiet.ngay.DayOfWeek.ToString()) + ", "; lblNgay.Text = "ngày " + tiet.ngay.ToString("dd/MM/yyyy"); int x = lblThu.Location.X + lblThu.Width - 10, y = lblNgay.Location.Y; lblNgay.Location = new Point(x, y); lblLop.Text = "Lớp: " + Lop.ten; lblTiet.Text = "Tiết: " + tiet.tiet; string[] arr = tiet.mon.ten.Split(new char[] { '|' }); string bai = tiet.bai == "" ? "Không nhập" : tiet.bai; lblMon.Text = "Môn: " + arr[0]; lblBai.Text = "Bài: " + bai; lblHinhThuc.Text = "Hình thức: " + tiet.hinhThuc; lblGiangDuong.Text = "Địa điểm: " + tiet.diaDiem; lblGiangVien.Text = tiet.giangViens == "" ? "GV: Không nhập" : "GV: " + tiet.giangViens; toolTip.RemoveAll(); toolTip.SetToolTip(lblLop, lblLop.Text); toolTip.SetToolTip(lblMon, "Môn học: " + arr[0]); toolTip.SetToolTip(lblGiangVien, tiet.giangViens == "" ? "Giảng viên: Không nhập" : "Giảng viên: " + tiet.giangViens); grpChiTiet.Visible = true; }
private void xlsxViewer_CellBeginEdit(object sender, DevExpress.XtraSpreadsheet.SpreadsheetCellCancelEventArgs e) { if (!isNewData) { return; } Cell cell = e.Cell; string sheetName = e.Worksheet.Name; Dictionary <string, TietHoc> map = (sheetName == "TKB d2,10,3") ? cellMap[0] : cellMap[1]; if (!map.ContainsKey(cell.GetReferenceA1())) { return; } //Nạp xlsx để xem chi tiết using (FileStream stream = new FileStream(@"tietViewer.xlsx", FileMode.Open)) { spreadsheetChiTiet.LoadDocument(stream, DocumentFormat.Xlsx); wbChiTiet = spreadsheetChiTiet.Document; wsChiTiet = wbChiTiet.Worksheets[0]; } TietHoc tiet = map[cell.GetReferenceA1()]; Lop lop = new Lop(); lop.giangDuong = "0"; TietHocRendering render = new TietHocRendering(lop, 20); wsChiTiet["A1"].SetRichText(render.tietToRich(tiet, "hocKy", 12)); wsChiTiet.FreezePanes(0, 0); //Khoá ô hiển thị lblThu.Text = dateToThu(tiet.ngay.DayOfWeek.ToString()) + ", "; lblNgay.Text = "ngày " + tiet.ngay.ToString("dd/MM/yyyy"); int x = lblThu.Location.X + lblThu.Width - 10, y = lblNgay.Location.Y; lblNgay.Location = new Point(x, y); string lops = "Lớp: " + tiet.lop.ten; int count = cell.GetMergedRanges().Count > 0 ? cell.GetMergedRanges()[0].ColumnCount : 1; if (count > 1) { for (int i = cell.ColumnIndex + 1; i < cell.ColumnIndex + count; i++) { lops += ", " + ws[6, i].Value; } } lblLop.Text = lops; lblTiet.Text = "Tiết: " + tiet.tiet; string[] arr = tiet.mon.ten.Split(new char[] { '|' }); string bai = tiet.bai == "" ? "Không nhập" : tiet.bai; lblMon.Text = "Môn: " + arr[0]; lblBai.Text = "Bài: " + bai; lblHinhThuc.Text = "Hình thức: " + tiet.hinhThuc; lblGiangDuong.Text = "Địa điểm: " + tiet.diaDiem; lblGiangVien.Text = tiet.giangViens == "" ? "Giảng viên: Không nhập" : "Giảng viên: " + tiet.giangViens; toolTip.RemoveAll(); toolTip.ShowAlways = true; toolTip.SetToolTip(lblLop, lops); toolTip.SetToolTip(lblMon, "Môn học: " + arr[0]); toolTip.SetToolTip(lblGiangVien, lblGiangVien.Text); grpChiTiet.Visible = true; }