Exemplo n.º 1
0
        public void xep1Ngay(DateTime ngay)
        {
            TietHocRendering t = new TietHocRendering(Lop, size);
            //Tìm ô tiêu đề ngày
            Cell           dateCell = dateToCell[ngay];
            Cell           cell     = dateCell;
            List <TietHoc> list     = tietHocs.Where(x => x.ngay == ngay).ToList();

            list.OrderBy(x => x.tiet);
            if (list.Count == 0)
            {
                return;
            }

            Ngay_helper helper = new Ngay_helper();

            helper.Lop = Lop;
            helper.xep(ws, dateCell, list, "hocKy", size, map);
        }
Exemplo n.º 2
0
        public void xep()
        {
            if (tietHocs.Count == 0)
            {
                return;
            }
            TietHocRendering t = new TietHocRendering(Lop, size);
            //Tìm ô tiêu đề ngày / Môn học giảng đường
            Cell           cell = ws[r + 4, c + 1];
            List <TietHoc> list = tietHocs;

            list.OrderBy(x => x.tiet);

            if (list.Count == 0)
            {
                return;
            }

            Ngay_helper helper = new Ngay_helper();

            helper.Lop = Lop;
            helper.xep(ws, cell, list, "ngay", size, null);
        }
Exemplo n.º 3
0
        public void xep(Worksheet ws, Cell cell, List <TietHoc> tietHocs, string type, int size, Dictionary <string, TietHoc> cellToValue)
        {
            TietHocRendering render = new TietHocRendering(Lop, size);
            int col = cell.ColumnIndex;
            int row = cell.RowIndex;

            if (tietHocs[0].ngayNghi != null)
            {
                if (tietHocs[0].ngayNghi.lop == null && type == "tuan")
                {
                    return;
                }
            }
            tietHocs.ForEach(tiet =>
            {
                countTiet count = countTietHoc(tiet.tiet);

                if (type == "tuan")
                {
                    //Tiết ghép với tiết khác thì rend ra _ là đc
                    if (tiet.tiet == "Cả ngày")
                    {
                        int i   = (tiet.ngay.DayOfWeek.ToString() == "Saturday") ? 4 : 5;
                        Cell c1 = ws[row + count.start, col];
                        Cell c2 = ws[row + i, col];

                        while (count.start <= count.end)
                        {
                            Cell c = ws[row + count.start, col];
                            c.SetRichText(render.tietToRich(tiet, type, size));
                            if (cellToValue != null)
                            {
                                if (!cellToValue.ContainsKey(c.GetReferenceA1()))
                                {
                                    cellToValue.Add(c.GetReferenceA1(), tiet);
                                }
                            }
                            count.start++;
                        }
                    }
                    else
                    {   //Không phải cả ngày
                        while (count.start <= count.end)
                        {
                            Cell c = ws[row + count.start, col];
                            c.SetRichText(render.tietToRich(tiet, type, size));
                            if (cellToValue != null)
                            {
                                if (!cellToValue.ContainsKey(c.GetReferenceA1()))
                                {
                                    cellToValue.Add(c.GetReferenceA1(), tiet);
                                }
                            }
                            count.start++;
                        }
                    }
                }
                //Không phải tuần, T7 có 5 tiết
                else
                {   //Cả ngày
                    if (tiet.ngayNghi != null)
                    {
                        Cell c1  = ws[row + 1, col];
                        Cell c2  = ws[row + 5, col];
                        c1.Value = tiet.ngayNghi.ten;

                        ws.MergeCells(ws[c1.GetReferenceA1() + ":" + c2.GetReferenceA1()]);
                        c1.Alignment.RotationAngle = 90;

                        for (int i = 1; i < 6; i++)
                        {
                            if (cellToValue != null)
                            {
                                if (!cellToValue.ContainsKey(ws[row + i, col].GetReferenceA1()))
                                {
                                    cellToValue.Add(ws[row + i, col].GetReferenceA1(), tiet);
                                }
                            }
                        }
                    }
                    else
                    {
                        while (count.start <= count.end)
                        {
                            Cell c = ws[row + count.start, col];
                            c.SetRichText(render.tietToRich(tiet, type, size));
                            if (cellToValue != null)
                            {
                                if (!cellToValue.ContainsKey(c.GetReferenceA1()))
                                {
                                    cellToValue.Add(c.GetReferenceA1(), tiet);
                                }
                            }
                            count.start++;
                        }
                    }
                }
            });
        }