Page 1 of 2

Add new Category 6

PostPosted: Mon Feb 13, 2023 9:08 am
by DannyC
Had a request to add another inventory category, Category6. Exactly like this old forum question
viewtopic.php?f=26&t=718

The answer above doesn't go into much detail. Is there a sample plugin I could dissect and tweak? I just need a basic framework I can build on but don't know where to start.

No need for custom fields like we have in Cat1-5.

V 7.2.1.

Re: Add new Category 6

PostPosted: Mon Feb 13, 2023 9:48 am
by SBarnes
The question comes down to one of scope, for instance do you need to provide maintenance to the data in category 6, do you need the user the to be able to change the label like you can for categories 1 - 5 and do you need to be able to clear the field.

The lookup on the screen is not that complicated but you will need two custom tables in the database, one for the list and one to link the product to the category.

If you require the ability to be able to maintain the category then that would most likely put the answer beyond a forum post as there would be a reasonable amount of code involved and is probably best handled by getting a quote from Jiwa here

Re: Add new Category 6

PostPosted: Mon Feb 13, 2023 10:07 am
by DannyC
I've made a small start:

Code: Select all
#region "FormPlugin"
public class FormPlugin : System.MarshalByRefObject, JiwaFinancials.Jiwa.JiwaApplication.IJiwaFormPlugin
{

    public override object InitializeLifetimeService()
    {
        // returning null here will prevent the lease manager
        // from deleting the Object.
        return null;
    }

    public void SetupBeforeHandlers(JiwaFinancials.Jiwa.JiwaApplication.IJiwaForm JiwaForm, JiwaFinancials.Jiwa.JiwaApplication.Plugin.Plugin Plugin)
    {
    }

    public void Setup(JiwaFinancials.Jiwa.JiwaApplication.IJiwaForm JiwaForm, JiwaFinancials.Jiwa.JiwaApplication.Plugin.Plugin Plugin)
    {
        if (JiwaForm is JiwaFinancials.Jiwa.JiwaInventoryUI.InventoryMaintenanceForm)
        {
            JiwaFinancials.Jiwa.JiwaInventoryUI.InventoryMaintenanceForm inventoryForm = JiwaForm as JiwaFinancials.Jiwa.JiwaInventoryUI.InventoryMaintenanceForm;
            inventoryForm.CategoriesUltraGroupBox.Controls.Add(inventoryForm.Category6Lookup);
            inventoryForm.CategoriesUltraGroupBox.Controls.Add(inventoryForm.Category6Label);
      }
    }
   
   
    public virtual Infragistics.Win.Misc.UltraLabel Category6Label
    {
        get;
        [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.Synchronized)]
        set;
    }

    public virtual JiwaFinancials.Jiwa.JiwaApplication.Controls.Lookup Category6Lookup
    {
        get;
        [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.Synchronized)]
        set;
    }   
}
#endregion

Re: Add new Category 6

PostPosted: Mon Feb 13, 2023 10:18 am
by DannyC
do you need to provide maintenance to the data in category 6

Some way of maintaining the list, yes. Doesn't need to be added to the existing Categories screen for editing, but at least a separate screen to add/delete/edit the descriptions.

do you need the user the to be able to change the label like you can for categories 1 - 5

Not for this development. I'm sure they'd be happy just to have it hardcoded. Or even just keep it "Category 6".

you will need two custom tables in the database, one for the list and one to link the product to the category.

Yep - understood. That's the easy bit!

Re: Add new Category 6

PostPosted: Mon Feb 13, 2023 10:38 am
by DannyC
Thinking through this a bit more...I am sure for this client just a custom field with an editable list might be sufficient.

I can use this as the basis
viewtopic.php?f=26&t=576
and
viewtopic.php?f=27&t=498

It would be nicer if it's an extra category, easier for them to manage & understand. But doing it as a custom field combobox means I already have the knowhow.

Re: Add new Category 6

PostPosted: Mon Feb 13, 2023 10:44 am
by SBarnes
I would suggest you don't the problem you will have is with deletes and edits for instance if you keep the primary key/id field in the custom field and some one deletes one there is no data integrity likewise if you keep the description in the custom field and someone changes the description similar issue.

I would also not want to try and make it appear on a report that way either.

Re: Add new Category 6

PostPosted: Mon Feb 13, 2023 11:31 am
by DannyC
I would suggest you don't the problem you will have is with deletes and edits for instance if you keep the primary key/id field in the custom field and some one deletes one there is no data integrity likewise if you keep the description in the custom field and someone changes the description similar issue.


OK, fair enough.
Over to you then.

Re: Add new Category 6

PostPosted: Mon Feb 13, 2023 11:34 am
by Mike.Sheen
DannyC wrote:Over to you then.


I missed the part where Stuart volunteered to do this.

Re: Add new Category 6

PostPosted: Tue Feb 14, 2023 11:48 am
by DannyC
Just for my own edification and challenge, I've knocked up a plugin which has a maintenance list for Category 6 values. Whether I deploy or not is a moot point as at this stage I'd just like to get it working. Stuart & I have had discussions (outside the forum) on the merits & negatives of using custom fields like this.

The custom form/list works well and I can add, delete, edit values.

The problem I'm having is that when I try to use it as a basis for inventory combobox values, I am getting an error on Read() of the collection.
The error is occurring within the Read() at line 212
Code: Select all
var db = Manager.Database;
because Manager is null. I've tried
Code: Select all
var db = this.Manager.Database;
and
Code: Select all
var db = base.Manager.Database;
but each time the Manager is null.

What's the trick to getting a valid manager?

Note the debugger is enabled in the attached plugin.

Re: Add new Category 6  Topic is solved

PostPosted: Tue Feb 14, 2023 1:59 pm
by SBarnes
Without testing it this line is your problem

Code: Select all
Category6Collection Cat6ComboBoxValues = new Category6Collection() ;


change it to


Code: Select all
Category6Collection Cat6ComboBoxValues = BusinessLogicHost.Manager.BusinessLogicFactory.CreateBusinessLogic<Category6Collection>(null);


Anything with a manager in it should be created by the appropriate factory never just new it up with a constructor, the factory will attach the manager and call set up.