Open up Shipment Notes for editing on Closed shipment  Topic is solved

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

Open up Shipment Notes for editing on Closed shipment

Postby DannyC » Wed Dec 01, 2021 3:18 pm

I wonder if it's possible to open up the Notes text box on closed shipments so users can still edit.

The following isn't working but there must be something else to it.
Version 7.2.1 SR4
Code: Select all
public void Setup(JiwaFinancials.Jiwa.JiwaApplication.IJiwaForm JiwaForm, JiwaFinancials.Jiwa.JiwaApplication.Plugin.Plugin Plugin)
{
   if (JiwaForm is JiwaFinancials.Jiwa.JiwaLandedCostUI.Shipment.Shipment)
   {
      JiwaFinancials.Jiwa.JiwaLandedCostUI.Shipment.Shipment shipmentForm = (JiwaFinancials.Jiwa.JiwaLandedCostUI.Shipment.Shipment)JiwaForm;
      shipmentForm.Shipment.ReadEnd += ReadShipmentEnd;
   }
}
   
private void ReadShipmentEnd(object sender, System.EventArgs e)
{
   JiwaFinancials.Jiwa.JiwaLandedCost.Shipment.Shipment shipment = (JiwaFinancials.Jiwa.JiwaLandedCost.Shipment.Shipment)sender;
   JiwaFinancials.Jiwa.JiwaLandedCostUI.Shipment.Shipment shipmentForm = (JiwaFinancials.Jiwa.JiwaLandedCostUI.Shipment.Shipment)shipment.Client;
      
   if (shipment.Status == JiwaFinancials.Jiwa.JiwaLandedCost.Shipment.Shipment.StatusType.Closed)
      {
         shipmentForm.TableLayoutPanel1.Enabled = true;
         shipmentForm.NotesUltraTextEditor.Enabled = true;
      }
}
User avatar
DannyC
Senpai
Senpai
 
Posts: 718
Joined: Fri Mar 22, 2013 12:23 pm
Topics Solved: 31

Re: Open up Shipment Notes for editing on Closed shipment  Topic is solved

Postby Mike.Sheen » Thu Dec 02, 2021 1:35 pm

We typically use the MakeReadOnly method of the Manager to lock and unlock controls.

Code: Select all
Manager.MakeReadOnly(shipmentForm.NotesUltraTextEditor, false);


Attached plugin demonstrates this.
Attachments
Plugin Shipment form - unlock notes.xml
(16.97 KiB) Downloaded 576 times
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: 2583
Joined: Tue Feb 12, 2008 11:12 am
Location: Perth, Republic of Western Australia
Topics Solved: 807

Re: Open up Shipment Notes for editing on Closed shipment

Postby DannyC » Fri Dec 03, 2021 10:11 am

That's great!
Whilst it answers the question on how to unlock the text box, unfortunately for Shipments I'm now getting this error:
shipment error.png
shipment error.png (15.68 KiB) Viewed 2079 times


With each character typed this message appears and furthermore the save icon isn't active.

Maybe I could do it with an InputBox and write it directly to the database?
User avatar
DannyC
Senpai
Senpai
 
Posts: 718
Joined: Fri Mar 22, 2013 12:23 pm
Topics Solved: 31

Re: Open up Shipment Notes for editing on Closed shipment

Postby DannyC » Sat Dec 04, 2021 10:16 am

In case anyone is interested, the business logic doesn't allow editing notes on closed shipments.
I can't even temporarily change the status to 'entering' as that property is read only.

The workaround as I see it, is to grab the currrent Notes, chuck 'em in an InputBox and add to them as needed then update the SH_Main table.
I've added a button to the Utilities tab to fire it.

It ain't pretty but it works.

If someone could chime in with how we might be able to display a multi-line inputbox, that'd be great but for now I've attached the plugin I knocked up to give others an opportunity to comment & improve it.
Attachments
Plugin Attkey Open Notes for editing on Closed Shipments.xml
(27.62 KiB) Downloaded 393 times
User avatar
DannyC
Senpai
Senpai
 
Posts: 718
Joined: Fri Mar 22, 2013 12:23 pm
Topics Solved: 31

Re: Open up Shipment Notes for editing on Closed shipment

Postby pricerc » Mon Dec 06, 2021 10:46 am

DannyC wrote:If someone could chime in with how we might be able to display a multi-line inputbox, that'd be great but for now I've attached the plugin I knocked up to give others an opportunity to comment & improve it.


Just roll your own:
Code: Select all
public class NoteDialog : Form
{
    private TextBox noteEditor;

    public NoteDialog()
    {
        InitialiseDialog();
    }

    public int MaxLength
    {
        get { return noteEditor.MaxLength; }
        set { noteEditor.MaxLength = value; }
    }

    public string Note
    {
        get { return noteEditor.Text; }
        set { noteEditor.Text = value; }
    }
    public int MaxLength
    {
        get { return noteEditor.MaxLength; }
        set { noteEditor.MaxLength = value; }
    }

    public string Note
    {
        get { return noteEditor.Text; }
        set { noteEditor.Text = value; }
    }

    private void InitialiseDialog()
    {
        noteEditor = new TextBox
        {
            Anchor = AnchorStyles.Top | AnchorStyles.Bottom | AnchorStyles.Left | AnchorStyles.Right,
            Location = new System.Drawing.Point(12, 12),
            MaxLength = 250,
            Multiline = true,
            Size = new System.Drawing.Size(408, 86),
            TabIndex = 1
        };

        Button OK_Button = new Button
        {
            Anchor = AnchorStyles.Bottom | AnchorStyles.Right,
            Location = new System.Drawing.Point(280, 113),
            Size = new System.Drawing.Size(67, 23),
            TabIndex = 2,
            Text = "OK"
        };
        OK_Button.Click += (sender, e) =>
        {
            DialogResult = DialogResult.OK;
            Close();
        };

        Button Cancel_Button = new Button
        {
            Anchor = AnchorStyles.Bottom | AnchorStyles.Right,
            DialogResult = DialogResult.Cancel,
            Location = new System.Drawing.Point(353, 113),
            Size = new System.Drawing.Size(67, 23),
            TabIndex = 3,
            Text = "Cancel"
        };
        Cancel_Button.Click += (sender, e) =>
        {
            DialogResult = DialogResult.Cancel;
            Close();
        };

        SuspendLayout();

        AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
        AutoScaleMode = AutoScaleMode.Font;
        ClientSize = new System.Drawing.Size(435, 148);
        Controls.Add(OK_Button);
        Controls.Add(Cancel_Button);
        Controls.Add(noteEditor);
        FormBorderStyle = FormBorderStyle.SizableToolWindow;
        MaximizeBox = false;
        MinimizeBox = false;
        Name = "NoteDialog";
        ShowInTaskbar = false;
        StartPosition = FormStartPosition.CenterParent;
        Text = "Enter Notes";
        ResumeLayout(false);
        PerformLayout();
    }
}


Code: Select all
...
var toolbarManager = (Infragistics.Win.UltraWinToolbars.UltraToolbarsManager)sender;
var shipmentForm = (JiwaFinancials.Jiwa.JiwaLandedCostUI.Shipment.Shipment)toolbarManager.DockWithinContainer;
var shipment = shipmentForm.Shipment;
...
var noteDialog = new NoteDialog() { Note = shipment.DeliveryNotes, MaxLength = 250 };
if(noteDialog.ShowDialog(shipmentForm) == DialogResult.OK)
{
   ShipmentNotes = noteDialog.Note;

// additional code here.
}
/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


Return to Technical and or Programming

Who is online

Users browsing this forum: No registered users and 1 guest