private void btnMoKhoa_Click(object sender, EventArgs e) { if (cbbMaDocGia.Text == "") { MessageBox.Show("Chưa chọn mã đọc giả để mở khóa !!!"); } else { using (QUANLYTHUVIENEntities db = new QUANLYTHUVIENEntities()) { DataRow row = ((DataRowView)cbbMaDocGia.SelectedItem).Row; string madocgia = row[0].ToString(); var thongtindocgiaQuery = from thongtindocgia in db.THONGTINDOCGIAs where thongtindocgia.MADOCGIA == madocgia select thongtindocgia; if (thongtindocgiaQuery.Any()) { THONGTINDOCGIA ttdg = thongtindocgiaQuery.Single(); ttdg.TRANGTHAIDOCGIA = 1; db.SaveChanges(); } MessageBox.Show("Đã mở khóa thành công."); } } cbbMaDocGia.DataSource = LayDuLieuMaDG(); cbbMaDocGia.ValueMember = "MaDocGia"; }
private void cbbMaDocGia_TextChanged(object sender, EventArgs e) { using (QUANLYTHUVIENEntities db = new QUANLYTHUVIENEntities()) { DataRow row = ((DataRowView)cbbMaDocGia.SelectedItem).Row; string madocgia = row[0].ToString(); var thongtindocgiaQuery = from thongtindocgia in db.THONGTINDOCGIAs where thongtindocgia.MADOCGIA == madocgia select thongtindocgia; if (thongtindocgiaQuery.Any()) { THONGTINDOCGIA ttdg = thongtindocgiaQuery.Single(); tbxHoTen.Text = ttdg.TENDOCGIA; tbxNgaySinh.Text = ttdg.NGAYSINH.ToString(); tbxSDT.Text = ttdg.SODIENTHOAIDOCGIA; } } }
private void btnChuyenNhom_Click(object sender, EventArgs e) { using (QUANLYTHUVIENEntities db = new QUANLYTHUVIENEntities()) { var manhomQuery = from nhomdocgia in db.NHOMDOCGIAs where nhomdocgia.TENNHOM == cbbTenNhomChuyen.Text select nhomdocgia.MANHOM; string manhom = manhomQuery.Single(); var thongtindocgiaQuery = from thongtindocgia in db.THONGTINDOCGIAs where thongtindocgia.MADOCGIA == cbbMaDocGia.Text select thongtindocgia; THONGTINDOCGIA ttdgCapnhat = thongtindocgiaQuery.Single(); ttdgCapnhat.MANHOM = manhom; db.SaveChanges(); } MessageBox.Show("Đã chuyển thành công."); this.Close(); }
private void btnXacNhan_Click(object sender, EventArgs e) { using (QUANLYTHUVIENEntities db = new QUANLYTHUVIENEntities()) { var ttdgQuery = from ttdg in db.THONGTINDOCGIAs where ttdg.MADOCGIA == tbxMaDG.Text select ttdg; if (ttdgQuery.Any()) { THONGTINDOCGIA objThongtindocgia = ttdgQuery.Single(); tbxTenDG.Text = objThongtindocgia.TENDOCGIA; tbxMaNhom.Text = objThongtindocgia.MANHOM; string manhom = objThongtindocgia.MANHOM; tbxNSinh.Text = objThongtindocgia.NGAYSINH.ToString(); if (objThongtindocgia.GIOITINH.ToString() == "1") { tbxGioiTinh.Text = "Nam"; } else { tbxGioiTinh.Text = "Nu"; } tbxCMND.Text = objThongtindocgia.SOCMND.ToString(); string ma = tbxMaDG.Text; string link = ".\\HinhAnh\\nguoidung.jpg"; pbxHinh.Image = Image.FromFile(link); tbxNgaySinh.Text = tbxNSinh.Text.Substring(3, 2) + "/" + tbxNSinh.Text.Substring(0, 2) + "/" + tbxNSinh.Text.Substring(6, 4); var tennhomQuery = from nhom in db.NHOMDOCGIAs where nhom.MANHOM == manhom select nhom.TENNHOM; tbxTenNhom.Text = tennhomQuery.Single().ToString(); } else { MessageBox.Show("Không tồn tại mã độc giã này !!!"); } } }