Shipment line custom field  Topic is solved

Discussions relating to plugin development, and the Jiwa API.

Shipment line custom field

Postby perry » Mon Nov 20, 2023 3:41 pm

Hi,

7.2.1

A customer is looking for lookup and dropdown custom fields on shipment line. Since we dont have custom field table for shipment line, I'm planning to add a button & dropdown column to the grid. The value will be stored against one of those spare fields(1-10).

I'm curious on what event should be used for the lookup column. I cant find a suitable event in shipmentForm.ShipmentLinesJiwaGrid for assigning the cell's Items and ItemData property. Also not sure what event should be used when user select a value (shipmentForm.ShipmentLinesJiwaGrid.Change?).

Any assistance is much appreciated.
Perry Ma
S. Programmer
Lonicera Pty Ltd
http://www.lonicera.com.au
perry
Frequent Contributor
Frequent Contributor
 
Posts: 173
Joined: Mon Oct 27, 2008 2:26 pm
Topics Solved: 15

Re: Shipment line custom field  Topic is solved

Postby SBarnes » Tue Nov 21, 2023 6:33 am

Here are some code snipptets from one of my projects that should hopefully point you in the right direction, the project just to give you the context of what you are looking at replaces the usual debtor address tab and then allows you to link 2 debtor contacts to each address. Most of the vent handlers are the original ones from Jiwa with extra code to handle the extra bits I needed to do.

You add the column to the grid like this, contact1 is used to display the results of the look up and Contact1Btn is the actual button column

Code: Select all
grid.AddColumn("Contact1", new JiwaTextCellType(), "Contact 1", 8, false, true, true, true, 50, false, false, 0, true);
 grid.AddColumn("Contact1Btn", new JiwaLookupButtonCellType(dform.Manager), "",10, false, true, true, false, 50, false, false, 0, true);


and you react to it like this

Add the event handler for the button click of the grid

Code: Select all
 grid.ButtonClicked += ExtraAddressesGrid_ButtonClicked;


and the actual event handler method is something like this

Code: Select all
private void ExtraAddressesGrid_ButtonClicked(object sender, EditorNotifyEventArgs e)
        {
            if (!this.debtor.IsReading)
            {
                JiwaGrid jiwaGrid = this.addressgrid;
                string str = Conversions.ToString(jiwaGrid.get_GridText("Key", e.Row)).Trim();
                object tag = jiwaGrid.ActiveSheet.Columns[e.Column].Tag;
                if (Operators.ConditionalCompareObjectEqual(tag, "Bin", false))
                {
                    this.debtor.DeliveryAddresses.Remove(this.debtor.DeliveryAddresses[str]);
                }
                else if (Operators.ConditionalCompareObjectEqual(tag, "Default", false) && str.Trim().Length > 0)
                {
                    bool defval = Conversions.ToBoolean(this.addressgrid.get_GridText("Default", e.Row));
                    this.debtor.DeliveryAddresses[str].IsDefault = Conversions.ToBoolean(this.addressgrid.get_GridText("Default", e.Row));
                }
                else if (Operators.ConditionalCompareObjectEqual(tag, "Contact1Btn", false))
                {

                    string con1id = this.delcontacts.Search(this.debtorform);
                    if (con1id != "")
                    {
                        DBDeliveryAddressContact dcon = delcontacts.GetDeliverAddressContactForDelID(str);
                        dcon.ContactID1 = con1id;
                        JiwaFinancials.Jiwa.JiwaDebtors.DeliveryAddress item = this.debtor.DeliveryAddresses[str];
                        item.Address1 = item.Address1;
                        this.DisplayContact(str);
                        this.debtorform.CheckEditStatus();

                    }

                }
                else if (Operators.ConditionalCompareObjectEqual(tag, "Contact1Btn", false))
                {

                    string con1id = this.delcontacts.Search(this.debtorform);
                    if (con1id != "")
                    {
                        DBDeliveryAddressContact dcon = delcontacts.GetDeliverAddressContactForDelID(str);
                        dcon.ContactID1 = con1id;
                        JiwaFinancials.Jiwa.JiwaDebtors.DeliveryAddress item = this.debtor.DeliveryAddresses[str];
                        item.Address1 = item.Address1;
                        this.DisplayContact(str);
                        this.debtorform.CheckEditStatus();

                    }

                }
                else if (Operators.ConditionalCompareObjectEqual(tag, "Contact2Btn", false))
                {

                    string con2id = this.delcontacts.Search(this.debtorform);
                    if (con2id != "")
                    {
                        DBDeliveryAddressContact dcon = delcontacts.GetDeliverAddressContactForDelID(str);
                        dcon.ContactID2 = con2id;
                        JiwaFinancials.Jiwa.JiwaDebtors.DeliveryAddress item = this.debtor.DeliveryAddresses[str];
                        item.Address1 = item.Address1;
                        this.DisplayContact(str);
                        this.debtorform.CheckEditStatus();

                    }


                }
                else if (Operators.ConditionalCompareObjectEqual(tag, "GetLL", false))
                {

                    Debug.DoDebug();
                    JiwaFinancials.Jiwa.JiwaDebtors.DeliveryAddress item = this.debtor.DeliveryAddresses[str];
                    LocationServices.MapPoint result = Helpers.LocationUtility.GetLocation(Settings.SettingsVault.GoogleAPIKey, item.AsText());
                    DBDeliveryAddressContact dcon = delcontacts.GetDeliverAddressContactForDelID(str);
                   

                    dcon.Latitude = (decimal)result.Latitude;
                    dcon.Longitude = (decimal)result.Longitude;
                    item.Address1 = item.Address1;
                    this.DisplayDeliveryAddress(str);
                    this.debtorform.CheckEditStatus();

                }




                   





            }
        }



The grid changed event handler is added like this

Code: Select all
 grid.Change += ExtraAddressesGrid_Change;


and its event handler looks like this

Code: Select all
  private void ExtraAddressesGrid_Change(object sender, ChangeEventArgs e)
        {
            string str = "";
            string str1 = "";
            string str2 = "";
            string str3 = "";
            string str4 = "";
            string str5 = "";
            string str6 = "";
            string str7 = "";
            string str8 = "";
            string str9 = "";
            string str10 = "";
            string str12 = "";
            if (!this.debtor.IsReading)
            {
                JiwaGrid jiwaGrid = this.addressgrid;
                string str11 = Conversions.ToString(this.addressgrid.get_GridText("Key", e.Row));
                if (str11.Trim().Length != 0)
                {
                    JiwaFinancials.Jiwa.JiwaDebtors.DeliveryAddress item = this.debtor.DeliveryAddresses[str11];
                    object tag = jiwaGrid.ActiveSheet.Columns[e.Column].Tag;
                    if (Operators.ConditionalCompareObjectEqual(tag, "Address1", false))
                    {
                        item.Address1 = Conversions.ToString(this.addressgrid.get_GridText("Address1", e.Row));
                    }
                    else if (Operators.ConditionalCompareObjectEqual(tag, "Address2", false))
                    {
                        item.Address2 = Conversions.ToString(this.addressgrid.get_GridText("Address2", e.Row));
                    }
                    else if (Operators.ConditionalCompareObjectEqual(tag, "Suburb", false))
                    {
                        item.Address3 = Conversions.ToString(this.addressgrid.get_GridText("Suburb", e.Row));
                    }
                    else if (Operators.ConditionalCompareObjectEqual(tag, "State", false))
                    {
                        item.Address4 = Conversions.ToString(this.addressgrid.get_GridText("State", e.Row));
                    }
                    else if (Operators.ConditionalCompareObjectEqual(tag, "Notes", false))
                    {
                        item.Notes = Conversions.ToString(this.addressgrid.get_GridText("Notes", e.Row));
                    }
                    else if (Operators.ConditionalCompareObjectEqual(tag, "Postcode", false))
                    {
                        item.Postcode = Conversions.ToString(this.addressgrid.get_GridText("Postcode", e.Row));
                    }
                    else if (Operators.ConditionalCompareObjectEqual(tag, "Country", false))
                    {
                        item.Country = Conversions.ToString(this.addressgrid.get_GridText("Country", e.Row));
                    }
                    else if (Operators.ConditionalCompareObjectEqual(tag, "Default", false))
                    {
                        item.IsDefault = Conversions.ToBoolean(this.addressgrid.get_GridText("Default", e.Row));
                    }
                    else if (Operators.ConditionalCompareObjectEqual(tag, "Courier", false))
                    {
                        item.CourierDetails = Conversions.ToString(this.addressgrid.get_GridText("Courier", e.Row));
                    }
                    else if (Operators.ConditionalCompareObjectEqual(tag, "EDIStoreLocationCode", false))
                    {
                        item.EDIStoreLocationCode = Conversions.ToString(this.addressgrid.get_GridText("EDIStoreLocationCode", e.Row));
                    }
                    else if (Operators.ConditionalCompareObjectEqual(tag, "DeliveryAddressCode", false))
                    {
                        item.DeliveryAddressCode = Conversions.ToString(this.addressgrid.get_GridText("DeliveryAddressCode", e.Row));
                    }
                    else if (Operators.ConditionalCompareObjectEqual(tag, "DeliveryAddressName", false))
                    {
                        item.DeliveryAddressName = Conversions.ToString(this.addressgrid.get_GridText("DeliveryAddressName", e.Row));
                    }
                    else if (Operators.ConditionalCompareObjectEqual(tag, "LongitudeLatitude", false))
                    {
                        str12 = Conversions.ToString(this.addressgrid.get_GridText("LongitudeLatitude", e.Row));
                    }


                }
                else
                {
                    object obj = jiwaGrid.ActiveSheet.Columns[e.Column].Tag;
                    if (Operators.ConditionalCompareObjectEqual(obj, "Address1", false))
                    {
                        str = Conversions.ToString(this.addressgrid.get_GridText("Address1", e.Row));
                    }
                    else if (Operators.ConditionalCompareObjectEqual(obj, "Address2", false))
                    {
                        str1 = Conversions.ToString(this.addressgrid.get_GridText("Address2", e.Row));
                    }
                    else if (Operators.ConditionalCompareObjectEqual(obj, "Suburb", false))
                    {
                        str2 = Conversions.ToString(this.addressgrid.get_GridText("Suburb", e.Row));
                    }
                    else if (Operators.ConditionalCompareObjectEqual(obj, "State", false))
                    {
                        str3 = Conversions.ToString(this.addressgrid.get_GridText("State", e.Row));
                    }
                    else if (Operators.ConditionalCompareObjectEqual(obj, "Country", false))
                    {
                        str3 = Conversions.ToString(this.addressgrid.get_GridText("Country", e.Row));
                    }
                    else if (Operators.ConditionalCompareObjectEqual(obj, "Postcode", false))
                    {
                        str4 = Conversions.ToString(this.addressgrid.get_GridText("Postcode", e.Row));
                    }
                    else if (Operators.ConditionalCompareObjectEqual(obj, "Notes", false))
                    {
                        str6 = Conversions.ToString(this.addressgrid.get_GridText("Notes", e.Row));
                    }
                    else if (Operators.ConditionalCompareObjectEqual(obj, "Country", false))
                    {
                        str5 = Conversions.ToString(this.addressgrid.get_GridText("Country", e.Row));
                    }
                    else if (Operators.ConditionalCompareObjectEqual(obj, "Courier", false))
                    {
                        str7 = Conversions.ToString(this.addressgrid.get_GridText("Courier", e.Row));
                    }
                    else if (Operators.ConditionalCompareObjectEqual(obj, "EDIStoreLocationCode", false))
                    {
                        str8 = Conversions.ToString(this.addressgrid.get_GridText("EDIStoreLocationCode", e.Row));
                    }
                    else if (Operators.ConditionalCompareObjectEqual(obj, "DeliveryAddressCode", false))
                    {
                        str9 = Conversions.ToString(this.addressgrid.get_GridText("DeliveryAddressCode", e.Row));
                    }
                    else if (Operators.ConditionalCompareObjectEqual(obj, "DeliveryAddressName", false))
                    {
                        str10 = Conversions.ToString(this.addressgrid.get_GridText("DeliveryAddressName", e.Row));
                    }
                    else if (Operators.ConditionalCompareObjectEqual(obj, "LongitudeLatitude", false))
                    {
                        str12 = Conversions.ToString(this.addressgrid.get_GridText("LongitudeLatitude", e.Row));
                    }
                    JiwaFinancials.Jiwa.JiwaDebtors.DeliveryAddress deliveryAddress = this.manager.CollectionItemFactory.CreateCollectionItem<JiwaFinancials.Jiwa.JiwaDebtors.DeliveryAddress>();
                    deliveryAddress.Address1 = str;
                    deliveryAddress.Address2 = str1;
                    deliveryAddress.Address3 = str2;
                    deliveryAddress.Address4 = str3;
                    deliveryAddress.Postcode = str4;
                    deliveryAddress.Notes = str6;
                    deliveryAddress.Country = str5;
                    deliveryAddress.CourierDetails = str7;
                    deliveryAddress.EDIStoreLocationCode = str8;
                    deliveryAddress.DeliveryAddressCode = str9;
                    deliveryAddress.DeliveryAddressName = str10;
                    string recIDBA = deliveryAddress.RecID;
                    this.debtor.DeliveryAddresses.Add(deliveryAddress);
                    try
                    {
                        this.delcontacts.GetDeliverAddressContactForDelID(recIDBA).DeliveryID = deliveryAddress.RecID;
                        this.addressgrid.set_GridText("Key", e.Row, deliveryAddress.RecID);
                    }
                    catch (Exception ex)
                    {

                       
                    }
                   
                }
                if (str12 != "")
                {
                    string strid = Conversions.ToString(this.addressgrid.get_GridText("Key", e.Row));
                    DBDeliveryAddressContact dcon = delcontacts.GetDeliverAddressContactForDelID(strid);
                    dcon.LongitudeLatitude = str12;
                }
                jiwaGrid = null;
            }
        }



for the drop down you want capture it closing which is attached like this, on this one I'll admit I haven't used it

Code: Select all
 grid.ComboCloseUp += Grid_ComboCloseUp;


and the handler signature looks like this

Code: Select all
        private void Grid_ComboCloseUp(object sender, EditorNotifyEventArgs e)
        {
            throw new NotImplementedException();
        }


To add combo columns and set data to them looks like the below which is out of Jiwa's bank reconciliation screen and hence the vb but this should also point you in the right direction bear in mind this code is in a with grdTransactions block hence starting with . notation

Code: Select all
 .AddColumn("Type", New CellType.ComboBoxCellType, "Type", 10, False, True, True, True, , True)
 DirectCast(.ActiveSheet.Columns("Type").CellType, CellType.ComboBoxCellType).Items = New String() {"Direct GL Transaction", "Direct Debtor Receipt", "Direct Debtor Payment", "Direct Creditor Receipt", "Direct Creditor Payment", "Opening Balance Transaction"}
 DirectCast(.ActiveSheet.Columns("Type").CellType, CellType.ComboBoxCellType).ItemData = New String() {"Direct GL Transaction", "Direct Debtor Receipt", "Direct Debtor Payment", "Direct Creditor Receipt", "Direct Creditor Payment", "Opening Balance Transaction"}
Regards
Stuart Barnes
SBarnes
Shihan
Shihan
 
Posts: 1619
Joined: Fri Aug 15, 2008 3:27 pm
Topics Solved: 175

Re: Shipment line custom field

Postby perry » Wed Nov 22, 2023 9:38 am

Code: Select all
 grid.ComboCloseUp += Grid_ComboCloseUp;


Thanks!
Perry Ma
S. Programmer
Lonicera Pty Ltd
http://www.lonicera.com.au
perry
Frequent Contributor
Frequent Contributor
 
Posts: 173
Joined: Mon Oct 27, 2008 2:26 pm
Topics Solved: 15


Return to Technical and or Programming

Who is online

Users browsing this forum: No registered users and 15 guests

cron