Good morning in the code below, which I’m using in Custom Function Code is there a way to update the two tables below using BO or is using the Db the best or simplest way to make these updates?
try
{
var partOprs = this.Db.PartOpr.Where(po => po.Company == Session.CompanyID &&
po.PartNum == ipPartNumber &&
po.OprSeq == ipOprSeq &&
po.OpCode == ipOpCode);
foreach (var partOpr in partOprs)
{
partOpr.EstUnitCost = ipNewEstUnitCost;
partOpr.VendorNum = ipNewVendorNum;
partOpr.PurPoint = ipNewPurPoint;
}
var jobOpers = this.Db.JobOper.Where(jo => jo.Company == Session.CompanyID &&
jo.PartNum == ipPartNumber &&
jo.OprSeq == ipOprSeq &&
jo.OpCode == ipOpCode &&
jo.OpComplete == false &&
!jo.JobNum.StartsWith("MRP"));
foreach (var jobOper in jobOpers)
{
jobOper.EstUnitCost = ipNewEstUnitCost;
jobOper.VendorNum = ipNewVendorNum;
jobOper.PurPoint = ipNewPurPoint;
}
this.Db.SaveChanges();
opSuccess = 1;
}
catch (Exception ex)
{
opErrorMsg = ex.Message;
opSuccess = 0;
}