Limiting Inventory Search

Discussions relating to Jiwa 7 plugin development, and the Jiwa 7 API.

Limiting Inventory Search

Postby pricerc » Fri Jul 10, 2020 2:33 pm

I'm trying to limit an inventory search.

The following code works fine unless I uncomment the "// search.Options.Clear();", at which point double-clicking on a search result, I get me an exception: 'Conversion from string "" to type 'Integer' is not valid.'

I do know it's something to do with turning on "search.ShowQuantityInSearchResults", because with that turned off, it also works, I just can't change the quantities.

Code: Select all
   public static bool DoInventorySearch(Form ownerForm, string searchText)
   {
      JiwaSearch.clsSearch search = Jiwa.Search;

                search.Clear();
                search.FilterNo = 36;
                search.CurrentOption = 1;
                search.Caption = "Inventory";
                var searchMode = JiwaSearch.clsSearch.SearchModes.jswInventory;
                search.SetDefaultSearch(ref searchMode);
                // search.Options.Clear();
                search.ShowQuantityInSearchResults = true;
                search.ShowSSCMatrixInSearch = false;
                search.UsePinBoard = true;

                JiwaSearch.SearchOption AOption = Jiwa.CollectionItemFactory.CreateCollectionItem<JiwaSearch.SearchOption>();
                AOption.Title = "Inventory Search";
                AOption.SQLStr = "SELECT InventoryID, DecimalPlaces, PartNo, Description, Category1, Category2, Category3, Category4, Category5, Classification, DefaultPrice, Available, Aux2 FROM POS_InventorySearch";
                AOption.OrderBy = "ORDER BY PartNo, Description, Classification, Category1, Category2, Category3, Category4, Category5";
                AOption.AddColumn("ID", VariantType.String, string.Empty, 0, 1);
                AOption.AddColumn("Decimal Places", VariantType.Integer, string.Empty, 0, 2);
                AOption.AddColumn("PartNo", VariantType.String, string.Empty, 10, 3);
                AOption.AddColumn("Description", VariantType.String, string.Empty, 20, 4);
                AOption.AddColumn(Cat1Description, VariantType.String, string.Empty, 7, 5);
                AOption.AddColumn(Cat2Description, VariantType.String, string.Empty, 7, 6);
                AOption.AddColumn(Cat3Description, VariantType.String, string.Empty, 7, 7);
                AOption.AddColumn(Cat4Description, VariantType.String, string.Empty, 7, 8);
                AOption.AddColumn(Cat5Description, VariantType.String, string.Empty, 7, 9);
                AOption.AddColumn("Class", VariantType.String, string.Empty, 9, 10);
                AOption.AddColumn("Price", VariantType.Double, JiwaMoneyFormat, 9, 11, ".", 2);
                AOption.AddColumn("Available", VariantType.Double, string.Empty, 8, 12, ".", 0, JiwaSearch.Column.DecimalPlacesTypes.AnotherColumn, true, ",", 2);
                AOption.AddColumn("Bar Code", VariantType.String, string.Empty, 9, 13);

                search.AddSearchOption(ref AOption);
                search.CurrentOption = AOption.ItemNo;
                // search.Filters.Clear();

                search.PreTypedKeys = searchText;

                if (search.Show(ownerForm) == DialogResult.OK)
                    if (search.Results.Count != 0)
                        return true;

                return false;
   }


What secret sauce am I missing?
/Ryan

ERP Consultant,
Advanced ERP Limited, NZ
https://aerp.co.nz
User avatar
pricerc
Senpai
Senpai
 
Posts: 518
Joined: Mon Aug 10, 2009 12:22 pm
Location: Auckland, NZ
Topics Solved: 21

Re: Limiting Inventory Search

Postby pricerc » Fri Jul 10, 2020 2:50 pm

To answer my own question:

Code: Select all
       AOption.AddColumn("Decimal Places", VariantType.Integer, string.Empty, 0, 2);


needs to be

Code: Select all
       AOption.AddColumn("Decimals", VariantType.Integer, string.Empty, 0, 2);
/Ryan

ERP Consultant,
Advanced ERP Limited, NZ
https://aerp.co.nz
User avatar
pricerc
Senpai
Senpai
 
Posts: 518
Joined: Mon Aug 10, 2009 12:22 pm
Location: Auckland, NZ
Topics Solved: 21

Re: Limiting Inventory Search

Postby SBarnes » Sat Jul 11, 2020 3:06 pm

Hi Ryan

I've done a similar thing before but with using one of Jiwa's standard searches like this, which avoided having to redo the columns

Code: Select all
private void Category2Lookup_ButtonClicked(object sender, EventArgs e,  JiwaFinancials.Jiwa.JiwaInventoryUI.InventoryMaintenanceForm iform)
    {
      if(!iform.Inventory.WebEnabled)
      {
         return;
      }
        if(iform.Inventory.Category1.RecID != "")
      {
         //System.Windows.Forms.MessageBox.Show("Got here");
         
         
         string str;
            Form ownerForm;
            clsSearch search = iform.Manager.Search;
            search.Clear();
            search.FilterNo = 4002;
            search.UsePinBoard = false;
            search.Caption = "Category 2";
            search.SQLWhereCondition = " WHERE Category2ID in (select from vAttk_Cat2ToCat1 where category1 = '" + iform.Inventory.Category1.RecID  + "') ";
            clsSearch.SearchModes searchMode = clsSearch.SearchModes.jswInventoryCatagory2;
         
            search.SetDefaultSearch(ref searchMode);
         search.Options[1].SQLStr += " WHERE Category2ID in (select Category2ID from vAttk_Cat2ToCat1 where category1 = '" + iform.Inventory.Category1.RecID  + "') ";
            clsSearch _clsSearch = search;
            ownerForm = iform;

            if (_clsSearch.Show(ownerForm) != DialogResult.OK)
            {
                str = "";
            }
            else
            {
            if(search.Results.Count == 0)
            {
               
               str  = "";
            }
            else
            {
               JiwaFinancials.Jiwa.JiwaApplication.JiwaSearch.Field field = (JiwaFinancials.Jiwa.JiwaApplication.JiwaSearch.Field)_clsSearch.get_Fields(1);
               str = field.FieldValue.ToString();
            }
               
            }
         //System.Windows.Forms.MessageBox.Show(str);
         if(str != null && str != "")
         {
             iform.Inventory.Category2.ReadRecord( str);      
         }
              
         
         
         
         throw new JiwaFinancials.Jiwa.JiwaApplication.Exceptions.ClientCancelledException();
      }
    }
Regards
Stuart Barnes
SBarnes
Shihan
Shihan
 
Posts: 1696
Joined: Fri Aug 15, 2008 3:27 pm
Topics Solved: 191

Re: Limiting Inventory Search

Postby pricerc » Mon Jul 13, 2020 9:22 am

SBarnes wrote:Hi Ryan

I've done a similar thing before but with using one of Jiwa's standard searches like this, which avoided having to redo the columns


My code come pretty much straight out of the POS plugin, so someone else already re-did the columns!

I'm working on an even simpler version, that will also be usable 'standalone' so that a PC can run the POS without starting full JIWA. Long term, I'd like to make one that is platform-independent and uses the REST API, since even without starting the full JIWA, it's a bit slow while it loads all the plugins. But we have an opportunity in a very small retail store, and I need to get something working quickly.
/Ryan

ERP Consultant,
Advanced ERP Limited, NZ
https://aerp.co.nz
User avatar
pricerc
Senpai
Senpai
 
Posts: 518
Joined: Mon Aug 10, 2009 12:22 pm
Location: Auckland, NZ
Topics Solved: 21

Re: Limiting Inventory Search

Postby SBarnes » Mon Jul 13, 2020 9:54 am

Hi Ryan,

apologies if you alreafy know this but if you are looking to do it with the Rest API take a look at AutoQuery for ServiceStack if you don't already know about it.

The api doesn't by default define all the routes but you can add them for instance https://api.jiwa.com.au/swagger-ui/#!/Q ... N_Main_Get is already there, for any others you just need to add the routes.

With the T4 templates for ORMLite it can be run against the database and create the request and response classes for any stored procedure or views that you add.

You can even annotate a request class with [QueryDb(QueryTerm.Or)] to make it or the query conditions passed in as opposed to and
Regards
Stuart Barnes
SBarnes
Shihan
Shihan
 
Posts: 1696
Joined: Fri Aug 15, 2008 3:27 pm
Topics Solved: 191


Return to Technical and or Programming

Who is online

Users browsing this forum: No registered users and 3 guests