@PartId should probably be declared as an Int and not a VarChar
@PartId is not initialzed and therefore is null before the select:
If the select returns 0 rows then the @PartId will be unchanged and will remain null.
If the select does contain rows and the all values for Part_ID are null then @PartId will be assigned null.
After the select:
Set @PartId = IsNull( @PartId, 1 )
Whether the select returns a null or returns no rows, the Set IsNull will give the desired results.