Ejemplo n.º 1
0
        private void NewMethod()
        {
            CollectionSourceBase collectionSource = application.CreateCollectionSource(objectSpace, type, ListViewId);
            string criteria = application.Model.Views[ListViewId].GetValue <string>("Criteria");

            collectionSource.SetCriteria("Filter1", criteria);
            var count = collectionSource.GetCount();

            this.label1.Text = count.ToString();
            if (count > 0 && ShowColor)
            {
                this.BackColor = Color.FromArgb(203, 46, 2);
            }
        }
Ejemplo n.º 2
0
        private void callbackPanel_Callback(object sender, CallbackEventArgsBase e)
        {
            if (e.Parameter == "add")
            {
                var newObject = (XPBaseObject)_objectSpace.CreateObject(Model.ModelClass.TypeInfo.Type);
                _collectionSource.Add(newObject);

                BindDataSource();

                object itemOid = newObject.GetMemberValue(Model.ModelClass.KeyProperty); // newObject.Oid;
                try{
                    var firstOrDefault = Model.Columns.Where(t => t.Index.HasValue && t.Index.Value >= 0)
                                         .OrderBy(t => t.Index.Value)
                                         .FirstOrDefault();
                    if (firstOrDefault != null)
                    {
                        _controlsPerObjectInList[itemOid][
                            firstOrDefault
                            .PropertyName].Focus();
                    }
                }
                catch {
                }
            }
            else if (e.Parameter != null && e.Parameter.StartsWith("changed_"))
            {
                string[] split        = e.Parameter.Split('_');
                string   itemOid      = split[2];
                string   propertyName = split[1];
                BindDataSource();
                try{
                    object key = _controlsPerObjectInList.Keys.FirstOrDefault(item => item.ToString() == itemOid);

                    if (key != null && _controlsPerObjectInList.ContainsKey(key))
                    {
                        _controlsPerObjectInList[key][propertyName].Focus();
                    }
                }
                catch {
                }
            }
            else if (e.Parameter != null && e.Parameter.StartsWith("rem_"))
            {
                string itemOid = e.Parameter.Replace("rem_", "");
                if (_dataSourceList == null)
                {
                    return;
                }
                XPBaseObject itemToBeDeleted = _dataSourceList.Cast <XPBaseObject>().FirstOrDefault(item => item.GetMemberValue(Model.ModelClass.KeyProperty).ToString() == itemOid);
                if (itemToBeDeleted != null)
                {
                    _collectionSource.Remove(itemToBeDeleted);
                    itemToBeDeleted.Delete();
                }
                if (_collectionSource.GetCount() == 0 && _btnAddFirst != null)
                {
                    _btnAddFirst.Visible = true;
                }

                BindDataSource();

                FocusCorrectControl();
            }
            ToggleHeadersVisibility();

            OnCallbackPerformed();
        }
Ejemplo n.º 3
0
 void cs_CollectionChanged(object sender, EventArgs e)
 {
     System.Diagnostics.Debug.WriteLine(cs.GetCount());
 }