示例#1
0
        private void SendValue()
        {
            if (m_loadingData)
            {
                return;
            }
            if (dataGridView1.DataSource == null)
            {
                return;
            }
            if (m_data == null || m_data.LookupInfo == null)
            {
                return;
            }
            if (dataGridView1.SelectedRows.Count != 1)
            {
                return;
            }
            DataTable       tbl = (DataTable)dataGridView1.DataSource;
            DataGridViewRow row = dataGridView1.SelectedRows[0];
            object          value = row.Cells[m_data.LookupInfo.PkColIndex].Value;
            BedValueHolder  h1 = new BedValueHolder(), h2 = new BedValueHolder();

            h1.ReadFrom(value);
            m_data.BedConvertor.ConvertValue(h1, m_targetType, h2);
            m_data.SetData(h2);
        }
示例#2
0
        public static bool GetValueAsXml(object value, ref string xtype, ref string xdata)
        {
            var holder = new BedValueHolder();

            holder.ReadFrom(value);
            return(GetValueAsXml(holder, ref xtype, ref xdata));
        }
示例#3
0
        public void SetValue(int colindex, IBedValueReader reader)
        {
            var holder = new BedValueHolder();

            m_table.BedConvertor.ConvertValue(reader, GetDefaultStorage(colindex), holder);
            m_fields[colindex].Value   = holder.GetValue();
            m_fields[colindex].Changed = true;
            if (RowState == BedRowState.Unchanged)
            {
                RowState = BedRowState.Modified;
            }
        }
示例#4
0
        // not very efective, better is to direct call DDA.GetSqlLiteral
        public static string GetSqlLiteral(this ISqlDialect dialect, object value)
        {
            var hld = new BedValueHolder();
            var dda = dialect.CreateDataAdapter();

            hld.ReadFrom(value);
            return(dda.GetSqlLiteral(hld));
            //if (value == DBNull.Value || value == null) return "NULL";
            //if (value.GetType().IsNumberType()) return dialect.EscapeNumber(value);
            //if (value is byte[]) return dialect.EscapeBinary((byte[])value);
            //if (value is DateTime) return dialect.EscapeDateTime((DateTime)value);
            //if (value is bool) return dialect.EscapeLogical((bool)value);
            //return dialect.QuoteString(Convert.ToString(value, CultureInfo.InvariantCulture));
        }
        protected virtual void ApplyTypeRestrictions(BedValueHolder holder, DbTypeBase type, ILogger logger)
        {
            var stype = type as DbTypeString;
            var htype = holder.GetFieldType();

            if (stype != null && htype == TypeStorage.String)
            {
                string sval = holder.GetString();
                if (stype.Length > 0 && sval.Length > stype.Length)
                {
                    sval = sval.Substring(0, stype.Length);
                    holder.SetString(sval);
                }
            }
            if (htype.IsDateRelated() && !m_allowZeroInDate)
            {
                var dt = holder.GetDateTimeValue();
                dt.MakeValidDate();
                m_holder.SetDateTimeEx(dt);
            }
        }
示例#6
0
        public virtual string ReadHash(IBedValueReader reader, BedValueConvertor auxConv, BedValueHolder auxHolder)
        {
            switch (reader.GetFieldType())
            {
            case TypeStorage.String:
                return(reader.GetString().ToLower());

            case TypeStorage.ByteArray:
            {
                byte[] data = reader.GetByteArray();
                if (data.Length == 32)
                {
                    return(Encoding.UTF8.GetString(data));
                }
                return(StringTool.EncodeHex(data).ToLower());
            }
            }
            auxConv.ConvertValue(reader, TypeStorage.String, auxHolder);
            return(auxHolder.GetString());
        }
示例#7
0
 public BedRecordAdapter()
 {
     m_convertor = new BedValueConvertor(new DataFormatSettings());
     m_value     = new BedValueHolder();
 }