I want to validate in order entry if the part entered exists in Parts Database
see the code that i found.
Erp.Tables.Part Part;
foreach(var item in ds.OrderDtl.Where(row => row.Added()||row.Updated()))
{
if(item["PartNum"]!=null)
{
Part = (from Part_Row in Db.Part
where string.Compare(Part_Row.Company,item.Company,true) == 0 &&
Part_Row.PartNum == item.PartNum select Part_Row ).FirstOrDefault();
if(Part==null)
{
throw new BLException("Part "+ item["PartNum"].ToString()+ " is not created in System, Please create "+ item["PartNum"].ToString()+ " in part master and proceed. ");
}
}
}
I Tried to do this in pre-processing with this method
where string.Compare(Part_Row.Company,Session.CompanyID) == 0 &&
Part_Row.PartNum == partNum select Part_Row ).FirstOrDefault();
if(Part==null)
{
throw new BLException("Part "+ partNum.ToString()+ " is not created in System, Please create "+ partNum.ToString()+ " in part master and proceed. ");
}
}