private void btnThemLP_Click(object sender, EventArgs e) { int c = new PhongDao().addLP(new LOAIPHONG { MaLoai = Int32.Parse(txtMaLoai.Text), TenLoai = txtTenLoai.Text, SoNguoi = Int32.Parse(txtSoNguoi.Text), Gia = float.Parse(txtGia.Text) }); if (c > 0) { MessageBox.Show("Thêm thành công !"); dgvLoaiPhong.DataSource = new PhongDao().DSLoaiPhong(); Load(); } else { MessageBox.Show("Thêm không thành công !"); } }
private void btnXoaP_Click(object sender, EventArgs e) { bool c = new PhongDao().xoaPhong(Int32.Parse(txtMaPhong.Text)); if (c) { MessageBox.Show("Xóa thành công !"); dgvPhong.DataSource = new PhongDao().DSPhong(); txtMaPhong.Text = ""; txtTenLoai.Text = ""; dgvPhong.DataSource = new PhongDao().DSPhong(); } else { MessageBox.Show("Xóa không thành công !"); } }
public void ThemPhong(PhongDao _phongDao) { try { ConnectDB(); OpenConnect(); string sqlInsert = "INSERT INTO Phong VALUES(@TenP,@TrangThai,@MaLP,@Anh,@Gia)"; cmd = new SqlCommand(sqlInsert, conn); cmd.Parameters.AddWithValue("TenP", _phongDao.TenP); cmd.Parameters.AddWithValue("TrangThai", _phongDao.TrangThai); cmd.Parameters.AddWithValue("MaLP", _phongDao.MaLP); cmd.Parameters.AddWithValue("Anh", _phongDao.Anh); cmd.Parameters.AddWithValue("Gia", _phongDao.Gia); cmd.ExecuteNonQuery(); } finally { CloseConnect(); } }
public void UpdatePhong(PhongDao _phongDao) { try { ConnectDB(); OpenConnect(); string sqlUpdate = "UPDATE Phong SET(TenP=@TenP,TrangThai=@TrangThai,MaLP=@MaLP,Gia=@Gia) WHERE MaP=@MaP"; cmd = new SqlCommand(sqlUpdate, conn); cmd.Parameters.AddWithValue("MaP", _phongDao.MaP); cmd.Parameters.AddWithValue("TenP", _phongDao.TenP); cmd.Parameters.AddWithValue("TrangThai", _phongDao.TrangThai); cmd.Parameters.AddWithValue("MaLP", _phongDao.MaLP); cmd.Parameters.AddWithValue("Anh", _phongDao.Anh); cmd.Parameters.AddWithValue("Gia", _phongDao.Gia); cmd.ExecuteNonQuery(); } finally { CloseConnect(); } }
public void UpdatePhong(PhongDao _phongDao) { _phongDal.UpdatePhong(_phongDao); }
public void XoaPhong(PhongDao _phongDao) { _phongDal.DeletePhong(_phongDao); }
public void ThemPhong(PhongDao _phongDao) { _phongDal.ThemPhong(_phongDao); }