Page 1 of 1

Open up Shipment Notes for editing on Closed shipment

PostPosted: Wed Dec 01, 2021 3:18 pm
by DannyC
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;
      }
}

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

PostPosted: Thu Dec 02, 2021 1:35 pm
by Mike.Sheen
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.

Re: Open up Shipment Notes for editing on Closed shipment

PostPosted: Fri Dec 03, 2021 10:11 am
by DannyC
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 2081 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?

Re: Open up Shipment Notes for editing on Closed shipment

PostPosted: Sat Dec 04, 2021 10:16 am
by DannyC
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.

Re: Open up Shipment Notes for editing on Closed shipment

PostPosted: Mon Dec 06, 2021 10:46 am
by pricerc
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.
}