数据访问层——字段的封装

一个对表格字段的封装类
调试环境:Visual Stdio 2005,C#.net
/// <summary>
/// 字段类型数据
/// </summary>
public class DBFieldInfo
{
    private String fieldName;
    private SqlDbType fieldType;
    private int fieldSize;
    private object fieldValue;
    private bool isChanged;
    private static int index = 1;
    /// <summary>
    /// 构造默认字段(Name:field00001,Type:VarChar,Size:100,Value:"")
    /// </summary>
    public DBFieldInfo()
    {
        fieldName = "field" + index.ToString("00000");
        fieldType = SqlDbType.VarChar;
        fieldSize = 100;
        fieldValue = "";
        isChanged = false;
        index++;
    }
    /// <summary>
    /// 构造指定字段
    /// </summary>
    public DBFieldInfo(string fieldName, SqlDbType fieldType)
    {
        this.fieldName = fieldName;
        this.fieldType = fieldType;
        this.fieldValue = null;
        this.isChanged = false;
    }
    /// <summary>
    /// 构造指定字段
    /// </summary>
    public DBFieldInfo(string fieldName, SqlDbType fieldType, object fieldValue)
    {
        this.fieldName = fieldName;
        this.fieldType = fieldType;
        this.fieldValue = fieldValue;
        this.isChanged = false;
    }
    /// <summary>
    /// 构造指定字段
    /// </summary>
    public DBFieldInfo(string fieldName, SqlDbType fieldType, int fieldSize)
    {
        this.fieldName = fieldName;
        this.fieldType = fieldType;
        this.fieldSize = fieldSize;
        this.fieldValue = null;
        this.isChanged = false;
    }
    /// <summary>
    /// 构造指定字段
    /// </summary>
    public DBFieldInfo(string fieldName, SqlDbType fieldType, int fieldSize, object fieldValue)
    {
        this.fieldName = fieldName;
        this.fieldType = fieldType;
        this.fieldSize = fieldSize;
        this.fieldValue = fieldValue;
        this.isChanged = false;
    }
    /// <summary>
    /// 字段名
    /// </summary>
    public String FieldName
    {
        get {return this.fieldName;}
        set {this.fieldName=value;}
    }
    /// <summary>
    /// 字段类型
    /// </summary>
    public SqlDbType FieldType
    {
        get { return this.fieldType; }
        set { this.fieldType = value; }
    }
    /// <summary>
    /// 字段大小
    /// </summary>
    public int FieldSize
    {
        get { return this.fieldSize; }
        set { this.fieldSize = value; }
    }
    /// <summary>
    /// 字段值
    /// </summary>
    public object FieldValue
    {
        get { return this.fieldValue; }
        set
        {
            this.fieldValue = value;
            isChanged = true;
        }
    }
    /// <summary>
    /// 字段内容是否被修改
    /// </summary>
    public bool IsChanged
    {
        get { return this.isChanged; }
        set { this.isChanged = value; }
    }
}
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值