Ejemplo n.º 1
0
        public static async Task SetDimValues(Type tp, DimComboBoxEditor cb, CrudAPI api, bool showNoChnage = false)
        {
            var cache = api.GetCache(tp) ?? await api.LoadCache(tp);

            List <IdKey> lst = new List <IdKey>((cache != null) ? cache.Count + 2 : 2);

            if (showNoChnage)
            {
                lst.Add(new KeyNamePair()
                {
                    _RowId = -1, _KeyStr = Uniconta.ClientTools.Localization.lookup("NoChange")
                });
            }
            else
            {
                lst.Add(new KeyNamePair()
                {
                    _RowId = -2, _KeyStr = Uniconta.ClientTools.Localization.lookup("Values")
                });
            }
            lst.Add(new KeyNamePair()
            {
                _RowId = 0, _KeyStr = Uniconta.ClientTools.Localization.lookup("Blank")
            });

            if (cache != null && cache.Count > 0)
            {
                foreach (GLDimType dim in cache.GetKeyStrRecords)
                {
                    lst.Add(new KeyNamePair()
                    {
                        _RowId = dim.RowId, _KeyStr = string.Format("{0} ({1})", dim.KeyStr, dim.KeyName)
                    });
                }
            }

            cb.ItemsSource   = lst;
            cb.ValueMember   = "RowId";
            cb.DisplayMember = "KeyStr";
            if (showNoChnage)
            {
                cb.SelectedIndex = 0;
            }
        }
Ejemplo n.º 2
0
 public static List <int> GetRowIDs(DimComboBoxEditor cb)
 {
     return((cb.EditValue as List <object>)?.Cast <int>().ToList());
 }