public int Sua(TheLoai_DTO tlDTO) { DataAccess data = new DataAccess(); string cmd = @"UPDATE TheLoai SET TenTL = @tentl WHERE MaTL = @matl "; SqlParameter[] parameter = new SqlParameter[] { new SqlParameter("@matl", tlDTO.MaTL), new SqlParameter("@tentl", tlDTO.TenTL) }; return(data.AddData(cmd, parameter)); }
public int Them(TheLoai_DTO tlDTO) { DataAccess data = new DataAccess(); string cmd = @"INSERT INTO TheLoai(MaTL,TenTL) VALUES(@matl,@tentl ) "; SqlParameter[] parameter = new SqlParameter[] { new SqlParameter("@matl", tlDTO.MaTL), new SqlParameter("@tentl", tlDTO.TenTL) }; int result = data.AddData(cmd, parameter); return(result); }
private void btnThemTL_Click(object sender, EventArgs e) { TheLoai_DTO thDTO = new TheLoai_DTO(); thDTO.MaTL = txtMaTL.Text; thDTO.TenTL = txtTenTL.Text; TheLoai_BO tlBO = new TheLoai_BO(); int result = 0; result = tlBO.Them(thDTO); 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!"); } }
private void btnSuaTL_Click(object sender, EventArgs e) { TheLoai_DTO thDTO = new TheLoai_DTO(); thDTO.MaTL = txtMaTL.Text; thDTO.TenTL = txtTenTL.Text; TheLoai_BO tlBO = new TheLoai_BO(); int result = 0; result = tlBO.Sua(thDTO); if (result > 0) { MessageBox.Show("Sửa thành công!"); } else { MessageBox.Show("Sửa thất bại!"); } }