I’ve added a button to the top of the Assembly Details page within the Job Entry that is supposed to add 1 labor quantity to the operation. The issue i’m having is it loops around 3-6 times adding Labor Quantity each time. I can’t find anything in my code to signify this, any advice?
var JobHead = this.Db.JobHead.Where(x => x.JobNum == jobNumber && x.Company == Session.CompanyID).FirstOrDefault();
var emp = this.Session.EmployeeID;
if (JobHead != null)
{
var AsmHead = this.Db.JobAsmbl.Where(x => x.AssemblySeq == AsmSeq && x.Company == Session.CompanyID).FirstOrDefault();
if (AsmHead != null)
{
var AllOps = this.Db.JobOper.Where(x => x.AssemblySeq == AsmHead.AssemblySeq && x.Company == Session.CompanyID).AsEnumerable();
if (AllOps != null)
{
//this.PublishInfoMessage($"{AllOps.Count()} & {emp}", Ice.Common.BusinessObjectMessageType.Information, Ice.Bpm.InfoMessageDisplayMode.Individual, "title 1", "title 2");
foreach (var op in AllOps)
{
try
{
//this.PublishInfoMessage($"ASM: {op.AssemblySeq} -- Op Seq: {op.OprSeq} -- Code: {op.OpCode} -- Description: {op.OpDesc}", Ice.Common.BusinessObjectMessageType.Information, Ice.Bpm.InfoMessageDisplayMode.Individual, "LaborQuant", "LaborQuantityUpdate");
var context = Ice.Services.ContextFactory.CreateContext<ErpContext>();
using (var lbr = ServiceRenderer.GetService<Erp.Contracts.LaborSvcContract>(context))
{
string msg;
var ts = new Erp.Tablesets.LaborTableset();
ts.LaborDtl[0].RowMod = "U";
lbr.GetNewLaborDtlNoHdr(ref ts, "300080", false, DateTime.Today, 0, DateTime.Today, 0);
lbr.DefaultJobNum(ref ts, jobNumber);
lbr.LaborRateCalc(ref ts);
lbr.DefaultAssemblySeq(ref ts, AsmSeq);
lbr.LaborRateCalc(ref ts);
lbr.ChangeLaborDtlOprSeq(ref ts, op.OprSeq, out msg);
lbr.LaborRateCalc(ref ts);
lbr.DefaultLaborQty(ref ts, 1, out msg);
lbr.CheckWarnings(ref ts, out msg);
lbr.Update(ref ts);
lbr.ValidateChargeRateForTimeType(ref ts, out msg);
lbr.SubmitForApprovalBySelected(ref ts, false, out msg);
}
AsmHead.AsmCompDate_c = DateTime.Today;
AsmHead.AsmComplete_c = true;
this.Db.SaveChanges();
}
catch
{
// perform actions if there is an error
}
}
}
}
}
I’ve created a few UD fields to hold data within the JobAsmbl table. I’ve also been having issues with the Session.EmployeeID
as it only works on the first loop and returns null for the employee after the fact.
I also have read about the LaborTableset.LaborDtl[0].RowMod = "U"
but i am unsure of the reasoning for this.