private async void ExecuteWizardFinishingAsync(object sender, FinishingEventArgs e) { try { // The values indicated in the wizard are loaded List <Aliquo.Core.Models.DataField> result = (List <Aliquo.Core.Models.DataField>)e.Result; string customerCode = Aliquo.Core.Data.FindField(result, "CustomerCode").Value.ToString(); DateTime dateNote = Aliquo.Core.Convert.ValueToDate(Aliquo.Core.Data.FindField(result, "DateNote").Value); string productCode = Aliquo.Core.Data.FindField(result, "ProductCode").Value.ToString(); // We create the model to store the data Aliquo.Core.Models.Note note = new Aliquo.Core.Models.Note(); // The collection starts note.Lines = new List <Aliquo.Core.Models.Line>(); // This is the basic information to create a note note.Type = Aliquo.Core.NoteType.SalesOrder; note.PropertyCode = customerCode; note.Date = dateNote; Aliquo.Core.Models.Line line = new Aliquo.Core.Models.Line { Type = Aliquo.Core.LineType.Product, Code = productCode, Quantity = 1 }; // The line is assigned to the model list note.Lines.Add(line); // Call the function to create the note long id = await Host.Documents.SetNoteAsync(note); // Update the list this.View.Refresh(); } catch (HandledException ex) { throw new HandledException(ex.Message, ex); } catch (System.Exception ex) { throw new Exception(ex.Message, ex); } }
private async void Command_Execute(IHost sender, ExecuteEventArgs e) { try { // We create the model to store the data Aliquo.Core.Models.Note note = new Aliquo.Core.Models.Note(); // The collection starts note.Lines = new List <Aliquo.Core.Models.Line>(); // This is the basic information to create a note note.Type = Aliquo.Core.NoteType.SalesOrder; note.PropertyCode = "001"; Aliquo.Core.Models.Line line = new Aliquo.Core.Models.Line { Type = Aliquo.Core.LineType.Product, Code = "0275", Quantity = 1 }; // The line is assigned to the model list note.Lines.Add(line); // Call the function to create the note Int64 id = await sender.Documents.SetNoteAsync(note); // Update the list e.View.Refresh(); // Now, if necessary, the document created on the screen is displayed sender.Documents.Views.ShowNote(id, isActive: true); } catch (Exception ex) { sender.Management.Views.ShowException(ex); } }