Пример #1
0
        /// <summary>
        /// 更新一条数据
        /// </summary>
        public bool Update(ECommerce.Admin.Model.OrgArea model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("update OrgArea set ");
            strSql.Append("AreaName=@AreaName,");
            strSql.Append("AreaLevel=@AreaLevel,");
            strSql.Append("ParentId=@ParentId,");
            strSql.Append("Status=@Status");
            strSql.Append(" where AreaId=@AreaId ");
            Database  db        = DatabaseFactory.CreateDatabase();
            DbCommand dbCommand = db.GetSqlStringCommand(strSql.ToString());

            db.AddInParameter(dbCommand, "AreaId", DbType.AnsiString, model.AreaId);
            db.AddInParameter(dbCommand, "AreaName", DbType.String, model.AreaName);
            db.AddInParameter(dbCommand, "AreaLevel", DbType.Int32, model.AreaLevel);
            db.AddInParameter(dbCommand, "ParentId", DbType.AnsiString, model.ParentId);
            db.AddInParameter(dbCommand, "Status", DbType.Byte, model.Status);
            int rows = db.ExecuteNonQuery(dbCommand);

            if (rows > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
Пример #2
0
 /// <summary>
 /// 得到一个对象实体
 /// </summary>
 public ECommerce.Admin.Model.OrgArea DataRowToModel(DataRow row)
 {
     ECommerce.Admin.Model.OrgArea model=new ECommerce.Admin.Model.OrgArea();
     if (row != null)
     {
         if(row["AreaId"]!=null)
         {
             model.AreaId=row["AreaId"].ToString();
         }
         if(row["AreaName"]!=null)
         {
             model.AreaName=row["AreaName"].ToString();
         }
         if(row["AreaLevel"]!=null && row["AreaLevel"].ToString()!="")
         {
             model.AreaLevel=Convert.ToInt32(row["AreaLevel"].ToString());
         }
         if(row["ParentId"]!=null)
         {
             model.ParentId=row["ParentId"].ToString();
         }
         if(row["Status"]!=null && row["Status"].ToString()!="")
         {
             model.Status=Convert.ToInt32(row["Status"].ToString());
         }
     }
     return model;
 }
Пример #3
0
        /// <summary>
        /// 增加一条数据
        /// </summary>
        public bool Add(ECommerce.Admin.Model.OrgArea model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("insert into OrgArea(");
            strSql.Append("AreaId,AreaName,AreaLevel,ParentId,Status)");

            strSql.Append(" values (");
            strSql.Append("@AreaId,@AreaName,@AreaLevel,@ParentId,@Status)");
            Database  db        = DatabaseFactory.CreateDatabase();
            DbCommand dbCommand = db.GetSqlStringCommand(strSql.ToString());

            db.AddInParameter(dbCommand, "AreaId", DbType.AnsiString, model.AreaId);
            db.AddInParameter(dbCommand, "AreaName", DbType.String, model.AreaName);
            db.AddInParameter(dbCommand, "AreaLevel", DbType.Int32, model.AreaLevel);
            db.AddInParameter(dbCommand, "ParentId", DbType.AnsiString, model.ParentId);
            db.AddInParameter(dbCommand, "Status", DbType.Byte, model.Status);
            int    result;
            object obj = db.ExecuteNonQuery(dbCommand);

            if (!int.TryParse(obj.ToString(), out result))
            {
                return(false);
            }
            return(true);
        }
Пример #4
0
 /// <summary>
 /// 得到一个对象实体
 /// </summary>
 public ECommerce.Admin.Model.OrgArea DataRowToModel(DataRow row)
 {
     ECommerce.Admin.Model.OrgArea model = new ECommerce.Admin.Model.OrgArea();
     if (row != null)
     {
         if (row["AreaId"] != null)
         {
             model.AreaId = row["AreaId"].ToString();
         }
         if (row["AreaName"] != null)
         {
             model.AreaName = row["AreaName"].ToString();
         }
         if (row["AreaLevel"] != null && row["AreaLevel"].ToString() != "")
         {
             model.AreaLevel = Convert.ToInt32(row["AreaLevel"].ToString());
         }
         if (row["ParentId"] != null)
         {
             model.ParentId = row["ParentId"].ToString();
         }
         if (row["Status"] != null && row["Status"].ToString() != "")
         {
             model.Status = Convert.ToInt32(row["Status"].ToString());
         }
     }
     return(model);
 }
Пример #5
0
        /// <summary>
        /// 对象实体绑定数据
        /// </summary>
        public ECommerce.Admin.Model.OrgArea ReaderBind(IDataReader dataReader)
        {
            ECommerce.Admin.Model.OrgArea model = new ECommerce.Admin.Model.OrgArea();
            object ojb;

            model.AreaId   = dataReader["AreaId"].ToString();
            model.AreaName = dataReader["AreaName"].ToString();
            ojb            = dataReader["AreaLevel"];
            if (ojb != null && ojb != DBNull.Value)
            {
                model.AreaLevel = Convert.ToInt32(ojb);
            }
            model.ParentId = dataReader["ParentId"].ToString();
            ojb            = dataReader["Status"];
            if (ojb != null && ojb != DBNull.Value)
            {
                model.Status = Convert.ToInt32(ojb);
            }
            return(model);
        }
Пример #6
0
        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public ECommerce.Admin.Model.OrgArea GetModel(string AreaId)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("select AreaId,AreaName,AreaLevel,ParentId,Status from OrgArea ");
            strSql.Append(" where AreaId=@AreaId ");
            Database  db        = DatabaseFactory.CreateDatabase();
            DbCommand dbCommand = db.GetSqlStringCommand(strSql.ToString());

            db.AddInParameter(dbCommand, "AreaId", DbType.AnsiString, AreaId);
            ECommerce.Admin.Model.OrgArea model = null;
            using (IDataReader dataReader = db.ExecuteReader(dbCommand))
            {
                if (dataReader.Read())
                {
                    model = ReaderBind(dataReader);
                }
            }
            return(model);
        }
Пример #7
0
 /// <summary>
 /// 对象实体绑定数据
 /// </summary>
 public ECommerce.Admin.Model.OrgArea ReaderBind(IDataReader dataReader)
 {
     ECommerce.Admin.Model.OrgArea model=new ECommerce.Admin.Model.OrgArea();
     object ojb;
     model.AreaId=dataReader["AreaId"].ToString();
     model.AreaName=dataReader["AreaName"].ToString();
     ojb = dataReader["AreaLevel"];
     if(ojb != null && ojb != DBNull.Value)
     {
         model.AreaLevel=Convert.ToInt32(ojb);
     }
     model.ParentId=dataReader["ParentId"].ToString();
     ojb = dataReader["Status"];
     if(ojb != null && ojb != DBNull.Value)
     {
         model.Status=Convert.ToInt32(ojb);
     }
     return model;
 }