/// <summary>
        /// 增加一条数据
        /// </summary>
        public int Add(ManagementCenter.Model.CM_FuseTimesection model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("insert into CM_FuseTimesection(");
            strSql.Append("CommodityCode,StartTime,EndTime)");

            strSql.Append(" values (");
            strSql.Append("@CommodityCode,@StartTime,@EndTime)");
            strSql.Append(";select @@IDENTITY");
            Database  db        = DatabaseFactory.CreateDatabase();
            DbCommand dbCommand = db.GetSqlStringCommand(strSql.ToString());

            db.AddInParameter(dbCommand, "CommodityCode", DbType.String, model.CommodityCode);
            db.AddInParameter(dbCommand, "StartTime", DbType.DateTime, model.StartTime);
            db.AddInParameter(dbCommand, "EndTime", DbType.DateTime, model.EndTime);
            int    result;
            object obj = db.ExecuteScalar(dbCommand);

            if (!int.TryParse(obj.ToString(), out result))
            {
                return(0);
            }
            return(result);
        }
        /// <summary>
        /// 更新一条数据
        /// </summary>
        public bool Update(ManagementCenter.Model.CM_FuseTimesection model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("update CM_FuseTimesection set ");
            strSql.Append("CommodityCode=@CommodityCode,");
            strSql.Append("StartTime=@StartTime,");
            strSql.Append("EndTime=@EndTime");
            strSql.Append(" where TimesectionID=@TimesectionID ");
            Database  db        = DatabaseFactory.CreateDatabase();
            DbCommand dbCommand = db.GetSqlStringCommand(strSql.ToString());

            db.AddInParameter(dbCommand, "TimesectionID", DbType.Int32, model.TimesectionID);
            db.AddInParameter(dbCommand, "CommodityCode", DbType.String, model.CommodityCode);
            db.AddInParameter(dbCommand, "StartTime", DbType.DateTime, model.StartTime);
            db.AddInParameter(dbCommand, "EndTime", DbType.DateTime, model.EndTime);
            db.ExecuteNonQuery(dbCommand);
            return(true);
        }
        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public ManagementCenter.Model.CM_FuseTimesection GetModel(int TimesectionID)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("select TimesectionID,CommodityCode,StartTime,EndTime from CM_FuseTimesection ");
            strSql.Append(" where TimesectionID=@TimesectionID ");
            Database  db        = DatabaseFactory.CreateDatabase();
            DbCommand dbCommand = db.GetSqlStringCommand(strSql.ToString());

            db.AddInParameter(dbCommand, "TimesectionID", DbType.Int32, TimesectionID);
            ManagementCenter.Model.CM_FuseTimesection model = null;
            using (IDataReader dataReader = db.ExecuteReader(dbCommand))
            {
                if (dataReader.Read())
                {
                    model = ReaderBind(dataReader);
                }
            }
            return(model);
        }
        /// <summary>
        /// 对象实体绑定数据
        /// </summary>
        public ManagementCenter.Model.CM_FuseTimesection ReaderBind(IDataReader dataReader)
        {
            ManagementCenter.Model.CM_FuseTimesection model = new ManagementCenter.Model.CM_FuseTimesection();
            object ojb;

            ojb = dataReader["TimesectionID"];
            if (ojb != null && ojb != DBNull.Value)
            {
                model.TimesectionID = (int)ojb;
            }
            model.CommodityCode = dataReader["CommodityCode"].ToString();
            ojb = dataReader["StartTime"];
            if (ojb != null && ojb != DBNull.Value)
            {
                model.StartTime = (DateTime)ojb;
            }
            ojb = dataReader["EndTime"];
            if (ojb != null && ojb != DBNull.Value)
            {
                model.EndTime = (DateTime)ojb;
            }
            return(model);
        }