// luu chinh sua private void butLuu_Click(object sender, EventArgs e) { SachBUS objSach = new SachBUS(); Sach sach = new Sach(txtMa.Text, txtSach.Text, txtTacgia.Text, txtTheloai.Text, int.Parse(txtGia.Text), int.Parse(txtSl.Text)); if (objSach.CapNhatSach(sach) == true) { labThongbao.Text = "Thành công"; LoadData(); } else { MessageBox.Show("Lỗi dữ liệu"); } }
private void btnLuu_Click(object sender, EventArgs e) { string NgayNhap = String.Format("{0:MM/dd/yyyy}", dtpNgayNhap.Value); //Định dạng ngày tương ứng với trong CSDL SQLserver if (_themmoi) { _sachContext.ThemSach(txtTenSach.Text.Trim(), txtTacGia.Text.Trim(), txtNamXuatBan.Text.Trim(), txtNhaXuatBan.Text.Trim(), txtTriGia.Text.Trim(), NgayNhap); MessageBox.Show("Thêm mới thành công"); } else { _sachContext.CapNhatSach(lsvSach.SelectedItems[0].SubItems[0].Text, txtTenSach.Text.Trim(), txtTacGia.Text.Trim(), txtNamXuatBan.Text.Trim(), txtNhaXuatBan.Text.Trim(), txtTriGia.Text.Trim(), NgayNhap); MessageBox.Show("Cập nhật thành công"); } HienthiSach(); setNull(); }