Ejemplo n.º 1
0
        private countTiet countTietHoc(string tiet)
        {
            countTiet c = new countTiet();
            char      b = tiet[0];

            switch (b)
            {
            case '3': c.start = 2;  break;

            case '5': c.start = 3;  break;

            case '7': c.start = 4;  break;

            case 'Đ': c.start = 5;  break;

            default: c.start = 1;  break;
            }

            char a = tiet[tiet.Length - 1];

            switch (a)
            {
            case '2': c.end = 1; break;

            case '4': c.end = 2; break;

            case '6': c.end = 3; break;

            case '9': c.end = 4; break;

            default: c.end = 5; break;
            }

            return(c);
        }
Ejemplo n.º 2
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++;
                        }
                    }
                }
            });
        }