Page 1 of 1

getting MarkUpMaterial value from Job Costing Object

PostPosted: Wed Mar 16, 2022 9:54 am
by indikad
Jiwa 7.2.1
Trying to get the MarkUpMaterial value off the JiwaJobCosting object
see the Jiwa7 code below: I am getting an error after the MessageBox.Show ("1"); line
error = "Object reference not st to an instance...."


*trying to replicate the Jiwa6 code of
Jiwa 6 code
Code: Select all
       Dim jobCostingObject
   Set jobCostingObject = CreateObject("JiwaJobCosting.clsJob")
   Set jobCostingObject.Database = JiwaDatabaseObject
   JobNumber = Left(Trim(FormObject.grdStock.Text("JobNo", Row)), jobCostingObject.LengthJobNo)
   jobCostingObject.ReadRecord 0, JobNumber, "JB_Main.JobNo", False
   MarkUpMaterialVal =  jobCostingObject.MarkUpMaterial



Jiwa 7 code
Code: Select all
public void Setup(JiwaFinancials.Jiwa.JiwaApplication.IJiwaForm JiwaForm, JiwaFinancials.Jiwa.JiwaApplication.Plugin.Plugin Plugin)
    {
      if(JiwaForm is JiwaFinancials.Jiwa.JiwaInvReceivalUI.MainForm)
      {   
         JiwaFinancials.Jiwa.JiwaInvReceivalUI.MainForm goodsRecdNoteEntryForm = (JiwaFinancials.Jiwa.JiwaInvReceivalUI.MainForm )JiwaForm;
         _goodsRecdNoteEntryForm =  goodsRecdNoteEntryForm;
         _Plugin = Plugin;   
         goodsRecdNoteEntryForm.InventoryJiwaGrid.Change +=  InventoryJiwaGridChange ;         
      }
    }   
   private void InventoryJiwaGridChange(object sender ,  FarPoint.Win.Spread.ChangeEventArgs e )
   {
      try
      {   
         JiwaFinancials.Jiwa.JiwaApplication.Controls.JiwaGrid InventoryJiwaGrid = (JiwaFinancials.Jiwa.JiwaApplication.Controls.JiwaGrid) sender;
         JiwaFinancials.Jiwa.JiwaInvReceivalUI.MainForm goodsRecdNoteEntryForm  = _goodsRecdNoteEntryForm  ;
         int iPartNoColIndex = InventoryJiwaGrid.ActiveSheet.Columns["PartNo"].Index;
         if ( InventoryJiwaGrid.ActiveSheet.Cells[e.Row, iPartNoColIndex ].Value.ToString().Trim() == "MISC")
         {
            int iJobNoColIndex = InventoryJiwaGrid.ActiveSheet.Columns["JobNo"].Index;            
            string sJobNo =  InventoryJiwaGrid.ActiveSheet.Cells[e.Row, iJobNoColIndex ].Value.ToString().Trim();            
            JiwaFinancials.Jiwa.JiwaJobCosting.Job oJob = new  JiwaFinancials.Jiwa.JiwaJobCosting.Job();            
            MessageBox.Show ("1");
       // line below gives the Object referenec not set .... error
            oJob.ReadRecord(JiwaFinancials.Jiwa.JiwaJobCosting.Job.ReadModes.ActualRecord , JiwaFinancials.Jiwa.JiwaJobCosting.Job.SeedTypes.JobNo , sJobNo.Trim() , "") ;
            MessageBox.Show ("2");
            MessageBox.Show("Markup mat " + oJob.MarkUpMaterial.ToString());
         }

Re: getting MarkUpMaterial value from Job Costing Object

PostPosted: Wed Mar 16, 2022 11:54 am
by SBarnes
JiwaFinancials.Jiwa.JiwaJobCosting.Job is a business logic object in that it implements JiwaFinancials.Jiwa.JiwaApplication.IJiwaBusinessLogic you should use the business logic factory on a manager to create one don't just new one up, the read will fail because it will use the manager and hence the database which are not set.

Re: getting MarkUpMaterial value from Job Costing Object

PostPosted: Wed Mar 16, 2022 2:48 pm
by indikad
Thanks Stuart, that could be it - have you got a similar example line that you can throw in here ?

Re: getting MarkUpMaterial value from Job Costing Object  Topic is solved

PostPosted: Wed Mar 16, 2022 3:28 pm
by SBarnes
Simple replace


Code: Select all
 JiwaFinancials.Jiwa.JiwaJobCosting.Job oJob = new  JiwaFinancials.Jiwa.JiwaJobCosting.Job();     


with

Code: Select all
JiwaFinancials.Jiwa.JiwaJobCosting.Job oJob = goodsRecdNoteEntryForm.Manager.BusinessLogicFactory.CreateBusinessLogic<JiwaFinancials.Jiwa.JiwaJobCosting.Job>(null);   

Re: getting MarkUpMaterial value from Job Costing Object

PostPosted: Thu Mar 24, 2022 2:03 pm
by indikad
Thanks Stuart. This helped.