WEB开发网
开发学院软件开发C语言 个人开发框架总结(一) 阅读

个人开发框架总结(一)

 2009-05-05 08:27:23 来源:WEB开发网   
核心提示: 这样,每一个类就好维护了,个人开发框架总结(一)(3),Oracle就使用OracleConnection,OleDb就使用OleDbConnection,比如在使用添加或修改的时候,可以这样使用dataHelper.ExecuteNonQuery(params.Format("

这样,每一个类就好维护了,Oracle就使用OracleConnection,OleDb就使用OleDbConnection。

Parameter 存储过程参数类,这跟System.Data里的差不多,都是实现同样的一个功能,只是说使用这个的时候,ParameterName不用具体的加入@或:这样的前缀。

ParameterCollection 存储过程参数集合类,这里面特别的有几个方法

FromDataModel 从模型转换为存储参数。可以根据具体的模型,将所有属性转换为存储过程参数,以为添加或修改作准备。

Format 可以格式化Sql查询语句,比如在使用添加或修改的时候,可以这样使用

dataHelper.ExecuteNonQuery(params.Format("insert into table({0}) values({1})"), params);

dataHelper.ExecuteNonQuery(params.Format("update table set {0}"), params);

BaseModel 数据模型基类,所有的数据模型都是继承这个类,如TB_BUY_BILL.cs

using System;
using FaibClass.Data;

namespace WindowsApplication1
{
    /// <summary>
    /// 模型类
    /// </summary>
    [Serializable]
    public class TB_BUY_BILL : BaseModel
    {
        #region 表映射
        /// <summary>
        /// 表名称
        /// </summary>
        public override string TableName
        {
            get { return "TB_BUY_BILL"; }
        }
        /// <summary>
        /// 表名称
        /// </summary>
        public static string _TableName = "TB_BUY_BILL";
        /// <summary>
        /// 主键
        /// </summary>
        public override string PrimaryKey
        {
            get { return "BUY_BILL_ID"; }
        }
        /// <summary>
        /// 主键
        /// </summary>
        public static string _PrimaryKey = "BUY_BILL_ID";

        public override DataColumn GetDataColumn(string ColumnName)
        {
            DataColumn column = new DataColumn();
            switch (ColumnName)
            {

                case "BUY_BILL_ID":
                    column.ColumnName = "BUY_BILL_ID";
                    column.ColumnSize = 200;
                    column.DbType = 16;
                    column.IsPrimaryKey = true;
                    column.Precision = 0;
                    column.Scale = 0;
                    return column;

                case "BILL_TYPE":
                    column.ColumnName = "BILL_TYPE";
                    column.ColumnSize = 0;
                    column.DbType = 10;
                    column.IsPrimaryKey = false;
                    column.Precision = 0;
                    column.Scale = 0;
                    return column;

                case "BILL_NO":
                    column.ColumnName = "BILL_NO";
                    column.ColumnSize = 200;
                    column.DbType = 16;
                    column.IsPrimaryKey = false;
                    column.Precision = 0;
                    column.Scale = 0;
                    return column;

                case "DEPARTMENT_NAME":
                    column.ColumnName = "DEPARTMENT_NAME";
                    column.ColumnSize = 200;
                    column.DbType = 16;
                    column.IsPrimaryKey = false;
                    column.Precision = 0;
                    column.Scale = 0;
                    return column;

                case "SALED_AMOUNT":
                    column.ColumnName = "DEPARTMENT_NAME";
                    column.ColumnSize = 0;
                    column.DbType = 11;
                    column.IsPrimaryKey = false;
                    column.Precision = 0;
                    column.Scale = 0;
                    return column;

                case "CONTRACT_AMOUNT":
                    column.ColumnName = "CONTRACT_AMOUNT";
                    column.ColumnSize = 0;
                    column.DbType = 11;
                    column.IsPrimaryKey = false;
                    column.Precision = 0;
                    column.Scale = 0;
                    return column;

            }
            return null;
        }
        #endregion

        #region 字段常量

        public static string _BUY_BILL_ID = "BUY_BILL_ID";
        public static string _BILL_NO = "BILL_NO";
        public static string _BILL_TYPE = "BILL_TYPE";
        public static string _DEPARTMENT_NAME = "DEPARTMENT_NAME";
        public static string _SALED_AMOUNT = "SALED_AMOUNT";
        public static string _CONTRACT_AMOUNT = "CONTRACT_AMOUNT";
        #endregion

        #region 成员

        private string m_BUY_BILL_ID;
        private BILL_TYPE m_BILL_TYPE;
        private string m_BILL_NO;
        private string m_DEPARTMENT_NAME;
        private decimal m_SALED_AMOUNT;
        private decimal m_CONTRACT_AMOUNT;
        #endregion

        #region 属性

        public string BUY_BILL_ID
        {
            get { return m_BUY_BILL_ID; }
            set { m_BUY_BILL_ID = value; }
        }

        public BILL_TYPE BILL_TYPE
        {
            get { return m_BILL_TYPE; }
            set { m_BILL_TYPE = value; }
        }

        public string BILL_NO
        {
            get { return m_BILL_NO; }
            set { m_BILL_NO = value; }
        }

        public string DEPARTMENT_NAME
        {
            get { return m_DEPARTMENT_NAME; }
            set { m_DEPARTMENT_NAME = value; }
        }

        public decimal SALED_AMOUNT
        {
            get { return m_SALED_AMOUNT; }
            set { m_SALED_AMOUNT = value; }
        }

        public decimal CONTRACT_AMOUNT
        {
            get { return m_CONTRACT_AMOUNT; }
            set { m_CONTRACT_AMOUNT = value; }
        }

        #endregion
    }

    public enum BILL_TYPE
    {
        [EnumText("电子")]
        ELE = 0,
        [EnumText("手工")]
        MAN = 1,
    }

    public enum BILL_STATE
    {
        [EnumText("暂存")]
        NoSave = 0,
        [EnumText("已保存")]
        Saved = 1,
    }

    /// <summary>
    /// 集合类
    /// </summary>
    [Serializable]
    public class TB_BUY_BILLs : DataModelList<TB_BUY_BILL>
    {
    }
}

上一页  1 2 3 4 5  下一页

Tags:个人 开发 框架

编辑录入:爽爽 [复制链接] [打 印]
赞助商链接