Ejemplo n.º 1
0
        /// <summary>
        /// 对象实体绑定数据
        /// </summary>
        public ManagementCenter.Model.UM_Functions ReaderBind(IDataReader dataReader)
        {
            ManagementCenter.Model.UM_Functions model = new ManagementCenter.Model.UM_Functions();
            object ojb;

            ojb = dataReader["FunctionID"];
            if (ojb != null && ojb != DBNull.Value)
            {
                model.FunctionID = (int)ojb;
            }
            model.FunctionName = dataReader["FunctionName"].ToString();
            return(model);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// 更新一条数据
        /// </summary>
        public void Update(ManagementCenter.Model.UM_Functions model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("update UM_Functions set ");
            strSql.Append("FunctionName=@FunctionName");
            strSql.Append(" where FunctionID=@FunctionID ");
            Database  db        = DatabaseFactory.CreateDatabase();
            DbCommand dbCommand = db.GetSqlStringCommand(strSql.ToString());

            db.AddInParameter(dbCommand, "FunctionID", DbType.Int32, model.FunctionID);
            db.AddInParameter(dbCommand, "FunctionName", DbType.String, model.FunctionName);
            db.ExecuteNonQuery(dbCommand);
        }
Ejemplo n.º 3
0
        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public ManagementCenter.Model.UM_Functions GetModel(int FunctionID)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("select FunctionID,FunctionName from UM_Functions ");
            strSql.Append(" where FunctionID=@FunctionID ");
            Database  db        = DatabaseFactory.CreateDatabase();
            DbCommand dbCommand = db.GetSqlStringCommand(strSql.ToString());

            db.AddInParameter(dbCommand, "FunctionID", DbType.Int32, FunctionID);
            ManagementCenter.Model.UM_Functions model = null;
            using (IDataReader dataReader = db.ExecuteReader(dbCommand))
            {
                if (dataReader.Read())
                {
                    model = ReaderBind(dataReader);
                }
            }
            return(model);
        }
Ejemplo n.º 4
0
        /// <summary>
        /// 增加一条数据
        /// </summary>
        public int Add(ManagementCenter.Model.UM_Functions model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("insert into UM_Functions(");
            strSql.Append("FunctionName)");

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

            db.AddInParameter(dbCommand, "FunctionName", DbType.String, model.FunctionName);
            int    result;
            object obj = db.ExecuteScalar(dbCommand);

            if (!int.TryParse(obj.ToString(), out result))
            {
                return(0);
            }
            return(result);
        }