private void btnCapNhat_Click(object sender, EventArgs e) { string capnhat = @"update THELOAI set TenTL=N'" + txtTenTL.Text + "', GhiChu=N'" + txtGhiChu.Text + "' where MaTL='" + txtMaTL.Text + "'"; DatabaseService.executeQuery(capnhat); Load_data(); }
private void btnThem_Click(object sender, EventArgs e) { string them = @"insert into THELOAI values(N'" + txtTenTL.Text + "',N'" + txtGhiChu.Text + "')"; DatabaseService.executeQuery(them); Load_data(); }
private void btnDoiMK_Click(object sender, EventArgs e) { string update = "update NGUOIDUNG set Password='******' where(ID=N'" + txtID.Text + "')"; DatabaseService.executeQuery(update); Load_Data(); }
private void btnCapNhat_Click(object sender, EventArgs e) { string update = "update NGUOIDUNG set Password='******' where(ID=N'" + txtTaiKhoan.Text + "' and Password='******')"; string ten = txtTaiKhoan.Text; if (ten == "") { MessageBox.Show("Bạn chưa nhập tên truy cập"); } if (txtMaXacNhan.Text != txtMaXacMinh_.Text) { MessageBox.Show("Mã xác nhận không đúng"); XacMinh(); return; } else { if (txtMatKhauCu.Text == "") { MessageBox.Show("Bạn chưa nhập mật khẩu"); } else { if (txtMatKhauMoi.Text == "") { MessageBox.Show("Bạn chưa nhập mật khẩu mới"); } else { if (txtXacNhanMatKhau.Text == "") { MessageBox.Show("Bạn chưa nhập lại mật khẩu"); } else { if ((txtMatKhauMoi.Text == txtXacNhanMatKhau.Text) && txtMatKhauCu.Text == password) { DatabaseService.executeQuery(update); MessageBox.Show("Bạn đã thay đổi mật khẩu thành công"); this.Close(); } else { MessageBox.Show("Bạn nhập lại mật khẩu không đúng"); } } } } } }
private void btnTra_Click(object sender, EventArgs e) { if (Kiemtra() == 1) { string xoaHoaDonMuon = @"update HOADON set TinhTrang=1 where MaPM='" + cboxMaPM.Text + "' and MaDG='" + cboxMaDG.Text + "'"; //MessageBox.Show(xoaHoaDonMuon); DatabaseService.executeQuery(xoaHoaDonMuon); // foreach (var listBoxItem in listBox1.Items) { string tra = @"delete from CHITIETHOADON where MaSach=(select MaSach from SACH where SACH.TenSach=N'" + listBoxItem.ToString() + "' and CHITIETHOADON.MaPM='" + cboxMaPM.Text + "' and CHITIETHOADON.NgayThue='" + cboxNgayMuon.Text + "')"; string upTontai = @"update SACH set SLTon=(SLTon+1) where MaSach=(select MaSach from SACH where SACH.TenSach=N'" + listBoxItem.ToString() + "')"; string upSLMuon = @"update SACH set SLMuon=(SLMuon-1) where MaSach=(select MaSach from SACH where SACH.TenSach=N'" + listBoxItem.ToString() + "')"; //MessageBox.Show(upTontai); DatabaseService.executeQuery(upTontai); //MessageBox.Show(upSLMuon); DatabaseService.executeQuery(upSLMuon); //MessageBox.Show(tra); DatabaseService.executeQuery(tra); } MessageBox.Show("Bạn đã trả hết sách thành công!! Bạn có thể mượn ở lần tới."); listBox1.Items.Clear(); } else { string xoaHoaDonMuon = @"update HOADON set TinhTrang=0 where MaPM='" + cboxMaPM.Text + "' and MaDG='" + cboxMaDG.Text + "'"; //MessageBox.Show(xoaHoaDonMuon); DatabaseService.executeQuery(xoaHoaDonMuon); foreach (var listBoxItem in listBox1.Items) { string tra = @"delete from CHITIETHOADON where MaSach=(select MaSach from SACH where SACH.TenSach=N'" + listBoxItem.ToString() + "' and CHITIETHOADON.MaPM='" + cboxMaPM.Text + "' and CHITIETHOADON.NgayThue='" + cboxNgayMuon.Text + "')"; string upTontai = @"update SACH set SLTon=(SLTon+1) where MaSach=(select MaSach from SACH where SACH.TenSach=N'" + listBoxItem.ToString() + "')"; string upSLMuon = @"update SACH set SLMuon=(SLMuon-1) where MaSach=(select MaSach from SACH where SACH.TenSach=N'" + listBoxItem.ToString() + "')"; //MessageBox.Show(upTontai); DatabaseService.executeQuery(upTontai); //MessageBox.Show(upSLMuon); DatabaseService.executeQuery(upSLMuon); //MessageBox.Show(tra); DatabaseService.executeQuery(tra); } MessageBox.Show("Bạn đã trả sách thành công nhưng chưa đủ!!"); this.Load_Muon(); listBox1.Items.Clear(); } //MessageBox.Show("Trả thành công"); }
private void btnThem_Click(object sender, EventArgs e) { string GioiTinh = ""; if (swGioiTinh.Value == true) { GioiTinh = "0"; } else { GioiTinh = "1"; } string them = @"insert into DOCGIA values (N'" + txtTenDG.Text + "','" + dateNgaySinh.Text + "',N'" + GioiTinh + "',N'" + txtDiaChi.Text + "','" + txtSDT.Text + "','" + txtEmail.Text + "',N'" + txtGhiChu.Text + "')"; DatabaseService.executeQuery(them); Load_Data(); }
private void btnPhanQuyen_Click(object sender, EventArgs e) { string _PhanQuyen = ""; if (cboxPhanQuyen.Text == "Quản Trị") { _PhanQuyen = "1"; } if (cboxPhanQuyen.Text == "Nhân Viên") { _PhanQuyen = "2"; } string update = "update NGUOIDUNG set PhanQuyen=N'" + _PhanQuyen + "' where(ID=N'" + txtID.Text + "')"; DatabaseService.executeQuery(update); Load_Data(); }
private void btnCapNhat_Click(object sender, EventArgs e) { string GioiTinh = ""; if (swGioiTinh.Value == true) { GioiTinh = "0"; } else { GioiTinh = "1"; } string CapNhatTS = @"update DOCGIA set TenDG=N'" + txtTenDG.Text + "',GioiTinh='" + GioiTinh + "',NgaySinh='" + dateNgaySinh.Text + "',DiaChi=N'" + txtDiaChi.Text + "',SDT='" + txtSDT.Text + "',Email='" + txtEmail.Text + "',GhiChu=N'" + txtGhiChu.Text + "' where MaDG='" + txtMaDG.Text + "'"; DatabaseService.executeQuery(CapNhatTS); Load_Data(); }
private void btnMuon_Click(object sender, EventArgs e) { int sum = 0; foreach (var listBoxItem in listBox1.Items) { sum++; } //txtSL.Text = Convert.ToInt32(sum).ToString(); if (sum == 0) { MessageBox.Show("Không có sách nào được chọn để mượn", "Thông báo"); } else { if (txtMaPM.Text == "") { MessageBox.Show("Mã Phiếu mượn không được trống!!"); } else { string muon = @"insert into HOADON(MaPM,MaDG,TinhTrang) values('" + txtMaPM.Text + "','" + cboxMaDG.Text + "',0)"; // 0 chưa trả //MessageBox.Show(muon); DatabaseService.executeQuery(muon); // // Thêm vào CT Mượn foreach (var listBoxItem in listBox1.Items) { //MessageBox.Show(listBoxItem.ToString()); string ctMuon = @"insert into CHITIETHOADON(MaPM,MaSach,NgayThue,NgayTra) values('" + txtMaPM.Text + "',(select MaSach from SACH where SACH.TenSach=N'" + listBoxItem.ToString() + "'),'" + dateNgayMuon.Text + "','" + dateNgayTra.Text + "')"; string upTontai = @"update SACH set SLTon=(SLTon-1) where MaSach=(select MaSach from SACH where SACH.TenSach=N'" + listBoxItem.ToString() + "')"; string upSLMuon = @"update SACH set SLMuon=(SLMuon+1) where MaSach=(select MaSach from SACH where SACH.TenSach=N'" + listBoxItem.ToString() + "')"; DatabaseService.executeQuery(ctMuon); DatabaseService.executeQuery(upTontai); DatabaseService.executeQuery(upSLMuon); } } MessageBox.Show("Mượn thành công!!"); listBox1.Items.Clear(); } // }
private void btnXoa_Click(object sender, EventArgs e) { string XoaTS = "DELETE FROM SACH WHERE MaSach='" + txtMaSach.Text + "'"; DialogResult dialog = MessageBox.Show("Bạn có muốn xóa sách: " +txtTenSach.Text + "\nCủa tác giả: " + cboxTacGia.Text, "Thông báo", MessageBoxButtons.YesNo, MessageBoxIcon.Question); if (dialog == DialogResult.Yes) { try { DatabaseService.executeQuery(XoaTS); Load_Data(); } catch (Exception) { } } else if (dialog == DialogResult.No) { // } }
private void btnXoa_Click(object sender, EventArgs e) { string xoa = @"delete from THELOAI where MaTL='" + txtMaTL.Text + "'"; DialogResult dialog = MessageBox.Show("Bạn có muốn xóa thể loại: " + txtTenTL.Text, "Thông báo", MessageBoxButtons.YesNo, MessageBoxIcon.Question); if (dialog == DialogResult.Yes) { try { DatabaseService.executeQuery(xoa); Load_data(); } catch (Exception) { } } else if (dialog == DialogResult.No) { // } }
private void btnThem_Click(object sender, EventArgs e) { string them = @"insert into SACH values (N'" + cboxTheLoai.Text + "',N'" + txtTenSach.Text + "',N'" + cboxTacGia.Text + "',N'" + cboxNXB.Text + "','" + dateNgayNhap.Text + "','" + txtSLTon.Text + "','" + txtSLMuon.Text + "')"; DatabaseService.executeQuery(them); Load_Data(); }
private void btnCapNhat_Click(object sender, EventArgs e) { string CapNhatTS = @"update SACH set TheLoai=N'" + cboxTheLoai.Text + "',TenSach=N'" + txtTenSach.Text + "',TacGia=N'" + cboxTacGia.Text + "',NXB=N'" + cboxNXB.Text + "',NgayNhap=N'" + dateNgayNhap.Text + "',SLTon='" + txtSLTon.Text + "',SLMuon='" + txtSLMuon.Text + "' where MaSach='" + txtMaSach.Text + "'"; DatabaseService.executeQuery(CapNhatTS); Load_Data(); }