Add new Category 6  Topic is solved

Discussions relating to plugin development, and the Jiwa API.

Add new Category 6

Postby DannyC » Mon Feb 13, 2023 9:08 am

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.
User avatar
DannyC
Senpai
Senpai
 
Posts: 636
Joined: Fri Mar 22, 2013 12:23 pm
Topics Solved: 30

Re: Add new Category 6

Postby SBarnes » Mon Feb 13, 2023 9:48 am

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
Regards
Stuart Barnes
SBarnes
Shihan
Shihan
 
Posts: 1619
Joined: Fri Aug 15, 2008 3:27 pm
Topics Solved: 175

Re: Add new Category 6

Postby DannyC » Mon Feb 13, 2023 10:07 am

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
User avatar
DannyC
Senpai
Senpai
 
Posts: 636
Joined: Fri Mar 22, 2013 12:23 pm
Topics Solved: 30

Re: Add new Category 6

Postby DannyC » Mon Feb 13, 2023 10:18 am

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!
User avatar
DannyC
Senpai
Senpai
 
Posts: 636
Joined: Fri Mar 22, 2013 12:23 pm
Topics Solved: 30

Re: Add new Category 6

Postby DannyC » Mon Feb 13, 2023 10:38 am

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.
User avatar
DannyC
Senpai
Senpai
 
Posts: 636
Joined: Fri Mar 22, 2013 12:23 pm
Topics Solved: 30

Re: Add new Category 6

Postby SBarnes » Mon Feb 13, 2023 10:44 am

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.
Regards
Stuart Barnes
SBarnes
Shihan
Shihan
 
Posts: 1619
Joined: Fri Aug 15, 2008 3:27 pm
Topics Solved: 175

Re: Add new Category 6

Postby DannyC » Mon Feb 13, 2023 11:31 am

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.
User avatar
DannyC
Senpai
Senpai
 
Posts: 636
Joined: Fri Mar 22, 2013 12:23 pm
Topics Solved: 30

Re: Add new Category 6

Postby Mike.Sheen » Mon Feb 13, 2023 11:34 am

DannyC wrote:Over to you then.


I missed the part where Stuart volunteered to do this.
Mike Sheen
Chief Software Engineer
Jiwa Financials

If I do answer your question to your satisfaction, please mark it as the post solving the topic so others with the same issue can readily identify the solution
User avatar
Mike.Sheen
Overflow Error
Overflow Error
 
Posts: 2444
Joined: Tue Feb 12, 2008 11:12 am
Location: Perth, Republic of Western Australia
Topics Solved: 756

Re: Add new Category 6

Postby DannyC » Tue Feb 14, 2023 11:48 am

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.
Attachments
Plugin Category6 Maintenance.xml
(54.86 KiB) Downloaded 56 times
User avatar
DannyC
Senpai
Senpai
 
Posts: 636
Joined: Fri Mar 22, 2013 12:23 pm
Topics Solved: 30

Re: Add new Category 6  Topic is solved

Postby SBarnes » Tue Feb 14, 2023 1:59 pm

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.
Regards
Stuart Barnes
SBarnes
Shihan
Shihan
 
Posts: 1619
Joined: Fri Aug 15, 2008 3:27 pm
Topics Solved: 175

Next

Return to Technical and or Programming

Who is online

Users browsing this forum: No registered users and 25 guests