private void dgvContent_CellContentClick(object sender, DataGridViewCellEventArgs e)
 {
     if (e.RowIndex < 0 || e.RowIndex >= dgvContent.RowCount)
     {
         return;
     }
     if (dgvContent.Columns[e.ColumnIndex].Name == "DiemDanh")
     {
         //Console.WriteLine("Hoc sinh: " + dgvContent.Rows[e.RowIndex].Cells[2].Value.ToString());
         int      maHocSinh = int.Parse(dgvContent.Rows[e.RowIndex].Cells[2].Value.ToString());
         DiemDanh diemDanh  = db.DiemDanhs.Where(dd => dd.MaBuoiHoc == _maBuoiHoc && dd.MaHocSinh == maHocSinh).FirstOrDefault();
         diemDanh.DaDiemDanh = !diemDanh.DaDiemDanh;
         db.SaveChanges();
         BoundDataSource();
     }
 }
        private void btnAdd_Click(object sender, EventArgs e)
        {
            int maHocSinh            = int.Parse(lueHocSinh.EditValue.ToString());
            BienLaiThuHocPhi bienLai = new BienLaiThuHocPhi()
            {
                TongSoBuoi = 0,
                TongTien   = 0,
                NgayThu    = DateTime.Now,
                MaHocSinh  = maHocSinh,
                MaLopHoc   = curClassId
            };

            db.BienLaiThuHocPhis.Add(bienLai);
            db.SaveChanges();
            RebindBindingSources();
        }
        private void btnSave_Click(object sender, EventArgs e)
        {
            HashSet <string> userNameSet = new HashSet <string>();

            foreach (var curTeacher in db.GiaoViens.ToList())
            {
                Console.WriteLine("Ten dang nhap: " + curTeacher.TenDangNhap);
                if (userNameSet.Contains(curTeacher.TenDangNhap))
                {
                    XtraMessageBox.Show("Ten dang nhap: \"" + curTeacher.TenDangNhap + "\" da ton tai!!!", "Lỗi", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    return;
                }
                else
                {
                    userNameSet.Add(curTeacher.TenDangNhap);
                }
            }
            db.SaveChanges();
            XtraMessageBox.Show("Luu thay doi thanh cong", "Message", MessageBoxButtons.OK, MessageBoxIcon.Information);
        }
 private void barButtonItem3_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
 {
     db.SaveChanges();
     XtraMessageBox.Show("Luu thay doi thanh cong", "Message", MessageBoxButtons.OK, MessageBoxIcon.Information);
 }