public bool themDatPhong(DTO_DatPhong dp) { try { conn.Open(); string SQL = string.Format( "INSERT INTO dbo.PHIEUDATPHONG(MAPHIEUDAT,MAPHONG,MA_KH,NGAYDAT,SONGUOI) VALUES ('{0}',N'{1}',N'{2}',N'{3}',N'{4}')" , dp.MAPHIEUDAT, dp.MAPHONG, dp.MA_KH, dp.NGAYDAT, dp.SONGUOI); SqlCommand cmd = new SqlCommand(SQL, conn); int kq = (int)cmd.ExecuteNonQuery(); if (kq > 0) { return(true); } } catch (Exception ex) { throw ex; } finally { conn.Close(); } return(false); }
private void btnSua_DP_Click(object sender, EventArgs e) { DTO_DatPhong DatPhong = new DTO_DatPhong(txtMa_Phieu_Đ.Text, txtMa_P_Đ.Text, txtMa_KH_Đ.Text, dtpNgay_Đ.Text, txtSo_Nguoi_Đ.Text); // thêm if (bus_datphong.suaDatPhong(DatPhong)) { MessageBox.Show("sửa thành công"); dvgDat_phong.DataSource = bus_datphong.getDatPhong(); } else { MessageBox.Show("sửa không thành công"); } }
public bool xoaDatPhong(DTO_DatPhong dp) { try { conn.Open(); string SQL = string.Format("DELETE dbo.PHIEUDATPHONG WHERE MAPHIEUDAT ='{0}'", dp.MAPHIEUDAT); SqlCommand cmd = new SqlCommand(SQL, conn); int kq = cmd.ExecuteNonQuery(); if (kq > 0) { return(true); } } catch (Exception ex) { } finally { conn.Close(); } return(false); }
private void btnThem_DP_Click(object sender, EventArgs e) { if (txtMa_Phieu_Đ.Text != " " && txtMa_P_Đ.Text != " " && txtMa_KH_Đ.Text != " " && txtSo_Nguoi_Đ.Text != " ") { DTO_DatPhong DatPhong = new DTO_DatPhong(txtMa_Phieu_Đ.Text, txtMa_P_Đ.Text, txtMa_KH_Đ.Text, dtpNgay_Đ.Text , txtSo_Nguoi_Đ.Text); // thêm if (bus_datphong.themDatPhong(DatPhong)) { MessageBox.Show("thêm thành công"); dvgDat_phong.DataSource = bus_datphong.getDatPhong(); } else { MessageBox.Show("thêm không thành công"); } } else { MessageBox.Show("xin vui lòng nhập đủ thông tin"); } }
public bool suaDatPhong(DTO_DatPhong dp) { try { conn.Open(); string SQL = string.Format( "UPDATE dbo.PHIEUDATPHONG SET MAPHONG = '{0}', MA_KH = '{1}', NGAYDAT = '{2}', SONGUOI = '{3}' WHERE MAPHIEUDAT = '{4}'", dp.MAPHONG, dp.MA_KH, dp.NGAYDAT, dp.SONGUOI, dp.MAPHIEUDAT); SqlCommand cmd = new SqlCommand(SQL, conn); int kq = cmd.ExecuteNonQuery(); if (kq > 0) { return(true); } } catch (Exception ex) { } finally { conn.Close(); } return(false); }
public bool xoaDatPhong(DTO_DatPhong dp) { return(dao_datphong.xoaDatPhong(dp)); }
public bool themDatPhong(DTO_DatPhong dp) { return(dao_datphong.themDatPhong(dp)); }