public bool Add(MonTheLuc item) { try { db.MonTheLucs.Add(item); db.SaveChanges(); HocVien_TheLuc temp = new HocVien_TheLuc(); temp.KetQua = 0; temp.MonTheLucID = item.ID; List <HocVien> hv = db.HocViens.ToList(); HocVienDAO dao = new HocVienDAO(); foreach (var x in hv) { temp.HocVienID = x.ID; dao.Add_HocVien_MonTheLuc(temp); } return(true); } catch { return(false); } }
public bool Insert(HocVien item) { try { db.HocViens.Add(item); db.SaveChanges(); //Them mon hoc List <Lop_MonHoc> monhoc = db.Lop_MonHoc.Where(x => x.LopID == item.LopID).ToList(); HocVien_MonHoc temp_mh = new HocVien_MonHoc(); temp_mh.HocVienID = item.ID; temp_mh.Diem = 0; foreach (Lop_MonHoc mh in monhoc) { temp_mh.MonHocID = mh.MonHocID; new HocVienDAO().Add_HocVien_MonHoc(temp_mh); } // Them mon the luc List <MonTheLuc> montheluc = db.MonTheLucs.ToList(); HocVien_TheLuc temp_mtl = new HocVien_TheLuc(); temp_mtl.HocVienID = item.ID; temp_mtl.KetQua = 0; foreach (var mtl in montheluc) { temp_mtl.MonTheLucID = mtl.ID; new HocVienDAO().Add_HocVien_MonTheLuc(temp_mtl); } //Them mon cong tac dang List <CongTacDang> monctd = db.CongTacDangs.ToList(); HocVien_CongTacDang temp_mctd = new HocVien_CongTacDang(); temp_mctd.HocVienID = item.ID; temp_mctd.Diem = 0; foreach (var mctd in monctd) { temp_mctd.CongTacDangID = mctd.ID; new HocVienDAO().Add_HocVien_CongTacDang(temp_mctd); } db.SaveChanges(); return(true); } catch (Exception e) { var x = e.ToString(); MessageBox.Show(x); return(false); } }
public bool EditTheLuc(HocVien_TheLuc item) { try { var dbEntry = db.HocVien_TheLuc.SingleOrDefault(x => x.HocVienID == item.HocVienID && x.MonTheLucID == item.MonTheLucID && x.Quy == item.Quy && x.Nam == item.Nam); dbEntry.KetQua = item.KetQua; db.SaveChanges(); return(true); } catch { return(false); } }
private void btn_Sua_Click(object sender, EventArgs e) { if (Common.Acc_type == "Root" || Common.Acc_type == "Admin") { if (btn_Sua.Text == "Sửa") { gridColumn6.OptionsColumn.ReadOnly = false; btn_Sua.Text = "Lưu"; MessageBox.Show("Bạn có thể sửa thành tích học viên trong bảng !", "Sửa thành tích", MessageBoxButtons.OK, MessageBoxIcon.Information); btn_Huy_In.Text = "Hủy"; } else { btn_Sua.Text = "Sửa"; btn_Huy_In.Text = "In kết quả"; gridColumn6.OptionsColumn.ReadOnly = true; HocVien_TheLuc temp = new HocVien_TheLuc(); temp.HocVienID = Convert.ToInt32(grvDSHocVien.GetFocusedRowCellValue("ID").ToString()); temp.Nam = Convert.ToInt16(comboBox2.Text); temp.Quy = comboBox1.Text; HocVienDAO dao = new HocVienDAO(); foreach (var item in list_KQTL) { temp.MonTheLucID = item.MonTheLucID; if (item.ThanhTich < 0) { MessageBox.Show("Bạn không thể nhập thành tích < 0 !", "Lỗi", MessageBoxButtons.OK, MessageBoxIcon.Hand); continue; } temp.KetQua = item.ThanhTich; dao.EditTheLuc(temp); } MessageBox.Show("Cập nhật thành công !", "Thành công", MessageBoxButtons.OK, MessageBoxIcon.Information); LoadDataKQTheLuc(); } } else { MessageBox.Show("Bạn không có quyền thực hiện tác vụ này"); } }
public bool Add_HocVien_MonTheLuc(HocVien_TheLuc item) { try { for (int i = 1; i <= 4; i++) { for (int j = 1; j <= 5; j++) { db.HocVien_TheLuc.Add(new HocVien_TheLuc() { HocVienID = item.HocVienID, MonTheLucID = item.MonTheLucID, KetQua = 0, Nam = j, Quy = returnQuy(i) }); db.SaveChanges(); } } return(true); } catch (Exception e) { var x = e.ToString(); return(false); } }