Skip to content

Instantly share code, notes, and snippets.

@smarenich
Last active October 9, 2018 04:09
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save smarenich/3839a2d25e7143317f6a3b1e821199d2 to your computer and use it in GitHub Desktop.
Save smarenich/3839a2d25e7143317f6a3b1e821199d2 to your computer and use it in GitHub Desktop.
public class SOARDocTypesListAttribute : PXStringListAttribute, IPXRowSelectedSubscriber
{
public Type _Module;
public class OrderTypesDefinition : IPrefetchable
{
public Dictionary<String, String> list = new Dictionary<String, String>();
public void Prefetch()
{
list.Clear();
foreach (PXDataRecord rec in PXDatabase.SelectMulti<SOOrderType>(
new PXDataField<SOOrderType.orderType>(),
new PXDataField<SOOrderType.descr>()))
{
list[rec.GetString(0)] = rec.GetString(1);
}
}
}
public SOARDocTypesListAttribute(Type module)
: base()
{
_Module = module;
}
public void RowSelected(PXCache sender, PXRowSelectedEventArgs e)
{
Object row = e.Row as Object;
String module = (String)sender.GetValue(row, _Module.Name);
if (row != null && module != null)
{
if (module == arModule.value)
{
PXStringListAttribute.SetList(sender, row, _FieldName, new ARDocType.ListAttribute());
}
if (module == soModule.value)
{
OrderTypesDefinition def = PXDatabase.GetSlot<OrderTypesDefinition>(typeof(OrderTypesDefinition).Name, typeof(SOOrderType));
PXStringListAttribute.SetList(sender, row, _FieldName, def.list.Keys.ToArray(), def.list.Values.ToArray());
}
}
}
}
#endregion
[Serializable]
public class DAC : IBqlTable
{
#region DocType
[PXDBString(3, IsKey = true, IsFixed = false)]
[PXUIField(DisplayName = "Doc Type", Enabled = false)]
[SOARDocTypesListAttribute(typeof(DAC.module))]
public string DocType { get; set; }
public class docType : IBqlField { }
#endregion
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment