private async Task getAllTiets()
        {
            lops = await apis.GetLops(main.HocKy);

            string lopFilter = "&lop=null";

            lops.ForEach(lop =>
            {
                lopFilter += $"&lop={lop.id}";
            });
            DateTime t2 = date;
            DateTime t7 = t2.AddDays(5);

            lopFilter += $"&ngay_gte={t2.ToString("yyyy-MM-dd")}&ngay_lte={t7.ToString("yyyy-MM-dd")}";
            tiets      = await apis.GetTietHocs(main.HocKy, null, lopFilter);

            List <TietHoc> list = new List <TietHoc>();

            tiets.ForEach(t =>
            {
                TietHoc tiet = t;
                if (tiet.lop == null)
                {
                    tiet.lop    = new Lop();
                    tiet.lop.id = 0;
                }
                list.Add(tiet);
            });
            tiets = list;
        }
        private async void TkbNgayTatCaLopForm_Load(object sender, EventArgs e)
        {
            this.Text = "Thời khoá biểu các lớp ngày " + ngay.ToString("dd/MM/yyyy");

            using (FileStream stream = new FileStream("TKB_Ngay_Tat_Ca_Lop.xlsx", FileMode.Open))
            {
                xlsxViewer.LoadDocument(stream, DocumentFormat.Xlsx);
                wb = xlsxViewer.Document;
                ws = wb.Worksheets[0];
            }

            IEnumerable <Cell> cells = ws.Search("_nguoiKy");

            foreach (Cell c in cells)
            {
                c.Value = nguoiKy;
            }

            lops = await apis.GetLops(hocKy);

            lops.ForEach(async lop =>
            {
                Cell cell = search(ws, $"Lớp: {lop.ten}");
                if (cell != null)
                {
                    tietHocs = await apis.GetTietHocsNgay(hocKy, lop, ngay);
                    TkbNgayLopHelper helper = new TkbNgayLopHelper(ws, lop, tietHocs, ngay, size, cell);
                    helper.setBackground();
                    helper.xep();
                }
            });

            if (true)
            {
                //for(int i = 0; i < lops.Count; i++)
                //{
                //    Lop lop = lops[i];
                //    Cell cell = search(ws, $"Lớp: {lop.ten}");
                //    tietHocs = await apis.GetTietHocsNgay(hocKy, lop, ngay);
                //    TkbNgayLopHelper helper = new TkbNgayLopHelper(ws, lop, tietHocs, ngay, size, cell);
                //    helper.setBackground();
                //    helper.xep();
                //}

                //for(int i = 0; i < 24; i++)
                //{
                //    ws[0, i * 9].Value = "lop";
                //    ws[19, i * 9].Value = "lop";
                //}

                //CellRange range = ws["A:I"];
                //CellRange range2 = ws["J:R"];
                //range2.CopyFrom(range);


                //TkbNgayLopHelper tKB_helper = new TkbNgayLopHelper(wb.Worksheets[0], Lop, tietHocs, ngay, size);
                //tKB_helper.setBackground();
                //tKB_helper.xep();
            }
        }
Esempio n. 3
0
        private async Task loadData()
        {
            lops = await apis.GetLops(hocKy);

            gridLop.DataSource = lops;
        }