private void cbxTenTacGiaTK_SelectedIndexChanged_1(object sender, EventArgs e) { string tacgia = "Select MaTacGia from TacGia where TenTacGia =N'" + cbxTenTacGiaTK.Text.ToString() + "'"; string MaTG = Convert.ToString(ac.executeScalar(tacgia)); string sql2 = "Select *from TuaSach where MaTacGia ='" + MaTG + "'"; dataGridViewTimKiem.DataSource = ac.TaoBang(sql2); }
private void cbxMaSachMuon_TextChanged(object sender, EventArgs e) { //Lấy tên sach string sach = "Select TenSach from TuaSach where TenSach='" + cbxMaSachMuon.Text.ToString() + "'"; string TenS = Convert.ToString(ac.executeScalar(sach)); cbxTenSachMuon.Text = TenS; }
private void button1_Click(object sender, EventArgs e) { //Lấy tên độc giả string docgia = "Select TenDocGia from DocGia where MaDocGia='" + cbxMaDocGiaThe.Text.ToString() + "'"; string TenDocGia = Convert.ToString(ac.executeScalar(docgia)); string sql = "Insert into The values('" + txtMaThe.Text + "','" + cbxMaDocGiaThe.Text.ToString() + "',N'" + TenDocGia + "','" + dateTimePicker1.Value.ToString() + "','" + dateTimePicker2.Value.ToString() + "'," + nbSoSachDuocMuon.Value.ToString() + ")"; if (txtMaThe.Text.Length != 0) { try { ac.ExcuteNonQuery(sql); string sql1 = "Select *from The"; dataGridViewThe.DataSource = ac.TaoBang(sql1); Xoa(); } catch (Exception ex) { MessageBox.Show("Mã thẻ đã tồn !", "Thêm Lỗi", MessageBoxButtons.OK, MessageBoxIcon.Warning); txtMaThe.Clear(); } } else { MessageBox.Show("Mã thẻ và mã độc giả không được để trống !", "Thêm Lỗi", MessageBoxButtons.OK, MessageBoxIcon.Warning); } }
private void ThongKe_Load(object sender, EventArgs e) { // this.tacGiaTableAdapter.Fill(this.quanLyThuVienDataSet.TacGia); string sql1 = "Select COUNT(*) from TuaSach"; string sql2 = "Select COUNT(*) from DocGia"; string sql3 = "Select COUNT(*) from TacGia"; string sql4 = "Select COUNT(*) from TheLoai"; string sql5 = "Select COUNT(*) from NhaXuatBan"; string sql6 = "Select COUNT(*) from PhieuMuon"; int a = Convert.ToInt32(ac.executeScalar(sql1)); int b = Convert.ToInt32(ac.executeScalar(sql2)); int c = Convert.ToInt32(ac.executeScalar(sql3)); int d = Convert.ToInt32(ac.executeScalar(sql4)); int f = Convert.ToInt32(ac.executeScalar(sql5)); int g = Convert.ToInt32(ac.executeScalar(sql6)); labSoSach.Text += a; labSoDocGia.Text += b; labSoTacGia.Text += c; labSoTL.Text += d; labSoNXB.Text += f; labChoMuon.Text += g; }
private void btnThemSach_Click_1(object sender, EventArgs e) { //Lấy mã tác giả string tacgia = "Select MaTacGia from TacGia where TenTacGia=N'" + cbxTenTacGiaSach.Text.ToString() + "'"; string MaTG = Convert.ToString(ac.executeScalar(tacgia)); //Lấy mã thể loại string theloai = "Select MaTheLoai from TheLoai where TenTheLoai=N'" + cbxTenTheLoai.Text.ToString() + "'"; string MaTL = Convert.ToString(ac.executeScalar(theloai)); //Lấy mã NXB string nxb = "Select MaNhaXuaBan from NhaXuatBan where TenNhaXuatBan=N'" + cbxTenNXBSach.Text.ToString() + "'"; string MaNXB = Convert.ToString(ac.executeScalar(nxb)); string sql = @"Insert into TuaSach values('" + txtMaSach.Text + "',N'" + txtTenSach.Text + "','" + cbxNamXuatBan.Text.ToString() + "','" + txtGiaSach.Text + "','" + MaTG + "', '" + MaTL + "','" + MaNXB + "','" + txtSL.Text + "')"; if (txtMaSach.Text.Length != 0 && txtTenSach.Text.Length != 0) { ac.ExcuteNonQuery(sql); string sql1 = "Select *from TuaSach"; dataGridViewSach.DataSource = ac.TaoBang(sql1); XoaSach(); try { } catch (Exception ex) { MessageBox.Show("Mã Tua sách đã tồn !", "Thêm Lỗi", MessageBoxButtons.OK, MessageBoxIcon.Warning); txtMaSach.Clear(); } } else { MessageBox.Show("Mã Tua sách và tên sách không được để trống !", "Thêm Lỗi", MessageBoxButtons.OK, MessageBoxIcon.Warning); } }