示例#1
0
        public static bool IsEditValueInDataSource(this LookUpEdit lookupEdit)
        {
            if (lookupEdit.Properties.DataSource == null || !lookupEdit.HasValue())
            {
                return(false);
            }

            bool result;

            if (lookupEdit.Properties.DataSource is DataTable)
            {
                var dtLookup = lookupEdit.Properties.DataSource as DataTable;
                result = DataTableContainsValue(dtLookup, lookupEdit.Properties.ValueMember, lookupEdit.EditValue);
            }
            else if (lookupEdit.Properties.DataSource is BindingSource)
            {
                var bsLookup = lookupEdit.Properties.DataSource as BindingSource;
                result = BindingSourceContainsValue(bsLookup, lookupEdit.Properties.ValueMember, lookupEdit.EditValue);
            }
            else
            {
                result = false;
            }

            return(result);
        }
示例#2
0
        /// <summary>
        /// Clears the Editvalue if no longer in DataSource
        /// </summary>
        public static void CheckEditValueInAgainstDataSource(this LookUpEdit lookupEdit)
        {
            if (!lookupEdit.HasValue())
            {
                return;
            }

            if (!lookupEdit.IsEditValueInDataSource())
            {
                lookupEdit.EditValue = null;
            }
        }
示例#3
0
        /// <summary>
        /// Clears the Editvalue if no longer in DataSource
        /// </summary>
        public static T GetEditValue <T>(this LookUpEdit lookupEdit)
        {
            T editValue;

            if (lookupEdit.HasValue())
            {
                editValue = (T)lookupEdit.EditValue;
            }
            else
            {
                editValue = default(T);
            }

            return(editValue);
        }