Ejemplo n.º 1
0
        private void RemoveLine(object sender, EventArgs e)
        {
            var current = GridView.GetSelected <t>();

            if (current.StateRecord == eState.eAdd && Lines.IndexOf(current) < 0)
            {
                if (OnRemoveList != null)
                {
                    var args = new GridViewEditableEventArgs()
                    {
                        item = current
                    };
                    OnRemoveList(this, args);

                    if (args.Cancel)
                    {
                        return;
                    }
                }

                Lines.Remove(current);
            }
            else
            {
                if (OnRemoveList != null)
                {
                    var args = new GridViewEditableEventArgs()
                    {
                        item = current
                    };
                    OnRemoveList(this, args);

                    if (args.Cancel)
                    {
                        return;
                    }
                }

                current.StateRecord = eState.eRemove;
            }

            FillAll();

            if (OnChangeList != null)
            {
                OnChangeList(this, new EventArgs());
            }
        }
Ejemplo n.º 2
0
        void AtiveEditor_EditValueChanged(object sender, EventArgs e)
        {
            t CurrentLine = GridView.GetSelected <t>();

            //Verifica se o registro á o último se for
            //adicina a lista
            switch (CurrentLine.StateRecord)
            {
            case eState.eAdd:
            {
                var line = Lines.IndexOf(CurrentLine);

                if (line < 0)
                {
                    //var nextID = Lines.Count == 0 ? 1 : Lines.Max(p => p.KeyFields[0].GetInt32()) + 1;
                    //CurrentLine.KeyFields[0].Value = nextID;

                    if (OnAddList != null)
                    {
                        var args = new GridViewEditableEventArgs()
                        {
                            item = CurrentLine
                        };
                        OnAddList(this, args);
                        if (args.Cancel)
                        {
                            return;
                        }
                    }

                    if (!Lines.Contains(CurrentLine))
                    {
                        Lines.Add(CurrentLine);
                    }
                }
            }
            break;

            case eState.eDatabase:
                CurrentLine.StateRecord = eState.eUpdate;
                break;
            }

            if (OnChangeList != null)
            {
                OnChangeList(this, new EventArgs());
            }
        }