Skip to content

Instantly share code, notes, and snippets.

@chadsten
Created February 21, 2017 20:52
Show Gist options
  • Save chadsten/7003e92fea4e8981fd7b61884253eede to your computer and use it in GitHub Desktop.
Save chadsten/7003e92fea4e8981fd7b61884253eede to your computer and use it in GitHub Desktop.
Erp.Tables.OrderDtl OrderDtl;
Erp.Tables.OrderHed OrderHed;
Erp.Tables.Customer Customer;
Erp.Tables.OrderRel OrderRel;
Erp.Tables.PartPlant PartPlant;
Erp.Tables.Vendor Vendor;
Erp.Tables.JobMtl JobMtl;
Erp.Tables.JobOper JobOper;
foreach (var ttSug_Iter in (from ttSug_Row in ttSugPoDtl select ttSug_Row)) {
// load Order Detail record, if it exists
OrderDtl = (from OrderDtl_Row in Db.OrderDtl where ttSug_Iter.Company == OrderDtl_Row.Company && ttSug_Iter.OrderNum == OrderDtl_Row.OrderNum && ttSug_Iter.OrderLine == OrderDtl_Row.OrderLine select OrderDtl_Row).FirstOrDefault();
if (OrderDtl != null) {
ttSug_Iter.SONotes_c = OrderDtl.PONotes_c;
ttSug_Iter.CommentText = OrderDtl.PrintPONotesCB_c;
ttSug_Iter.OrderDtlHold_c = OrderDtl.OrderDtlHold_c;
ttSug_Iter.DueDate = OrderDtl.NeedByDate;
ttSug_Iter.PONotes_c = OrderDtl.PONotes_c;
ttSug_Iter.PrintPONotesCB_c = OrderDtl.PrintPONotesCB_c;
ttSug_Iter.DocUnitPrice = OrderDtl.Cost_c;
ttSug_Iter.UnitPrice = OrderDtl.Cost_c;
ttSug_Iter.ProductNotes_c = OrderDtl.ProductNotes_c; // 2016.09.12.GJG
}
// load Order Rel record, if it exists
OrderRel = (from OrderRel_Row in Db.OrderRel where ttSug_Iter.Company == OrderRel_Row.Company && ttSug_Iter.OrderNum == OrderRel_Row.OrderNum && ttSug_Iter.OrderLine == OrderRel_Row.OrderLine select OrderRel_Row).FirstOrDefault();
if (OrderRel != null) {
ttSug_Iter.SetUDField<System.Boolean>("HotOrder_c", OrderRel.UDField<System.Boolean>("BuyEmergency_c"));
}
// load PartPlant, if it exists (this always should)
PartPlant = (from PartPlant_Row in Db.PartPlant where ttSug_Iter.Company == PartPlant_Row.Company && ttSug_Iter.PartNum == PartPlant_Row.PartNum && ttSug_Iter.Plant == PartPlant_Row.Plant select PartPlant_Row).FirstOrDefault();
if (PartPlant != null) {
ttSug_Iter.SetUDField<System.String>("ItemMoveType_c", PartPlant.UDField<System.String>("ItemMoveType_c"));
}
// load JobMtl record, if it exists
JobMtl = (from JobMtl_Row in Db.JobMtl where ttSug_Iter.Company == JobMtl_Row.Company && ttSug_Iter.JobNum == JobMtl_Row.JobNum && ttSug_Iter.AssemblySeq == JobMtl_Row.AssemblySeq && ttSug_Iter.JobSeq == JobMtl_Row.MtlSeq select JobMtl_Row).FirstOrDefault();
if (JobMtl != null) {
ttSug_Iter.DocUnitPrice = JobMtl.EstUnitCost;
ttSug_Iter.UnitPrice = JobMtl.EstUnitCost;
}
// load JobOper record, if it exists
JobOper = (from JobOper_Row in Db.JobOper where ttSug_Iter.Company == JobOper_Row.Company && ttSug_Iter.JobNum == JobOper_Row.JobNum && ttSug_Iter.JobSeq == JobOper_Row.OprSeq select JobOper_Row).FirstOrDefault();
if (JobOper != null) {
ttSug_Iter.DocUnitPrice = JobOper.EstUnitCost;
ttSug_Iter.UnitPrice = JobOper.EstUnitCost;
}
// load Order Head record, if it exists
OrderHed = (from OrderHed_Row in Db.OrderHed where ttSug_Iter.Company == OrderHed_Row.Company && ttSug_Iter.OrderNum == OrderHed_Row.OrderNum select OrderHed_Row).FirstOrDefault();
if (OrderHed != null) {
ttSug_Iter.HotOrder_c = OrderHed.HotOrder_c;
ttSug_Iter.EntryPerson_c = OrderHed.EntryPerson;
Customer = (from Customer_Row in Db.Customer where ttSug_Iter.Company == Customer_Row.Company && OrderHed.CustNum == Customer_Row.CustNum select Customer_Row).FirstOrDefault();
if (Customer != null) {
if (Customer.CreditHold == true && OrderHed.CreditOverride == false) {
ttSug_Iter.SOCreditHold_c = true;
} else {
ttSug_Iter.SOCreditHold_c = false;
}
}
}
// happens outside of order for Job/Stock Sug Records
Vendor = (from Vendor_Row in Db.Vendor where ttSug_Iter.Company == Vendor_Row.Company && ttSug_Iter.VendorNum == Vendor_Row.VendorNum select Vendor_Row).FirstOrDefault();
if (Vendor != null) {
ttSug_Iter.MinOrderValue_c = Vendor.MinOrderValue;
ttSug_Iter.ShipViaCode = Vendor.ShipViaCode;
if (Vendor.FreightTarget_c != null) {
ttSug_Iter.FreightTarget_c = Vendor.FreightTarget_c;
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment