Automatically get a list of items on the invoice.

Purpose: in the moment when the user selects the desired order in the edit form, invoice, neobhodimo create detaily (ЗаписьВНакладной) on the basis of what is specified in the order.

1.Add Заказ in the string representation of the order, remove the check mark in the box Видимость.

2.To regenerate the objects. 3.in NakladnayaE.aspx.cs to register:

using ICSSoft.STORMNET.Business;
using ICSSoft.STORMNET.FunctionalLanguage;
using ICSSoft.STORMNET.Windows.Forms;

4.Further, to correct the method PreApplyToControls as follows:

protected override void PreApplyToControls()
{
	if (IsPostBack && (DataObject == null || DataObject.GetStatus(true) == ObjectStatus.Created))
	{
		var заказ = ctrlЗаказ.SelectedMasterPK;
		ctrlЗаказ.MasterViewName = Заказ.Views.ЗаказL.Name;
		
		var lcs = LoadingCustomizationStruct.GetSimpleStruct(typeof(СтрокаЗаказа), СтрокаЗаказа.Views.СтрокаЗаказаE);
		lcs.LimitFunction = FunctionBuilder.BuildEquals<СтрокаЗаказа>(x => x.Заказ, заказ);
		var строкиЗаказа = DataServiceProvider.DataService.LoadObjects(lcs);

		foreach (var s in строкиЗаказа)
		{
			var строкаЗаказа = (СтрокаЗаказа)s;
			DataObject.ЗаписьВНакладной.Add(new ЗаписьВНакладной { Количество = строкаЗаказа.Количество, Товар = строкаЗаказа.Товар });
		}
	}
}

This method checks whether there has been PostBack, and then using the service data loaded detaily class Заказ (loadable representation is detaily), because by default they are not loaded. After loading in a loop are formed and are filled detaily. Don’t forget to change the setting flexberryautogenerated on false to form not to lose the changes upon regeneration.

5.To ensure that the method PreApplyToControls worked immediately after selecting the values in lucapa, you must add an event handler change lucapa, which cause PostBack. In NakladnayaE.aspx to register:

<script type="text/javascript">
	$('#<%= ctrlЗаказ.ClientID %>').on('change', function (e, d) {
		$.ics.postBack('', '');
	});
</script>

6.Not to forget each modified file to change the setting flexberryautogenerated to avoid losing changes.

Go