The way I write integration by parts is by first choosing one of the functions to be $d$, which is the one we differentiate, and the other function to be $i$, which is the one we integrate. Then, we integrate by parts by doing the following: $d \times \int i - \int \{\int i \cdot $ differential of $d \}$. Which, I think is the same as the formula, but I don't really know how to use the formula properly because I was taught to think of it in this way. Now for your integral, we start of by saying let
$$ I =\int e^{-x} \sin(3x)dx$$
If we select $e^{-x}$ to be the one we integrate and so we will differentiate $\sin(3x)$, as that is easier. So now, if we apply my by parts algorithm to calculate $ I$, we start off by holding $\sin(3x)$, multiplying it by $\int e^{-x}dx = -e^{-x}$, and then subtracting the integral of $-\int e^{-x} \cdot 3 \cos(3x)$, so we get
$$I = \sin(3x) \cdot - e^{-x} - \int \left( - \int e^{-x} \cdot 3 \cdot \cos(3x) \right)$$
$$ = - \sin(3x) e^{-x} - 3 \int \left(e^{-x} \cos(3x)\right)dx.$$
Now, once again, we apply the by parts algorithm to the new bit involving $\cos$. Again, we can choose to integrate $e^{-x}$ and differentiate $\cos(3x)$ and so we get
$$ I = - \sin(3x)e^{-x} - 3 \left[ \cos(3x) \cdot -e^{-x} - \int \left( - \int e^{-x} \cdot - 3\sin(3x) \right) \right]$$
tidying this up gives us
$$I = - \sin(3x)e^{-x} - 3 \left[-\cos(3x)e^{-x} + 3 \underbrace{ \int \left(e^{-x} \sin(3x) \right) }_\text{=I} \right].$$
From here, we see that the final bit in the integral is our original integral, i.e $I$, so we can substitute this in and simplify to get
$$I = - \sin(3x)e^{-x} -3 (- \cos(3x)e^{-x} + 3I)$$
$$I = - \sin(3x)e^{-x} + 3 \cos(3x)e^{-x} - 9I.$$
We can now re-arrange and solve for $I$, which is the answer to our original integral:
$$10I = - \sin(3x)e^{-x} + 3\cos(3x) e^{-x}$$
$$I = \frac{e^{-x} \left( 3 \cos(3x) - \sin(3x) \right)}{10}$$
which is your final answer.