public Boolean GetDataDP_khongLP(string maPhong, DateTime start, DateTime finish) { ExecuteDB e = new ExecuteDB(); string sql = "SELECT COUNT(*) FROM DatPhong WHERE MaPhong = N'" + maPhong + "' AND(NgayNhan >= '" + finish.ToString("yyyy-MM-dd") + "' OR NgayTra <= '" + start.ToString("yyyy-MM-dd") + "')"; int status = (int)e.ExecuteScalar(sql); if (status != 0) { return(false); } return(true); }
public Boolean GetDataDP_coLP(string maPhong, DateTime start, DateTime finish, string tenLP) { ExecuteDB e = new ExecuteDB(); string sql = "SELECT COUNT(*) FROM DatPhong WHERE MaPhong = N'" + maPhong + "' AND(NgayNhan >= '" + finish.ToString("yyyy-MM-dd") + "' OR NgayTra <= '" + start.ToString("yyyy-MM-dd") + "') AND MaPhong IN (SELECT MaPhong FROM Phong WHERE MaLP IN (SELECT IDLoaiPhong FROM LoaiPhong WHERE TenLP = N'" + tenLP + "'))"; int status = (int)e.ExecuteScalar(sql); if (status != 0) { return(false); } return(true); }
public Boolean ThemDP(DatPhong_DTO dp) { ExecuteDB e = new ExecuteDB(); string sql = "SELECT COUNT(*) FROM DatPhong WHERE MaPhong = N'" + dp.MaPhong + "' AND(NgayNhan >= '" + dp.NgayTra.ToString("yyyy-MM-dd") + "' OR NgayTra <= '" + dp.NgayNhan.ToString("yyyy-MM-dd") + "')"; int status = (int)e.ExecuteScalar(sql); if (status != 0) { return(false); } sql = "INSERT INTO DatPhong VALUES(N'" + dp.IDDatPhong + "', N'" + dp.MaKH + " ', N'" + dp.MaNV + "', N'" + dp.MaPhong + "', '" + dp.NgayDat.ToString("yyyy-MM-dd") + "', '" + dp.NgayNhan.ToString("yyyy-MM-dd") + "', '" + dp.NgayTra.ToString("yyyy-MM-dd") + "', '" + dp.ThanhTien + "', '" + dp.TraTruoc + "', N'" + dp.GhiChu + "', 1)"; return(e.ExecuteData(sql)); }