PR Header if Material select then same in TDI Purchase Category
var documentTypeID = PR.PurchaseRequisition_TDH.DocumentType; // Replace with the correct property name var documentType = db.DocumentType_ECH .FirstOrDefault(dt => dt.DocumentTypeID == documentTypeID); if (documentType != null) { // Get the corresponding PurchaseCategoryCode based on DocumentTypeCode string purchaseCategoryCode = documentType.DocumentTypeCode == "MReq" ? "M" : ...