// 13. bang phieu dat phong public string InsertPhieuDatPhong(PhieuDatPhong ttPhieuDatPhong) { string Message; SqlConnection con = new SqlConnection(strQuery); con.Open(); SqlCommand cmd = new SqlCommand("insert into Hoadon(SoPD,NgayDat,GioDat,MaPH,MaKH) values(@idSoPD,@ngayDat,@gioDat,@maPH,@maKH)", con); cmd.Parameters.AddWithValue("@idSoPD", ttPhieuDatPhong.soPD); cmd.Parameters.AddWithValue("@ngayDat", ttPhieuDatPhong.ngayDat); cmd.Parameters.AddWithValue("@gioDat", ttPhieuDatPhong.gioDat); cmd.Parameters.AddWithValue("@maPH", ttPhieuDatPhong.maPH); cmd.Parameters.AddWithValue("@maKH", ttPhieuDatPhong.maKH); int result = cmd.ExecuteNonQuery(); if (result == 1) { Message = "phieu dat phong hat duoc them thanh cong"; } else { Message = "phieu dat phong hat them khong thanh cong"; } con.Close(); return(Message); }
public bool DeletePhieuDatPhong(PhieuDatPhong ttPhieuDatPhong) { SqlConnection con = new SqlConnection(strQuery); con.Open(); SqlCommand cmd = new SqlCommand("delete from PhieuDatPHong where SoPD=@idSoPD", con); cmd.Parameters.AddWithValue("@idSoPD", ttPhieuDatPhong.soPD); cmd.ExecuteNonQuery(); con.Close(); return(true); }
public void UpdatePhieuDatPhong(PhieuDatPhong ttPhieuDatPhong) { SqlConnection con = new SqlConnection(strQuery); con.Open(); SqlCommand cmd = new SqlCommand("update PhieuDatPhong set NgayDat=@ngayDat, GioDat=@gioDat, MaPH=@maPH, MaKH=@maKH where SoPD=@idSoPD", con); cmd.Parameters.AddWithValue("@idSoPD", ttPhieuDatPhong.soPD); cmd.Parameters.AddWithValue("@ngayDat", ttPhieuDatPhong.ngayDat); cmd.Parameters.AddWithValue("@gioDat", ttPhieuDatPhong.gioDat); cmd.Parameters.AddWithValue("@maPH", ttPhieuDatPhong.maPH); cmd.Parameters.AddWithValue("@maKH", ttPhieuDatPhong.maKH); cmd.ExecuteNonQuery(); con.Close(); }