public async Task <ActionResult <BaseResponse> > PutLichThi(int id, LichThi lichThi) { var lichThiSua = await _context.LichThis.FindAsync(id); if (lichThiSua == null) { return(new BaseResponse { ErrorCode = 1, Message = "Không tìm thấy" }); } lichThiSua.LopHPId = lichThi.LopHPId; lichThiSua.PhongThi = lichThi.PhongThi; lichThiSua.SoSV = lichThi.SoSV; _context.LichThis.Update(lichThiSua); await _context.SaveChangesAsync(); return(new BaseResponse { Message = "Cập nhật thành công", Data = lichThi }); }
public void setLichThi(LichThi lh) { this.panel_lichthi.Controls.Clear(); Control ct = this.panel_lichthi.Controls["header_lichthi"]; if (ct != null) { this.panel_lichthi.Controls.Remove(ct); } listMT = lh.ds_mon_thi.ToArray <MonThi>(); for (int i = listMT.Length - 1; i >= 0; i--) { LichThiItem item = new LichThiItem(); item.ma_mon_hoc.Text = listMT[i].ma_mh; item.ten_mon_hoc.Text = listMT[i].ten_mh; item.nhom_to.Text = listMT[i].nhomto; item.phongGK.Text = listMT[i].phong_ktra; item.ngayGK.Text = listMT[i].ngaykt; item.gioGK.Text = listMT[i].gio_kt; item.phongCK.Text = listMT[i].phong_thi; item.ngayCK.Text = listMT[i].ngaythi; item.gioCK.Text = listMT[i].gio_thi; item.TabIndex = i; item.Dock = DockStyle.Top; this.panel_lichthi.Controls.Add(item); } setupHeader(); }
public XemLichThi() { InitializeComponent(); StreamReader sr = new StreamReader(MyBK.Lib.Data.PathData.lichThiData, Encoding.UTF8); String json = sr.ReadToEnd(); sr.Close(); listLT = LichThi.getLichThi(json); this.setupDSHocKy(); this.setLichThi(listLT[0]); comboBox_ds_hoc_ki.Text = listLT[0].ten_hocky; }
private void button1_Click(object sender, EventArgs e) { SaveFileDialog op = new SaveFileDialog(); op.Filter = "ExcelFile| *.xlsx"; op.ShowDialog(); if (op.FileName != "") { KeyValuePair <String, LichThi> item = (KeyValuePair <String, LichThi>)comboBox_ds_hoc_ki.SelectedItem; LichThi.exportExcel(op.FileName, item.Value.hk_nh); } }
public async Task <ActionResult <BaseResponse> > PostLichThi(LichThi lichThi) { try { _context.LichThis.Add(lichThi); await _context.SaveChangesAsync(); return(new BaseResponse { Message = "Thêm mới thành công", Data = lichThi }); } catch { return(new BaseResponse { ErrorCode = 1, Message = "Thêm mới thất bại" }); } }
public async Task <ActionResult <BaseResponse> > ImportFile([FromForm] ImportFileRequest request) { LichThi lichThi; LopHocPhan lopHocPhan; LopSinhVien lopSinhVien; HocPhan hocPhan; using (var file = new OfficeOpenXml.ExcelPackage()) { using (var stream = request.File.OpenReadStream()) { file.Load(stream); } var worksheet = file.Workbook.Worksheets.First(); for (int i = 1; i < worksheet.Dimension.End.Row; i++) { var rowCells = worksheet.Cells[i, 1, i, worksheet.Dimension.End.Column]; var maLopSV = rowCells[i, 10].Value.ToString(); var khoa = rowCells[i, 9].Value.ToString();; lopSinhVien = LopSinhVienExists(maLopSV, khoa); if (lopSinhVien == null) { lopSinhVien = new LopSinhVien(); lopSinhVien.MaLop = maLopSV; lopSinhVien.NganhHoc = rowCells[i, 6].Value.ToString(); lopSinhVien.Khoa = khoa; await lopSVsCtrl.PostLopSinhVien(lopSinhVien); } var maHP = rowCells[i, 1].Value.ToString(); hocPhan = HocPhanExists(maHP); if (hocPhan == null) { hocPhan = new HocPhan(); hocPhan.MaHP = maHP; hocPhan.TenHP = rowCells[i, 3].Value.ToString(); hocPhan.SoTinChi = Int16.Parse(rowCells[i, 4].Value.ToString()); await hocPhansCtrl.PostHocPhan(hocPhan); } var maLopHP = rowCells[i, 2].Value.ToString(); lopHocPhan = LopHocPhanExists(maLopHP); if (lopHocPhan == null) { lopHocPhan = new LopHocPhan(); lopHocPhan.HocPhanId = hocPhan.Id; lopHocPhan.LopSVId = lopSinhVien.Id; lopHocPhan.MaLopHP = maLopHP; lopHocPhan.CSThi = rowCells[i, 16].Value.ToString(); var dateStr = rowCells[i, 15].Value.ToString().Substring(0, 10) + " " + rowCells[i, 13].Value.ToString().Replace("g", ":") + ":00"; lopHocPhan.NgayGioBDThi = DateTime.Parse(dateStr); lopHocPhan.Thu = rowCells[i, 14].Value.ToString(); lopHocPhan.ThoiKB = rowCells[i, 8].Value.ToString(); lopHocPhan.HeDaoTao = rowCells[i, 7].Value.ToString(); lopHocPhan.BacDaoTao = rowCells[i, 5].Value.ToString(); await lopHocPhansCtrl.PostLopHocPhan(lopHocPhan); } var phongThi = rowCells[i, 17].Value.ToString(); if (LichThiExists(maLopHP, phongThi) == null) { lichThi = new LichThi(); lichThi.LopHPId = lopHocPhan.Id; lichThi.PhongThi = rowCells[i, 17].Value.ToString(); lichThi.SoSV = Int16.Parse(rowCells[i, 12].Value.ToString()); await PostLichThi(lichThi); } } return(new BaseResponse { Message = "Import thành công" }); } }