Beispiel #1
0
        /// <summary>
        /// 更新一条数据
        /// </summary>
        public bool Update(Model.LandAttribute model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("update LandAttribute set ");
            strSql.Append("LAName=@LAName,");
            strSql.Append("Status=@Status");
            strSql.Append(" where LAId=@LAId ");
            Database  db        = DatabaseFactory.CreateDatabase();
            DbCommand dbCommand = db.GetSqlStringCommand(strSql.ToString());

            db.AddInParameter(dbCommand, "LAId", DbType.Int32, model.LAId);
            db.AddInParameter(dbCommand, "LAName", DbType.String, model.LAName);
            db.AddInParameter(dbCommand, "Status", DbType.Byte, model.Status);
            int rows = db.ExecuteNonQuery(dbCommand);

            if (rows > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
Beispiel #2
0
        /// <summary>
        /// 对象实体绑定数据
        /// </summary>
        public Model.LandAttribute ReaderBind(IDataReader dataReader)
        {
            Model.LandAttribute model = new Model.LandAttribute();
            object ojb;

            ojb = dataReader["LAId"];
            if (ojb != null && ojb != DBNull.Value)
            {
                model.LAId = Convert.ToInt32(ojb);
            }
            model.LAName = dataReader["LAName"].ToString();
            ojb          = dataReader["Status"];
            if (ojb != null && ojb != DBNull.Value)
            {
                model.Status = Convert.ToInt32(ojb);
            }
            return(model);
        }
Beispiel #3
0
 /// <summary>
 /// 得到一个对象实体
 /// </summary>
 public Model.LandAttribute DataRowToModel(DataRow row)
 {
     Model.LandAttribute model = new Model.LandAttribute();
     if (row != null)
     {
         if (row["LAId"] != null && row["LAId"].ToString() != "")
         {
             model.LAId = Convert.ToInt32(row["LAId"].ToString());
         }
         if (row["LAName"] != null)
         {
             model.LAName = row["LAName"].ToString();
         }
         if (row["Status"] != null && row["Status"].ToString() != "")
         {
             model.Status = Convert.ToInt32(row["Status"].ToString());
         }
     }
     return(model);
 }
Beispiel #4
0
        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public Model.LandAttribute GetModel(int LAId)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("select LAId,LAName,Status from LandAttribute ");
            strSql.Append(" where LAId=@LAId ");
            Database  db        = DatabaseFactory.CreateDatabase();
            DbCommand dbCommand = db.GetSqlStringCommand(strSql.ToString());

            db.AddInParameter(dbCommand, "LAId", DbType.Int32, LAId);
            Model.LandAttribute model = null;
            using (IDataReader dataReader = db.ExecuteReader(dbCommand))
            {
                if (dataReader.Read())
                {
                    model = ReaderBind(dataReader);
                }
            }
            return(model);
        }
Beispiel #5
0
        /// <summary>
        /// 增加一条数据
        /// </summary>
        public int Add(Model.LandAttribute model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("insert into LandAttribute(");
            strSql.Append("LAName,Status)");

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

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

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