Yes you are right. But yet The Updating Querys logic is erronous.It is vulnerable to add duplicate record.
IF EXISTS (SELECT p.pid from trans t
join M_prdt P On P.pid = t.pid WHERE p.pid=@ppid )
UPDATE trans set pid=@ppid ,qty=@pqty ,rate=@prate ,AMOUNT=@pamt ,billno=@pbillno ,frmdt=@pfrmdt ,todt=@ptodt
WHERE cid= @pcid and [Month] =@pmonth and [year] = @pyear and pid=@ppid and billno=@pbillno
Else
insert into trans(tid,cid,pid,qty,rate,AMOUNT,[month],[year],billno,frmdt,todt)
values (@pmaxid, @pcid ,@ppid,@pqty,@prate ,@pamt,@pmonth,@pyear,@pbillno,@pfrmdt,@ptodt)
condition should include Primary key of the master table (I dont know weather p.pid is your pk but just assumed or it should be.) This way your problem is not with code but you are inserting wrongly.We needs to fix this.