Example #1
0
        void _submit(object sender, EventArgs e)
        {
            bool Insert = false;

            if (DataEntity == null)
            {
                Insert     = true;
                DataEntity = Activator.CreateInstance(DataEntityType) as IDataEntity;
            }

            foreach (var i in Children)
            {
                if (i is FieldBase)
                {
                    (i as FieldBase).Update(DataEntity);
                }
            }

            if (Updating != null)
            {
                Updating(this, new UpdateEventArgs(DataEntity));
            }

            try
            {
                int res;
                if (Insert)
                {
                    res = DataEntity.Insert(Data.CommandBuilder.InsertType.New, null);
                }
                else
                {
                    res = DataEntity.Update(null, UpdateFields);
                }
                if (res > -1)
                {
                    Tip.Text     = SuccessTip;
                    Tip.CssClass = FailCssClass;
                }
                else
                {
                    Tip.Text     = FailTip;
                    Tip.CssClass = FailCssClass;
                }
            }
            catch
            {
                Tip.Text     = FailTip;
                Tip.CssClass = FailCssClass;
            }
        }