예제 #1
0
        /// <summary>
        /// 获得数据列表
        /// </summary>
        public List <RelaProductModel> GetModelList(string strWhere)
        {
            DataSet ds = dal.GetList(strWhere);
            List <RelaProductModel> modelList = new List <RelaProductModel>();
            int rowsCount = ds.Tables[0].Rows.Count;

            if (rowsCount > 0)
            {
                RelaProductModel model;
                for (int n = 0; n < rowsCount; n++)
                {
                    model = new RelaProductModel();
                    if (ds.Tables[0].Rows[n]["ProductId"].ToString() != "")
                    {
                        model.ProductId = int.Parse(ds.Tables[0].Rows[n]["ProductId"].ToString());
                    }
                    if (ds.Tables[0].Rows[n]["RelaProductId"].ToString() != "")
                    {
                        model.RelaProductId = int.Parse(ds.Tables[0].Rows[n]["RelaProductId"].ToString());
                    }
                    modelList.Add(model);
                }
            }
            return(modelList);
        }
예제 #2
0
        /// <summary>
        ///  更新一条数据
        /// </summary>
        public void Update(RelaProductModel model)
        {
            DbCommand dbCommand = dbw.GetStoredProcCommand("UP_pdRelaProduct_Update");

            dbw.AddInParameter(dbCommand, "ProductId", DbType.Int32, model.ProductId);
            dbw.AddInParameter(dbCommand, "RelaProductId", DbType.Int32, model.RelaProductId);
            dbw.ExecuteNonQuery(dbCommand);
        }
예제 #3
0
        /// <summary>
        /// 对象实体绑定数据
        /// </summary>
        public RelaProductModel ReaderBind(IDataReader dataReader)
        {
            RelaProductModel model = new RelaProductModel();
            object           ojb;

            ojb = dataReader["ProductId"];
            if (ojb != null && ojb != DBNull.Value)
            {
                model.ProductId = (int)ojb;
            }
            ojb = dataReader["RelaProductId"];
            if (ojb != null && ojb != DBNull.Value)
            {
                model.RelaProductId = (int)ojb;
            }
            return(model);
        }
예제 #4
0
        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public RelaProductModel GetModel(int ProductId, int RelaProductId)
        {
            DbCommand dbCommand = dbr.GetStoredProcCommand("UP_pdRelaProduct_GetModel");

            dbr.AddInParameter(dbCommand, "ProductId", DbType.Int32, ProductId);
            dbr.AddInParameter(dbCommand, "RelaProductId", DbType.Int32, RelaProductId);

            RelaProductModel model = null;

            using (IDataReader dataReader = dbr.ExecuteReader(dbCommand))
            {
                if (dataReader.Read())
                {
                    model = ReaderBind(dataReader);
                }
            }
            return(model);
        }
예제 #5
0
 /// <summary>
 /// 更新一条数据
 /// </summary>
 public void Update(RelaProductModel model)
 {
     dal.Update(model);
 }
예제 #6
0
 /// <summary>
 /// 增加一条数据
 /// </summary>
 public void Add(RelaProductModel model)
 {
     dal.Add(model);
 }