public int Sua(Audio_DTO Audio) { DataAccess data = new DataAccess(); string cmd = @"UPDATE AudioBook SET TenSach=@TenSach, MaTG=@MaTG ,MaTL=@MaTL, MaNXB=@MaNXB, NamXB=@NamXB, FileAudio=@FileAudio, HinhAnh=@HinhAnh, DinhDang=@DinhDang, DungLuong=@DungLuong,ThoiLuong=@ThoiLuong,MCAudio=@MCAudio WHERE MaAudio=@MaAudio "; SqlParameter[] parameter = new SqlParameter[] { new SqlParameter("@MaAudio", Audio.MaAudio), new SqlParameter("@TenSach", Audio.TenSach), new SqlParameter("@MaTG", Audio.MaTG), new SqlParameter("@MaTL", Audio.MaTL), new SqlParameter("@MaNXB", Audio.MaNXB), new SqlParameter("@NamXB", Audio.NamXB), new SqlParameter("@FileAudio", Audio.FileAudio), new SqlParameter("@HinhAnh", Audio.HinhAnh), new SqlParameter("@DinhDang", Audio.DinhDang), new SqlParameter("@DungLuong", Audio.DungLuong), new SqlParameter("@ThoiLuong", Audio.ThoiLuong), new SqlParameter("@MCAudio", Audio.MCAudio) }; return(data.AddData(cmd, parameter)); }
private void btnThemA_Click(object sender, EventArgs e) { Audio_DTO audioDTO = new Audio_DTO(); audioDTO.MaAudio = txtMaAudio.Text; audioDTO.TenSach = txtTenSachA.Text; audioDTO.MaTG = txtMaTGAbook.Text; audioDTO.MaTL = txtMaTLAbook.Text; audioDTO.MaNXB = txtMaNXBAbook.Text; audioDTO.NamXB = txtNamXBAbook.Text; audioDTO.FileAudio = txtMP3Abook.Text; audioDTO.HinhAnh = txtImageAbook.Text; audioDTO.DinhDang = txtDinhDangA.Text; audioDTO.DungLuong = txtDungLuongA.Text; audioDTO.ThoiLuong = txtThoiLuongAbook.Text; audioDTO.MCAudio = txtMCAbook.Text; Audio_BO audioBO = new Audio_BO(); int result = 0; result = audioBO.Them(audioDTO); if (result > 0) { MessageBox.Show("Thêm thông tin thành công"); } else { MessageBox.Show("Thông tin này đã tồn tại!"); } }
public int Them(Audio_DTO Audio) { DataAccess data = new DataAccess(); string cmd = @"INSERT INTO AudioBook(MaAudio,TenSach, MaTG ,MaTL, MaNXB, NamXB, FileAudio, HinhAnh, DinhDang, DungLuong,ThoiLuong,MCAudio ) VALUES(@MaAudio,@TenSach ,@MaTG, @MaTL,@MaNXB,@NamXB,@FileAudio,@HinhAnh,@DinhDang,@DungLuong,@ThoiLuong,@MCAudio) "; SqlParameter[] parameter = new SqlParameter[] { new SqlParameter("@MaAudio", Audio.MaAudio), new SqlParameter("@TenSach", Audio.TenSach), new SqlParameter("@MaTG", Audio.MaTG), new SqlParameter("@MaTL", Audio.MaTL), new SqlParameter("@MaNXB", Audio.MaNXB), new SqlParameter("@NamXB", Audio.NamXB), new SqlParameter("@FileAudio", Audio.FileAudio), new SqlParameter("@HinhAnh", Audio.HinhAnh), new SqlParameter("@DinhDang", Audio.DinhDang), new SqlParameter("@DungLuong", Audio.DungLuong), new SqlParameter("@ThoiLuong", Audio.ThoiLuong), new SqlParameter("@MCAudio", Audio.MCAudio) }; int result = data.AddData(cmd, parameter); return(result); }